@instructure/ui-pagination 11.6.0 → 11.6.1-snapshot-129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -296
- package/es/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/index.js +2 -2
- package/es/Pagination/{PaginationButton → v1/PaginationButton}/index.js +1 -1
- package/es/Pagination/{PaginationPageInput → v1/PaginationPageInput}/index.js +1 -1
- package/es/Pagination/{index.js → v1/index.js} +1 -1
- package/es/Pagination/v2/PaginationArrowButton/index.js +109 -0
- package/es/Pagination/v2/PaginationArrowButton/props.js +30 -0
- package/es/Pagination/v2/PaginationButton/index.js +77 -0
- package/es/Pagination/v2/PaginationButton/props.js +29 -0
- package/es/Pagination/v2/PaginationPageInput/index.js +189 -0
- package/es/Pagination/v2/PaginationPageInput/props.js +26 -0
- package/es/Pagination/v2/PaginationPageInput/styles.js +56 -0
- package/es/Pagination/v2/index.js +481 -0
- package/es/Pagination/v2/props.js +26 -0
- package/es/Pagination/v2/styles.js +58 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/es/exports/b.js +24 -0
- package/lib/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/index.js +8 -8
- package/lib/Pagination/{PaginationButton → v1/PaginationButton}/index.js +2 -2
- package/lib/Pagination/{PaginationPageInput → v1/PaginationPageInput}/index.js +2 -2
- package/lib/Pagination/{index.js → v1/index.js} +6 -6
- package/lib/Pagination/v2/PaginationArrowButton/index.js +115 -0
- package/lib/Pagination/v2/PaginationArrowButton/props.js +35 -0
- package/lib/Pagination/v2/PaginationButton/index.js +83 -0
- package/lib/Pagination/v2/PaginationButton/props.js +34 -0
- package/lib/Pagination/v2/PaginationPageInput/index.js +194 -0
- package/lib/Pagination/v2/PaginationPageInput/props.js +31 -0
- package/lib/Pagination/v2/PaginationPageInput/styles.js +62 -0
- package/lib/Pagination/v2/index.js +496 -0
- package/lib/Pagination/v2/props.js +31 -0
- package/lib/Pagination/v2/styles.js +64 -0
- package/lib/{index.js → exports/a.js} +3 -3
- package/lib/exports/b.js +18 -0
- package/package.json +48 -25
- package/src/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/index.tsx +2 -2
- package/src/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/props.ts +1 -1
- package/src/Pagination/{PaginationButton → v1/PaginationButton}/index.tsx +1 -1
- package/src/Pagination/{PaginationButton → v1/PaginationButton}/props.ts +1 -1
- package/src/Pagination/{PaginationPageInput → v1/PaginationPageInput}/index.tsx +1 -1
- package/src/Pagination/{index.tsx → v1/index.tsx} +1 -1
- package/src/Pagination/v2/PaginationArrowButton/index.tsx +120 -0
- package/src/Pagination/v2/PaginationArrowButton/props.ts +74 -0
- package/src/Pagination/v2/PaginationButton/index.tsx +82 -0
- package/src/Pagination/v2/PaginationButton/props.ts +77 -0
- package/src/Pagination/v2/PaginationPageInput/index.tsx +242 -0
- package/src/Pagination/v2/PaginationPageInput/props.ts +95 -0
- package/src/Pagination/v2/PaginationPageInput/styles.ts +62 -0
- package/src/Pagination/v2/README.md +417 -0
- package/src/Pagination/v2/index.tsx +665 -0
- package/src/Pagination/v2/props.ts +245 -0
- package/src/Pagination/v2/styles.ts +64 -0
- package/src/exports/a.ts +29 -0
- package/src/exports/b.ts +29 -0
- package/tsconfig.build.json +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Pagination/v1/PaginationArrowButton/index.d.ts.map +1 -0
- package/types/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/props.d.ts +1 -1
- package/types/Pagination/v1/PaginationArrowButton/props.d.ts.map +1 -0
- package/types/Pagination/v1/PaginationButton/index.d.ts.map +1 -0
- package/types/Pagination/{PaginationButton → v1/PaginationButton}/props.d.ts +1 -1
- package/types/Pagination/v1/PaginationButton/props.d.ts.map +1 -0
- package/types/Pagination/v1/PaginationPageInput/index.d.ts.map +1 -0
- package/types/Pagination/v1/PaginationPageInput/props.d.ts.map +1 -0
- package/types/Pagination/v1/PaginationPageInput/styles.d.ts.map +1 -0
- package/types/Pagination/v1/PaginationPageInput/theme.d.ts.map +1 -0
- package/types/Pagination/v1/index.d.ts.map +1 -0
- package/types/Pagination/v1/props.d.ts.map +1 -0
- package/types/Pagination/v1/styles.d.ts.map +1 -0
- package/types/Pagination/v1/theme.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationArrowButton/index.d.ts +27 -0
- package/types/Pagination/v2/PaginationArrowButton/index.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationArrowButton/props.d.ts +17 -0
- package/types/Pagination/v2/PaginationArrowButton/props.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationButton/index.d.ts +26 -0
- package/types/Pagination/v2/PaginationButton/index.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationButton/props.d.ts +30 -0
- package/types/Pagination/v2/PaginationButton/props.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationPageInput/index.d.ts +50 -0
- package/types/Pagination/v2/PaginationPageInput/index.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationPageInput/props.d.ts +45 -0
- package/types/Pagination/v2/PaginationPageInput/props.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationPageInput/styles.d.ts +16 -0
- package/types/Pagination/v2/PaginationPageInput/styles.d.ts.map +1 -0
- package/types/Pagination/v2/index.d.ts +106 -0
- package/types/Pagination/v2/index.d.ts.map +1 -0
- package/types/Pagination/v2/props.d.ts +138 -0
- package/types/Pagination/v2/props.d.ts.map +1 -0
- package/types/Pagination/v2/styles.d.ts +16 -0
- package/types/Pagination/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +5 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +5 -0
- package/types/exports/b.d.ts.map +1 -0
- package/src/index.ts +0 -29
- package/types/Pagination/PaginationArrowButton/index.d.ts.map +0 -1
- package/types/Pagination/PaginationArrowButton/props.d.ts.map +0 -1
- package/types/Pagination/PaginationButton/index.d.ts.map +0 -1
- package/types/Pagination/PaginationButton/props.d.ts.map +0 -1
- package/types/Pagination/PaginationPageInput/index.d.ts.map +0 -1
- package/types/Pagination/PaginationPageInput/props.d.ts.map +0 -1
- package/types/Pagination/PaginationPageInput/styles.d.ts.map +0 -1
- package/types/Pagination/PaginationPageInput/theme.d.ts.map +0 -1
- package/types/Pagination/index.d.ts.map +0 -1
- package/types/Pagination/props.d.ts.map +0 -1
- package/types/Pagination/styles.d.ts.map +0 -1
- package/types/Pagination/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.d.ts.map +0 -1
- /package/es/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/props.js +0 -0
- /package/es/Pagination/{PaginationButton → v1/PaginationButton}/props.js +0 -0
- /package/es/Pagination/{PaginationPageInput → v1/PaginationPageInput}/props.js +0 -0
- /package/es/Pagination/{PaginationPageInput → v1/PaginationPageInput}/styles.js +0 -0
- /package/es/Pagination/{PaginationPageInput → v1/PaginationPageInput}/theme.js +0 -0
- /package/es/Pagination/{props.js → v1/props.js} +0 -0
- /package/es/Pagination/{styles.js → v1/styles.js} +0 -0
- /package/es/Pagination/{theme.js → v1/theme.js} +0 -0
- /package/lib/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/props.js +0 -0
- /package/lib/Pagination/{PaginationButton → v1/PaginationButton}/props.js +0 -0
- /package/lib/Pagination/{PaginationPageInput → v1/PaginationPageInput}/props.js +0 -0
- /package/lib/Pagination/{PaginationPageInput → v1/PaginationPageInput}/styles.js +0 -0
- /package/lib/Pagination/{PaginationPageInput → v1/PaginationPageInput}/theme.js +0 -0
- /package/lib/Pagination/{props.js → v1/props.js} +0 -0
- /package/lib/Pagination/{styles.js → v1/styles.js} +0 -0
- /package/lib/Pagination/{theme.js → v1/theme.js} +0 -0
- /package/src/Pagination/{PaginationPageInput → v1/PaginationPageInput}/props.ts +0 -0
- /package/src/Pagination/{PaginationPageInput → v1/PaginationPageInput}/styles.ts +0 -0
- /package/src/Pagination/{PaginationPageInput → v1/PaginationPageInput}/theme.ts +0 -0
- /package/src/Pagination/{README.md → v1/README.md} +0 -0
- /package/src/Pagination/{props.ts → v1/props.ts} +0 -0
- /package/src/Pagination/{styles.ts → v1/styles.ts} +0 -0
- /package/src/Pagination/{theme.ts → v1/theme.ts} +0 -0
- /package/types/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/index.d.ts +0 -0
- /package/types/Pagination/{PaginationButton → v1/PaginationButton}/index.d.ts +0 -0
- /package/types/Pagination/{PaginationPageInput → v1/PaginationPageInput}/index.d.ts +0 -0
- /package/types/Pagination/{PaginationPageInput → v1/PaginationPageInput}/props.d.ts +0 -0
- /package/types/Pagination/{PaginationPageInput → v1/PaginationPageInput}/styles.d.ts +0 -0
- /package/types/Pagination/{PaginationPageInput → v1/PaginationPageInput}/theme.d.ts +0 -0
- /package/types/Pagination/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/Pagination/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/Pagination/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Pagination/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
---
|
|
2
|
+
describes: Pagination
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
### NOTE
|
|
6
|
+
|
|
7
|
+
Pagination is in a state of transition. Its API has been expanded to allow
|
|
8
|
+
as close to zero config usage as possible, without introducing breaking changes to the previous methods.
|
|
9
|
+
|
|
10
|
+
The component is under review by the design team and it's possible we'll deprecate te "old" API in a
|
|
11
|
+
following version. If you're able to, please use the "new" API. Its documentation is on the top of this page.
|
|
12
|
+
|
|
13
|
+
One of the biggest improvement is that pagination now can handle large page numbers as well.
|
|
14
|
+
|
|
15
|
+
### Pagination
|
|
16
|
+
|
|
17
|
+
The pagination component provides props to handle most of the pagination use-cases. These following examples are the same as the "old" examples in behaviour, but with the "new" API
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
---
|
|
21
|
+
type: example
|
|
22
|
+
---
|
|
23
|
+
const Example = () => {
|
|
24
|
+
const [currentPage, setCurrentPage] = useState(1)
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Pagination
|
|
28
|
+
as="nav"
|
|
29
|
+
margin="small"
|
|
30
|
+
variant="compact"
|
|
31
|
+
labelNext="Next Page"
|
|
32
|
+
labelPrev="Previous Page"
|
|
33
|
+
currentPage={currentPage}
|
|
34
|
+
totalPageNumber={9}
|
|
35
|
+
onPageChange={(nextPage) => setCurrentPage(nextPage)}
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
render(<Example />)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
You can set any `totalPageNumber`, the component can handle it easily.\
|
|
44
|
+
Furthermore, you can set `siblingCount`, which indicates how many pages are visible on either side of the `currentPage` and the
|
|
45
|
+
`boundaryCount`, which indicates how many pages are visible in the beginning and end.\
|
|
46
|
+
Also, you can set `screenReaderLabelPageButton` to customize what a screenreader will announce when the button receives focus.
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
---
|
|
50
|
+
type: example
|
|
51
|
+
---
|
|
52
|
+
const Example = () => {
|
|
53
|
+
const [currentPage, setCurrentPage] = useState(1)
|
|
54
|
+
return (
|
|
55
|
+
<Pagination
|
|
56
|
+
as="nav"
|
|
57
|
+
margin="small"
|
|
58
|
+
variant="compact"
|
|
59
|
+
labelNext="Next Page"
|
|
60
|
+
labelPrev="Previous Page"
|
|
61
|
+
currentPage={currentPage}
|
|
62
|
+
totalPageNumber={100000}
|
|
63
|
+
onPageChange={(nextPage) => setCurrentPage(nextPage)}
|
|
64
|
+
siblingCount={3}
|
|
65
|
+
boundaryCount={2}
|
|
66
|
+
screenReaderLabelPageButton={(currentPage, totalPageNumber) =>
|
|
67
|
+
`Page ${currentPage} of ${totalPageNumber}`
|
|
68
|
+
}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
render(<Example />)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
You can only display 1000 pages at once.
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
---
|
|
80
|
+
type: example
|
|
81
|
+
---
|
|
82
|
+
const Example = () => {
|
|
83
|
+
const [currentPage, setCurrentPage] = useState(1)
|
|
84
|
+
return (
|
|
85
|
+
<Pagination
|
|
86
|
+
as="nav"
|
|
87
|
+
margin="small"
|
|
88
|
+
variant="full"
|
|
89
|
+
labelNext="Next Page"
|
|
90
|
+
labelPrev="Previous Page"
|
|
91
|
+
currentPage={currentPage}
|
|
92
|
+
totalPageNumber={100000}
|
|
93
|
+
onPageChange={(nextPage) => setCurrentPage(nextPage)}
|
|
94
|
+
siblingCount={3}
|
|
95
|
+
boundaryCount={2}
|
|
96
|
+
/>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
render(<Example />)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
You can override the default page rendering with `renderPageIndicator`.
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
---
|
|
107
|
+
type: example
|
|
108
|
+
---
|
|
109
|
+
const Example = () => {
|
|
110
|
+
const [currentPage, setCurrentPage] = useState(1)
|
|
111
|
+
|
|
112
|
+
const pageMap = ['A-G', 'H-J', 'K-M', 'N-Q', 'R-Z']
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<Pagination
|
|
116
|
+
as="nav"
|
|
117
|
+
margin="small"
|
|
118
|
+
variant="full"
|
|
119
|
+
labelNext="Next Page"
|
|
120
|
+
labelPrev="Previous Page"
|
|
121
|
+
currentPage={currentPage}
|
|
122
|
+
totalPageNumber={5}
|
|
123
|
+
onPageChange={(nextPage) => setCurrentPage(nextPage)}
|
|
124
|
+
siblingCount={5}
|
|
125
|
+
boundaryCount={0}
|
|
126
|
+
renderPageIndicator={(page) => pageMap[page - 1]}
|
|
127
|
+
/>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
render(<Example />)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The `variant="input"` prop will render Pagination with a NumberInput and all the arrow buttons.
|
|
135
|
+
|
|
136
|
+
```js
|
|
137
|
+
---
|
|
138
|
+
type: example
|
|
139
|
+
---
|
|
140
|
+
const Example = () => {
|
|
141
|
+
const [currentPage, setCurrentPage] = useState(1)
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<Pagination
|
|
145
|
+
as="nav"
|
|
146
|
+
margin="small"
|
|
147
|
+
variant="input"
|
|
148
|
+
labelNext="Next Page"
|
|
149
|
+
labelPrev="Previous Page"
|
|
150
|
+
currentPage={currentPage}
|
|
151
|
+
totalPageNumber={9}
|
|
152
|
+
onPageChange={(nextPage) => setCurrentPage(nextPage)}
|
|
153
|
+
/>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
render(<Example />)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Legacy examples
|
|
161
|
+
|
|
162
|
+
These provide possibly finer, but much more complicated control over the pagination component. They are still supported, but we recommend using the new API.
|
|
163
|
+
|
|
164
|
+
Renders available pages of content, and reacts to selection of another page.
|
|
165
|
+
Expects array of `Pagination.Page` children. Focus and announcement of page change is
|
|
166
|
+
the responsibility of your app.
|
|
167
|
+
|
|
168
|
+
If there are more than 5 pages, the `compact` variant truncates the page navigation
|
|
169
|
+
to show only the first, last, and pages surrounding the current page. At fewer than
|
|
170
|
+
5 pages, no next/previous arrow buttons will be shown, and all pages will be listed.
|
|
171
|
+
|
|
172
|
+
Provide an `onClick` to `Pagination.Page` to handle navigation.
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
---
|
|
176
|
+
type: example
|
|
177
|
+
---
|
|
178
|
+
class Example extends React.Component {
|
|
179
|
+
constructor (props) {
|
|
180
|
+
super(props)
|
|
181
|
+
this.state = { currentPage: 0 }
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
setPage (page) {
|
|
185
|
+
this.setState({ currentPage: page })
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
render () {
|
|
189
|
+
const pages = Array.from(Array(9)).map((v, i) => <Pagination.Page
|
|
190
|
+
key={i}
|
|
191
|
+
onClick={this.setPage.bind(this, i)}
|
|
192
|
+
current={i === this.state.currentPage}>
|
|
193
|
+
{i + 1}
|
|
194
|
+
</Pagination.Page>)
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<Pagination
|
|
198
|
+
as="nav"
|
|
199
|
+
margin="small"
|
|
200
|
+
variant="compact"
|
|
201
|
+
labelNext="Next Page"
|
|
202
|
+
labelPrev="Previous Page"
|
|
203
|
+
>
|
|
204
|
+
{pages}
|
|
205
|
+
</Pagination>
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
render(<Example />)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
You can handle endpoints that have a lot of pages by using a sparse array of children:
|
|
214
|
+
|
|
215
|
+
```js
|
|
216
|
+
---
|
|
217
|
+
type: example
|
|
218
|
+
---
|
|
219
|
+
class Example extends React.Component {
|
|
220
|
+
constructor (props) {
|
|
221
|
+
super(props)
|
|
222
|
+
this.state = { currentPage: 0 }
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
renderPage(pageIndex) {
|
|
226
|
+
return (
|
|
227
|
+
<Pagination.Page
|
|
228
|
+
key={pageIndex}
|
|
229
|
+
onClick={() => this.setState({ currentPage: pageIndex })}
|
|
230
|
+
current={pageIndex === this.state.currentPage}
|
|
231
|
+
>
|
|
232
|
+
{pageIndex + 1}
|
|
233
|
+
</Pagination.Page>
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
render () {
|
|
238
|
+
const {currentPage} = this.state
|
|
239
|
+
const pages = Array(100000)
|
|
240
|
+
pages[0] = this.renderPage(0)
|
|
241
|
+
pages[pages.length - 1] = this.renderPage(pages.length - 1)
|
|
242
|
+
const visiblePageRangeStart = Math.min(pages.length - 4, Math.max(currentPage - 1, 1))
|
|
243
|
+
const visiblePageRangeEnd = Math.min(currentPage + 4, pages.length - 1)
|
|
244
|
+
for (let i = visiblePageRangeStart; i < visiblePageRangeEnd; i++) {
|
|
245
|
+
pages[i] = this.renderPage(i)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return (
|
|
249
|
+
<Pagination
|
|
250
|
+
as="nav"
|
|
251
|
+
margin="small"
|
|
252
|
+
variant="compact"
|
|
253
|
+
labelNext="Next Page"
|
|
254
|
+
labelPrev="Previous Page"
|
|
255
|
+
>
|
|
256
|
+
{pages}
|
|
257
|
+
</Pagination>
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
render(<Example />)
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
If you instead provide an href to `Pagination.Page` it will render as a link.
|
|
266
|
+
|
|
267
|
+
```js
|
|
268
|
+
---
|
|
269
|
+
type: example
|
|
270
|
+
---
|
|
271
|
+
<Pagination variant="full" label="Jump to">
|
|
272
|
+
<Pagination.Page href="/pages/1" current>A-G</Pagination.Page>
|
|
273
|
+
<Pagination.Page href="/pages/2">H-J</Pagination.Page>
|
|
274
|
+
<Pagination.Page href="/pages/3">K-M</Pagination.Page>
|
|
275
|
+
<Pagination.Page href="/pages/3">N-Q</Pagination.Page>
|
|
276
|
+
<Pagination.Page href="/pages/3">R-Z</Pagination.Page>
|
|
277
|
+
</Pagination>
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
The `variant="input"` prop will render Pagination with a NumberInput and all the arrow buttons.
|
|
281
|
+
|
|
282
|
+
```js
|
|
283
|
+
---
|
|
284
|
+
type: example
|
|
285
|
+
---
|
|
286
|
+
class Example extends React.Component {
|
|
287
|
+
constructor (props) {
|
|
288
|
+
super(props)
|
|
289
|
+
this.state = { currentPage: 0 }
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
setPage (page) {
|
|
293
|
+
this.setState({ currentPage: page })
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
render () {
|
|
297
|
+
const pages = Array.from(Array(9)).map((v, i) => <Pagination.Page
|
|
298
|
+
key={i}
|
|
299
|
+
onClick={this.setPage.bind(this, i)}
|
|
300
|
+
current={i === this.state.currentPage}>
|
|
301
|
+
{i + 1}
|
|
302
|
+
</Pagination.Page>)
|
|
303
|
+
|
|
304
|
+
return (
|
|
305
|
+
<Pagination
|
|
306
|
+
as="nav"
|
|
307
|
+
margin="small"
|
|
308
|
+
variant="input"
|
|
309
|
+
labelFirst="First Page"
|
|
310
|
+
labelPrev="Previous Page"
|
|
311
|
+
labelNext="Next Page"
|
|
312
|
+
labelLast="Last Page"
|
|
313
|
+
>
|
|
314
|
+
{pages}
|
|
315
|
+
</Pagination>
|
|
316
|
+
)
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
render(<Example />)
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
The `withFirstAndLastButton` prop makes the "Jump to first" and "Jump to last" buttons appear. The `labelFirst` and `labelLast` props set the labels for these buttons.
|
|
324
|
+
|
|
325
|
+
The `showDisabledButtons` prop displays the unavailable navigation buttons as disabled instead of hiding them.
|
|
326
|
+
|
|
327
|
+
```js
|
|
328
|
+
---
|
|
329
|
+
type: example
|
|
330
|
+
---
|
|
331
|
+
class Example extends React.Component {
|
|
332
|
+
constructor (props) {
|
|
333
|
+
super(props)
|
|
334
|
+
this.state = {
|
|
335
|
+
currentPage: 0,
|
|
336
|
+
withFirstAndLastButton: true,
|
|
337
|
+
showDisabledButtons: true
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
setPage (page) {
|
|
342
|
+
this.setState({ currentPage: page })
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
render () {
|
|
346
|
+
const pages = Array.from(Array(9)).map((v, i) => <Pagination.Page
|
|
347
|
+
key={i}
|
|
348
|
+
onClick={this.setPage.bind(this, i)}
|
|
349
|
+
current={i === this.state.currentPage}>
|
|
350
|
+
{i + 1}
|
|
351
|
+
</Pagination.Page>)
|
|
352
|
+
|
|
353
|
+
return (
|
|
354
|
+
<div>
|
|
355
|
+
<FormFieldGroup description="Pagination Settings">
|
|
356
|
+
<Checkbox
|
|
357
|
+
checked={this.state.withFirstAndLastButton}
|
|
358
|
+
label="With First and Last buttons"
|
|
359
|
+
onChange={() => {
|
|
360
|
+
this.setState({ withFirstAndLastButton: !this.state.withFirstAndLastButton })
|
|
361
|
+
}}
|
|
362
|
+
/>
|
|
363
|
+
<Checkbox
|
|
364
|
+
checked={this.state.showDisabledButtons}
|
|
365
|
+
label="Show disabled buttons"
|
|
366
|
+
onChange={() => {
|
|
367
|
+
this.setState({ showDisabledButtons: !this.state.showDisabledButtons })
|
|
368
|
+
}}
|
|
369
|
+
/>
|
|
370
|
+
</FormFieldGroup>
|
|
371
|
+
|
|
372
|
+
<Pagination
|
|
373
|
+
as="nav"
|
|
374
|
+
margin="large small small"
|
|
375
|
+
variant="compact"
|
|
376
|
+
labelNext="Next Page"
|
|
377
|
+
labelPrev="Previous Page"
|
|
378
|
+
labelFirst="First Page"
|
|
379
|
+
labelLast="Last Page"
|
|
380
|
+
withFirstAndLastButton={ this.state.withFirstAndLastButton }
|
|
381
|
+
showDisabledButtons={ this.state.showDisabledButtons }
|
|
382
|
+
>
|
|
383
|
+
{pages}
|
|
384
|
+
</Pagination>
|
|
385
|
+
</div>
|
|
386
|
+
)
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
render(<Example />)
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Guidelines
|
|
394
|
+
|
|
395
|
+
```js
|
|
396
|
+
---
|
|
397
|
+
type: embed
|
|
398
|
+
---
|
|
399
|
+
<Guidelines>
|
|
400
|
+
<Figure recommendation="yes" title="Do">
|
|
401
|
+
<Figure.Item>Use for splitting up content or data into several pages</Figure.Item>
|
|
402
|
+
<Figure.Item>Use if there are more than 20 items displayed in one view</Figure.Item>
|
|
403
|
+
</Figure>
|
|
404
|
+
</Guidelines>
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
```js
|
|
408
|
+
---
|
|
409
|
+
type: embed
|
|
410
|
+
---
|
|
411
|
+
<Guidelines>
|
|
412
|
+
<Figure recommendation="a11y" title="Accessibility">
|
|
413
|
+
<Figure.Item>Ensure page links and the next/previous buttons are labeled correctly for screen readers</Figure.Item>
|
|
414
|
+
<Figure.Item>Use `screenReaderLabelPageButton` or `screenReaderLabelNumberInput` for better screenreader experience</Figure.Item>
|
|
415
|
+
</Figure>
|
|
416
|
+
</Guidelines>
|
|
417
|
+
```
|