@instructure/ui-pagination 8.13.1-snapshot.9 → 8.14.0

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/es/Pagination/PaginationArrowButton/index.js +36 -4
  3. package/es/Pagination/PaginationArrowButton/props.js +6 -3
  4. package/es/Pagination/PaginationButton/props.js +9 -2
  5. package/es/Pagination/PaginationLocator.js +4 -0
  6. package/es/Pagination/PaginationPageInput/PaginationPageInputLocator.js +35 -0
  7. package/es/Pagination/PaginationPageInput/index.js +208 -0
  8. package/es/Pagination/PaginationPageInput/props.js +35 -0
  9. package/es/Pagination/PaginationPageInput/styles.js +55 -0
  10. package/es/Pagination/PaginationPageInput/theme.js +40 -0
  11. package/es/Pagination/index.js +178 -52
  12. package/es/Pagination/props.js +32 -2
  13. package/lib/Pagination/PaginationArrowButton/index.js +39 -3
  14. package/lib/Pagination/PaginationArrowButton/props.js +6 -3
  15. package/lib/Pagination/PaginationButton/props.js +9 -2
  16. package/lib/Pagination/PaginationLocator.js +5 -0
  17. package/lib/Pagination/PaginationPageInput/PaginationPageInputLocator.js +46 -0
  18. package/lib/Pagination/PaginationPageInput/index.js +202 -0
  19. package/lib/Pagination/PaginationPageInput/props.js +46 -0
  20. package/lib/Pagination/PaginationPageInput/styles.js +63 -0
  21. package/lib/Pagination/PaginationPageInput/theme.js +48 -0
  22. package/lib/Pagination/index.js +179 -52
  23. package/lib/Pagination/props.js +32 -2
  24. package/package.json +23 -22
  25. package/src/Pagination/PaginationArrowButton/index.tsx +32 -4
  26. package/src/Pagination/PaginationArrowButton/props.ts +22 -6
  27. package/src/Pagination/PaginationButton/props.ts +18 -2
  28. package/src/Pagination/PaginationLocator.ts +5 -1
  29. package/src/Pagination/PaginationPageInput/PaginationPageInputLocator.ts +42 -0
  30. package/src/Pagination/PaginationPageInput/index.tsx +242 -0
  31. package/src/Pagination/PaginationPageInput/props.ts +112 -0
  32. package/src/Pagination/PaginationPageInput/styles.ts +60 -0
  33. package/src/Pagination/PaginationPageInput/theme.ts +46 -0
  34. package/src/Pagination/README.md +116 -0
  35. package/src/Pagination/index.tsx +213 -80
  36. package/src/Pagination/props.ts +53 -4
  37. package/tsconfig.build.json +26 -2
  38. package/tsconfig.build.tsbuildinfo +1 -0
  39. package/types/Pagination/PaginationArrowButton/PaginationArrowButtonLocator.d.ts +57 -56
  40. package/types/Pagination/PaginationArrowButton/PaginationArrowButtonLocator.d.ts.map +1 -1
  41. package/types/Pagination/PaginationArrowButton/index.d.ts +9 -4
  42. package/types/Pagination/PaginationArrowButton/index.d.ts.map +1 -1
  43. package/types/Pagination/PaginationArrowButton/props.d.ts +5 -3
  44. package/types/Pagination/PaginationArrowButton/props.d.ts.map +1 -1
  45. package/types/Pagination/PaginationButton/index.d.ts +2 -0
  46. package/types/Pagination/PaginationButton/index.d.ts.map +1 -1
  47. package/types/Pagination/PaginationButton/props.d.ts +1 -0
  48. package/types/Pagination/PaginationButton/props.d.ts.map +1 -1
  49. package/types/Pagination/PaginationLocator.d.ts +944 -234
  50. package/types/Pagination/PaginationLocator.d.ts.map +1 -1
  51. package/types/Pagination/PaginationPageInput/PaginationPageInputLocator.d.ts +581 -0
  52. package/types/Pagination/PaginationPageInput/PaginationPageInputLocator.d.ts.map +1 -0
  53. package/types/Pagination/PaginationPageInput/index.d.ts +63 -0
  54. package/types/Pagination/PaginationPageInput/index.d.ts.map +1 -0
  55. package/types/Pagination/PaginationPageInput/props.d.ts +46 -0
  56. package/types/Pagination/PaginationPageInput/props.d.ts.map +1 -0
  57. package/types/Pagination/PaginationPageInput/styles.d.ts +15 -0
  58. package/types/Pagination/PaginationPageInput/styles.d.ts.map +1 -0
  59. package/types/Pagination/PaginationPageInput/theme.d.ts +10 -0
  60. package/types/Pagination/PaginationPageInput/theme.d.ts.map +1 -0
  61. package/types/Pagination/index.d.ts +50 -14
  62. package/types/Pagination/index.d.ts.map +1 -1
  63. package/types/Pagination/props.d.ts +13 -3
  64. package/types/Pagination/props.d.ts.map +1 -1
  65. package/LICENSE.md +0 -27
