@patternfly/react-core 4.199.4 → 4.200.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 +30 -0
- package/dist/esm/components/Avatar/Avatar.d.ts +2 -0
- package/dist/esm/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/esm/components/Avatar/Avatar.js +2 -2
- package/dist/esm/components/Avatar/Avatar.js.map +1 -1
- package/dist/esm/components/FormSelect/FormSelect.d.ts +2 -0
- package/dist/esm/components/FormSelect/FormSelect.d.ts.map +1 -1
- package/dist/esm/components/FormSelect/FormSelect.js +3 -2
- package/dist/esm/components/FormSelect/FormSelect.js.map +1 -1
- package/dist/esm/components/TextArea/TextArea.d.ts +2 -0
- package/dist/esm/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/esm/components/TextArea/TextArea.js +4 -3
- package/dist/esm/components/TextArea/TextArea.js.map +1 -1
- package/dist/esm/components/TextInput/TextInput.d.ts +2 -0
- package/dist/esm/components/TextInput/TextInput.d.ts.map +1 -1
- package/dist/esm/components/TextInput/TextInput.js +3 -2
- package/dist/esm/components/TextInput/TextInput.js.map +1 -1
- package/dist/js/components/Avatar/Avatar.d.ts +2 -0
- package/dist/js/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/js/components/Avatar/Avatar.js +2 -2
- package/dist/js/components/Avatar/Avatar.js.map +1 -1
- package/dist/js/components/FormSelect/FormSelect.d.ts +2 -0
- package/dist/js/components/FormSelect/FormSelect.d.ts.map +1 -1
- package/dist/js/components/FormSelect/FormSelect.js +3 -2
- package/dist/js/components/FormSelect/FormSelect.js.map +1 -1
- package/dist/js/components/TextArea/TextArea.d.ts +2 -0
- package/dist/js/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/js/components/TextArea/TextArea.js +4 -3
- package/dist/js/components/TextArea/TextArea.js.map +1 -1
- package/dist/js/components/TextInput/TextInput.d.ts +2 -0
- package/dist/js/components/TextInput/TextInput.d.ts.map +1 -1
- package/dist/js/components/TextInput/TextInput.js +3 -2
- package/dist/js/components/TextInput/TextInput.js.map +1 -1
- package/dist/umd/react-core.css +2 -2
- package/dist/umd/react-core.js +12 -9
- package/dist/umd/react-core.min.css +2 -2
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +6 -6
- package/src/components/Avatar/Avatar.tsx +4 -0
- package/src/components/Avatar/examples/Avatar.md +33 -4
- package/src/components/FormSelect/FormSelect.tsx +16 -1
- package/src/components/FormSelect/examples/FormSelect.md +58 -0
- package/src/components/TextArea/TextArea.tsx +5 -0
- package/src/components/TextArea/__tests__/__snapshots__/TextArea.test.tsx.snap +2 -0
- package/src/components/TextArea/examples/TextArea.md +43 -0
- package/src/components/TextInput/TextInput.tsx +5 -0
- package/src/components/TextInput/__tests__/__snapshots__/TextInput.test.tsx.snap +2 -0
- package/src/components/TextInput/examples/TextInput.md +104 -27
- package/src/components/Tooltip/examples/Tooltip.md +9 -1
- package/src/components/Tooltip/examples/TooltipExamples.css +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.200.1",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.
|
|
38
|
-
"@patternfly/react-styles": "^4.
|
|
39
|
-
"@patternfly/react-tokens": "^4.
|
|
37
|
+
"@patternfly/react-icons": "^4.51.1",
|
|
38
|
+
"@patternfly/react-styles": "^4.50.1",
|
|
39
|
+
"@patternfly/react-tokens": "^4.52.1",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
43
43
|
"tslib": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@patternfly/patternfly": "4.183.
|
|
46
|
+
"@patternfly/patternfly": "4.183.2",
|
|
47
47
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
48
48
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
49
49
|
"@rollup/plugin-replace": "^3.0.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "0ae1c2fe74b54b12236dcc7d64f9b3827d457d8d"
|
|
64
64
|
}
|
|
@@ -12,6 +12,8 @@ export interface AvatarProps
|
|
|
12
12
|
alt: string;
|
|
13
13
|
/** Border to add */
|
|
14
14
|
border?: 'light' | 'dark';
|
|
15
|
+
/** Size variant of avatar. */
|
|
16
|
+
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export const Avatar: React.FunctionComponent<AvatarProps> = ({
|
|
@@ -19,6 +21,7 @@ export const Avatar: React.FunctionComponent<AvatarProps> = ({
|
|
|
19
21
|
src = '',
|
|
20
22
|
alt,
|
|
21
23
|
border,
|
|
24
|
+
size,
|
|
22
25
|
...props
|
|
23
26
|
}: AvatarProps) => (
|
|
24
27
|
<img
|
|
@@ -26,6 +29,7 @@ export const Avatar: React.FunctionComponent<AvatarProps> = ({
|
|
|
26
29
|
alt={alt}
|
|
27
30
|
className={css(
|
|
28
31
|
styles.avatar,
|
|
32
|
+
styles.modifiers[size],
|
|
29
33
|
border === 'light' && styles.modifiers.light,
|
|
30
34
|
border === 'dark' && styles.modifiers.dark,
|
|
31
35
|
className
|
|
@@ -10,30 +10,59 @@ import avatarImgDark from './avatarImgDark.svg';
|
|
|
10
10
|
import './example.css';
|
|
11
11
|
|
|
12
12
|
## Examples
|
|
13
|
+
|
|
13
14
|
### Basic
|
|
15
|
+
|
|
14
16
|
```ts
|
|
15
17
|
import React from 'react';
|
|
16
18
|
import { Avatar } from '@patternfly/react-core';
|
|
17
19
|
import avatarImg from './avatarImg.svg';
|
|
18
20
|
|
|
19
|
-
<Avatar src={avatarImg} alt="avatar"
|
|
21
|
+
<Avatar src={avatarImg} alt="avatar" />;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Size variations
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import { Avatar } from '@patternfly/react-core';
|
|
29
|
+
import avatarImg from './avatarImg.svg';
|
|
30
|
+
|
|
31
|
+
<React.Fragment>
|
|
32
|
+
Small
|
|
33
|
+
<br />
|
|
34
|
+
<Avatar src={avatarImg} alt="avatar" size="sm" />
|
|
35
|
+
<br />
|
|
36
|
+
Medium
|
|
37
|
+
<br />
|
|
38
|
+
<Avatar src={avatarImg} alt="avatar" size="md" />
|
|
39
|
+
<br />
|
|
40
|
+
Large
|
|
41
|
+
<br />
|
|
42
|
+
<Avatar src={avatarImg} alt="avatar" size="lg" />
|
|
43
|
+
<br />
|
|
44
|
+
Extra Large
|
|
45
|
+
<br />
|
|
46
|
+
<Avatar src={avatarImg} alt="avatar" size="xl" />
|
|
47
|
+
</React.Fragment>;
|
|
20
48
|
```
|
|
21
49
|
|
|
22
50
|
### Bordered - light
|
|
51
|
+
|
|
23
52
|
```ts
|
|
24
53
|
import React from 'react';
|
|
25
54
|
import { Avatar } from '@patternfly/react-core';
|
|
26
55
|
import avatarImg from './img_avatar.svg';
|
|
27
56
|
|
|
28
|
-
<Avatar src={avatarImg} alt="avatar" border="light"
|
|
57
|
+
<Avatar src={avatarImg} alt="avatar" border="light" />;
|
|
29
58
|
```
|
|
30
59
|
|
|
31
60
|
### Bordered - dark
|
|
61
|
+
|
|
32
62
|
```ts
|
|
33
63
|
import React from 'react';
|
|
34
64
|
import { Avatar } from '@patternfly/react-core';
|
|
35
65
|
import avatarImgDark from './img_avatar-dark.svg';
|
|
36
66
|
|
|
37
|
-
<Avatar src={avatarImgDark} alt="avatar" border="dark"
|
|
67
|
+
<Avatar src={avatarImgDark} alt="avatar" border="dark" />;
|
|
38
68
|
```
|
|
39
|
-
|
|
@@ -23,6 +23,8 @@ export interface FormSelectProps
|
|
|
23
23
|
isDisabled?: boolean;
|
|
24
24
|
/** Sets the FormSelect required. */
|
|
25
25
|
isRequired?: boolean;
|
|
26
|
+
/** Use the external file instead of a data URI */
|
|
27
|
+
isIconSprite?: boolean;
|
|
26
28
|
/** Optional callback for updating when selection loses focus */
|
|
27
29
|
onBlur?: (event: React.FormEvent<HTMLSelectElement>) => void;
|
|
28
30
|
/** Optional callback for updating when selection gets focus */
|
|
@@ -52,6 +54,7 @@ export class FormSelect extends React.Component<FormSelectProps, { ouiaStateId:
|
|
|
52
54
|
validated: 'default',
|
|
53
55
|
isDisabled: false,
|
|
54
56
|
isRequired: false,
|
|
57
|
+
isIconSprite: false,
|
|
55
58
|
onBlur: (): any => undefined,
|
|
56
59
|
onFocus: (): any => undefined,
|
|
57
60
|
onChange: (): any => undefined,
|
|
@@ -63,7 +66,18 @@ export class FormSelect extends React.Component<FormSelectProps, { ouiaStateId:
|
|
|
63
66
|
};
|
|
64
67
|
|
|
65
68
|
render() {
|
|
66
|
-
const {
|
|
69
|
+
const {
|
|
70
|
+
children,
|
|
71
|
+
className,
|
|
72
|
+
value,
|
|
73
|
+
validated,
|
|
74
|
+
isDisabled,
|
|
75
|
+
isRequired,
|
|
76
|
+
isIconSprite,
|
|
77
|
+
ouiaId,
|
|
78
|
+
ouiaSafe,
|
|
79
|
+
...props
|
|
80
|
+
} = this.props;
|
|
67
81
|
/* find selected option and get placeholder flag */
|
|
68
82
|
const selectedOption = React.Children.toArray(children).find((option: any) => option.props.value === value) as any;
|
|
69
83
|
const isSelectedPlaceholder = selectedOption && selectedOption.props.isPlaceholder;
|
|
@@ -72,6 +86,7 @@ export class FormSelect extends React.Component<FormSelectProps, { ouiaStateId:
|
|
|
72
86
|
{...props}
|
|
73
87
|
className={css(
|
|
74
88
|
styles.formControl,
|
|
89
|
+
isIconSprite && styles.modifiers.iconSprite,
|
|
75
90
|
className,
|
|
76
91
|
validated === ValidatedOptions.success && styles.modifiers.success,
|
|
77
92
|
validated === ValidatedOptions.warning && styles.modifiers.warning,
|
|
@@ -258,3 +258,61 @@ class FormSelectInputGrouped extends React.Component {
|
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
```
|
|
261
|
+
|
|
262
|
+
### Icon sprite variant
|
|
263
|
+
|
|
264
|
+
**Note:** The dropdown toggle icon is applied as a background image 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.
|
|
265
|
+
|
|
266
|
+
```js isBeta
|
|
267
|
+
import React from 'react';
|
|
268
|
+
import { FormSelect, FormSelectOption, FormSelectOptionGroup } from '@patternfly/react-core';
|
|
269
|
+
|
|
270
|
+
class FormSelectIconSpriteInput extends React.Component {
|
|
271
|
+
constructor(props) {
|
|
272
|
+
super(props);
|
|
273
|
+
this.state = {
|
|
274
|
+
value: '',
|
|
275
|
+
validated: ValidatedOptions.default
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
this.onChange = (value, event) => {
|
|
279
|
+
if (value === '3') {
|
|
280
|
+
this.setState({ value, validated: ValidatedOptions.success, helperText: 'You chose wisely' });
|
|
281
|
+
} else if (value === '') {
|
|
282
|
+
this.setState({ value, validated: ValidatedOptions.warning, helperText: 'You must select a value' });
|
|
283
|
+
} else {
|
|
284
|
+
this.setState({
|
|
285
|
+
value,
|
|
286
|
+
validated: ValidatedOptions.error,
|
|
287
|
+
invalidText: 'You must chose Three (thought that was obvious)'
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
this.options = [
|
|
293
|
+
{ value: '', label: 'Select a number', disabled: false, isPlaceholder: true },
|
|
294
|
+
{ value: '1', label: 'One', disabled: false, isPlaceholder: false },
|
|
295
|
+
{ value: '2', label: 'Two', disabled: false, isPlaceholder: false },
|
|
296
|
+
{ value: '3', label: 'Three - the only valid option', disabled: false, isPlaceholder: false }
|
|
297
|
+
];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
render() {
|
|
301
|
+
const { value, validated, helperText, invalidText } = this.state;
|
|
302
|
+
|
|
303
|
+
return (
|
|
304
|
+
<FormSelect
|
|
305
|
+
validated={validated}
|
|
306
|
+
isIconSprite
|
|
307
|
+
value={value}
|
|
308
|
+
onChange={this.onChange}
|
|
309
|
+
aria-label="FormSelect Input"
|
|
310
|
+
>
|
|
311
|
+
{this.options.map((option, index) => (
|
|
312
|
+
<FormSelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} />
|
|
313
|
+
))}
|
|
314
|
+
</FormSelect>
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
```
|
|
@@ -20,6 +20,8 @@ export interface TextAreaProps extends Omit<HTMLProps<HTMLTextAreaElement>, 'onC
|
|
|
20
20
|
isDisabled?: boolean;
|
|
21
21
|
/** Flag to show if the TextArea is read only. */
|
|
22
22
|
isReadOnly?: boolean;
|
|
23
|
+
/** Use the external file instead of a data URI */
|
|
24
|
+
isIconSprite?: boolean;
|
|
23
25
|
/** Flag to modify height based on contents. */
|
|
24
26
|
autoResize?: boolean;
|
|
25
27
|
/** Value to indicate if the textarea is modified to show that validation state.
|
|
@@ -46,6 +48,7 @@ export class TextAreaBase extends React.Component<TextAreaProps> {
|
|
|
46
48
|
className: '',
|
|
47
49
|
isRequired: false,
|
|
48
50
|
isDisabled: false,
|
|
51
|
+
isIconSprite: false,
|
|
49
52
|
validated: 'default',
|
|
50
53
|
resizeOrientation: 'both',
|
|
51
54
|
'aria-label': null as string
|
|
@@ -86,6 +89,7 @@ export class TextAreaBase extends React.Component<TextAreaProps> {
|
|
|
86
89
|
validated,
|
|
87
90
|
isRequired,
|
|
88
91
|
isDisabled,
|
|
92
|
+
isIconSprite,
|
|
89
93
|
isReadOnly,
|
|
90
94
|
resizeOrientation,
|
|
91
95
|
innerRef,
|
|
@@ -102,6 +106,7 @@ export class TextAreaBase extends React.Component<TextAreaProps> {
|
|
|
102
106
|
<textarea
|
|
103
107
|
className={css(
|
|
104
108
|
styles.formControl,
|
|
109
|
+
isIconSprite && styles.modifiers.iconSprite,
|
|
105
110
|
className,
|
|
106
111
|
resizeOrientation !== TextAreResizeOrientation.both && styles.modifiers[orientation],
|
|
107
112
|
validated === ValidatedOptions.success && styles.modifiers.success,
|
|
@@ -116,6 +116,7 @@ exports[`validated text area success 1`] = `
|
|
|
116
116
|
className=""
|
|
117
117
|
innerRef={null}
|
|
118
118
|
isDisabled={false}
|
|
119
|
+
isIconSprite={false}
|
|
119
120
|
isRequired={false}
|
|
120
121
|
onChange={[MockFunction]}
|
|
121
122
|
required={true}
|
|
@@ -148,6 +149,7 @@ exports[`validated text area warning 1`] = `
|
|
|
148
149
|
className=""
|
|
149
150
|
innerRef={null}
|
|
150
151
|
isDisabled={false}
|
|
152
|
+
isIconSprite={false}
|
|
151
153
|
isRequired={false}
|
|
152
154
|
onChange={[MockFunction]}
|
|
153
155
|
required={true}
|
|
@@ -207,3 +207,46 @@ import { TextArea } from '@patternfly/react-core';
|
|
|
207
207
|
<TextArea aria-label="auto resizing text area example" autoResize />
|
|
208
208
|
```
|
|
209
209
|
|
|
210
|
+
### Icon sprite variants
|
|
211
|
+
|
|
212
|
+
**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.
|
|
213
|
+
|
|
214
|
+
```js isBeta
|
|
215
|
+
import React from 'react';
|
|
216
|
+
import { TextArea } from '@patternfly/react-core';
|
|
217
|
+
|
|
218
|
+
IconSpriteTextArea = () => {
|
|
219
|
+
const [success, setSuccess] = React.useState('');
|
|
220
|
+
const [warning, setWarning] = React.useState('');
|
|
221
|
+
const [error, setError] = React.useState('');
|
|
222
|
+
|
|
223
|
+
return (
|
|
224
|
+
<>
|
|
225
|
+
<TextArea
|
|
226
|
+
validated={ValidatedOptions.success}
|
|
227
|
+
isIconSprite
|
|
228
|
+
type="text"
|
|
229
|
+
onChange={value => setSuccess(value)}
|
|
230
|
+
aria-label="success icon sprite text area example"
|
|
231
|
+
/>
|
|
232
|
+
<br />
|
|
233
|
+
<br />
|
|
234
|
+
<TextArea
|
|
235
|
+
validated={ValidatedOptions.warning}
|
|
236
|
+
isIconSprite
|
|
237
|
+
type="text"
|
|
238
|
+
onChange={value => setWarning(value)}
|
|
239
|
+
aria-label="warning icon sprite text input example"
|
|
240
|
+
/>
|
|
241
|
+
<br />
|
|
242
|
+
<br />
|
|
243
|
+
<TextArea
|
|
244
|
+
validated={ValidatedOptions.error}
|
|
245
|
+
isIconSprite
|
|
246
|
+
type="text"
|
|
247
|
+
onChange={value => setError(value)}
|
|
248
|
+
aria-label="error icon sprite text area example"
|
|
249
|
+
/>
|
|
250
|
+
</>
|
|
251
|
+
);
|
|
252
|
+
};
|
|
@@ -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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
160
|
-
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
```
|
|
@@ -105,10 +105,18 @@ OptionsTooltip = () => {
|
|
|
105
105
|
const [exitDelayInput, setExitDelayInput] = React.useState(0);
|
|
106
106
|
const [animationDuration, setAnimationDuration] = React.useState(300);
|
|
107
107
|
const tipBoxRef = React.useRef(null);
|
|
108
|
-
|
|
108
|
+
|
|
109
|
+
const scrollToRef = ref => {
|
|
110
|
+
if (ref && ref.current) {
|
|
111
|
+
ref.current.scrollTop = 400;
|
|
112
|
+
ref.current.scrollLeft = 300;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
109
116
|
React.useEffect(() => {
|
|
110
117
|
scrollToRef(tipBoxRef);
|
|
111
118
|
}, []);
|
|
119
|
+
|
|
112
120
|
return (
|
|
113
121
|
<>
|
|
114
122
|
<div>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
height: 450px;
|
|
3
3
|
position: relative;
|
|
4
4
|
width: 100%;
|
|
5
|
-
overflow
|
|
5
|
+
overflow: scroll;
|
|
6
6
|
overscroll-behavior: contain;
|
|
7
7
|
margin: 0 auto;
|
|
8
8
|
border: 2px dashed #ff6b81;
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
.tooltip-box::after {
|
|
13
13
|
content: '';
|
|
14
14
|
display: block;
|
|
15
|
-
width:
|
|
15
|
+
width: 1500px;
|
|
16
16
|
height: 600px;
|
|
17
17
|
}
|
|
18
18
|
.tooltip-button {
|
|
19
19
|
position: absolute;
|
|
20
|
-
left:
|
|
21
|
-
}
|
|
20
|
+
left: 600px;
|
|
21
|
+
}
|