@patternfly/react-core 4.222.3 → 4.222.6

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 (85) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/esm/components/AboutModal/AboutModal.d.ts +1 -1
  3. package/dist/esm/components/AboutModal/AboutModal.js.map +1 -1
  4. package/dist/esm/components/Dropdown/InternalDropdownItem.d.ts.map +1 -1
  5. package/dist/esm/components/Dropdown/InternalDropdownItem.js +3 -3
  6. package/dist/esm/components/Dropdown/InternalDropdownItem.js.map +1 -1
  7. package/dist/esm/components/DualListSelector/DualListSelector.d.ts.map +1 -1
  8. package/dist/esm/components/DualListSelector/DualListSelector.js +6 -5
  9. package/dist/esm/components/DualListSelector/DualListSelector.js.map +1 -1
  10. package/dist/esm/components/DualListSelector/DualListSelectorPane.d.ts.map +1 -1
  11. package/dist/esm/components/DualListSelector/DualListSelectorPane.js.map +1 -1
  12. package/dist/esm/components/Menu/MenuItem.js.map +1 -1
  13. package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
  14. package/dist/esm/components/Modal/Modal.d.ts +1 -1
  15. package/dist/esm/components/Modal/Modal.js.map +1 -1
  16. package/dist/esm/components/Select/Select.d.ts.map +1 -1
  17. package/dist/esm/components/Select/Select.js +2 -1
  18. package/dist/esm/components/Select/Select.js.map +1 -1
  19. package/dist/esm/components/Toolbar/ToolbarToggleGroup.d.ts.map +1 -1
  20. package/dist/esm/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
  21. package/dist/js/components/AboutModal/AboutModal.d.ts +1 -1
  22. package/dist/js/components/AboutModal/AboutModal.js.map +1 -1
  23. package/dist/js/components/Dropdown/InternalDropdownItem.d.ts.map +1 -1
  24. package/dist/js/components/Dropdown/InternalDropdownItem.js +3 -3
  25. package/dist/js/components/Dropdown/InternalDropdownItem.js.map +1 -1
  26. package/dist/js/components/DualListSelector/DualListSelector.d.ts.map +1 -1
  27. package/dist/js/components/DualListSelector/DualListSelector.js +6 -5
  28. package/dist/js/components/DualListSelector/DualListSelector.js.map +1 -1
  29. package/dist/js/components/DualListSelector/DualListSelectorPane.d.ts.map +1 -1
  30. package/dist/js/components/DualListSelector/DualListSelectorPane.js.map +1 -1
  31. package/dist/js/components/Menu/MenuItem.js.map +1 -1
  32. package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
  33. package/dist/js/components/Modal/Modal.d.ts +1 -1
  34. package/dist/js/components/Modal/Modal.js.map +1 -1
  35. package/dist/js/components/Select/Select.d.ts.map +1 -1
  36. package/dist/js/components/Select/Select.js +2 -1
  37. package/dist/js/components/Select/Select.js.map +1 -1
  38. package/dist/js/components/Toolbar/ToolbarToggleGroup.d.ts.map +1 -1
  39. package/dist/js/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
  40. package/dist/umd/react-core.css +132 -64
  41. package/dist/umd/react-core.js +11 -9
  42. package/dist/umd/react-core.min.css +69 -1
  43. package/dist/umd/react-core.min.js +1 -1
  44. package/package.json +6 -6
  45. package/src/components/AboutModal/AboutModal.tsx +1 -1
  46. package/src/components/ApplicationLauncher/__tests__/Generated/__snapshots__/ApplicationLauncherSeparator.test.tsx.snap +1 -1
  47. package/src/components/ApplicationLauncher/__tests__/__snapshots__/ApplicationLauncher.test.tsx.snap +26 -14
  48. package/src/components/Dropdown/InternalDropdownItem.tsx +3 -2
  49. package/src/components/Dropdown/__tests__/Generated/__snapshots__/DropdownSeparator.test.tsx.snap +1 -1
  50. package/src/components/Dropdown/__tests__/__snapshots__/Dropdown.test.tsx.snap +21 -3
  51. package/src/components/Dropdown/__tests__/__snapshots__/InternalDropdownItem.test.tsx.snap +10 -0
  52. package/src/components/Dropdown/examples/DropdownBasic.tsx +4 -2
  53. package/src/components/DualListSelector/DualListSelector.tsx +57 -37
  54. package/src/components/DualListSelector/DualListSelectorPane.tsx +10 -8
  55. package/src/components/JumpLinks/examples/JumpLinks.md +6 -69
  56. package/src/components/JumpLinks/examples/JumpLinksBasic.tsx +10 -0
  57. package/src/components/JumpLinks/examples/JumpLinksExpandableVerticalWithSubsection.tsx +18 -0
  58. package/src/components/JumpLinks/examples/JumpLinksVertical.tsx +10 -0
  59. package/src/components/JumpLinks/examples/JumpLinksVerticalWithLabel.tsx +10 -0
  60. package/src/components/JumpLinks/examples/JumpLinksWithCenteredList.tsx +10 -0
  61. package/src/components/JumpLinks/examples/JumpLinksWithLabel.tsx +17 -0
  62. package/src/components/LabelGroup/examples/LabelGroup.md +6 -172
  63. package/src/components/LabelGroup/examples/LabelGroupBasic.tsx +15 -0
  64. package/src/components/LabelGroup/examples/LabelGroupCategory.tsx +15 -0
  65. package/src/components/LabelGroup/examples/LabelGroupCategoryRemovable.tsx +24 -0
  66. package/src/components/LabelGroup/examples/LabelGroupEditableLabels.tsx +53 -0
  67. package/src/components/LabelGroup/examples/LabelGroupOverflow.tsx +24 -0
  68. package/src/components/LabelGroup/examples/LabelGroupVerticalCategoryOverflowRemovable.tsx +24 -0
  69. package/src/components/List/examples/List.md +10 -72
  70. package/src/components/List/examples/ListBasic.tsx +10 -0
  71. package/src/components/List/examples/ListHorizontalRules.tsx +10 -0
  72. package/src/components/List/examples/ListIcons.tsx +13 -0
  73. package/src/components/List/examples/ListInline.tsx +10 -0
  74. package/src/components/List/examples/ListLargeIcons.tsx +13 -0
  75. package/src/components/List/examples/ListOrdered.tsx +10 -0
  76. package/src/components/List/examples/ListPlain.tsx +10 -0
  77. package/src/components/Menu/MenuItem.tsx +1 -1
  78. package/src/components/MenuToggle/MenuToggle.tsx +1 -1
  79. package/src/components/Modal/Modal.tsx +1 -1
  80. package/src/components/OptionsMenu/__tests__/Generated/__snapshots__/OptionsMenuItem.test.tsx.snap +2 -1
  81. package/src/components/OptionsMenu/__tests__/__snapshots__/OptionsMenu.test.tsx.snap +12 -6
  82. package/src/components/OverflowMenu/__tests__/Generated/__snapshots__/OverflowMenuDropdownItem.test.tsx.snap +2 -1
  83. package/src/components/Select/Select.tsx +6 -3
  84. package/src/components/Toolbar/ToolbarToggleGroup.tsx +4 -1
  85. package/src/demos/Wizard/WizardDemo.md +66 -121
