@patternfly/react-core 5.0.0-alpha.62 → 5.0.0-alpha.64

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 (236) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
  3. package/dist/esm/components/CalendarMonth/CalendarMonth.js +9 -11
  4. package/dist/esm/components/CalendarMonth/CalendarMonth.js.map +1 -1
  5. package/dist/esm/components/DualListSelector/DualListSelectorControl.d.ts +1 -1
  6. package/dist/esm/components/Menu/MenuItem.d.ts +1 -1
  7. package/dist/esm/components/MenuToggle/MenuToggle.d.ts.map +1 -1
  8. package/dist/esm/components/MenuToggle/MenuToggle.js +3 -1
  9. package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
  10. package/dist/esm/components/Select/Select.d.ts +26 -192
  11. package/dist/esm/components/Select/Select.d.ts.map +1 -1
  12. package/dist/esm/components/Select/Select.js +51 -935
  13. package/dist/esm/components/Select/Select.js.map +1 -1
  14. package/dist/esm/components/Select/SelectGroup.d.ts +7 -8
  15. package/dist/esm/components/Select/SelectGroup.d.ts.map +1 -1
  16. package/dist/esm/components/Select/SelectGroup.js +4 -7
  17. package/dist/esm/components/Select/SelectGroup.js.map +1 -1
  18. package/dist/{js/next → esm}/components/Select/SelectList.d.ts +1 -1
  19. package/dist/esm/components/Select/SelectList.d.ts.map +1 -0
  20. package/dist/esm/{next/components → components}/Select/SelectList.js +1 -1
  21. package/dist/esm/components/Select/SelectList.js.map +1 -0
  22. package/dist/esm/components/Select/SelectOption.d.ts +13 -66
  23. package/dist/esm/components/Select/SelectOption.d.ts.map +1 -1
  24. package/dist/esm/components/Select/SelectOption.js +6 -192
  25. package/dist/esm/components/Select/SelectOption.js.map +1 -1
  26. package/dist/esm/components/Select/index.d.ts +1 -1
  27. package/dist/esm/components/Select/index.d.ts.map +1 -1
  28. package/dist/esm/components/Select/index.js +1 -1
  29. package/dist/esm/components/Select/index.js.map +1 -1
  30. package/dist/esm/deprecated/components/Select/Select.d.ts +199 -0
  31. package/dist/esm/deprecated/components/Select/Select.d.ts.map +1 -0
  32. package/dist/esm/deprecated/components/Select/Select.js +940 -0
  33. package/dist/esm/deprecated/components/Select/Select.js.map +1 -0
  34. package/dist/esm/deprecated/components/Select/SelectGroup.d.ts +13 -0
  35. package/dist/esm/deprecated/components/Select/SelectGroup.d.ts.map +1 -0
  36. package/dist/esm/deprecated/components/Select/SelectGroup.js +13 -0
  37. package/dist/esm/deprecated/components/Select/SelectGroup.js.map +1 -0
  38. package/dist/esm/deprecated/components/Select/SelectMenu.d.ts.map +1 -0
  39. package/dist/esm/{components → deprecated/components}/Select/SelectMenu.js +1 -1
  40. package/dist/esm/deprecated/components/Select/SelectMenu.js.map +1 -0
  41. package/dist/esm/deprecated/components/Select/SelectOption.d.ts +73 -0
  42. package/dist/esm/deprecated/components/Select/SelectOption.d.ts.map +1 -0
  43. package/dist/esm/deprecated/components/Select/SelectOption.js +196 -0
  44. package/dist/esm/deprecated/components/Select/SelectOption.js.map +1 -0
  45. package/dist/esm/deprecated/components/Select/SelectToggle.d.ts.map +1 -0
  46. package/dist/esm/{components → deprecated/components}/Select/SelectToggle.js +2 -2
  47. package/dist/esm/deprecated/components/Select/SelectToggle.js.map +1 -0
  48. package/dist/esm/{next → deprecated}/components/Select/index.d.ts +1 -1
  49. package/dist/esm/deprecated/components/Select/index.d.ts.map +1 -0
  50. package/dist/esm/{next → deprecated}/components/Select/index.js +1 -1
  51. package/dist/esm/deprecated/components/Select/index.js.map +1 -0
  52. package/dist/esm/deprecated/components/Select/selectConstants.d.ts.map +1 -0
  53. package/dist/esm/deprecated/components/Select/selectConstants.js.map +1 -0
  54. package/dist/esm/deprecated/components/index.d.ts +1 -0
  55. package/dist/esm/deprecated/components/index.d.ts.map +1 -1
  56. package/dist/esm/deprecated/components/index.js +1 -0
  57. package/dist/esm/deprecated/components/index.js.map +1 -1
  58. package/dist/esm/next/components/index.d.ts +0 -1
  59. package/dist/esm/next/components/index.d.ts.map +1 -1
  60. package/dist/esm/next/components/index.js +0 -1
  61. package/dist/esm/next/components/index.js.map +1 -1
  62. package/dist/js/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
  63. package/dist/js/components/CalendarMonth/CalendarMonth.js +8 -10
  64. package/dist/js/components/CalendarMonth/CalendarMonth.js.map +1 -1
  65. package/dist/js/components/DualListSelector/DualListSelectorControl.d.ts +1 -1
  66. package/dist/js/components/Menu/MenuItem.d.ts +1 -1
  67. package/dist/js/components/MenuToggle/MenuToggle.d.ts.map +1 -1
  68. package/dist/js/components/MenuToggle/MenuToggle.js +3 -1
  69. package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
  70. package/dist/js/components/Select/Select.d.ts +26 -192
  71. package/dist/js/components/Select/Select.d.ts.map +1 -1
  72. package/dist/js/components/Select/Select.js +51 -936
  73. package/dist/js/components/Select/Select.js.map +1 -1
  74. package/dist/js/components/Select/SelectGroup.d.ts +7 -8
  75. package/dist/js/components/Select/SelectGroup.d.ts.map +1 -1
  76. package/dist/js/components/Select/SelectGroup.js +4 -7
  77. package/dist/js/components/Select/SelectGroup.js.map +1 -1
  78. package/dist/{esm/next → js}/components/Select/SelectList.d.ts +1 -1
  79. package/dist/js/components/Select/SelectList.d.ts.map +1 -0
  80. package/dist/js/{next/components → components}/Select/SelectList.js +1 -1
  81. package/dist/js/components/Select/SelectList.js.map +1 -0
  82. package/dist/js/components/Select/SelectOption.d.ts +13 -66
  83. package/dist/js/components/Select/SelectOption.d.ts.map +1 -1
  84. package/dist/js/components/Select/SelectOption.js +7 -193
  85. package/dist/js/components/Select/SelectOption.js.map +1 -1
  86. package/dist/js/components/Select/index.d.ts +1 -1
  87. package/dist/js/components/Select/index.d.ts.map +1 -1
  88. package/dist/js/components/Select/index.js +1 -1
  89. package/dist/js/components/Select/index.js.map +1 -1
  90. package/dist/js/deprecated/components/Select/Select.d.ts +199 -0
  91. package/dist/js/deprecated/components/Select/Select.d.ts.map +1 -0
  92. package/dist/js/deprecated/components/Select/Select.js +944 -0
  93. package/dist/js/deprecated/components/Select/Select.js.map +1 -0
  94. package/dist/js/deprecated/components/Select/SelectGroup.d.ts +13 -0
  95. package/dist/js/deprecated/components/Select/SelectGroup.d.ts.map +1 -0
  96. package/dist/js/deprecated/components/Select/SelectGroup.js +17 -0
  97. package/dist/js/deprecated/components/Select/SelectGroup.js.map +1 -0
  98. package/dist/js/deprecated/components/Select/SelectMenu.d.ts.map +1 -0
  99. package/dist/js/{components → deprecated/components}/Select/SelectMenu.js +1 -1
  100. package/dist/js/deprecated/components/Select/SelectMenu.js.map +1 -0
  101. package/dist/js/deprecated/components/Select/SelectOption.d.ts +73 -0
  102. package/dist/js/deprecated/components/Select/SelectOption.d.ts.map +1 -0
  103. package/dist/js/deprecated/components/Select/SelectOption.js +200 -0
  104. package/dist/js/deprecated/components/Select/SelectOption.js.map +1 -0
  105. package/dist/js/deprecated/components/Select/SelectToggle.d.ts.map +1 -0
  106. package/dist/js/{components → deprecated/components}/Select/SelectToggle.js +2 -2
  107. package/dist/js/deprecated/components/Select/SelectToggle.js.map +1 -0
  108. package/dist/js/{next → deprecated}/components/Select/index.d.ts +1 -1
  109. package/dist/js/deprecated/components/Select/index.d.ts.map +1 -0
  110. package/dist/js/{next → deprecated}/components/Select/index.js +1 -1
  111. package/dist/js/deprecated/components/Select/index.js.map +1 -0
  112. package/dist/js/deprecated/components/Select/selectConstants.d.ts.map +1 -0
  113. package/dist/js/deprecated/components/Select/selectConstants.js.map +1 -0
  114. package/dist/js/deprecated/components/index.d.ts +1 -0
  115. package/dist/js/deprecated/components/index.d.ts.map +1 -1
  116. package/dist/js/deprecated/components/index.js +1 -0
  117. package/dist/js/deprecated/components/index.js.map +1 -1
  118. package/dist/js/next/components/index.d.ts +0 -1
  119. package/dist/js/next/components/index.d.ts.map +1 -1
  120. package/dist/js/next/components/index.js +0 -1
  121. package/dist/js/next/components/index.js.map +1 -1
  122. package/dist/umd/react-core.min.js +3 -3
  123. package/package.json +2 -2
  124. package/src/components/CalendarMonth/CalendarMonth.tsx +25 -15
  125. package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.test.tsx.snap +22 -31
  126. package/src/components/LoginPage/examples/LoginPageLanguageSelect.tsx +28 -19
  127. package/src/components/MenuToggle/MenuToggle.tsx +2 -1
  128. package/src/components/MenuToggle/__tests__/__snapshots__/MenuToggle.test.tsx.snap +18 -10
  129. package/src/components/MenuToggle/examples/MenuToggle.md +85 -78
  130. package/src/components/MenuToggle/examples/MenuToggleSplitButtonAction.tsx +10 -11
  131. package/src/components/MenuToggle/examples/MenuToggleSplitButtonCheckbox.tsx +4 -17
  132. package/src/components/MenuToggle/examples/MenuToggleSplitButtonCheckboxWithText.tsx +10 -11
  133. package/src/components/MenuToggle/examples/MenuToggleTypeahead.tsx +35 -0
  134. package/src/components/Select/Select.tsx +113 -1475
  135. package/src/components/Select/SelectGroup.tsx +13 -25
  136. package/src/{next/components → components}/Select/SelectList.tsx +1 -1
  137. package/src/components/Select/SelectOption.tsx +22 -452
  138. package/src/components/Select/examples/Select.md +11 -2897
  139. package/src/{next/components → components}/Select/examples/SelectBasic.tsx +1 -2
  140. package/src/{next/components → components}/Select/examples/SelectCheckbox.tsx +1 -2
  141. package/src/{next/components → components}/Select/examples/SelectGrouped.tsx +1 -2
  142. package/src/{next/components → components}/Select/examples/SelectMultiTypeahead.tsx +4 -1
  143. package/src/{next/components → components}/Select/examples/SelectTypeahead.tsx +4 -1
  144. package/src/components/Select/index.ts +1 -1
  145. package/src/components/Toolbar/__tests__/Toolbar.test.tsx +3 -21
  146. package/src/components/Toolbar/__tests__/__snapshots__/Toolbar.test.tsx.snap +12 -124
  147. package/src/components/Toolbar/examples/Toolbar.md +0 -1
  148. package/src/components/Toolbar/examples/ToolbarComponentManagedToggleGroups.tsx +59 -63
  149. package/src/components/Toolbar/examples/ToolbarConsumerManagedToggleGroups.tsx +58 -62
  150. package/src/components/Toolbar/examples/ToolbarCustomChipGroupContent.tsx +107 -23
  151. package/src/components/Toolbar/examples/ToolbarGroups.tsx +96 -59
  152. package/src/components/Toolbar/examples/ToolbarStacked.tsx +56 -39
  153. package/src/components/Toolbar/examples/ToolbarWithFilters.tsx +115 -28
  154. package/src/components/Tooltip/examples/TooltipOptions.tsx +53 -23
  155. package/src/demos/Card/Card.md +39 -23
  156. package/src/demos/CardDemos.md +99 -46
  157. package/src/demos/Toolbar.md +51 -21
  158. package/src/demos/examples/Tabs/TabsAndTable.tsx +5 -22
  159. package/src/deprecated/components/Select/Select.tsx +1495 -0
  160. package/src/deprecated/components/Select/SelectGroup.tsx +36 -0
  161. package/src/{components → deprecated/components}/Select/SelectMenu.tsx +2 -2
  162. package/src/deprecated/components/Select/SelectOption.tsx +461 -0
  163. package/src/{components → deprecated/components}/Select/SelectToggle.tsx +3 -3
  164. package/src/{components → deprecated/components}/Select/__tests__/Select.test.tsx +1 -1
  165. package/src/deprecated/components/Select/examples/Select.md +2937 -0
  166. package/src/{next → deprecated}/components/Select/index.ts +1 -1
  167. package/src/deprecated/components/index.ts +1 -0
  168. package/src/next/components/index.ts +0 -1
  169. package/dist/esm/components/Select/SelectMenu.d.ts.map +0 -1
  170. package/dist/esm/components/Select/SelectMenu.js.map +0 -1
  171. package/dist/esm/components/Select/SelectToggle.d.ts.map +0 -1
  172. package/dist/esm/components/Select/SelectToggle.js.map +0 -1
  173. package/dist/esm/components/Select/selectConstants.d.ts.map +0 -1
  174. package/dist/esm/components/Select/selectConstants.js.map +0 -1
  175. package/dist/esm/next/components/Select/Select.d.ts +0 -33
  176. package/dist/esm/next/components/Select/Select.d.ts.map +0 -1
  177. package/dist/esm/next/components/Select/Select.js +0 -56
  178. package/dist/esm/next/components/Select/Select.js.map +0 -1
  179. package/dist/esm/next/components/Select/SelectGroup.d.ts +0 -12
  180. package/dist/esm/next/components/Select/SelectGroup.d.ts.map +0 -1
  181. package/dist/esm/next/components/Select/SelectGroup.js +0 -10
  182. package/dist/esm/next/components/Select/SelectGroup.js.map +0 -1
  183. package/dist/esm/next/components/Select/SelectList.d.ts.map +0 -1
  184. package/dist/esm/next/components/Select/SelectList.js.map +0 -1
  185. package/dist/esm/next/components/Select/SelectOption.d.ts +0 -20
  186. package/dist/esm/next/components/Select/SelectOption.d.ts.map +0 -1
  187. package/dist/esm/next/components/Select/SelectOption.js +0 -10
  188. package/dist/esm/next/components/Select/SelectOption.js.map +0 -1
  189. package/dist/esm/next/components/Select/index.d.ts.map +0 -1
  190. package/dist/esm/next/components/Select/index.js.map +0 -1
  191. package/dist/js/components/Select/SelectMenu.d.ts.map +0 -1
  192. package/dist/js/components/Select/SelectMenu.js.map +0 -1
  193. package/dist/js/components/Select/SelectToggle.d.ts.map +0 -1
  194. package/dist/js/components/Select/SelectToggle.js.map +0 -1
  195. package/dist/js/components/Select/selectConstants.d.ts.map +0 -1
  196. package/dist/js/components/Select/selectConstants.js.map +0 -1
  197. package/dist/js/next/components/Select/Select.d.ts +0 -33
  198. package/dist/js/next/components/Select/Select.d.ts.map +0 -1
  199. package/dist/js/next/components/Select/Select.js +0 -59
  200. package/dist/js/next/components/Select/Select.js.map +0 -1
  201. package/dist/js/next/components/Select/SelectGroup.d.ts +0 -12
  202. package/dist/js/next/components/Select/SelectGroup.d.ts.map +0 -1
  203. package/dist/js/next/components/Select/SelectGroup.js +0 -14
  204. package/dist/js/next/components/Select/SelectGroup.js.map +0 -1
  205. package/dist/js/next/components/Select/SelectList.d.ts.map +0 -1
  206. package/dist/js/next/components/Select/SelectList.js.map +0 -1
  207. package/dist/js/next/components/Select/SelectOption.d.ts +0 -20
  208. package/dist/js/next/components/Select/SelectOption.d.ts.map +0 -1
  209. package/dist/js/next/components/Select/SelectOption.js +0 -14
  210. package/dist/js/next/components/Select/SelectOption.js.map +0 -1
  211. package/dist/js/next/components/Select/index.d.ts.map +0 -1
  212. package/dist/js/next/components/Select/index.js.map +0 -1
  213. package/src/components/MenuToggle/examples/MenuToggleSplitButtonActionPrimary.tsx +0 -58
  214. package/src/components/MenuToggle/examples/MenuToggleSplitButtonActionSecondary.tsx +0 -58
  215. package/src/components/MenuToggle/examples/MenuToggleSplitButtonCheckboxPrimary.tsx +0 -55
  216. package/src/components/MenuToggle/examples/MenuToggleSplitButtonCheckboxSecondary.tsx +0 -55
  217. package/src/next/components/Select/Select.tsx +0 -133
  218. package/src/next/components/Select/SelectGroup.tsx +0 -24
  219. package/src/next/components/Select/SelectOption.tsx +0 -31
  220. package/src/next/components/Select/examples/Select.md +0 -38
  221. /package/dist/esm/{components → deprecated/components}/Select/SelectMenu.d.ts +0 -0
  222. /package/dist/esm/{components → deprecated/components}/Select/SelectToggle.d.ts +0 -0
  223. /package/dist/esm/{components → deprecated/components}/Select/selectConstants.d.ts +0 -0
  224. /package/dist/esm/{components → deprecated/components}/Select/selectConstants.js +0 -0
  225. /package/dist/js/{components → deprecated/components}/Select/SelectMenu.d.ts +0 -0
  226. /package/dist/js/{components → deprecated/components}/Select/SelectToggle.d.ts +0 -0
  227. /package/dist/js/{components → deprecated/components}/Select/selectConstants.d.ts +0 -0
  228. /package/dist/js/{components → deprecated/components}/Select/selectConstants.js +0 -0
  229. /package/src/{components → deprecated/components}/Select/__tests__/SelectGroup.test.tsx +0 -0
  230. /package/src/{components → deprecated/components}/Select/__tests__/SelectOption.test.tsx +0 -0
  231. /package/src/{components → deprecated/components}/Select/__tests__/SelectToggle.test.tsx +0 -0
  232. /package/src/{components → deprecated/components}/Select/__tests__/__snapshots__/Select.test.tsx.snap +0 -0
  233. /package/src/{components → deprecated/components}/Select/__tests__/__snapshots__/SelectGroup.test.tsx.snap +0 -0
  234. /package/src/{components → deprecated/components}/Select/__tests__/__snapshots__/SelectOption.test.tsx.snap +0 -0
  235. /package/src/{components → deprecated/components}/Select/__tests__/__snapshots__/SelectToggle.test.tsx.snap +0 -0
  236. /package/src/{components → deprecated/components}/Select/selectConstants.tsx +0 -0
