@patternfly/react-core 4.199.3 → 4.200.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 (60) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/esm/components/Avatar/Avatar.d.ts +2 -0
  3. package/dist/esm/components/Avatar/Avatar.d.ts.map +1 -1
  4. package/dist/esm/components/Avatar/Avatar.js +2 -2
  5. package/dist/esm/components/Avatar/Avatar.js.map +1 -1
  6. package/dist/esm/components/FormSelect/FormSelect.d.ts +2 -0
  7. package/dist/esm/components/FormSelect/FormSelect.d.ts.map +1 -1
  8. package/dist/esm/components/FormSelect/FormSelect.js +3 -2
  9. package/dist/esm/components/FormSelect/FormSelect.js.map +1 -1
  10. package/dist/esm/components/TextArea/TextArea.d.ts +2 -0
  11. package/dist/esm/components/TextArea/TextArea.d.ts.map +1 -1
  12. package/dist/esm/components/TextArea/TextArea.js +4 -3
  13. package/dist/esm/components/TextArea/TextArea.js.map +1 -1
  14. package/dist/esm/components/TextInput/TextInput.d.ts +2 -0
  15. package/dist/esm/components/TextInput/TextInput.d.ts.map +1 -1
  16. package/dist/esm/components/TextInput/TextInput.js +3 -2
  17. package/dist/esm/components/TextInput/TextInput.js.map +1 -1
  18. package/dist/js/components/Avatar/Avatar.d.ts +2 -0
  19. package/dist/js/components/Avatar/Avatar.d.ts.map +1 -1
  20. package/dist/js/components/Avatar/Avatar.js +2 -2
  21. package/dist/js/components/Avatar/Avatar.js.map +1 -1
  22. package/dist/js/components/FormSelect/FormSelect.d.ts +2 -0
  23. package/dist/js/components/FormSelect/FormSelect.d.ts.map +1 -1
  24. package/dist/js/components/FormSelect/FormSelect.js +3 -2
  25. package/dist/js/components/FormSelect/FormSelect.js.map +1 -1
  26. package/dist/js/components/TextArea/TextArea.d.ts +2 -0
  27. package/dist/js/components/TextArea/TextArea.d.ts.map +1 -1
  28. package/dist/js/components/TextArea/TextArea.js +4 -3
  29. package/dist/js/components/TextArea/TextArea.js.map +1 -1
  30. package/dist/js/components/TextInput/TextInput.d.ts +2 -0
  31. package/dist/js/components/TextInput/TextInput.d.ts.map +1 -1
  32. package/dist/js/components/TextInput/TextInput.js +3 -2
  33. package/dist/js/components/TextInput/TextInput.js.map +1 -1
  34. package/dist/umd/react-core.css +769 -769
  35. package/dist/umd/react-core.js +12 -9
  36. package/dist/umd/react-core.min.css +2 -2
  37. package/dist/umd/react-core.min.js +2 -2
  38. package/package.json +6 -6
  39. package/src/components/Avatar/Avatar.tsx +4 -0
  40. package/src/components/Avatar/examples/Avatar.md +33 -4
  41. package/src/components/ClipboardCopy/examples/ClipboardCopy.md +11 -123
  42. package/src/components/ClipboardCopy/examples/ClipboardCopyBasic.tsx +8 -0
  43. package/src/components/ClipboardCopy/examples/ClipboardCopyExpanded.tsx +9 -0
  44. package/src/components/ClipboardCopy/examples/ClipboardCopyExpandedWithArray.tsx +14 -0
  45. package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompact.tsx +7 -0
  46. package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactCode.tsx +8 -0
  47. package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactInSentence.tsx +36 -0
  48. package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactWithAdditionalAction.tsx +20 -0
  49. package/src/components/ClipboardCopy/examples/ClipboardCopyJSONObject.tsx +18 -0
  50. package/src/components/ClipboardCopy/examples/ClipboardCopyReadOnly.tsx +8 -0
  51. package/src/components/ClipboardCopy/examples/ClipboardCopyReadOnlyExpanded.tsx +9 -0
  52. package/src/components/ClipboardCopy/examples/ClipboardCopyReadOnlyExpandedByDefault.tsx +9 -0
  53. package/src/components/FormSelect/FormSelect.tsx +16 -1
  54. package/src/components/FormSelect/examples/FormSelect.md +58 -0
  55. package/src/components/TextArea/TextArea.tsx +5 -0
  56. package/src/components/TextArea/__tests__/__snapshots__/TextArea.test.tsx.snap +2 -0
  57. package/src/components/TextArea/examples/TextArea.md +43 -0
  58. package/src/components/TextInput/TextInput.tsx +5 -0
  59. package/src/components/TextInput/__tests__/__snapshots__/TextInput.test.tsx.snap +2 -0
  60. package/src/components/TextInput/examples/TextInput.md +104 -27
