@patternfly/react-core 4.177.0 → 4.180.0
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 +41 -0
- package/dist/esm/components/Card/Card.d.ts +5 -7
- package/dist/esm/components/Card/Card.d.ts.map +1 -1
- package/dist/esm/components/Card/Card.js +14 -2
- package/dist/esm/components/Card/Card.js.map +1 -1
- package/dist/esm/components/DragDrop/Droppable.d.ts.map +1 -1
- package/dist/esm/components/DragDrop/Droppable.js +5 -1
- package/dist/esm/components/DragDrop/Droppable.js.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorTree.d.ts +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorTree.d.ts.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorTree.js +2 -1
- package/dist/esm/components/DualListSelector/DualListSelectorTree.js.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorTreeItem.d.ts +3 -1
- package/dist/esm/components/DualListSelector/DualListSelectorTreeItem.d.ts.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorTreeItem.js +24 -2
- package/dist/esm/components/DualListSelector/DualListSelectorTreeItem.js.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.d.ts +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.d.ts.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.js +2 -1
- package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
- package/dist/esm/components/Popover/Popover.d.ts.map +1 -1
- package/dist/esm/components/Popover/Popover.js +2 -22
- package/dist/esm/components/Popover/Popover.js.map +1 -1
- package/dist/js/components/Card/Card.d.ts +5 -7
- package/dist/js/components/Card/Card.d.ts.map +1 -1
- package/dist/js/components/Card/Card.js +14 -2
- package/dist/js/components/Card/Card.js.map +1 -1
- package/dist/js/components/DragDrop/Droppable.d.ts.map +1 -1
- package/dist/js/components/DragDrop/Droppable.js +5 -1
- package/dist/js/components/DragDrop/Droppable.js.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorTree.d.ts +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorTree.d.ts.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorTree.js +2 -1
- package/dist/js/components/DualListSelector/DualListSelectorTree.js.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorTreeItem.d.ts +3 -1
- package/dist/js/components/DualListSelector/DualListSelectorTreeItem.d.ts.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorTreeItem.js +24 -3
- package/dist/js/components/DualListSelector/DualListSelectorTreeItem.js.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.d.ts +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.d.ts.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.js +2 -1
- package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
- package/dist/js/components/Popover/Popover.d.ts.map +1 -1
- package/dist/js/components/Popover/Popover.js +2 -22
- package/dist/js/components/Popover/Popover.js.map +1 -1
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-Black.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-BlackItalic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-Bold.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-BoldItalic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-Italic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-Light.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-LightItalic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-Medium.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-MediumItalic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-Regular.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplayVF-updated-Italic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplayVF-updated.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-Bold.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-BoldItalic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-Italic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-Light.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-LightItalic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-Medium.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-MediumItalic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-Regular.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMonoVF-updated-Italic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMonoVF-updated.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-Bold.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-BoldItalic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-Italic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-Light.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-LightItalic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-Medium.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-MediumItalic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-Regular.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatTextVF-updated-Italic.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatTextVF-updated.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/modified/RedHatDisplayVF-updated-ItalicModified.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/modified/RedHatDisplayVFModified-updated.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/modified/RedHatTextVF-updated-ItalicModified.woff2 +0 -0
- package/dist/styles/assets/fonts/RedHatFont-updated/modified/RedHatTextVFModified-updated.woff2 +0 -0
- package/dist/styles/base-no-reset.css +121 -0
- package/dist/styles/base.css +121 -15
- package/dist/umd/react-core.css +183 -12
- package/dist/umd/react-core.js +58 -31
- package/dist/umd/react-core.min.css +183 -12
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +6 -6
- package/src/components/Card/Card.tsx +23 -17
- package/src/components/Card/__tests__/Card.test.tsx +8 -14
- package/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap +2 -12
- package/src/components/Card/examples/Card.md +230 -264
- package/src/components/DragDrop/Droppable.tsx +5 -1
- package/src/components/DragDrop/examples/DragDrop.md +2 -0
- package/src/components/DualListSelector/DualListSelectorTree.tsx +4 -2
- package/src/components/DualListSelector/DualListSelectorTreeItem.tsx +32 -1
- package/src/components/DualListSelector/__tests__/__snapshots__/DualListSelector.test.tsx.snap +3 -0
- package/src/components/DualListSelector/examples/ComposableTree.tsx +345 -0
- package/src/components/DualListSelector/examples/DualListSelector.md +5 -1
- package/src/components/MenuToggle/MenuToggle.tsx +5 -2
- package/src/components/MenuToggle/__tests__/MenuToggle.test.tsx +5 -0
- package/src/components/MenuToggle/__tests__/__snapshots__/MenuToggle.test.tsx.snap +59 -0
- package/src/components/MenuToggle/examples/MenuToggle.md +60 -67
- package/src/components/Popover/Popover.tsx +1 -19
- package/src/components/Popover/__tests__/Generated/__snapshots__/Popover.test.tsx.snap +0 -1
- package/src/components/Popover/__tests__/__snapshots__/Popover.test.tsx.snap +0 -4
- package/src/demos/Card/Card.md +47 -23
- package/src/demos/TextInputGroupDemo.md +8 -246
- package/src/demos/examples/TextInputGroup/AttributeValueFiltering.js +250 -0
- package/src/demos/examples/TextInputGroup/AutoCompleteSearch.js +230 -0
|
@@ -13,119 +13,112 @@ import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-ico
|
|
|
13
13
|
|
|
14
14
|
### Collapsed
|
|
15
15
|
|
|
16
|
-
```
|
|
16
|
+
```ts
|
|
17
17
|
import React from 'react';
|
|
18
18
|
import { MenuToggle } from '@patternfly/react-core';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return <MenuToggle>Collapsed</MenuToggle>;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
20
|
+
<MenuToggle>Collapsed</MenuToggle>
|
|
21
|
+
|
|
25
22
|
```
|
|
26
23
|
|
|
27
24
|
### Expanded
|
|
28
25
|
|
|
29
|
-
```
|
|
26
|
+
```ts
|
|
30
27
|
import React from 'react';
|
|
31
28
|
import { MenuToggle } from '@patternfly/react-core';
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return <MenuToggle isExpanded>Expanded</MenuToggle>;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
30
|
+
<MenuToggle isExpanded>Expanded</MenuToggle>;
|
|
31
|
+
|
|
38
32
|
```
|
|
39
33
|
|
|
40
34
|
### Disabled
|
|
41
35
|
|
|
42
|
-
```
|
|
36
|
+
```ts
|
|
43
37
|
import React from 'react';
|
|
44
38
|
import { MenuToggle } from '@patternfly/react-core';
|
|
45
39
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return <MenuToggle isDisabled>Disabled</MenuToggle>;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
40
|
+
<MenuToggle isDisabled>Disabled</MenuToggle>
|
|
41
|
+
|
|
51
42
|
```
|
|
52
43
|
|
|
53
44
|
### Icon
|
|
54
45
|
|
|
55
|
-
```
|
|
46
|
+
```ts
|
|
56
47
|
import React from 'react';
|
|
57
48
|
import { MenuToggle } from '@patternfly/react-core';
|
|
58
49
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
59
50
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return <MenuToggle icon={<CogIcon />}>Icon</MenuToggle>;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
51
|
+
<MenuToggle icon={<CogIcon />}>Icon</MenuToggle>;
|
|
52
|
+
|
|
65
53
|
```
|
|
66
54
|
|
|
67
55
|
### Count
|
|
68
56
|
|
|
69
|
-
```
|
|
57
|
+
```ts
|
|
70
58
|
import React from 'react';
|
|
71
59
|
import { MenuToggle, Badge } from '@patternfly/react-core';
|
|
72
60
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return <MenuToggle badge={<Badge>4 selected</Badge>}>Count</MenuToggle>;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
61
|
+
<MenuToggle badge={<Badge>4 selected</Badge>}>Count</MenuToggle>
|
|
62
|
+
|
|
78
63
|
```
|
|
79
64
|
|
|
80
65
|
### Primary
|
|
81
66
|
|
|
82
|
-
```
|
|
67
|
+
```ts
|
|
83
68
|
import React from 'react';
|
|
84
69
|
import { MenuToggle } from '@patternfly/react-core';
|
|
85
70
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
86
71
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
</MenuToggle>
|
|
101
|
-
</React.Fragment>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
72
|
+
<React.Fragment>
|
|
73
|
+
<MenuToggle variant="primary">Collapsed</MenuToggle>{' '}
|
|
74
|
+
<MenuToggle variant="primary" icon={<CogIcon />}>
|
|
75
|
+
Icon
|
|
76
|
+
</MenuToggle>{' '}
|
|
77
|
+
<MenuToggle variant="primary" isExpanded>
|
|
78
|
+
Expanded
|
|
79
|
+
</MenuToggle>{' '}
|
|
80
|
+
<MenuToggle variant="primary" isDisabled>
|
|
81
|
+
Disabled
|
|
82
|
+
</MenuToggle>
|
|
83
|
+
</React.Fragment>
|
|
84
|
+
|
|
105
85
|
```
|
|
106
86
|
|
|
107
87
|
### Plain
|
|
108
88
|
|
|
109
|
-
```
|
|
89
|
+
```ts
|
|
110
90
|
import React from 'react';
|
|
111
91
|
import { MenuToggle } from '@patternfly/react-core';
|
|
112
92
|
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
|
113
93
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
94
|
+
<React.Fragment>
|
|
95
|
+
<MenuToggle variant="plain" aria-label="plain kebab">
|
|
96
|
+
<EllipsisVIcon />
|
|
97
|
+
</MenuToggle>
|
|
98
|
+
<MenuToggle variant="plain" isExpanded aria-label="plain expanded kebab">
|
|
99
|
+
<EllipsisVIcon />
|
|
100
|
+
</MenuToggle>
|
|
101
|
+
<MenuToggle variant="plain" isDisabled aria-label="disabled kebab">
|
|
102
|
+
<EllipsisVIcon />
|
|
103
|
+
</MenuToggle>
|
|
104
|
+
</React.Fragment>
|
|
105
|
+
```
|
|
106
|
+
### Plain with text
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import React from 'react';
|
|
110
|
+
import { MenuToggle } from '@patternfly/react-core';
|
|
111
|
+
|
|
112
|
+
<React.Fragment>
|
|
113
|
+
<MenuToggle variant="plainText" isDisabled aria-label="Disabled plain menu toggle">
|
|
114
|
+
Disabled
|
|
115
|
+
</MenuToggle>
|
|
116
|
+
|
|
117
|
+
<MenuToggle variant="plainText" aria-label="Plain menu toggle">
|
|
118
|
+
Custom text
|
|
119
|
+
</MenuToggle>
|
|
120
|
+
<MenuToggle variant="plainText" isExpanded aria-label="Expanded plain menu toggle">
|
|
121
|
+
Custom text (expanded)
|
|
122
|
+
</MenuToggle>
|
|
123
|
+
</React.Fragment>
|
|
131
124
|
```
|
|
@@ -334,23 +334,6 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
|
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
};
|
|
337
|
-
const onTriggerEnter = (event: KeyboardEvent) => {
|
|
338
|
-
if (event.keyCode === KEY_CODES.ENTER) {
|
|
339
|
-
if (!visible) {
|
|
340
|
-
if (triggerManually) {
|
|
341
|
-
shouldOpen(show, event);
|
|
342
|
-
} else {
|
|
343
|
-
show(true);
|
|
344
|
-
}
|
|
345
|
-
} else {
|
|
346
|
-
if (triggerManually) {
|
|
347
|
-
shouldClose(null, hide, event);
|
|
348
|
-
} else {
|
|
349
|
-
hide();
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
337
|
const onTriggerClick = (event: MouseEvent) => {
|
|
355
338
|
if (triggerManually) {
|
|
356
339
|
if (visible) {
|
|
@@ -362,7 +345,7 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
|
|
|
362
345
|
if (visible) {
|
|
363
346
|
hide();
|
|
364
347
|
} else {
|
|
365
|
-
show();
|
|
348
|
+
show(true);
|
|
366
349
|
}
|
|
367
350
|
}
|
|
368
351
|
};
|
|
@@ -451,7 +434,6 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
|
|
|
451
434
|
distance={distance}
|
|
452
435
|
placement={position}
|
|
453
436
|
onTriggerClick={onTriggerClick}
|
|
454
|
-
onTriggerEnter={onTriggerEnter}
|
|
455
437
|
onDocumentClick={onDocumentClick}
|
|
456
438
|
onDocumentKeyDown={onDocumentKeyDown}
|
|
457
439
|
enableFlip={enableFlip}
|
|
@@ -27,7 +27,6 @@ exports[`popover can close from content (uncontrolled) 1`] = `
|
|
|
27
27
|
onDocumentClick={[Function]}
|
|
28
28
|
onDocumentKeyDown={[Function]}
|
|
29
29
|
onTriggerClick={[Function]}
|
|
30
|
-
onTriggerEnter={[Function]}
|
|
31
30
|
placement="top"
|
|
32
31
|
popper={
|
|
33
32
|
<FocusTrap
|
|
@@ -150,7 +149,6 @@ exports[`popover can have a custom minimum width 1`] = `
|
|
|
150
149
|
onDocumentClick={[Function]}
|
|
151
150
|
onDocumentKeyDown={[Function]}
|
|
152
151
|
onTriggerClick={[Function]}
|
|
153
|
-
onTriggerEnter={[Function]}
|
|
154
152
|
placement="top"
|
|
155
153
|
popper={
|
|
156
154
|
<FocusTrap
|
|
@@ -256,7 +254,6 @@ exports[`popover can specify position as object value 1`] = `
|
|
|
256
254
|
onDocumentClick={[Function]}
|
|
257
255
|
onDocumentKeyDown={[Function]}
|
|
258
256
|
onTriggerClick={[Function]}
|
|
259
|
-
onTriggerEnter={[Function]}
|
|
260
257
|
placement="right"
|
|
261
258
|
popper={
|
|
262
259
|
<FocusTrap
|
|
@@ -362,7 +359,6 @@ exports[`popover renders close-button, header and body 1`] = `
|
|
|
362
359
|
onDocumentClick={[Function]}
|
|
363
360
|
onDocumentKeyDown={[Function]}
|
|
364
361
|
onTriggerClick={[Function]}
|
|
365
|
-
onTriggerEnter={[Function]}
|
|
366
362
|
placement="top"
|
|
367
363
|
popper={
|
|
368
364
|
<FocusTrap
|
package/src/demos/Card/Card.md
CHANGED
|
@@ -86,8 +86,6 @@ class CardViewBasic extends React.Component {
|
|
|
86
86
|
constructor(props) {
|
|
87
87
|
super(props);
|
|
88
88
|
|
|
89
|
-
this.handleCheckboxClick = this.handleCheckboxClick.bind(this);
|
|
90
|
-
|
|
91
89
|
this.state = {
|
|
92
90
|
filters: {
|
|
93
91
|
products: []
|
|
@@ -199,6 +197,39 @@ class CardViewBasic extends React.Component {
|
|
|
199
197
|
});
|
|
200
198
|
}
|
|
201
199
|
};
|
|
200
|
+
|
|
201
|
+
this.onKeyDown = (event, productId) => {
|
|
202
|
+
console.log(productId);
|
|
203
|
+
if (event.target !== event.currentTarget) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if ([' ', 'Enter'].includes(event.key)) {
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
this.setState(prevState => {
|
|
209
|
+
return prevState.selectedItems.includes(productId*1) ?
|
|
210
|
+
{
|
|
211
|
+
selectedItems: [...prevState.selectedItems.filter(id => productId * 1 != id)],
|
|
212
|
+
areAllSelected: false
|
|
213
|
+
} : {
|
|
214
|
+
selectedItems: [...prevState.selectedItems, productId * 1],
|
|
215
|
+
areAllSelected: prevState.totalItemCount === prevState.selectedItems.length + 1
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
this.onClick = productId => {
|
|
222
|
+
this.setState(prevState => {
|
|
223
|
+
return prevState.selectedItems.includes(productId*1) ?
|
|
224
|
+
{
|
|
225
|
+
selectedItems: [...prevState.selectedItems.filter(id => productId * 1 != id)],
|
|
226
|
+
areAllSelected: false
|
|
227
|
+
} : {
|
|
228
|
+
selectedItems: [...prevState.selectedItems, productId * 1],
|
|
229
|
+
areAllSelected: prevState.totalItemCount === prevState.selectedItems.length + 1
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
};
|
|
202
233
|
}
|
|
203
234
|
|
|
204
235
|
selectedItems(e) {
|
|
@@ -294,24 +325,6 @@ class CardViewBasic extends React.Component {
|
|
|
294
325
|
return collection;
|
|
295
326
|
}
|
|
296
327
|
|
|
297
|
-
handleCheckboxClick(checked, e) {
|
|
298
|
-
const { value } = e.target;
|
|
299
|
-
const { totalItemCount } = this.state;
|
|
300
|
-
|
|
301
|
-
if (checked) {
|
|
302
|
-
const collection = this.getAllItems();
|
|
303
|
-
this.setState(prevState => ({
|
|
304
|
-
selectedItems: [...prevState.selectedItems, value * 1],
|
|
305
|
-
areAllSelected: totalItemCount === prevState.selectedItems.length + 1
|
|
306
|
-
}));
|
|
307
|
-
} else {
|
|
308
|
-
this.setState(prevState => ({
|
|
309
|
-
selectedItems: prevState.selectedItems.filter(item => item != value),
|
|
310
|
-
areAllSelected: false
|
|
311
|
-
}));
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
328
|
updateSelected() {
|
|
316
329
|
const { res, selectedItems } = this.state;
|
|
317
330
|
let rows = res.map(post => {
|
|
@@ -547,7 +560,11 @@ class CardViewBasic extends React.Component {
|
|
|
547
560
|
</PageSection>
|
|
548
561
|
<PageSection isFilled>
|
|
549
562
|
<Gallery hasGutter>
|
|
550
|
-
<Card
|
|
563
|
+
<Card
|
|
564
|
+
isSelectable
|
|
565
|
+
selectableVariant="raised"
|
|
566
|
+
isCompact
|
|
567
|
+
>
|
|
551
568
|
<Bullseye>
|
|
552
569
|
<EmptyState variant={EmptyStateVariant.xs}>
|
|
553
570
|
<EmptyStateIcon icon={PlusCircleIcon} />
|
|
@@ -561,7 +578,15 @@ class CardViewBasic extends React.Component {
|
|
|
561
578
|
</Bullseye>
|
|
562
579
|
</Card>
|
|
563
580
|
{filtered.map((product, key) => (
|
|
564
|
-
<Card
|
|
581
|
+
<Card
|
|
582
|
+
isSelectable
|
|
583
|
+
selectableVariant="raised"
|
|
584
|
+
isCompact
|
|
585
|
+
key={product.name}
|
|
586
|
+
onKeyDown={(e) => this.onKeyDown(e, product.id)}
|
|
587
|
+
onClick={() => this.onClick(product.id)}
|
|
588
|
+
isSelected={selectedItems.includes(product.id)}
|
|
589
|
+
>
|
|
565
590
|
<CardHeader>
|
|
566
591
|
<img src={icons[product.icon]} alt={`${product.name} icon`} style={{ maxWidth: '60px' }} />
|
|
567
592
|
<CardActions>
|
|
@@ -587,7 +612,6 @@ class CardViewBasic extends React.Component {
|
|
|
587
612
|
<Checkbox
|
|
588
613
|
checked={isChecked}
|
|
589
614
|
value={product.id}
|
|
590
|
-
onChange={this.handleCheckboxClick}
|
|
591
615
|
isChecked={selectedItems.includes(product.id)}
|
|
592
616
|
aria-label="card checkbox example"
|
|
593
617
|
id={`check-${product.id}`}
|
|
@@ -24,255 +24,17 @@ Additionally, attributes can be selected by typing the full (case sensitive) nam
|
|
|
24
24
|
|
|
25
25
|
Attributes can be deselected (returning you to attribute selection mode) by hitting `escape`, or by hitting `backspace` when the only text in the text input is the attribute.
|
|
26
26
|
|
|
27
|
-
```js
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
TextInputGroup,
|
|
31
|
-
TextInputGroupMain,
|
|
32
|
-
TextInputGroupUtilities,
|
|
33
|
-
Button,
|
|
34
|
-
Menu,
|
|
35
|
-
MenuContent,
|
|
36
|
-
MenuList,
|
|
37
|
-
MenuItem,
|
|
38
|
-
Popper,
|
|
39
|
-
Chip,
|
|
40
|
-
ChipGroup,
|
|
41
|
-
Divider
|
|
42
|
-
} from '@patternfly/react-core';
|
|
43
|
-
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
44
|
-
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
|
|
45
|
-
|
|
46
|
-
export const KeyValueFiltering = () => {
|
|
47
|
-
const [inputValue, setInputValue] = React.useState('');
|
|
48
|
-
const [selectedKey, setSelectedKey] = React.useState('');
|
|
49
|
-
const [menuIsOpen, setMenuIsOpen] = React.useState(false);
|
|
50
|
-
const [currentChips, setCurrentChips] = React.useState([]);
|
|
51
|
-
|
|
52
|
-
/** key and value data to be shown in the menu */
|
|
53
|
-
const data = {
|
|
54
|
-
Cluster: ['acmeqe-managed-1', 'local-cluster'],
|
|
55
|
-
Kind: ['Template', 'ReplicationController', 'ReplicaSet', 'Deployment'],
|
|
56
|
-
Label: ['release', 'environment', 'partition'],
|
|
57
|
-
Name: ['backup-1', 'backup-2', 'production-1', 'production-2', 'testing'],
|
|
58
|
-
Namespace: ['default', 'public'],
|
|
59
|
-
Status: ['running', 'idle', 'stopped']
|
|
60
|
-
};
|
|
61
|
-
const keyNames = ['Cluster', 'Kind', 'Label', 'Name', 'Namespace', 'Status'];
|
|
62
|
-
const [menuItemsText, setMenuItemsText] = React.useState(keyNames);
|
|
63
|
-
const [menuItems, setMenuItems] = React.useState([]);
|
|
64
|
-
|
|
65
|
-
/** refs used to detect when clicks occur inside vs outside of the textInputGroup and menu popper */
|
|
66
|
-
const menuRef = React.useRef();
|
|
67
|
-
const textInputGroupRef = React.useRef();
|
|
68
|
-
|
|
69
|
-
/** callback for updating the inputValue state in this component so that the input can be controlled */
|
|
70
|
-
const handleInputChange = (value, _event) => {
|
|
71
|
-
setInputValue(value);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/** callback for removing a chip from the chip selections */
|
|
75
|
-
const deleteChip = chipToDelete => {
|
|
76
|
-
const newChips = currentChips.filter(chip => !Object.is(chip, chipToDelete));
|
|
77
|
-
setCurrentChips(newChips);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/** reset state hooks associated with key selection */
|
|
81
|
-
const clearSelectedKey = () => {
|
|
82
|
-
setInputValue('');
|
|
83
|
-
setSelectedKey('');
|
|
84
|
-
setMenuItemsText(keyNames);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/** callback for clearing all selected chips, the text input, and any selected keys */
|
|
88
|
-
const clearChipsAndInput = () => {
|
|
89
|
-
setCurrentChips([]);
|
|
90
|
-
clearSelectedKey();
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
React.useEffect(() => {
|
|
94
|
-
/** in the menu only show items that include the text in the input */
|
|
95
|
-
const filteredMenuItems = menuItemsText
|
|
96
|
-
.filter(
|
|
97
|
-
item =>
|
|
98
|
-
!inputValue ||
|
|
99
|
-
item.toLowerCase().includes(
|
|
100
|
-
inputValue
|
|
101
|
-
.toString()
|
|
102
|
-
.slice(selectedKey.length && selectedKey.length + 2)
|
|
103
|
-
.toLowerCase()
|
|
104
|
-
)
|
|
105
|
-
)
|
|
106
|
-
.map((currentValue, index) => (
|
|
107
|
-
<MenuItem key={currentValue} itemId={index}>
|
|
108
|
-
{currentValue}
|
|
109
|
-
</MenuItem>
|
|
110
|
-
));
|
|
111
|
-
|
|
112
|
-
/** in the menu show a disabled "no result" when all menu items are filtered out */
|
|
113
|
-
if (filteredMenuItems.length === 0) {
|
|
114
|
-
const noResultItem = (
|
|
115
|
-
<MenuItem isDisabled key="no result">
|
|
116
|
-
No results found
|
|
117
|
-
</MenuItem>
|
|
118
|
-
);
|
|
119
|
-
setMenuItems([noResultItem]);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/** determine the menu heading text based on key selection; or lack thereof */
|
|
124
|
-
const headingItem = (
|
|
125
|
-
<MenuItem isDisabled key="heading">
|
|
126
|
-
{selectedKey.length ? `${selectedKey} values` : 'Attributes'}
|
|
127
|
-
</MenuItem>
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
const divider = <Divider key="divider" />;
|
|
131
|
-
|
|
132
|
-
setMenuItems([headingItem, divider, ...filteredMenuItems]);
|
|
133
|
-
}, [inputValue]);
|
|
134
|
-
|
|
135
|
-
/** add selected key/value pair as a chip in the chip group */
|
|
136
|
-
const selectValue = selectedValue => {
|
|
137
|
-
setCurrentChips([...currentChips, `${selectedKey}: ${selectedValue}`]);
|
|
138
|
-
clearSelectedKey();
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
/** update the input to show the selected key and the menu to show the values associated with that specific key */
|
|
142
|
-
const selectKey = selectedText => {
|
|
143
|
-
setInputValue(`${selectedText}: `);
|
|
144
|
-
setSelectedKey(selectedText);
|
|
145
|
-
setMenuItemsText(data[selectedText]);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const handleEnter = () => {
|
|
149
|
-
/** do nothing if the menu contains no real results */
|
|
150
|
-
if (menuItems.length === 1) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/** perform the appropriate action based on key selection state */
|
|
155
|
-
if (selectedKey.length) {
|
|
156
|
-
selectValue(menuItems[2].props.children);
|
|
157
|
-
} else {
|
|
158
|
-
selectKey(menuItems[2].props.children);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
/** allow the user to backspace at the selected key name to drop the currently selected key */
|
|
163
|
-
const handleBackspace = () => {
|
|
164
|
-
if (selectedKey.length && inputValue === `${selectedKey}: `) {
|
|
165
|
-
clearSelectedKey();
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
/** allow the user to select a key by simply typing it and entering a colon, exact (case sensitive) matches only */
|
|
170
|
-
const handleColon = () => {
|
|
171
|
-
if (!selectedKey.length && keyNames.includes(inputValue)) {
|
|
172
|
-
selectKey(inputValue);
|
|
173
|
-
event.preventDefault();
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
/** allow the user to focus on the menu and navigate using the arrow keys */
|
|
178
|
-
const handleArrowKey = () => {
|
|
179
|
-
if (menuRef.current) {
|
|
180
|
-
const firstElement = menuRef.current.querySelector('li > button:not(:disabled)');
|
|
181
|
-
firstElement && firstElement.focus();
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
/** enable keyboard only usage */
|
|
186
|
-
const handleTextInputKeyDown = event => {
|
|
187
|
-
switch (event.key) {
|
|
188
|
-
case 'Enter':
|
|
189
|
-
handleEnter();
|
|
190
|
-
break;
|
|
191
|
-
case 'Escape':
|
|
192
|
-
clearSelectedKey();
|
|
193
|
-
break;
|
|
194
|
-
case 'Backspace':
|
|
195
|
-
handleBackspace();
|
|
196
|
-
break;
|
|
197
|
-
case ':':
|
|
198
|
-
handleColon();
|
|
199
|
-
break;
|
|
200
|
-
case 'ArrowUp':
|
|
201
|
-
case 'ArrowDown':
|
|
202
|
-
handleArrowKey();
|
|
203
|
-
break;
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
/** perform the proper key or value selection when a menu item is selected */
|
|
208
|
-
const onSelect = (event, _itemId) => {
|
|
209
|
-
const selectedText = event.target.innerText;
|
|
210
|
-
|
|
211
|
-
if (selectedKey.length) {
|
|
212
|
-
selectValue(selectedText);
|
|
213
|
-
} else {
|
|
214
|
-
selectKey(selectedText);
|
|
215
|
-
}
|
|
216
|
-
event.stopPropagation();
|
|
217
|
-
textInputGroupRef.current.querySelector('input').focus();
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
/** close the menu when a click occurs outside of the menu or text input group */
|
|
221
|
-
const handleClick = event => {
|
|
222
|
-
if (
|
|
223
|
-
menuRef.current &&
|
|
224
|
-
!menuRef.current.contains(event.target) &&
|
|
225
|
-
!textInputGroupRef.current.contains(event.target)
|
|
226
|
-
) {
|
|
227
|
-
setMenuIsOpen(false);
|
|
228
|
-
}
|
|
229
|
-
};
|
|
27
|
+
```js file="./examples/TextInputGroup/AttributeValueFiltering.js"
|
|
28
|
+
```
|
|
29
|
+
### Auto-complete search
|
|
230
30
|
|
|
231
|
-
|
|
232
|
-
const showSearchIcon = !currentChips.length;
|
|
31
|
+
This demo showcases a search input with suggestions, which filters possible selections based on the text you've entered. Unlike the attribute-value filtering demo, it allows creation of new chip items when the text entered is not available in the list of suggestions.
|
|
233
32
|
|
|
234
|
-
|
|
235
|
-
const showClearButton = inputValue || !!currentChips.length;
|
|
33
|
+
The current text in the input can be converted to a chip at any time by hitting `enter`. Auto-complete suggestions can be chosen by clicking the corresponding entry in the menu, or by navigating to an entry using the up/down arrow keys and selecting it with `enter`.
|
|
236
34
|
|
|
237
|
-
|
|
238
|
-
<div ref={textInputGroupRef}>
|
|
239
|
-
<TextInputGroup>
|
|
240
|
-
<TextInputGroupMain
|
|
241
|
-
icon={showSearchIcon && <SearchIcon />}
|
|
242
|
-
value={inputValue}
|
|
243
|
-
onChange={handleInputChange}
|
|
244
|
-
onFocus={() => setMenuIsOpen(true)}
|
|
245
|
-
onKeyDown={handleTextInputKeyDown}
|
|
246
|
-
>
|
|
247
|
-
<ChipGroup>
|
|
248
|
-
{currentChips.map(currentChip => (
|
|
249
|
-
<Chip key={currentChip} onClick={() => deleteChip(currentChip)}>
|
|
250
|
-
{currentChip}
|
|
251
|
-
</Chip>
|
|
252
|
-
))}
|
|
253
|
-
</ChipGroup>
|
|
254
|
-
</TextInputGroupMain>
|
|
255
|
-
<TextInputGroupUtilities>
|
|
256
|
-
{showClearButton && (
|
|
257
|
-
<Button variant="plain" onClick={clearChipsAndInput} aria-label="Clear button and input">
|
|
258
|
-
<TimesIcon />
|
|
259
|
-
</Button>
|
|
260
|
-
)}
|
|
261
|
-
</TextInputGroupUtilities>
|
|
262
|
-
</TextInputGroup>
|
|
263
|
-
</div>
|
|
264
|
-
);
|
|
35
|
+
Hitting `escape` while focused on the input or menu will close the menu, and the menu will reopen when text is entered.
|
|
265
36
|
|
|
266
|
-
|
|
267
|
-
<div ref={menuRef}>
|
|
268
|
-
<Menu onSelect={onSelect}>
|
|
269
|
-
<MenuContent>
|
|
270
|
-
<MenuList>{menuItems}</MenuList>
|
|
271
|
-
</MenuContent>
|
|
272
|
-
</Menu>
|
|
273
|
-
</div>
|
|
274
|
-
);
|
|
37
|
+
When only one item remains in the suggestion list, tab can be used to auto-complete the typing of that item.
|
|
275
38
|
|
|
276
|
-
|
|
277
|
-
};
|
|
39
|
+
```js file="./examples/TextInputGroup/AutoCompleteSearch.js"
|
|
278
40
|
```
|