@patternfly/react-core 3.144.1 → 3.146.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/esm/components/DataToolbar/DataToolbarFilter.js +16 -5
  3. package/dist/esm/components/Drawer/Drawer.js +26 -36
  4. package/dist/esm/components/Drawer/DrawerActions.js +28 -0
  5. package/dist/esm/components/Drawer/DrawerCloseButton.js +36 -0
  6. package/dist/esm/components/Drawer/DrawerContent.js +9 -6
  7. package/dist/esm/components/Drawer/DrawerContentBody.js +30 -0
  8. package/dist/esm/components/Drawer/DrawerHead.js +33 -0
  9. package/dist/esm/components/Drawer/DrawerMain.js +28 -0
  10. package/dist/esm/components/Drawer/DrawerPanelBody.js +30 -0
  11. package/dist/esm/components/Drawer/DrawerPanelContent.js +12 -8
  12. package/dist/esm/components/Drawer/DrawerSection.js +28 -0
  13. package/dist/esm/components/Drawer/index.js +7 -1
  14. package/dist/esm/components/Dropdown/Toggle.js +3 -1
  15. package/dist/esm/components/FileUpload/FileUpload.js +123 -0
  16. package/dist/esm/components/FileUpload/FileUploadField.js +123 -0
  17. package/dist/esm/components/FileUpload/index.js +3 -0
  18. package/dist/esm/components/Modal/ModalBoxDescription.js +30 -0
  19. package/dist/esm/components/Modal/ModalContent.js +2 -3
  20. package/dist/esm/components/Select/Select.js +70 -36
  21. package/dist/esm/components/Select/SelectMenu.js +34 -25
  22. package/dist/esm/components/Select/SelectOption.js +15 -5
  23. package/dist/esm/components/Select/SelectToggle.js +6 -3
  24. package/dist/esm/components/index.js +1 -0
  25. package/dist/esm/helpers/fileUtils.js +32 -0
  26. package/dist/esm/helpers/util.js +1 -1
  27. package/dist/js/components/DataToolbar/DataToolbarFilter.d.ts +8 -2
  28. package/dist/js/components/DataToolbar/DataToolbarFilter.js +21 -12
  29. package/dist/js/components/Drawer/Drawer.d.ts +7 -6
  30. package/dist/js/components/Drawer/Drawer.js +32 -67
  31. package/dist/js/components/Drawer/DrawerActions.d.ts +8 -0
  32. package/dist/js/components/Drawer/DrawerActions.js +44 -0
  33. package/dist/js/components/Drawer/DrawerCloseButton.d.ts +10 -0
  34. package/dist/js/components/Drawer/DrawerCloseButton.js +58 -0
  35. package/dist/js/components/Drawer/DrawerContent.d.ts +3 -1
  36. package/dist/js/components/Drawer/DrawerContent.js +9 -5
  37. package/dist/js/components/Drawer/DrawerContentBody.d.ts +10 -0
  38. package/dist/js/components/Drawer/DrawerContentBody.js +47 -0
  39. package/dist/js/components/Drawer/DrawerHead.d.ts +10 -0
  40. package/dist/js/components/Drawer/DrawerHead.js +51 -0
  41. package/dist/js/components/Drawer/DrawerMain.d.ts +8 -0
  42. package/dist/js/components/Drawer/DrawerMain.js +44 -0
  43. package/dist/js/components/Drawer/DrawerPanelBody.d.ts +10 -0
  44. package/dist/js/components/Drawer/DrawerPanelBody.js +47 -0
  45. package/dist/js/components/Drawer/DrawerPanelContent.d.ts +3 -4
  46. package/dist/js/components/Drawer/DrawerPanelContent.js +16 -10
  47. package/dist/js/components/Drawer/DrawerSection.d.ts +8 -0
  48. package/dist/js/components/Drawer/DrawerSection.js +44 -0
  49. package/dist/js/components/Drawer/index.d.ts +7 -1
  50. package/dist/js/components/Drawer/index.js +75 -3
  51. package/dist/js/components/Dropdown/Toggle.js +2 -1
  52. package/dist/js/components/FileUpload/FileUpload.d.ts +57 -0
  53. package/dist/js/components/FileUpload/FileUpload.js +151 -0
  54. package/dist/js/components/FileUpload/FileUploadField.d.ts +57 -0
  55. package/dist/js/components/FileUpload/FileUploadField.js +167 -0
  56. package/dist/js/components/FileUpload/index.d.ts +2 -0
  57. package/dist/js/components/FileUpload/index.js +30 -0
  58. package/dist/js/components/Modal/ModalBoxDescription.d.ts +10 -0
  59. package/dist/js/components/Modal/ModalBoxDescription.js +49 -0
  60. package/dist/js/components/Modal/ModalContent.js +3 -4
  61. package/dist/js/components/Select/Select.d.ts +2 -0
  62. package/dist/js/components/Select/Select.js +79 -35
  63. package/dist/js/components/Select/SelectMenu.d.ts +3 -1
  64. package/dist/js/components/Select/SelectMenu.js +30 -14
  65. package/dist/js/components/Select/SelectOption.d.ts +2 -0
  66. package/dist/js/components/Select/SelectOption.js +15 -5
  67. package/dist/js/components/Select/SelectToggle.d.ts +2 -0
  68. package/dist/js/components/Select/SelectToggle.js +6 -3
  69. package/dist/js/components/index.d.ts +1 -0
  70. package/dist/js/components/index.js +12 -0
  71. package/dist/js/helpers/fileUtils.d.ts +12 -0
  72. package/dist/js/helpers/fileUtils.js +45 -0
  73. package/dist/js/helpers/util.js +3 -1
  74. package/dist/umd/components/DataToolbar/DataToolbarFilter.js +16 -5
  75. package/dist/umd/components/Drawer/Drawer.js +27 -50
  76. package/dist/umd/components/Drawer/DrawerActions.js +154 -0
  77. package/dist/umd/components/Drawer/DrawerCloseButton.js +162 -0
  78. package/dist/umd/components/Drawer/DrawerContent.js +12 -10
  79. package/dist/umd/components/Drawer/DrawerContentBody.js +156 -0
  80. package/dist/umd/components/Drawer/DrawerHead.js +158 -0
  81. package/dist/umd/components/Drawer/DrawerMain.js +154 -0
  82. package/dist/umd/components/Drawer/DrawerPanelBody.js +156 -0
  83. package/dist/umd/components/Drawer/DrawerPanelContent.js +16 -13
  84. package/dist/umd/components/Drawer/DrawerSection.js +154 -0
  85. package/dist/umd/components/Drawer/index.js +60 -6
  86. package/dist/umd/components/Dropdown/Toggle.js +3 -1
  87. package/dist/umd/components/FileUpload/FileUpload.js +291 -0
  88. package/dist/umd/components/FileUpload/FileUploadField.js +243 -0
  89. package/dist/umd/components/FileUpload/index.js +38 -0
  90. package/dist/umd/components/Modal/ModalBoxDescription.js +156 -0
  91. package/dist/umd/components/Modal/ModalContent.js +5 -8
  92. package/dist/umd/components/Select/Select.js +71 -38
  93. package/dist/umd/components/Select/SelectMenu.js +37 -29
  94. package/dist/umd/components/Select/SelectOption.js +15 -5
  95. package/dist/umd/components/Select/SelectToggle.js +6 -3
  96. package/dist/umd/components/index.js +13 -4
  97. package/dist/umd/helpers/fileUtils.js +52 -0
  98. package/dist/umd/helpers/util.js +1 -1
  99. package/package.json +7 -6
  100. package/src/components/ApplicationLauncher/__tests__/__snapshots__/ApplicationLauncher.test.tsx.snap +0 -6
  101. package/src/components/DataToolbar/DataToolbarFilter.tsx +18 -6
  102. package/src/components/DataToolbar/__tests__/__snapshots__/DataToolbar.test.tsx.snap +16 -0
  103. package/src/components/Drawer/Drawer.tsx +36 -31
  104. package/src/components/Drawer/DrawerActions.tsx +21 -0
  105. package/src/components/Drawer/DrawerCloseButton.tsx +28 -0
  106. package/src/components/Drawer/DrawerContent.tsx +11 -4
  107. package/src/components/Drawer/DrawerContentBody.tsx +24 -0
  108. package/src/components/Drawer/DrawerHead.tsx +27 -0
  109. package/src/components/Drawer/DrawerMain.tsx +21 -0
  110. package/src/components/Drawer/DrawerPanelBody.tsx +24 -0
  111. package/src/components/Drawer/DrawerPanelContent.tsx +19 -8
  112. package/src/components/Drawer/DrawerSection.tsx +21 -0
  113. package/src/components/Drawer/__tests__/Drawer.test.tsx +24 -13
  114. package/src/components/Drawer/__tests__/Generated/__snapshots__/Drawer.test.tsx.snap +13 -5
  115. package/src/components/Drawer/__tests__/Generated/__snapshots__/DrawerContent.test.tsx.snap +8 -6
  116. package/src/components/Drawer/__tests__/Generated/__snapshots__/DrawerPanelContent.test.tsx.snap +3 -11
  117. package/src/components/Drawer/__tests__/__snapshots__/Drawer.test.tsx.snap +764 -69
  118. package/src/components/Drawer/examples/Drawer.md +434 -11
  119. package/src/components/Drawer/index.ts +7 -1
  120. package/src/components/Dropdown/Toggle.tsx +2 -0
  121. package/src/components/Dropdown/__tests__/__snapshots__/Dropdown.test.tsx.snap +0 -14
  122. package/src/components/Dropdown/__tests__/__snapshots__/DropdownToggle.test.tsx.snap +0 -5
  123. package/src/components/Dropdown/__tests__/__snapshots__/Toggle.test.tsx.snap +0 -2
  124. package/src/components/FileUpload/FileUpload.tsx +150 -0
  125. package/src/components/FileUpload/FileUploadField.tsx +176 -0
  126. package/src/components/FileUpload/__tests__/FileUpload.test.tsx +22 -0
  127. package/src/components/FileUpload/__tests__/FileUploadField.test.tsx +27 -0
  128. package/src/components/FileUpload/__tests__/__snapshots__/FileUpload.test.tsx.snap +16 -0
  129. package/src/components/FileUpload/__tests__/__snapshots__/FileUploadField.test.tsx.snap +60 -0
  130. package/src/components/FileUpload/examples/FileUpload.md +283 -0
  131. package/src/components/FileUpload/index.ts +2 -0
  132. package/src/components/Modal/ModalBoxDescription.tsx +23 -0
  133. package/src/components/Modal/ModalContent.tsx +2 -6
  134. package/src/components/Modal/__tests__/__snapshots__/ModalContent.test.tsx.snap +2 -3
  135. package/src/components/OptionsMenu/__tests__/__snapshots__/OptionsMenu.test.tsx.snap +0 -7
  136. package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +0 -13
  137. package/src/components/Select/Select.tsx +74 -33
  138. package/src/components/Select/SelectMenu.tsx +28 -23
  139. package/src/components/Select/SelectOption.tsx +28 -3
  140. package/src/components/Select/SelectToggle.tsx +6 -1
  141. package/src/components/Select/__tests__/Select.test.tsx +16 -0
  142. package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +911 -174
  143. package/src/components/Select/__tests__/__snapshots__/SelectOption.test.tsx.snap +7 -7
  144. package/src/components/Select/__tests__/__snapshots__/SelectToggle.test.tsx.snap +3 -0
  145. package/src/components/Select/examples/Select.md +109 -6
  146. package/src/components/index.ts +1 -0
  147. package/src/helpers/__tests__/fileUtils.test.ts +17 -0
  148. package/src/helpers/fileUtils.ts +26 -0
  149. package/src/helpers/util.ts +1 -1
  150. package/src/components/Drawer/Drawer.test.tsx +0 -22
  151. package/src/components/Drawer/__snapshots__/Drawer.test.tsx.snap +0 -121
