@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.
Files changed (110) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/esm/components/Card/Card.d.ts +5 -7
  3. package/dist/esm/components/Card/Card.d.ts.map +1 -1
  4. package/dist/esm/components/Card/Card.js +14 -2
  5. package/dist/esm/components/Card/Card.js.map +1 -1
  6. package/dist/esm/components/DragDrop/Droppable.d.ts.map +1 -1
  7. package/dist/esm/components/DragDrop/Droppable.js +5 -1
  8. package/dist/esm/components/DragDrop/Droppable.js.map +1 -1
  9. package/dist/esm/components/DualListSelector/DualListSelectorTree.d.ts +1 -1
  10. package/dist/esm/components/DualListSelector/DualListSelectorTree.d.ts.map +1 -1
  11. package/dist/esm/components/DualListSelector/DualListSelectorTree.js +2 -1
  12. package/dist/esm/components/DualListSelector/DualListSelectorTree.js.map +1 -1
  13. package/dist/esm/components/DualListSelector/DualListSelectorTreeItem.d.ts +3 -1
  14. package/dist/esm/components/DualListSelector/DualListSelectorTreeItem.d.ts.map +1 -1
  15. package/dist/esm/components/DualListSelector/DualListSelectorTreeItem.js +24 -2
  16. package/dist/esm/components/DualListSelector/DualListSelectorTreeItem.js.map +1 -1
  17. package/dist/esm/components/MenuToggle/MenuToggle.d.ts +1 -1
  18. package/dist/esm/components/MenuToggle/MenuToggle.d.ts.map +1 -1
  19. package/dist/esm/components/MenuToggle/MenuToggle.js +2 -1
  20. package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
  21. package/dist/esm/components/Popover/Popover.d.ts.map +1 -1
  22. package/dist/esm/components/Popover/Popover.js +2 -22
  23. package/dist/esm/components/Popover/Popover.js.map +1 -1
  24. package/dist/js/components/Card/Card.d.ts +5 -7
  25. package/dist/js/components/Card/Card.d.ts.map +1 -1
  26. package/dist/js/components/Card/Card.js +14 -2
  27. package/dist/js/components/Card/Card.js.map +1 -1
  28. package/dist/js/components/DragDrop/Droppable.d.ts.map +1 -1
  29. package/dist/js/components/DragDrop/Droppable.js +5 -1
  30. package/dist/js/components/DragDrop/Droppable.js.map +1 -1
  31. package/dist/js/components/DualListSelector/DualListSelectorTree.d.ts +1 -1
  32. package/dist/js/components/DualListSelector/DualListSelectorTree.d.ts.map +1 -1
  33. package/dist/js/components/DualListSelector/DualListSelectorTree.js +2 -1
  34. package/dist/js/components/DualListSelector/DualListSelectorTree.js.map +1 -1
  35. package/dist/js/components/DualListSelector/DualListSelectorTreeItem.d.ts +3 -1
  36. package/dist/js/components/DualListSelector/DualListSelectorTreeItem.d.ts.map +1 -1
  37. package/dist/js/components/DualListSelector/DualListSelectorTreeItem.js +24 -3
  38. package/dist/js/components/DualListSelector/DualListSelectorTreeItem.js.map +1 -1
  39. package/dist/js/components/MenuToggle/MenuToggle.d.ts +1 -1
  40. package/dist/js/components/MenuToggle/MenuToggle.d.ts.map +1 -1
  41. package/dist/js/components/MenuToggle/MenuToggle.js +2 -1
  42. package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
  43. package/dist/js/components/Popover/Popover.d.ts.map +1 -1
  44. package/dist/js/components/Popover/Popover.js +2 -22
  45. package/dist/js/components/Popover/Popover.js.map +1 -1
  46. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-Black.woff2 +0 -0
  47. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-BlackItalic.woff2 +0 -0
  48. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-Bold.woff2 +0 -0
  49. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-BoldItalic.woff2 +0 -0
  50. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-Italic.woff2 +0 -0
  51. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-Light.woff2 +0 -0
  52. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-LightItalic.woff2 +0 -0
  53. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-Medium.woff2 +0 -0
  54. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-MediumItalic.woff2 +0 -0
  55. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplay-updated-Regular.woff2 +0 -0
  56. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplayVF-updated-Italic.woff2 +0 -0
  57. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatDisplay/RedHatDisplayVF-updated.woff2 +0 -0
  58. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-Bold.woff2 +0 -0
  59. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-BoldItalic.woff2 +0 -0
  60. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-Italic.woff2 +0 -0
  61. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-Light.woff2 +0 -0
  62. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-LightItalic.woff2 +0 -0
  63. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-Medium.woff2 +0 -0
  64. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-MediumItalic.woff2 +0 -0
  65. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMono-updated-Regular.woff2 +0 -0
  66. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMonoVF-updated-Italic.woff2 +0 -0
  67. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatMono/RedHatMonoVF-updated.woff2 +0 -0
  68. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-Bold.woff2 +0 -0
  69. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-BoldItalic.woff2 +0 -0
  70. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-Italic.woff2 +0 -0
  71. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-Light.woff2 +0 -0
  72. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-LightItalic.woff2 +0 -0
  73. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-Medium.woff2 +0 -0
  74. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-MediumItalic.woff2 +0 -0
  75. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-Regular.woff2 +0 -0
  76. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatTextVF-updated-Italic.woff2 +0 -0
  77. package/dist/styles/assets/fonts/RedHatFont-updated/RedHatText/RedHatTextVF-updated.woff2 +0 -0
  78. package/dist/styles/assets/fonts/RedHatFont-updated/modified/RedHatDisplayVF-updated-ItalicModified.woff2 +0 -0
  79. package/dist/styles/assets/fonts/RedHatFont-updated/modified/RedHatDisplayVFModified-updated.woff2 +0 -0
  80. package/dist/styles/assets/fonts/RedHatFont-updated/modified/RedHatTextVF-updated-ItalicModified.woff2 +0 -0
  81. package/dist/styles/assets/fonts/RedHatFont-updated/modified/RedHatTextVFModified-updated.woff2 +0 -0
  82. package/dist/styles/base-no-reset.css +121 -0
  83. package/dist/styles/base.css +121 -15
  84. package/dist/umd/react-core.css +183 -12
  85. package/dist/umd/react-core.js +58 -31
  86. package/dist/umd/react-core.min.css +183 -12
  87. package/dist/umd/react-core.min.js +2 -2
  88. package/package.json +6 -6
  89. package/src/components/Card/Card.tsx +23 -17
  90. package/src/components/Card/__tests__/Card.test.tsx +8 -14
  91. package/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap +2 -12
  92. package/src/components/Card/examples/Card.md +230 -264
  93. package/src/components/DragDrop/Droppable.tsx +5 -1
  94. package/src/components/DragDrop/examples/DragDrop.md +2 -0
  95. package/src/components/DualListSelector/DualListSelectorTree.tsx +4 -2
  96. package/src/components/DualListSelector/DualListSelectorTreeItem.tsx +32 -1
  97. package/src/components/DualListSelector/__tests__/__snapshots__/DualListSelector.test.tsx.snap +3 -0
  98. package/src/components/DualListSelector/examples/ComposableTree.tsx +345 -0
  99. package/src/components/DualListSelector/examples/DualListSelector.md +5 -1
  100. package/src/components/MenuToggle/MenuToggle.tsx +5 -2
  101. package/src/components/MenuToggle/__tests__/MenuToggle.test.tsx +5 -0
  102. package/src/components/MenuToggle/__tests__/__snapshots__/MenuToggle.test.tsx.snap +59 -0
  103. package/src/components/MenuToggle/examples/MenuToggle.md +60 -67
  104. package/src/components/Popover/Popover.tsx +1 -19
  105. package/src/components/Popover/__tests__/Generated/__snapshots__/Popover.test.tsx.snap +0 -1
  106. package/src/components/Popover/__tests__/__snapshots__/Popover.test.tsx.snap +0 -4
  107. package/src/demos/Card/Card.md +47 -23
  108. package/src/demos/TextInputGroupDemo.md +8 -246
  109. package/src/demos/examples/TextInputGroup/AttributeValueFiltering.js +250 -0
  110. 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
