@patternfly/react-core 3.144.1 → 3.146.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 (151) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/esm/components/DataToolbar/DataToolbarFilter.js +16 -5
  3. package/dist/esm/components/Drawer/Drawer.js +26 -36
  4. package/dist/esm/components/Drawer/DrawerActions.js +28 -0
  5. package/dist/esm/components/Drawer/DrawerCloseButton.js +36 -0
  6. package/dist/esm/components/Drawer/DrawerContent.js +9 -6
  7. package/dist/esm/components/Drawer/DrawerContentBody.js +30 -0
  8. package/dist/esm/components/Drawer/DrawerHead.js +33 -0
  9. package/dist/esm/components/Drawer/DrawerMain.js +28 -0
  10. package/dist/esm/components/Drawer/DrawerPanelBody.js +30 -0
  11. package/dist/esm/components/Drawer/DrawerPanelContent.js +12 -8
  12. package/dist/esm/components/Drawer/DrawerSection.js +28 -0
  13. package/dist/esm/components/Drawer/index.js +7 -1
  14. package/dist/esm/components/Dropdown/Toggle.js +3 -1
  15. package/dist/esm/components/FileUpload/FileUpload.js +123 -0
  16. package/dist/esm/components/FileUpload/FileUploadField.js +123 -0
  17. package/dist/esm/components/FileUpload/index.js +3 -0
  18. package/dist/esm/components/Modal/ModalBoxDescription.js +30 -0
  19. package/dist/esm/components/Modal/ModalContent.js +2 -3
  20. package/dist/esm/components/Select/Select.js +70 -36
  21. package/dist/esm/components/Select/SelectMenu.js +34 -25
  22. package/dist/esm/components/Select/SelectOption.js +15 -5
  23. package/dist/esm/components/Select/SelectToggle.js +6 -3
  24. package/dist/esm/components/index.js +1 -0
  25. package/dist/esm/helpers/fileUtils.js +32 -0
  26. package/dist/esm/helpers/util.js +1 -1
  27. package/dist/js/components/DataToolbar/DataToolbarFilter.d.ts +8 -2
  28. package/dist/js/components/DataToolbar/DataToolbarFilter.js +21 -12
  29. package/dist/js/components/Drawer/Drawer.d.ts +7 -6
  30. package/dist/js/components/Drawer/Drawer.js +32 -67
  31. package/dist/js/components/Drawer/DrawerActions.d.ts +8 -0
  32. package/dist/js/components/Drawer/DrawerActions.js +44 -0
  33. package/dist/js/components/Drawer/DrawerCloseButton.d.ts +10 -0
  34. package/dist/js/components/Drawer/DrawerCloseButton.js +58 -0
  35. package/dist/js/components/Drawer/DrawerContent.d.ts +3 -1
  36. package/dist/js/components/Drawer/DrawerContent.js +9 -5
  37. package/dist/js/components/Drawer/DrawerContentBody.d.ts +10 -0
  38. package/dist/js/components/Drawer/DrawerContentBody.js +47 -0
  39. package/dist/js/components/Drawer/DrawerHead.d.ts +10 -0
  40. package/dist/js/components/Drawer/DrawerHead.js +51 -0
  41. package/dist/js/components/Drawer/DrawerMain.d.ts +8 -0
  42. package/dist/js/components/Drawer/DrawerMain.js +44 -0
  43. package/dist/js/components/Drawer/DrawerPanelBody.d.ts +10 -0
  44. package/dist/js/components/Drawer/DrawerPanelBody.js +47 -0
  45. package/dist/js/components/Drawer/DrawerPanelContent.d.ts +3 -4
  46. package/dist/js/components/Drawer/DrawerPanelContent.js +16 -10
  47. package/dist/js/components/Drawer/DrawerSection.d.ts +8 -0
  48. package/dist/js/components/Drawer/DrawerSection.js +44 -0
  49. package/dist/js/components/Drawer/index.d.ts +7 -1
  50. package/dist/js/components/Drawer/index.js +75 -3
  51. package/dist/js/components/Dropdown/Toggle.js +2 -1
  52. package/dist/js/components/FileUpload/FileUpload.d.ts +57 -0
  53. package/dist/js/components/FileUpload/FileUpload.js +151 -0
  54. package/dist/js/components/FileUpload/FileUploadField.d.ts +57 -0
  55. package/dist/js/components/FileUpload/FileUploadField.js +167 -0
  56. package/dist/js/components/FileUpload/index.d.ts +2 -0
  57. package/dist/js/components/FileUpload/index.js +30 -0
  58. package/dist/js/components/Modal/ModalBoxDescription.d.ts +10 -0
  59. package/dist/js/components/Modal/ModalBoxDescription.js +49 -0
  60. package/dist/js/components/Modal/ModalContent.js +3 -4
  61. package/dist/js/components/Select/Select.d.ts +2 -0
  62. package/dist/js/components/Select/Select.js +79 -35
  63. package/dist/js/components/Select/SelectMenu.d.ts +3 -1
  64. package/dist/js/components/Select/SelectMenu.js +30 -14
  65. package/dist/js/components/Select/SelectOption.d.ts +2 -0
  66. package/dist/js/components/Select/SelectOption.js +15 -5
  67. package/dist/js/components/Select/SelectToggle.d.ts +2 -0
  68. package/dist/js/components/Select/SelectToggle.js +6 -3
  69. package/dist/js/components/index.d.ts +1 -0
  70. package/dist/js/components/index.js +12 -0
  71. package/dist/js/helpers/fileUtils.d.ts +12 -0
  72. package/dist/js/helpers/fileUtils.js +45 -0
  73. package/dist/js/helpers/util.js +3 -1
  74. package/dist/umd/components/DataToolbar/DataToolbarFilter.js +16 -5
  75. package/dist/umd/components/Drawer/Drawer.js +27 -50
  76. package/dist/umd/components/Drawer/DrawerActions.js +154 -0
  77. package/dist/umd/components/Drawer/DrawerCloseButton.js +162 -0
  78. package/dist/umd/components/Drawer/DrawerContent.js +12 -10
  79. package/dist/umd/components/Drawer/DrawerContentBody.js +156 -0
  80. package/dist/umd/components/Drawer/DrawerHead.js +158 -0
  81. package/dist/umd/components/Drawer/DrawerMain.js +154 -0
  82. package/dist/umd/components/Drawer/DrawerPanelBody.js +156 -0
  83. package/dist/umd/components/Drawer/DrawerPanelContent.js +16 -13
  84. package/dist/umd/components/Drawer/DrawerSection.js +154 -0
  85. package/dist/umd/components/Drawer/index.js +60 -6
  86. package/dist/umd/components/Dropdown/Toggle.js +3 -1
  87. package/dist/umd/components/FileUpload/FileUpload.js +291 -0
  88. package/dist/umd/components/FileUpload/FileUploadField.js +243 -0
  89. package/dist/umd/components/FileUpload/index.js +38 -0
  90. package/dist/umd/components/Modal/ModalBoxDescription.js +156 -0
  91. package/dist/umd/components/Modal/ModalContent.js +5 -8
  92. package/dist/umd/components/Select/Select.js +71 -38
  93. package/dist/umd/components/Select/SelectMenu.js +37 -29
  94. package/dist/umd/components/Select/SelectOption.js +15 -5
  95. package/dist/umd/components/Select/SelectToggle.js +6 -3
  96. package/dist/umd/components/index.js +13 -4
  97. package/dist/umd/helpers/fileUtils.js +52 -0
  98. package/dist/umd/helpers/util.js +1 -1
  99. package/package.json +7 -6
  100. package/src/components/ApplicationLauncher/__tests__/__snapshots__/ApplicationLauncher.test.tsx.snap +0 -6
  101. package/src/components/DataToolbar/DataToolbarFilter.tsx +18 -6
  102. package/src/components/DataToolbar/__tests__/__snapshots__/DataToolbar.test.tsx.snap +16 -0
  103. package/src/components/Drawer/Drawer.tsx +36 -31
  104. package/src/components/Drawer/DrawerActions.tsx +21 -0
  105. package/src/components/Drawer/DrawerCloseButton.tsx +28 -0
  106. package/src/components/Drawer/DrawerContent.tsx +11 -4
  107. package/src/components/Drawer/DrawerContentBody.tsx +24 -0
  108. package/src/components/Drawer/DrawerHead.tsx +27 -0
  109. package/src/components/Drawer/DrawerMain.tsx +21 -0
  110. package/src/components/Drawer/DrawerPanelBody.tsx +24 -0
  111. package/src/components/Drawer/DrawerPanelContent.tsx +19 -8
  112. package/src/components/Drawer/DrawerSection.tsx +21 -0
  113. package/src/components/Drawer/__tests__/Drawer.test.tsx +24 -13
  114. package/src/components/Drawer/__tests__/Generated/__snapshots__/Drawer.test.tsx.snap +13 -5
  115. package/src/components/Drawer/__tests__/Generated/__snapshots__/DrawerContent.test.tsx.snap +8 -6
  116. package/src/components/Drawer/__tests__/Generated/__snapshots__/DrawerPanelContent.test.tsx.snap +3 -11
  117. package/src/components/Drawer/__tests__/__snapshots__/Drawer.test.tsx.snap +764 -69
  118. package/src/components/Drawer/examples/Drawer.md +434 -11
  119. package/src/components/Drawer/index.ts +7 -1
  120. package/src/components/Dropdown/Toggle.tsx +2 -0
  121. package/src/components/Dropdown/__tests__/__snapshots__/Dropdown.test.tsx.snap +0 -14
  122. package/src/components/Dropdown/__tests__/__snapshots__/DropdownToggle.test.tsx.snap +0 -5
  123. package/src/components/Dropdown/__tests__/__snapshots__/Toggle.test.tsx.snap +0 -2
  124. package/src/components/FileUpload/FileUpload.tsx +150 -0
  125. package/src/components/FileUpload/FileUploadField.tsx +176 -0
  126. package/src/components/FileUpload/__tests__/FileUpload.test.tsx +22 -0
  127. package/src/components/FileUpload/__tests__/FileUploadField.test.tsx +27 -0
  128. package/src/components/FileUpload/__tests__/__snapshots__/FileUpload.test.tsx.snap +16 -0
  129. package/src/components/FileUpload/__tests__/__snapshots__/FileUploadField.test.tsx.snap +60 -0
  130. package/src/components/FileUpload/examples/FileUpload.md +283 -0
  131. package/src/components/FileUpload/index.ts +2 -0
  132. package/src/components/Modal/ModalBoxDescription.tsx +23 -0
  133. package/src/components/Modal/ModalContent.tsx +2 -6
  134. package/src/components/Modal/__tests__/__snapshots__/ModalContent.test.tsx.snap +2 -3
  135. package/src/components/OptionsMenu/__tests__/__snapshots__/OptionsMenu.test.tsx.snap +0 -7
  136. package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +0 -13
  137. package/src/components/Select/Select.tsx +74 -33
  138. package/src/components/Select/SelectMenu.tsx +28 -23
  139. package/src/components/Select/SelectOption.tsx +28 -3
  140. package/src/components/Select/SelectToggle.tsx +6 -1
  141. package/src/components/Select/__tests__/Select.test.tsx +16 -0
  142. package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +911 -174
  143. package/src/components/Select/__tests__/__snapshots__/SelectOption.test.tsx.snap +7 -7
  144. package/src/components/Select/__tests__/__snapshots__/SelectToggle.test.tsx.snap +3 -0
  145. package/src/components/Select/examples/Select.md +109 -6
  146. package/src/components/index.ts +1 -0
  147. package/src/helpers/__tests__/fileUtils.test.ts +17 -0
  148. package/src/helpers/fileUtils.ts +26 -0
  149. package/src/helpers/util.ts +1 -1
  150. package/src/components/Drawer/Drawer.test.tsx +0 -22
  151. package/src/components/Drawer/__snapshots__/Drawer.test.tsx.snap +0 -121