@@ -65,6 +65,8 @@ export interface TextInputProps
65
65
  onBlur?: (event?: any) => void;
66
66
  /** icon variant */
67
67
  iconVariant?: 'calendar' | 'clock' | 'search';
68
+ /** Use the external file instead of a data URI */
69
+ isIconSprite?: boolean;
68
70
  /** Custom icon url to set as the input's background-image */
69
71
  customIconUrl?: string;
70
72
  /** Dimensions for the custom icon set as the input's background-size */
@@ -84,6 +86,7 @@ export class TextInputBase extends React.Component<TextInputProps, TextInputStat
84
86
  validated: 'default' as 'success' | 'warning' | 'error' | 'default',
85
87
  isDisabled: false,
86
88
  isReadOnly: false,
89
+ isIconSprite: false,
87
90
  type: TextInputTypes.text,
88
91
  isLeftTruncated: false,
89
92
  onChange: (): any => undefined,
@@ -170,6 +173,7 @@ export class TextInputBase extends React.Component<TextInputProps, TextInputStat
170
173
  isReadOnly,
171
174
  isRequired,
172
175
  isDisabled,
176
+ isIconSprite,
173
177
  iconVariant,
174
178
  customIconUrl,
175
179
  customIconDimensions,
@@ -193,6 +197,7 @@ export class TextInputBase extends React.Component<TextInputProps, TextInputStat
193
197
  onBlur={this.onBlur}