@@ -0,0 +1,242 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ /** @jsx jsx */
25
+
26
+ import React, { Component } from 'react'
27
+
28
+ import { testable } from '@instructure/ui-testable'
29
+ import { withStyle, jsx } from '@instructure/emotion'
30
+ import { NumberInput } from '@instructure/ui-number-input'
31
+ import { ScreenReaderContent } from '@instructure/ui-a11y-content'
32
+
33
+ import generateStyle from './styles'
34
+ import generateComponentTheme from './theme'
35
+
36
+ import { propTypes, allowedProps } from './props'
37
+ import type {
38
+ PaginationPageInputProps,
39
+ PaginationPageInputState
40
+ } from './props'
41
+
42
+ /**
43
+ ---
44
+ parent: Pagination
45
+ id: Pagination.PageInput
46
+ ---
47
+ @tsProps
48
+ **/
49
+ @withStyle(generateStyle, generateComponentTheme)
50
+ @testable()
51
+ class PaginationPageInput extends Component<
52
+ PaginationPageInputProps,
53
+ PaginationPageInputState
54
+ > {
55
+ static readonly componentId = 'Pagination.PageInput'
56
+
57
+ static propTypes = propTypes
58
+ static allowedProps = allowedProps
59
+ static defaultProps = {
60
+ disabled: false
61
+ }
62
+
63
+ ref: HTMLSpanElement | null = null
64
+ _inputRef: HTMLInputElement | null = null
65
+
66
+ constructor(props: PaginationPageInputProps) {
67
+ super(props)
68
+
69
+ this.state = this.initialState
70
+ }
71
+
72
+ get currentPage() {
73
+ return this.props.currentPageIndex + 1
74
+ }
75
+
76
+ get initialState() {
77
+ return {
78
+ number: this.currentPage,
79
+ value: `${this.currentPage}`
80
+ }
81
+ }
82
+
83
+ get MIN() {
84
+ return 1
85
+ }
86
+
87
+ get MAX() {
88
+ return this.props.numberOfPages
89
+ }
90
+
91
+ componentDidMount() {
92
+ this.props.makeStyles?.()
93
+ }
94
+
95
+ componentDidUpdate(prevProps: PaginationPageInputProps) {
96
+ this.props.makeStyles?.()
97
+
98
+ // when the current page changes from outside (e.g.: from arrow buttons),
99
+ // we update the initial state
100
+ if (this.props.currentPageIndex !== prevProps.currentPageIndex) {
101
+ this.resetInitialState()
102
+ }
103
+ }
104
+
105
+ resetInitialState() {
106
+ this.setState(this.initialState)
107
+ }
108
+
109
+ handleRef = (el: HTMLSpanElement | null) => {
110
+ this.ref = el
111
+ }
112
+
113
+ handleInputRef = (el: HTMLInputElement | null) => {
114
+ this._inputRef = el
115
+
116
+ if (typeof this.props.inputRef === 'function') {
117
+ this.props.inputRef(el)
118
+ }
119
+ }
120
+
121
+ handleChange = (
122
+ _event: React.ChangeEvent<HTMLInputElement>,
123
+ value: string
124
+ ) => {
125
+ let newValue = value
126
+
127
+ // if the last character was not a number, don't accept it
128
+ if (value.length > 0 && isNaN(value.slice(-1) as any)) {
129
+ newValue = value.slice(0, -1)
130
+ }
131
+
132
+ this.setState({
133
+ number: newValue ? Number(newValue) : this.MIN,
134
+ value: newValue
135
+ })
136
+ }
137
+
138
+ handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {
139
+ const { key } = event
140
+
141
+ if (key.toLowerCase() === 'enter') {
142
+ const { value, number } = this.state
143
+
144
+ // If it is invalid, we reset the input to the current page
145
+ if (value === '' || isNaN(value as any)) {
146
+ this.resetInitialState()
147
+ return
148
+ }
149
+
150
+ this.setNewPage(event, number)
151
+ }
152
+ }
153
+
154
+ handleDecrement = (
155
+ event:
156
+ | React.KeyboardEvent<HTMLInputElement>
157
+ | React.MouseEvent<HTMLButtonElement>
158
+ ) => {
159
+ this.setNewPage(event, Math.floor(this.currentPage - 1))
160
+ }
161
+
162
+ handleIncrement = (
163
+ event:
164
+ | React.KeyboardEvent<HTMLInputElement>
165
+ | React.MouseEvent<HTMLButtonElement>
166
+ ) => {
167
+ this.setNewPage(event, Math.floor(this.currentPage + 1))
168
+ }
169
+
170
+ handleBlur = (event: React.FocusEvent<HTMLInputElement>) => {
171
+ this.setNewPage(event, Math.round(this.state.number))
172
+ }
173
+
174
+ getNumberWithinRange(n: number) {
175
+ if (n < this.MIN) return this.MIN
176
+ if (n > this.MAX) return this.MAX
177
+ return n
178
+ }
179
+
180
+ setNewPage(
181
+ event:
182
+ | React.KeyboardEvent<HTMLInputElement>
183
+ | React.MouseEvent<HTMLButtonElement>
184
+ | React.FocusEvent<HTMLInputElement>,
185
+ n: number
186
+ ) {
187
+ const number = this.getNumberWithinRange(n)
188
+
189
+ this.setState({
190
+ number,
191
+ value: `${number}`
192
+ })
193
+
194
+ this.props.onChange(event, number - 1)
195
+ }
196
+
197
+ renderLabel() {
198
+ const { label, numberOfPages, styles } = this.props
199
+
200
+ return typeof label === 'function' && label(numberOfPages) ? (
201
+ <span css={styles?.inputLabel}>{label(numberOfPages)}</span>
202
+ ) : null
203
+ }
204
+
205
+ renderScreenReaderLabel() {
206
+ const { screenReaderLabel, numberOfPages } = this.props
207
+ return (
208
+ <ScreenReaderContent>
209
+ {screenReaderLabel(this.currentPage, numberOfPages)}
210
+ </ScreenReaderContent>
211
+ )
212
+ }
213
+
214
+ render() {
215
+ const { styles, disabled } = this.props
216
+
217
+ return (
218
+ <span css={styles?.paginationPageInput} ref={this.handleRef}>
219
+ <span css={styles?.numberInput}>
220
+ <NumberInput
221
+ renderLabel={this.renderScreenReaderLabel()}
222
+ onBlur={this.handleBlur}
223
+ onChange={this.handleChange}
224
+ onDecrement={this.handleDecrement}
225
+ onIncrement={this.handleIncrement}
226
+ onKeyDown={this.handleKeyDown.bind(this)}
227
+ interaction={disabled ? 'disabled' : 'enabled'}
228
+ showArrows={false}
229
+ value={this.state.value}
230
+ width="100%"
231
+ textAlign="center"
232
+ inputRef={this.handleInputRef}
233
+ />
234
+ </span>
235
+ {this.renderLabel()}
236
+ </span>
237
+ )
238
+ }
239
+ }
240
+
241
+ export default PaginationPageInput
242
+ export { PaginationPageInput }
@@ -0,0 +1,112 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import PropTypes from 'prop-types'
26
+
27
+ import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
28
+ import type {
29
+ PaginationPageInputTheme,
30
+ PropValidators
31
+ } from '@instructure/shared-types'
32
+ import React from 'react'
33
+
34
+ type PaginationPageInputOwnProps = {
35
+ /**
36
+ * The number of pages in total
37
+ */
38
+ numberOfPages: number
39
+ /**
40
+ * The index of the current page
41
+ */
42
+ currentPageIndex: number
43
+ /**
44
+ * Fires when a new page index is selected
45
+ */
46
+ onChange: (
47
+ event:
48
+ | React.KeyboardEvent<HTMLInputElement>
49
+ | React.MouseEvent<HTMLButtonElement>
50
+ | React.FocusEvent<HTMLInputElement>,
51
+ pageIndex: number
52
+ ) => void
53
+ /**
54
+ * ScreenReaderLabel for number input
55
+ */
56
+ screenReaderLabel: (currentPage: number, numberOfPages: number) => string
57
+ /**
58
+ * Label for number input
59
+ */
60
+ label?: (numberOfPages: number) => React.ReactNode
61
+ /**
62
+ * Disables interaction with the input
63
+ */
64
+ disabled?: boolean
65
+ /**
66
+ * provides a reference to the underlying html root element
67
+ */
68
+ inputRef?: (element: Element | null) => void
69
+ }
70
+
71
+ type PropKeys = keyof PaginationPageInputOwnProps
72
+
73
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
74
+
75
+ type PaginationPageInputProps = PaginationPageInputOwnProps &
76
+ WithStyleProps<PaginationPageInputTheme, PaginationPageInputStyle>
77
+
78
+ type PaginationPageInputStyle = ComponentStyle<
79
+ 'paginationPageInput' | 'numberInput' | 'inputLabel'
80
+ >
81
+
82
+ type PaginationPageInputState = {
83
+ number: number
84
+ value: string
85
+ }
86
+
87
+ const propTypes: PropValidators<PropKeys> = {
88
+ numberOfPages: PropTypes.number.isRequired,
89
+ currentPageIndex: PropTypes.number.isRequired,
90
+ onChange: PropTypes.func.isRequired,
91
+ screenReaderLabel: PropTypes.func.isRequired,
92
+ label: PropTypes.func,
93
+ disabled: PropTypes.bool,
94
+ inputRef: PropTypes.func
95
+ }
96
+
97
+ const allowedProps: AllowedPropKeys = [
98
+ 'numberOfPages',
99
+ 'currentPageIndex',
100
+ 'onChange',
101
+ 'screenReaderLabel',
102
+ 'label',
103
+ 'disabled',
104
+ 'inputRef'
105
+ ]
106
+
107
+ export type {
108
+ PaginationPageInputProps,
109
+ PaginationPageInputStyle,
110
+ PaginationPageInputState
111
+ }
112
+ export { propTypes, allowedProps }
@@ -0,0 +1,60 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { PaginationPageInputTheme } from '@instructure/shared-types'
26
+ import type { PaginationPageInputStyle } from './props'
27
+
28
+ /**
29
+ * ---
30
+ * private: true
31
+ * ---
32
+ * Generates the style object from the theme and provided additional information
33
+ * @param {Object} componentTheme The theme variable object.
34
+ * @param {Object} props the props of the component, the style is applied to
35
+ * @param {Object} state the state of the component, the style is applied to
36
+ * @return {Object} The final style object, which will be used in the component
37
+ */
38
+ const generateStyle = (
39
+ componentTheme: PaginationPageInputTheme
40
+ ): PaginationPageInputStyle => {
41
+ return {
42
+ paginationPageInput: {
43
+ label: 'paginationPageInput',
44
+ display: 'inline-flex',
45
+ alignItems: 'center',
46
+ margin: `0 ${componentTheme.inputSpacing}`
47
+ },
48
+ numberInput: {
49
+ label: 'paginationPageInput__input',
50
+ width: componentTheme.inputWidth
51
+ },
52
+ inputLabel: {
53
+ label: 'paginationPageInput__inputLabel',
54
+ marginInlineStart: componentTheme.inputSpacing,
55
+ whiteSpace: 'nowrap'
56
+ }
57
+ }
58
+ }
59
+
60
+ export default generateStyle
@@ -0,0 +1,46 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { Theme } from '@instructure/ui-themes'
26
+ import type { PaginationPageInputTheme } from '@instructure/shared-types'
27
+
28
+ /**
29
+ * Generates the theme object for the component from the theme and provided additional information
30
+ * @param {Object} theme The actual theme object.
31
+ * @return {Object} The final theme object with the overrides and component variables
32
+ */
33
+ const generateComponentTheme = (theme: Theme): PaginationPageInputTheme => {
34
+ const { spacing } = theme
35
+
36
+ const componentVariables: PaginationPageInputTheme = {
37
+ inputSpacing: spacing.xSmall,
38
+ inputWidth: '4.5rem'
39
+ }
40
+
41
+ return {
42
+ ...componentVariables
43
+ }
44
+ }
45
+
46
+ export default generateComponentTheme
@@ -119,6 +119,122 @@ example: true
119
119
  <Pagination.Page href="/pages/3">R-Z</Pagination.Page>
