@patternfly/react-core 4.203.0 → 4.203.1
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 +8 -0
- package/dist/esm/components/MultipleFileUpload/MultipleFileUploadStatusItem.d.ts +4 -2
- package/dist/esm/components/MultipleFileUpload/MultipleFileUploadStatusItem.d.ts.map +1 -1
- package/dist/esm/components/MultipleFileUpload/MultipleFileUploadStatusItem.js +2 -2
- package/dist/esm/components/MultipleFileUpload/MultipleFileUploadStatusItem.js.map +1 -1
- package/dist/esm/components/Pagination/OptionsToggle.d.ts +10 -6
- package/dist/esm/components/Pagination/OptionsToggle.d.ts.map +1 -1
- package/dist/esm/components/Pagination/OptionsToggle.js +10 -4
- package/dist/esm/components/Pagination/OptionsToggle.js.map +1 -1
- package/dist/esm/components/Pagination/Pagination.d.ts +7 -3
- package/dist/esm/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/esm/components/Pagination/Pagination.js +5 -4
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/Pagination/PaginationOptionsMenu.d.ts +12 -8
- package/dist/esm/components/Pagination/PaginationOptionsMenu.d.ts.map +1 -1
- package/dist/esm/components/Pagination/PaginationOptionsMenu.js +6 -5
- package/dist/esm/components/Pagination/PaginationOptionsMenu.js.map +1 -1
- package/dist/js/components/MultipleFileUpload/MultipleFileUploadStatusItem.d.ts +4 -2
- package/dist/js/components/MultipleFileUpload/MultipleFileUploadStatusItem.d.ts.map +1 -1
- package/dist/js/components/MultipleFileUpload/MultipleFileUploadStatusItem.js +2 -2
- package/dist/js/components/MultipleFileUpload/MultipleFileUploadStatusItem.js.map +1 -1
- package/dist/js/components/Pagination/OptionsToggle.d.ts +10 -6
- package/dist/js/components/Pagination/OptionsToggle.d.ts.map +1 -1
- package/dist/js/components/Pagination/OptionsToggle.js +10 -4
- package/dist/js/components/Pagination/OptionsToggle.js.map +1 -1
- package/dist/js/components/Pagination/Pagination.d.ts +7 -3
- package/dist/js/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/js/components/Pagination/Pagination.js +5 -4
- package/dist/js/components/Pagination/Pagination.js.map +1 -1
- package/dist/js/components/Pagination/PaginationOptionsMenu.d.ts +12 -8
- package/dist/js/components/Pagination/PaginationOptionsMenu.d.ts.map +1 -1
- package/dist/js/components/Pagination/PaginationOptionsMenu.js +6 -5
- package/dist/js/components/Pagination/PaginationOptionsMenu.js.map +1 -1
- package/dist/umd/react-core.css +69 -69
- package/dist/umd/react-core.js +23 -15
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +5 -5
- package/src/components/MultipleFileUpload/MultipleFileUploadStatusItem.tsx +6 -2
- package/src/components/MultipleFileUpload/__tests__/MultipleFileUpload.test.tsx +8 -8
- package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadButton.test.tsx +7 -7
- package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadInfo.test.tsx +5 -5
- package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadMain.test.tsx +11 -11
- package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadStatus.test.tsx +11 -9
- package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadStatusItem.test.tsx +28 -13
- package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadTitle.test.tsx +11 -11
- package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadTitleIcon.test.tsx +5 -5
- package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadTitleText.test.tsx +5 -5
- package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadTitleTextSeparator.test.tsx +7 -5
- package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUpload.test.tsx.snap +42 -124
- package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadButton.test.tsx.snap +36 -86
- package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadInfo.test.tsx.snap +6 -8
- package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadMain.test.tsx.snap +85 -179
- package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadStatus.test.tsx.snap +188 -383
- package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadStatusItem.test.tsx.snap +596 -330
- package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadTitle.test.tsx.snap +32 -49
- package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadTitleIcon.test.tsx.snap +9 -11
- package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadTitleText.test.tsx.snap +6 -8
- package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadTitleTextSeparator.test.tsx.snap +6 -8
- package/src/components/Pagination/OptionsToggle.tsx +56 -46
- package/src/components/Pagination/Pagination.tsx +12 -5
- package/src/components/Pagination/PaginationOptionsMenu.tsx +20 -12
- package/src/components/Pagination/__tests__/Generated/__snapshots__/OptionsToggle.test.tsx.snap +1 -0
- package/src/components/Pagination/__tests__/Pagination.test.tsx +6 -4
- package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +223 -0
- package/src/components/Pagination/examples/Pagination.md +11 -1
- package/src/components/TimePicker/__tests__/TimePicker.test.tsx +1 -1
- package/src/components/Dropdown/__tests__/Generated/InternalDropdownItem.test.tsx +0 -42
- package/src/components/Dropdown/__tests__/Generated/__snapshots__/InternalDropdownItem.test.tsx.snap +0 -10
- package/src/components/Select/__tests__/Generated/SelectGroup.test.tsx +0 -25
- package/src/components/Select/__tests__/Generated/SelectMenu.test.tsx +0 -25
- package/src/components/Select/__tests__/Generated/__snapshots__/SelectGroup.test.tsx.snap +0 -18
- package/src/components/Select/__tests__/Generated/__snapshots__/SelectMenu.test.tsx.snap +0 -10
- package/src/components/Toolbar/__tests__/Generated/ToolbarToggleGroup.test.tsx +0 -27
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarToggleGroup.test.tsx.snap +0 -29
|
@@ -1,81 +1,64 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`MultipleFileUploadTitle renders custom class names 1`] = `
|
|
4
|
-
<
|
|
5
|
-
className="test"
|
|
6
|
-
>
|
|
4
|
+
<DocumentFragment>
|
|
7
5
|
<div
|
|
8
|
-
|
|
6
|
+
class="pf-c-multiple-file-upload__title test"
|
|
9
7
|
/>
|
|
10
|
-
</
|
|
8
|
+
</DocumentFragment>
|
|
11
9
|
`;
|
|
12
10
|
|
|
13
11
|
exports[`MultipleFileUploadTitle renders with expected class names 1`] = `
|
|
14
|
-
<
|
|
12
|
+
<DocumentFragment>
|
|
15
13
|
<div
|
|
16
|
-
|
|
14
|
+
class="pf-c-multiple-file-upload__title"
|
|
17
15
|
/>
|
|
18
|
-
</
|
|
16
|
+
</DocumentFragment>
|
|
19
17
|
`;
|
|
20
18
|
|
|
21
19
|
exports[`MultipleFileUploadTitle renders with title icon 1`] = `
|
|
22
|
-
<
|
|
23
|
-
icon="icon"
|
|
24
|
-
>
|
|
20
|
+
<DocumentFragment>
|
|
25
21
|
<div
|
|
26
|
-
|
|
22
|
+
class="pf-c-multiple-file-upload__title"
|
|
27
23
|
>
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
</div>
|
|
34
|
-
</MultipleFileUploadTitleIcon>
|
|
24
|
+
<div
|
|
25
|
+
class="pf-c-multiple-file-upload__title-icon"
|
|
26
|
+
>
|
|
27
|
+
icon
|
|
28
|
+
</div>
|
|
35
29
|
</div>
|
|
36
|
-
</
|
|
30
|
+
</DocumentFragment>
|
|
37
31
|
`;
|
|
38
32
|
|
|
39
33
|
exports[`MultipleFileUploadTitle renders with title text 1`] = `
|
|
40
|
-
<
|
|
41
|
-
text="text"
|
|
42
|
-
>
|
|
34
|
+
<DocumentFragment>
|
|
43
35
|
<div
|
|
44
|
-
|
|
36
|
+
class="pf-c-multiple-file-upload__title"
|
|
45
37
|
>
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
</div>
|
|
52
|
-
</MultipleFileUploadTitleText>
|
|
38
|
+
<div
|
|
39
|
+
class="pf-c-multiple-file-upload__title-text"
|
|
40
|
+
>
|
|
41
|
+
text
|
|
42
|
+
</div>
|
|
53
43
|
</div>
|
|
54
|
-
</
|
|
44
|
+
</DocumentFragment>
|
|
55
45
|
`;
|
|
56
46
|
|
|
57
47
|
exports[`MultipleFileUploadTitle renders with title text separator 1`] = `
|
|
58
|
-
<
|
|
59
|
-
text="text"
|
|
60
|
-
textSeparator="text separator"
|
|
61
|
-
>
|
|
48
|
+
<DocumentFragment>
|
|
62
49
|
<div
|
|
63
|
-
|
|
50
|
+
class="pf-c-multiple-file-upload__title"
|
|
64
51
|
>
|
|
65
|
-
<
|
|
52
|
+
<div
|
|
53
|
+
class="pf-c-multiple-file-upload__title-text"
|
|
54
|
+
>
|
|
55
|
+
text
|
|
66
56
|
<div
|
|
67
|
-
|
|
57
|
+
class="pf-c-multiple-file-upload__title-text-separator"
|
|
68
58
|
>
|
|
69
|
-
text
|
|
70
|
-
<MultipleFileUploadTitleTextSeparator>
|
|
71
|
-
<div
|
|
72
|
-
className="pf-c-multiple-file-upload__title-text-separator"
|
|
73
|
-
>
|
|
74
|
-
text separator
|
|
75
|
-
</div>
|
|
76
|
-
</MultipleFileUploadTitleTextSeparator>
|
|
59
|
+
text separator
|
|
77
60
|
</div>
|
|
78
|
-
</
|
|
61
|
+
</div>
|
|
79
62
|
</div>
|
|
80
|
-
</
|
|
63
|
+
</DocumentFragment>
|
|
81
64
|
`;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`MultipleFileUploadTitleIcon renders custom class names 1`] = `
|
|
4
|
-
<
|
|
5
|
-
className="test"
|
|
6
|
-
>
|
|
4
|
+
<DocumentFragment>
|
|
7
5
|
<div
|
|
8
|
-
|
|
6
|
+
class="pf-c-multiple-file-upload__title-icon test"
|
|
7
|
+
data-testid="test-id"
|
|
9
8
|
/>
|
|
10
|
-
</
|
|
9
|
+
</DocumentFragment>
|
|
11
10
|
`;
|
|
12
11
|
|
|
13
12
|
exports[`MultipleFileUploadTitleIcon renders with expected class names 1`] = `
|
|
14
|
-
<
|
|
13
|
+
<DocumentFragment>
|
|
15
14
|
<div
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
</MultipleFileUploadTitleIcon>
|
|
15
|
+
class="pf-c-multiple-file-upload__title-icon"
|
|
16
|
+
data-testid="test-id"
|
|
17
|
+
/>
|
|
18
|
+
</DocumentFragment>
|
|
21
19
|
`;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`MultipleFileUploadTitleText renders custom class names 1`] = `
|
|
4
|
-
<
|
|
5
|
-
className="test"
|
|
6
|
-
>
|
|
4
|
+
<DocumentFragment>
|
|
7
5
|
<div
|
|
8
|
-
|
|
6
|
+
class="pf-c-multiple-file-upload__title-text test"
|
|
9
7
|
>
|
|
10
8
|
Foo
|
|
11
9
|
</div>
|
|
12
|
-
</
|
|
10
|
+
</DocumentFragment>
|
|
13
11
|
`;
|
|
14
12
|
|
|
15
13
|
exports[`MultipleFileUploadTitleText renders with expected class names 1`] = `
|
|
16
|
-
<
|
|
14
|
+
<DocumentFragment>
|
|
17
15
|
<div
|
|
18
|
-
|
|
16
|
+
class="pf-c-multiple-file-upload__title-text"
|
|
19
17
|
>
|
|
20
18
|
Foo
|
|
21
19
|
</div>
|
|
22
|
-
</
|
|
20
|
+
</DocumentFragment>
|
|
23
21
|
`;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`MultipleFileUploadTitleTextSeparator renders custom class names 1`] = `
|
|
4
|
-
<
|
|
5
|
-
className="test"
|
|
6
|
-
>
|
|
4
|
+
<DocumentFragment>
|
|
7
5
|
<div
|
|
8
|
-
|
|
6
|
+
class="pf-c-multiple-file-upload__title-text-separator test"
|
|
9
7
|
>
|
|
10
8
|
Foo
|
|
11
9
|
</div>
|
|
12
|
-
</
|
|
10
|
+
</DocumentFragment>
|
|
13
11
|
`;
|
|
14
12
|
|
|
15
13
|
exports[`MultipleFileUploadTitleTextSeparator renders with expected class names 1`] = `
|
|
16
|
-
<
|
|
14
|
+
<DocumentFragment>
|
|
17
15
|
<div
|
|
18
|
-
|
|
16
|
+
class="pf-c-multiple-file-upload__title-text-separator"
|
|
19
17
|
>
|
|
20
18
|
Foo
|
|
21
19
|
</div>
|
|
22
|
-
</
|
|
20
|
+
</DocumentFragment>
|
|
23
21
|
`;
|
|
@@ -9,9 +9,9 @@ import { DropdownToggle } from '../Dropdown';
|
|
|
9
9
|
export interface OptionsToggleProps extends React.HTMLProps<HTMLDivElement> {
|
|
10
10
|
/** The type or title of the items being paginated */
|
|
11
11
|
itemsTitle?: string;
|
|
12
|
-
/** Accessible label for the
|
|
12
|
+
/** Accessible label for the options toggle */
|
|
13
13
|
optionsToggle?: string;
|
|
14
|
-
/** The
|
|
14
|
+
/** The title of the pagination options menu */
|
|
15
15
|
itemsPerPageTitle?: string;
|
|
16
16
|
/** The first index of the items being paginated */
|
|
17
17
|
firstIndex?: number;
|
|
@@ -19,15 +19,15 @@ export interface OptionsToggleProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
19
19
|
lastIndex?: number;
|
|
20
20
|
/** The total number of items being paginated */
|
|
21
21
|
itemCount?: number;
|
|
22
|
-
/** Id added to the title of the
|
|
22
|
+
/** Id added to the title of the pagination options menu */
|
|
23
23
|
widgetId?: string;
|
|
24
24
|
/** showToggle */
|
|
25
25
|
showToggle?: boolean;
|
|
26
|
-
/** Event function that fires when user clicks the
|
|
26
|
+
/** Event function that fires when user clicks the options menu toggle */
|
|
27
27
|
onToggle?: (isOpen: boolean) => void;
|
|
28
|
-
/** Flag indicating if the
|
|
28
|
+
/** Flag indicating if the options menu dropdown is open or not */
|
|
29
29
|
isOpen?: boolean;
|
|
30
|
-
/** Flag indicating if the
|
|
30
|
+
/** Flag indicating if the options menu is disabled */
|
|
31
31
|
isDisabled?: boolean;
|
|
32
32
|
/** */
|
|
33
33
|
parentRef?: HTMLElement;
|
|
@@ -37,12 +37,16 @@ export interface OptionsToggleProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
37
37
|
onEnter?: () => void;
|
|
38
38
|
/** Label for the English word "of" */
|
|
39
39
|
ofWord?: string;
|
|
40
|
+
/** Component to be used for wrapping the toggle contents. Use 'button' when you want
|
|
41
|
+
* all of the toggle text to be clickable.
|
|
42
|
+
*/
|
|
43
|
+
perPageComponent?: 'div' | 'button';
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
let toggleId = 0;
|
|
43
47
|
export const OptionsToggle: React.FunctionComponent<OptionsToggleProps> = ({
|
|
44
48
|
itemsTitle = 'items',
|
|
45
|
-
optionsToggle
|
|
49
|
+
optionsToggle,
|
|
46
50
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
47
51
|
itemsPerPageTitle = 'Items per page',
|
|
48
52
|
ofWord = 'of',
|
|
@@ -57,43 +61,49 @@ export const OptionsToggle: React.FunctionComponent<OptionsToggleProps> = ({
|
|
|
57
61
|
isDisabled = false,
|
|
58
62
|
parentRef = null,
|
|
59
63
|
toggleTemplate: ToggleTemplate,
|
|
60
|
-
onEnter = null
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
64
|
+
onEnter = null,
|
|
65
|
+
perPageComponent = 'div'
|
|
66
|
+
}: OptionsToggleProps) => {
|
|
67
|
+
const isDiv = perPageComponent === 'div';
|
|
68
|
+
const toggleClasses = css(
|
|
69
|
+
styles.optionsMenuToggle,
|
|
70
|
+
isDisabled && styles.modifiers.disabled,
|
|
71
|
+
styles.modifiers.plain,
|
|
72
|
+
styles.modifiers.text
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const template =
|
|
76
|
+
typeof ToggleTemplate === 'string' ? (
|
|
77
|
+
fillTemplate(ToggleTemplate, { firstIndex, lastIndex, ofWord, itemCount, itemsTitle })
|
|
78
|
+
) : (
|
|
79
|
+
<ToggleTemplate
|
|
80
|
+
firstIndex={firstIndex}
|
|
81
|
+
lastIndex={lastIndex}
|
|
82
|
+
ofWord={ofWord}
|
|
83
|
+
itemCount={itemCount}
|
|
84
|
+
itemsTitle={itemsTitle}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const dropdown = showToggle && (
|
|
89
|
+
<React.Fragment>
|
|
90
|
+
{isDiv && <span className={css(styles.optionsMenuToggleText)}>{template}</span>}
|
|
91
|
+
<DropdownToggle
|
|
92
|
+
onEnter={onEnter}
|
|
93
|
+
aria-label={isDiv ? optionsToggle || 'Items per page' : optionsToggle}
|
|
94
|
+
onToggle={onToggle}
|
|
95
|
+
isDisabled={isDisabled || (itemCount && itemCount <= 0)}
|
|
96
|
+
isOpen={isOpen}
|
|
97
|
+
id={`${widgetId}-toggle-${toggleId++}`}
|
|
98
|
+
className={isDiv ? styles.optionsMenuToggleButton : toggleClasses}
|
|
99
|
+
parentRef={parentRef}
|
|
100
|
+
aria-haspopup="listbox"
|
|
101
|
+
>
|
|
102
|
+
{!isDiv && template}
|
|
103
|
+
</DropdownToggle>
|
|
104
|
+
</React.Fragment>
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
return isDiv ? <div className={toggleClasses}>{dropdown}</div> : dropdown;
|
|
108
|
+
};
|
|
99
109
|
OptionsToggle.displayName = 'OptionsToggle';
|
|
@@ -48,9 +48,9 @@ export interface PaginationTitles {
|
|
|
48
48
|
pages?: string;
|
|
49
49
|
/** The type or title of the items being paginated */
|
|
50
50
|
items?: string;
|
|
51
|
-
/** The
|
|
51
|
+
/** The title of the pagination options menu */
|
|
52
52
|
itemsPerPage?: string;
|
|
53
|
-
/** The suffix to be displayed after each option on the
|
|
53
|
+
/** The suffix to be displayed after each option on the options menu dropdown */
|
|
54
54
|
perPageSuffix?: string;
|
|
55
55
|
/** Accessible label for the button which moves to the first page */
|
|
56
56
|
toFirstPage?: string;
|
|
@@ -60,7 +60,7 @@ export interface PaginationTitles {
|
|
|
60
60
|
toLastPage?: string;
|
|
61
61
|
/** Accessible label for the button which moves to the next page */
|
|
62
62
|
toNextPage?: string;
|
|
63
|
-
/** Accessible label for the
|
|
63
|
+
/** Accessible label for the options toggle */
|
|
64
64
|
optionsToggle?: string;
|
|
65
65
|
/** Accessible label for the input displaying the current page */
|
|
66
66
|
currPage?: string;
|
|
@@ -141,6 +141,10 @@ export interface PaginationProps extends React.HTMLProps<HTMLDivElement>, OUIAPr
|
|
|
141
141
|
onPageInput?: (event: React.SyntheticEvent<HTMLButtonElement>, page: number) => void;
|
|
142
142
|
/** Function called when user selects number of items per page. */
|
|
143
143
|
onPerPageSelect?: OnPerPageSelect;
|
|
144
|
+
/** Component to be used for wrapping the toggle contents. Use 'button' when you want
|
|
145
|
+
* all of the toggle text to be clickable.
|
|
146
|
+
*/
|
|
147
|
+
perPageComponent?: 'div' | 'button';
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
const handleInputWidth = (lastPage: number, node: HTMLDivElement) => {
|
|
@@ -177,7 +181,7 @@ export class Pagination extends React.Component<PaginationProps, { ouiaStateId:
|
|
|
177
181
|
toPreviousPage: 'Go to previous page',
|
|
178
182
|
toLastPage: 'Go to last page',
|
|
179
183
|
toNextPage: 'Go to next page',
|
|
180
|
-
optionsToggle: '
|
|
184
|
+
optionsToggle: '',
|
|
181
185
|
currPage: 'Current page',
|
|
182
186
|
paginationTitle: 'Pagination',
|
|
183
187
|
ofWord: 'of'
|
|
@@ -197,7 +201,8 @@ export class Pagination extends React.Component<PaginationProps, { ouiaStateId:
|
|
|
197
201
|
onNextClick: () => undefined,
|
|
198
202
|
onPageInput: () => undefined,
|
|
199
203
|
onLastClick: () => undefined,
|
|
200
|
-
ouiaSafe: true
|
|
204
|
+
ouiaSafe: true,
|
|
205
|
+
perPageComponent: 'div'
|
|
201
206
|
};
|
|
202
207
|
|
|
203
208
|
state = {
|
|
@@ -252,6 +257,7 @@ export class Pagination extends React.Component<PaginationProps, { ouiaStateId:
|
|
|
252
257
|
onLastClick,
|
|
253
258
|
ouiaId,
|
|
254
259
|
ouiaSafe,
|
|
260
|
+
perPageComponent,
|
|
255
261
|
...props
|
|
256
262
|
} = this.props;
|
|
257
263
|
const dropDirection = dropDirectionProp || (variant === 'bottom' && !isStatic ? 'up' : 'down');
|
|
@@ -335,6 +341,7 @@ export class Pagination extends React.Component<PaginationProps, { ouiaStateId:
|
|
|
335
341
|
widgetId={widgetId}
|
|
336
342
|
toggleTemplate={toggleTemplate}
|
|
337
343
|
isDisabled={isDisabled}
|
|
344
|
+
perPageComponent={perPageComponent}
|
|
338
345
|
/>
|
|
339
346
|
<Navigation
|
|
340
347
|
pagesTitle={titles.page}
|
|
@@ -8,25 +8,25 @@ import { ToggleTemplateProps, ToggleTemplate } from './ToggleTemplate';
|
|
|
8
8
|
import { PerPageOptions, OnPerPageSelect } from './Pagination';
|
|
9
9
|
|
|
10
10
|
export interface PaginationOptionsMenuProps extends React.HTMLProps<HTMLDivElement> {
|
|
11
|
-
/** Custom class name added to the
|
|
11
|
+
/** Custom class name added to the pagination options menu */
|
|
12
12
|
className?: string;
|
|
13
|
-
/** Id added to the title of the Pagination
|
|
13
|
+
/** Id added to the title of the Pagination options menu */
|
|
14
14
|
widgetId?: string;
|
|
15
|
-
/** Flag indicating if
|
|
15
|
+
/** Flag indicating if pagination options menu is disabled */
|
|
16
16
|
isDisabled?: boolean;
|
|
17
|
-
/** Menu will open up or open down from the
|
|
17
|
+
/** Menu will open up or open down from the options menu toggle */
|
|
18
18
|
dropDirection?: 'up' | 'down';
|
|
19
|
-
/** Array of titles and values which will be the options on the
|
|
19
|
+
/** Array of titles and values which will be the options on the options menu dropdown */
|
|
20
20
|
perPageOptions?: PerPageOptions[];
|
|
21
|
-
/** The
|
|
21
|
+
/** The title of the pagination options menu */
|
|
22
22
|
itemsPerPageTitle?: string;
|
|
23
23
|
/** Current page number */
|
|
24
24
|
page?: number;
|
|
25
|
-
/** The suffix to be displayed after each option on the
|
|
25
|
+
/** The suffix to be displayed after each option on the options menu dropdown */
|
|
26
26
|
perPageSuffix?: string;
|
|
27
27
|
/** The type or title of the items being paginated */
|
|
28
28
|
itemsTitle?: string;
|
|
29
|
-
/**
|
|
29
|
+
/** Accessible label for the options toggle */
|
|
30
30
|
optionsToggle?: string;
|
|
31
31
|
/** The total number of items being paginated */
|
|
32
32
|
itemCount?: number;
|
|
@@ -46,6 +46,10 @@ export interface PaginationOptionsMenuProps extends React.HTMLProps<HTMLDivEleme
|
|
|
46
46
|
onPerPageSelect?: OnPerPageSelect;
|
|
47
47
|
/** Label for the English word "of" */
|
|
48
48
|
ofWord?: string;
|
|
49
|
+
/** Component to be used for wrapping the toggle contents. Use 'button' when you want
|
|
50
|
+
* all of the toggle text to be clickable.
|
|
51
|
+
*/
|
|
52
|
+
perPageComponent?: 'div' | 'button';
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
interface PaginationOptionsMenuState {
|
|
@@ -63,7 +67,7 @@ export class PaginationOptionsMenu extends React.Component<PaginationOptionsMenu
|
|
|
63
67
|
perPageOptions: [] as PerPageOptions[],
|
|
64
68
|
itemsPerPageTitle: 'Items per page',
|
|
65
69
|
perPageSuffix: 'per page',
|
|
66
|
-
optionsToggle: '
|
|
70
|
+
optionsToggle: '',
|
|
67
71
|
ofWord: 'of',
|
|
68
72
|
perPage: 0,
|
|
69
73
|
firstIndex: 0,
|
|
@@ -71,7 +75,8 @@ export class PaginationOptionsMenu extends React.Component<PaginationOptionsMenu
|
|
|
71
75
|
defaultToFullPage: false,
|
|
72
76
|
itemsTitle: 'items',
|
|
73
77
|
toggleTemplate: ToggleTemplate,
|
|
74
|
-
onPerPageSelect: () => null as any
|
|
78
|
+
onPerPageSelect: () => null as any,
|
|
79
|
+
perPageComponent: 'div'
|
|
75
80
|
};
|
|
76
81
|
|
|
77
82
|
constructor(props: PaginationOptionsMenuProps) {
|
|
@@ -144,7 +149,8 @@ export class PaginationOptionsMenu extends React.Component<PaginationOptionsMenu
|
|
|
144
149
|
lastIndex,
|
|
145
150
|
itemCount,
|
|
146
151
|
itemsTitle,
|
|
147
|
-
ofWord
|
|
152
|
+
ofWord,
|
|
153
|
+
perPageComponent
|
|
148
154
|
} = this.props;
|
|
149
155
|
const { isOpen } = this.state;
|
|
150
156
|
|
|
@@ -153,7 +159,8 @@ export class PaginationOptionsMenu extends React.Component<PaginationOptionsMenu
|
|
|
153
159
|
value={{
|
|
154
160
|
id: widgetId,
|
|
155
161
|
onSelect: this.onSelect,
|
|
156
|
-
toggleIndicatorClass:
|
|
162
|
+
toggleIndicatorClass:
|
|
163
|
+
perPageComponent === 'div' ? styles.optionsMenuToggleButtonIcon : styles.optionsMenuToggleIcon,
|
|
157
164
|
toggleTextClass: styles.optionsMenuToggleText,
|
|
158
165
|
menuClass: styles.optionsMenuMenu,
|
|
159
166
|
itemClass: styles.optionsMenuMenuItem,
|
|
@@ -184,6 +191,7 @@ export class PaginationOptionsMenu extends React.Component<PaginationOptionsMenu
|
|
|
184
191
|
toggleTemplate={toggleTemplate}
|
|
185
192
|
parentRef={this.parentRef.current}
|
|
186
193
|
isDisabled={isDisabled}
|
|
194
|
+
perPageComponent={perPageComponent}
|
|
187
195
|
/>
|
|
188
196
|
}
|
|
189
197
|
dropdownItems={this.renderItems()}
|
package/src/components/Pagination/__tests__/Generated/__snapshots__/OptionsToggle.test.tsx.snap
CHANGED
|
@@ -10,6 +10,7 @@ exports[`OptionsToggle should match snapshot (auto-generated) 1`] = `
|
|
|
10
10
|
/>
|
|
11
11
|
<button
|
|
12
12
|
aria-expanded="false"
|
|
13
|
+
aria-haspopup="listbox"
|
|
13
14
|
aria-label="'Select'"
|
|
14
15
|
class="pf-c-dropdown__toggle pf-c-options-menu__toggle-button"
|
|
15
16
|
data-ouia-component-id="OUIA-Generated-DropdownToggle-1"
|
|
@@ -75,10 +75,7 @@ describe('Pagination', () => {
|
|
|
75
75
|
|
|
76
76
|
test('custom pagination toggle', () => {
|
|
77
77
|
const { asFragment } = render(
|
|
78
|
-
<Pagination
|
|
79
|
-
itemCount={40}
|
|
80
|
-
toggleTemplate={'${firstIndex} - ${lastIndex} - ${itemCount} - ${itemsTitle}'}
|
|
81
|
-
/>
|
|
78
|
+
<Pagination itemCount={40} toggleTemplate={'${firstIndex} - ${lastIndex} - ${itemCount} - ${itemsTitle}'} />
|
|
82
79
|
);
|
|
83
80
|
expect(asFragment()).toMatchSnapshot();
|
|
84
81
|
});
|
|
@@ -110,6 +107,11 @@ describe('Pagination', () => {
|
|
|
110
107
|
render(<Pagination toggleTemplate={'I am a string'} />);
|
|
111
108
|
expect(screen.getAllByText('I am a string')[0]).toBeInTheDocument();
|
|
112
109
|
});
|
|
110
|
+
|
|
111
|
+
test('should render correctly button variant', () => {
|
|
112
|
+
const { asFragment } = render(<Pagination perPageComponent="button" itemCount={20} />);
|
|
113
|
+
expect(asFragment()).toMatchSnapshot();
|
|
114
|
+
});
|
|
113
115
|
});
|
|
114
116
|
|
|
115
117
|
describe('API', () => {
|