@@ -8,11 +8,12 @@ import TimesCircleIcon from '@patternfly/react-icons/dist/js/icons/times-circle-
8
8
  import { SelectMenu } from './SelectMenu';
9
9
  import { SelectOption, SelectOptionObject } from './SelectOption';
10
10
  import { SelectToggle } from './SelectToggle';
11
- import { SelectContext, SelectVariant, SelectDirection } from './selectConstants';
11
+ import { SelectContext, SelectVariant, SelectDirection, KeyTypes } from './selectConstants';
12
12
  import { Chip, ChipGroup } from '../ChipGroup';
13
13
  import { keyHandler, getNextIndex } from '../../helpers/util';
14
14
  import { Omit, PickOptional } from '../../helpers/typeUtils';
15
15
  import { InjectedOuiaProps, withOuiaContext } from '../withOuia';
16
+ import { Divider } from '../Divider';
16
17
 
17
18
  // seed for the aria-labelledby ID
18
19
  let currentId = 0;
@@ -81,6 +82,8 @@ export interface SelectProps
81
82
  toggleIcon?: React.ReactElement;
82
83
  /** Custom content to render in the select menu. If this prop is defined, the variant prop will be ignored and the select will render with a single select toggle */
83
84
  customContent?: React.ReactNode;
85
+ /** Flag indicating if select should have an inline text input for filtering */
86
+ hasInlineFilter?: boolean;
84
87
  }
