@patternfly/react-core 4.265.1 → 4.265.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 +11 -0
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.js +5 -4
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.js +23 -3
- package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/js/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
- package/dist/js/components/SearchInput/AdvancedSearchMenu.js +5 -4
- package/dist/js/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
- package/dist/js/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/js/components/SearchInput/SearchInput.js +23 -3
- package/dist/js/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/umd/react-core.min.css +108 -108
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +2 -2
- package/src/components/SearchInput/AdvancedSearchMenu.tsx +7 -4
- package/src/components/SearchInput/SearchInput.tsx +26 -3
- package/src/components/SearchInput/examples/SearchInput.md +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.265.
|
|
3
|
+
"version": "4.265.2",
|
|
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",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"react": "^16.8 || ^17 || ^18",
|
|
78
78
|
"react-dom": "^16.8 || ^17 || ^18"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "16dc61cc8c2e8ee43522c388c638290d34bbb20b"
|
|
81
81
|
}
|
|
@@ -133,21 +133,24 @@ export const AdvancedSearchMenu: React.FunctionComponent<AdvancedSearchMenuProps
|
|
|
133
133
|
|
|
134
134
|
const handleValueChange = (attribute: string, newValue: string, event: React.FormEvent<HTMLInputElement>) => {
|
|
135
135
|
const newMap = getAttrValueMap();
|
|
136
|
+
|
|
136
137
|
newMap[attribute] = newValue;
|
|
137
138
|
let updatedValue = '';
|
|
138
139
|
Object.entries(newMap).forEach(([k, v]) => {
|
|
139
140
|
if (v.trim() !== '') {
|
|
141
|
+
/* Wrap the value in quotes if it contains spaces */
|
|
142
|
+
const quoteWrappedValue = v.includes(' ') ? `'${v.replace(/(^'|'$)/g, '')}'` : v;
|
|
143
|
+
|
|
140
144
|
if (k !== 'haswords') {
|
|
141
|
-
updatedValue = `${updatedValue} ${k}${advancedSearchDelimiter}${
|
|
145
|
+
updatedValue = `${updatedValue} ${k}${advancedSearchDelimiter}${quoteWrappedValue}`;
|
|
142
146
|
} else {
|
|
143
|
-
updatedValue = `${updatedValue} ${
|
|
147
|
+
updatedValue = `${updatedValue} ${quoteWrappedValue}`;
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
150
|
});
|
|
147
|
-
updatedValue = updatedValue.replace(/^\s+/g, '');
|
|
148
151
|
|
|
149
152
|
if (onChange) {
|
|
150
|
-
onChange(updatedValue, event);
|
|
153
|
+
onChange(updatedValue.replace(/^\s+/g, ''), event);
|
|
151
154
|
}
|
|
152
155
|
};
|
|
153
156
|
|
|
@@ -229,13 +229,36 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
|
|
|
229
229
|
setIsSearchMenuOpen(false);
|
|
230
230
|
};
|
|
231
231
|
|
|
232
|
+
const splitStringExceptInQuotes = (str: string) => {
|
|
233
|
+
let quoteType: string;
|
|
234
|
+
|
|
235
|
+
return str.match(/\\?.|^$/g).reduce(
|
|
236
|
+
(p: any, c: string) => {
|
|
237
|
+
if (c === "'" || c === '"') {
|
|
238
|
+
if (!quoteType) {
|
|
239
|
+
quoteType = c;
|
|
240
|
+
}
|
|
241
|
+
if (c === quoteType) {
|
|
242
|
+
p.quote = !p.quote;
|
|
243
|
+
}
|
|
244
|
+
} else if (!p.quote && c === ' ') {
|
|
245
|
+
p.a.push('');
|
|
246
|
+
} else {
|
|
247
|
+
p.a[p.a.length - 1] += c.replace(/\\(.)/, '$1');
|
|
248
|
+
}
|
|
249
|
+
return p;
|
|
250
|
+
},
|
|
251
|
+
{ a: [''] }
|
|
252
|
+
).a;
|
|
253
|
+
};
|
|
254
|
+
|
|
232
255
|
const getAttrValueMap = () => {
|
|
233
256
|
const attrValue: { [key: string]: string } = {};
|
|
234
|
-
const pairs = searchValue
|
|
235
|
-
pairs.map(pair => {
|
|
257
|
+
const pairs = splitStringExceptInQuotes(searchValue);
|
|
258
|
+
pairs.map((pair: string) => {
|
|
236
259
|
const splitPair = pair.split(advancedSearchDelimiter);
|
|
237
260
|
if (splitPair.length === 2) {
|
|
238
|
-
attrValue[splitPair[0]] = splitPair[1];
|
|
261
|
+
attrValue[splitPair[0]] = splitPair[1].replace(/(^'|'$)/g, '');
|
|
239
262
|
} else if (splitPair.length === 1) {
|
|
240
263
|
attrValue.haswords = attrValue.hasOwnProperty('haswords')
|
|
241
264
|
? `${attrValue.haswords} ${splitPair[0]}`
|
|
@@ -48,5 +48,9 @@ the following example. The search input component can also be used as a composab
|
|
|
48
48
|
or other elements to build a completely custom advanced search form. This feature is demonstrated
|
|
49
49
|
in the search input's <a href="/components/search-input/react-demos">react demos</a>.
|
|
50
50
|
|
|
51
|
+
The values used in the attribute-value form fields may contain spaces. The values containing spaces
|
|
52
|
+
should be wrapped with quotes inside the summary search string in the input field. If the latter is
|
|
53
|
+
autogenerated from the individual fields the quotes will be autoplaced.
|
|
54
|
+
|
|
51
55
|
```ts file='./SearchInputAdvanced.tsx'
|
|
52
56
|
```
|