@instructure/ui-pagination 8.14.1-snapshot.21 → 8.14.1-snapshot.31
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/es/Pagination/PaginationArrowButton/PaginationArrowButtonLocator.js +4 -2
- package/es/Pagination/PaginationArrowButton/index.js +2 -3
- package/es/Pagination/PaginationArrowButton/props.js +1 -1
- package/es/Pagination/PaginationButton/index.js +2 -2
- package/es/Pagination/PaginationButton/props.js +0 -11
- package/es/Pagination/PaginationLocator.js +4 -2
- package/es/Pagination/PaginationPageInput/PaginationPageInputLocator.js +4 -2
- package/es/Pagination/PaginationPageInput/index.js +0 -3
- package/es/Pagination/index.js +10 -12
- package/es/Pagination/props.js +2 -70
- package/lib/Pagination/PaginationArrowButton/PaginationArrowButtonLocator.js +3 -1
- package/lib/Pagination/PaginationArrowButton/index.js +2 -3
- package/lib/Pagination/PaginationArrowButton/props.js +1 -1
- package/lib/Pagination/PaginationButton/index.js +2 -2
- package/lib/Pagination/PaginationButton/props.js +0 -11
- package/lib/Pagination/PaginationLocator.js +3 -1
- package/lib/Pagination/PaginationPageInput/PaginationPageInputLocator.js +3 -1
- package/lib/Pagination/PaginationPageInput/index.js +0 -3
- package/lib/Pagination/index.js +10 -12
- package/lib/Pagination/props.js +2 -70
- package/package.json +22 -22
- package/src/Pagination/PaginationArrowButton/index.tsx +3 -6
- package/src/Pagination/PaginationArrowButton/props.ts +20 -6
- package/src/Pagination/PaginationButton/index.tsx +4 -2
- package/src/Pagination/PaginationButton/props.ts +16 -11
- package/src/Pagination/PaginationPageInput/index.tsx +0 -3
- package/src/Pagination/PaginationPageInput/props.ts +1 -1
- package/src/Pagination/index.tsx +26 -31
- package/src/Pagination/props.ts +82 -55
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Pagination/PaginationArrowButton/index.d.ts +6 -7
- package/types/Pagination/PaginationArrowButton/index.d.ts.map +1 -1
- package/types/Pagination/PaginationArrowButton/props.d.ts +5 -4
- package/types/Pagination/PaginationArrowButton/props.d.ts.map +1 -1
- package/types/Pagination/PaginationButton/index.d.ts.map +1 -1
- package/types/Pagination/PaginationButton/props.d.ts +12 -2
- package/types/Pagination/PaginationButton/props.d.ts.map +1 -1
- package/types/Pagination/PaginationPageInput/index.d.ts +2 -3
- package/types/Pagination/PaginationPageInput/index.d.ts.map +1 -1
- package/types/Pagination/PaginationPageInput/props.d.ts +1 -1
- package/types/Pagination/PaginationPageInput/props.d.ts.map +1 -1
- package/types/Pagination/index.d.ts +15 -15
- package/types/Pagination/index.d.ts.map +1 -1
- package/types/Pagination/props.d.ts +66 -2
- package/types/Pagination/props.d.ts.map +1 -1
|
@@ -43,6 +43,7 @@ import { allowedProps, propTypes } from './props'
|
|
|
43
43
|
parent: Pagination
|
|
44
44
|
id: Pagination.Navigation
|
|
45
45
|
---
|
|
46
|
+
@tsProps
|
|
46
47
|
**/
|
|
47
48
|
@testable()
|
|
48
49
|
class PaginationArrowButton extends Component<PaginationNavigationProps> {
|
|
@@ -51,10 +52,7 @@ class PaginationArrowButton extends Component<PaginationNavigationProps> {
|
|
|
51
52
|
static allowedProps = allowedProps
|
|
52
53
|
static propTypes = propTypes
|
|
53
54
|
|
|
54
|
-
static defaultProps = {
|
|
55
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'el' is declared but its value is never read.
|
|
56
|
-
buttonRef: (el) => {}
|
|
57
|
-
}
|
|
55
|
+
static defaultProps = {}
|
|
58
56
|
|
|
59
57
|
ref: Element | null = null
|
|
60
58
|
|
|
@@ -90,6 +88,7 @@ class PaginationArrowButton extends Component<PaginationNavigationProps> {
|
|
|
90
88
|
|
|
91
89
|
render() {
|
|
92
90
|
const { label, direction, buttonRef, ...props } = this.props
|
|
91
|
+
|
|
93
92
|
return (
|
|
94
93
|
<Tooltip
|
|
95
94
|
on={['hover', 'focus']}
|
|
@@ -104,9 +103,7 @@ class PaginationArrowButton extends Component<PaginationNavigationProps> {
|
|
|
104
103
|
size="small"
|
|
105
104
|
withBackground={false}
|
|
106
105
|
withBorder={false}
|
|
107
|
-
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
|
|
108
106
|
screenReaderLabel={label}
|
|
109
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property 'href' does not exist on type '{ children... Remove this comment to see the full error message
|
|
110
107
|
rel={props.href || props.to ? direction : undefined}
|
|
111
108
|
elementRef={buttonRef}
|
|
112
109
|
margin={this.margin}
|
|
@@ -27,15 +27,17 @@ import PropTypes from 'prop-types'
|
|
|
27
27
|
|
|
28
28
|
import type {
|
|
29
29
|
OtherHTMLAttributes,
|
|
30
|
-
PropValidators
|
|
30
|
+
PropValidators,
|
|
31
|
+
PickPropsWithExceptions
|
|
31
32
|
} from '@instructure/shared-types'
|
|
33
|
+
import type { IconButtonProps } from '@instructure/ui-buttons'
|
|
32
34
|
|
|
33
35
|
type PaginationArrowDirections = 'first' | 'prev' | 'next' | 'last'
|
|
34
36
|
|
|
35
37
|
type PaginationNavigationOwnProps = {
|
|
36
38
|
direction?: PaginationArrowDirections
|
|
37
|
-
label: string
|
|
38
|
-
buttonRef?: (
|
|
39
|
+
label: string
|
|
40
|
+
buttonRef?: (element: Element | null) => void
|
|
39
41
|
onClick?: (
|
|
40
42
|
event:
|
|
41
43
|
| React.KeyboardEvent<HTMLInputElement>
|
|
@@ -48,12 +50,24 @@ type PropKeys = keyof PaginationNavigationOwnProps
|
|
|
48
50
|
|
|
49
51
|
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
50
52
|
|
|
51
|
-
type PaginationNavigationProps =
|
|
52
|
-
|
|
53
|
+
type PaginationNavigationProps =
|
|
54
|
+
// We pass almost all the props to IconButton
|
|
55
|
+
PickPropsWithExceptions<
|
|
56
|
+
IconButtonProps,
|
|
57
|
+
| 'size'
|
|
58
|
+
| 'withBackground'
|
|
59
|
+
| 'withBorder'
|
|
60
|
+
| 'screenReaderLabel'
|
|
61
|
+
| 'rel'
|
|
62
|
+
| 'elementRef'
|
|
63
|
+
| 'margin'
|
|
64
|
+
> &
|
|
65
|
+
PaginationNavigationOwnProps &
|
|
66
|
+
OtherHTMLAttributes<PaginationNavigationOwnProps>
|
|
53
67
|
|
|
54
68
|
const propTypes: PropValidators<PropKeys> = {
|
|
55
69
|
direction: PropTypes.oneOf(['first', 'prev', 'next', 'last']),
|
|
56
|
-
label: PropTypes.
|
|
70
|
+
label: PropTypes.string.isRequired,
|
|
57
71
|
buttonRef: PropTypes.func,
|
|
58
72
|
onClick: PropTypes.func
|
|
59
73
|
}
|
|
@@ -56,12 +56,14 @@ class PaginationButton extends Component<PaginationPageProps> {
|
|
|
56
56
|
|
|
57
57
|
render() {
|
|
58
58
|
const exclude = this.props.current ? ['onClick', 'href'] : []
|
|
59
|
+
|
|
59
60
|
const props = omitProps(this.props, PaginationButton.allowedProps, exclude)
|
|
61
|
+
|
|
60
62
|
return (
|
|
61
63
|
<BaseButton
|
|
62
64
|
color="primary"
|
|
63
|
-
withBackground={this.props.current
|
|
64
|
-
withBorder={this.props.current
|
|
65
|
+
withBackground={this.props.current}
|
|
66
|
+
withBorder={this.props.current}
|
|
65
67
|
{...props}
|
|
66
68
|
aria-current={this.props.current ? 'page' : undefined}
|
|
67
69
|
elementRef={this.handleRef}
|
|
@@ -27,12 +27,23 @@ import PropTypes from 'prop-types'
|
|
|
27
27
|
|
|
28
28
|
import type {
|
|
29
29
|
OtherHTMLAttributes,
|
|
30
|
+
PickPropsWithExceptions,
|
|
30
31
|
PropValidators
|
|
31
32
|
} from '@instructure/shared-types'
|
|
33
|
+
import type { BaseButtonProps } from '@instructure/ui-buttons'
|
|
32
34
|
|
|
33
35
|
type PaginationPageOwnProps = {
|
|
36
|
+
/**
|
|
37
|
+
* Content to render as page selection
|
|
38
|
+
*/
|
|
34
39
|
children: React.ReactNode
|
|
40
|
+
/**
|
|
41
|
+
* Whether the page is currently displayed
|
|
42
|
+
*/
|
|
35
43
|
current?: boolean
|
|
44
|
+
/**
|
|
45
|
+
* Whether the page is currently displayed
|
|
46
|
+
*/
|
|
36
47
|
onClick?: (
|
|
37
48
|
event:
|
|
38
49
|
| React.KeyboardEvent<HTMLInputElement>
|
|
@@ -45,21 +56,15 @@ type PropKeys = keyof PaginationPageOwnProps
|
|
|
45
56
|
|
|
46
57
|
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
47
58
|
|
|
48
|
-
type PaginationPageProps =
|
|
49
|
-
|
|
59
|
+
type PaginationPageProps =
|
|
60
|
+
// We pass almost all props to BaseButton
|
|
61
|
+
PickPropsWithExceptions<BaseButtonProps, 'aria-current' | 'elementRef'> &
|
|
62
|
+
PaginationPageOwnProps &
|
|
63
|
+
OtherHTMLAttributes<PaginationPageOwnProps>
|
|
50
64
|
|
|
51
65
|
const propTypes: PropValidators<PropKeys> = {
|
|
52
|
-
/**
|
|
53
|
-
* Content to render as page selection
|
|
54
|
-
*/
|
|
55
66
|
children: PropTypes.node.isRequired,
|
|
56
|
-
/**
|
|
57
|
-
* Whether the page is currently displayed
|
|
58
|
-
*/
|
|
59
67
|
current: PropTypes.bool,
|
|
60
|
-
/**
|
|
61
|
-
* Whether the page is currently displayed
|
|
62
|
-
*/
|
|
63
68
|
onClick: PropTypes.func
|
|
64
69
|
}
|
|
65
70
|
|
|
@@ -61,7 +61,6 @@ class PaginationPageInput extends Component<
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
ref: HTMLSpanElement | null = null
|
|
64
|
-
_inputRef: HTMLInputElement | null = null
|
|
65
64
|
|
|
66
65
|
constructor(props: PaginationPageInputProps) {
|
|
67
66
|
super(props)
|
|
@@ -111,8 +110,6 @@ class PaginationPageInput extends Component<
|
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
handleInputRef = (el: HTMLInputElement | null) => {
|
|
114
|
-
this._inputRef = el
|
|
115
|
-
|
|
116
113
|
if (typeof this.props.inputRef === 'function') {
|
|
117
114
|
this.props.inputRef(el)
|
|
118
115
|
}
|
|
@@ -65,7 +65,7 @@ type PaginationPageInputOwnProps = {
|
|
|
65
65
|
/**
|
|
66
66
|
* provides a reference to the underlying html root element
|
|
67
67
|
*/
|
|
68
|
-
inputRef?: (element:
|
|
68
|
+
inputRef?: (element: HTMLInputElement | null) => void
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
type PropKeys = keyof PaginationPageInputOwnProps
|
package/src/Pagination/index.tsx
CHANGED
|
@@ -42,12 +42,13 @@ import type { PaginationPageProps } from './PaginationButton/props'
|
|
|
42
42
|
import type { PaginationArrowDirections } from './PaginationArrowButton/props'
|
|
43
43
|
|
|
44
44
|
import { propTypes, allowedProps } from './props'
|
|
45
|
-
import type { PaginationProps, PaginationSnapshot } from './props'
|
|
45
|
+
import type { PaginationProps, PaginationSnapshot, ChildPage } from './props'
|
|
46
46
|
|
|
47
47
|
/** This is an [].findIndex optimized to work on really big, but sparse, arrays */
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
const fastFindIndex = (
|
|
49
|
+
arr: ChildPage[],
|
|
50
|
+
fn: (page: ChildPage) => boolean | undefined
|
|
51
|
+
) => Number(Object.keys(arr).find((k) => fn(arr[Number(k)])))
|
|
51
52
|
|
|
52
53
|
const childrenArray = (props: PaginationProps) => {
|
|
53
54
|
const { children } = props
|
|
@@ -69,13 +70,14 @@ type ArrowConfig = {
|
|
|
69
70
|
pageIndex: number
|
|
70
71
|
label: string
|
|
71
72
|
shouldEnableIcon: boolean
|
|
72
|
-
handleButtonRef: (el:
|
|
73
|
+
handleButtonRef: (el: Element | null) => void
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
/**
|
|
76
77
|
---
|
|
77
78
|
category: components
|
|
78
79
|
---
|
|
80
|
+
@tsProps
|
|
79
81
|
**/
|
|
80
82
|
@withStyle(generateStyle, null)
|
|
81
83
|
@testable()
|
|
@@ -85,14 +87,11 @@ class Pagination extends Component<PaginationProps> {
|
|
|
85
87
|
static propTypes = propTypes
|
|
86
88
|
static allowedProps = allowedProps
|
|
87
89
|
static defaultProps = {
|
|
88
|
-
children: null,
|
|
89
90
|
disabled: false,
|
|
90
91
|
withFirstAndLastButton: false,
|
|
91
92
|
showDisabledButtons: false,
|
|
92
93
|
variant: 'full',
|
|
93
94
|
as: 'div',
|
|
94
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'el' is declared but its value is never read.
|
|
95
|
-
elementRef: (el) => {},
|
|
96
95
|
labelNumberInput: (numberOfPages: number) => `of ${numberOfPages}`,
|
|
97
96
|
screenReaderLabelNumberInput: (
|
|
98
97
|
currentPage: number,
|
|
@@ -104,20 +103,17 @@ class Pagination extends Component<PaginationProps> {
|
|
|
104
103
|
static Page = PaginationButton
|
|
105
104
|
static Navigation = PaginationArrowButton
|
|
106
105
|
|
|
107
|
-
_labelId: string
|
|
106
|
+
private readonly _labelId: string
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
private _firstButton: HTMLButtonElement | null = null
|
|
109
|
+
private _prevButton: HTMLButtonElement | null = null
|
|
110
|
+
private _nextButton: HTMLButtonElement | null = null
|
|
111
|
+
private _lastButton: HTMLButtonElement | null = null
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
_prevButton: HTMLButtonElement | null = null
|
|
114
|
-
_nextButton: HTMLButtonElement | null = null
|
|
115
|
-
_lastButton: HTMLButtonElement | null = null
|
|
113
|
+
ref: Element | null = null
|
|
116
114
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// @ts-expect-error ts-migrate(2556) FIXME: Expected 1-2 arguments, but got 0 or more.
|
|
120
|
-
super(...args)
|
|
115
|
+
constructor(props: PaginationProps) {
|
|
116
|
+
super(props)
|
|
121
117
|
|
|
122
118
|
this._labelId = uid('Pagination')
|
|
123
119
|
}
|
|
@@ -221,15 +217,15 @@ class Pagination extends Component<PaginationProps> {
|
|
|
221
217
|
|
|
222
218
|
handleElementRef = (el: Element | null) => {
|
|
223
219
|
this.ref = el
|
|
224
|
-
if (el) {
|
|
225
|
-
|
|
226
|
-
this.props.elementRef(el)
|
|
227
|
-
}
|
|
220
|
+
if (el && typeof this.props.elementRef === 'function') {
|
|
221
|
+
this.props.elementRef(el)
|
|
228
222
|
}
|
|
229
223
|
}
|
|
230
224
|
|
|
231
|
-
handleInputRef = (el:
|
|
232
|
-
this.
|
|
225
|
+
handleInputRef = (el: HTMLInputElement | null) => {
|
|
226
|
+
if (typeof this.props.inputRef === 'function') {
|
|
227
|
+
this.props.inputRef(el)
|
|
228
|
+
}
|
|
233
229
|
}
|
|
234
230
|
|
|
235
231
|
renderLabel() {
|
|
@@ -326,7 +322,7 @@ class Pagination extends Component<PaginationProps> {
|
|
|
326
322
|
label: this.props.labelFirst || 'First Page',
|
|
327
323
|
shouldEnableIcon: currentPageIndex > 1,
|
|
328
324
|
handleButtonRef: (el) => {
|
|
329
|
-
this._firstButton = el
|
|
325
|
+
this._firstButton = el as HTMLButtonElement
|
|
330
326
|
}
|
|
331
327
|
}
|
|
332
328
|
case 'prev':
|
|
@@ -335,7 +331,7 @@ class Pagination extends Component<PaginationProps> {
|
|
|
335
331
|
label: this.props.labelPrev || 'Previous Page',
|
|
336
332
|
shouldEnableIcon: currentPageIndex > 0,
|
|
337
333
|
handleButtonRef: (el) => {
|
|
338
|
-
this._prevButton = el
|
|
334
|
+
this._prevButton = el as HTMLButtonElement
|
|
339
335
|
}
|
|
340
336
|
}
|
|
341
337
|
case 'next':
|
|
@@ -344,7 +340,7 @@ class Pagination extends Component<PaginationProps> {
|
|
|
344
340
|
label: this.props.labelNext || 'Next Page',
|
|
345
341
|
shouldEnableIcon: currentPageIndex < pagesCount - 1,
|
|
346
342
|
handleButtonRef: (el) => {
|
|
347
|
-
this._nextButton = el
|
|
343
|
+
this._nextButton = el as HTMLButtonElement
|
|
348
344
|
}
|
|
349
345
|
}
|
|
350
346
|
case 'last':
|
|
@@ -353,7 +349,7 @@ class Pagination extends Component<PaginationProps> {
|
|
|
353
349
|
label: this.props.labelLast || 'Last Page',
|
|
354
350
|
shouldEnableIcon: currentPageIndex < pagesCount - 2,
|
|
355
351
|
handleButtonRef: (el) => {
|
|
356
|
-
this._lastButton = el
|
|
352
|
+
this._lastButton = el as HTMLButtonElement
|
|
357
353
|
}
|
|
358
354
|
}
|
|
359
355
|
}
|
|
@@ -402,8 +398,7 @@ class Pagination extends Component<PaginationProps> {
|
|
|
402
398
|
if (!this.props.children) return null
|
|
403
399
|
|
|
404
400
|
const currentPageIndex = fastFindIndex(
|
|
405
|
-
this.
|
|
406
|
-
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'p' implicitly has an 'any' type.
|
|
401
|
+
this.childPages,
|
|
407
402
|
(p) => p && p.props && p.props.current
|
|
408
403
|
)
|
|
409
404
|
|
package/src/Pagination/props.ts
CHANGED
|
@@ -42,113 +42,139 @@ import type {
|
|
|
42
42
|
} from '@instructure/shared-types'
|
|
43
43
|
import type { PaginationPageProps } from './PaginationButton/props'
|
|
44
44
|
|
|
45
|
+
type ChildPage = React.ReactElement<PaginationPageProps>
|
|
46
|
+
|
|
45
47
|
type PaginationOwnProps = {
|
|
46
48
|
// this won't filter the children completely well,
|
|
47
49
|
// it will allow simple elements (e.g. `<div>`) and components with compatible props
|
|
48
50
|
// TODO: find a better way to type Children.oneOf([PaginationButton])
|
|
49
|
-
children?:
|
|
50
|
-
| React.ReactElement<PaginationPageProps>
|
|
51
|
-
| React.ReactElement<PaginationPageProps>[]
|
|
52
|
-
disabled?: boolean
|
|
53
|
-
withFirstAndLastButton?: boolean
|
|
54
|
-
showDisabledButtons?: boolean
|
|
55
|
-
label?: React.ReactNode
|
|
56
|
-
labelNext?: string
|
|
57
|
-
labelPrev?: string
|
|
58
|
-
labelFirst?: string
|
|
59
|
-
labelLast?: string
|
|
60
|
-
labelNumberInput?: (numberOfPages: number) => React.ReactNode
|
|
61
|
-
screenReaderLabelNumberInput?: (
|
|
62
|
-
currentPage: number,
|
|
63
|
-
numberOfPages: number
|
|
64
|
-
) => string
|
|
65
|
-
variant?: 'full' | 'compact' | 'input'
|
|
66
|
-
margin?: Spacing
|
|
67
|
-
as?: AsElementType
|
|
68
|
-
elementRef?: (element: Element | null) => void
|
|
69
|
-
shouldHandleFocus?: boolean
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
type PropKeys = keyof PaginationOwnProps
|
|
73
|
-
|
|
74
|
-
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
75
|
-
|
|
76
|
-
type PaginationProps = PaginationOwnProps &
|
|
77
|
-
WithStyleProps<null, PaginationStyle> &
|
|
78
|
-
OtherHTMLAttributes<PaginationOwnProps>
|
|
79
|
-
|
|
80
|
-
type PaginationStyle = ComponentStyle<'pagination' | 'pages'>
|
|
81
|
-
|
|
82
|
-
const propTypes: PropValidators<PropKeys> = {
|
|
83
51
|
/**
|
|
84
52
|
* children of type Pagination.Page
|
|
85
53
|
*/
|
|
86
|
-
children
|
|
54
|
+
children?: ChildPage | ChildPage[]
|
|
55
|
+
|
|
87
56
|
/**
|
|
88
57
|
* Disables interaction with all pages
|
|
89
58
|
*/
|
|
90
|
-
disabled
|
|
59
|
+
disabled?: boolean
|
|
60
|
+
|
|
91
61
|
/**
|
|
92
62
|
* Displays "jump to first" and "jump to last" buttons. Always turned on with `input` variant.
|
|
93
63
|
*/
|
|
94
|
-
withFirstAndLastButton
|
|
64
|
+
withFirstAndLastButton?: boolean
|
|
65
|
+
|
|
95
66
|
/**
|
|
96
|
-
* Displays the unavailable navigation buttons as disabled instead of hiding them.
|
|
67
|
+
* Displays the unavailable navigation buttons as disabled instead of hiding them. Always turned on with `input` variant.
|
|
97
68
|
*/
|
|
98
|
-
showDisabledButtons
|
|
69
|
+
showDisabledButtons?: boolean
|
|
70
|
+
|
|
99
71
|
/**
|
|
100
72
|
* Visible label for component
|
|
101
73
|
*/
|
|
102
|
-
label
|
|
74
|
+
label?: React.ReactNode
|
|
75
|
+
|
|
103
76
|
/**
|
|
104
77
|
* Accessible label for next button
|
|
105
78
|
*/
|
|
106
|
-
labelNext
|
|
79
|
+
labelNext?: string
|
|
80
|
+
|
|
107
81
|
/**
|
|
108
82
|
* Accessible label for previous button
|
|
109
83
|
*/
|
|
110
|
-
labelPrev
|
|
84
|
+
labelPrev?: string
|
|
85
|
+
|
|
111
86
|
/**
|
|
112
87
|
* Accessible label for "jump to first" button
|
|
113
88
|
*/
|
|
114
|
-
labelFirst
|
|
89
|
+
labelFirst?: string
|
|
90
|
+
|
|
115
91
|
/**
|
|
116
92
|
* Accessible label for "jump to last" button
|
|
117
93
|
*/
|
|
118
|
-
labelLast
|
|
94
|
+
labelLast?: string
|
|
95
|
+
|
|
119
96
|
/**
|
|
120
|
-
* Label for number input
|
|
97
|
+
* Label for number input
|
|
98
|
+
*
|
|
99
|
+
* (__only__ for `input` variant)
|
|
121
100
|
*/
|
|
122
|
-
labelNumberInput:
|
|
101
|
+
labelNumberInput?: (numberOfPages: number) => React.ReactNode
|
|
102
|
+
|
|
123
103
|
/**
|
|
124
|
-
* ScreenReaderLabel for number input
|
|
104
|
+
* ScreenReaderLabel for number input
|
|
105
|
+
*
|
|
106
|
+
* (__only__ for `input` variant)
|
|
125
107
|
*/
|
|
126
|
-
screenReaderLabelNumberInput
|
|
108
|
+
screenReaderLabelNumberInput?: (
|
|
109
|
+
currentPage: number,
|
|
110
|
+
numberOfPages: number
|
|
111
|
+
) => string
|
|
112
|
+
|
|
127
113
|
/**
|
|
128
114
|
* The compact variant truncates the page navigation to show only the first,
|
|
129
115
|
* last, and pages immediately surrounding the current page. Fewer than 5 pages,
|
|
130
116
|
* no next/previous arrow buttons will be shown, and all pages will be listed
|
|
131
117
|
*/
|
|
132
|
-
variant
|
|
118
|
+
variant?: 'full' | 'compact' | 'input'
|
|
119
|
+
|
|
133
120
|
/**
|
|
134
121
|
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
135
122
|
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
136
123
|
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
137
124
|
*/
|
|
138
|
-
margin
|
|
125
|
+
margin?: Spacing
|
|
126
|
+
|
|
139
127
|
/**
|
|
140
128
|
* the element type to render as
|
|
141
129
|
*/
|
|
142
|
-
as
|
|
130
|
+
as?: AsElementType
|
|
131
|
+
|
|
143
132
|
/**
|
|
144
133
|
* provides a reference to the underlying html root element
|
|
145
134
|
*/
|
|
146
|
-
elementRef:
|
|
135
|
+
elementRef?: (element: Element | null) => void
|
|
136
|
+
|
|
147
137
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
138
|
+
* provides a reference to the html input element
|
|
139
|
+
*
|
|
140
|
+
* (__only__ for `input` variant)
|
|
141
|
+
*/
|
|
142
|
+
inputRef?: (inputElement: HTMLInputElement | null) => void
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* For accessibility, Pagination sets focus on the first or last Pagination.Pages, respectively, when the Previous or Next arrow buttons are removed from the DOM.
|
|
150
146
|
* Set this property to `false` to prevent this behavior.
|
|
151
147
|
*/
|
|
148
|
+
shouldHandleFocus?: boolean
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
type PropKeys = keyof PaginationOwnProps
|
|
152
|
+
|
|
153
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
154
|
+
|
|
155
|
+
type PaginationProps = PaginationOwnProps &
|
|
156
|
+
WithStyleProps<null, PaginationStyle> &
|
|
157
|
+
OtherHTMLAttributes<PaginationOwnProps>
|
|
158
|
+
|
|
159
|
+
type PaginationStyle = ComponentStyle<'pagination' | 'pages'>
|
|
160
|
+
|
|
161
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
162
|
+
children: Children.oneOf([PaginationButton]),
|
|
163
|
+
disabled: PropTypes.bool,
|
|
164
|
+
withFirstAndLastButton: PropTypes.bool,
|
|
165
|
+
showDisabledButtons: PropTypes.bool,
|
|
166
|
+
label: PropTypes.node,
|
|
167
|
+
labelNext: PropTypes.string,
|
|
168
|
+
labelPrev: PropTypes.string,
|
|
169
|
+
labelFirst: PropTypes.string,
|
|
170
|
+
labelLast: PropTypes.string,
|
|
171
|
+
labelNumberInput: PropTypes.func,
|
|
172
|
+
screenReaderLabelNumberInput: PropTypes.func,
|
|
173
|
+
variant: PropTypes.oneOf(['full', 'compact', 'input']),
|
|
174
|
+
margin: ThemeablePropTypes.spacing,
|
|
175
|
+
as: PropTypes.elementType,
|
|
176
|
+
elementRef: PropTypes.func,
|
|
177
|
+
inputRef: PropTypes.func,
|
|
152
178
|
shouldHandleFocus: PropTypes.bool
|
|
153
179
|
}
|
|
154
180
|
|
|
@@ -168,6 +194,7 @@ const allowedProps: AllowedPropKeys = [
|
|
|
168
194
|
'margin',
|
|
169
195
|
'as',
|
|
170
196
|
'elementRef',
|
|
197
|
+
'inputRef',
|
|
171
198
|
'shouldHandleFocus'
|
|
172
199
|
]
|
|
173
200
|
|
|
@@ -175,5 +202,5 @@ type PaginationSnapshot = {
|
|
|
175
202
|
lastFocusedButton?: HTMLButtonElement
|
|
176
203
|
}
|
|
177
204
|
|
|
178
|
-
export type { PaginationProps, PaginationStyle, PaginationSnapshot }
|
|
205
|
+
export type { PaginationProps, PaginationStyle, PaginationSnapshot, ChildPage }
|
|
179
206
|
export { propTypes, allowedProps }
|