@@ -0,0 +1,283 @@
1
+ ---
2
+ title: 'File upload'
3
+ cssPrefix: 'pf-c-file-upload'
4
+ typescript: true
5
+ propComponents: ['FileUpload', 'FileUploadField']
6
+ section: 'components'
7
+ beta: true
8
+ ---
9
+
10
+ import { FileUpload, Form, FormGroup, FileUploadField, Checkbox } from '@patternfly/react-core';
11
+ import FileUploadIcon from '@patternfly/react-icons/dist/js/icons/file-upload-icon';
12
+
13
+ ## Examples
14
+
15
+ The basic `FileUpload` component can accept a file via browse or drag-and-drop, and behaves like a standard form field with its `value` and `onChange` props. The `type` prop determines how the `FileUpload` component behaves upon accepting a file, what type of value it passes to its `onChange` prop, and what type it expects for its `value` prop.
16
+
17
+ ### Text files
18
+
19
+ If `type="text"` is passed (and `hideDefaultPreview` is not), a `TextArea` preview will be rendered underneath the filename bar. When a file is selected, its contents will be read into memory and passed to the `onChange` prop as a string (along with its filename). Typing/pasting text in the box will also call `onChange` with a string, and a string value is expected for the `value` prop.
20
+
21
+ ```js title=Simple-text-file
22
+ import React from 'react';
23
+ import { FileUpload } from '@patternfly/react-core';
24
+
25
+ class SimpleTextFileUpload extends React.Component {
26
+ constructor(props) {
27
+ super(props);
28
+ this.state = { value: '', filename: '', isLoading: false };
29
+ this.handleFileChange = (value, filename, event) => this.setState({ value, filename });
30
+ this.handleFileReadStarted = fileHandle => this.setState({ isLoading: true });
31
+ this.handleFileReadFinished = fileHandle => this.setState({ isLoading: false });
32
+ }
33
+
34
+ render() {
35
+ const { value, filename, isLoading } = this.state;
36
+ return (
37
+ <FileUpload
38
+ id="simple-text-file"
39
+ type="text"
40
+ value={value}
41
+ filename={filename}
42
+ onChange={this.handleFileChange}
43
+ onReadStarted={this.handleFileReadStarted}
44
+ onReadFinished={this.handleFileReadFinished}
45
+ isLoading={isLoading}
46
+ />
47
+ );
48
+ }
49
+ }
50
+ ```
51
+
52
+ A user can always type instead of selecting a file, but by default, once a user selects a text file from their disk they are not allowed to edit it (to prevent unintended changes to a format-sensitive file). This behavior can be changed with the `allowEditingUploadedText` prop:
53
+
54
+ ```js title=Text-file-with-edits-allowed
55
+ import React from 'react';
56
+ import { FileUpload } from '@patternfly/react-core';
57
+
58
+ class TextFileWithEditsAllowed extends React.Component {
59
+ constructor(props) {
60
+ super(props);
61
+ this.state = { value: '', filename: '', isLoading: false };
62
+ this.handleFileChange = (value, filename, event) => this.setState({ value, filename });
63
+ this.handleFileReadStarted = fileHandle => this.setState({ isLoading: true });
64
+ this.handleFileReadFinished = fileHandle => this.setState({ isLoading: false });
65
+ }
66
+
67
+ render() {
68
+ const { value, filename, isLoading } = this.state;
69
+ return (
70
+ <FileUpload
71
+ id="text-file-with-edits-allowed"
72
+ type="text"
73
+ value={value}
74
+ filename={filename}
75
+ onChange={this.handleFileChange}
76
+ onReadStarted={this.handleFileReadStarted}
77
+ onReadFinished={this.handleFileReadFinished}
78
+ isLoading={isLoading}
79
+ allowEditingUploadedText
80
+ />
81
+ );
82
+ }
83
+ }
84
+ ```
85
+
86
+ ### Restricting file size and type
87
+
88
+ Any [props accepted by `react-dropzone`'s `Dropzone` component](https://react-dropzone.js.org/#!/Dropzone) can be passed as a `dropzoneProps` object in order to customize the behavior of the Dropzone, such as restricting the size and type of files allowed. The following example will only accept CSV files smaller than 1 KB. Note that file type determination is not reliable across platforms (see the note on react-dropzone's docs about the `accept` prop), so be sure to test the behavior of your file upload restriction on all browsers and operating systems targeted by your application.
89
+
90
+ #### IMPORTANT: A note about security
91
+
92
+ Restricting file sizes and types in this way is for user convenience only, and it cannot prevent a malicious user from submitting anything to your server. As with any user input, your application should also validate, sanitize and/or reject restricted files on the server side.
93
+
94
+ ```js title=Text-file-with-restrictions
95
+ import React from 'react';
96
+ import { FileUpload, Form, FormGroup } from '@patternfly/react-core';
97
+
98
+ class TextFileUploadWithRestrictions extends React.Component {
99
+ constructor(props) {
100
+ super(props);
101
+ this.state = { value: '', filename: '', isLoading: false, isRejected: false };
102
+ this.handleFileChange = (value, filename, event) => {
103
+ this.setState({ value, filename, isRejected: false });
104
+ };
105
+ this.handleFileRejected = (rejectedFiles, event) => this.setState({ isRejected: true });
106
+ this.handleFileReadStarted = fileHandle => this.setState({ isLoading: true });
107
+ this.handleFileReadFinished = fileHandle => this.setState({ isLoading: false });
108
+ }
109
+
110
+ render() {
111
+ const { value, filename, isLoading, isRejected } = this.state;
112
+ return (
113
+ <Form>
114
+ <FormGroup
115
+ fieldId="text-file-with-restrictions"
116
+ helperText="Upload a CSV file"
117
+ helperTextInvalid="Must be a CSV file no larger than 1 KB"
118
+ validated={isRejected ? 'error' : 'default'}
119
+ >
120
+ <FileUpload
121
+ id="text-file-with-restrictions"
122
+ type="text"
123
+ value={value}
124
+ filename={filename}
125
+ onChange={this.handleFileChange}
126
+ onReadStarted={this.handleFileReadStarted}
127
+ onReadFinished={this.handleFileReadFinished}
128
+ isLoading={isLoading}
129
+ dropzoneProps={{
130
+ accept: '.csv',
131
+ maxSize: 1024,
132
+ onDropRejected: this.handleFileRejected
133
+ }}
134
+ validated={isRejected ? 'error' : 'default'}
135
+ />
136
+ </FormGroup>
137
+ </Form>
138
+ );
139
+ }
140
+ }
141
+ ```
142
+
143
+ ### Other file types
144
+
145
+ If no `type` prop is specified, the component will not read files directly. When a file is selected, a [`File` object](https://developer.mozilla.org/en-US/docs/Web/API/File) will be passed to `onChange` and your application will be responsible for reading from it (e.g. by using the [FileReader API](https://developer.mozilla.org/en-US/docs/Web/API/FileReader) or attaching it to a [FormData object](https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects)). A `File` object will also be expected for the `value` prop instead of a string, and no preview of the file contents will be shown by default. The `onReadStarted` and `onReadFinished` callbacks will also not be called since the component is not reading the file.
146
+
147
+ ```js title=Simple-file-of-any-format
148
+ import React from 'react';
149
+ import { FileUpload } from '@patternfly/react-core';
150
+
151
+ class SimpleFileUpload extends React.Component {
152
+ constructor(props) {
153
+ super(props);
154
+ this.state = { value: null, filename: '' };
155
+ this.handleFileChange = (value, filename, event) => this.setState({ value, filename });
156
+ }
157
+
158
+ render() {
159
+ const { value, filename } = this.state;
160
+ return <FileUpload id="simple-file" value={value} filename={filename} onChange={this.handleFileChange} />;
161
+ }
162
+ }
163
+ ```
164
+
165
+ ### Customizing the file preview
166
+
167
+ Regardless of `type`, the preview area (the TextArea, or any future implementations of default previews for other types) can be removed by passing `hideDefaultPreview`, and a custom one can be rendered by passing `children`.
168
+
169
+ ```js title=Custom-file-preview
170
+ import React from 'react';
171
+ import { FileUpload } from '@patternfly/react-core';
172
+ import FileUploadIcon from '@patternfly/react-icons/dist/js/icons/file-upload-icon';
173
+
174
+ class CustomPreviewFileUpload extends React.Component {
175
+ constructor(props) {
176
+ super(props);
177
+ this.state = { value: null, filename: '' };
178
+ this.handleFileChange = (value, filename, event) => this.setState({ value, filename });
179
+ }
180
+
181
+ render() {
182
+ const { value, filename, isLoading } = this.state;
183
+ return (
184
+ <FileUpload
185
+ id="customized-preview-file"
186
+ value={value}
187
+ filename={filename}
188
+ onChange={this.handleFileChange}
189
+ hideDefaultPreview
190
+ >
191
+ {value && (
192
+ <div className="pf-u-m-md">
193
+ <FileUploadIcon size="lg" /> Custom preview here for your {value.size}-byte file named {value.name}
194
+ </div>
195
+ )}
196
+ </FileUpload>
197
+ );
198
+ }
199
+ }
200
+ ```
201
+
202
+ ### Bringing your own file browse logic
203
+
204
+ `FileUpload` is a thin wrapper around the `FileUploadField` presentational component. If you need to implement your own logic for accepting files, you can instead render a `FileUploadField` directly, which does not include `react-dropzone` and requires additional props (e.g. `onBrowseButtonClick`, `onClearButtonClick`, `isDragActive`).
205
+
206
+ Note that the `isLoading` prop is styled to position the spinner dead center above the entire component, so it should not be used with `hideDefaultPreview` unless a custom empty-state preview is provided via `children`. The below example prevents `isLoading` and `hideDefaultPreview` from being used at the same time. You can always provide your own spinner as part of the `children`!
207
+
208
+ ```js title=Custom-file-upload
209
+ import React from 'react';
210
+ import { FileUploadField, Checkbox } from '@patternfly/react-core';
211
+
212
+ class CustomFileUpload extends React.Component {
213
+ constructor(props) {
214
+ super(props);
215
+ this.state = {
216
+ value: '',
217
+ filename: false,
218
+ isClearButtonDisabled: true,
219
+ isLoading: false,
220
+ isDragActive: false,
221
+ hideDefaultPreview: false,
222
+ children: false
223
+ };
224
+ this.handleTextAreaChange = value => {
225
+ this.setState({ value });
226
+ };
227
+ }
228
+
229
+ render() {
230
+ const {
231
+ value,
232
+ filename,
233
+ isClearButtonDisabled,
234
+ isLoading,
235
+ isDragActive,
236
+ hideDefaultPreview,
237
+ children
238
+ } = this.state;
239
+ return (
240
+ <div>
241
+ {['filename', 'isClearButtonDisabled', 'isDragActive', 'isLoading', 'hideDefaultPreview', 'children'].map(
242
+ stateKey => (
243
+ <Checkbox
244
+ key={stateKey}
245
+ id={stateKey}
246
+ label={stateKey}
247
+ aria-label={stateKey}
248
+ isChecked={this.state[stateKey]}
249
+ onChange={checked =>
250
+ this.setState({
251
+ [stateKey]: checked,
252
+ // See notes above this example
253
+ ...(stateKey === 'isLoading' && checked && { hideDefaultPreview: false }),
254
+ ...(stateKey === 'hideDefaultPreview' && checked && { isLoading: false })
255
+ })
256
+ }
257
+ />
258
+ )
259
+ )}
260
+ <br />
261
+ <FileUploadField
262
+ id="custom-file-upload"
263
+ type="text"
264
+ value={value}
265
+ filename={filename ? 'example-filename.txt' : ''}
266
+ onChange={this.handleTextAreaChange}
267
+ filenamePlaceholder="Do something custom with this!"
268
+ onBrowseButtonClick={() => alert('Browse button clicked!')}
269
+ onClearButtonClick={() => alert('Clear button clicked!')}
270
+ isClearButtonDisabled={isClearButtonDisabled}
271
+ isLoading={isLoading}
272
+ isDragActive={isDragActive}
273
+ hideDefaultPreview={hideDefaultPreview}
274
+ >
275
+ {children && (
276
+ <div className="pf-u-m-md">(A custom preview of the uploaded file can be passed as children)</div>
277
+ )}
278
+ </FileUploadField>
279
+ </div>
280
+ );
281
+ }
282
+ }
283
+ ```
@@ -0,0 +1,2 @@
1
+ export * from './FileUploadField';
2
+ export * from './FileUpload';
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ import { css } from '@patternfly/react-styles';
3
+ import styles from '@patternfly/react-styles/css/components/ModalBox/modal-box';
4
+
5
+ export interface ModalBoxDescriptionProps {
6
+ /** Content rendered inside the description */
7
+ children?: React.ReactNode;
8
+ /** Additional classes added to the description */
9
+ className?: string;
10
+ /** ID of the description */
11
+ id?: string;
12
+ }
13
+
14
+ export const ModalBoxDescription: React.FunctionComponent<ModalBoxDescriptionProps> = ({
15
+ children = null,
16
+ className = '',
17
+ id = '',
18
+ ...props
19
+ }: ModalBoxDescriptionProps) => (
20
+ <div {...props} id={id} className={css(styles.modalBoxDescription, className)}>
21
+ {children}
22
+ </div>
23
+ );
@@ -7,7 +7,6 @@ const FocusTrap: any = require('focus-trap-react');
7
7
 
8
8
  import styles from '@patternfly/react-styles/css/layouts/Bullseye/bullseye';
9
9
  import titleStyles from '@patternfly/react-styles/css/components/Title/title';
10
- import modalStyles from '@patternfly/react-styles/css/components/ModalBox/modal-box';
11
10
  import { css } from '@patternfly/react-styles';
12
11
 
13
12
  import { Backdrop } from '../Backdrop/Backdrop';
@@ -16,6 +15,7 @@ import { ModalBoxHeader } from './ModalBoxHeader';
16
15
  import { ModalBoxCloseButton } from './ModalBoxCloseButton';
17
16
  import { ModalBox } from './ModalBox';
18
17
  import { ModalBoxFooter } from './ModalBoxFooter';
18
+ import { ModalBoxDescription } from './ModalBoxDescription';
19
19
 
20
20
  export interface ModalContentProps {
21
21
  /** Content rendered inside the Modal. */
@@ -104,11 +104,7 @@ export const ModalContent: React.FunctionComponent<ModalContentProps> = ({
104
104
  >
105
105
  {showClose && <ModalBoxCloseButton onClose={onClose} />}
106
106
  {modalBoxHeader}
107
- {description && (
108
- <div className={css(modalStyles.modalBoxDescription)} id={id}>
109
- {description}
110
- </div>
111
- )}
107
+ {description && <ModalBoxDescription id={id}>{description}</ModalBoxDescription>}
112
108
  <ModalBoxBody {...props} {...(!description && { id })}>
113
109
  {children}
114
110
  </ModalBoxBody>
@@ -32,12 +32,11 @@ exports[`Modal Content Test description 1`] = `
32
32
  Test Modal Content title
33
33
 
34
34
  </ModalBoxHeader>
35
- <div
36
- className="pf-c-modal-box__description"
35
+ <ModalBoxDescription
37
36
  id="id"
38
37
  >
39
38
  This is a test description.
40
- </div>
39
+ </ModalBoxDescription>
41
40
  <ModalBoxBody>
42
41
  This is a ModalBox header
43
42
  </ModalBoxBody>
@@ -705,7 +705,6 @@ exports[`optionsMenu expanded 1`] = `
705
705
  aria-expanded={true}
706
706
  aria-haspopup="listbox"
707
707
  aria-label="Options menu"
708
- bubbleEvent={false}
709
708
  className="pf-c-options-menu__toggle"
710
709
  disabled={false}
711
710
  id="expanded-toggle"
@@ -1493,7 +1492,6 @@ exports[`optionsMenu isDisabled 1`] = `
1493
1492
  aria-expanded={false}
1494
1493
  aria-haspopup="listbox"
1495
1494
  aria-label="Options menu"
1496
- bubbleEvent={false}
1497
1495
  className="pf-c-options-menu__toggle"
1498
1496
  disabled={true}
1499
1497
  id="disabled-toggle"
@@ -1891,7 +1889,6 @@ exports[`optionsMenu open up 1`] = `
1891
1889
  aria-expanded={false}
1892
1890
  aria-haspopup="listbox"
1893
1891
  aria-label="Options menu"
1894
- bubbleEvent={false}
1895
1892
  className="pf-c-options-menu__toggle"
1896
1893
  disabled={false}
1897
1894
  id="openUp-toggle"
@@ -2239,7 +2236,6 @@ exports[`optionsMenu plain 1`] = `
2239
2236
  aria-expanded={false}
2240
2237
  aria-haspopup="listbox"
2241
2238
  aria-label="Options menu"
2242
- bubbleEvent={false}
2243
2239
  className="pf-c-options-menu__toggle pf-m-plain"
2244
2240
  disabled={false}
2245
2241
  id="plain-toggle"
@@ -2606,7 +2602,6 @@ exports[`optionsMenu regular 1`] = `
2606
2602
  aria-expanded={false}
2607
2603
  aria-haspopup="listbox"
2608
2604
  aria-label="Options menu"
2609
- bubbleEvent={false}
2610
2605
  className="pf-c-options-menu__toggle"
2611
2606
  disabled={false}
2612
2607
  id="regular-toggle"
@@ -3007,7 +3002,6 @@ exports[`optionsMenu right aligned + open up 1`] = `
3007
3002
  aria-expanded={false}
3008
3003
  aria-haspopup="listbox"
3009
3004
  aria-label="Options menu"
3010
- bubbleEvent={false}
3011
3005
  className="pf-c-options-menu__toggle"
3012
3006
  disabled={false}
3013
3007
  id="rightAlignedOpenUp-toggle"
@@ -3405,7 +3399,6 @@ exports[`optionsMenu right aligned 1`] = `
3405
3399
  aria-expanded={false}
3406
3400
  aria-haspopup="listbox"
3407
3401
  aria-label="Options menu"
3408
- bubbleEvent={false}
3409
3402
  className="pf-c-options-menu__toggle"
3410
3403
  disabled={false}
3411
3404
  id="rightAligned-toggle"
@@ -607,7 +607,6 @@ exports[`component render custom pagination toggle 1`] = `
607
607
  <button
608
608
  aria-expanded={false}
609
609
  aria-label="Items per page"
610
- bubbleEvent={false}
611
610
  className=" pf-c-options-menu__toggle-button"
612
611
  disabled={false}
613
612
  id="pagination-options-menu-toggle-11"
@@ -1542,7 +1541,6 @@ exports[`component render custom perPageOptions 1`] = `
1542
1541
  <button
1543
1542
  aria-expanded={false}
1544
1543
  aria-label="Items per page"
1545
- bubbleEvent={false}
1546
1544
  className=" pf-c-options-menu__toggle-button"
1547
1545
  disabled={false}
1548
1546
  id="pagination-options-menu-toggle-7"
@@ -2638,7 +2636,6 @@ exports[`component render custom start end 1`] = `
2638
2636
  <button
2639
2637
  aria-expanded={false}
2640
2638
  aria-label="Items per page"
2641
- bubbleEvent={false}
2642
2639
  className=" pf-c-options-menu__toggle-button"
2643
2640
  disabled={false}
2644
2641
  id="pagination-options-menu-toggle-9"
@@ -4365,7 +4362,6 @@ exports[`component render last page 1`] = `
4365
4362
  <button
4366
4363
  aria-expanded={false}
4367
4364
  aria-label="Items per page"
4368
- bubbleEvent={false}
4369
4365
  className=" pf-c-options-menu__toggle-button"
4370
4366
  disabled={false}
4371
4367
  id="pagination-options-menu-toggle-6"
@@ -5459,7 +5455,6 @@ exports[`component render limited number of pages 1`] = `
5459
5455
  <button
5460
5456
  aria-expanded={false}
5461
5457
  aria-label="Items per page"
5462
- bubbleEvent={false}
5463
5458
  className=" pf-c-options-menu__toggle-button"
5464
5459
  disabled={false}
5465
5460
  id="pagination-options-menu-toggle-4"
@@ -6554,7 +6549,6 @@ exports[`component render no items 1`] = `
6554
6549
  <button
6555
6550
  aria-expanded={false}
6556
6551
  aria-label="Items per page"
6557
- bubbleEvent={false}
6558
6552
  className=" pf-c-options-menu__toggle-button"
6559
6553
  disabled={true}
6560
6554
  id="pagination-options-menu-toggle-8"
@@ -7626,7 +7620,6 @@ exports[`component render should render correctly bottom 1`] = `
7626
7620
  <button
7627
7621
  aria-expanded={false}
7628
7622
  aria-label="Items per page"
7629
- bubbleEvent={false}
7630
7623
  className=" pf-c-options-menu__toggle-button"
7631
7624
  disabled={false}
7632
7625
  id="pagination-options-menu-toggle-1"
@@ -8720,7 +8713,6 @@ exports[`component render should render correctly compact 1`] = `
8720
8713
  <button
8721
8714
  aria-expanded={false}
8722
8715
  aria-label="Items per page"
8723
- bubbleEvent={false}
8724
8716
  className=" pf-c-options-menu__toggle-button"
8725
8717
  disabled={false}
8726
8718
  id="pagination-options-menu-toggle-2"
@@ -9628,7 +9620,6 @@ exports[`component render should render correctly disabled 1`] = `
9628
9620
  <button
9629
9621
  aria-expanded={false}
9630
9622
  aria-label="Items per page"
9631
- bubbleEvent={false}
9632
9623
  className=" pf-c-options-menu__toggle-button"
9633
9624
  disabled={true}
9634
9625
  id="pagination-options-menu-toggle-3"
@@ -10720,7 +10711,6 @@ exports[`component render should render correctly top 1`] = `
10720
10711
  <button
10721
10712
  aria-expanded={false}
10722
10713
  aria-label="Items per page"
10723
- bubbleEvent={false}
10724
10714
  className=" pf-c-options-menu__toggle-button"
10725
10715
  disabled={false}
10726
10716
  id="pagination-options-menu-toggle-0"
@@ -11815,7 +11805,6 @@ exports[`component render titles 1`] = `
11815
11805
  <button
11816
11806
  aria-expanded={false}
11817
11807
  aria-label="Select"
11818
- bubbleEvent={false}
11819
11808
  className=" pf-c-options-menu__toggle-button"
11820
11809
  disabled={false}
11821
11810
  id="pagination-options-menu-toggle-10"
@@ -12909,7 +12898,6 @@ exports[`component render up drop direction 1`] = `
12909
12898
  <button
12910
12899
  aria-expanded={false}
12911
12900
  aria-label="Items per page"
12912
- bubbleEvent={false}
12913
12901
  className=" pf-c-options-menu__toggle-button"
12914
12902
  disabled={false}
12915
12903
  id="pagination-options-menu-toggle-12"
@@ -14004,7 +13992,6 @@ exports[`component render zero results 1`] = `
14004
13992
  <button
14005
13993
  aria-expanded={false}
14006
13994
  aria-label="Items per page"
14007
- bubbleEvent={false}
14008
13995
  className=" pf-c-options-menu__toggle-button"
14009
13996
  disabled={true}
14010
13997
  id="pagination-options-menu-toggle-5"