@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.
Files changed (74) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/esm/components/MultipleFileUpload/MultipleFileUploadStatusItem.d.ts +4 -2
  3. package/dist/esm/components/MultipleFileUpload/MultipleFileUploadStatusItem.d.ts.map +1 -1
  4. package/dist/esm/components/MultipleFileUpload/MultipleFileUploadStatusItem.js +2 -2
  5. package/dist/esm/components/MultipleFileUpload/MultipleFileUploadStatusItem.js.map +1 -1
  6. package/dist/esm/components/Pagination/OptionsToggle.d.ts +10 -6
  7. package/dist/esm/components/Pagination/OptionsToggle.d.ts.map +1 -1
  8. package/dist/esm/components/Pagination/OptionsToggle.js +10 -4
  9. package/dist/esm/components/Pagination/OptionsToggle.js.map +1 -1
  10. package/dist/esm/components/Pagination/Pagination.d.ts +7 -3
  11. package/dist/esm/components/Pagination/Pagination.d.ts.map +1 -1
  12. package/dist/esm/components/Pagination/Pagination.js +5 -4
  13. package/dist/esm/components/Pagination/Pagination.js.map +1 -1
  14. package/dist/esm/components/Pagination/PaginationOptionsMenu.d.ts +12 -8
  15. package/dist/esm/components/Pagination/PaginationOptionsMenu.d.ts.map +1 -1
  16. package/dist/esm/components/Pagination/PaginationOptionsMenu.js +6 -5
  17. package/dist/esm/components/Pagination/PaginationOptionsMenu.js.map +1 -1
  18. package/dist/js/components/MultipleFileUpload/MultipleFileUploadStatusItem.d.ts +4 -2
  19. package/dist/js/components/MultipleFileUpload/MultipleFileUploadStatusItem.d.ts.map +1 -1
  20. package/dist/js/components/MultipleFileUpload/MultipleFileUploadStatusItem.js +2 -2
  21. package/dist/js/components/MultipleFileUpload/MultipleFileUploadStatusItem.js.map +1 -1
  22. package/dist/js/components/Pagination/OptionsToggle.d.ts +10 -6
  23. package/dist/js/components/Pagination/OptionsToggle.d.ts.map +1 -1
  24. package/dist/js/components/Pagination/OptionsToggle.js +10 -4
  25. package/dist/js/components/Pagination/OptionsToggle.js.map +1 -1
  26. package/dist/js/components/Pagination/Pagination.d.ts +7 -3
  27. package/dist/js/components/Pagination/Pagination.d.ts.map +1 -1
  28. package/dist/js/components/Pagination/Pagination.js +5 -4
  29. package/dist/js/components/Pagination/Pagination.js.map +1 -1
  30. package/dist/js/components/Pagination/PaginationOptionsMenu.d.ts +12 -8
  31. package/dist/js/components/Pagination/PaginationOptionsMenu.d.ts.map +1 -1
  32. package/dist/js/components/Pagination/PaginationOptionsMenu.js +6 -5
  33. package/dist/js/components/Pagination/PaginationOptionsMenu.js.map +1 -1
  34. package/dist/umd/react-core.css +69 -69
  35. package/dist/umd/react-core.js +23 -15
  36. package/dist/umd/react-core.min.js +1 -1
  37. package/package.json +5 -5
  38. package/src/components/MultipleFileUpload/MultipleFileUploadStatusItem.tsx +6 -2
  39. package/src/components/MultipleFileUpload/__tests__/MultipleFileUpload.test.tsx +8 -8
  40. package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadButton.test.tsx +7 -7
  41. package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadInfo.test.tsx +5 -5
  42. package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadMain.test.tsx +11 -11
  43. package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadStatus.test.tsx +11 -9
  44. package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadStatusItem.test.tsx +28 -13
  45. package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadTitle.test.tsx +11 -11
  46. package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadTitleIcon.test.tsx +5 -5
  47. package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadTitleText.test.tsx +5 -5
  48. package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadTitleTextSeparator.test.tsx +7 -5
  49. package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUpload.test.tsx.snap +42 -124
  50. package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadButton.test.tsx.snap +36 -86
  51. package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadInfo.test.tsx.snap +6 -8
  52. package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadMain.test.tsx.snap +85 -179
  53. package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadStatus.test.tsx.snap +188 -383
  54. package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadStatusItem.test.tsx.snap +596 -330
  55. package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadTitle.test.tsx.snap +32 -49
  56. package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadTitleIcon.test.tsx.snap +9 -11
  57. package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadTitleText.test.tsx.snap +6 -8
  58. package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadTitleTextSeparator.test.tsx.snap +6 -8
  59. package/src/components/Pagination/OptionsToggle.tsx +56 -46
  60. package/src/components/Pagination/Pagination.tsx +12 -5
  61. package/src/components/Pagination/PaginationOptionsMenu.tsx +20 -12
  62. package/src/components/Pagination/__tests__/Generated/__snapshots__/OptionsToggle.test.tsx.snap +1 -0
  63. package/src/components/Pagination/__tests__/Pagination.test.tsx +6 -4
  64. package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +223 -0
  65. package/src/components/Pagination/examples/Pagination.md +11 -1
  66. package/src/components/TimePicker/__tests__/TimePicker.test.tsx +1 -1
  67. package/src/components/Dropdown/__tests__/Generated/InternalDropdownItem.test.tsx +0 -42
  68. package/src/components/Dropdown/__tests__/Generated/__snapshots__/InternalDropdownItem.test.tsx.snap +0 -10
  69. package/src/components/Select/__tests__/Generated/SelectGroup.test.tsx +0 -25
  70. package/src/components/Select/__tests__/Generated/SelectMenu.test.tsx +0 -25
  71. package/src/components/Select/__tests__/Generated/__snapshots__/SelectGroup.test.tsx.snap +0 -18
  72. package/src/components/Select/__tests__/Generated/__snapshots__/SelectMenu.test.tsx.snap +0 -10
  73. package/src/components/Toolbar/__tests__/Generated/ToolbarToggleGroup.test.tsx +0 -27
  74. 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