120
120
  </Pagination>
121
121
  ```
122
+
123
+ The `variant="input"` prop will render Pagination with a NumberInput and all the arrow buttons.
124
+
125
+ ```js
126
+ ---
127
+ example: true
128
+ render: false
129
+ ---
130
+ class Example extends React.Component {
131
+ constructor (props) {
132
+ super(props)
133
+ this.state = { currentPage: 0 }
134
+ }
135
+
136
+ setPage (page) {
137
+ this.setState({ currentPage: page })
138
+ }
139
+
140
+ render () {
141
+ const pages = Array.from(Array(9)).map((v, i) => <Pagination.Page
142
+ key={i}
143
+ onClick={this.setPage.bind(this, i)}
144
+ current={i === this.state.currentPage}>
145
+ {i + 1}
146
+ </Pagination.Page>)
147
+
148
+ return (
149
+ <Pagination
150
+ as="nav"
151
+ margin="small"
152
+ variant="input"
153
+ labelFirst="First Page"
154
+ labelPrev="Previous Page"
155
+ labelNext="Next Page"
156
+ labelLast="Last Page"
157
+ >
158
+ {pages}
159
+ </Pagination>
160
+ )
161
+ }
162
+ }
163
+
164
+ render(<Example />)
165
+ ```
166
+
167
+ 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.
168
+
169
+ The `showDisabledButtons` prop displays the unavailable navigation buttons as disabled instead of hiding them.
170
+
171
+ ```js
172
+ ---
173
+ example: true
174
+ render: false
175
+ ---
176
+ class Example extends React.Component {
177
+ constructor (props) {
178
+ super(props)
179
+ this.state = {
180
+ currentPage: 0,
181
+ withFirstAndLastButton: true,
182
+ showDisabledButtons: true
183
+ }
184
+ }
185
+
186
+ setPage (page) {
187
+ this.setState({ currentPage: page })
188
+ }
189
+
190
+ render () {
191
+ const pages = Array.from(Array(9)).map((v, i) => <Pagination.Page
192
+ key={i}
193
+ onClick={this.setPage.bind(this, i)}
194
+ current={i === this.state.currentPage}>
195
+ {i + 1}
196
+ </Pagination.Page>)
197
+
198
+ return (
199
+ <div>
200
+ <FormFieldGroup description="Pagination Settings">
201
+ <Checkbox
202
+ checked={this.state.withFirstAndLastButton}
203
+ label="With First and Last buttons"
204
+ onChange={() => {
205
+ this.setState({ withFirstAndLastButton: !this.state.withFirstAndLastButton })
206
+ }}
207
+ />
208
+ <Checkbox
209
+ checked={this.state.showDisabledButtons}
210
+ label="Show disabled buttons"
211
+ onChange={() => {
212
+ this.setState({ showDisabledButtons: !this.state.showDisabledButtons })
213
+ }}
214
+ />
215
+ </FormFieldGroup>
216
+
217
+ <Pagination
218
+ as="nav"
219
+ margin="large small small"
220
+ variant="compact"
221
+ labelNext="Next Page"
222
+ labelPrev="Previous Page"
223
+ labelFirst="First Page"
224
+ labelLast="Last Page"
225
+ withFirstAndLastButton={ this.state.withFirstAndLastButton }
226
+ showDisabledButtons={ this.state.showDisabledButtons }
227
+ >
228
+ {pages}
229
+ </Pagination>
230
+ </div>
231
+ )
232
+ }
233
+ }
234
+
235
+ render(<Example />)
236
+ ```
237
+
122
238
  ### Guidelines
123
239
 
124
240
  ```js