@@ -16,11 +16,28 @@ import PaginationItem from './PaginationItem'
16
16
*/
17
17
const Pagination = React . forwardRef ( function ( props , ref ) {
18
18
const {
19
- 'aria-label' : ariaLabel ,
20
- boundaryRange,
19
+ 'aria-label' : ariaLabel = 'Pagination Navigation' ,
20
+ boundaryRange = 1 ,
21
21
disabled,
22
- ellipsisItem,
23
- siblingRange,
22
+ ellipsisItem = '...' ,
23
+ firstItem = {
24
+ 'aria-label' : 'First item' ,
25
+ content : '«' ,
26
+ } ,
27
+ lastItem = {
28
+ 'aria-label' : 'Last item' ,
29
+ content : '»' ,
30
+ } ,
31
+ nextItem = {
32
+ 'aria-label' : 'Next item' ,
33
+ content : '⟩' ,
34
+ } ,
35
+ pageItem = { } ,
36
+ prevItem = {
37
+ 'aria-label' : 'Previous item' ,
38
+ content : '⟨' ,
39
+ } ,
40
+ siblingRange = 1 ,
24
41
totalPages,
25
42
} = props
26
43
const [ activePage , setActivePage ] = useAutoControlledValue ( {
@@ -63,10 +80,19 @@ const Pagination = React.forwardRef(function (props, ref) {
63
80
} )
64
81
const rest = getUnhandledProps ( Pagination , props )
65
82
83
+ const paginationItemTypes = {
84
+ firstItem,
85
+ lastItem,
86
+ ellipsisItem,
87
+ nextItem,
88
+ pageItem,
89
+ prevItem,
90
+ }
91
+
66
92
return (
67
93
< Menu { ...rest } aria-label = { ariaLabel } pagination role = 'navigation' ref = { ref } >
68
94
{ _ . map ( items , ( { active, type, value } ) =>
69
- PaginationItem . create ( props [ type ] , {
95
+ PaginationItem . create ( paginationItemTypes [ type ] , {
70
96
defaultProps : {
71
97
content : value ,
72
98
disabled,
@@ -129,30 +155,6 @@ Pagination.propTypes = {
129
155
totalPages : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . string ] ) . isRequired ,
130
156
}
131
157
132
- Pagination . defaultProps = {
133
- 'aria-label' : 'Pagination Navigation' ,
134
- boundaryRange : 1 ,
135
- ellipsisItem : '...' ,
136
- firstItem : {
137
- 'aria-label' : 'First item' ,
138
- content : '«' ,
139
- } ,
140
- lastItem : {
141
- 'aria-label' : 'Last item' ,
142
- content : '»' ,
143
- } ,
144
- nextItem : {
145
- 'aria-label' : 'Next item' ,
146
- content : '⟩' ,
147
- } ,
148
- pageItem : { } ,
149
- prevItem : {
150
- 'aria-label' : 'Previous item' ,
151
- content : '⟨' ,
152
- } ,
153
- siblingRange : 1 ,
154
- }
155
-
156
158
Pagination . Item = PaginationItem
157
159
158
160
export default Pagination
0 commit comments