- <MultipleFileUploadTitle
5
- className="test"
6
- >
4
+ <DocumentFragment>
7
5
  <div
8
- className="pf-c-multiple-file-upload__title test"
6
+ class="pf-c-multiple-file-upload__title test"
9
7
  />
10
- </MultipleFileUploadTitle>
8
+ </DocumentFragment>
11
9
  `;
12
10
 
13
11
  exports[`MultipleFileUploadTitle renders with expected class names 1`] = `
14
- <MultipleFileUploadTitle>
12
+ <DocumentFragment>
15
13
  <div
16
- className="pf-c-multiple-file-upload__title"
14
+ class="pf-c-multiple-file-upload__title"
17
15
  />
18
- </MultipleFileUploadTitle>
16
+ </DocumentFragment>
19
17
  `;
20
18
 
21
19
  exports[`MultipleFileUploadTitle renders with title icon 1`] = `
22
- <MultipleFileUploadTitle
23
- icon="icon"
24
- >
20
+ <DocumentFragment>
25
21
  <div
26
- className="pf-c-multiple-file-upload__title"
22
+ class="pf-c-multiple-file-upload__title"
27
23
  >
28
- <MultipleFileUploadTitleIcon>
29
- <div
30
- className="pf-c-multiple-file-upload__title-icon"
31
- >
32
- icon
33
- </div>
34
- </MultipleFileUploadTitleIcon>
24
+ <div
25
+ class="pf-c-multiple-file-upload__title-icon"
26
+ >
27
+ icon
28
+ </div>
35
29
  </div>
36
- </MultipleFileUploadTitle>
30
+ </DocumentFragment>
37
31
  `;
38
32
 
39
33
  exports[`MultipleFileUploadTitle renders with title text 1`] = `
40
- <MultipleFileUploadTitle
41
- text="text"
42
- >
34
+ <DocumentFragment>
43
35
  <div
44
- className="pf-c-multiple-file-upload__title"
36
+ class="pf-c-multiple-file-upload__title"
45
37
  >
46
- <MultipleFileUploadTitleText>
47
- <div
48
- className="pf-c-multiple-file-upload__title-text"
49
- >
50
- text
51
- </div>
52
- </MultipleFileUploadTitleText>
38
+ <div
39
+ class="pf-c-multiple-file-upload__title-text"
40
+ >
41
+ text
42
+ </div>
53
43
  </div>
54
- </MultipleFileUploadTitle>
44
+ </DocumentFragment>
55
45
  `;
56
46
 
57
47
  exports[`MultipleFileUploadTitle renders with title text separator 1`] = `
58
- <MultipleFileUploadTitle
59
- text="text"
60
- textSeparator="text separator"
61
- >
48
+ <DocumentFragment>
62
49
  <div
63
- className="pf-c-multiple-file-upload__title"
50
+ class="pf-c-multiple-file-upload__title"
64
51
  >
65
- <MultipleFileUploadTitleText>
52
+ <div
53
+ class="pf-c-multiple-file-upload__title-text"
54
+ >
55
+ text
66
56
  <div
67
- className="pf-c-multiple-file-upload__title-text"
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
- </MultipleFileUploadTitleText>
61
+ </div>
79
62
  </div>
80
- </MultipleFileUploadTitle>
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
- <MultipleFileUploadTitleIcon
5
- className="test"
6
- >
4
+ <DocumentFragment>
7
5
  <div
8
- className="pf-c-multiple-file-upload__title-icon test"
6
+ class="pf-c-multiple-file-upload__title-icon test"
7
+ data-testid="test-id"
9
8
  />
10
- </MultipleFileUploadTitleIcon>
9
+ </DocumentFragment>
11
10
  `;
12
11
 
13
12
  exports[`MultipleFileUploadTitleIcon renders with expected class names 1`] = `
14
- <MultipleFileUploadTitleIcon>
13
+ <DocumentFragment>
15
14
  <div