- ```js
16
+ ```ts
17
17
  import React from 'react';
18
18
  import { MenuToggle } from '@patternfly/react-core';
19
19
 
20
- class MenuToggleCollapsed extends React.Component {
21
- render() {
22
- return <MenuToggle>Collapsed</MenuToggle>;
23
- }
24
- }
20
+ <MenuToggle>Collapsed</MenuToggle>
21
+
25
22
  ```
26
23
 
27
24
  ### Expanded
28
25
 
29
- ```js
26
+ ```ts
30
27
  import React from 'react';
31
28
  import { MenuToggle } from '@patternfly/react-core';
32
29
 
33
- class MenuToggleCollapsed extends React.Component {
34
- render() {
35
- return <MenuToggle isExpanded>Expanded</MenuToggle>;
36
- }
37
- }
30
+ <MenuToggle isExpanded>Expanded</MenuToggle>;
31
+
38
32
  ```
39
33
 
40
34
  ### Disabled
41
35
 
42
- ```js
36
+ ```ts
43
37
  import React from 'react';
44
38
  import { MenuToggle } from '@patternfly/react-core';
45
39
 
46
- class MenuToggleCollapsed extends React.Component {
47
- render() {
48
- return <MenuToggle isDisabled>Disabled</MenuToggle>;
49
- }
50
- }
40
+ <MenuToggle isDisabled>Disabled</MenuToggle>
41
+
51
42
  ```
52
43
 
53
44
  ### Icon
54
45
 
55
- ```js
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
- class MenuToggleCollapsed extends React.Component {
61
- render() {
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
- ```js
57
+ ```ts
70
58
  import React from 'react';
71
59
  import { MenuToggle, Badge } from '@patternfly/react-core';
72
60
 
73
- class MenuToggleCollapsed extends React.Component {
74
- render() {
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
- ```js
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
- class MenuToggleCollapsed extends React.Component {
88
- render() {
89
- return (
90
- <React.Fragment>
91
- <MenuToggle variant="primary">Collapsed</MenuToggle>{' '}
92
- <MenuToggle variant="primary" icon={<CogIcon />}>
93
- Icon
94
- </MenuToggle>{' '}
95
- <MenuToggle variant="primary" isExpanded>
96
- Expanded
97
- </MenuToggle>{' '}
98
- <MenuToggle variant="primary" isDisabled>
99
- Disabled
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
- ```js
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
- class MenuToggleCollapsed extends React.Component {
115
- render() {
116
- return (
117
- <React.Fragment>
118
- <MenuToggle variant="plain" aria-label="plain kebab">
119
- <EllipsisVIcon />
120
- </MenuToggle>
121
- <MenuToggle variant="plain" isExpanded aria-label="plain expanded kebab">
122
- <EllipsisVIcon />
123
- </MenuToggle>
124
- <MenuToggle variant="plain" isDisabled aria-label="disabled kebab">
125
- <EllipsisVIcon />
126
- </MenuToggle>
127
- </React.Fragment>
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
+ &nbsp;
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 should match snapshot (auto-generated) 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
@@ -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
@@ -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 isHoverable isCompact>
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 isHoverable isCompact key={product.name}>
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
- import React from 'react';
29
- import {
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
- /** only show the search icon when no chips are selected */
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
- /** only show the clear button when there is something that can be cleared */
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
- const inputGroup = (
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
- const menu = (
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
- return <Popper trigger={inputGroup} popper={menu} isVisible={menuIsOpen} onDocumentClick={handleClick} />;
277
- };
39
+ ```js file="./examples/TextInputGroup/AutoCompleteSearch.js"
278
40
  ```