@patternfly/react-core 4.232.10 → 4.232.11
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 +8 -0
- package/dist/umd/react-core.css +651 -651
- package/package.json +5 -5
- package/src/components/SearchInput/examples/SearchInput.md +6 -223
- package/src/components/SearchInput/examples/SearchInputAdvanced.tsx +56 -0
- package/src/components/SearchInput/examples/SearchInputBasic.tsx +12 -0
- package/src/components/SearchInput/examples/SearchInputFocusSearch.tsx +14 -0
- package/src/components/SearchInput/examples/SearchInputWithNavigableOptions.tsx +43 -0
- package/src/components/SearchInput/examples/SearchInputWithResultCount.tsx +27 -0
- package/src/components/SearchInput/examples/SearchInputWithSubmitButton.tsx +16 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.232.
|
|
3
|
+
"version": "4.232.11",
|
|
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",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"generate": "node scripts/copyStyles.js"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@patternfly/react-icons": "^4.83.
|
|
54
|
-
"@patternfly/react-styles": "^4.82.
|
|
55
|
-
"@patternfly/react-tokens": "^4.84.
|
|
53
|
+
"@patternfly/react-icons": "^4.83.11",
|
|
54
|
+
"@patternfly/react-styles": "^4.82.11",
|
|
55
|
+
"@patternfly/react-tokens": "^4.84.11",
|
|
56
56
|
"focus-trap": "6.9.2",
|
|
57
57
|
"react-dropzone": "9.0.0",
|
|
58
58
|
"tippy.js": "5.1.2",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"react": "^16.8.0 || ^17.0.0",
|
|
77
77
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "3b4fe0a85d88aa9616d7a6768d187d6fc87abb32"
|
|
80
80
|
}
|
|
@@ -6,193 +6,33 @@ propComponents: ['SearchInput', 'SearchAttribute']
|
|
|
6
6
|
beta: true
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
import { SearchInput } from '@patternfly/react-core';
|
|
10
9
|
import { ExternalLinkSquareAltIcon } from '@patternfly/react-icons';
|
|
11
10
|
|
|
12
11
|
## Examples
|
|
13
12
|
|
|
14
13
|
### Basic
|
|
15
14
|
|
|
16
|
-
```
|
|
17
|
-
import React from 'react';
|
|
18
|
-
import { SearchInput } from '@patternfly/react-core';
|
|
19
|
-
|
|
20
|
-
class BasicSearchInput extends React.Component {
|
|
21
|
-
constructor(props) {
|
|
22
|
-
super(props);
|
|
23
|
-
this.state = {
|
|
24
|
-
value: ''
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
this.onChange = (value, event) => {
|
|
28
|
-
this.setState({
|
|
29
|
-
value: value
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
render() {
|
|
35
|
-
return (
|
|
36
|
-
<SearchInput
|
|
37
|
-
placeholder="Find by name"
|
|
38
|
-
value={this.state.value}
|
|
39
|
-
onChange={this.onChange}
|
|
40
|
-
onClear={evt => this.onChange('', evt)}
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
15
|
+
```ts file='./SearchInputBasic.tsx'
|
|
45
16
|
```
|
|
46
17
|
|
|
47
18
|
### Match with result count
|
|
48
19
|
|
|
49
|
-
```
|
|
50
|
-
import React from 'react';
|
|
51
|
-
import { SearchInput } from '@patternfly/react-core';
|
|
52
|
-
|
|
53
|
-
class SearchInputWithResultCount extends React.Component {
|
|
54
|
-
constructor(props) {
|
|
55
|
-
super(props);
|
|
56
|
-
this.state = {
|
|
57
|
-
value: '',
|
|
58
|
-
resultsCount: 0
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
this.onChange = (value, event) => {
|
|
62
|
-
this.setState({
|
|
63
|
-
value: value,
|
|
64
|
-
resultsCount: 3
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
this.onClear = event => {
|
|
69
|
-
this.setState({
|
|
70
|
-
value: '',
|
|
71
|
-
resultsCount: 0
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
render() {
|
|
77
|
-
return (
|
|
78
|
-
<SearchInput
|
|
79
|
-
placeholder="Find by name"
|
|
80
|
-
value={this.state.value}
|
|
81
|
-
onChange={this.onChange}
|
|
82
|
-
onClear={this.onClear}
|
|
83
|
-
resultsCount={this.state.resultsCount}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
20
|
+
```ts file='./SearchInputWithResultCount.tsx'
|
|
88
21
|
```
|
|
89
22
|
|
|
90
23
|
### Match with navigable options
|
|
91
24
|
|
|
92
|
-
```
|
|
93
|
-
import React from 'react';
|
|
94
|
-
import { SearchInput } from '@patternfly/react-core';
|
|
95
|
-
|
|
96
|
-
class SearchInputWithNavigableOptions extends React.Component {
|
|
97
|
-
constructor(props) {
|
|
98
|
-
super(props);
|
|
99
|
-
this.state = {
|
|
100
|
-
value: '',
|
|
101
|
-
resultsCount: 0,
|
|
102
|
-
currentResult: 1,
|
|
103
|
-
isPreviousNavigationButtonDisabled: false,
|
|
104
|
-
isNextNavigationButtonDisabled: false
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
this.onChange = (value, event) => {
|
|
108
|
-
this.setState({
|
|
109
|
-
value: value,
|
|
110
|
-
resultsCount: 3
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
this.onClear = event => {
|
|
115
|
-
this.setState({
|
|
116
|
-
value: '',
|
|
117
|
-
resultsCount: 0,
|
|
118
|
-
currentResult: 1
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
this.onNext = event => {
|
|
123
|
-
this.setState(prevState => {
|
|
124
|
-
const newCurrentResult = prevState.currentResult + 1;
|
|
125
|
-
return {
|
|
126
|
-
currentResult: newCurrentResult <= prevState.resultsCount ? newCurrentResult : prevState.resultsCount
|
|
127
|
-
};
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
this.onPrevious = event => {
|
|
132
|
-
this.setState(prevState => {
|
|
133
|
-
const newCurrentResult = prevState.currentResult - 1;
|
|
134
|
-
return {
|
|
135
|
-
currentResult: newCurrentResult > 0 ? newCurrentResult : 1
|
|
136
|
-
};
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
render() {
|
|
141
|
-
return (
|
|
142
|
-
<SearchInput
|
|
143
|
-
placeholder="Find by name"
|
|
144
|
-
value={this.state.value}
|
|
145
|
-
onChange={this.onChange}
|
|
146
|
-
onClear={this.onClear}
|
|
147
|
-
isNextNavigationButtonDisabled={this.state.currentResult === 3}
|
|
148
|
-
isPreviousNavigationButtonDisabled={this.state.currentResult === 1}
|
|
149
|
-
resultsCount={`${this.state.currentResult} / ${this.state.resultsCount}`}
|
|
150
|
-
onNextClick={this.onNext}
|
|
151
|
-
onPreviousClick={this.onPrevious}
|
|
152
|
-
/>
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
25
|
+
```ts file='./SearchInputWithNavigableOptions.tsx'
|
|
156
26
|
```
|
|
157
27
|
|
|
158
28
|
### With submit button
|
|
159
29
|
|
|
160
|
-
```
|
|
161
|
-
import React from 'react';
|
|
162
|
-
import { SearchInput } from '@patternfly/react-core';
|
|
163
|
-
|
|
164
|
-
SubmitButtonSearchInput = () => {
|
|
165
|
-
const [value, setValue] = React.useState('');
|
|
166
|
-
|
|
167
|
-
return (
|
|
168
|
-
<SearchInput
|
|
169
|
-
placeholder='Find by name'
|
|
170
|
-
value={value}
|
|
171
|
-
onChange={setValue}
|
|
172
|
-
onSearch={setValue}
|
|
173
|
-
onClear={() => setValue('')}
|
|
174
|
-
/>
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
|
|
30
|
+
```ts file='./SearchInputWithSubmitButton.tsx'
|
|
178
31
|
```
|
|
179
32
|
|
|
180
33
|
### Focus search input using ref
|
|
181
34
|
|
|
182
|
-
```
|
|
183
|
-
import React from 'react';
|
|
184
|
-
import { SearchInput, Button } from '@patternfly/react-core';
|
|
185
|
-
|
|
186
|
-
TextInputSelectAll = () => {
|
|
187
|
-
const [value, setValue] = React.useState('');
|
|
188
|
-
const ref = React.useRef(null);
|
|
189
|
-
return (
|
|
190
|
-
<React.Fragment>
|
|
191
|
-
<SearchInput ref={ref} value={value} onChange={setValue} onClear={() => setValue('')} />
|
|
192
|
-
<Button onClick={() => ref.current && ref.current.focus()}>Focus on the search input</Button>
|
|
193
|
-
</React.Fragment>
|
|
194
|
-
);
|
|
195
|
-
};
|
|
35
|
+
```ts file='./SearchInputFocusSearch.tsx'
|
|
196
36
|
```
|
|
197
37
|
|
|
198
38
|
### Advanced
|
|
@@ -203,62 +43,5 @@ the following example. The search input component can also be used as a composab
|
|
|
203
43
|
or other elements to build a completely custom advanced search form. This feature is demonstrated
|
|
204
44
|
in the search input's <a href="/components/search-input/react-demos">react demos</a>.
|
|
205
45
|
|
|
206
|
-
```
|
|
207
|
-
import React from 'react';
|
|
208
|
-
import { Button, Checkbox, FormGroup, SearchInput } from '@patternfly/react-core';
|
|
209
|
-
import ExternalLinkSquareAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-square-alt-icon';
|
|
210
|
-
|
|
211
|
-
AdvancedSearchInput = () => {
|
|
212
|
-
const [value, setValue] = React.useState('username:player firstname:john');
|
|
213
|
-
const [useEqualsAsDelimiter, setUseEqualsAsDelimiter] = React.useState(false);
|
|
214
|
-
const [useCustomFooter, setUseCustomFooter] = React.useState(false);
|
|
215
|
-
|
|
216
|
-
const toggleDelimiter = checked => {
|
|
217
|
-
const newValue = value.replace(/:|=/g, checked ? '=' : ':');
|
|
218
|
-
setUseEqualsAsDelimiter(checked);
|
|
219
|
-
setValue(newValue);
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
return (
|
|
223
|
-
<>
|
|
224
|
-
<Checkbox
|
|
225
|
-
label="Use equal sign as search attribute delimiter"
|
|
226
|
-
isChecked={useEqualsAsDelimiter}
|
|
227
|
-
onChange={toggleDelimiter}
|
|
228
|
-
aria-label="change delimiter checkbox"
|
|
229
|
-
id="toggle-delimiter"
|
|
230
|
-
name="toggle-delimiter"
|
|
231
|
-
/>
|
|
232
|
-
<Checkbox
|
|
233
|
-
label="Add custom footer element after the attributes in the menu"
|
|
234
|
-
isChecked={useCustomFooter}
|
|
235
|
-
onChange={value => setUseCustomFooter(value)}
|
|
236
|
-
aria-label="change use custom footer checkbox"
|
|
237
|
-
id="toggle-custom-footer"
|
|
238
|
-
name="toggle-custom-footer"
|
|
239
|
-
/>
|
|
240
|
-
<br />
|
|
241
|
-
<SearchInput
|
|
242
|
-
attributes={[
|
|
243
|
-
{ attr: 'username', display: 'Username' },
|
|
244
|
-
{ attr: 'firstname', display: 'First name' }
|
|
245
|
-
]}
|
|
246
|
-
advancedSearchDelimiter={useEqualsAsDelimiter ? '=' : ':'}
|
|
247
|
-
value={value}
|
|
248
|
-
onChange={setValue}
|
|
249
|
-
onSearch={setValue}
|
|
250
|
-
onClear={() => setValue('')}
|
|
251
|
-
formAdditionalItems={
|
|
252
|
-
useCustomFooter ? (
|
|
253
|
-
<FormGroup>
|
|
254
|
-
<Button variant="link" isInline icon={<ExternalLinkSquareAltIcon />} iconPosition="right">
|
|
255
|
-
Link
|
|
256
|
-
</Button>
|
|
257
|
-
</FormGroup>
|
|
258
|
-
) : null
|
|
259
|
-
}
|
|
260
|
-
/>
|
|
261
|
-
</>
|
|
262
|
-
);
|
|
263
|
-
};
|
|
46
|
+
```ts file='./SearchInputAdvanced.tsx'
|
|
264
47
|
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, Checkbox, FormGroup, SearchInput } from '@patternfly/react-core';
|
|
3
|
+
import ExternalLinkSquareAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-square-alt-icon';
|
|
4
|
+
|
|
5
|
+
export const SearchInputAdvanced: React.FunctionComponent = () => {
|
|
6
|
+
const [value, setValue] = React.useState('username:player firstname:john');
|
|
7
|
+
const [useEqualsAsDelimiter, setUseEqualsAsDelimiter] = React.useState(false);
|
|
8
|
+
const [useCustomFooter, setUseCustomFooter] = React.useState(false);
|
|
9
|
+
|
|
10
|
+
const toggleDelimiter = (checked: boolean) => {
|
|
11
|
+
setValue(value.replace(/:|=/g, checked ? '=' : ':'));
|
|
12
|
+
setUseEqualsAsDelimiter(checked);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<Checkbox
|
|
18
|
+
label="Use equal sign as search attribute delimiter"
|
|
19
|
+
isChecked={useEqualsAsDelimiter}
|
|
20
|
+
onChange={toggleDelimiter}
|
|
21
|
+
aria-label="change delimiter checkbox"
|
|
22
|
+
id="toggle-delimiter"
|
|
23
|
+
name="toggle-delimiter"
|
|
24
|
+
/>
|
|
25
|
+
<Checkbox
|
|
26
|
+
label="Add custom footer element after the attributes in the menu"
|
|
27
|
+
isChecked={useCustomFooter}
|
|
28
|
+
onChange={value => setUseCustomFooter(value)}
|
|
29
|
+
aria-label="change use custom footer checkbox"
|
|
30
|
+
id="toggle-custom-footer"
|
|
31
|
+
name="toggle-custom-footer"
|
|
32
|
+
/>
|
|
33
|
+
<br />
|
|
34
|
+
<SearchInput
|
|
35
|
+
attributes={[
|
|
36
|
+
{ attr: 'username', display: 'Username' },
|
|
37
|
+
{ attr: 'firstname', display: 'First name' }
|
|
38
|
+
]}
|
|
39
|
+
advancedSearchDelimiter={useEqualsAsDelimiter ? '=' : ':'}
|
|
40
|
+
value={value}
|
|
41
|
+
onChange={setValue}
|
|
42
|
+
onSearch={setValue}
|
|
43
|
+
onClear={() => setValue('')}
|
|
44
|
+
formAdditionalItems={
|
|
45
|
+
useCustomFooter ? (
|
|
46
|
+
<FormGroup>
|
|
47
|
+
<Button variant="link" isInline icon={<ExternalLinkSquareAltIcon />} iconPosition="right">
|
|
48
|
+
Link
|
|
49
|
+
</Button>
|
|
50
|
+
</FormGroup>
|
|
51
|
+
) : null
|
|
52
|
+
}
|
|
53
|
+
/>
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SearchInput } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const SearchInputBasic: React.FunctionComponent = () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
|
|
7
|
+
const onChange = (value: string) => {
|
|
8
|
+
setValue(value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return <SearchInput placeholder="Find by name" value={value} onChange={onChange} onClear={() => onChange('')} />;
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SearchInput, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const SearchInputFocusSearch: React.FunctionComponent = () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
const ref: React.MutableRefObject<HTMLInputElement | null> = React.useRef(null);
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<SearchInput ref={ref} value={value} onChange={setValue} onClear={() => setValue('')} />
|
|
11
|
+
<Button onClick={() => ref.current && ref.current.focus()}>Focus on the search input</Button>
|
|
12
|
+
</>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SearchInput } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const SearchInputWithNavigableOptions: React.FunctionComponent = () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
const [resultsCount, setResultsCount] = React.useState(0);
|
|
7
|
+
const [currentResult, setCurrentResult] = React.useState(1);
|
|
8
|
+
|
|
9
|
+
const onChange = (value: string) => {
|
|
10
|
+
setValue(value);
|
|
11
|
+
setResultsCount(3);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const onClear = () => {
|
|
15
|
+
setValue('');
|
|
16
|
+
setResultsCount(0);
|
|
17
|
+
setCurrentResult(1);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const onNext = () => {
|
|
21
|
+
const newCurrentResult = currentResult + 1;
|
|
22
|
+
setCurrentResult(newCurrentResult > resultsCount ? resultsCount : newCurrentResult);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const onPrevious = () => {
|
|
26
|
+
const newCurrentResult = currentResult - 1;
|
|
27
|
+
setCurrentResult(newCurrentResult > 0 ? newCurrentResult : 1);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<SearchInput
|
|
32
|
+
placeholder="Find by name"
|
|
33
|
+
value={value}
|
|
34
|
+
onChange={onChange}
|
|
35
|
+
onClear={onClear}
|
|
36
|
+
isNextNavigationButtonDisabled={currentResult === 3}
|
|
37
|
+
isPreviousNavigationButtonDisabled={currentResult === 1}
|
|
38
|
+
resultsCount={`${currentResult} / ${resultsCount}`}
|
|
39
|
+
onNextClick={onNext}
|
|
40
|
+
onPreviousClick={onPrevious}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SearchInput } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const SearchInputWithResultCount: React.FunctionComponent = () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
const [resultsCount, setResultsCount] = React.useState(0);
|
|
7
|
+
|
|
8
|
+
const onChange = (value: string) => {
|
|
9
|
+
setValue(value);
|
|
10
|
+
setResultsCount(3);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const onClear = () => {
|
|
14
|
+
setValue('');
|
|
15
|
+
setResultsCount(0);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<SearchInput
|
|
20
|
+
placeholder="Find by name"
|
|
21
|
+
value={value}
|
|
22
|
+
onChange={onChange}
|
|
23
|
+
onClear={onClear}
|
|
24
|
+
resultsCount={resultsCount}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SearchInput } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const SearchInputWithSubmitButton: React.FunctionComponent = () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<SearchInput
|
|
9
|
+
placeholder="Find by name"
|
|
10
|
+
value={value}
|
|
11
|
+
onChange={setValue}
|
|
12
|
+
onSearch={setValue}
|
|
13
|
+
onClear={() => setValue('')}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
};
|