@patternfly/react-core 4.191.5 → 4.191.6
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 +11 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts +4 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js +2 -2
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts +4 -0
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js +2 -2
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
- package/dist/umd/react-core.js +2 -2
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +5 -5
- package/src/components/TextInputGroup/TextInputGroupMain.tsx +7 -1
- package/src/components/TextInputGroup/__tests__/__snapshots__/TextInputGroup.test.tsx.snap +6 -0
- package/src/components/TextInputGroup/examples/TextInputGroupFilters.tsx +12 -7
- package/src/components/TextInputGroup/examples/TextInputGroupUtilitiesAndIcon.tsx +12 -7
- package/src/demos/examples/TextInputGroup/AttributeValueFiltering.tsx +13 -8
- package/src/demos/examples/TextInputGroup/AutoCompleteSearch.tsx +29 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.191.
|
|
3
|
+
"version": "4.191.6",
|
|
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,9 +34,9 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.42.
|
|
38
|
-
"@patternfly/react-styles": "^4.41.
|
|
39
|
-
"@patternfly/react-tokens": "^4.43.
|
|
37
|
+
"@patternfly/react-icons": "^4.42.6",
|
|
38
|
+
"@patternfly/react-styles": "^4.41.6",
|
|
39
|
+
"@patternfly/react-tokens": "^4.43.6",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
@@ -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": "ce80b69350209b17f274f222e03278a3d09c021f"
|
|
64
64
|
}
|
|
@@ -31,6 +31,10 @@ export interface TextInputGroupMainProps extends Omit<React.HTMLProps<HTMLDivEle
|
|
|
31
31
|
onBlur?: (event?: any) => void;
|
|
32
32
|
/** Accessibility label for the input */
|
|
33
33
|
'aria-label'?: string;
|
|
34
|
+
/** Value for the input */
|
|
35
|
+
value?: string | number;
|
|
36
|
+
/** Placeholder value for the input */
|
|
37
|
+
placeholder?: string;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
export const TextInputGroupMain: React.FunctionComponent<TextInputGroupMainProps> = ({
|
|
@@ -43,6 +47,7 @@ export const TextInputGroupMain: React.FunctionComponent<TextInputGroupMainProps
|
|
|
43
47
|
onBlur,
|
|
44
48
|
'aria-label': ariaLabel = 'Type to filter',
|
|
45
49
|
value: inputValue,
|
|
50
|
+
placeholder: inputPlaceHolder,
|
|
46
51
|
...props
|
|
47
52
|
}: TextInputGroupMainProps) => {
|
|
48
53
|
const { isDisabled } = React.useContext(TextInputGroupContext);
|
|
@@ -64,7 +69,8 @@ export const TextInputGroupMain: React.FunctionComponent<TextInputGroupMainProps
|
|
|
64
69
|
onChange={handleChange}
|
|
65
70
|
onFocus={onFocus}
|
|
66
71
|
onBlur={onBlur}
|
|
67
|
-
value={inputValue}
|
|
72
|
+
value={inputValue || ''}
|
|
73
|
+
placeholder={inputPlaceHolder}
|
|
68
74
|
/>
|
|
69
75
|
</span>
|
|
70
76
|
</div>
|
|
@@ -22,6 +22,7 @@ exports[`TextInputGroup gets custom class and id 1`] = `
|
|
|
22
22
|
className="pf-c-text-input-group__text-input"
|
|
23
23
|
onChange={[Function]}
|
|
24
24
|
type="text"
|
|
25
|
+
value=""
|
|
25
26
|
/>
|
|
26
27
|
</span>
|
|
27
28
|
</div>
|
|
@@ -53,6 +54,7 @@ exports[`TextInputGroup renders content 1`] = `
|
|
|
53
54
|
className="pf-c-text-input-group__text-input"
|
|
54
55
|
onChange={[Function]}
|
|
55
56
|
type="text"
|
|
57
|
+
value=""
|
|
56
58
|
/>
|
|
57
59
|
</span>
|
|
58
60
|
</div>
|
|
@@ -87,6 +89,7 @@ exports[`TextInputGroup renders with the proper stying when disabled 1`] = `
|
|
|
87
89
|
disabled={true}
|
|
88
90
|
onChange={[Function]}
|
|
89
91
|
type="text"
|
|
92
|
+
value=""
|
|
90
93
|
/>
|
|
91
94
|
</span>
|
|
92
95
|
</div>
|
|
@@ -115,6 +118,7 @@ exports[`TextInputGroupMain renders content 1`] = `
|
|
|
115
118
|
disabled={false}
|
|
116
119
|
onChange={[Function]}
|
|
117
120
|
type="text"
|
|
121
|
+
value=""
|
|
118
122
|
/>
|
|
119
123
|
</span>
|
|
120
124
|
</div>
|
|
@@ -172,6 +176,7 @@ exports[`TextInputGroupMain renders given input icon props 1`] = `
|
|
|
172
176
|
disabled={false}
|
|
173
177
|
onChange={[Function]}
|
|
174
178
|
type="text"
|
|
179
|
+
value=""
|
|
175
180
|
/>
|
|
176
181
|
</span>
|
|
177
182
|
</div>
|
|
@@ -195,6 +200,7 @@ exports[`TextInputGroupMain renders the input with custom aria label when given
|
|
|
195
200
|
disabled={false}
|
|
196
201
|
onChange={[Function]}
|
|
197
202
|
type="text"
|
|
203
|
+
value=""
|
|
198
204
|
/>
|
|
199
205
|
</span>
|
|
200
206
|
</div>
|
|
@@ -40,6 +40,9 @@ export const TextInputGroupFilters: React.FunctionComponent = () => {
|
|
|
40
40
|
/** show the input/chip clearing button only when either the text input or chip group are not empty */
|
|
41
41
|
const showClearButton = !!inputValue || !!currentChips.length;
|
|
42
42
|
|
|
43
|
+
/** render the utilities component only when a component it contains is being rendered */
|
|
44
|
+
const showUtilities = showClearButton;
|
|
45
|
+
|
|
43
46
|
/** callback for clearing all selected chips and the text input */
|
|
44
47
|
const clearChipsAndInput = () => {
|
|
45
48
|
setCurrentChips([]);
|
|
@@ -57,13 +60,15 @@ export const TextInputGroupFilters: React.FunctionComponent = () => {
|
|
|
57
60
|
))}
|
|
58
61
|
</ChipGroup>
|
|
59
62
|
</TextInputGroupMain>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
{showUtilities && (
|
|
64
|
+
<TextInputGroupUtilities>
|
|
65
|
+
{showClearButton && (
|
|
66
|
+
<Button variant="plain" onClick={clearChipsAndInput} aria-label="Clear button and input">
|
|
67
|
+
<TimesIcon />
|
|
68
|
+
</Button>
|
|
69
|
+
)}
|
|
70
|
+
</TextInputGroupUtilities>
|
|
71
|
+
)}
|
|
67
72
|
</TextInputGroup>
|
|
68
73
|
);
|
|
69
74
|
};
|
|
@@ -14,6 +14,9 @@ export const TextInputGroupUtilitiesAndIcon: React.FunctionComponent = () => {
|
|
|
14
14
|
/** show the input clearing button only when the input is not empty */
|
|
15
15
|
const showClearButton = !!inputValue;
|
|
16
16
|
|
|
17
|
+
/** render the utilities component only when a component it contains is being rendered */
|
|
18
|
+
const showUtilities = showClearButton;
|
|
19
|
+
|
|
17
20
|
/** callback for clearing the text input */
|
|
18
21
|
const clearInput = () => {
|
|
19
22
|
setInputValue('');
|
|
@@ -22,13 +25,15 @@ export const TextInputGroupUtilitiesAndIcon: React.FunctionComponent = () => {
|
|
|
22
25
|
return (
|
|
23
26
|
<TextInputGroup>
|
|
24
27
|
<TextInputGroupMain icon={<SearchIcon />} value={inputValue} onChange={handleInputChange} />
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
{showUtilities && (
|
|
29
|
+
<TextInputGroupUtilities>
|
|
30
|
+
{showClearButton && (
|
|
31
|
+
<Button variant="plain" onClick={clearInput} aria-label="Clear button and input">
|
|
32
|
+
<TimesIcon />
|
|
33
|
+
</Button>
|
|
34
|
+
)}
|
|
35
|
+
</TextInputGroupUtilities>
|
|
36
|
+
)}
|
|
32
37
|
</TextInputGroup>
|
|
33
38
|
);
|
|
34
39
|
};
|
|
@@ -205,12 +205,15 @@ export const AttributeValueFiltering: React.FunctionComponent = () => {
|
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
-
/**
|
|
208
|
+
/** show the search icon only when there are no chips to prevent the chips from being displayed behind the icon */
|
|
209
209
|
const showSearchIcon = !currentChips.length;
|
|
210
210
|
|
|
211
211
|
/** only show the clear button when there is something that can be cleared */
|
|
212
212
|
const showClearButton = !!inputValue || !!currentChips.length;
|
|
213
213
|
|
|
214
|
+
/** render the utilities component only when a component it contains is being rendered */
|
|
215
|
+
const showUtilities = showClearButton;
|
|
216
|
+
|
|
214
217
|
const inputGroup = (
|
|
215
218
|
<div ref={textInputGroupRef}>
|
|
216
219
|
<TextInputGroup>
|
|
@@ -229,13 +232,15 @@ export const AttributeValueFiltering: React.FunctionComponent = () => {
|
|
|
229
232
|
))}
|
|
230
233
|
</ChipGroup>
|
|
231
234
|
</TextInputGroupMain>
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
<
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
235
|
+
{showUtilities && (
|
|
236
|
+
<TextInputGroupUtilities>
|
|
237
|
+
{showClearButton && (
|
|
238
|
+
<Button variant="plain" onClick={clearChipsAndInput} aria-label="Clear button and input">
|
|
239
|
+
<TimesIcon />
|
|
240
|
+
</Button>
|
|
241
|
+
)}
|
|
242
|
+
</TextInputGroupUtilities>
|
|
243
|
+
)}
|
|
239
244
|
</TextInputGroup>
|
|
240
245
|
</div>
|
|
241
246
|
);
|
|
@@ -92,11 +92,11 @@ export const AutoCompleteSearch: React.FunctionComponent = () => {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
const handleTab = (
|
|
95
|
+
const handleTab = () => {
|
|
96
96
|
if (menuItems.length === 3) {
|
|
97
97
|
setInputValue(menuItems[2].props.children);
|
|
98
|
-
event.preventDefault();
|
|
99
98
|
}
|
|
99
|
+
setMenuIsOpen(false);
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
/** close the menu when escape is hit */
|
|
@@ -129,7 +129,7 @@ export const AutoCompleteSearch: React.FunctionComponent = () => {
|
|
|
129
129
|
handleEscape();
|
|
130
130
|
break;
|
|
131
131
|
case 'Tab':
|
|
132
|
-
handleTab(
|
|
132
|
+
handleTab();
|
|
133
133
|
break;
|
|
134
134
|
case 'ArrowUp':
|
|
135
135
|
case 'ArrowDown':
|
|
@@ -166,19 +166,29 @@ export const AutoCompleteSearch: React.FunctionComponent = () => {
|
|
|
166
166
|
|
|
167
167
|
/** enable keyboard only usage while focused on the menu */
|
|
168
168
|
const handleMenuKeyDown = (event: React.KeyboardEvent) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
switch (event.key) {
|
|
170
|
+
case 'Tab':
|
|
171
|
+
case 'Escape':
|
|
172
|
+
event.preventDefault();
|
|
173
|
+
focusTextInput();
|
|
174
|
+
setMenuIsOpen(false);
|
|
175
|
+
break;
|
|
176
|
+
case 'Enter':
|
|
177
|
+
case ' ':
|
|
178
|
+
setTimeout(() => setMenuIsOpen(false), 0);
|
|
179
|
+
break;
|
|
173
180
|
}
|
|
174
181
|
};
|
|
175
182
|
|
|
176
|
-
/**
|
|
183
|
+
/** show the search icon only when there are no chips to prevent the chips from being displayed behind the icon */
|
|
177
184
|
const showSearchIcon = !currentChips.length;
|
|
178
185
|
|
|
179
186
|
/** only show the clear button when there is something that can be cleared */
|
|
180
187
|
const showClearButton = !!inputValue || !!currentChips.length;
|
|
181
188
|
|
|
189
|
+
/** render the utilities component only when a component it contains is being rendered */
|
|
190
|
+
const showUtilities = showClearButton;
|
|
191
|
+
|
|
182
192
|
const inputGroup = (
|
|
183
193
|
<div ref={textInputGroupRef}>
|
|
184
194
|
<TextInputGroup>
|
|
@@ -188,6 +198,8 @@ export const AutoCompleteSearch: React.FunctionComponent = () => {
|
|
|
188
198
|
onChange={handleInputChange}
|
|
189
199
|
onFocus={() => setMenuIsOpen(true)}
|
|
190
200
|
onKeyDown={handleTextInputKeyDown}
|
|
201
|
+
placeholder="search"
|
|
202
|
+
aria-label="Search input"
|
|
191
203
|
>
|
|
192
204
|
<ChipGroup>
|
|
193
205
|
{currentChips.map(currentChip => (
|
|
@@ -197,13 +209,15 @@ export const AutoCompleteSearch: React.FunctionComponent = () => {
|
|
|
197
209
|
))}
|
|
198
210
|
</ChipGroup>
|
|
199
211
|
</TextInputGroupMain>
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
<
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
212
|
+
{showUtilities && (
|
|
213
|
+
<TextInputGroupUtilities>
|
|
214
|
+
{showClearButton && (
|
|
215
|
+
<Button variant="plain" onClick={clearChipsAndInput} aria-label="Clear button for chips and input">
|
|
216
|
+
<TimesIcon />
|
|
217
|
+
</Button>
|
|
218
|
+
)}
|
|
219
|
+
</TextInputGroupUtilities>
|
|
220
|
+
)}
|
|
207
221
|
</TextInputGroup>
|
|
208
222
|
</div>
|
|
209
223
|
);
|