@patternfly/react-core 4.220.1 → 4.221.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 +27 -0
- 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/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/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/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 +873 -91
- package/dist/umd/react-core.js +409 -327
- 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/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/TextInputGroup/TextInputGroup.tsx +18 -7
- package/src/components/TextInputGroup/TextInputGroupMain.tsx +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.221.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.72.1",
|
|
38
|
+
"@patternfly/react-styles": "^4.71.1",
|
|
39
|
+
"@patternfly/react-tokens": "^4.73.1",
|
|
40
40
|
"focus-trap": "6.9.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.
|
|
46
|
+
"@patternfly/patternfly": "4.196.6",
|
|
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": "185f5001db15c2ef7690bb60e9876dfbd758c4d9"
|
|
64
64
|
}
|
|
@@ -10,19 +10,25 @@ export interface InputGroupProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
10
10
|
className?: string;
|
|
11
11
|
/** Content rendered inside the input group. */
|
|
12
12
|
children: React.ReactNode;
|
|
13
|
+
/** @hide A reference object to attach to the input box */
|
|
14
|
+
innerRef?: React.RefObject<any>;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export const InputGroup: React.FunctionComponent<InputGroupProps> = ({
|
|
16
18
|
className = '',
|
|
17
19
|
children,
|
|
20
|
+
innerRef,
|
|
18
21
|
...props
|
|
19
22
|
}: InputGroupProps) => {
|
|
20
23
|
const formCtrls = [FormSelect, TextArea, TextInput].map(comp => comp.displayName);
|
|
21
24
|
const idItem = React.Children.toArray(children).find(
|
|
22
25
|
(child: any) => !formCtrls.includes(child.type.displayName) && child.props.id
|
|
23
26
|
) as React.ReactElement<{ id: string }>;
|
|
27
|
+
|
|
28
|
+
const inputGroupRef = innerRef || React.useRef(null);
|
|
29
|
+
|
|
24
30
|
return (
|
|
25
|
-
<div className={css(styles.inputGroup, className)} {...props}>
|
|
31
|
+
<div ref={inputGroupRef} className={css(styles.inputGroup, className)} {...props}>
|
|
26
32
|
{idItem
|
|
27
33
|
? React.Children.map(children, (child: any) =>
|
|
28
34
|
formCtrls.includes(child.type.displayName)
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import styles from '@patternfly/react-styles/css/components/SearchInput/search-input';
|
|
3
2
|
import { Button } from '../Button';
|
|
4
3
|
import { ActionGroup, Form, FormGroup } from '../Form';
|
|
5
4
|
import { TextInput } from '../TextInput';
|
|
6
5
|
import { GenerateId, KEY_CODES } from '../../helpers';
|
|
7
6
|
import { SearchAttribute } from './SearchInput';
|
|
7
|
+
import { Panel, PanelMain, PanelMainBody } from '../Panel';
|
|
8
|
+
import { css } from '@patternfly/react-styles';
|
|
8
9
|
|
|
9
10
|
export interface AdvancedSearchMenuProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange'> {
|
|
11
|
+
/** Additional classes added to the Advanced search menu */
|
|
12
|
+
className?: string;
|
|
10
13
|
/** Value of the search input */
|
|
11
14
|
value?: string;
|
|
12
15
|
/** Ref of the div wrapping the whole search input **/
|
|
@@ -46,6 +49,7 @@ export interface AdvancedSearchMenuProps extends Omit<React.HTMLProps<HTMLDivEle
|
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
export const AdvancedSearchMenu: React.FunctionComponent<AdvancedSearchMenuProps> = ({
|
|
52
|
+
className,
|
|
49
53
|
parentRef,
|
|
50
54
|
parentInputRef,
|
|
51
55
|
value = '',
|
|
@@ -200,24 +204,26 @@ export const AdvancedSearchMenu: React.FunctionComponent<AdvancedSearchMenuProps
|
|
|
200
204
|
};
|
|
201
205
|
|
|
202
206
|
return isSearchMenuOpen ? (
|
|
203
|
-
<
|
|
204
|
-
<
|
|
205
|
-
<
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
<
|
|
210
|
-
{
|
|
211
|
-
|
|
212
|
-
{!!onClear && (
|
|
213
|
-
<Button variant="link" type="reset" onClick={onClear}>
|
|
214
|
-
{resetButtonLabel}
|
|
207
|
+
<Panel variant="raised" className={css(className)}>
|
|
208
|
+
<PanelMain>
|
|
209
|
+
<PanelMainBody>
|
|
210
|
+
<Form>
|
|
211
|
+
{buildFormGroups()}
|
|
212
|
+
{formAdditionalItems ? formAdditionalItems : null}
|
|
213
|
+
<ActionGroup>
|
|
214
|
+
<Button variant="primary" type="submit" onClick={onSearchHandler} isDisabled={!value}>
|
|
215
|
+
{submitSearchButtonLabel}
|
|
215
216
|
</Button>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
{!!onClear && (
|
|
218
|
+
<Button variant="link" type="reset" onClick={onClear}>
|
|
219
|
+
{resetButtonLabel}
|
|
220
|
+
</Button>
|
|
221
|
+
)}
|
|
222
|
+
</ActionGroup>
|
|
223
|
+
</Form>
|
|
224
|
+
</PanelMainBody>
|
|
225
|
+
</PanelMain>
|
|
226
|
+
</Panel>
|
|
221
227
|
) : null;
|
|
222
228
|
};
|
|
223
229
|
AdvancedSearchMenu.displayName = 'SearchInput';
|
|
@@ -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' }));
|