@@ -134,10 +134,10 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
134
134
  private removeAllButtonRef = React.createRef<HTMLButtonElement>();
135
135
  static defaultProps: PickOptional<DualListSelectorProps> = {
136
136
  children: '',
137
- availableOptions: [] as React.ReactNode[],
137
+ availableOptions: [],
138
138
  availableOptionsTitle: 'Available options',
139
139
  availableOptionsSearchAriaLabel: 'Available search input',
140
- chosenOptions: [] as React.ReactNode[],
140
+ chosenOptions: [],
141
141
  chosenOptionsTitle: 'Chosen options',
142
142
  chosenOptionsSearchAriaLabel: 'Chosen search input',
143
143
  id: getUniqueId('dual-list-selector'),
@@ -177,11 +177,11 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
177
177
  constructor(props: DualListSelectorProps) {
178
178
  super(props);
179
179
  this.state = {
180
- availableOptions: [...this.props.availableOptions],
180
+ availableOptions: [...this.props.availableOptions] as React.ReactNode[],
181
181
  availableOptionsSelected: [],
182
182
  availableFilteredOptions: null,
183
183
  availableTreeFilteredOptions: null,
184
- chosenOptions: [...this.props.chosenOptions],
184
+ chosenOptions: [...this.props.chosenOptions] as React.ReactNode[],
185
185
  chosenOptionsSelected: [],
186
186
  chosenFilteredOptions: null,
187
187
  chosenTreeFilteredOptions: null,
@@ -208,8 +208,8 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
208
208
  JSON.stringify(this.state.chosenOptions, this.replacer)
209
209
  ) {
210
210
  this.setState({
211
- availableOptions: [...this.props.availableOptions],
212
- chosenOptions: [...this.props.chosenOptions]
211
+ availableOptions: [...this.props.availableOptions] as React.ReactNode[],
212
+ chosenOptions: [...this.props.chosenOptions] as React.ReactNode[]
213
213
  });
214
214
  }
215
215
  }
@@ -226,7 +226,9 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
226
226
  }