194
198
  className={css(
195
199
  styles.formControl,
200
+ isIconSprite && styles.modifiers.iconSprite,
196
201
  validated === ValidatedOptions.success && styles.modifiers.success,
197
202
  validated === ValidatedOptions.warning && styles.modifiers.warning,
198
203
  ((iconVariant && iconVariant !== 'search') || customIconUrl) && styles.modifiers.icon,
@@ -90,6 +90,7 @@ exports[`validated text input success 1`] = `
90
90
  className=""
91
91
  innerRef={null}
92
92
  isDisabled={false}
93
+ isIconSprite={false}
93
94
  isLeftTruncated={false}
94
95
  isReadOnly={false}
95
96
  isRequired={false}
@@ -133,6 +134,7 @@ exports[`validated text input success 2`] = `
133
134
  className=""
134
135
  innerRef={null}
135
136
  isDisabled={false}
137
+ isIconSprite={false}
136
138
  isLeftTruncated={false}
137
139
  isReadOnly={false}
138
140
  isRequired={false}
@@ -6,7 +6,9 @@ propComponents: ['TextInput']
6
6
  ---
7
7
 
8
8
  ## Examples
9
+
9
10
  ### Basic
11
+
10
12
  ```js
11
13
  import React from 'react';
12
14
  import { TextInput } from '@patternfly/react-core';
@@ -139,37 +141,112 @@ TextInputSelectAll = () => {
139
141
  ```
140
142
 
141
143
  ### Icon variants
144
+
142
145
  ```js
143
146
  import React from 'react';
144
147
  import { TextInput } from '@patternfly/react-core';
145
148
 
146
- class SimpleTextInput extends React.Component {
147
- constructor(props) {
148
- super(props);
149
- this.state = {
150
- calendar: '',
151
- clock: '',
152
- custom: ''
153
- };
154
- this.handleTextInputChange = (value, field) => {
155
- this.setState({ [field]: value });
156
- };
157
- }
149
+ SimpleTextInput = () => {
150
+ const [calendar, setCalendar] = React.useState('');
151
+ const [clock, setClock] = React.useState('');
152
+ const [custom, setCustom] = React.useState('');
158
153
 
159
- render() {
160
- const { calendar, clock, custom } = this.state;
154
+ return (
155
+ <>
156
+ <TextInput
157
+ value={calendar}
158
+ type="text"
159
+ iconVariant="calendar"
160
+ onChange={value => setCalendar(value)}
161
+ aria-label="text input example"
162
+ />
163
+ <br />
164
+ <br />
165
+ <TextInput
166
+ value={clock}
167
+ type="text"
168
+ iconVariant="clock"
169
+ onChange={value => setClock(value)}
170
+ aria-label="text input example"
171
+ />
172
+ <br />
173
+ <br />
174
+ <TextInput
175
+ value={custom}
176
+ type="text"
177
+ customIconDimensions="24px 24px"
178
+ customIconUrl='data:image/svg+xml;charset=utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"%3E%3Cpath fill="%23a18fff" d="M158.87.15c-16.16-1.52-31.2 8.42-35.33 24.12l-14.81 56.27c187.62 5.49 314.54 130.61 322.48 317l56.94-15.78c15.72-4.36 25.49-19.68 23.62-35.9C490.89 165.08 340.78 17.32 158.87.15zm-58.47 112L.55 491.64a16.21 16.21 0 0 0 20 19.75l379-105.1c-4.27-174.89-123.08-292.14-299.15-294.1zM128 416a32 32 0 1 1 32-32 32 32 0 0 1-32 32zm48-152a32 32 0 1 1 32-32 32 32 0 0 1-32 32zm104 104a32 32 0 1 1 32-32 32 32 0 0 1-32 32z"/%3E%3C/svg%3E'
179
+ onChange={value => setCustom(value)}
180
+ aria-label="text input example"
181
+ />
182
+ </>
183
+ );
184
+ };
185
+ ```
161
186
 
162
- return (
163
- <>
164
- <TextInput value={calendar} type="text" iconVariant='calendar' onChange={(value) => this.handleTextInputChange(value, "calendar")} aria-label="text input example" />
165
- <br />
166
- <br />
167
- <TextInput value={clock} type="text" iconVariant='clock' onChange={(value) => this.handleTextInputChange(value, "clock")} aria-label="text input example" />
168
- <br />
169
- <br />
170
- <TextInput value={custom} type="text" customIconDimensions='24px 24px' customIconUrl='data:image/svg+xml;charset=utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"%3E%3Cpath fill="%23a18fff" d="M158.87.15c-16.16-1.52-31.2 8.42-35.33 24.12l-14.81 56.27c187.62 5.49 314.54 130.61 322.48 317l56.94-15.78c15.72-4.36 25.49-19.68 23.62-35.9C490.89 165.08 340.78 17.32 158.87.15zm-58.47 112L.55 491.64a16.21 16.21 0 0 0 20 19.75l379-105.1c-4.27-174.89-123.08-292.14-299.15-294.1zM128 416a32 32 0 1 1 32-32 32 32 0 0 1-32 32zm48-152a32 32 0 1 1 32-32 32 32 0 0 1-32 32zm104 104a32 32 0 1 1 32-32 32 32 0 0 1-32 32z"/%3E%3C/svg%3E' onChange={(value) => this.handleTextInputChange(value, "custom")} aria-label="text input example" />
171
- </>
172
- );
173
- }
174
- }
187
+ ### Icon sprite variants
188
+
189
+ **Note:** The icons for the success, invalid, calendar, etc. variations in form control elements are applied as background images to the form element. By default, the image URLs for these icons are data URIs. However, there may be cases where data URIs are not ideal, such as in an application with a content security policy that disallows data URIs for security reasons. The `isIconSprite` variation changes the icon source to an external SVG file that serves as a sprite for all of the supported icons.
190
+
191
+ ```js isBeta
192
+ import React from 'react';
193
+ import { TextInput } from '@patternfly/react-core';
194
+
195
+ IconSpriteTextInputs = () => {
196
+ const [success, setSuccess] = React.useState('');
197
+ const [warning, setWarning] = React.useState('');
198
+ const [error, setError] = React.useState('');
199
+ const [calendar, setCalendar] = React.useState('');
200
+ const [clock, setClock] = React.useState('');
201
+
202
+ return (
203
+ <>
204
+ <TextInput
205
+ validated={ValidatedOptions.success}
206
+ isIconSprite
207
+ type="text"
208
+ onChange={value => setSuccess(value)}
209
+ aria-label="success icon sprite text input example"
210
+ />
211
+ <br />
212
+ <br />
213
+ <TextInput
214
+ validated={ValidatedOptions.warning}
215
+ isIconSprite
216
+ type="text"
217
+ onChange={value => setWarning(value)}
218
+ aria-label="warning icon sprite text input example"
219
+ />
220
+ <br />
221
+ <br />
222
+ <TextInput
223
+ validated={ValidatedOptions.error}
224
+ isIconSprite
225
+ type="text"
226
+ onChange={value => setError(value)}
227
+ aria-label="error icon sprite text input example"
228
+ />
229
+ <br />
230
+ <br />
231
+ <TextInput
232
+ value={calendar}
233
+ isIconSprite
234
+ type="text"
235
+ iconVariant="calendar"
236
+ onChange={value => setCalendar(value)}
237
+ aria-label="calendar icon sprite text input example"
238
+ />
239
+ <br />
240
+ <br />
241
+ <TextInput
242
+ value={clock}
243
+ isIconSprite
244
+ type="text"
245
+ iconVariant="clock"
246
+ onChange={value => setClock(value)}
247
+ aria-label="clock icon sprite text input example"
248
+ />
249
+ </>
250
+ );
251
+ };
175
252
  ```