85
88
 
86
89
  export interface SelectState {
@@ -94,6 +97,7 @@ export interface SelectState {
94
97
 
95
98
  class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectState> {
96
99
  private parentRef = React.createRef<HTMLDivElement>();
100
+ private filterRef = React.createRef<HTMLInputElement>();
97
101
  private refCollection: HTMLElement[] = [];
98
102
 
99
103
  static defaultProps: PickOptional<SelectProps> = {
@@ -122,7 +126,8 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
122
126
  onCreateOption: () => undefined as void,
123
127
  toggleIcon: null as React.ReactElement,
124
128
  onFilter: null,
125
- customContent: null
129
+ customContent: null,
130
+ hasInlineFilter: false
126
131
  };
127
132
 
128
133
  state: SelectState = {
@@ -135,6 +140,10 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
135
140
  };
136
141
 
137
142
  componentDidUpdate = (prevProps: SelectProps, prevState: SelectState) => {
143
+ if (this.props.hasInlineFilter) {
144
+ this.refCollection[0] = this.filterRef.current;
145
+ }
146
+
138
147
  if (!prevState.openedOnEnter && this.state.openedOnEnter) {
139
148
  this.refCollection[0].focus();
140
149
  }
@@ -190,7 +199,10 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
190
199
  typeaheadFilteredChildren = [];
191
200
  }
192
201
  if (typeaheadFilteredChildren.length === 0) {
193
- !isCreatable && typeaheadFilteredChildren.push(<SelectOption isDisabled key={0} value={noResultsFoundText} />);
202
+ !isCreatable &&
203
+ typeaheadFilteredChildren.push(
204
+ <SelectOption isDisabled key={0} value={noResultsFoundText} isNoResultsOption />
205
+ );
194
206
  }
195
207
  if (isCreatable && e.target.value !== '') {
196
208
  const newValue = e.target.value;
@@ -357,10 +369,11 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
357
369
  ouiaId,
358
370
  createText,
359
371
  noResultsFoundText,
372
+ hasInlineFilter,
360
373
  ...props
361
374
  } = this.props;
362
375
  /* eslint-enable @typescript-eslint/no-unused-vars */
363
- const { openedOnEnter, typeaheadInputValue, typeaheadActiveChild } = this.state;
376
+ const { openedOnEnter, typeaheadInputValue, typeaheadActiveChild, typeaheadFilteredChildren } = this.state;
364
377
  const selectToggleId = toggleId || `pf-toggle-id-${currentId++}`;
365
378
  let childPlaceholderText = null;
366
379
  if (!customContent) {
@@ -371,6 +384,25 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
371
384
  (children[0] && this.getDisplay(children[0].props.value, 'node'));
372
385
  }
373
386
  }
387
+
388
+ const hasOnClear = onClear !== Select.defaultProps.onClear;
389
+ const hasAnySelections =
390
+ selections && (Array.isArray(selections) ? (selections.length > 0 ? true : false) : selections !== '');
391
+ const clearBtn = (
392
+ <button
393
+ className={css(buttonStyles.button, buttonStyles.modifiers.plain, styles.selectToggleClear)}
394
+ onClick={e => {
395
+ this.clearSelection(e);
396
+ onClear(e);
397
+ }}
398
+ aria-label={ariaLabelClear}
399
+ type="button"
400
+ disabled={isDisabled}
401
+ >
402
+ <TimesCircleIcon aria-hidden />
403
+ </button>
404
+ );
405
+
374
406
  let selectedChips = null;
375
407
  if (variant === SelectVariant.typeaheadMulti) {
376
408
  selectedChips = (
@@ -385,6 +417,36 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
385
417
  );
386
418
  }
387
419
 
420
+ let filterWithChildren = children;
421
+ if (hasInlineFilter) {
422
+ const filterBox = (
423
+ <React.Fragment>
424
+ <div key="inline-filter" className={css(styles.selectMenuInput)}>
425
+ <input
426
+ key="inline-filter-input"
427
+ type="search"
428
+ className={css(formStyles.formControl, formStyles.modifiers.search)}
429
+ onChange={this.onChange}
430
+ onKeyDown={event => {
431
+ if (event.key === KeyTypes.ArrowUp) {
432
+ this.handleArrowKeys(0, 'up');
433
+ } else if (event.key === KeyTypes.ArrowDown) {
434
+ this.handleArrowKeys(0, 'down');
435
+ }
436
+ }}
437
+ ref={this.filterRef}
438
+ autoComplete="off"
439
+ ></input>
440
+ </div>
441
+ <Divider key="inline-filter-divider" />
442
+ </React.Fragment>
443
+ );
444
+ this.refCollection[0] = this.filterRef.current;
445
+ filterWithChildren = [filterBox, ...(typeaheadFilteredChildren as React.ReactElement[])].map((option, index) =>
446
+ React.cloneElement(option, { key: index })
447
+ );
448
+ }
449
+
388
450
  return (
389
451
  <div
390
452
  className={css(
@@ -414,6 +476,7 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
414
476
  ariaLabelToggle={ariaLabelToggle}
415
477
  handleTypeaheadKeys={this.handleTypeaheadKeys}
416
478
  isDisabled={isDisabled}
479
+ hasClearButton={hasOnClear}
417
480
  >
418
481
  {customContent && (
419
482
  <div className={css(styles.selectToggleWrapper)}>
@@ -427,6 +490,7 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
427
490
  <span className={css(styles.selectToggleText)}>
428
491
  {this.getDisplay(selections as string, 'node') || placeholderText || childPlaceholderText}
429
492
  </span>
493
+ {hasOnClear && hasAnySelections && clearBtn}
430
494
  </div>
431
495
  )}
432
496
  {variant === SelectVariant.checkbox && !customContent && (
@@ -440,6 +504,7 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
440
504
  </div>
441
505
  )}
442
506
  </div>
507
+ {hasOnClear && hasAnySelections && clearBtn}
443
508
  </React.Fragment>
444
509
  )}
445
510
  {variant === SelectVariant.typeahead && !customContent && (
@@ -465,20 +530,7 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
465
530
  disabled={isDisabled}
466
531
  />
467
532
  </div>
468
- {(selections || typeaheadInputValue) && (
469
- <button
470
- className={css(buttonStyles.button, buttonStyles.modifiers.plain, styles.selectToggleClear)}
471
- onClick={e => {
472
- this.clearSelection(e);
473
- onClear(e);
474
- }}
475
- aria-label={ariaLabelClear}
476
- type="button"
477
- disabled={isDisabled}
478
- >
479
- <TimesCircleIcon aria-hidden />
480
- </button>
481
- )}
533
+ {(selections || typeaheadInputValue) && clearBtn}
482
534
  </React.Fragment>
483
535
  )}
484
536
  {variant === SelectVariant.typeaheadMulti && !customContent && (
@@ -501,20 +553,8 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
501
553
  disabled={isDisabled}
502
554
  />
503
555
  </div>
504
- {((selections && (Array.isArray(selections) && selections.length > 0)) || typeaheadInputValue) && (
505
- <button
506
- className={css(buttonStyles.button, buttonStyles.modifiers.plain, styles.selectToggleClear)}
507
- onClick={e => {
508
- this.clearSelection(e);
509
- onClear(e);
510
- }}
511
- aria-label={ariaLabelClear}
512
- type="button"
513
- disabled={isDisabled}
514
- >
515
- <TimesCircleIcon aria-hidden />
516
- </button>
517
- )}
556
+ {((selections && (Array.isArray(selections) && selections.length > 0)) || typeaheadInputValue) &&
557
+ clearBtn}
518
558
  </React.Fragment>
519
559
  )}
520
560
  </SelectToggle>
@@ -557,8 +597,9 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
557
597
  sendRef={this.sendRef}
558
598
  keyHandler={this.handleArrowKeys}
559
599
  maxHeight={maxHeight}
600
+ hasInlineFilter={hasInlineFilter}
560
601
  >
561
- {children}
602
+ {filterWithChildren}
562
603
  </SelectMenu>
563
604
  )}
564
605
  {(variant === SelectVariant.typeahead || variant === SelectVariant.typeaheadMulti) &&
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import styles from '@patternfly/react-styles/css/components/Select/select';
3
3
  import { default as formStyles } from '@patternfly/react-styles/css/components/Form/form';
4
4
  import { css } from '@patternfly/react-styles';
5
- import { SelectOptionObject } from './SelectOption';
5
+ import { SelectOptionObject, SelectOption } from './SelectOption';
6
6
  import { SelectConsumer, SelectVariant } from './selectConstants';
7
7
  import { Omit, PickOptional } from '../../helpers/typeUtils';
8
8
 
@@ -36,6 +36,8 @@ export interface SelectMenuProps extends Omit<React.HTMLProps<HTMLElement>, 'che
36
36
  sendRef?: (ref: React.ReactNode, index: number) => void;
37
37
  /** Internal callback for keyboard navigation */
38
38
  keyHandler?: (index: number, position: string) => void;
39
+ /** Flag indicating select has an inline text input for filtering */
40
+ hasInlineFilter?: boolean;
39
41
  }
40
42
 
41
43
  export class SelectMenu extends React.Component<SelectMenuProps> {
@@ -48,7 +50,8 @@ export class SelectMenu extends React.Component<SelectMenuProps> {
48
50
  maxHeight: '',
49
51
  sendRef: () => {},
50
52
  keyHandler: () => {},
51
- isCustomContent: false
53
+ isCustomContent: false,
54
+ hasInlineFilter: false
52
55
  };
53
56
 
54
57
  extendChildren() {
@@ -83,13 +86,15 @@ export class SelectMenu extends React.Component<SelectMenuProps> {
83
86
  });
84
87
  }
85
88
 
86
- extendCheckboxChildren() {
87
- const { children, isGrouped, checked, sendRef, keyHandler } = this.props;
88
- const childrenArray = children as React.ReactElement[];
89
+ extendCheckboxChildren(children: React.ReactElement[]) {
90
+ const { isGrouped, checked, sendRef, keyHandler, hasInlineFilter } = this.props;
91
+ let index = hasInlineFilter ? 1 : 0;
89
92
  if (isGrouped) {
90
- let index = 0;
91
- return React.Children.map(childrenArray, (group: React.ReactElement) =>
92
- React.cloneElement(group, {
93
+ return React.Children.map(children, (group: React.ReactElement) => {
94
+ if (group.type === SelectOption) {
95
+ return group;
96
+ }
97
+ return React.cloneElement(group, {
93
98
  titleId: group.props.label.replace(/\W/g, '-'),
94
99
  children: (
95
100
  <fieldset
@@ -106,20 +111,16 @@ export class SelectMenu extends React.Component<SelectMenuProps> {
106
111
  )}
107
112
  </fieldset>
108
113
  )
109
- })
110
- );
114
+ });
115
+ });
111
116
  }
112
- return (
113
- <React.Fragment>
114
- {React.Children.map(childrenArray, (child: React.ReactElement, index: number) =>
115
- React.cloneElement(child, {
116
- isChecked: checked && checked.includes(child.props.value),
117
- sendRef,
118
- keyHandler,
119
- index
120
- })
121
- )}
122
- </React.Fragment>
117
+ return React.Children.map(children, (child: React.ReactElement) =>
118
+ React.cloneElement(child, {
119
+ isChecked: checked && checked.includes(child.props.value),
120
+ sendRef,
121
+ keyHandler,
122
+ index: index++
123
+ })
123
124
  );
124
125
  }
125
126
 
@@ -141,10 +142,10 @@ export class SelectMenu extends React.Component<SelectMenuProps> {
141
142
  createText,
142
143
  'aria-label': ariaLabel,
143
144
  'aria-labelledby': ariaLabelledBy,
145
+ hasInlineFilter,
144
146
  ...props
145
147
  } = this.props;
146
148
  /* eslint-enable @typescript-eslint/no-unused-vars */
147
-
148
149
  return (
149
150
  <SelectConsumer>
150
151
  {({ variant }) => (
@@ -180,7 +181,11 @@ export class SelectMenu extends React.Component<SelectMenuProps> {
180
181
  aria-labelledby={(!ariaLabel && ariaLabelledBy) || null}
181
182
  className={css(formStyles.formFieldset)}
182
183
  >
183
- {this.extendCheckboxChildren()}
184
+ {hasInlineFilter && [
185
+ (children as React.ReactElement[]).shift(),
186
+ ...this.extendCheckboxChildren(children as React.ReactElement[])
187
+ ]}
188
+ {!hasInlineFilter && this.extendCheckboxChildren(children as React.ReactElement[])}
184
189
  </fieldset>
185
190
  </div>
186
191
  </FocusTrap>
@@ -27,6 +27,8 @@ export interface SelectOptionProps extends Omit<React.HTMLProps<HTMLElement>, 't
27
27
  isDisabled?: boolean;
28
28
  /** Flag indicating if the option acts as a placeholder */
29
29
  isPlaceholder?: boolean;
30
+ /** Flad indicating if the option acts as a "no results" indicator */
31
+ isNoResultsOption?: boolean;
30
32
  /** Internal flag indicating if the option is selected */
31
33
  isSelected?: boolean;
32
34
  /** Internal flag indicating if the option is checked */
@@ -52,6 +54,7 @@ export class SelectOption extends React.Component<SelectOptionProps> {
52
54
  isSelected: false,
53
55
  isChecked: false,
54
56
  isFocused: false,
57
+ isNoResultsOption: false,
55
58
  component: 'button',
56
59
  onClick: () => {},
57
60
  sendRef: () => {},
@@ -59,11 +62,11 @@ export class SelectOption extends React.Component<SelectOptionProps> {
59
62
  };
60
63
 
61
64
  componentDidMount() {
62
- this.props.sendRef(this.ref.current, this.props.index);
65
+ this.props.sendRef(this.props.isDisabled ? null : this.ref.current, this.props.index);
63
66
  }
64
67
 
65
68
  componentDidUpdate() {
66
- this.props.sendRef(this.ref.current, this.props.index);
69
+ this.props.sendRef(this.props.isDisabled ? null : this.ref.current, this.props.index);
67
70
  }
68
71
 
69
72
  onKeyDown = (event: React.KeyboardEvent) => {
@@ -92,6 +95,7 @@ export class SelectOption extends React.Component<SelectOptionProps> {
92
95
  onClick,
93
96
  isDisabled,
94
97
  isPlaceholder,
98
+ isNoResultsOption,
95
99
  isSelected,
96
100
  isChecked,
97
101
  isFocused,
@@ -136,7 +140,7 @@ export class SelectOption extends React.Component<SelectOptionProps> {
136
140
  </Component>
137
141
  </li>
138
142
  )}
139
- {variant === SelectVariant.checkbox && (
143
+ {variant === SelectVariant.checkbox && !isNoResultsOption && (
140
144
  <label
141
145
  {...props}
142
146
  className={css(
@@ -166,6 +170,27 @@ export class SelectOption extends React.Component<SelectOptionProps> {
166
170
  </span>
167
171
  </label>
168
172
  )}
173
+ {variant === SelectVariant.checkbox && isNoResultsOption && (
174
+ <div>
175
+ <Component
176
+ {...props}
177
+ className={css(
178
+ styles.selectMenuItem,
179
+ isSelected && styles.modifiers.selected,
180
+ isDisabled && styles.modifiers.disabled,
181
+ isFocused && styles.modifiers.focus,
182
+ className
183
+ )}
184
+ role="option"
185
+ aria-selected={isSelected || null}
186
+ ref={this.ref}
187
+ onKeyDown={this.onKeyDown}
188
+ type="button"
189
+ >
190
+ {children || value.toString()}
191
+ </Component>
192
+ </div>
193
+ )}
169
194
  </React.Fragment>
170
195
  )}
171
196
  </SelectConsumer>
@@ -43,6 +43,8 @@ export interface SelectToggleProps extends React.HTMLProps<HTMLElement> {
43
43
  ariaLabelToggle?: string;
44
44
  /** Flag for variant, determines toggle rules and interaction */
45
45
  variant?: 'single' | 'checkbox' | 'typeahead' | 'typeaheadmulti';
46
+ /** Flag indicating if select toggle has an clear button */
47
+ hasClearButton?: boolean;
46
48
  }
47
49
 
48
50
  export class SelectToggle extends React.Component<SelectToggleProps> {
@@ -56,6 +58,7 @@ export class SelectToggle extends React.Component<SelectToggleProps> {
56
58
  isActive: false,
57
59
  isPlain: false,
58
60
  isDisabled: false,
61
+ hasClearButton: false,
59
62
  variant: 'single',
60
63
  ariaLabelledBy: '',
61
64
  ariaLabelToggle: '',
@@ -168,12 +171,14 @@ export class SelectToggle extends React.Component<SelectToggleProps> {
168
171
  parentRef,
169
172
  id,
170
173
  type,
174
+ hasClearButton,
171
175
  ariaLabelledBy,
172
176
  ariaLabelToggle,
173
177
  ...props
174
178
  } = this.props;
175
179
  /* eslint-enable @typescript-eslint/no-unused-vars */
176
- const isTypeahead = variant === SelectVariant.typeahead || variant === SelectVariant.typeaheadMulti;
180
+ const isTypeahead =
181
+ variant === SelectVariant.typeahead || variant === SelectVariant.typeaheadMulti || hasClearButton;
177
182
  const toggleProps: {
178
183
  id: string;
179
184
  'aria-labelledby': string;
@@ -170,6 +170,22 @@ describe('checkbox select', () => {
170
170
  expect(view).toMatchSnapshot();
171
171
  });
172
172
 
173
+ test('renders expanded with filtering successfully', () => {
174
+ const view = mount(
175
+ <Select
176
+ variant={SelectVariant.checkbox}
177
+ onSelect={jest.fn()}
178
+ onToggle={jest.fn()}
179
+ onClear={jest.fn()}
180
+ isExpanded
181
+ hasInlineFilter
182
+ >
183
+ {selectOptions}
184
+ </Select>
185
+ );
186
+ expect(view).toMatchSnapshot();
187
+ });
188
+
173
189
  test('renders expanded successfully with custom objects', () => {
174
190
  const view = mount(
175
191
  <Select variant={SelectVariant.checkbox} onSelect={jest.fn()} onToggle={jest.fn()} isExpanded>