@@ -2,943 +2,58 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Select = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const React = tslib_1.__importStar(require("react"));
6
- const select_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/Select/select"));
7
- const badge_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/Badge/badge"));
8
- const form_control_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/FormControl/form-control"));
9
- const button_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/Button/button"));
5
+ const react_1 = tslib_1.__importDefault(require("react"));
10
6
  const react_styles_1 = require("@patternfly/react-styles");
11
- const times_circle_icon_1 = tslib_1.__importDefault(require('@patternfly/react-icons/dist/js/icons/times-circle-icon'));
12
- const check_circle_icon_1 = tslib_1.__importDefault(require('@patternfly/react-icons/dist/js/icons/check-circle-icon'));
13
- const exclamation_triangle_icon_1 = tslib_1.__importDefault(require('@patternfly/react-icons/dist/js/icons/exclamation-triangle-icon'));
14
- const exclamation_circle_icon_1 = tslib_1.__importDefault(require('@patternfly/react-icons/dist/js/icons/exclamation-circle-icon'));
15
- const SelectMenu_1 = require("./SelectMenu");
16
- const SelectOption_1 = require("./SelectOption");
17
- const SelectGroup_1 = require("./SelectGroup");
18
- const SelectToggle_1 = require("./SelectToggle");
19
- const selectConstants_1 = require("./selectConstants");
20
- const ChipGroup_1 = require("../ChipGroup");
21
- const Chip_1 = require("../Chip");
22
- const Spinner_1 = require("../Spinner");
23
- const helpers_1 = require("../../helpers");
24
- const constants_1 = require("../../helpers/constants");
25
- const Divider_1 = require("../Divider");
7
+ const Menu_1 = require("../Menu");
26
8
  const Popper_1 = require("../../helpers/Popper/Popper");