16
- className="pf-c-multiple-file-upload__title-icon"
17
- >
18
- Foo
19
- </div>
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
- <MultipleFileUploadTitleText
5
- className="test"
6
- >
4
+ <DocumentFragment>
7
5
  <div
8
- className="pf-c-multiple-file-upload__title-text test"
6
+ class="pf-c-multiple-file-upload__title-text test"
9
7
  >
10
8
  Foo
11
9
  </div>
12
- </MultipleFileUploadTitleText>
10
+ </DocumentFragment>
13
11
  `;
14
12
 
15
13
  exports[`MultipleFileUploadTitleText renders with expected class names 1`] = `
16
- <MultipleFileUploadTitleText>
14
+ <DocumentFragment>
17
15
  <div
18
- className="pf-c-multiple-file-upload__title-text"
16
+ class="pf-c-multiple-file-upload__title-text"
19
17
  >
20
18
  Foo
21
19
  </div>
22
- </MultipleFileUploadTitleText>
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
- <MultipleFileUploadTitleTextSeparator
5
- className="test"
6
- >
4
+ <DocumentFragment>
7
5
  <div
8
- className="pf-c-multiple-file-upload__title-text-separator test"
6
+ class="pf-c-multiple-file-upload__title-text-separator test"
9
7
  >
10
8
  Foo
11
9
  </div>
12
- </MultipleFileUploadTitleTextSeparator>
10
+ </DocumentFragment>
13
11
  `;
14
12
 
15
13
  exports[`MultipleFileUploadTitleTextSeparator renders with expected class names 1`] = `
16
- <MultipleFileUploadTitleTextSeparator>
14
+ <DocumentFragment>
17
15
  <div
18
- className="pf-c-multiple-file-upload__title-text-separator"
16
+ class="pf-c-multiple-file-upload__title-text-separator"
19
17
  >
20
18
  Foo
21
19
  </div>
22
- </MultipleFileUploadTitleTextSeparator>
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 Options Toggle */
12
+ /** Accessible label for the options toggle */
13
13
  optionsToggle?: string;
14
- /** The Title of the Pagination Options Menu */
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 Pagination Options Menu */
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 Options Menu toggle */
26
+ /** Event function that fires when user clicks the options menu toggle */
27
27
  onToggle?: (isOpen: boolean) => void;
28
- /** Flag indicating if the Options Menu dropdown is open or not */
28
+ /** Flag indicating if the options menu dropdown is open or not */
29
29
  isOpen?: boolean;
30
- /** Flag indicating if the Options Menu is disabled */
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 = 'Items per page',
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
- }: OptionsToggleProps) => (
62
- <div
63
- className={css(
64
- styles.optionsMenuToggle,
65
- isDisabled && styles.modifiers.disabled,
66
- styles.modifiers.plain,
67
- styles.modifiers.text
68
- )}
69
- >
70
- {showToggle && (
71
- <React.Fragment>
72
- <span className={css(styles.optionsMenuToggleText)}>
73
- {typeof ToggleTemplate === 'string' ? (
74
- fillTemplate(ToggleTemplate, { firstIndex, lastIndex, ofWord, itemCount, itemsTitle })
75
- ) : (
76
- <ToggleTemplate
77
- firstIndex={firstIndex}
78
- lastIndex={lastIndex}
79
- ofWord={ofWord}
80
- itemCount={itemCount}
81
- itemsTitle={itemsTitle}
82
- />
83
- )}
84
- </span>
85
- <DropdownToggle
86
- onEnter={onEnter}
87
- aria-label={optionsToggle}
88
- onToggle={onToggle}
89
- isDisabled={isDisabled || (itemCount && itemCount <= 0)}
90
- isOpen={isOpen}
91
- id={`${widgetId}-toggle-${toggleId++}`}
92
- className={styles.optionsMenuToggleButton}
93
- parentRef={parentRef}
94
- ></DropdownToggle>
95
- </React.Fragment>
96
- )}
97
- </div>
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 Title of the Pagination Options Menu */
51
+ /** The title of the pagination options menu */
52
52
  itemsPerPage?: string;
53
- /** The suffix to be displayed after each option on the Options Menu dropdown */
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 Options Toggle */
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: 'Items per page',
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 Pagination Options Menu */
11
+ /** Custom class name added to the pagination options menu */
12
12
  className?: string;
13
- /** Id added to the title of the Pagination Options Menu */
13
+ /** Id added to the title of the Pagination options menu */
14
14
  widgetId?: string;
15
- /** Flag indicating if Pagination Options Menu is disabled */
15
+ /** Flag indicating if pagination options menu is disabled */
16
16
  isDisabled?: boolean;
17
- /** Menu will open up or open down from the Options menu toggle */
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 Options Menu dropdown */
19
+ /** Array of titles and values which will be the options on the options menu dropdown */
20
20
  perPageOptions?: PerPageOptions[];
21
- /** The Title of the Pagination Options Menu */
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 Options Menu dropdown */
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
- /** The text to be displayed on the Options Toggle */
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: 'Items per page',
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: styles.optionsMenuToggleButtonIcon,
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()}
@@ -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', () => {