@patternfly/react-core 4.220.2 → 4.221.2
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 +27 -0
- package/dist/esm/components/DataList/DataList.d.ts +9 -0
- package/dist/esm/components/DataList/DataList.d.ts.map +1 -1
- package/dist/esm/components/DataList/DataList.js +3 -2
- package/dist/esm/components/DataList/DataList.js.map +1 -1
- package/dist/esm/components/DataList/DataListItem.d.ts +2 -0
- package/dist/esm/components/DataList/DataListItem.d.ts.map +1 -1
- package/dist/esm/components/DataList/DataListItem.js +13 -6
- package/dist/esm/components/DataList/DataListItem.js.map +1 -1
- package/dist/esm/components/InputGroup/InputGroup.d.ts +2 -0
- package/dist/esm/components/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/esm/components/InputGroup/InputGroup.js +3 -2
- package/dist/esm/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.d.ts +2 -0
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.js +12 -10
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.d.ts +8 -0
- package/dist/esm/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.js +38 -28
- package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/esm/components/Select/Select.d.ts +2 -0
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +8 -7
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroup.d.ts +2 -0
- package/dist/esm/components/TextInputGroup/TextInputGroup.d.ts.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroup.js +3 -2
- package/dist/esm/components/TextInputGroup/TextInputGroup.js.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts +2 -0
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js +3 -2
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
- package/dist/js/components/DataList/DataList.d.ts +9 -0
- package/dist/js/components/DataList/DataList.d.ts.map +1 -1
- package/dist/js/components/DataList/DataList.js +3 -2
- package/dist/js/components/DataList/DataList.js.map +1 -1
- package/dist/js/components/DataList/DataListItem.d.ts +2 -0
- package/dist/js/components/DataList/DataListItem.d.ts.map +1 -1
- package/dist/js/components/DataList/DataListItem.js +13 -6
- package/dist/js/components/DataList/DataListItem.js.map +1 -1
- package/dist/js/components/InputGroup/InputGroup.d.ts +2 -0
- package/dist/js/components/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/js/components/InputGroup/InputGroup.js +3 -2
- package/dist/js/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/js/components/SearchInput/AdvancedSearchMenu.d.ts +2 -0
- package/dist/js/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
- package/dist/js/components/SearchInput/AdvancedSearchMenu.js +12 -10
- package/dist/js/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
- package/dist/js/components/SearchInput/SearchInput.d.ts +8 -0
- package/dist/js/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/js/components/SearchInput/SearchInput.js +38 -28
- package/dist/js/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/js/components/Select/Select.d.ts +2 -0
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +8 -7
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroup.d.ts +2 -0
- package/dist/js/components/TextInputGroup/TextInputGroup.d.ts.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroup.js +3 -2
- package/dist/js/components/TextInputGroup/TextInputGroup.js.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts +2 -0
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js +3 -2
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
- package/dist/styles/assets/images/icon-github.hbs +4 -0
- package/dist/styles/assets/images/icon-google.hbs +4 -0
- package/dist/styles/assets/images/icon-red-hat.hbs +1 -0
- package/dist/styles/base-no-reset.css +93 -4
- package/dist/styles/base.css +93 -4
- package/dist/umd/react-core.css +790 -8
- package/dist/umd/react-core.js +433 -342
- package/dist/umd/react-core.min.css +790 -8
- package/dist/umd/react-core.min.js +6 -6
- package/package.json +6 -6
- package/src/components/DataList/DataList.tsx +12 -0
- package/src/components/DataList/DataListItem.tsx +32 -3
- package/src/components/DataList/__tests__/DataList.test.tsx +130 -0
- package/src/components/DataList/examples/DataList.md +1 -0
- package/src/components/DataList/examples/DataListSelectableRows.tsx +5 -0
- package/src/components/InputGroup/InputGroup.tsx +7 -1
- package/src/components/SearchInput/AdvancedSearchMenu.tsx +24 -18
- package/src/components/SearchInput/SearchInput.tsx +130 -113
- package/src/components/SearchInput/__tests__/SearchInput.test.tsx +1 -1
- package/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap +297 -301
- package/src/components/SearchInput/examples/SearchInput.md +5 -2
- package/src/components/Select/Select.tsx +8 -2
- package/src/components/TextInputGroup/TextInputGroup.tsx +18 -7
- package/src/components/TextInputGroup/TextInputGroupMain.tsx +5 -0
- package/src/demos/PrimaryDetail.md +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import styles from '@patternfly/react-styles/css/components/SearchInput/search-input';
|
|
3
2
|
import { css } from '@patternfly/react-styles';
|
|
3
|
+
import styles from '@patternfly/react-styles/css/components/SearchInput/search-input';
|
|
4
4
|
import { Button, ButtonVariant } from '../Button';
|
|
5
5
|
import { Badge } from '../Badge';
|
|
6
6
|
import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-icon';
|
|
@@ -9,8 +9,9 @@ import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
|
|
|
9
9
|
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
10
10
|
import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
|
|
11
11
|
import ArrowRightIcon from '@patternfly/react-icons/dist/esm/icons/arrow-right-icon';
|
|
12
|
-
import { InputGroup } from '../InputGroup';
|
|
13
12
|
import { AdvancedSearchMenu } from './AdvancedSearchMenu';
|
|
13
|
+
import { TextInputGroup, TextInputGroupMain, TextInputGroupUtilities } from '../TextInputGroup';
|
|
14
|
+
import { InputGroup } from '../InputGroup';
|
|
14
15
|
|
|
15
16
|
export interface SearchAttribute {
|
|
16
17
|
/** The search attribute's value to be provided in the search input's query string.
|
|
@@ -56,7 +57,14 @@ export interface SearchInputProps extends Omit<React.HTMLProps<HTMLDivElement>,
|
|
|
56
57
|
isAdvancedSearchOpen?: boolean;
|
|
57
58
|
/** Label for the button which opens the advanced search form menu */
|
|
58
59
|
openMenuButtonAriaLabel?: string;
|
|
59
|
-
|
|
60
|
+
/** Label for the button to navigate to previous result */
|
|
61
|
+
previousNavigationButtonAriaLabel?: string;
|
|
62
|
+
/** Flag indicating if the previous navigation button is disabled */
|
|
63
|
+
isPreviousNavigationButtonDisabled?: boolean;
|
|
64
|
+
/** Label for the button to navigate to next result */
|
|
65
|
+
nextNavigationButtonAriaLabel?: string;
|
|
66
|
+
/** Flag indicating if the next navigation button is disabled */
|
|
67
|
+
isNextNavigationButtonDisabled?: boolean;
|
|
60
68
|
/** Function called when user clicks to navigate to next result */
|
|
61
69
|
onNextClick?: (event: React.SyntheticEvent<HTMLButtonElement>) => void;
|
|
62
70
|
/** Function called when user clicks to navigate to previous result */
|
|
@@ -98,6 +106,10 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
|
|
|
98
106
|
'aria-label': ariaLabel = 'Search input',
|
|
99
107
|
resetButtonLabel = 'Reset',
|
|
100
108
|
openMenuButtonAriaLabel = 'Open advanced search',
|
|
109
|
+
previousNavigationButtonAriaLabel = 'Previous',
|
|
110
|
+
isPreviousNavigationButtonDisabled = false,
|
|
111
|
+
isNextNavigationButtonDisabled = false,
|
|
112
|
+
nextNavigationButtonAriaLabel = 'Next',
|
|
101
113
|
submitSearchButtonLabel = 'Search',
|
|
102
114
|
isDisabled = false,
|
|
103
115
|
...props
|
|
@@ -124,11 +136,11 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
|
|
|
124
136
|
setIsSearchMenuOpen(isAdvancedSearchOpen);
|
|
125
137
|
}, [isAdvancedSearchOpen]);
|
|
126
138
|
|
|
127
|
-
const onChangeHandler = (event: React.
|
|
139
|
+
const onChangeHandler = (value: string, event: React.FormEvent<HTMLInputElement>) => {
|
|
128
140
|
if (onChange) {
|
|
129
|
-
onChange(
|
|
141
|
+
onChange(value, event);
|
|
130
142
|
}
|
|
131
|
-
setSearchValue(
|
|
143
|
+
setSearchValue(value);
|
|
132
144
|
};
|
|
133
145
|
|
|
134
146
|
const onToggle = (e: React.SyntheticEvent<HTMLButtonElement>) => {
|
|
@@ -178,116 +190,121 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
|
|
|
178
190
|
}
|
|
179
191
|
};
|
|
180
192
|
|
|
181
|
-
|
|
182
|
-
<
|
|
183
|
-
<
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
<
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
)}
|
|
216
|
-
{!!onNextClick && !!onPreviousClick && (
|
|
217
|
-
<span className={css(styles.searchInputNav)}>
|
|
218
|
-
<Button
|
|
219
|
-
variant={ButtonVariant.plain}
|
|
220
|
-
aria-label="Previous"
|
|
221
|
-
isDisabled={isDisabled}
|
|
222
|
-
onClick={onPreviousClick}
|
|
223
|
-
>
|
|
224
|
-
<AngleUpIcon />
|
|
225
|
-
</Button>
|
|
226
|
-
<Button variant={ButtonVariant.plain} aria-label="Next" isDisabled={isDisabled} onClick={onNextClick}>
|
|
227
|
-
<AngleDownIcon />
|
|
228
|
-
</Button>
|
|
229
|
-
</span>
|
|
230
|
-
)}
|
|
231
|
-
{!!onClear && (
|
|
232
|
-
<span className="pf-c-search-input__clear">
|
|
233
|
-
<Button
|
|
234
|
-
variant={ButtonVariant.plain}
|
|
235
|
-
isDisabled={isDisabled}
|
|
236
|
-
aria-label={resetButtonLabel}
|
|
237
|
-
onClick={onClearInput}
|
|
238
|
-
>
|
|
239
|
-
<TimesIcon />
|
|
240
|
-
</Button>
|
|
241
|
-
</span>
|
|
242
|
-
)}
|
|
243
|
-
</span>
|
|
193
|
+
const buildSearchTextInputGroup = ({ ...searchInputProps } = {}) => (
|
|
194
|
+
<TextInputGroup isDisabled={isDisabled} {...searchInputProps}>
|
|
195
|
+
<TextInputGroupMain
|
|
196
|
+
hint={hint}
|
|
197
|
+
icon={<SearchIcon />}
|
|
198
|
+
innerRef={searchInputInputRef}
|
|
199
|
+
value={searchValue}
|
|
200
|
+
placeholder={placeholder}
|
|
201
|
+
aria-label={ariaLabel}
|
|
202
|
+
onKeyDown={onEnter}
|
|
203
|
+
onChange={onChangeHandler}
|
|
204
|
+
/>
|
|
205
|
+
{value && (
|
|
206
|
+
<TextInputGroupUtilities>
|
|
207
|
+
{resultsCount && <Badge isRead>{resultsCount}</Badge>}
|
|
208
|
+
{!!onNextClick && !!onPreviousClick && (
|
|
209
|
+
<div className="pf-c-text-input-group__group">
|
|
210
|
+
<Button
|
|
211
|
+
variant={ButtonVariant.plain}
|
|
212
|
+
aria-label={previousNavigationButtonAriaLabel}
|
|
213
|
+
isDisabled={isDisabled || isPreviousNavigationButtonDisabled}
|
|
214
|
+
onClick={onPreviousClick}
|
|
215
|
+
>
|
|
216
|
+
<AngleUpIcon />
|
|
217
|
+
</Button>
|
|
218
|
+
<Button
|
|
219
|
+
variant={ButtonVariant.plain}
|
|
220
|
+
aria-label={nextNavigationButtonAriaLabel}
|
|
221
|
+
isDisabled={isDisabled || isNextNavigationButtonDisabled}
|
|
222
|
+
onClick={onNextClick}
|
|
223
|
+
>
|
|
224
|
+
<AngleDownIcon />
|
|
225
|
+
</Button>
|
|
226
|
+
</div>
|
|
244
227
|
)}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
</Button>
|
|
257
|
-
)}
|
|
258
|
-
{!!onSearch && (
|
|
259
|
-
<Button
|
|
260
|
-
type="submit"
|
|
261
|
-
variant={ButtonVariant.control}
|
|
262
|
-
aria-label={submitSearchButtonLabel}
|
|
263
|
-
onClick={onSearchHandler}
|
|
264
|
-
isDisabled={isDisabled}
|
|
265
|
-
>
|
|
266
|
-
<ArrowRightIcon />
|
|
267
|
-
</Button>
|
|
268
|
-
)}
|
|
269
|
-
</InputGroup>
|
|
270
|
-
{attributes.length > 0 && (
|
|
271
|
-
<AdvancedSearchMenu
|
|
272
|
-
value={value}
|
|
273
|
-
parentRef={searchInputRef}
|
|
274
|
-
parentInputRef={searchInputInputRef}
|
|
275
|
-
onSearch={onSearch}
|
|
276
|
-
onClear={onClear}
|
|
277
|
-
onChange={onChange}
|
|
278
|
-
onToggleAdvancedMenu={onToggle}
|
|
279
|
-
resetButtonLabel={resetButtonLabel}
|
|
280
|
-
submitSearchButtonLabel={submitSearchButtonLabel}
|
|
281
|
-
attributes={attributes}
|
|
282
|
-
formAdditionalItems={formAdditionalItems}
|
|
283
|
-
hasWordsAttrLabel={hasWordsAttrLabel}
|
|
284
|
-
advancedSearchDelimiter={advancedSearchDelimiter}
|
|
285
|
-
getAttrValueMap={getAttrValueMap}
|
|
286
|
-
isSearchMenuOpen={isSearchMenuOpen}
|
|
287
|
-
/>
|
|
228
|
+
{!!onClear && (
|
|
229
|
+
<Button
|
|
230
|
+
variant={ButtonVariant.plain}
|
|
231
|
+
isDisabled={isDisabled}
|
|
232
|
+
aria-label={resetButtonLabel}
|
|
233
|
+
onClick={onClearInput}
|
|
234
|
+
>
|
|
235
|
+
<TimesIcon />
|
|
236
|
+
</Button>
|
|
237
|
+
)}
|
|
238
|
+
</TextInputGroupUtilities>
|
|
288
239
|
)}
|
|
289
|
-
</
|
|
240
|
+
</TextInputGroup>
|
|
290
241
|
);
|
|
242
|
+
|
|
243
|
+
const buildSearchTextInputGroupWithExtraButtons = ({ ...searchInputProps } = {}) => (
|
|
244
|
+
<InputGroup {...searchInputProps}>
|
|
245
|
+
{buildSearchTextInputGroup()}
|
|
246
|
+
{(attributes.length > 0 || onToggleAdvancedSearch) && (
|
|
247
|
+
<Button
|
|
248
|
+
className={isSearchMenuOpen && 'pf-m-expanded'}
|
|
249
|
+
variant={ButtonVariant.control}
|
|
250
|
+
aria-label={openMenuButtonAriaLabel}
|
|
251
|
+
onClick={onToggle}
|
|
252
|
+
isDisabled={isDisabled}
|
|
253
|
+
aria-expanded={isSearchMenuOpen}
|
|
254
|
+
>
|
|
255
|
+
<CaretDownIcon />
|
|
256
|
+
</Button>
|
|
257
|
+
)}
|
|
258
|
+
{!!onSearch && (
|
|
259
|
+
<Button
|
|
260
|
+
type="submit"
|
|
261
|
+
variant={ButtonVariant.control}
|
|
262
|
+
aria-label={submitSearchButtonLabel}
|
|
263
|
+
onClick={onSearchHandler}
|
|
264
|
+
isDisabled={isDisabled || !searchValue}
|
|
265
|
+
>
|
|
266
|
+
<ArrowRightIcon />
|
|
267
|
+
</Button>
|
|
268
|
+
)}
|
|
269
|
+
</InputGroup>
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
const searchInputProps = {
|
|
273
|
+
...props,
|
|
274
|
+
className: className && css(className),
|
|
275
|
+
innerRef: searchInputRef
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
if (!!onSearch || attributes.length > 0 || !!onToggleAdvancedSearch) {
|
|
279
|
+
if (attributes.length > 0) {
|
|
280
|
+
return (
|
|
281
|
+
<div className={css(className, styles.searchInput)} ref={searchInputRef} {...props}>
|
|
282
|
+
{buildSearchTextInputGroupWithExtraButtons()}
|
|
283
|
+
<AdvancedSearchMenu
|
|
284
|
+
className={styles.searchInputMenu}
|
|
285
|
+
value={value}
|
|
286
|
+
parentRef={searchInputRef}
|
|
287
|
+
parentInputRef={searchInputInputRef}
|
|
288
|
+
onSearch={onSearch}
|
|
289
|
+
onClear={onClear}
|
|
290
|
+
onChange={onChange}
|
|
291
|
+
onToggleAdvancedMenu={onToggle}
|
|
292
|
+
resetButtonLabel={resetButtonLabel}
|
|
293
|
+
submitSearchButtonLabel={submitSearchButtonLabel}
|
|
294
|
+
attributes={attributes}
|
|
295
|
+
formAdditionalItems={formAdditionalItems}
|
|
296
|
+
hasWordsAttrLabel={hasWordsAttrLabel}
|
|
297
|
+
advancedSearchDelimiter={advancedSearchDelimiter}
|
|
298
|
+
getAttrValueMap={getAttrValueMap}
|
|
299
|
+
isSearchMenuOpen={isSearchMenuOpen}
|
|
300
|
+
/>
|
|
301
|
+
</div>
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return buildSearchTextInputGroupWithExtraButtons({ ...searchInputProps });
|
|
306
|
+
}
|
|
307
|
+
return buildSearchTextInputGroup(searchInputProps);
|
|
291
308
|
};
|
|
292
309
|
SearchInputBase.displayName = 'SearchInputBase';
|
|
293
310
|
|
|
@@ -37,7 +37,7 @@ describe('SearchInput', () => {
|
|
|
37
37
|
render(<SearchInput {...props} resultsCount="3 / 7" aria-label="simple text input" data-testid="test-id" />);
|
|
38
38
|
|
|
39
39
|
const input = screen.getByTestId('test-id');
|
|
40
|
-
expect(input.querySelector('.pf-c-
|
|
40
|
+
expect(input.querySelector('.pf-c-text-input-group__group')).toBeInTheDocument();
|
|
41
41
|
expect(input.querySelector('.pf-c-badge')).toBeInTheDocument();
|
|
42
42
|
|
|
43
43
|
userEvent.click(screen.getByRole('button', { name: 'Previous' }));
|