227
227
  if (isTree) {
228
228
  this.setState({
229
- availableTreeFilteredOptions: flattenTreeWithFolders(newFilteredOptions as DualListSelectorTreeItemData[])
229
+ availableTreeFilteredOptions: flattenTreeWithFolders(
230
+ (newFilteredOptions as unknown) as DualListSelectorTreeItemData[]
231
+ )
230
232
  });
231
233
  } else {
232
234
  this.setState({
@@ -243,7 +245,9 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
243
245
  }
244
246
  if (isTree) {
245
247
  this.setState({
246
- chosenTreeFilteredOptions: flattenTreeWithFolders(newFilteredOptions as DualListSelectorTreeItemData[])
248
+ chosenTreeFilteredOptions: flattenTreeWithFolders(
249
+ (newFilteredOptions as unknown) as DualListSelectorTreeItemData[]
250
+ )
247
251
  });
248
252
  } else {
249
253
  this.setState({
@@ -283,16 +287,20 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
283
287
  this.setState(prevState => {
284
288
  const movedOptions =
285
289
  prevState.availableTreeFilteredOptions ||
286
- flattenTreeWithFolders(prevState.availableOptions as DualListSelectorTreeItemData[]);
290
+ flattenTreeWithFolders((prevState.availableOptions as unknown) as DualListSelectorTreeItemData[]);
287
291
  const newAvailable = prevState.availableOptions
288
292
  .map(opt => Object.assign({}, opt))
289
- .filter(item => filterRestTreeItems(item as DualListSelectorTreeItemData, movedOptions));
293
+ .filter(item =>
294
+ filterRestTreeItems((item as unknown) as DualListSelectorTreeItemData, movedOptions)
295
+ ) as React.ReactNode[];
290
296
 
291
- const currChosen = flattenTree(prevState.chosenOptions as DualListSelectorTreeItemData[]);
297
+ const currChosen = flattenTree((prevState.chosenOptions as unknown) as DualListSelectorTreeItemData[]);
292
298
  const nextChosenOptions = currChosen.concat(movedOptions);
293
299
  const newChosen = this.createMergedCopy()
294
300
  .map(opt => Object.assign({}, opt))
295
- .filter(item => filterTreeItemsWithoutFolders(item as DualListSelectorTreeItemData, nextChosenOptions));
301
+ .filter(item =>
302
+ filterTreeItemsWithoutFolders(item as DualListSelectorTreeItemData, nextChosenOptions)
303
+ ) as React.ReactNode[];
296
304
 
297
305
  this.props.addAll && this.props.addAll(newAvailable, newChosen);
298
306
  this.props.onListChange && this.props.onListChange(newAvailable, newChosen);
@@ -339,15 +347,17 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
339
347
  const newAvailable = prevState.availableOptions
340
348
  .map(opt => Object.assign({}, opt))
341
349
  .filter(item =>
342
- filterRestTreeItems(item as DualListSelectorTreeItemData, prevState.availableTreeOptionsChecked)
350
+ filterRestTreeItems((item as unknown) as DualListSelectorTreeItemData, prevState.availableTreeOptionsChecked)
343
351
  );
344
352
 
345
353
  // Get next chosen options from current + new nodes and remap from base
346
- const currChosen = flattenTree(prevState.chosenOptions as DualListSelectorTreeItemData[]);
354
+ const currChosen = flattenTree((prevState.chosenOptions as unknown) as DualListSelectorTreeItemData[]);
347
355
  const nextChosenOptions = currChosen.concat(prevState.availableTreeOptionsChecked);
348
356
  const newChosen = this.createMergedCopy()
349
357
  .map(opt => Object.assign({}, opt))
350
- .filter(item => filterTreeItemsWithoutFolders(item as DualListSelectorTreeItemData, nextChosenOptions));
358
+ .filter(item =>
359
+ filterTreeItemsWithoutFolders(item as DualListSelectorTreeItemData, nextChosenOptions)
360
+ ) as React.ReactNode[];
351
361
 
352
362
  this.props.addSelected && this.props.addSelected(newAvailable, newChosen);
353
363
  this.props.onListChange && this.props.onListChange(newAvailable, newChosen);
@@ -391,16 +401,18 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
391
401
  this.setState(prevState => {
392
402
  const movedOptions =
393
403
  prevState.chosenTreeFilteredOptions ||
394
- flattenTreeWithFolders(prevState.chosenOptions as DualListSelectorTreeItemData[]);
404
+ flattenTreeWithFolders((prevState.chosenOptions as unknown) as DualListSelectorTreeItemData[]);
395
405
 
396
406
  const newChosen = prevState.chosenOptions
397
407
  .map(opt => Object.assign({}, opt))
398
- .filter(item => filterRestTreeItems(item as DualListSelectorTreeItemData, movedOptions));
399
- const currAvailable = flattenTree(prevState.availableOptions as DualListSelectorTreeItemData[]);
408
+ .filter(item => filterRestTreeItems((item as unknown) as DualListSelectorTreeItemData, movedOptions));
409
+ const currAvailable = flattenTree((prevState.availableOptions as unknown) as DualListSelectorTreeItemData[]);
400
410
  const nextAvailableOptions = currAvailable.concat(movedOptions);
401
411
  const newAvailable = this.createMergedCopy()
402
412
  .map(opt => Object.assign({}, opt))
403
- .filter(item => filterTreeItemsWithoutFolders(item as DualListSelectorTreeItemData, nextAvailableOptions));
413
+ .filter(item =>
414
+ filterTreeItemsWithoutFolders(item as DualListSelectorTreeItemData, nextAvailableOptions)
415
+ ) as React.ReactNode[];
404
416
 
405
417
  this.props.removeAll && this.props.removeAll(newAvailable, newChosen);
406
418
  this.props.onListChange && this.props.onListChange(newAvailable, newChosen);
@@ -444,14 +456,18 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
444
456
  // Remove selected chosen nodes from current chosen nodes
445
457
  const newChosen = prevState.chosenOptions
446
458
  .map(opt => Object.assign({}, opt))
447
- .filter(item => filterRestTreeItems(item as DualListSelectorTreeItemData, prevState.chosenTreeOptionsChecked));
459
+ .filter(item =>
460
+ filterRestTreeItems((item as unknown) as DualListSelectorTreeItemData, prevState.chosenTreeOptionsChecked)
461
+ );
448
462
 
449
463
  // Get next chosen options from current and remap from base
450
- const currAvailable = flattenTree(prevState.availableOptions as DualListSelectorTreeItemData[]);
464
+ const currAvailable = flattenTree((prevState.availableOptions as unknown) as DualListSelectorTreeItemData[]);
451
465
  const nextAvailableOptions = currAvailable.concat(prevState.chosenTreeOptionsChecked);
452
466
  const newAvailable = this.createMergedCopy()
453
467
  .map(opt => Object.assign({}, opt))
454
- .filter(item => filterTreeItemsWithoutFolders(item as DualListSelectorTreeItemData, nextAvailableOptions));
468
+ .filter(item =>
469
+ filterTreeItemsWithoutFolders(item as DualListSelectorTreeItemData, nextAvailableOptions)
470
+ ) as React.ReactNode[];
455
471
 
456
472
  this.props.removeSelected && this.props.removeSelected(newAvailable, newChosen);
457
473
  this.props.onListChange && this.props.onListChange(newAvailable, newChosen);
@@ -542,7 +558,7 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
542
558
  panelOptions = chosenOptions
543
559
  .map(opt => Object.assign({}, opt))
544
560
  .filter(item =>
545
- filterTreeItemsWithoutFolders(item as DualListSelectorTreeItemData, chosenTreeFilteredOptions)
561
+ filterTreeItemsWithoutFolders((item as unknown) as DualListSelectorTreeItemData, chosenTreeFilteredOptions)
546
562
  );
547
563
  } else {
548
564
  panelOptions = chosenOptions;
@@ -552,7 +568,10 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
552
568
  panelOptions = availableOptions
553
569
  .map(opt => Object.assign({}, opt))
554
570
  .filter(item =>
555
- filterTreeItemsWithoutFolders(item as DualListSelectorTreeItemData, availableTreeFilteredOptions)
571
+ filterTreeItemsWithoutFolders(
572
+ (item as unknown) as DualListSelectorTreeItemData,
573
+ availableTreeFilteredOptions
574
+ )
556
575
  );
557
576
  } else {
558
577
  panelOptions = availableOptions;
@@ -560,8 +579,8 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
560
579
  }
561
580
  const checkedOptionTree = panelOptions
562
581
  .map(opt => Object.assign({}, opt))
563
- .filter(item => filterTreeItems(item as DualListSelectorTreeItemData, [itemData.id]));
564
- const flatTree = flattenTreeWithFolders(checkedOptionTree as DualListSelectorTreeItemData[]);
582
+ .filter(item => filterTreeItems((item as unknown) as DualListSelectorTreeItemData, [itemData.id]));
583
+ const flatTree = flattenTreeWithFolders((checkedOptionTree as unknown) as DualListSelectorTreeItemData[]);
565
584
 
566
585
  const prevChecked = isChosen ? this.state.chosenTreeOptionsChecked : this.state.availableTreeOptionsChecked;
567
586
  let updatedChecked = [] as string[];
@@ -638,23 +657,24 @@ export class DualListSelector extends React.Component<DualListSelectorProps, Dua
638
657
  availableOptionsStatus ||
639
658
  (isTree
640
659
  ? `${
641
- filterFolders(availableOptions as DualListSelectorTreeItemData[], availableTreeOptionsChecked).length
642
- } of ${flattenTree(availableOptions as DualListSelectorTreeItemData[]).length} items selected`
660
+ filterFolders((availableOptions as unknown) as DualListSelectorTreeItemData[], availableTreeOptionsChecked)
661
+ .length
662
+ } of ${flattenTree((availableOptions as unknown) as DualListSelectorTreeItemData[]).length} items selected`
643
663
  : `${availableOptionsSelected.length} of ${availableOptions.length} items selected`);
644
664
  const chosenOptionsStatusToDisplay =
645
665
  chosenOptionsStatus ||
646
666
  (isTree
647
- ? `${filterFolders(chosenOptions as DualListSelectorTreeItemData[], chosenTreeOptionsChecked).length} of ${
648
- flattenTree(chosenOptions as DualListSelectorTreeItemData[]).length
649
- } items selected`
667
+ ? `${
668
+ filterFolders((chosenOptions as unknown) as DualListSelectorTreeItemData[], chosenTreeOptionsChecked).length
669
+ } of ${flattenTree((chosenOptions as unknown) as DualListSelectorTreeItemData[]).length} items selected`
650
670
  : `${chosenOptionsSelected.length} of ${chosenOptions.length} items selected`);
651
671
 
652
- const available = isTree
653
- ? availableOptions.map(item => this.mapChecked(item as DualListSelectorTreeItemData, false))
654
- : availableOptions;
655
- const chosen = isTree
656
- ? chosenOptions.map(item => this.mapChecked(item as DualListSelectorTreeItemData, true))
657
- : chosenOptions;
672
+ const available = (isTree
673
+ ? availableOptions.map(item => this.mapChecked((item as unknown) as DualListSelectorTreeItemData, false))
674
+ : availableOptions) as React.ReactNode[];
675
+ const chosen = (isTree
676
+ ? chosenOptions.map(item => this.mapChecked((item as unknown) as DualListSelectorTreeItemData, true))
677
+ : chosenOptions) as React.ReactNode[];
658
678
 
659
679
  return (
660
680
  <DualListSelectorContext.Provider value={{ isTree }}>
@@ -70,7 +70,7 @@ export const DualListSelectorPane: React.FunctionComponent<DualListSelectorPaneP
70
70
  onOptionSelect,
71
71
  onOptionCheck,
72
72
  title = '',
73
- options = [] as React.ReactNode[],
73
+ options = [],
74
74
  selectedOptions = [],
75
75
  isSearchable = false,
76
76
  searchInputAriaLabel = '',
@@ -87,11 +87,11 @@ export const DualListSelectorPane: React.FunctionComponent<DualListSelectorPaneP
87
87
  // only called when search input is dynamically built
88
88
  const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
89
89
  const newValue = e.target.value;
90
- let filtered;
90
+ let filtered: React.ReactNode[];
91
91
  if (isTree) {
92
- filtered = (options as DualListSelectorTreeItemData[])
92
+ filtered = options
93
93
  .map(opt => Object.assign({}, opt))
94
- .filter(item => filterInput(item as DualListSelectorTreeItemData, newValue));
94
+ .filter(item => filterInput((item as unknown) as DualListSelectorTreeItemData, newValue));
95
95
  } else {
96
96
  filtered = options.filter(option => {
97
97
  if (displayOption(option)) {
@@ -110,7 +110,7 @@ export const DualListSelectorPane: React.FunctionComponent<DualListSelectorPaneP
110
110
  // only called when options are passed via options prop and isTree === true
111
111
  const filterInput = (item: DualListSelectorTreeItemData, input: string): boolean => {
112
112
  if (filterOption) {
113
- return filterOption(item, input);
113
+ return filterOption((item as unknown) as React.ReactNode, input);
114
114
  } else {
115
115
  if (item.text.toLowerCase().includes(input.toLowerCase()) || input === '') {
116
116
  return true;
@@ -200,10 +200,12 @@ export const DualListSelectorPane: React.FunctionComponent<DualListSelectorPaneP
200
200
  <DualListSelectorTree
201
201
  data={
202
202
  isSearchable
203
- ? (options as DualListSelectorTreeItemData[])
203
+ ? ((options
204
204
  .map(opt => Object.assign({}, opt))
205
- .filter(item => filterInput(item as DualListSelectorTreeItemData, input))
206
- : (options as DualListSelectorTreeItemData[])
205
+ .filter(item =>
206
+ filterInput((item as unknown) as DualListSelectorTreeItemData, input)
207
+ ) as unknown) as DualListSelectorTreeItemData[])
208
+ : ((options as unknown) as DualListSelectorTreeItemData[])
207
209
  }
208
210
  onOptionCheck={onOptionCheck}
209
211
  id={`${id}-tree`}
@@ -9,89 +9,26 @@ propComponents: ['JumpLinks', 'JumpLinksItem']
9
9
  These examples are static because they have no element to scroll spy on that makes sense. Check out the [React demos](./react-demos) to see scroll spying in action!
10
10
 
11
11
  ### Basic
12
- ```js
13
- import React from 'react';
14
- import { JumpLinks, JumpLinksItem } from '@patternfly/react-core';
15
-
16
- <JumpLinks>
17
- <JumpLinksItem>Inactive section</JumpLinksItem>
18
- <JumpLinksItem isActive>Active section</JumpLinksItem>
19
- <JumpLinksItem>Inactive section</JumpLinksItem>
20
- </JumpLinks>
12
+ ```ts file='./JumpLinksBasic.tsx'
21
13
  ```
22
14
 
23
15
  ### With centered list
24
- ```js
25
- import React from 'react';
26
- import { JumpLinks, JumpLinksItem } from '@patternfly/react-core';
27
-
28
- <JumpLinks isCentered>
29
- <JumpLinksItem>Inactive section</JumpLinksItem>
30
- <JumpLinksItem isActive>Active section</JumpLinksItem>
31
- <JumpLinksItem>Inactive section</JumpLinksItem>
32
- </JumpLinks>
16
+ ```ts file='./JumpLinksWithCenteredList.tsx'
33
17
  ```
34
18
 
35
19
  ### With label
36
- ```js
37
- import React from 'react';
38
- import { JumpLinks, JumpLinksItem } from '@patternfly/react-core';
39
-
40
- <React.Fragment>
41
- <JumpLinks label="Jump to section">
42
- <JumpLinksItem>Inactive section</JumpLinksItem>
43
- <JumpLinksItem isActive>Active section</JumpLinksItem>
44
- <JumpLinksItem>Inactive section</JumpLinksItem>
45
- </JumpLinks>
46
- <JumpLinks isCentered label="Jump to section">
47
- <JumpLinksItem>Inactive section</JumpLinksItem>
48
- <JumpLinksItem isActive>Active section</JumpLinksItem>
49
- <JumpLinksItem>Inactive section</JumpLinksItem>
50
- </JumpLinks>
51
- </React.Fragment>
20
+ ```ts file='./JumpLinksWithLabel.tsx'
52
21
  ```
53
22
 
54
23
  ### Vertical
55
- ```js
56
- import React from 'react';
57
- import { JumpLinks, JumpLinksItem } from '@patternfly/react-core';
58
-
59
- <JumpLinks isVertical>
60
- <JumpLinksItem>Inactive section</JumpLinksItem>
61
- <JumpLinksItem isActive>Active section</JumpLinksItem>
62
- <JumpLinksItem>Inactive section</JumpLinksItem>
63
- </JumpLinks>
24
+ ```ts file='./JumpLinksVertical.tsx'
64
25
  ```
65
26
 
66
27
  ### Vertical with label
67
- ```js
68
- import React from 'react';
69
- import { JumpLinks, JumpLinksItem } from '@patternfly/react-core';
70
-
71
- <JumpLinks isVertical label="Jump to section">
72
- <JumpLinksItem>Inactive section</JumpLinksItem>
73
- <JumpLinksItem isActive>Active section</JumpLinksItem>
74
- <JumpLinksItem>Inactive section</JumpLinksItem>
75
- </JumpLinks>
28
+ ```ts file='./JumpLinksVerticalWithLabel.tsx'
76
29
  ```
77
30
 
78
31
  ### Expandable vertical with subsection
79
- ```js
80
- import React from 'react';
81
- import { JumpLinks, JumpLinksItem, JumpLinksList } from '@patternfly/react-core';
82
-
83
- <JumpLinks isVertical label="Jump to section" expandable={{ default: 'expandable' }}>
84
- <JumpLinksItem>Inactive section</JumpLinksItem>
85
- <JumpLinksItem>
86
- Section with active subsection
87
- <JumpLinksList>
88
- <JumpLinksItem isActive>Active subsection</JumpLinksItem>
89
- <JumpLinksItem>Inactive subsection</JumpLinksItem>
90
- <JumpLinksItem>Inactive subsection</JumpLinksItem>
91
- </JumpLinksList>
92
- </JumpLinksItem>
93
- <JumpLinksItem>Inactive section</JumpLinksItem>
94
- <JumpLinksItem>Inactive section</JumpLinksItem>
95
- </JumpLinks>
32
+ ```ts file='./JumpLinksExpandableVerticalWithSubsection.tsx'
96
33
  ```
97
34
 
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { JumpLinks, JumpLinksItem } from '@patternfly/react-core';
3
+
4
+ export const JumpLinksBasic: React.FunctionComponent = () => (
5
+ <JumpLinks>
6
+ <JumpLinksItem>Inactive section</JumpLinksItem>
7
+ <JumpLinksItem isActive>Active section</JumpLinksItem>
8
+ <JumpLinksItem>Inactive section</JumpLinksItem>
9
+ </JumpLinks>
10
+ );
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { JumpLinks, JumpLinksItem, JumpLinksList } from '@patternfly/react-core';
3
+
4
+ export const JumpLinksExpandableVerticalWithSubsection: React.FunctionComponent = () => (
5
+ <JumpLinks isVertical label="Jump to section" expandable={{ default: 'expandable' }}>
6
+ <JumpLinksItem>Inactive section</JumpLinksItem>
7
+ <JumpLinksItem>
8
+ Section with active subsection
9
+ <JumpLinksList>
10
+ <JumpLinksItem isActive>Active subsection</JumpLinksItem>
11
+ <JumpLinksItem>Inactive subsection</JumpLinksItem>
12
+ <JumpLinksItem>Inactive subsection</JumpLinksItem>
13
+ </JumpLinksList>
14
+ </JumpLinksItem>
15
+ <JumpLinksItem>Inactive section</JumpLinksItem>
16
+ <JumpLinksItem>Inactive section</JumpLinksItem>
17
+ </JumpLinks>
18
+ );
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { JumpLinks, JumpLinksItem } from '@patternfly/react-core';
3
+
4
+ export const JumpLinksVertical: React.FunctionComponent = () => (
5
+ <JumpLinks isVertical>
6
+ <JumpLinksItem>Inactive section</JumpLinksItem>
7
+ <JumpLinksItem isActive>Active section</JumpLinksItem>
8
+ <JumpLinksItem>Inactive section</JumpLinksItem>
9
+ </JumpLinks>
10
+ );
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { JumpLinks, JumpLinksItem } from '@patternfly/react-core';
3
+
4
+ export const JumpLinksVerticalWithLabel: React.FunctionComponent = () => (
5
+ <JumpLinks isVertical label="Jump to section">
6
+ <JumpLinksItem>Inactive section</JumpLinksItem>
7
+ <JumpLinksItem isActive>Active section</JumpLinksItem>
8
+ <JumpLinksItem>Inactive section</JumpLinksItem>
9
+ </JumpLinks>
10
+ );
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { JumpLinks, JumpLinksItem } from '@patternfly/react-core';
3
+
4
+ export const JumpLinksWithCenteredList: React.FunctionComponent = () => (
5
+ <JumpLinks isCentered>
6
+ <JumpLinksItem>Inactive section</JumpLinksItem>
7
+ <JumpLinksItem isActive>Active section</JumpLinksItem>
8
+ <JumpLinksItem>Inactive section</JumpLinksItem>
9
+ </JumpLinks>
10
+ );
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { JumpLinks, JumpLinksItem } from '@patternfly/react-core';
3
+
4
+ export const JumpLinksWithLabel: React.FunctionComponent = () => (
5
+ <>
6
+ <JumpLinks label="Jump to section">
7
+ <JumpLinksItem>Inactive section</JumpLinksItem>
8
+ <JumpLinksItem isActive>Active section</JumpLinksItem>
9
+ <JumpLinksItem>Inactive section</JumpLinksItem>
10
+ </JumpLinks>
11
+ <JumpLinks isCentered label="Jump to section">
12
+ <JumpLinksItem>Inactive section</JumpLinksItem>
13
+ <JumpLinksItem isActive>Active section</JumpLinksItem>
14
+ <JumpLinksItem>Inactive section</JumpLinksItem>
15
+ </JumpLinks>
16
+ </>
17
+ );
@@ -13,196 +13,30 @@ import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-i
13
13
 
14
14
  ### Basic
15
15
 
16
- ```js
17
- import React from 'react';
18
- import { Label, LabelGroup } from '@patternfly/react-core';
19
- import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
20
-
21
- <LabelGroup>
22
- <Label icon={<InfoCircleIcon />}>Label 1</Label>
23
- <Label icon={<InfoCircleIcon />} color="blue">
24
- Label 2
25
- </Label>
26
- <Label icon={<InfoCircleIcon />} color="green">
27
- Label 3
28
- </Label>
29
- </LabelGroup>;
16
+ ```ts file="LabelGroupBasic.tsx"
30
17
  ```
31
18
 
32
19
  ### Overflow
33
20
 
34
- ```js
35
- import React from 'react';
36
- import { Label, LabelGroup } from '@patternfly/react-core';
37
- import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
38
-
39
- <LabelGroup>
40
- <Label icon={<InfoCircleIcon />}>Label 1</Label>
41
- <Label icon={<InfoCircleIcon />} color="blue">
42
- Label 2
43
- </Label>
44
- <Label icon={<InfoCircleIcon />} color="green">
45
- Label 3
46
- </Label>
47
- <Label icon={<InfoCircleIcon />} color="orange">
48
- Label 4
49
- </Label>
50
- <Label icon={<InfoCircleIcon />} color="red">
51
- Label 5
52
- </Label>
53
- <Label icon={<InfoCircleIcon />} color="purple">
54
- Label 6
55
- </Label>
56
- </LabelGroup>;
21
+ ```ts file="LabelGroupOverflow.tsx"
57
22
  ```
58
23
 
59
24
  ### Category
60
25
 
61
- ```js
62
- import React from 'react';
63
- import { Label, LabelGroup } from '@patternfly/react-core';
64
- import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
65
-
66
- <LabelGroup categoryName="Group label">
67
- <Label icon={<InfoCircleIcon />}>Label 1</Label>
68
- <Label icon={<InfoCircleIcon />} color="blue">
69
- Label 2
70
- </Label>
71
- <Label icon={<InfoCircleIcon />} color="green">
72
- Label 3
73
- </Label>
74
- </LabelGroup>;
26
+ ```ts file="LabelGroupCategory.tsx"
75
27
  ```
76
28
 
77
29
  ### Category removable
78
30
 
79
- ```js
80
- import React from 'react';
81
- import { Label, LabelGroup } from '@patternfly/react-core';
82
- import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
83
-
84
- CategoryLabelGroupRemovable = () => {
85
- const [labels, setLabels] = React.useState([
86
- ['Label 1', 'grey'],
87
- ['Label 2', 'blue'],
88
- ['Label 3', 'green'],
89
- ['Label 4', 'orange'],
90
- ['Label 5', 'red']
91
- ]);
92
- const deleteCategory = () => setLabels([]);
93
-
94
- return (
95
- <LabelGroup categoryName="Group label" isClosable onClick={deleteCategory}>
96
- {labels.map(([labelText, labelColor]) => (
97
- <Label icon={<InfoCircleIcon />} color={labelColor} key={labelText}>
98
- {labelText}
99
- </Label>
100
- ))}
101
- </LabelGroup>
102
- );
103
- };
31
+ ```ts file="LabelGroupCategoryRemovable.tsx"
104
32
  ```
105
33
 
106
34
  ### Vertical category overflow removable
107
35
 
108
- ```js
109
- import React from 'react';
110
- import { Label, LabelGroup } from '@patternfly/react-core';
111
- import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
112
-
113
- VerticalCategoryLabelGroupOverflowRemovable = () => {
114
- const [labels, setLabels] = React.useState([
115
- ['Label 1', 'grey'],
116
- ['Label 2', 'blue'],
117
- ['Label 3', 'green'],
118
- ['Label 4', 'orange'],
119
- ['Label 5', 'red']
120
- ]);
121
- const deleteCategory = () => setLabels([]);
122
-
123
- return (
124
- <LabelGroup categoryName="Group label with a very long name" isVertical isClosable onClick={deleteCategory}>
125
- {labels.map(([labelText, labelColor]) => (
126
- <Label icon={<InfoCircleIcon />} color={labelColor} key={labelText}>
127
- {labelText}
128
- </Label>
129
- ))}
130
- </LabelGroup>
131
- );
132
- };
36
+ ```ts file="LabelGroupVerticalCategoryOverflowRemovable.tsx"
133
37
  ```
134
38
 
135
39
  ### Editable labels
136
40
 
137
- ```js isBeta
138
- import React from 'react';
139
- import { LabelGroup, Label, TextArea } from '@patternfly/react-core';
140
-
141
- class EditableLabelGroup extends React.Component {
142
- constructor(props) {
143
- super(props);
144
- this.state = {
145
- label1: 'Editable label',
146
- label2: 'Editable label 2',
147
- label3: 'Editable label 3'
148
- };
149
- this.onEditCancel = (prevText, label) => {
150
- this.setState({
151
- [label]: prevText
152
- });
153
- };
154
- this.onEditComplete = (newText, label) => {
155
- this.setState({
156
- [label]: newText
157
- });
158
- };
159
- }
160
-
161
- render() {
162
- return (
163
- <LabelGroup numLabels={5} isEditable>
164
- <Label
165
- color="blue"
166
- onClose={Function.prototype}
167
- onEditCancel={prevText => this.onEditCancel(prevText, 'label1')}
168
- onEditComplete={newText => this.onEditComplete(newText, 'label1')}
169
- isEditable
170
- editableProps={{
171
- 'aria-label': 'Editable text',
172
- id: 'editable-label-1'
173
- }}
174
- >
175
- {this.state.label1}
176
- </Label>
177
- <Label color="green">Static label</Label>
178
- <Label
179
- color="blue"
180
- onClose={Function.prototype}
181
- onEditCancel={prevText => this.onEditCancel(prevText, 'label2')}
182
- onEditComplete={newText => this.onEditComplete(newText, 'label2')}
183
- isEditable
184
- editableProps={{
185
- 'aria-label': 'Editable text 2',
186
- id: 'editable-label-2'
187
- }}
188
- >
189
- {this.state.label2}
190
- </Label>
191
- <Label
192
- color="blue"
193
- onClose={Function.prototype}
194
- onEditCancel={prevText => this.onEditCancel(prevText, 'label3')}
195
- onEditComplete={newText => this.onEditComplete(newText, 'label3')}
196
- isEditable
197
- editableProps={{
198
- 'aria-label': 'Editable text 3',
199
- id: 'editable-label-3'
200
- }}
201
- >
202
- {this.state.label3}
203
- </Label>
204
- </LabelGroup>
205
- );
206
- }
207
- }
41
+ ```ts file="LabelGroupEditableLabels.tsx" isBeta
208
42
  ```
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { Label, LabelGroup } from '@patternfly/react-core';
3
+ import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
4
+
5
+ export const LabelGroupBasic: React.FunctionComponent = () => (
6
+ <LabelGroup>
7
+ <Label icon={<InfoCircleIcon />}>Label 1</Label>
8
+ <Label icon={<InfoCircleIcon />} color="blue">
9
+ Label 2
10
+ </Label>
11
+ <Label icon={<InfoCircleIcon />} color="green">
12
+ Label 3
13
+ </Label>
14
+ </LabelGroup>
15
+ );