@patternfly/react-core 4.181.4 → 4.182.2
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 +41 -0
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts +1 -0
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.js +5 -0
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuControl.d.ts.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuControl.js +8 -4
- package/dist/esm/components/OverflowMenu/OverflowMenuControl.js.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuGroup.d.ts.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuGroup.js +5 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuGroup.js.map +1 -1
- package/dist/esm/components/Pagination/Navigation.d.ts +2 -0
- package/dist/esm/components/Pagination/Navigation.d.ts.map +1 -1
- package/dist/esm/components/Pagination/Navigation.js +3 -2
- package/dist/esm/components/Pagination/Navigation.js.map +1 -1
- package/dist/esm/components/Pagination/Pagination.d.ts +2 -0
- package/dist/esm/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/esm/components/Pagination/Pagination.js +2 -1
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.d.ts +13 -0
- package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.js +28 -9
- package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/esm/components/TimePicker/TimePickerUtils.d.ts +2 -1
- package/dist/esm/components/TimePicker/TimePickerUtils.d.ts.map +1 -1
- package/dist/esm/components/TimePicker/TimePickerUtils.js +45 -19
- package/dist/esm/components/TimePicker/TimePickerUtils.js.map +1 -1
- package/dist/esm/components/Toolbar/Toolbar.d.ts +2 -0
- package/dist/esm/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/Toolbar.js +2 -2
- package/dist/esm/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarChipGroupContent.d.ts +2 -0
- package/dist/esm/components/Toolbar/ToolbarChipGroupContent.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarChipGroupContent.js +4 -5
- package/dist/esm/components/Toolbar/ToolbarChipGroupContent.js.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts +1 -0
- package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopy.js +5 -0
- package/dist/js/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuControl.d.ts.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuControl.js +7 -4
- package/dist/js/components/OverflowMenu/OverflowMenuControl.js.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuGroup.d.ts.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuGroup.js +4 -1
- package/dist/js/components/OverflowMenu/OverflowMenuGroup.js.map +1 -1
- package/dist/js/components/Pagination/Navigation.d.ts +2 -0
- package/dist/js/components/Pagination/Navigation.d.ts.map +1 -1
- package/dist/js/components/Pagination/Navigation.js +3 -2
- package/dist/js/components/Pagination/Navigation.js.map +1 -1
- package/dist/js/components/Pagination/Pagination.d.ts +2 -0
- package/dist/js/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/js/components/Pagination/Pagination.js +2 -1
- package/dist/js/components/Pagination/Pagination.js.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.d.ts +13 -0
- package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.js +27 -8
- package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/js/components/TimePicker/TimePickerUtils.d.ts +2 -1
- package/dist/js/components/TimePicker/TimePickerUtils.d.ts.map +1 -1
- package/dist/js/components/TimePicker/TimePickerUtils.js +47 -20
- package/dist/js/components/TimePicker/TimePickerUtils.js.map +1 -1
- package/dist/js/components/Toolbar/Toolbar.d.ts +2 -0
- package/dist/js/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/js/components/Toolbar/Toolbar.js +2 -2
- package/dist/js/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarChipGroupContent.d.ts +2 -0
- package/dist/js/components/Toolbar/ToolbarChipGroupContent.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarChipGroupContent.js +4 -5
- package/dist/js/components/Toolbar/ToolbarChipGroupContent.js.map +1 -1
- package/dist/umd/react-core.js +99 -42
- package/dist/umd/react-core.min.js +4 -4
- package/package.json +5 -5
- package/src/components/ClipboardCopy/ClipboardCopy.tsx +6 -0
- package/src/components/OverflowMenu/OverflowMenuControl.tsx +6 -2
- package/src/components/OverflowMenu/OverflowMenuGroup.tsx +3 -1
- package/src/components/Pagination/Navigation.tsx +5 -1
- package/src/components/Pagination/Pagination.tsx +4 -0
- package/src/components/Pagination/__tests__/Generated/__snapshots__/Pagination.test.tsx.snap +1 -0
- package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +31 -0
- package/src/components/TimePicker/TimePicker.tsx +48 -9
- package/src/components/TimePicker/TimePickerUtils.tsx +54 -24
- package/src/components/TimePicker/examples/TimePicker.md +11 -0
- package/src/components/Toolbar/Toolbar.tsx +4 -0
- package/src/components/Toolbar/ToolbarChipGroupContent.tsx +6 -2
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/Toolbar.test.tsx.snap +1 -0
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarToggleGroup.test.tsx.snap +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.182.2",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.
|
|
38
|
-
"@patternfly/react-styles": "^4.
|
|
39
|
-
"@patternfly/react-tokens": "^4.
|
|
37
|
+
"@patternfly/react-icons": "^4.33.2",
|
|
38
|
+
"@patternfly/react-styles": "^4.32.2",
|
|
39
|
+
"@patternfly/react-tokens": "^4.34.2",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "d54cbe2dbccd6f6d6539052d5d9c3b492b98328d"
|
|
64
64
|
}
|
|
@@ -111,6 +111,12 @@ export class ClipboardCopy extends React.Component<ClipboardCopyProps, Clipboard
|
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
+
componentWillUnmount = () => {
|
|
115
|
+
if (this.timer) {
|
|
116
|
+
window.clearTimeout(this.timer);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
114
120
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
115
121
|
expandContent = (_event: React.MouseEvent<Element, MouseEvent>) => {
|
|
116
122
|
this.setState(prevState => ({
|
|
@@ -15,12 +15,16 @@ export interface OverflowMenuControlProps extends React.HTMLProps<HTMLDivElement
|
|
|
15
15
|
export const OverflowMenuControl: React.SFC<OverflowMenuControlProps> = ({
|
|
16
16
|
className,
|
|
17
17
|
children,
|
|
18
|
-
hasAdditionalOptions
|
|
18
|
+
hasAdditionalOptions,
|
|
19
|
+
...props
|
|
19
20
|
}: OverflowMenuControlProps) => (
|
|
20
21
|
<OverflowMenuContext.Consumer>
|
|
21
22
|
{value =>
|
|
22
23
|
(value.isBelowBreakpoint || hasAdditionalOptions) && (
|
|
23
|
-
<div className={css(styles.overflowMenuControl, className)}
|
|
24
|
+
<div className={css(styles.overflowMenuControl, className)} {...props}>
|
|
25
|
+
{' '}
|
|
26
|
+
{children}{' '}
|
|
27
|
+
</div>
|
|
24
28
|
)
|
|
25
29
|
}
|
|
26
30
|
</OverflowMenuContext.Consumer>
|
|
@@ -18,7 +18,8 @@ export const OverflowMenuGroup: React.FC<OverflowMenuGroupProps> = ({
|
|
|
18
18
|
className,
|
|
19
19
|
children,
|
|
20
20
|
isPersistent = false,
|
|
21
|
-
groupType
|
|
21
|
+
groupType,
|
|
22
|
+
...props
|
|
22
23
|
}: OverflowMenuGroupProps) => (
|
|
23
24
|
<OverflowMenuContext.Consumer>
|
|
24
25
|
{value =>
|
|
@@ -30,6 +31,7 @@ export const OverflowMenuGroup: React.FC<OverflowMenuGroupProps> = ({
|
|
|
30
31
|
groupType === 'icon' && styles.modifiers.iconButtonGroup,
|
|
31
32
|
className
|
|
32
33
|
)}
|
|
34
|
+
{...props}
|
|
33
35
|
>
|
|
34
36
|
{children}
|
|
35
37
|
</div>
|
|
@@ -25,6 +25,8 @@ export interface NavigationProps extends React.HTMLProps<HTMLElement> {
|
|
|
25
25
|
firstPage?: number;
|
|
26
26
|
/** The title of a page displayed beside the page number */
|
|
27
27
|
pagesTitle?: string;
|
|
28
|
+
/** The title of a page displayed beside the page number (the plural form) */
|
|
29
|
+
pagesTitlePlural?: string;
|
|
28
30
|
/** Accessible label for the button which moves to the last page */
|
|
29
31
|
toLastPage?: string;
|
|
30
32
|
/** Accessible label for the button which moves to the previous page */
|
|
@@ -75,6 +77,7 @@ export class Navigation extends React.Component<NavigationProps, NavigationState
|
|
|
75
77
|
lastPage: 0,
|
|
76
78
|
firstPage: 0,
|
|
77
79
|
pagesTitle: '',
|
|
80
|
+
pagesTitlePlural: '',
|
|
78
81
|
toLastPage: 'Go to last page',
|
|
79
82
|
toNextPage: 'Go to next page',
|
|
80
83
|
toFirstPage: 'Go to first page',
|
|
@@ -146,6 +149,7 @@ export class Navigation extends React.Component<NavigationProps, NavigationState
|
|
|
146
149
|
lastPage,
|
|
147
150
|
firstPage,
|
|
148
151
|
pagesTitle,
|
|
152
|
+
pagesTitlePlural,
|
|
149
153
|
toLastPage,
|
|
150
154
|
toNextPage,
|
|
151
155
|
toFirstPage,
|
|
@@ -215,7 +219,7 @@ export class Navigation extends React.Component<NavigationProps, NavigationState
|
|
|
215
219
|
/>
|
|
216
220
|
{(itemCount || itemCount === 0) && (
|
|
217
221
|
<span aria-hidden="true">
|
|
218
|
-
{ofWord} {pagesTitle ? pluralize(lastPage, pagesTitle) : lastPage}
|
|
222
|
+
{ofWord} {pagesTitle ? pluralize(lastPage, pagesTitle, pagesTitlePlural) : lastPage}
|
|
219
223
|
</span>
|
|
220
224
|
)}
|
|
221
225
|
</div>
|
|
@@ -44,6 +44,8 @@ export interface PerPageOptions {
|
|
|
44
44
|
export interface PaginationTitles {
|
|
45
45
|
/** The title of a page displayed beside the page number */
|
|
46
46
|
page?: string;
|
|
47
|
+
/** The title of a page displayed beside the page number (plural form) */
|
|
48
|
+
pages?: string;
|
|
47
49
|
/** The type or title of the items being paginated */
|
|
48
50
|
items?: string;
|
|
49
51
|
/** The Title of the Pagination Options Menu */
|
|
@@ -168,6 +170,7 @@ export class Pagination extends React.Component<PaginationProps, { ouiaStateId:
|
|
|
168
170
|
titles: {
|
|
169
171
|
items: '',
|
|
170
172
|
page: '',
|
|
173
|
+
pages: '',
|
|
171
174
|
itemsPerPage: 'Items per page',
|
|
172
175
|
perPageSuffix: 'per page',
|
|
173
176
|
toFirstPage: 'Go to first page',
|
|
@@ -335,6 +338,7 @@ export class Pagination extends React.Component<PaginationProps, { ouiaStateId:
|
|
|
335
338
|
/>
|
|
336
339
|
<Navigation
|
|
337
340
|
pagesTitle={titles.page}
|
|
341
|
+
pagesTitlePlural={titles.pages}
|
|
338
342
|
toLastPage={titles.toLastPage}
|
|
339
343
|
toPreviousPage={titles.toPreviousPage}
|
|
340
344
|
toNextPage={titles.toNextPage}
|
|
@@ -50,6 +50,7 @@ exports[`component render custom pagination toggle 1`] = `
|
|
|
50
50
|
"ofWord": "of",
|
|
51
51
|
"optionsToggle": "Items per page",
|
|
52
52
|
"page": "",
|
|
53
|
+
"pages": "",
|
|
53
54
|
"paginationTitle": "Pagination",
|
|
54
55
|
"perPageSuffix": "per page",
|
|
55
56
|
"toFirstPage": "Go to first page",
|
|
@@ -461,6 +462,7 @@ exports[`component render custom pagination toggle 1`] = `
|
|
|
461
462
|
onSetPage={[Function]}
|
|
462
463
|
page={1}
|
|
463
464
|
pagesTitle=""
|
|
465
|
+
pagesTitlePlural=""
|
|
464
466
|
paginationTitle="Pagination"
|
|
465
467
|
perPage={10}
|
|
466
468
|
toFirstPage="Go to first page"
|
|
@@ -776,6 +778,7 @@ exports[`component render custom perPageOptions 1`] = `
|
|
|
776
778
|
"ofWord": "of",
|
|
777
779
|
"optionsToggle": "Items per page",
|
|
778
780
|
"page": "",
|
|
781
|
+
"pages": "",
|
|
779
782
|
"paginationTitle": "Pagination",
|
|
780
783
|
"perPageSuffix": "per page",
|
|
781
784
|
"toFirstPage": "Go to first page",
|
|
@@ -1212,6 +1215,7 @@ exports[`component render custom perPageOptions 1`] = `
|
|
|
1212
1215
|
onSetPage={[Function]}
|
|
1213
1216
|
page={1}
|
|
1214
1217
|
pagesTitle=""
|
|
1218
|
+
pagesTitlePlural=""
|
|
1215
1219
|
paginationTitle="Pagination"
|
|
1216
1220
|
perPage={10}
|
|
1217
1221
|
toFirstPage="Go to first page"
|
|
@@ -1539,6 +1543,7 @@ exports[`component render custom start end 1`] = `
|
|
|
1539
1543
|
"ofWord": "of",
|
|
1540
1544
|
"optionsToggle": "Items per page",
|
|
1541
1545
|
"page": "",
|
|
1546
|
+
"pages": "",
|
|
1542
1547
|
"paginationTitle": "Pagination",
|
|
1543
1548
|
"perPageSuffix": "per page",
|
|
1544
1549
|
"toFirstPage": "Go to first page",
|
|
@@ -2023,6 +2028,7 @@ exports[`component render custom start end 1`] = `
|
|
|
2023
2028
|
onSetPage={[Function]}
|
|
2024
2029
|
page={1}
|
|
2025
2030
|
pagesTitle=""
|
|
2031
|
+
pagesTitlePlural=""
|
|
2026
2032
|
paginationTitle="Pagination"
|
|
2027
2033
|
perPage={10}
|
|
2028
2034
|
toFirstPage="Go to first page"
|
|
@@ -2329,6 +2335,7 @@ exports[`component render empty per page options 1`] = `
|
|
|
2329
2335
|
"ofWord": "of",
|
|
2330
2336
|
"optionsToggle": "Items per page",
|
|
2331
2337
|
"page": "",
|
|
2338
|
+
"pages": "",
|
|
2332
2339
|
"paginationTitle": "Pagination",
|
|
2333
2340
|
"perPageSuffix": "per page",
|
|
2334
2341
|
"toFirstPage": "Go to first page",
|
|
@@ -2485,6 +2492,7 @@ exports[`component render empty per page options 1`] = `
|
|
|
2485
2492
|
onSetPage={[Function]}
|
|
2486
2493
|
page={1}
|
|
2487
2494
|
pagesTitle=""
|
|
2495
|
+
pagesTitlePlural=""
|
|
2488
2496
|
paginationTitle="Pagination"
|
|
2489
2497
|
perPage={10}
|
|
2490
2498
|
toFirstPage="Go to first page"
|
|
@@ -2838,6 +2846,7 @@ exports[`component render last page 1`] = `
|
|
|
2838
2846
|
"ofWord": "of",
|
|
2839
2847
|
"optionsToggle": "Items per page",
|
|
2840
2848
|
"page": "",
|
|
2849
|
+
"pages": "",
|
|
2841
2850
|
"paginationTitle": "Pagination",
|
|
2842
2851
|
"perPageSuffix": "per page",
|
|
2843
2852
|
"toFirstPage": "Go to first page",
|
|
@@ -3322,6 +3331,7 @@ exports[`component render last page 1`] = `
|
|
|
3322
3331
|
onSetPage={[Function]}
|
|
3323
3332
|
page={2}
|
|
3324
3333
|
pagesTitle=""
|
|
3334
|
+
pagesTitlePlural=""
|
|
3325
3335
|
paginationTitle="Pagination"
|
|
3326
3336
|
perPage={10}
|
|
3327
3337
|
toFirstPage="Go to first page"
|
|
@@ -3649,6 +3659,7 @@ exports[`component render limited number of pages 1`] = `
|
|
|
3649
3659
|
"ofWord": "of",
|
|
3650
3660
|
"optionsToggle": "Items per page",
|
|
3651
3661
|
"page": "",
|
|
3662
|
+
"pages": "",
|
|
3652
3663
|
"paginationTitle": "Pagination",
|
|
3653
3664
|
"perPageSuffix": "per page",
|
|
3654
3665
|
"toFirstPage": "Go to first page",
|
|
@@ -4133,6 +4144,7 @@ exports[`component render limited number of pages 1`] = `
|
|
|
4133
4144
|
onSetPage={[Function]}
|
|
4134
4145
|
page={1}
|
|
4135
4146
|
pagesTitle=""
|
|
4147
|
+
pagesTitlePlural=""
|
|
4136
4148
|
paginationTitle="Pagination"
|
|
4137
4149
|
perPage={20}
|
|
4138
4150
|
toFirstPage="Go to first page"
|
|
@@ -4462,6 +4474,7 @@ exports[`component render no items 1`] = `
|
|
|
4462
4474
|
"ofWord": "of",
|
|
4463
4475
|
"optionsToggle": "Items per page",
|
|
4464
4476
|
"page": "",
|
|
4477
|
+
"pages": "",
|
|
4465
4478
|
"paginationTitle": "Pagination",
|
|
4466
4479
|
"perPageSuffix": "per page",
|
|
4467
4480
|
"toFirstPage": "Go to first page",
|
|
@@ -4946,6 +4959,7 @@ exports[`component render no items 1`] = `
|
|
|
4946
4959
|
onSetPage={[Function]}
|
|
4947
4960
|
page={0}
|
|
4948
4961
|
pagesTitle=""
|
|
4962
|
+
pagesTitlePlural=""
|
|
4949
4963
|
paginationTitle="Pagination"
|
|
4950
4964
|
perPage={10}
|
|
4951
4965
|
toFirstPage="Go to first page"
|
|
@@ -5275,6 +5289,7 @@ exports[`component render should render correctly bottom 1`] = `
|
|
|
5275
5289
|
"ofWord": "of",
|
|
5276
5290
|
"optionsToggle": "Items per page",
|
|
5277
5291
|
"page": "",
|
|
5292
|
+
"pages": "",
|
|
5278
5293
|
"paginationTitle": "Pagination",
|
|
5279
5294
|
"perPageSuffix": "per page",
|
|
5280
5295
|
"toFirstPage": "Go to first page",
|
|
@@ -5735,6 +5750,7 @@ exports[`component render should render correctly bottom 1`] = `
|
|
|
5735
5750
|
onSetPage={[Function]}
|
|
5736
5751
|
page={1}
|
|
5737
5752
|
pagesTitle=""
|
|
5753
|
+
pagesTitlePlural=""
|
|
5738
5754
|
paginationTitle="Pagination"
|
|
5739
5755
|
perPage={10}
|
|
5740
5756
|
toFirstPage="Go to first page"
|
|
@@ -6062,6 +6078,7 @@ exports[`component render should render correctly bottom sticky 1`] = `
|
|
|
6062
6078
|
"ofWord": "of",
|
|
6063
6079
|
"optionsToggle": "Items per page",
|
|
6064
6080
|
"page": "",
|
|
6081
|
+
"pages": "",
|
|
6065
6082
|
"paginationTitle": "Pagination",
|
|
6066
6083
|
"perPageSuffix": "per page",
|
|
6067
6084
|
"toFirstPage": "Go to first page",
|
|
@@ -6522,6 +6539,7 @@ exports[`component render should render correctly bottom sticky 1`] = `
|
|
|
6522
6539
|
onSetPage={[Function]}
|
|
6523
6540
|
page={1}
|
|
6524
6541
|
pagesTitle=""
|
|
6542
|
+
pagesTitlePlural=""
|
|
6525
6543
|
paginationTitle="Pagination"
|
|
6526
6544
|
perPage={10}
|
|
6527
6545
|
toFirstPage="Go to first page"
|
|
@@ -6849,6 +6867,7 @@ exports[`component render should render correctly compact 1`] = `
|
|
|
6849
6867
|
"ofWord": "of",
|
|
6850
6868
|
"optionsToggle": "Items per page",
|
|
6851
6869
|
"page": "",
|
|
6870
|
+
"pages": "",
|
|
6852
6871
|
"paginationTitle": "Pagination",
|
|
6853
6872
|
"perPageSuffix": "per page",
|
|
6854
6873
|
"toFirstPage": "Go to first page",
|
|
@@ -7333,6 +7352,7 @@ exports[`component render should render correctly compact 1`] = `
|
|
|
7333
7352
|
onSetPage={[Function]}
|
|
7334
7353
|
page={1}
|
|
7335
7354
|
pagesTitle=""
|
|
7355
|
+
pagesTitlePlural=""
|
|
7336
7356
|
paginationTitle="Pagination"
|
|
7337
7357
|
perPage={10}
|
|
7338
7358
|
toFirstPage="Go to first page"
|
|
@@ -7519,6 +7539,7 @@ exports[`component render should render correctly disabled 1`] = `
|
|
|
7519
7539
|
"ofWord": "of",
|
|
7520
7540
|
"optionsToggle": "Items per page",
|
|
7521
7541
|
"page": "",
|
|
7542
|
+
"pages": "",
|
|
7522
7543
|
"paginationTitle": "Pagination",
|
|
7523
7544
|
"perPageSuffix": "per page",
|
|
7524
7545
|
"toFirstPage": "Go to first page",
|
|
@@ -8006,6 +8027,7 @@ exports[`component render should render correctly disabled 1`] = `
|
|
|
8006
8027
|
onSetPage={[Function]}
|
|
8007
8028
|
page={1}
|
|
8008
8029
|
pagesTitle=""
|
|
8030
|
+
pagesTitlePlural=""
|
|
8009
8031
|
paginationTitle="Pagination"
|
|
8010
8032
|
perPage={10}
|
|
8011
8033
|
toFirstPage="Go to first page"
|
|
@@ -8335,6 +8357,7 @@ exports[`component render should render correctly sticky 1`] = `
|
|
|
8335
8357
|
"ofWord": "of",
|
|
8336
8358
|
"optionsToggle": "Items per page",
|
|
8337
8359
|
"page": "",
|
|
8360
|
+
"pages": "",
|
|
8338
8361
|
"paginationTitle": "Pagination",
|
|
8339
8362
|
"perPageSuffix": "per page",
|
|
8340
8363
|
"toFirstPage": "Go to first page",
|
|
@@ -8819,6 +8842,7 @@ exports[`component render should render correctly sticky 1`] = `
|
|
|
8819
8842
|
onSetPage={[Function]}
|
|
8820
8843
|
page={1}
|
|
8821
8844
|
pagesTitle=""
|
|
8845
|
+
pagesTitlePlural=""
|
|
8822
8846
|
paginationTitle="Pagination"
|
|
8823
8847
|
perPage={10}
|
|
8824
8848
|
toFirstPage="Go to first page"
|
|
@@ -9146,6 +9170,7 @@ exports[`component render should render correctly top 1`] = `
|
|
|
9146
9170
|
"ofWord": "of",
|
|
9147
9171
|
"optionsToggle": "Items per page",
|
|
9148
9172
|
"page": "",
|
|
9173
|
+
"pages": "",
|
|
9149
9174
|
"paginationTitle": "Pagination",
|
|
9150
9175
|
"perPageSuffix": "per page",
|
|
9151
9176
|
"toFirstPage": "Go to first page",
|
|
@@ -9630,6 +9655,7 @@ exports[`component render should render correctly top 1`] = `
|
|
|
9630
9655
|
onSetPage={[Function]}
|
|
9631
9656
|
page={1}
|
|
9632
9657
|
pagesTitle=""
|
|
9658
|
+
pagesTitlePlural=""
|
|
9633
9659
|
paginationTitle="Pagination"
|
|
9634
9660
|
perPage={10}
|
|
9635
9661
|
toFirstPage="Go to first page"
|
|
@@ -10432,6 +10458,7 @@ exports[`component render titles 1`] = `
|
|
|
10432
10458
|
onSetPage={[Function]}
|
|
10433
10459
|
page={1}
|
|
10434
10460
|
pagesTitle="books"
|
|
10461
|
+
pagesTitlePlural=""
|
|
10435
10462
|
paginationTitle="Pagination"
|
|
10436
10463
|
perPage={10}
|
|
10437
10464
|
toFirstPage="Go to first page"
|
|
@@ -10788,6 +10815,7 @@ exports[`component render up drop direction 1`] = `
|
|
|
10788
10815
|
"ofWord": "of",
|
|
10789
10816
|
"optionsToggle": "Items per page",
|
|
10790
10817
|
"page": "",
|
|
10818
|
+
"pages": "",
|
|
10791
10819
|
"paginationTitle": "Pagination",
|
|
10792
10820
|
"perPageSuffix": "per page",
|
|
10793
10821
|
"toFirstPage": "Go to first page",
|
|
@@ -11272,6 +11300,7 @@ exports[`component render up drop direction 1`] = `
|
|
|
11272
11300
|
onSetPage={[Function]}
|
|
11273
11301
|
page={1}
|
|
11274
11302
|
pagesTitle=""
|
|
11303
|
+
pagesTitlePlural=""
|
|
11275
11304
|
paginationTitle="Pagination"
|
|
11276
11305
|
perPage={10}
|
|
11277
11306
|
toFirstPage="Go to first page"
|
|
@@ -11599,6 +11628,7 @@ exports[`component render zero results 1`] = `
|
|
|
11599
11628
|
"ofWord": "of",
|
|
11600
11629
|
"optionsToggle": "Items per page",
|
|
11601
11630
|
"page": "",
|
|
11631
|
+
"pages": "",
|
|
11602
11632
|
"paginationTitle": "Pagination",
|
|
11603
11633
|
"perPageSuffix": "per page",
|
|
11604
11634
|
"toFirstPage": "Go to first page",
|
|
@@ -12083,6 +12113,7 @@ exports[`component render zero results 1`] = `
|
|
|
12083
12113
|
onSetPage={[Function]}
|
|
12084
12114
|
page={0}
|
|
12085
12115
|
pagesTitle=""
|
|
12116
|
+
pagesTitlePlural=""
|
|
12086
12117
|
paginationTitle="Pagination"
|
|
12087
12118
|
perPage={10}
|
|
12088
12119
|
toFirstPage="Go to first page"
|
|
@@ -9,7 +9,16 @@ import { TimeOption } from './TimeOption';
|
|
|
9
9
|
import { KeyTypes, SelectDirection } from '../Select';
|
|
10
10
|
import { InputGroup } from '../InputGroup';
|
|
11
11
|
import { TextInput, TextInputProps } from '../TextInput';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
parseTime,
|
|
14
|
+
validateTime,
|
|
15
|
+
makeTimeOptions,
|
|
16
|
+
amSuffix,
|
|
17
|
+
pmSuffix,
|
|
18
|
+
getHours,
|
|
19
|
+
getMinutes,
|
|
20
|
+
isWithinMinMax
|
|
21
|
+
} from './TimePickerUtils';
|
|
13
22
|
|
|
14
23
|
export interface TimePickerProps
|
|
15
24
|
extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange' | 'onFocus' | 'onBlur' | 'disabled' | 'ref'> {
|
|
@@ -27,6 +36,8 @@ export interface TimePickerProps
|
|
|
27
36
|
time?: string | Date;
|
|
28
37
|
/** Error message to display when the time is provided in an invalid format. */
|
|
29
38
|
invalidFormatErrorMessage?: string;
|
|
39
|
+
/** Error message to display when the time provided is not within the minTime/maxTime constriants */
|
|
40
|
+
invalidMinMaxErrorMessage?: string;
|
|
30
41
|
/** True if the time is 24 hour time. False if the time is 12 hour time */
|
|
31
42
|
is24Hour?: boolean;
|
|
32
43
|
/** Optional event handler called each time the value in the time picker input changes. */
|
|
@@ -50,6 +61,10 @@ export interface TimePickerProps
|
|
|
50
61
|
stepMinutes?: number;
|
|
51
62
|
/** Additional props for input field */
|
|
52
63
|
inputProps?: TextInputProps;
|
|
64
|
+
/** A time string indicating the minimum value allowed. The format could be an ISO 8601 formatted date string or in 'HH{delimiter}MM' format */
|
|
65
|
+
minTime?: string | Date;
|
|
66
|
+
/** A time string indicating the maximum value allowed. The format could be an ISO 8601 formatted date string or in 'HH{delimiter}MM' format */
|
|
67
|
+
maxTime?: string | Date;
|
|
53
68
|
}
|
|
54
69
|
|
|
55
70
|
interface TimePickerState {
|
|
@@ -59,6 +74,8 @@ interface TimePickerState {
|
|
|
59
74
|
focusedIndex: number;
|
|
60
75
|
scrollIndex: number;
|
|
61
76
|
timeRegex: RegExp;
|
|
77
|
+
minTimeState: string;
|
|
78
|
+
maxTimeState: string;
|
|
62
79
|
}
|
|
63
80
|
|
|
64
81
|
export class TimePicker extends React.Component<TimePickerProps, TimePickerState> {
|
|
@@ -74,6 +91,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
74
91
|
time: '',
|
|
75
92
|
is24Hour: false,
|
|
76
93
|
invalidFormatErrorMessage: 'Invalid time format',
|
|
94
|
+
invalidMinMaxErrorMessage: 'Invalid time entered',
|
|
77
95
|
placeholder: 'hh:mm',
|
|
78
96
|
delimiter: ':',
|
|
79
97
|
'aria-label': 'Time picker',
|
|
@@ -81,22 +99,31 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
81
99
|
direction: 'down',
|
|
82
100
|
width: 150,
|
|
83
101
|
stepMinutes: 30,
|
|
84
|
-
inputProps: {}
|
|
102
|
+
inputProps: {},
|
|
103
|
+
minTime: '',
|
|
104
|
+
maxTime: ''
|
|
85
105
|
};
|
|
86
106
|
|
|
87
107
|
constructor(props: TimePickerProps) {
|
|
88
108
|
super(props);
|
|
89
|
-
|
|
90
109
|
const { is24Hour, delimiter, time } = this.props;
|
|
110
|
+
let { minTime, maxTime } = this.props;
|
|
111
|
+
if (minTime === '') {
|
|
112
|
+
minTime = is24Hour ? `00${delimiter}00` : `12${delimiter}00AM`;
|
|
113
|
+
}
|
|
114
|
+
if (maxTime === '') {
|
|
115
|
+
maxTime = is24Hour ? `23${delimiter}59` : `11${delimiter}59PM`;
|
|
116
|
+
}
|
|
91
117
|
const timeRegex = this.getRegExp();
|
|
92
|
-
|
|
93
118
|
this.state = {
|
|
94
119
|
isInvalid: false,
|
|
95
120
|
isOpen: false,
|
|
96
121
|
timeState: parseTime(time, timeRegex, delimiter, !is24Hour),
|
|
97
122
|
focusedIndex: null,
|
|
98
123
|
scrollIndex: 0,
|
|
99
|
-
timeRegex
|
|
124
|
+
timeRegex,
|
|
125
|
+
minTimeState: parseTime(minTime, timeRegex, delimiter, !is24Hour),
|
|
126
|
+
maxTimeState: parseTime(maxTime, timeRegex, delimiter, !is24Hour)
|
|
100
127
|
};
|
|
101
128
|
}
|
|
102
129
|
|
|
@@ -253,7 +280,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
253
280
|
getOptions = () =>
|
|
254
281
|
(this.menuRef && this.menuRef.current ? Array.from(this.menuRef.current.children) : []) as HTMLElement[];
|
|
255
282
|
|
|
256
|
-
|
|
283
|
+
isValidFormat = (time: string) => {
|
|
257
284
|
if (this.props.validateTime) {
|
|
258
285
|
return this.props.validateTime(time);
|
|
259
286
|
}
|
|
@@ -261,6 +288,14 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
261
288
|
return validateTime(time, this.state.timeRegex, delimiter, !is24Hour);
|
|
262
289
|
};
|
|
263
290
|
|
|
291
|
+
isValidTime = (time: string) => {
|
|
292
|
+
const { delimiter } = this.props;
|
|
293
|
+
const { minTimeState, maxTimeState } = this.state;
|
|
294
|
+
return isWithinMinMax(minTimeState, maxTimeState, time, delimiter);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
isValid = (time: string) => this.isValidFormat(time) && this.isValidTime(time);
|
|
298
|
+
|
|
264
299
|
onToggle = (isOpen: boolean) => {
|
|
265
300
|
// on close, parse and validate input
|
|
266
301
|
this.setState(prevState => {
|
|
@@ -329,6 +364,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
329
364
|
menuAppendTo,
|
|
330
365
|
is24Hour,
|
|
331
366
|
invalidFormatErrorMessage,
|
|
367
|
+
invalidMinMaxErrorMessage,
|
|
332
368
|
direction,
|
|
333
369
|
stepMinutes,
|
|
334
370
|
width,
|
|
@@ -338,11 +374,14 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
338
374
|
time,
|
|
339
375
|
validateTime,
|
|
340
376
|
inputProps,
|
|
377
|
+
minTime,
|
|
378
|
+
maxTime,
|
|
341
379
|
...props
|
|
342
380
|
} = this.props;
|
|
343
|
-
const { timeState, isOpen, isInvalid, focusedIndex } = this.state;
|
|
381
|
+
const { timeState, isOpen, isInvalid, focusedIndex, minTimeState, maxTimeState } = this.state;
|
|
344
382
|
const style = { '--pf-c-date-picker__input--c-form-control--Width': width } as React.CSSProperties;
|
|
345
|
-
const options = makeTimeOptions(stepMinutes, !is24Hour, delimiter);
|
|
383
|
+
const options = makeTimeOptions(stepMinutes, !is24Hour, delimiter, minTimeState, maxTimeState);
|
|
384
|
+
const isValidFormat = this.isValidFormat(timeState);
|
|
346
385
|
const randomId = id || getUniqueId('time-picker');
|
|
347
386
|
|
|
348
387
|
const menuContainer = (
|
|
@@ -408,7 +447,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
408
447
|
</InputGroup>
|
|
409
448
|
{isInvalid && (
|
|
410
449
|
<div className={css(datePickerStyles.datePickerHelperText, datePickerStyles.modifiers.error)}>
|
|
411
|
-
{invalidFormatErrorMessage}
|
|
450
|
+
{!isValidFormat ? invalidFormatErrorMessage : invalidMinMaxErrorMessage}
|
|
412
451
|
</div>
|
|
413
452
|
)}
|
|
414
453
|
</div>
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
export const amSuffix = ' AM';
|
|
2
2
|
export const pmSuffix = ' PM';
|
|
3
3
|
|
|
4
|
-
export const makeTimeOptions = (
|
|
4
|
+
export const makeTimeOptions = (
|
|
5
|
+
stepMinutes: number,
|
|
6
|
+
hour12: boolean,
|
|
7
|
+
delimiter: string,
|
|
8
|
+
minTime: string,
|
|
9
|
+
maxTime: string
|
|
10
|
+
) => {
|
|
5
11
|
const res = [];
|
|
6
12
|
const iter = new Date(new Date().setHours(0, 0, 0, 0));
|
|
7
13
|
const iterDay = iter.getDay();
|
|
8
14
|
while (iter.getDay() === iterDay) {
|
|
9
|
-
let hour = iter.getHours();
|
|
15
|
+
let hour: string | number = iter.getHours();
|
|
10
16
|
let suffix = amSuffix;
|
|
11
17
|
if (hour12) {
|
|
12
18
|
if (hour === 0) {
|
|
@@ -18,19 +24,18 @@ export const makeTimeOptions = (stepMinutes: number, hour12: boolean, delimiter:
|
|
|
18
24
|
hour %= 12;
|
|
19
25
|
}
|
|
20
26
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
hour = hour12 ? hour.toString() : hour.toString().padStart(2, '0');
|
|
28
|
+
const minutes = iter
|
|
29
|
+
.getMinutes()
|
|
30
|
+
.toString()
|
|
31
|
+
.padStart(2, '0');
|
|
32
|
+
const timeOption = hour + delimiter + minutes + (hour12 ? suffix : '');
|
|
33
|
+
// time option is valid if within min/max constraints
|
|
34
|
+
if (isWithinMinMax(minTime, maxTime, timeOption, delimiter)) {
|
|
35
|
+
res.push(timeOption);
|
|
36
|
+
}
|
|
31
37
|
iter.setMinutes(iter.getMinutes() + stepMinutes);
|
|
32
38
|
}
|
|
33
|
-
|
|
34
39
|
return res;
|
|
35
40
|
};
|
|
36
41
|
|
|
@@ -53,26 +58,20 @@ export const parseTime = (time: string | Date, timeRegex: RegExp, delimiter: str
|
|
|
53
58
|
} else if (typeof time === 'string') {
|
|
54
59
|
time = time.trim();
|
|
55
60
|
if (is12Hour && time !== '' && validateTime(time, timeRegex, delimiter, is12Hour)) {
|
|
61
|
+
const [, hours, minutes, suffix = ''] = timeRegex.exec(time);
|
|
62
|
+
const uppercaseSuffix = suffix.toUpperCase();
|
|
56
63
|
// Format AM/PM according to design
|
|
57
64
|
let ampm = '';
|
|
58
|
-
if (
|
|
59
|
-
time = time
|
|
60
|
-
.toUpperCase()
|
|
61
|
-
.replace(amSuffix.toUpperCase().trim(), '')
|
|
62
|
-
.trim();
|
|
65
|
+
if (uppercaseSuffix === amSuffix.toUpperCase().trim()) {
|
|
63
66
|
ampm = amSuffix;
|
|
64
|
-
} else if (
|
|
65
|
-
time = time
|
|
66
|
-
.toUpperCase()
|
|
67
|
-
.replace(pmSuffix.toUpperCase().trim(), '')
|
|
68
|
-
.trim();
|
|
67
|
+
} else if (uppercaseSuffix === pmSuffix.toUpperCase().trim()) {
|
|
69
68
|
ampm = pmSuffix;
|
|
70
69
|
} else {
|
|
71
70
|
// if this 12 hour time is missing am/pm but otherwise valid,
|
|
72
71
|
// append am/pm depending on time of day
|
|
73
72
|
ampm = new Date().getHours() > 11 ? pmSuffix : amSuffix;
|
|
74
73
|
}
|
|
75
|
-
return `${
|
|
74
|
+
return `${hours}${delimiter}${minutes}${ampm}`;
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
return time.toString();
|
|
@@ -111,3 +110,34 @@ export const getMinutes = (time: string, timeRegex: RegExp) => {
|
|
|
111
110
|
const parts = time.match(timeRegex);
|
|
112
111
|
return parts && parts.length ? parseInt(parts[2]) : null;
|
|
113
112
|
};
|
|
113
|
+
|
|
114
|
+
export const isWithinMinMax = (minTime: string, maxTime: string, time: string, delimiter: string) => {
|
|
115
|
+
// do not throw error if empty string
|
|
116
|
+
if (time.trim() === '') {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
const convertTo24Hour = (time: string): string => {
|
|
120
|
+
const timeReg = new RegExp(`^\\s*(\\d\\d?)${delimiter}([0-5]\\d)\\s*([AaPp][Mm])?\\s*$`);
|
|
121
|
+
const regMatches = timeReg.exec(time);
|
|
122
|
+
if (!regMatches || !regMatches.length) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
let hours = regMatches[1].padStart(2, '0');
|
|
126
|
+
const minutes = regMatches[2];
|
|
127
|
+
const suffix = regMatches[3] || '';
|
|
128
|
+
if (suffix.toUpperCase() === 'PM' && hours !== '12') {
|
|
129
|
+
hours = `${parseInt(hours) + 12}`;
|
|
130
|
+
} else if (suffix.toUpperCase() === 'AM' && hours === '12') {
|
|
131
|
+
hours = '00';
|
|
132
|
+
}
|
|
133
|
+
return `${hours}${delimiter}${minutes}`;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// correctly format as 24hr times (12:30AM => 00:30, 1:15 => 01:15)
|
|
137
|
+
minTime = convertTo24Hour(minTime);
|
|
138
|
+
time = convertTo24Hour(time);
|
|
139
|
+
maxTime = convertTo24Hour(maxTime);
|
|
140
|
+
|
|
141
|
+
// simple string comparison for 24hr times
|
|
142
|
+
return minTime <= time && time <= maxTime;
|
|
143
|
+
};
|
|
@@ -41,3 +41,14 @@ import { TimePicker } from '@patternfly/react-core';
|
|
|
41
41
|
|
|
42
42
|
<TimePicker is24Hour delimiter="h" placeholder=""/>
|
|
43
43
|
```
|
|
44
|
+
|
|
45
|
+
### Minimum/maximum times
|
|
46
|
+
|
|
47
|
+
The `minTime`/`maxTime` props restrict the options shown for the user to select from as well as trigger the `invalidMinMaxErrorMessage` if the user enters a time outside this range.
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import React from 'react';
|
|
51
|
+
import { TimePicker } from '@patternfly/react-core';
|
|
52
|
+
|
|
53
|
+
<TimePicker is24Hour minTime="9:30" maxTime="17:15" placeholder="14:00"/>
|
|
54
|
+
```
|