27
- const favorites_1 = require("../../helpers/favorites");
28
- const constants_2 = require("../../helpers/constants");
29
- const util_1 = require("../../helpers/util");
30
- // seed for the aria-labelledby ID
31
- let currentId = 0;
32
- class Select extends React.Component {
33
- constructor() {
34
- super(...arguments);
35
- this.parentRef = React.createRef();
36
- this.menuComponentRef = React.createRef();
37
- this.filterRef = React.createRef();
38
- this.clearRef = React.createRef();
39
- this.inputRef = React.createRef();
40
- this.refCollection = [[]];
41
- this.optionContainerRefCollection = [];
42
- this.footerRef = React.createRef();
43
- this.state = {
44
- focusFirstOption: false,
45
- typeaheadInputValue: null,
46
- typeaheadFilteredChildren: React.Children.toArray(this.props.children),
47
- favoritesGroup: [],
48
- typeaheadCurrIndex: -1,
49
- typeaheadStoredIndex: -1,
50
- creatableValue: '',
51
- tabbedIntoFavoritesMenu: false,
52
- ouiaStateId: (0, helpers_1.getDefaultOUIAId)(Select.displayName, this.props.variant),
53
- viewMoreNextIndex: -1
54
- };
55
- this.getTypeaheadActiveChild = (typeaheadCurrIndex) => this.refCollection[typeaheadCurrIndex] ? this.refCollection[typeaheadCurrIndex][0] : null;
56
- this.componentDidUpdate = (prevProps, prevState) => {
57
- if (this.props.hasInlineFilter) {
58
- this.refCollection[0][0] = this.filterRef.current;
59
- }
60
- // Move focus to top of the menu if state.focusFirstOption was updated to true and the menu does not have custom content
61
- if (!prevState.focusFirstOption && this.state.focusFirstOption && !this.props.customContent) {
62
- const firstRef = this.refCollection.find(ref =>
63
- // If a select option is disabled then ref[0] will be undefined, so we want to return
64
- // the first ref that both a) is not null and b) is not disabled.
65
- ref !== null && ref[0]);
66
- if (firstRef && firstRef[0]) {
67
- firstRef[0].focus();
68
- }
69
- }
70
- else if (
71
- // if viewMoreNextIndex is not -1, view more was clicked, set focus on first newly loaded item
72
- this.state.viewMoreNextIndex !== -1 &&
73
- this.refCollection.length > this.state.viewMoreNextIndex &&
74
- this.props.loadingVariant !== 'spinner' &&
75
- this.refCollection[this.state.viewMoreNextIndex][0] &&
76
- this.props.variant !== 'typeahead' && // do not hard focus newly added items for typeahead variants
77
- this.props.variant !== 'typeaheadmulti') {
78
- this.refCollection[this.state.viewMoreNextIndex][0].focus();
79
- this.setState({ viewMoreNextIndex: -1 });
80
- }
81
- const checkUpdatedChildren = (prevChildren, currChildren) => Array.from(prevChildren).some((prevChild, index) => {
82
- const prevChildProps = prevChild.props;
83
- const currChild = currChildren[index];
84
- const { props: currChildProps } = currChild;
85
- if (prevChildProps && currChildProps) {
86
- return (prevChildProps.value !== currChildProps.value ||
87
- prevChildProps.label !== currChildProps.label ||
88
- prevChildProps.isDisabled !== currChildProps.isDisabled ||
89
- prevChildProps.isPlaceholder !== currChildProps.isPlaceholder);
90
- }
91
- else {
92
- return prevChild !== currChild;
93
- }
94
- });
95
- const hasUpdatedChildren = prevProps.children.length !== this.props.children.length ||
96
- checkUpdatedChildren(prevProps.children, this.props.children) ||
97
- (this.props.isGrouped &&
98
- Array.from(prevProps.children).some((prevChild, index) => prevChild.type === SelectGroup_1.SelectGroup &&
99
- prevChild.props.children &&
100
- this.props.children[index].props.children &&
101
- (prevChild.props.children.length !== this.props.children[index].props.children.length ||
102
- checkUpdatedChildren(prevChild.props.children, this.props.children[index].props.children))));
103
- if (hasUpdatedChildren) {
104
- this.updateTypeAheadFilteredChildren(prevState.typeaheadInputValue || '', null);
105
- }
106
- // for menus with favorites,
107
- // if the number of favorites or typeahead filtered children has changed, the generated
108
- // list of favorites needs to be updated
109
- if (this.props.onFavorite &&
110
- (this.props.favorites.length !== prevProps.favorites.length ||
111
- this.state.typeaheadFilteredChildren !== prevState.typeaheadFilteredChildren)) {
112
- const tempRenderableChildren = this.props.variant === 'typeahead' || this.props.variant === 'typeaheadmulti'
113
- ? this.state.typeaheadFilteredChildren
114
- : this.props.children;
115
- const renderableFavorites = (0, favorites_1.createRenderableFavorites)(tempRenderableChildren, this.props.isGrouped, this.props.favorites);
116
- const favoritesGroup = renderableFavorites.length
117
- ? [
118
- React.createElement(SelectGroup_1.SelectGroup, { key: "favorites", label: this.props.favoritesLabel }, renderableFavorites),
119
- React.createElement(Divider_1.Divider, { key: "favorites-group-divider" })
120
- ]
121
- : [];
122
- this.setState({ favoritesGroup });
123
- }
124
- };
125
- this.onEnter = () => {
126
- this.setState({ focusFirstOption: true });
127
- };
128
- this.onToggle = (e, isExpanded) => {
129
- const { isInputValuePersisted, onSelect, onToggle, hasInlineFilter } = this.props;
130
- if (!isExpanded && isInputValuePersisted && onSelect) {
131
- onSelect(undefined, this.inputRef.current ? this.inputRef.current.value : '');
132
- }
133
- if (isExpanded && hasInlineFilter) {
134
- this.setState({
135
- focusFirstOption: true
136
- });
137
- }
138
- onToggle(e, isExpanded);
139
- };
140
- this.onClose = () => {
141
- const { isInputFilterPersisted } = this.props;
142
- this.setState(Object.assign(Object.assign({ focusFirstOption: false, typeaheadInputValue: null }, (!isInputFilterPersisted && {
143
- typeaheadFilteredChildren: React.Children.toArray(this.props.children)
144
- })), { typeaheadCurrIndex: -1, tabbedIntoFavoritesMenu: false, viewMoreNextIndex: -1 }));
145
- };
146
- this.onChange = (e) => {
147
- if (e.target.value.toString() !== '' && !this.props.isOpen) {
148
- this.onToggle(e, true);
149
- }
150
- if (this.props.onTypeaheadInputChanged) {
151
- this.props.onTypeaheadInputChanged(e.target.value.toString());
152
- }
153
- this.setState({
154
- typeaheadCurrIndex: -1,
155
- typeaheadInputValue: e.target.value,
156
- creatableValue: e.target.value
157
- });
158
- this.updateTypeAheadFilteredChildren(e.target.value.toString(), e);
159
- this.refCollection = [[]];
160
- };
161
- this.updateTypeAheadFilteredChildren = (typeaheadInputValue, e) => {
162
- let typeaheadFilteredChildren;
163
- const { onFilter, isCreatable, isCreateOptionOnTop, onCreateOption, createText, noResultsFoundText, children, isGrouped, isCreateSelectOptionObject, loadingVariant } = this.props;
164
- if (onFilter) {
165
- /* The updateTypeAheadFilteredChildren callback is not only called on input changes but also when the children change.
166
- * In this case the e is null but we can get the typeaheadInputValue from the state.
167
- */
168
- typeaheadFilteredChildren = onFilter(e, e ? e.target.value : typeaheadInputValue) || children;
169
- }
170
- else {
171
- let input;
172
- try {
173
- input = new RegExp(typeaheadInputValue.toString(), 'i');
174
- }
175
- catch (err) {
176
- input = new RegExp(typeaheadInputValue.toString().replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'i');
177
- }
178
- const childrenArray = React.Children.toArray(children);
179
- if (isGrouped) {
180
- const childFilter = (child) => child.props.value &&
181
- child.props.value.toString &&
182
- this.getDisplay(child.props.value.toString(), 'text').search(input) === 0;
183
- typeaheadFilteredChildren =
184
- typeaheadInputValue.toString() !== ''
185
- ? React.Children.map(children, group => {
186
- if (React.isValidElement(group) &&
187
- group.type === SelectGroup_1.SelectGroup) {
188
- const filteredGroupChildren = React.Children.toArray(group.props.children).filter(childFilter);
189
- if (filteredGroupChildren.length > 0) {
190
- return React.cloneElement(group, {
191
- titleId: group.props.label && group.props.label.replace(/\W/g, '-'),
192
- children: filteredGroupChildren
193
- });
194
- }
195
- }
196
- else {
197
- return React.Children.toArray(group).filter(childFilter);
198
- }
199
- })
200
- : childrenArray;
201
- }
202
- else {
203
- typeaheadFilteredChildren =
204
- typeaheadInputValue.toString() !== ''
205
- ? childrenArray.filter(child => {
206
- const valueToCheck = child.props.value;
207
- // Dividers don't have value and should not be filtered
208
- if (!valueToCheck) {
209
- return true;
210
- }
211
- const isSelectOptionObject = typeof valueToCheck !== 'string' &&
212
- valueToCheck.toString &&
213
- valueToCheck.compareTo;
214
- // View more option should be returned as not a match
215
- if (loadingVariant !== 'spinner' && (loadingVariant === null || loadingVariant === void 0 ? void 0 : loadingVariant.text) === valueToCheck) {
216
- return true;
217
- }
218
- // spinner should be returned as not a match
219
- if (loadingVariant === 'spinner' && valueToCheck === 'loading') {
220
- return true;
221
- }
222
- if (isSelectOptionObject) {
223
- return valueToCheck.compareTo(typeaheadInputValue);
224
- }
225
- else {
226
- return this.getDisplay(child.props.value.toString(), 'text').search(input) === 0;
227
- }
228
- })
229
- : childrenArray;
230
- }
231
- }
232
- if (!typeaheadFilteredChildren) {
233
- typeaheadFilteredChildren = [];
234
- }
235
- if (typeaheadFilteredChildren.length === 0) {
236
- !isCreatable &&
237
- typeaheadFilteredChildren.push(React.createElement(SelectOption_1.SelectOption, { isDisabled: true, key: "no-results", value: noResultsFoundText, isNoResultsOption: true }));
238
- }
239
- if (isCreatable && typeaheadInputValue !== '') {
240
- const newValue = typeaheadInputValue;
241
- if (!typeaheadFilteredChildren.find((i) => i.props.value && i.props.value.toString().toLowerCase() === newValue.toString().toLowerCase())) {
242
- const newOptionValue = isCreateSelectOptionObject
243
- ? {
244
- toString: () => newValue,
245
- compareTo: value => this.toString()
246
- .toLowerCase()
247
- .includes(value.toString().toLowerCase())
248
- }
249
- : newValue;
250
- const createSelectOption = (React.createElement(SelectOption_1.SelectOption, { key: `create ${newValue}`, value: newOptionValue, onClick: () => onCreateOption && onCreateOption(newValue) },
251
- createText,
252
- " \"",
253
- newValue,
254
- "\""));
255
- if (isCreateOptionOnTop) {
256
- typeaheadFilteredChildren.unshift(createSelectOption);
257
- }
258
- else {
259
- typeaheadFilteredChildren.push(createSelectOption);
260
- }
261
- }
262
- }
263
- this.setState({
264
- typeaheadFilteredChildren
265
- });
266
- };
267
- this.onClick = (e) => {
268
- if (!this.props.isOpen) {
269
- this.onToggle(e, true);
270
- }
271
- };
272
- this.clearSelection = (_e) => {
273
- this.setState({
274
- typeaheadInputValue: null,
275
- typeaheadFilteredChildren: React.Children.toArray(this.props.children),
276
- typeaheadCurrIndex: -1
277
- });
278
- };
279
- this.sendRef = (optionRef, favoriteRef, optionContainerRef, index) => {
280
- this.refCollection[index] = [optionRef, favoriteRef];
281
- this.optionContainerRefCollection[index] = optionContainerRef;
282
- };
283
- this.handleMenuKeys = (index, innerIndex, position) => {
284
- (0, helpers_1.keyHandler)(index, innerIndex, position, this.refCollection, this.refCollection);
285
- if (this.props.variant === selectConstants_1.SelectVariant.typeahead || this.props.variant === selectConstants_1.SelectVariant.typeaheadMulti) {
286
- if (position !== 'tab') {
287
- this.handleTypeaheadKeys(position);
288
- }
289
- }
290
- };
291
- this.moveFocus = (nextIndex, updateCurrentIndex = true) => {
292
- const { isCreatable, createText } = this.props;
293
- const hasDescriptionElm = Boolean(this.refCollection[nextIndex][0] && this.refCollection[nextIndex][0].classList.contains('pf-m-description'));
294
- const isLoad = Boolean(this.refCollection[nextIndex][0] && this.refCollection[nextIndex][0].classList.contains('pf-m-load'));
295
- const optionTextElm = hasDescriptionElm
296
- ? this.refCollection[nextIndex][0].firstElementChild
297
- : this.refCollection[nextIndex][0];
298
- let typeaheadInputValue = '';
299
- if (isCreatable && optionTextElm.textContent.includes(createText)) {
300
- typeaheadInputValue = this.state.creatableValue;
301
- }
302
- else if (optionTextElm && !isLoad) {
303
- // !isLoad prevents the view more button text from appearing the typeahead input
304
- typeaheadInputValue = optionTextElm.textContent;
305
- }
306
- this.setState(prevState => ({
307
- typeaheadCurrIndex: updateCurrentIndex ? nextIndex : prevState.typeaheadCurrIndex,
308
- typeaheadStoredIndex: nextIndex,
309
- typeaheadInputValue
310
- }));
311
- };
312
- this.switchFocusToFavoriteMenu = () => {
313
- const { typeaheadCurrIndex, typeaheadStoredIndex } = this.state;
314
- let indexForFocus = 0;
315
- if (typeaheadCurrIndex !== -1) {
316
- indexForFocus = typeaheadCurrIndex;
317
- }
318
- else if (typeaheadStoredIndex !== -1) {
319
- indexForFocus = typeaheadStoredIndex;
320
- }
321
- if (this.refCollection[indexForFocus] !== null && this.refCollection[indexForFocus][0] !== null) {
322
- this.refCollection[indexForFocus][0].focus();
323
- }
324
- else {
325
- this.clearRef.current.focus();
326
- }
327
- this.setState({
328
- tabbedIntoFavoritesMenu: true,
329
- typeaheadCurrIndex: -1
330
- });
331
- };
332
- this.moveFocusToLastMenuItem = () => {
333
- const refCollectionLen = this.refCollection.length;
334
- if (refCollectionLen > 0 &&
335
- this.refCollection[refCollectionLen - 1] !== null &&
336
- this.refCollection[refCollectionLen - 1][0] !== null) {
337
- this.refCollection[refCollectionLen - 1][0].focus();
338
- }
339
- };
340
- this.handleTypeaheadKeys = (position, shiftKey = false) => {
341
- const { isOpen, onFavorite, isCreatable } = this.props;
342
- const { typeaheadCurrIndex, tabbedIntoFavoritesMenu } = this.state;
343
- const typeaheadActiveChild = this.getTypeaheadActiveChild(typeaheadCurrIndex);
344
- if (isOpen) {
345
- if (position === 'enter') {
346
- if ((typeaheadCurrIndex !== -1 || (isCreatable && this.refCollection.length === 1)) && // do not allow selection without moving to an initial option unless it is a single create option
347
- (typeaheadActiveChild || (this.refCollection[0] && this.refCollection[0][0]))) {
348
- if (typeaheadActiveChild) {
349
- if (!typeaheadActiveChild.classList.contains('pf-m-load')) {
350
- const hasDescriptionElm = typeaheadActiveChild.childElementCount > 1;
351
- const typeaheadActiveChildText = hasDescriptionElm
352
- ? typeaheadActiveChild.firstChild.textContent
353
- : typeaheadActiveChild.textContent;
354
- this.setState({
355
- typeaheadInputValue: typeaheadActiveChildText
356
- });
357
- }
358
- }
359
- else if (this.refCollection[0] && this.refCollection[0][0]) {
360
- this.setState({
361
- typeaheadInputValue: this.refCollection[0][0].textContent
362
- });
363
- }
364
- if (typeaheadActiveChild) {
365
- typeaheadActiveChild.click();
366
- }
367
- else {
368
- this.refCollection[0][0].click();
369
- }
370
- }
371
- }
372
- else if (position === 'tab') {
373
- if (onFavorite) {
374
- // if the input has focus, tab to the first item or the last item that was previously focused.
375
- if (this.inputRef.current === document.activeElement) {
376
- // If shift is also clicked and there is a footer, tab to the last item in tabbable footer
377
- if (this.props.footer && shiftKey) {
378
- const tabbableItems = (0, util_1.findTabbableElements)(this.footerRef, selectConstants_1.SelectFooterTabbableItems);
379
- if (tabbableItems.length > 0) {
380
- if (tabbableItems[tabbableItems.length - 1]) {
381
- tabbableItems[tabbableItems.length - 1].focus();
382
- }
383
- }
384
- }
385
- else {
386
- this.switchFocusToFavoriteMenu();
387
- }
388
- }
389
- else {
390
- // focus is on menu or footer
391
- if (this.props.footer) {
392
- let tabbedIntoMenu = false;
393
- const tabbableItems = (0, util_1.findTabbableElements)(this.footerRef, selectConstants_1.SelectFooterTabbableItems);
394
- if (tabbableItems.length > 0) {
395
- // if current element is not in footer, tab to first tabbable element in footer,
396
- // if shift was clicked, tab to input since focus is on menu
397
- const currentElementIndex = tabbableItems.findIndex((item) => item === document.activeElement);
398
- if (currentElementIndex === -1) {
399
- if (shiftKey) {
400
- // currently in menu, shift back to input
401
- this.inputRef.current.focus();
402
- }
403
- else {
404
- // currently in menu, tab to first tabbable item in footer
405
- tabbableItems[0].focus();
406
- }
407
- }
408
- else {
409
- // already in footer
410
- if (shiftKey) {
411
- // shift to previous item
412
- if (currentElementIndex === 0) {
413
- // on first footer item, shift back to menu
414
- this.switchFocusToFavoriteMenu();
415
- tabbedIntoMenu = true;
416
- }
417
- else {
418
- // shift to previous footer item
419
- tabbableItems[currentElementIndex - 1].focus();
420
- }
421
- }
422
- else {
423
- // tab to next tabbable item in footer or to input.
424
- if (tabbableItems[currentElementIndex + 1]) {
425
- tabbableItems[currentElementIndex + 1].focus();
426
- }
427
- else {
428
- this.inputRef.current.focus();
429
- }
430
- }
431
- }
432
- }
433
- else {
434
- // no tabbable items in footer, tab to input
435
- this.inputRef.current.focus();
436
- tabbedIntoMenu = false;
437
- }
438
- this.setState({ tabbedIntoFavoritesMenu: tabbedIntoMenu });
439
- }
440
- else {
441
- this.inputRef.current.focus();
442
- this.setState({ tabbedIntoFavoritesMenu: false });
443
- }
444
- }
445
- }
446
- else {
447
- // Close if there is no footer
448
- if (!this.props.footer) {
449
- this.onToggle(null, false);
450
- this.onClose();
451
- }
452
- else {
453
- // has footer
454
- const tabbableItems = (0, util_1.findTabbableElements)(this.footerRef, selectConstants_1.SelectFooterTabbableItems);
455
- const currentElementIndex = tabbableItems.findIndex((item) => item === document.activeElement);
456
- if (this.inputRef.current === document.activeElement) {
457
- if (shiftKey) {
458
- // close toggle if shift key and tab on input
459
- this.onToggle(null, false);
460
- this.onClose();
461
- }
462
- else {
463
- // tab to first tabbable item in footer
464
- if (tabbableItems[0]) {
465
- tabbableItems[0].focus();
466
- }
467
- else {
468
- this.onToggle(null, false);
469
- this.onClose();
470
- }
471
- }
472
- }
473
- else {
474
- // focus is in footer
475
- if (shiftKey) {
476
- if (currentElementIndex === 0) {
477
- // shift tab back to input
478
- this.inputRef.current.focus();
479
- }
480
- else {
481
- // shift to previous footer item
482
- tabbableItems[currentElementIndex - 1].focus();
483
- }
484
- }
485
- else {
486
- // tab to next footer item or close tab if last item
487
- if (tabbableItems[currentElementIndex + 1]) {
488
- tabbableItems[currentElementIndex + 1].focus();
489
- }
490
- else {
491
- // no next item, close toggle
492
- this.onToggle(null, false);
493
- this.inputRef.current.focus();
494
- this.onClose();
495
- }
496
- }
497
- }
498
- }
499
- }
500
- }
501
- else if (!tabbedIntoFavoritesMenu) {
502
- if (this.refCollection[0][0] === null) {
503
- return;
504
- }
505
- let nextIndex;
506
- if (typeaheadCurrIndex === -1 && position === 'down') {
507
- nextIndex = 0;
508
- }
509
- else if (typeaheadCurrIndex === -1 && position === 'up') {
510
- nextIndex = this.refCollection.length - 1;
511
- }
512
- else if (position !== 'left' && position !== 'right') {
513
- nextIndex = (0, helpers_1.getNextIndex)(typeaheadCurrIndex, position, this.refCollection);
514
- }
515
- else {
516
- nextIndex = typeaheadCurrIndex;
517
- }
518
- if (this.refCollection[nextIndex] === null) {
519
- return;
520
- }
521
- this.moveFocus(nextIndex);
522
- }
523
- else {
524
- const nextIndex = this.refCollection.findIndex(ref => ref !== undefined && (ref[0] === document.activeElement || ref[1] === document.activeElement));
525
- this.moveFocus(nextIndex);
526
- }
527
- }
528
- };
529
- this.onClickTypeaheadToggleButton = () => {
530
- if (this.inputRef && this.inputRef.current) {
531
- this.inputRef.current.focus();
532
- }
533
- };
534
- this.getDisplay = (value, type = 'node') => {
535
- if (!value) {
536
- return;
537
- }
538
- const item = this.props.isGrouped
539
- ? React.Children.toArray(this.props.children)
540
- .reduce((acc, curr) => [...acc, ...React.Children.toArray(curr.props.children)], [])
541
- .find(child => child.props.value.toString() === value.toString())
542
- : React.Children.toArray(this.props.children).find(child => child.props.value &&
543
- child.props.value.toString() === value.toString());
544
- if (item) {
545
- if (item && item.props.children) {
546
- if (type === 'node') {
547
- return item.props.children;
548
- }
549
- return this.findText(item);
550
- }
551
- return item.props.value.toString();
552
- }
553
- return value.toString();
554
- };
555
- this.findText = (item) => {
556
- if (typeof item === 'string') {
557
- return item;
558
- }
559
- else if (!React.isValidElement(item)) {
560
- return '';
561
- }
562
- else {
563
- const multi = [];
564
- React.Children.toArray(item.props.children).forEach(child => multi.push(this.findText(child)));
565
- return multi.join('');
566
- }
567
- };
568
- this.generateSelectedBadge = () => {
569
- const { customBadgeText, selections } = this.props;
570
- if (customBadgeText !== null) {
571
- return customBadgeText;
572
- }
573
- if (Array.isArray(selections) && selections.length > 0) {
574
- return selections.length;
575
- }
576
- return null;
577
- };
578
- this.setVieMoreNextIndex = () => {
579
- this.setState({ viewMoreNextIndex: this.refCollection.length - 1 });
580
- };
581
- this.isLastOptionBeforeFooter = (index) => this.props.footer && index === this.refCollection.length - 1 ? true : false;
582
- }
583
- extendTypeaheadChildren(typeaheadCurrIndex, favoritesGroup) {
584
- const { isGrouped, onFavorite, createText } = this.props;
585
- const typeaheadChildren = favoritesGroup
586
- ? favoritesGroup.concat(this.state.typeaheadFilteredChildren)
587
- : this.state.typeaheadFilteredChildren;
588
- const activeElement = this.optionContainerRefCollection[typeaheadCurrIndex];
589
- let typeaheadActiveChild = this.getTypeaheadActiveChild(typeaheadCurrIndex);
590
- if (typeaheadActiveChild && typeaheadActiveChild.classList.contains('pf-m-description')) {
591
- typeaheadActiveChild = typeaheadActiveChild.firstElementChild;
592
- }
593
- this.refCollection = [[]];
594
- this.optionContainerRefCollection = [];
595
- if (isGrouped) {
596
- return React.Children.map(typeaheadChildren, (group) => {
597
- if (group.type === Divider_1.Divider) {
598
- return group;
599
- }
600
- else if (group.type === SelectGroup_1.SelectGroup && onFavorite) {
601
- return React.cloneElement(group, {
602
- titleId: group.props.label && group.props.label.replace(/\W/g, '-'),
603
- children: React.Children.map(group.props.children, (child) => child.type === Divider_1.Divider
604
- ? child
605
- : React.cloneElement(child, {
606
- isFocused: activeElement &&
607
- (activeElement.id === child.props.id ||
608
- (this.props.isCreatable &&
609
- typeaheadActiveChild.textContent ===
610
- `${createText} "${group.props.value}"`))
611
- }))
612
- });
613
- }
614
- else if (group.type === SelectGroup_1.SelectGroup) {
615
- return React.cloneElement(group, {
616
- titleId: group.props.label && group.props.label.replace(/\W/g, '-'),
617
- children: React.Children.map(group.props.children, (child) => child.type === Divider_1.Divider
618
- ? child
619
- : React.cloneElement(child, {
620
- isFocused: typeaheadActiveChild &&
621
- (typeaheadActiveChild.textContent === child.props.value.toString() ||
622
- (this.props.isCreatable &&
623
- typeaheadActiveChild.textContent ===
624
- `${createText} "${child.props.value}"`))
625
- }))
626
- });
627
- }
628
- else {
629
- // group has been filtered down to SelectOption
630
- return React.cloneElement(group, {
631
- isFocused: typeaheadActiveChild &&
632
- (typeaheadActiveChild.textContent === group.props.value.toString() ||
633
- (this.props.isCreatable && typeaheadActiveChild.textContent === `${createText} "${group.props.value}"`))
634
- });
635
- }
636
- });
637
- }
638
- return typeaheadChildren.map((child, index) => {
639
- const childElement = child;
640
- return childElement.type.displayName === 'Divider'
641
- ? child
642
- : React.cloneElement(child, {
643
- isFocused: typeaheadActiveChild
644
- ? typeaheadActiveChild.textContent === child.props.value.toString() ||
645
- (this.props.isCreatable &&
646
- typeaheadActiveChild.textContent === `${createText} "${child.props.value}"`)
647
- : index === typeaheadCurrIndex // fallback for view more + typeahead use cases, when the new expanded list is loaded and refCollection hasn't be updated yet
648
- });
649
- });
650
- }
651
- render() {
652
- const _a = this.props, { children, chipGroupProps, chipGroupComponent, className, customContent, variant, direction, onSelect, onClear, onBlur, toggleId, toggleRef, isOpen, isGrouped, isPlain, isDisabled, hasPlaceholderStyle, validated, selections: selectionsProp, typeAheadAriaLabel, typeAheadAriaDescribedby, clearSelectionsAriaLabel, toggleAriaLabel, removeSelectionAriaLabel, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedby, 'aria-invalid': ariaInvalid, placeholderText, width, maxHeight, toggleIcon, toggleIndicator, ouiaId, ouiaSafe, hasInlineFilter, isCheckboxSelectionBadgeHidden, inlineFilterPlaceholderText,
653
- /* eslint-disable @typescript-eslint/no-unused-vars */
654
- onFilter,
655
- /* eslint-disable @typescript-eslint/no-unused-vars */
656
- onTypeaheadInputChanged, onCreateOption, isCreatable, onToggle, createText, noResultsFoundText, customBadgeText, inputIdPrefix, inputAutoComplete,
657
- /* eslint-disable @typescript-eslint/no-unused-vars */
658
- isInputValuePersisted, isInputFilterPersisted,
659
- /* eslint-enable @typescript-eslint/no-unused-vars */
660
- menuAppendTo, favorites, onFavorite,
661
- /* eslint-disable @typescript-eslint/no-unused-vars */
662
- favoritesLabel, footer, loadingVariant, isCreateSelectOptionObject, isCreateOptionOnTop, shouldResetOnSelect, isFlipEnabled, zIndex } = _a, props = tslib_1.__rest(_a, ["children", "chipGroupProps", "chipGroupComponent", "className", "customContent", "variant", "direction", "onSelect", "onClear", "onBlur", "toggleId", "toggleRef", "isOpen", "isGrouped", "isPlain", "isDisabled", "hasPlaceholderStyle", "validated", "selections", "typeAheadAriaLabel", "typeAheadAriaDescribedby", "clearSelectionsAriaLabel", "toggleAriaLabel", "removeSelectionAriaLabel", 'aria-label', 'aria-labelledby', 'aria-describedby', 'aria-invalid', "placeholderText", "width", "maxHeight", "toggleIcon", "toggleIndicator", "ouiaId", "ouiaSafe", "hasInlineFilter", "isCheckboxSelectionBadgeHidden", "inlineFilterPlaceholderText", "onFilter", "onTypeaheadInputChanged", "onCreateOption", "isCreatable", "onToggle", "createText", "noResultsFoundText", "customBadgeText", "inputIdPrefix", "inputAutoComplete", "isInputValuePersisted", "isInputFilterPersisted", "menuAppendTo", "favorites", "onFavorite", "favoritesLabel", "footer", "loadingVariant", "isCreateSelectOptionObject", "isCreateOptionOnTop", "shouldResetOnSelect", "isFlipEnabled", "zIndex"]);
663
- const { focusFirstOption: openedOnEnter, typeaheadCurrIndex, typeaheadInputValue, typeaheadFilteredChildren, favoritesGroup } = this.state;
664
- const selectToggleId = toggleId || `pf-select-toggle-id-${currentId++}`;
665
- const selections = Array.isArray(selectionsProp) ? selectionsProp : [selectionsProp];
666
- // Find out if the selected option is a placeholder
667
- const selectedOption = React.Children.toArray(children).find((option) => option.props.value === selections[0]);
668
- const isSelectedPlaceholder = selectedOption && selectedOption.props.isPlaceholder;
669
- const hasAnySelections = Boolean(selections[0] && selections[0] !== '');
670
- const typeaheadActiveChild = this.getTypeaheadActiveChild(typeaheadCurrIndex);
671
- let childPlaceholderText = null;
672
- // If onFavorites is set, add isFavorite prop to children and add a Favorites group to the SelectMenu
673
- let renderableItems = [];
674
- if (onFavorite) {
675
- // if variant is type-ahead call the extendTypeaheadChildren before adding favorites
676
- let tempExtendedChildren = children;
677
- if (variant === 'typeahead' || variant === 'typeaheadmulti') {
678
- tempExtendedChildren = this.extendTypeaheadChildren(typeaheadCurrIndex, favoritesGroup);
679
- }
680
- else if (onFavorite) {
681
- tempExtendedChildren = favoritesGroup.concat(children);
682
- }
683
- // mark items that are favorited with isFavorite
684
- renderableItems = (0, favorites_1.extendItemsWithFavorite)(tempExtendedChildren, isGrouped, favorites);
685
- }
686
- else {
687
- renderableItems = children;
688
- }
689
- if (!customContent) {
690
- if (!hasAnySelections && !placeholderText) {
691
- const childPlaceholder = React.Children.toArray(children).filter((child) => child.props.isPlaceholder === true);
692
- childPlaceholderText =
693
- (childPlaceholder[0] && this.getDisplay(childPlaceholder[0].props.value, 'node')) ||
694
- (children[0] && this.getDisplay(children[0].props.value, 'node'));
695
- }
696
- }
697
- if (isOpen) {
698
- if (renderableItems.find(item => (item === null || item === void 0 ? void 0 : item.key) === 'loading') === undefined) {
699
- if (loadingVariant === 'spinner') {
700
- renderableItems.push(React.createElement(SelectOption_1.SelectOption, { isLoading: true, key: "loading", value: "loading" },
701
- React.createElement(Spinner_1.Spinner, { size: "lg" })));
702
- }
703
- else if (loadingVariant === null || loadingVariant === void 0 ? void 0 : loadingVariant.text) {
704
- renderableItems.push(React.createElement(SelectOption_1.SelectOption, { isLoad: true, key: "loading", value: loadingVariant.text, setViewMoreNextIndex: this.setVieMoreNextIndex, onClick: loadingVariant === null || loadingVariant === void 0 ? void 0 : loadingVariant.onClick }));
705
- }
706
- }
707
- }
708
- const hasOnClear = onClear !== Select.defaultProps.onClear;
709
- const clearBtn = (React.createElement("button", { className: (0, react_styles_1.css)(button_1.default.button, button_1.default.modifiers.plain, select_1.default.selectToggleClear), onClick: e => {
710
- this.clearSelection(e);
711
- onClear(e);
712
- e.stopPropagation();
713
- }, "aria-label": clearSelectionsAriaLabel, type: "button", disabled: isDisabled, ref: this.clearRef, onKeyDown: event => {
714
- if (event.key === constants_1.KeyTypes.Enter) {
715
- this.clearRef.current.click();
716
- }
717
- } },
718
- React.createElement(times_circle_icon_1.default, { "aria-hidden": true })));
719
- let selectedChips = null;
720
- if (variant === selectConstants_1.SelectVariant.typeaheadMulti) {
721
- selectedChips = chipGroupComponent ? (chipGroupComponent) : (React.createElement(ChipGroup_1.ChipGroup, Object.assign({}, chipGroupProps), selections &&
722
- selections.map(item => (React.createElement(Chip_1.Chip, { key: item, onClick: (e) => onSelect(e, item), closeBtnAriaLabel: removeSelectionAriaLabel }, this.getDisplay(item, 'node'))))));
723
- }
724
- if (hasInlineFilter) {
725
- const filterBox = (React.createElement(React.Fragment, null,
726
- React.createElement("div", { key: "inline-filter", className: (0, react_styles_1.css)(select_1.default.selectMenuSearch) },
727
- React.createElement("input", { key: "inline-filter-input", type: "search", className: (0, react_styles_1.css)(form_control_1.default.formControl, form_control_1.default.modifiers.search), onChange: this.onChange, placeholder: inlineFilterPlaceholderText, onKeyDown: event => {
728
- if (event.key === constants_1.KeyTypes.ArrowUp) {
729
- this.handleMenuKeys(0, 0, 'up');
730
- event.preventDefault();
731
- }
732
- else if (event.key === constants_1.KeyTypes.ArrowDown) {
733
- this.handleMenuKeys(0, 0, 'down');
734
- event.preventDefault();
735
- }
736
- else if (event.key === constants_1.KeyTypes.ArrowLeft) {
737
- this.handleMenuKeys(0, 0, 'left');
738
- event.preventDefault();
739
- }
740
- else if (event.key === constants_1.KeyTypes.ArrowRight) {
741
- this.handleMenuKeys(0, 0, 'right');
742
- event.preventDefault();
743
- }
744
- else if (event.key === constants_1.KeyTypes.Tab && variant !== selectConstants_1.SelectVariant.checkbox && this.props.footer) {
745
- // tab to footer or close menu if shift key
746
- if (event.shiftKey) {
747
- this.onToggle(event, false);
748
- }
749
- else {
750
- const tabbableItems = (0, util_1.findTabbableElements)(this.footerRef, selectConstants_1.SelectFooterTabbableItems);
751
- if (tabbableItems.length > 0) {
752
- tabbableItems[0].focus();
753
- event.stopPropagation();
754
- event.preventDefault();
755
- }
756
- else {
757
- this.onToggle(event, false);
758
- }
759
- }
760
- }
761
- else if (event.key === constants_1.KeyTypes.Tab && variant === selectConstants_1.SelectVariant.checkbox) {
762
- // More modal-like experience for checkboxes
763
- // Let SelectOption handle this
764
- if (event.shiftKey) {
765
- this.handleMenuKeys(0, 0, 'up');
766
- }
767
- else {
768
- this.handleMenuKeys(0, 0, 'down');
769
- }
770
- event.stopPropagation();
771
- event.preventDefault();
772
- }
773
- }, ref: this.filterRef, autoComplete: inputAutoComplete })),
774
- React.createElement(Divider_1.Divider, { key: "inline-filter-divider" })));
775
- renderableItems = [filterBox, ...typeaheadFilteredChildren].map((option, index) => React.cloneElement(option, { key: index }));
776
- }
777
- let variantProps;
778
- let variantChildren;
779
- if (customContent) {
780
- variantProps = {
781
- selected: selections,
782
- openedOnEnter,
783
- isCustomContent: true
784
- };
785
- variantChildren = customContent;
786
- }
787
- else {
788
- switch (variant) {
789
- case 'single':
790
- variantProps = {
791
- selected: selections[0],
792
- hasInlineFilter,
793
- openedOnEnter
794
- };
795
- variantChildren = renderableItems;
796
- break;
797
- case 'checkbox':
798
- variantProps = {
799
- checked: selections,
800
- isGrouped,
801
- hasInlineFilter,
802
- openedOnEnter
803
- };
804
- variantChildren = renderableItems;
805
- break;
806
- case 'typeahead':
807
- variantProps = {
808
- selected: selections[0],
809
- openedOnEnter
810
- };
811
- variantChildren = onFavorite ? renderableItems : this.extendTypeaheadChildren(typeaheadCurrIndex);
812
- if (variantChildren.length === 0) {
813
- variantChildren.push(React.createElement(SelectOption_1.SelectOption, { isDisabled: true, key: 0, value: noResultsFoundText, isNoResultsOption: true }));
814
- }
815
- break;
816
- case 'typeaheadmulti':
817
- variantProps = {
818
- selected: selections,
819
- openedOnEnter
820
- };
821
- variantChildren = onFavorite ? renderableItems : this.extendTypeaheadChildren(typeaheadCurrIndex);
822
- if (variantChildren.length === 0) {
823
- variantChildren.push(React.createElement(SelectOption_1.SelectOption, { isDisabled: true, key: 0, value: noResultsFoundText, isNoResultsOption: true }));
824
- }
825
- break;
826
- }
827
- }
828
- const isStatic = isFlipEnabled && menuAppendTo !== 'inline';
829
- const innerMenu = (React.createElement(SelectMenu_1.SelectMenu, Object.assign({ className: (0, react_styles_1.css)(isStatic && select_1.default.modifiers.static) }, props, { isGrouped: isGrouped, selected: selections }, variantProps, { openedOnEnter: openedOnEnter, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, sendRef: this.sendRef, keyHandler: this.handleMenuKeys, maxHeight: maxHeight, ref: this.menuComponentRef, footer: footer, footerRef: this.footerRef, isLastOptionBeforeFooter: this.isLastOptionBeforeFooter }), variantChildren));
830
- const menuContainer = footer ? React.createElement("div", { className: (0, react_styles_1.css)(select_1.default.selectMenu) },
831
- " ",
832
- innerMenu,
833
- " ") : innerMenu;
834
- const popperRef = React.createRef();
835
- const popperContainer = (React.createElement("div", Object.assign({ className: (0, react_styles_1.css)(select_1.default.select, isOpen && select_1.default.modifiers.expanded, validated === constants_2.ValidatedOptions.success && select_1.default.modifiers.success, validated === constants_2.ValidatedOptions.warning && select_1.default.modifiers.warning, validated === constants_2.ValidatedOptions.error && select_1.default.modifiers.invalid, direction === selectConstants_1.SelectDirection.up && select_1.default.modifiers.top, className), ref: popperRef }, (width && { style: { width } }), (validated !== constants_2.ValidatedOptions.default && { 'aria-invalid': ariaInvalid })), isOpen && menuContainer));
836
- const mainContainer = (React.createElement("div", Object.assign({ className: (0, react_styles_1.css)(select_1.default.select, isOpen && select_1.default.modifiers.expanded, validated === constants_2.ValidatedOptions.success && select_1.default.modifiers.success, validated === constants_2.ValidatedOptions.warning && select_1.default.modifiers.warning, validated === constants_2.ValidatedOptions.error && select_1.default.modifiers.invalid, direction === selectConstants_1.SelectDirection.up && select_1.default.modifiers.top, className), ref: this.parentRef }, (0, helpers_1.getOUIAProps)(Select.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe), (width && { style: { width } }), (validated !== constants_2.ValidatedOptions.default && { 'aria-invalid': ariaInvalid })),
837
- React.createElement(SelectToggle_1.SelectToggle, Object.assign({ id: selectToggleId, parentRef: this.parentRef, menuRef: this.menuComponentRef, ref: toggleRef }, (footer && { footerRef: this.footerRef }), { isOpen: isOpen, isPlain: isPlain, hasPlaceholderStyle: hasPlaceholderStyle && (!selections.length || selections[0] === null || isSelectedPlaceholder), onToggle: this.onToggle, onEnter: this.onEnter, onClose: this.onClose, onBlur: onBlur, variant: variant, toggleIndicator: toggleIndicator, "aria-labelledby": `${ariaLabelledBy || ''} ${selectToggleId}`, "aria-label": toggleAriaLabel }, (ariaDescribedby && { 'aria-describedby': ariaDescribedby }), { handleTypeaheadKeys: this.handleTypeaheadKeys, moveFocusToLastMenuItem: this.moveFocusToLastMenuItem, isDisabled: isDisabled, hasClearButton: hasOnClear, hasFooter: footer !== undefined, onClickTypeaheadToggleButton: this.onClickTypeaheadToggleButton }),
838
- customContent && (React.createElement("div", { className: (0, react_styles_1.css)(select_1.default.selectToggleWrapper) },
839
- toggleIcon && React.createElement("span", { className: (0, react_styles_1.css)(select_1.default.selectToggleIcon) }, toggleIcon),
840
- React.createElement("span", { className: (0, react_styles_1.css)(select_1.default.selectToggleText) }, placeholderText))),
841
- variant === selectConstants_1.SelectVariant.single && !customContent && (React.createElement(React.Fragment, null,
842
- React.createElement("div", { className: (0, react_styles_1.css)(select_1.default.selectToggleWrapper) },
843
- toggleIcon && React.createElement("span", { className: (0, react_styles_1.css)(select_1.default.selectToggleIcon) }, toggleIcon),
844
- React.createElement("span", { className: (0, react_styles_1.css)(select_1.default.selectToggleText) }, this.getDisplay(selections[0], 'node') || placeholderText || childPlaceholderText)),
845
- hasOnClear && hasAnySelections && clearBtn)),
846
- variant === selectConstants_1.SelectVariant.checkbox && !customContent && (React.createElement(React.Fragment, null,
847
- React.createElement("div", { className: (0, react_styles_1.css)(select_1.default.selectToggleWrapper) },
848
- toggleIcon && React.createElement("span", { className: (0, react_styles_1.css)(select_1.default.selectToggleIcon) }, toggleIcon),
849
- React.createElement("span", { className: (0, react_styles_1.css)(select_1.default.selectToggleText) }, placeholderText),
850
- !isCheckboxSelectionBadgeHidden && hasAnySelections && (React.createElement("div", { className: (0, react_styles_1.css)(select_1.default.selectToggleBadge) },
851
- React.createElement("span", { className: (0, react_styles_1.css)(badge_1.default.badge, badge_1.default.modifiers.read) }, this.generateSelectedBadge())))),
852
- hasOnClear && hasAnySelections && clearBtn)),
853
- variant === selectConstants_1.SelectVariant.typeahead && !customContent && (React.createElement(React.Fragment, null,
854
- React.createElement("div", { className: (0, react_styles_1.css)(select_1.default.selectToggleWrapper) },
855
- toggleIcon && React.createElement("span", { className: (0, react_styles_1.css)(select_1.default.selectToggleIcon) }, toggleIcon),
856
- React.createElement("input", Object.assign({ className: (0, react_styles_1.css)(form_control_1.default.formControl, select_1.default.selectToggleTypeahead), "aria-activedescendant": typeaheadActiveChild && typeaheadActiveChild.id, id: `${selectToggleId}-select-typeahead`, "aria-label": typeAheadAriaLabel }, (typeAheadAriaDescribedby && { 'aria-describedby': typeAheadAriaDescribedby }), { placeholder: placeholderText, value: typeaheadInputValue !== null
857
- ? typeaheadInputValue
858
- : this.getDisplay(selections[0], 'text') || '', type: "text", onClick: this.onClick, onChange: this.onChange, autoComplete: inputAutoComplete, disabled: isDisabled, ref: this.inputRef }))),
859
- hasOnClear && (selections[0] || typeaheadInputValue) && clearBtn)),
860
- variant === selectConstants_1.SelectVariant.typeaheadMulti && !customContent && (React.createElement(React.Fragment, null,
861
- React.createElement("div", { className: (0, react_styles_1.css)(select_1.default.selectToggleWrapper) },
862
- toggleIcon && React.createElement("span", { className: (0, react_styles_1.css)(select_1.default.selectToggleIcon) }, toggleIcon),
863
- selections && Array.isArray(selections) && selections.length > 0 && selectedChips,
864
- React.createElement("input", Object.assign({ className: (0, react_styles_1.css)(form_control_1.default.formControl, select_1.default.selectToggleTypeahead), "aria-activedescendant": typeaheadActiveChild && typeaheadActiveChild.id, id: `${selectToggleId}-select-multi-typeahead-typeahead`, "aria-label": typeAheadAriaLabel, "aria-invalid": validated === constants_2.ValidatedOptions.error }, (typeAheadAriaDescribedby && { 'aria-describedby': typeAheadAriaDescribedby }), { placeholder: placeholderText, value: typeaheadInputValue !== null ? typeaheadInputValue : '', type: "text", onChange: this.onChange, onClick: this.onClick, autoComplete: inputAutoComplete, disabled: isDisabled, ref: this.inputRef }))),
865
- hasOnClear && ((selections && selections.length > 0) || typeaheadInputValue) && clearBtn)),
866
- validated === constants_2.ValidatedOptions.success && (React.createElement("span", { className: (0, react_styles_1.css)(select_1.default.selectToggleStatusIcon) },
867
- React.createElement(check_circle_icon_1.default, { "aria-hidden": "true" }))),
868
- validated === constants_2.ValidatedOptions.error && (React.createElement("span", { className: (0, react_styles_1.css)(select_1.default.selectToggleStatusIcon) },
869
- React.createElement(exclamation_circle_icon_1.default, { "aria-hidden": "true" }))),
870
- validated === constants_2.ValidatedOptions.warning && (React.createElement("span", { className: (0, react_styles_1.css)(select_1.default.selectToggleStatusIcon) },
871
- React.createElement(exclamation_triangle_icon_1.default, { "aria-hidden": "true" })))),
872
- isOpen && menuAppendTo === 'inline' && menuContainer));
873
- const getParentElement = () => {
874
- if (this.parentRef && this.parentRef.current) {
875
- return this.parentRef.current.parentElement;
876
- }
877
- return null;
878
- };
879
- return (React.createElement(helpers_1.GenerateId, null, randomId => (React.createElement(selectConstants_1.SelectContext.Provider, { value: {
880
- onSelect,
881
- onFavorite,
882
- onClose: this.onClose,
883
- variant,
884
- inputIdPrefix: inputIdPrefix || randomId,
885
- shouldResetOnSelect
886
- } }, menuAppendTo === 'inline' ? (mainContainer) : (React.createElement(Popper_1.Popper, { trigger: mainContainer, triggerRef: this.parentRef, popper: popperContainer, popperRef: popperRef, direction: direction, appendTo: menuAppendTo === 'parent' ? getParentElement() : menuAppendTo, isVisible: isOpen, zIndex: zIndex }))))));
887
- }
888
- }
889
- exports.Select = Select;
890
- Select.displayName = 'Select';
891
- Select.defaultProps = {
892
- children: [],
893
- className: '',
894
- position: selectConstants_1.SelectPosition.left,
895
- direction: selectConstants_1.SelectDirection.down,
896
- toggleId: null,
897
- isOpen: false,
898
- isGrouped: false,
899
- isPlain: false,
900
- isDisabled: false,
901
- hasPlaceholderStyle: false,
902
- isCreatable: false,
903
- isCreateOptionOnTop: false,
904
- validated: 'default',
905
- 'aria-label': '',
906
- 'aria-labelledby': '',
907
- 'aria-describedby': '',
908
- 'aria-invalid': false,
909
- typeAheadAriaLabel: '',
910
- typeAheadAriaDescribedby: '',
911
- clearSelectionsAriaLabel: 'Clear all',
912
- toggleAriaLabel: 'Options menu',
913
- removeSelectionAriaLabel: 'Remove',
914
- selections: [],
915
- createText: 'Create',
916
- placeholderText: '',
917
- noResultsFoundText: 'No results found',
918
- variant: selectConstants_1.SelectVariant.single,
919
- width: '',
920
- onClear: () => undefined,
921
- onCreateOption: () => undefined,
922
- toggleIcon: null,
923
- toggleIndicator: null,
924
- onFilter: null,
925
- onTypeaheadInputChanged: null,
926
- customContent: null,
927
- hasInlineFilter: false,
928
- inlineFilterPlaceholderText: null,
929
- customBadgeText: null,
930
- inputIdPrefix: '',
931
- inputAutoComplete: 'off',
932
- menuAppendTo: 'inline',
933
- favorites: [],
934
- favoritesLabel: 'Favorites',
935
- ouiaSafe: true,
936
- chipGroupComponent: null,
937
- isInputValuePersisted: false,
938
- isInputFilterPersisted: false,
939
- isCreateSelectOptionObject: false,
940
- shouldResetOnSelect: true,
941
- isFlipEnabled: true,
942
- zIndex: 9999
9
+ const helpers_1 = require("../../helpers");
10
+ const SelectBase = (_a) => {
11
+ var { children, className, onSelect, isOpen, selected, toggle, onOpenChange, isPlain, innerRef, zIndex = 9999, role = 'listbox', popperProps } = _a, props = tslib_1.__rest(_a, ["children", "className", "onSelect", "isOpen", "selected", "toggle", "onOpenChange", "isPlain", "innerRef", "zIndex", "role", "popperProps"]);
12
+ const localMenuRef = react_1.default.useRef();
13
+ const toggleRef = react_1.default.useRef();
14
+ const containerRef = react_1.default.useRef();
15
+ const menuRef = innerRef || localMenuRef;
16
+ react_1.default.useEffect(() => {
17
+ const handleMenuKeys = (event) => {
18
+ var _a, _b, _c;
19
+ // Close the menu on tab or escape if onOpenChange is provided
20
+ if ((isOpen && onOpenChange && ((_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target))) ||
21
+ ((_b = toggleRef.current) === null || _b === void 0 ? void 0 : _b.contains(event.target))) {
22
+ if (event.key === 'Escape' || event.key === 'Tab') {
23
+ onOpenChange(false);
24
+ (_c = toggleRef.current) === null || _c === void 0 ? void 0 : _c.focus();
25
+ }
26
+ }
27
+ };
28
+ const handleClick = (event) => {
29
+ var _a, _b, _c;
30
+ // toggle was clicked open via keyboard, focus on first menu item
31
+ if (isOpen && ((_a = toggleRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target)) && event.detail === 0) {
32
+ setTimeout(() => {
33
+ var _a;
34
+ const firstElement = (_a = menuRef === null || menuRef === void 0 ? void 0 : menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('li button:not(:disabled),li input:not(:disabled)');
35
+ firstElement && firstElement.focus();
36
+ }, 0);
37
+ }
38
+ // If the event is not on the toggle and onOpenChange callback is provided, close the menu
39
+ if (isOpen && onOpenChange && !((_b = toggleRef === null || toggleRef === void 0 ? void 0 : toggleRef.current) === null || _b === void 0 ? void 0 : _b.contains(event.target))) {
40
+ if (isOpen && !((_c = menuRef.current) === null || _c === void 0 ? void 0 : _c.contains(event.target))) {
41
+ onOpenChange(false);
42
+ }
43
+ }
44
+ };
45
+ window.addEventListener('keydown', handleMenuKeys);
46
+ window.addEventListener('click', handleClick);
47
+ return () => {
48
+ window.removeEventListener('keydown', handleMenuKeys);
49
+ window.removeEventListener('click', handleClick);
50
+ };
51
+ }, [isOpen, menuRef, onOpenChange]);
52
+ const menu = (react_1.default.createElement(Menu_1.Menu, Object.assign({ role: role, className: (0, react_styles_1.css)(className), ref: menuRef, onSelect: (event, itemId) => onSelect && onSelect(event, itemId), isPlain: isPlain, selected: selected }, (0, helpers_1.getOUIAProps)(exports.Select.displayName, props.ouiaId !== undefined ? props.ouiaId : (0, helpers_1.getDefaultOUIAId)(exports.Select.displayName), props.ouiaSafe !== undefined ? props.ouiaSafe : true), props),
53
+ react_1.default.createElement(Menu_1.MenuContent, null, children)));
54
+ return (react_1.default.createElement("div", { ref: containerRef },
55
+ react_1.default.createElement(Popper_1.Popper, Object.assign({ trigger: toggle(toggleRef), triggerRef: toggleRef, popper: menu, popperRef: menuRef, appendTo: containerRef.current || undefined, isVisible: isOpen, zIndex: zIndex }, popperProps))));
943
56
  };
57
+ exports.Select = react_1.default.forwardRef((props, ref) => (react_1.default.createElement(SelectBase, Object.assign({ innerRef: ref }, props))));
58
+ exports.Select.displayName = 'Select';
944
59
  //# sourceMappingURL=Select.js.map