@qualtrics/ui-react 2.20.0 → 2.22.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 (211) hide show
  1. package/CHANGELOG.md +17 -33
  2. package/dist/__shared/cjs/{index-90d4069b.js → index-025620bf.js} +718 -673
  3. package/dist/__shared/cjs/{index-579c4690.js → index-41a013d2.js} +4 -4
  4. package/dist/components/Accordion/Accordion.js +1 -1
  5. package/dist/components/Accordion/Accordion2.js +3 -3
  6. package/dist/components/Accordion/AccordionHeader.js +4 -4
  7. package/dist/components/Accordion/AccordionPanel.js +3 -3
  8. package/dist/components/Button/Button.js +3 -3
  9. package/dist/components/Button/Button2.js +2 -2
  10. package/dist/components/ButtonGroup/ButtonGroup.js +1 -1
  11. package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
  12. package/dist/components/Checkbox/Checkbox.js +11 -11
  13. package/dist/components/Checkbox/Checkbox2.js +3 -3
  14. package/dist/components/Checkbox/VisualCheckbox2.js +3 -3
  15. package/dist/components/ColorPicker/Alpha.js +12 -16
  16. package/dist/components/ColorPicker/ColorPicker.js +15 -9
  17. package/dist/components/ColorPicker/ColorPicker2.js +3 -3
  18. package/dist/components/ColorPicker/ColorPickerFlyout.js +9 -4
  19. package/dist/components/ColorPicker/ColorPickerFlyoutInputs.js +8 -6
  20. package/dist/components/ColorPicker/Hue.js +3 -9
  21. package/dist/components/ColorPicker/Palette.js +13 -9
  22. package/dist/components/ColorPicker/Saturation.js +9 -17
  23. package/dist/components/ColorPicker/utils/hexToRgbaString.js +3 -2
  24. package/dist/components/ColorPicker/utils/rgbToHex.js +1 -1
  25. package/dist/components/ColorPicker/utils/validateHex.js +10 -9
  26. package/dist/components/Combobox/Combobox.js +54 -31
  27. package/dist/components/Combobox/Combobox2.js +3 -3
  28. package/dist/components/Combobox/ComboboxHeader.js +1 -1
  29. package/dist/components/Combobox/ComboboxIcon.js +3 -2
  30. package/dist/components/Combobox/ComboboxInput.js +4 -4
  31. package/dist/components/Combobox/ComboboxList.js +2 -2
  32. package/dist/components/ConfigPane/ConfigPane2.js +3 -3
  33. package/dist/components/Divider/Divider2.js +3 -3
  34. package/dist/components/Dropdown/ChildIndexContext/reach-descendants.js +5 -2
  35. package/dist/components/Dropdown/Dropdown.js +14 -14
  36. package/dist/components/Dropdown/Dropdown2.js +3 -3
  37. package/dist/components/Dropdown/DropdownButton.js +23 -19
  38. package/dist/components/Dropdown/DropdownList.js +4 -4
  39. package/dist/components/Dropdown/DropdownOption.js +5 -7
  40. package/dist/components/Dropdown/DropdownSearch.js +12 -9
  41. package/dist/components/FilePicker/FilePicker.js +13 -13
  42. package/dist/components/FilePicker/FilePicker2.js +3 -3
  43. package/dist/components/FormField/Caption.js +3 -3
  44. package/dist/components/FormField/FormField.js +2 -2
  45. package/dist/components/FormField/FormField2.js +3 -3
  46. package/dist/components/FormField/FormFieldContext.js +3 -3
  47. package/dist/components/FullScreenTakeover/FullScreenTakeover.js +5 -3
  48. package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
  49. package/dist/components/Icon/Icon.js +2 -2
  50. package/dist/components/IconButton/IconButton2.js +3 -3
  51. package/dist/components/InlineInput/InlineInput.js +12 -9
  52. package/dist/components/InlineInput/InlineInput2.js +3 -3
  53. package/dist/components/Input/Input.js +1 -1
  54. package/dist/components/Input/Input2.js +3 -3
  55. package/dist/components/Input/InputField.js +2 -2
  56. package/dist/components/InputGroup/InputGroup2.js +3 -3
  57. package/dist/components/Label/Label2.js +3 -3
  58. package/dist/components/Link/Link2.js +3 -3
  59. package/dist/components/LoadingSpinner/LoadingSpinner.js +1 -1
  60. package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
  61. package/dist/components/LogicEditor/ConditionSet.js +5 -5
  62. package/dist/components/LogicEditor/LogicEditor.js +1 -1
  63. package/dist/components/LogicEditor/LogicEditor2.js +3 -3
  64. package/dist/components/LogicEditor/utils.js +2 -1
  65. package/dist/components/Modal/Modal.js +14 -13
  66. package/dist/components/Modal/Modal2.js +3 -3
  67. package/dist/components/NewMenu/BaseMenu.js +41 -30
  68. package/dist/components/NewMenu/NewMenu.js +3 -3
  69. package/dist/components/NewMenu/SelectMenu/SelectMenu.js +2 -2
  70. package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +19 -15
  71. package/dist/components/NewMenu/parts/MenuItem.js +1 -1
  72. package/dist/components/NumberStepper/NumberStepper.js +7 -6
  73. package/dist/components/NumberStepper/NumberStepper2.js +3 -3
  74. package/dist/components/NumberStepper/NumberStepperDecrement.js +1 -1
  75. package/dist/components/NumberStepper/NumberStepperIncrement.js +1 -1
  76. package/dist/components/NumberStepper/NumberStepperInput.js +3 -3
  77. package/dist/components/PageLayout/PageLayout.js +3 -3
  78. package/dist/components/Pagination/Pagination.js +1 -1
  79. package/dist/components/Pagination/Pagination2.js +3 -3
  80. package/dist/components/Pagination/PaginationNextButton.js +5 -5
  81. package/dist/components/Pagination/PaginationPageInput.js +11 -9
  82. package/dist/components/Pagination/PaginationPreviousButton.js +5 -5
  83. package/dist/components/Popover/Popover.js +9 -7
  84. package/dist/components/Popover/Popover2.js +3 -3
  85. package/dist/components/QuickSearch/QuickSearch.js +4 -3
  86. package/dist/components/QuickSearch/QuickSearch2.js +3 -3
  87. package/dist/components/QuickSearch/QuickSearchInput.js +4 -4
  88. package/dist/components/Radio/Radio.js +12 -11
  89. package/dist/components/Radio/Radio2.js +3 -3
  90. package/dist/components/SearchInput/SearchInput.js +4 -3
  91. package/dist/components/SearchInput/SearchInput2.js +3 -3
  92. package/dist/components/SidebarNav/SidebarNav.js +2 -1
  93. package/dist/components/SidebarNav/SidebarNav2.js +3 -3
  94. package/dist/components/SidebarNav/SidebarNavLink.js +1 -1
  95. package/dist/components/Slider/RangeSlider.js +2 -2
  96. package/dist/components/Slider/Slider.js +1 -1
  97. package/dist/components/Slider/Slider2.js +3 -3
  98. package/dist/components/Slider/SliderButton.js +1 -1
  99. package/dist/components/Switch/Switch.js +11 -11
  100. package/dist/components/Switch/Switch2.js +3 -3
  101. package/dist/components/Table/Table2.js +3 -3
  102. package/dist/components/Tabs/Tab.js +3 -3
  103. package/dist/components/Tabs/TabList.js +6 -5
  104. package/dist/components/Tabs/TabPanel.js +3 -3
  105. package/dist/components/Tabs/Tabs2.js +3 -3
  106. package/dist/components/Tooltip/Tooltip.js +15 -7
  107. package/dist/components/Tooltip/Tooltip2.js +3 -3
  108. package/dist/components/UIProvider/UIProvider.js +2 -2
  109. package/dist/components/deprecated_ColorPicker/Alpha.js +4 -4
  110. package/dist/components/deprecated_ColorPicker/Color.js +6 -6
  111. package/dist/components/deprecated_ColorPicker/ColorPicker.js +2 -2
  112. package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
  113. package/dist/components/deprecated_ColorPicker/HexInput.js +1 -1
  114. package/dist/components/deprecated_ColorPicker/Hue.js +3 -3
  115. package/dist/components/deprecated_ColorPicker/Saturation.js +5 -5
  116. package/dist/components/deprecated_ColorPicker/Swatch.js +2 -2
  117. package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
  118. package/dist/components/deprecated_NumberStepper/NumberStepperDecrement.js +2 -2
  119. package/dist/components/deprecated_NumberStepper/NumberStepperIncrement.js +2 -2
  120. package/dist/components/deprecated_NumberStepper/NumberStepperInput.js +8 -8
  121. package/dist/components/deprecated_Tabs/Tabs.js +11 -7
  122. package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
  123. package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
  124. package/dist/components/deprecated_Toolbar/ToolbarPanel.js +3 -3
  125. package/dist/components/deprecated_Toolbar/ToolbarPanels.js +4 -29
  126. package/dist/components/deprecated_Toolbar/ToolbarTab.js +8 -8
  127. package/dist/components/deprecated_Toolbar/ToolbarTabs.js +6 -3
  128. package/dist/hooks/useBreakpoints/useBreakpoints.js +1 -1
  129. package/dist/hooks/useClickOutside/useClickOutside.js +2 -1
  130. package/dist/hooks/useControllableState/useControllableState.js +2 -1
  131. package/dist/hooks/useEventListener/useEventListener.js +4 -1
  132. package/dist/hooks/useId/useId.js +1 -1
  133. package/dist/hooks/useOverlay/useOverlay.js +11 -6
  134. package/dist/hooks/useOverlay/useOverlay2.js +3 -3
  135. package/dist/hooks/useResponsiveValue/useResponsiveValue.js +2 -1
  136. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +4 -2
  137. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
  138. package/dist/icons/Icon.js +3 -3
  139. package/dist/icons/createIconComponent.js +1 -1
  140. package/dist/icons/index.js +1 -1
  141. package/dist/index.d.ts +17 -8
  142. package/dist/index.es.js +1 -7
  143. package/dist/index.js +4 -7
  144. package/dist/next/AdvancedTable/AdvancedTable.js +86 -87
  145. package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
  146. package/dist/next/AdvancedTable/AdvancedTableCell.js +6 -4
  147. package/dist/next/AdvancedTable/AdvancedTableColumnHeader.js +18 -10
  148. package/dist/next/AdvancedTable/AdvancedTableColumnHeaderMenu.js +7 -6
  149. package/dist/next/AdvancedTable/AdvancedTableDragPreview.js +5 -4
  150. package/dist/next/AdvancedTable/AdvancedTablePagination.js +1 -1
  151. package/dist/next/AdvancedTable/useAdvancedTableDragAndDrop.js +3 -2
  152. package/dist/next/AdvancedTable/useComputedWidth.js +1 -1
  153. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput.js +6 -5
  154. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
  155. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInputIconButton.js +1 -1
  156. package/dist/next/Combobox/Combobox2.js +3 -3
  157. package/dist/next/Combobox/ComboboxFlyout.js +2 -2
  158. package/dist/next/Combobox/ComboboxGroup.js +1 -1
  159. package/dist/next/Combobox/ComboboxInput.js +2 -2
  160. package/dist/next/Combobox/ComboboxOption.js +1 -1
  161. package/dist/next/Combobox/hooks/useComboboxFilteredGroup/useComboboxFilteredGroup.js +1 -1
  162. package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +12 -8
  163. package/dist/next/Combobox/hooks/useComboboxValue/useComboboxValue.js +1 -1
  164. package/dist/next/Combobox/hooks/useListboxFlyoutDimensions/useListboxFlyoutDimensions.js +3 -2
  165. package/dist/next/Combobox/hooks/useSelectedOptionScroll/useSelectedOptionScroll.js +2 -1
  166. package/dist/next/Combobox/hooks/useShouldRenderGroupHeader/useShouldRenderGroupHeader.js +2 -1
  167. package/dist/next/Combobox/utils/nodeRegistration/nodeRegistration.js +1 -1
  168. package/dist/next/Drawer/Drawer.js +7 -4
  169. package/dist/next/Drawer/Drawer2.js +3 -3
  170. package/dist/next/FilterAnchor/FilterAnchor.js +3 -3
  171. package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
  172. package/dist/next/Input/Input.js +2 -2
  173. package/dist/next/Input/Input2.js +3 -3
  174. package/dist/next/Menu/Menu.js +11 -5
  175. package/dist/next/Menu/Menu2.js +3 -3
  176. package/dist/next/Menu/MenuItem.js +19 -11
  177. package/dist/next/Menu/MenuPane.js +70 -40
  178. package/dist/next/Menu/MenuSearch.js +16 -71
  179. package/dist/next/Menu/SubMenu.js +63 -46
  180. package/dist/next/Menu/constants.js +5 -1
  181. package/dist/next/Menu/useMutationObserver.js +17 -0
  182. package/dist/next/Menu/usePaneSearch.js +109 -7
  183. package/dist/next/PhoneNumberInput/PhoneNumberInput.js +7 -6
  184. package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
  185. package/dist/next/SplitButton/SplitButton.js +8 -2
  186. package/dist/next/SplitButton/SplitButton2.js +3 -3
  187. package/dist/next/TimePicker/TimeDropdown.js +4 -4
  188. package/dist/next/TimePicker/TimeInput.js +2 -2
  189. package/dist/next/TimePicker/TimePicker.js +4 -4
  190. package/dist/next/TimePicker/TimePicker2.js +3 -3
  191. package/dist/next/TimePicker/TimePickerIcon.js +2 -1
  192. package/dist/next/TimePicker/utils.js +10 -9
  193. package/dist/next/ToggleButton/styles.js +3 -3
  194. package/dist/next/index.d.ts +2 -1
  195. package/dist/next/index.js +601 -432
  196. package/dist/utils/Flyout/Flyout.js +1 -1
  197. package/dist/utils/Flyout/Flyout2.js +3 -3
  198. package/dist/utils/Popper/Popper.js +9 -5
  199. package/dist/utils/TextOverflowTooltip/TextOverflowTooltip.js +2 -1
  200. package/dist/utils/Translation/useTranslation.js +4 -5
  201. package/dist/utils/filterChildren/filterChildren.js +2 -1
  202. package/dist/utils/getSubDataTestId/getSubDataTestId.js +1 -1
  203. package/dist/utils/index.js +0 -1
  204. package/dist/utils/mediaQueryManager/mediaQueryManager.js +1 -1
  205. package/dist/utils/mergeRefs/mergeRefs.js +1 -1
  206. package/dist/utils/wrapEvent/wrapEvent.js +2 -2
  207. package/icons/package.json +1 -0
  208. package/next/package.json +2 -1
  209. package/package.json +4 -4
  210. package/dist/utils/keyboardUser/index.js +0 -1
  211. package/dist/utils/keyboardUser/keyboardUser.js +0 -30
@@ -3,18 +3,17 @@ import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/ins
3
3
  import React__default, { useState, useRef, useMemo, useEffect } from 'react';
4
4
  import { Sub, SubTrigger, SubContent, Item } from '@radix-ui/react-dropdown-menu';
5
5
  import classNames from 'classnames';
6
+ import { useFocusVisible } from '@react-aria/interactions';
6
7
  import styles from './Menu2.js';
7
8
  import '../../icons/index.es.js';
8
9
  import { usePaneContext, useMenuContext, PaneContextProvider } from './MenuContext.js';
9
10
  import '../../utils/index.js';
10
11
  import { DATA_TESTID_SUFFIXES, KEYS } from './constants.js';
11
- import MenuSearch from './MenuSearch.js';
12
12
  import '../../hooks/index.js';
13
13
  import usePaneSearch from './usePaneSearch.js';
14
14
  import useId from '../../hooks/useId/useId.js';
15
15
  import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
16
16
  import { useDidUpdate } from '../../hooks/useDidUpdate/useDidUpdate.js';
17
- import { getIsKeyboardUser } from '../../utils/keyboardUser/keyboardUser.js';
18
17
  import ChevronRightIcon from '../../icons/components/ChevronRightIcon.js';
19
18
  import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
20
19
  import ArrowLeftIcon from '../../icons/components/ArrowLeftIcon.js';
@@ -30,19 +29,14 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
30
29
  isSearchFilteringDisabled: isSearchFilteringDisabledForChildren = false,
31
30
  className,
32
31
  style,
32
+ onIsOpenChange,
33
33
  ...rest
34
34
  } = _ref;
35
35
  const [items, setItems] = useState([]);
36
- const {
37
- internalSearchValue,
38
- setSearchValue,
39
- zeroSearchResults,
40
- noMatchesText
41
- } = usePaneSearch(externalSearchValue, onSearchValueChange, items);
42
36
  const internalId = useId();
43
37
  const triggerRef = useRef(null);
44
38
  const flyoutRef = useRef(null);
45
- const searchItemRef = useRef(null);
39
+ const stickyBoxRef = useRef(null);
46
40
  const backButtonRef = useRef(null);
47
41
  const {
48
42
  dataTestId: paneContainingTriggerDataTestId,
@@ -57,17 +51,32 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
57
51
  registerSubmenu,
58
52
  setMaskHeight
59
53
  } = useMenuContext();
54
+ const {
55
+ isFocusVisible
56
+ } = useFocusVisible();
60
57
  const thisPanesDepth = useRef(totalOpenPaneDepth + 1).current;
58
+ const [isPaneInDOM, setIsPaneInDOM] = useState(false);
59
+ const [isFrameAfterPaneAddedToDOM, setIsFrameAfterPaneAddedToDOM] = useState(false);
60
+ const [isTransitioningFromRight, setIsTransitioningFromRight] = useState(false);
61
+ const animatedLeft = useMemo(() => thisPanesDepth < totalOpenPaneDepth, [totalOpenPaneDepth, thisPanesDepth]);
62
+ const animatedRight = useMemo(() => thisPanesDepth > totalOpenPaneDepth || isFrameAfterPaneAddedToDOM, [totalOpenPaneDepth, isFrameAfterPaneAddedToDOM, thisPanesDepth]);
61
63
  const paneDataTestId = getSubDataTestId(paneContainingTriggerDataTestId, String(triggerIndex));
62
- const backButtonDataTestId = paneDataTestId?.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_BACK);
63
- const triggerDataTestId = paneDataTestId?.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_ITEM);
64
+ const closeThisSubmenu = e => {
65
+ // prevent closing the entire menu, and Radix keyboard navigation
66
+ e.preventDefault();
67
+ registerSubmenu(internalId, false);
68
+ };
69
+ const {
70
+ internalSearchValue,
71
+ noSearchResultsNode,
72
+ onInteractOutside
73
+ } = usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, items, animatedLeft, animatedRight, paneDataTestId, internalId, flyoutRef, backButtonRef, closeThisSubmenu);
74
+ const backButtonDataTestId = paneDataTestId === null || paneDataTestId === void 0 ? void 0 : paneDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_BACK);
75
+ const triggerDataTestId = paneDataTestId === null || paneDataTestId === void 0 ? void 0 : paneDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_ITEM);
64
76
  const triggerIsVisible = useMemo(() => {
65
77
  var _context;
66
78
  return isSearchFilteringDisabledForPaneContainingTrigger || !paneContainingTriggerSearchValue || typeof label === 'string' && _includesInstanceProperty(_context = label.toLowerCase()).call(_context, paneContainingTriggerSearchValue.toLowerCase());
67
79
  }, [paneContainingTriggerSearchValue, label, isSearchFilteringDisabledForPaneContainingTrigger]);
68
- const [isPaneInDOM, setIsPaneInDOM] = useState(false);
69
- const [isFrameAfterPaneAddedToDOM, setIsFrameAfterPaneAddedToDOM] = useState(false);
70
- const [isTransitioningFromRight, setIsTransitioningFromRight] = useState(false);
71
80
  useDidUpdate(() => {
72
81
  if (isPaneInDOM) {
73
82
  setIsTransitioningFromRight(true);
@@ -76,42 +85,51 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
76
85
  window.requestAnimationFrame(() => setIsFrameAfterPaneAddedToDOM(false));
77
86
  }
78
87
  registerSubmenu(internalId, isPaneInDOM);
88
+ onIsOpenChange === null || onIsOpenChange === void 0 ? void 0 : onIsOpenChange(isPaneInDOM);
79
89
  }, [isPaneInDOM]);
90
+
91
+ // Omitted dependencies because this should only run on unmount
92
+ // eslint-disable-next-line react-hooks/exhaustive-deps
80
93
  useEffect(() => () => registerSubmenu(internalId, false), []);
81
- const closeThisSubmenu = e => {
82
- // prevent closing the entire menu, and Radix keyboard navigation
83
- e.preventDefault();
84
- registerSubmenu(internalId, false);
85
- };
94
+ useDidUpdate(() => {
95
+ if (thisPanesDepth === totalOpenPaneDepth) {
96
+ var _flyoutRef$current$cl, _flyoutRef$current;
97
+ setMaskHeight((_flyoutRef$current$cl = (_flyoutRef$current = flyoutRef.current) === null || _flyoutRef$current === void 0 ? void 0 : _flyoutRef$current.clientHeight) !== null && _flyoutRef$current$cl !== void 0 ? _flyoutRef$current$cl : null);
98
+ }
99
+ },
100
+ // ignoring other dependencies because this should only run when the children change
101
+ [children]);
86
102
  useDidUpdate(() => {
87
103
  if (thisPanesDepth === totalOpenPaneDepth) {
88
104
  window.requestAnimationFrame(() => {
89
- setMaskHeight(flyoutRef.current?.clientHeight ?? null);
105
+ var _flyoutRef$current$cl2, _flyoutRef$current2;
106
+ setMaskHeight((_flyoutRef$current$cl2 = (_flyoutRef$current2 = flyoutRef.current) === null || _flyoutRef$current2 === void 0 ? void 0 : _flyoutRef$current2.clientHeight) !== null && _flyoutRef$current$cl2 !== void 0 ? _flyoutRef$current$cl2 : null);
90
107
  });
91
108
  }
92
109
  }, [totalOpenPaneDepth, internalSearchValue]);
93
- const animatedLeft = useMemo(() => thisPanesDepth < totalOpenPaneDepth, [totalOpenPaneDepth]);
94
- const animatedRight = useMemo(() => thisPanesDepth > totalOpenPaneDepth || isFrameAfterPaneAddedToDOM, [totalOpenPaneDepth, isFrameAfterPaneAddedToDOM]);
95
110
  const handlePaneTransitionEnd = () => {
111
+ var _flyoutRef$current3;
96
112
  if (animatedLeft) {
97
113
  return;
98
114
  }
99
115
  if (animatedRight) {
100
116
  setIsPaneInDOM(false);
101
- if (getIsKeyboardUser()) {
102
- triggerRef.current?.focus();
117
+ if (isFocusVisible) {
118
+ var _triggerRef$current;
119
+ (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.focus();
103
120
  }
104
- } else {
105
- // if the newly closed submenu doesn't place the focus on its trigger
106
- if (!flyoutRef.current?.contains(document.activeElement) && getIsKeyboardUser()) {
107
- if (searchItemRef.current) {
108
- searchItemRef.current.focus();
109
- } else if (backButtonRef.current) {
110
- backButtonRef.current.focus();
111
- }
121
+ return;
122
+ }
123
+
124
+ // if the newly closed submenu doesn't place the focus on its trigger due to mouse events
125
+ if (!((_flyoutRef$current3 = flyoutRef.current) !== null && _flyoutRef$current3 !== void 0 && _flyoutRef$current3.contains(document.activeElement)) && isFocusVisible) {
126
+ if (triggerRef.current && paneContainingTriggerIsInteractive) {
127
+ triggerRef.current.focus();
128
+ } else if (backButtonRef.current) {
129
+ backButtonRef.current.focus();
112
130
  }
113
- setIsTransitioningFromRight(false);
114
131
  }
132
+ setIsTransitioningFromRight(false);
115
133
  };
116
134
  return triggerIsVisible ? /*#__PURE__*/React__default.createElement(Sub, {
117
135
  open: isPaneInDOM
@@ -132,7 +150,7 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
132
150
  if (!isDisabled && _includesInstanceProperty(_context2 = KEYS.OPEN_SUBMENU).call(_context2, e.key)) {
133
151
  setIsPaneInDOM(true);
134
152
  } else if (_includesInstanceProperty(_context3 = KEYS.CLOSE_SUBMENU).call(_context3, e.key)) {
135
- closeSubmenuContainingTrigger?.(e);
153
+ closeSubmenuContainingTrigger === null || closeSubmenuContainingTrigger === void 0 ? void 0 : closeSubmenuContainingTrigger(e);
136
154
  }
137
155
  }
138
156
  }, label, /*#__PURE__*/React__default.createElement(ChevronRightIcon, {
@@ -146,13 +164,15 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
146
164
  isSearchFilteringDisabled: isSearchFilteringDisabledForChildren,
147
165
  isInteractive: !isTransitioningFromRight && !animatedLeft && !animatedRight,
148
166
  closeSubmenu: closeThisSubmenu,
149
- flyoutRef
167
+ flyoutRef,
168
+ stickyBoxRef
150
169
  }
151
170
  }, /*#__PURE__*/React__default.createElement(SubContent, _extends({}, rest, {
152
- loop: true,
171
+ loop: !isSearchable,
153
172
  "data-testid": paneDataTestId,
154
173
  ref: mergeRefs(ref, flyoutRef),
155
- className: classNames(className, styles.flyout, styles.containsStickyBox, {
174
+ onInteractOutside: onInteractOutside,
175
+ className: classNames(className, styles.flyout, {
156
176
  [styles.animatedRight]: animatedRight,
157
177
  [styles.animatedLeft]: animatedLeft
158
178
  }),
@@ -162,11 +182,11 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
162
182
  zIndex: thisPanesDepth
163
183
  }
164
184
  }), /*#__PURE__*/React__default.createElement("div", {
165
- className: styles.stickyBox
166
- }, isSearchable && /*#__PURE__*/React__default.createElement(MenuSearch, {
167
- setSearchValue: setSearchValue,
168
- ref: searchItemRef
169
- }), /*#__PURE__*/React__default.createElement(Item, {
185
+ className: classNames(styles.stickyBox, {
186
+ [styles.isSearchable]: isSearchable
187
+ }),
188
+ ref: stickyBoxRef
189
+ }, /*#__PURE__*/React__default.createElement(Item, {
170
190
  className: classNames(styles.menuItem, {
171
191
  [styles.unresponsive]: isTransitioningFromRight || animatedLeft || animatedRight
172
192
  }),
@@ -182,10 +202,7 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
182
202
  }, /*#__PURE__*/React__default.createElement(ArrowLeftIcon, {
183
203
  size: "small",
184
204
  className: styles.backIcon
185
- }), label)), zeroSearchResults && /*#__PURE__*/React__default.createElement("div", {
186
- className: classNames(styles.menuItem, styles.noItems),
187
- "aria-live": "assertive"
188
- }, noMatchesText), children))) : null;
205
+ }), label)), noSearchResultsNode, children))) : null;
189
206
  });
190
207
 
191
208
  export { SubMenu as default };
@@ -9,7 +9,11 @@ const DATA_TESTID_SUFFIXES = {
9
9
  const KEYS = {
10
10
  OPEN_SUBMENU: ['ArrowRight', 'Enter', ' '],
11
11
  CLOSE_SUBMENU: ['ArrowLeft'],
12
- IGNORED_BY_SEARCH_INPUT: ['Escape', 'ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End']
12
+ NAVIGATE_UP: ['ArrowUp'],
13
+ NAVIGATE_DOWN: ['ArrowDown'],
14
+ NAVIGATE_TOP: ['Home'],
15
+ NAVIIGATE_BOTTOM: ['End'],
16
+ IGNORED_BY_SEARCH_INPUT: ['Tab']
13
17
  };
14
18
 
15
19
  export { DATA_TESTID_SUFFIXES, KEYS };
@@ -0,0 +1,17 @@
1
+ import { useEffect } from 'react';
2
+
3
+ const useMutationObserver = (target, options, onMutate) => useEffect(() => {
4
+ if (!target) {
5
+ return undefined;
6
+ }
7
+ const observer = new MutationObserver(function () {
8
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9
+ args[_key] = arguments[_key];
10
+ }
11
+ onMutate === null || onMutate === void 0 ? void 0 : onMutate(...args);
12
+ });
13
+ observer.observe(target, options);
14
+ return () => observer.disconnect();
15
+ }, [target, options, onMutate]);
16
+
17
+ export { useMutationObserver as default };
@@ -1,25 +1,127 @@
1
- import { useState, useEffect } from 'react';
1
+ import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
2
+ import React__default, { useState, useEffect, useRef, useCallback } from 'react';
3
+ import classNames from 'classnames';
4
+ import { useFocusVisible } from '@react-aria/interactions';
2
5
  import '../../hooks/index.js';
3
6
  import '../../utils/index.js';
7
+ import { useMenuContext } from './MenuContext.js';
8
+ import { KEYS, DATA_TESTID_SUFFIXES } from './constants.js';
9
+ import styles from './Menu2.js';
4
10
  import useControllableState from '../../hooks/useControllableState/useControllableState.js';
5
11
  import useTranslation from '../../utils/Translation/useTranslation.js';
12
+ import useEventListener from '../../hooks/useEventListener/useEventListener.js';
6
13
 
7
14
  // abstracts the logic required for searching by both `MenuPane` and `SubMenu`
8
- function usePaneSearch(externalSearchValue, onSearchValueChange, items) {
15
+ // creates a searchBarConfig, which maps to an instance of `MenuSearch`
16
+ // returns values that are necessary for use within pane
17
+ function usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, items, animatedLeft, animatedRight, menuParentDataTestId, id, flyoutRef) {
18
+ var _searchRef$current$qu, _searchRef$current;
19
+ let backButtonRef = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : undefined;
20
+ let closeSubmenu = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : undefined;
9
21
  const [internalSearchValue, setSearchValue] = useControllableState(externalSearchValue, onSearchValueChange, externalSearchValue);
10
22
  const [zeroSearchResults, setZeroSearchResults] = useState();
11
23
  const {
12
24
  translate
13
25
  } = useTranslation();
14
26
  const noMatchesText = translate('menu.noItemsToDisplay');
27
+ const searchPlaceholder = translate('searchText');
28
+ useEffect(() => setZeroSearchResults((items === null || items === void 0 ? void 0 : items.filter(item => item.element.current).length) === 0), [items, internalSearchValue]);
29
+ const {
30
+ isFocusVisible
31
+ } = useFocusVisible({
32
+ isTextInput: true
33
+ });
34
+ const searchRef = useRef(null);
35
+ const searchInput = (_searchRef$current$qu = (_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.querySelector('input')) !== null && _searchRef$current$qu !== void 0 ? _searchRef$current$qu : null;
36
+ const getFirstNonNullItem = () => {
37
+ var _backButtonRef$curren, _items$find;
38
+ return (_backButtonRef$curren = backButtonRef === null || backButtonRef === void 0 ? void 0 : backButtonRef.current) !== null && _backButtonRef$curren !== void 0 ? _backButtonRef$curren : (_items$find = items.find(item => item.element.current)) === null || _items$find === void 0 ? void 0 : _items$find.element.current;
39
+ };
40
+ const getLastNonNullItem = () => {
41
+ var _findLast$element$cur, _findLast;
42
+ return (// our tsconfig does not target a recent enough version to use `Array.prototype.findLast`
43
+ (_findLast$element$cur = (_findLast = items.findLast(item => item.element.current)) === null || _findLast === void 0 ? void 0 : _findLast.element.current) !== null && _findLast$element$cur !== void 0 ? _findLast$element$cur : backButtonRef === null || backButtonRef === void 0 ? void 0 : backButtonRef.current
44
+ );
45
+ };
46
+ useEventListener(flyoutRef, 'keydown', e => {
47
+ var _context, _context2;
48
+ if (_includesInstanceProperty(_context = KEYS.NAVIGATE_UP).call(_context, e.key) && e.target === getFirstNonNullItem() || _includesInstanceProperty(_context2 = KEYS.NAVIGATE_DOWN).call(_context2, e.key) && e.target === getLastNonNullItem()) {
49
+ searchInput === null || searchInput === void 0 ? void 0 : searchInput.focus();
50
+ }
51
+ }, {
52
+ additionalDependencies: [flyoutRef.current],
53
+ isDisabled: !isSearchable
54
+ });
55
+ useEventListener(searchInput, 'keydown', e => {
56
+ var _context3, _context4, _context5, _e$target, _context6;
57
+ if (_includesInstanceProperty(_context3 = [...KEYS.NAVIGATE_DOWN, ...KEYS.NAVIGATE_TOP]).call(_context3, e.key)) {
58
+ var _getFirstNonNullItem;
59
+ // prevent scrolling
60
+ e.preventDefault();
61
+ (_getFirstNonNullItem = getFirstNonNullItem()) === null || _getFirstNonNullItem === void 0 ? void 0 : _getFirstNonNullItem.focus();
62
+ } else if (_includesInstanceProperty(_context4 = [...KEYS.NAVIGATE_UP, ...KEYS.NAVIIGATE_BOTTOM]).call(_context4, e.key)) {
63
+ var _getLastNonNullItem;
64
+ // prevent scrolling
65
+ e.preventDefault();
66
+ (_getLastNonNullItem = getLastNonNullItem()) === null || _getLastNonNullItem === void 0 ? void 0 : _getLastNonNullItem.focus();
67
+ } else if (_includesInstanceProperty(_context5 = KEYS.CLOSE_SUBMENU).call(_context5, e.key) && ((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.selectionStart) === 0) {
68
+ closeSubmenu === null || closeSubmenu === void 0 ? void 0 : closeSubmenu(e);
69
+ } else if (_includesInstanceProperty(_context6 = KEYS.IGNORED_BY_SEARCH_INPUT).call(_context6, e.key)) {
70
+ e.preventDefault();
71
+ }
72
+ });
73
+ useEventListener(searchInput, 'blur', () => !isFocusVisible && !animatedLeft && !animatedRight && (searchInput === null || searchInput === void 0 ? void 0 : searchInput.focus()));
74
+ const {
75
+ searchBarConfigs,
76
+ setSearchBarConfigs
77
+ } = useMenuContext();
78
+ const onInteractOutside = useCallback(e => searchBarConfigs.some(config => {
79
+ var _config$ref$current;
80
+ return (_config$ref$current = config.ref.current) === null || _config$ref$current === void 0 ? void 0 : _config$ref$current.contains(e.target);
81
+ }) && e.preventDefault(), [searchBarConfigs]);
15
82
  useEffect(() => {
16
- setZeroSearchResults(items?.filter(item => item.element.current).length === 0);
17
- }, [items, internalSearchValue]);
83
+ if (!isSearchable) {
84
+ return undefined;
85
+ }
86
+ setSearchBarConfigs(configs => {
87
+ const configsClone = [...configs];
88
+ const updatedConfig = {
89
+ searchValue: internalSearchValue,
90
+ isInteractive: !animatedLeft && !animatedRight,
91
+ animatedLeft,
92
+ animatedRight,
93
+ dataTestId: menuParentDataTestId === null || menuParentDataTestId === void 0 ? void 0 : menuParentDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_SEARCH),
94
+ setSearchValue,
95
+ ref: searchRef,
96
+ id,
97
+ searchPlaceholder
98
+ };
99
+ const configIndex = configs.findIndex(config => config.id === id);
100
+ if (configIndex === -1) {
101
+ configsClone.push(updatedConfig);
102
+ } else {
103
+ configsClone[configIndex] = updatedConfig;
104
+ }
105
+ return configsClone;
106
+ });
107
+ return () => setSearchBarConfigs(configs => {
108
+ const configIndex = configs.findIndex(config => config.id === id);
109
+ if (configIndex === -1) {
110
+ return configs;
111
+ }
112
+ const configsClone = [...configs];
113
+ configsClone.splice(configIndex, 1);
114
+ return configsClone;
115
+ });
116
+ }, [isSearchable, searchPlaceholder, setSearchBarConfigs, internalSearchValue, animatedLeft, animatedRight, menuParentDataTestId, setSearchValue, searchRef, id]);
117
+ const noSearchResultsNode = zeroSearchResults && /*#__PURE__*/React__default.createElement("div", {
118
+ className: classNames(styles.menuItem, styles.noItems),
119
+ "aria-live": "assertive"
120
+ }, noMatchesText);
18
121
  return {
19
122
  internalSearchValue,
20
- setSearchValue,
21
- zeroSearchResults,
22
- noMatchesText
123
+ noSearchResultsNode,
124
+ onInteractOutside
23
125
  };
24
126
  }
25
127
 
@@ -34,9 +34,10 @@ const PhoneNumberInput = /*#__PURE__*/forwardRef((_ref, ref) => {
34
34
  translate
35
35
  } = useTranslation();
36
36
  const getMinMaxLength = useCallback(() => {
37
+ var _metadata$numberingPl;
37
38
  const metadata = new Metadata();
38
39
  metadata.selectNumberingPlan(countryCode);
39
- const possibleLengths = metadata?.numberingPlan?.possibleLengths();
40
+ const possibleLengths = metadata === null || metadata === void 0 ? void 0 : (_metadata$numberingPl = metadata.numberingPlan) === null || _metadata$numberingPl === void 0 ? void 0 : _metadata$numberingPl.possibleLengths();
40
41
  return possibleLengths ? [Math.min(...possibleLengths), Math.max(...possibleLengths)] : [0, genericMaxNumberLength];
41
42
  }, [countryCode]);
42
43
  const shouldUseMask = Number(getCountryCallingCode(countryCode)) === 1;
@@ -50,7 +51,7 @@ const PhoneNumberInput = /*#__PURE__*/forwardRef((_ref, ref) => {
50
51
  useEffect(() => {
51
52
  updateMask();
52
53
  }, [countryCode, updateMask]);
53
- const removeNonNumericCharacters = value => value?.replace(/\D/g, '');
54
+ const removeNonNumericCharacters = value => value === null || value === void 0 ? void 0 : value.replace(/\D/g, '');
54
55
  const handleInputChange = a => {
55
56
  // remove all non-numeric characters
56
57
  const value = removeNonNumericCharacters(a.target.value);
@@ -66,12 +67,12 @@ const PhoneNumberInput = /*#__PURE__*/forwardRef((_ref, ref) => {
66
67
  } catch (e) {
67
68
  // `parsePhoneNumber` throws an error if the inputs are invalid.
68
69
  }
69
- onChange?.(internationalNumber, isValidLength, countryCode, value);
70
+ onChange === null || onChange === void 0 ? void 0 : onChange(internationalNumber, isValidLength, countryCode, value);
70
71
  };
71
72
  const inputClassNames = classNames(styles.input, {
72
73
  [styles.disabled]: isDisabled
73
74
  });
74
- const dropdownLabel = useMemo(() => countryCode ? `+${getCountryCallingCode(countryCode)}` : undefined, [countryCode]);
75
+ const dropdownLabel = useMemo(() => countryCode ? "+".concat(getCountryCallingCode(countryCode)) : undefined, [countryCode]);
75
76
  return /*#__PURE__*/React__default.createElement("div", {
76
77
  className: styles.container,
77
78
  "data-testid": dataTestId
@@ -88,14 +89,14 @@ const PhoneNumberInput = /*#__PURE__*/forwardRef((_ref, ref) => {
88
89
  disabled: isDisabled,
89
90
  "aria-label": buttonAriaLabel,
90
91
  "aria-labelledby": buttonAriaLabelledBy
91
- }, (countryCodes ?? getCountries()).map(individualCountryCode => {
92
+ }, (countryCodes !== null && countryCodes !== void 0 ? countryCodes : getCountries()).map(individualCountryCode => {
92
93
  if (!isSupportedCountry(individualCountryCode)) {
93
94
  return null;
94
95
  }
95
96
  return /*#__PURE__*/React__default.createElement(MenuItem, {
96
97
  key: individualCountryCode,
97
98
  value: individualCountryCode
98
- }, `${translate(individualCountryCode)} +${getCountryCallingCode(individualCountryCode)}`);
99
+ }, "".concat(translate(individualCountryCode), " +").concat(getCountryCallingCode(individualCountryCode)));
99
100
  })), /*#__PURE__*/React__default.createElement(InputMask, {
100
101
  value: isDisabled ? removeNonNumericCharacters(initialValue) : undefined,
101
102
  type: "tel",
@@ -1,8 +1,8 @@
1
1
  import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
2
2
 
3
- var css_248z = "._0ugqV input{padding-left:76px!important}._5fTUE input{background-color:#e5e5e5!important;color:#9d9fa1!important;cursor:not-allowed!important;-webkit-text-fill-color:#9d9fa1}._5fTUE input::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._5fTUE input::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._jzrnt{position:absolute!important;left:4px;right:4px;bottom:4px;z-index:100;width:67px;height:28px!important;border-radius:4px}._jzrnt,._jzrnt._5fTUE:hover{background-color:transparent!important}._jzrnt:hover{background-color:rgba(50,54,58,.08)!important}._jzrnt:active{background-color:rgba(50,54,58,.11)!important}._jzrnt svg{top:2px!important}._Wv-Ld{position:relative}._Qcs1E{position:absolute;top:18px;left:12px;line-height:0;font-size:14px;color:#32363a;z-index:101;pointer-events:none}";
4
- var styles = {"input":"_0ugqV","disabled":"_5fTUE","dropdown":"_jzrnt","container":"_Wv-Ld","countryCode":"_Qcs1E"};
5
- var stylesheet="._0ugqV input{padding-left:76px!important}._5fTUE input{background-color:#e5e5e5!important;color:#9d9fa1!important;cursor:not-allowed!important;-webkit-text-fill-color:#9d9fa1}._5fTUE input::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._5fTUE input::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._jzrnt{position:absolute!important;left:4px;right:4px;bottom:4px;z-index:100;width:67px;height:28px!important;border-radius:4px}._jzrnt,._jzrnt._5fTUE:hover{background-color:transparent!important}._jzrnt:hover{background-color:rgba(50,54,58,.08)!important}._jzrnt:active{background-color:rgba(50,54,58,.11)!important}._jzrnt svg{top:2px!important}._Wv-Ld{position:relative}._Qcs1E{position:absolute;top:18px;left:12px;line-height:0;font-size:14px;color:#32363a;z-index:101;pointer-events:none}";
3
+ var css_248z = "._YIYhi input{padding-left:76px!important}._8-lxx input{background-color:#e5e5e5!important;color:#9d9fa1!important;cursor:not-allowed!important;-webkit-text-fill-color:#9d9fa1}._8-lxx input::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._8-lxx input::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._Sijhl{position:absolute!important;left:4px;right:4px;bottom:4px;z-index:100;width:67px;height:28px!important;border-radius:4px}._Sijhl,._Sijhl._8-lxx:hover{background-color:transparent!important}._Sijhl:hover{background-color:rgba(50,54,58,.08)!important}._Sijhl:active{background-color:rgba(50,54,58,.11)!important}._Sijhl svg{top:2px!important}._SAdmy{position:relative}._Aoh3n{position:absolute;top:18px;left:12px;line-height:0;font-size:14px;color:#32363a;z-index:101;pointer-events:none}";
4
+ var styles = {"input":"_YIYhi","disabled":"_8-lxx","dropdown":"_Sijhl","container":"_SAdmy","countryCode":"_Aoh3n"};
5
+ var stylesheet="._YIYhi input{padding-left:76px!important}._8-lxx input{background-color:#e5e5e5!important;color:#9d9fa1!important;cursor:not-allowed!important;-webkit-text-fill-color:#9d9fa1}._8-lxx input::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._8-lxx input::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._Sijhl{position:absolute!important;left:4px;right:4px;bottom:4px;z-index:100;width:67px;height:28px!important;border-radius:4px}._Sijhl,._Sijhl._8-lxx:hover{background-color:transparent!important}._Sijhl:hover{background-color:rgba(50,54,58,.08)!important}._Sijhl:active{background-color:rgba(50,54,58,.11)!important}._Sijhl svg{top:2px!important}._SAdmy{position:relative}._Aoh3n{position:absolute;top:18px;left:12px;line-height:0;font-size:14px;color:#32363a;z-index:101;pointer-events:none}";
6
6
  styleInject(css_248z);
7
7
 
8
8
  export { styles as default, stylesheet };
@@ -33,8 +33,14 @@ const SplitButton = /*#__PURE__*/forwardRef((_ref, ref) => {
33
33
  const [mainButtonHasFocus, setMainButtonHasFocus] = useState(false);
34
34
 
35
35
  // Keyboard navigation cannot be implemented using `onKeyDown` on the `button`s because keyboard events are disabled if the buttons are disabled. The consumer must be able to access either button, even if the other is disabled.
36
- useEventListener(mainButtonRef, 'keydown', e => e.key === 'ArrowRight' && dropdownButtonRef.current?.focus());
37
- useEventListener(dropdownButtonRef, 'keydown', e => e.key === 'ArrowLeft' && mainButtonRef.current?.focus());
36
+ useEventListener(mainButtonRef, 'keydown', e => {
37
+ var _dropdownButtonRef$cu;
38
+ return e.key === 'ArrowRight' && ((_dropdownButtonRef$cu = dropdownButtonRef.current) === null || _dropdownButtonRef$cu === void 0 ? void 0 : _dropdownButtonRef$cu.focus());
39
+ });
40
+ useEventListener(dropdownButtonRef, 'keydown', e => {
41
+ var _mainButtonRef$curren;
42
+ return e.key === 'ArrowLeft' && ((_mainButtonRef$curren = mainButtonRef.current) === null || _mainButtonRef$curren === void 0 ? void 0 : _mainButtonRef$curren.focus());
43
+ });
38
44
  return /*#__PURE__*/React__default.createElement("div", {
39
45
  "data-testid": dataTestId,
40
46
  className: classNames(styles.container, className),
@@ -1,8 +1,8 @@
1
1
  import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
2
2
 
3
- var css_248z = "._m7pGf{display:flex}._QN3kF{z-index:2;width:1px;margin-left:-1px;margin-right:-1px}._QN3kF._rQAGM{background-color:#fff}._QN3kF._rQAGM._eo5P0:not(._QN3kF._rQAGM._nnjid),._QN3kF._rZ4iL,body.keyboard-user ._QN3kF._rQAGM._42-Ca:not(._KWjQZ){background-color:#0b6ed0}._QN3kF._rZ4iL._KWjQZ._42-Ca,._QN3kF._rZ4iL._KWjQZ._nnjid,._QN3kF._rZ4iL._nnjid._eo5P0{opacity:.4}._ySQpY{border-radius:4px 0 0 4px;border-right:none;padding-right:17px}._ySQpY:focus{z-index:1}._WKbWy{border-radius:0 4px 4px 0;transition:border .2s,background .2s,color .2s;border-left:none;min-width:35px!important;padding:0!important;justify-content:center!important}._WKbWy svg{margin-left:1px}._WKbWy._rQAGM{background-color:#0b6ed0;border-color:transparent}._WKbWy._rQAGM svg{fill:#fff!important}._WKbWy._rQAGM:not(._KFkhb):hover{background-color:#085caf!important}._WKbWy._rQAGM:not(._KFkhb):active{background-color:#0854a1!important}._WKbWy._rQAGM._KFkhb{opacity:.4}._WKbWy._rQAGM._KFkhb svg{background-color:transparent}._WKbWy._rZ4iL{border-color:#0b6ed0;background-color:#fff}._WKbWy._rZ4iL svg{fill:#0b6ed0!important}._WKbWy._rZ4iL:not(._KFkhb):hover{background-color:#eef5fc!important}._WKbWy._rZ4iL:not(._KFkhb):active{background-color:#e1edf9!important}._WKbWy._rZ4iL._KFkhb{opacity:.4}._WKbWy._rZ4iL._KFkhb svg{background-color:transparent}._mpYIf{width:260px}";
4
- var styles = {"container":"_m7pGf","divider":"_QN3kF","primary":"_rQAGM","mainButtonFocus":"_42-Ca","mainButtonDisabled":"_KWjQZ","dropdownButtonFocus":"_eo5P0","dropdownButtonDisabled":"_nnjid","secondary":"_rZ4iL","mainButton":"_ySQpY","dropdownButton":"_WKbWy","disabled":"_KFkhb","dropdownOption":"_mpYIf"};
5
- var stylesheet="._m7pGf{display:flex}._QN3kF{z-index:2;width:1px;margin-left:-1px;margin-right:-1px}._QN3kF._rQAGM{background-color:#fff}._QN3kF._rQAGM._eo5P0:not(._QN3kF._rQAGM._nnjid),._QN3kF._rZ4iL,body.keyboard-user ._QN3kF._rQAGM._42-Ca:not(._KWjQZ){background-color:#0b6ed0}._QN3kF._rZ4iL._KWjQZ._42-Ca,._QN3kF._rZ4iL._KWjQZ._nnjid,._QN3kF._rZ4iL._nnjid._eo5P0{opacity:.4}._ySQpY{border-radius:4px 0 0 4px;border-right:none;padding-right:17px}._ySQpY:focus{z-index:1}._WKbWy{border-radius:0 4px 4px 0;transition:border .2s,background .2s,color .2s;border-left:none;min-width:35px!important;padding:0!important;justify-content:center!important}._WKbWy svg{margin-left:1px}._WKbWy._rQAGM{background-color:#0b6ed0;border-color:transparent}._WKbWy._rQAGM svg{fill:#fff!important}._WKbWy._rQAGM:not(._KFkhb):hover{background-color:#085caf!important}._WKbWy._rQAGM:not(._KFkhb):active{background-color:#0854a1!important}._WKbWy._rQAGM._KFkhb{opacity:.4}._WKbWy._rQAGM._KFkhb svg{background-color:transparent}._WKbWy._rZ4iL{border-color:#0b6ed0;background-color:#fff}._WKbWy._rZ4iL svg{fill:#0b6ed0!important}._WKbWy._rZ4iL:not(._KFkhb):hover{background-color:#eef5fc!important}._WKbWy._rZ4iL:not(._KFkhb):active{background-color:#e1edf9!important}._WKbWy._rZ4iL._KFkhb{opacity:.4}._WKbWy._rZ4iL._KFkhb svg{background-color:transparent}._mpYIf{width:260px}";
3
+ var css_248z = "._B6seV{display:flex}._pqoB0{z-index:2;width:1px;margin-left:-1px;margin-right:-1px}._pqoB0._UBkiu{background-color:#fff}._pqoB0._3U-X7,._pqoB0._UBkiu._0hH1c:not(._pqoB0._UBkiu._MbRy5),._pqoB0._UBkiu._4gcxR.focus-visible:not(._4ZzAQ),._pqoB0._UBkiu._4gcxR:focus-visible:not(._4ZzAQ){background-color:#0b6ed0}._pqoB0._3U-X7._4ZzAQ._4gcxR,._pqoB0._3U-X7._4ZzAQ._MbRy5,._pqoB0._3U-X7._MbRy5._0hH1c{opacity:.4}._7rzyU{border-radius:4px 0 0 4px;border-right:none;padding-right:17px}._7rzyU:focus{z-index:1}._Mn5Se{border-radius:0 4px 4px 0;transition:border .2s,background .2s,color .2s;border-left:none;min-width:35px!important;padding:0!important;justify-content:center!important}._Mn5Se svg{margin-left:1px}._Mn5Se._UBkiu{background-color:#0b6ed0;border-color:transparent}._Mn5Se._UBkiu svg{fill:#fff!important}._Mn5Se._UBkiu:not(._HDAla):hover{background-color:#085caf!important}._Mn5Se._UBkiu:not(._HDAla):active{background-color:#0854a1!important}._Mn5Se._UBkiu._HDAla{opacity:.4}._Mn5Se._UBkiu._HDAla svg{background-color:transparent}._Mn5Se._3U-X7{border-color:#0b6ed0;background-color:#fff}._Mn5Se._3U-X7 svg{fill:#0b6ed0!important}._Mn5Se._3U-X7:not(._HDAla):hover{background-color:#eef5fc!important}._Mn5Se._3U-X7:not(._HDAla):active{background-color:#e1edf9!important}._Mn5Se._3U-X7._HDAla{opacity:.4}._Mn5Se._3U-X7._HDAla svg{background-color:transparent}._ehPYJ{width:260px}";
4
+ var styles = {"container":"_B6seV","divider":"_pqoB0","primary":"_UBkiu","mainButtonFocus":"_4gcxR","mainButtonDisabled":"_4ZzAQ","dropdownButtonFocus":"_0hH1c","dropdownButtonDisabled":"_MbRy5","secondary":"_3U-X7","mainButton":"_7rzyU","dropdownButton":"_Mn5Se","disabled":"_HDAla","dropdownOption":"_ehPYJ"};
5
+ var stylesheet="._B6seV{display:flex}._pqoB0{z-index:2;width:1px;margin-left:-1px;margin-right:-1px}._pqoB0._UBkiu{background-color:#fff}._pqoB0._3U-X7,._pqoB0._UBkiu._0hH1c:not(._pqoB0._UBkiu._MbRy5),._pqoB0._UBkiu._4gcxR.focus-visible:not(._4ZzAQ),._pqoB0._UBkiu._4gcxR:focus-visible:not(._4ZzAQ){background-color:#0b6ed0}._pqoB0._3U-X7._4ZzAQ._4gcxR,._pqoB0._3U-X7._4ZzAQ._MbRy5,._pqoB0._3U-X7._MbRy5._0hH1c{opacity:.4}._7rzyU{border-radius:4px 0 0 4px;border-right:none;padding-right:17px}._7rzyU:focus{z-index:1}._Mn5Se{border-radius:0 4px 4px 0;transition:border .2s,background .2s,color .2s;border-left:none;min-width:35px!important;padding:0!important;justify-content:center!important}._Mn5Se svg{margin-left:1px}._Mn5Se._UBkiu{background-color:#0b6ed0;border-color:transparent}._Mn5Se._UBkiu svg{fill:#fff!important}._Mn5Se._UBkiu:not(._HDAla):hover{background-color:#085caf!important}._Mn5Se._UBkiu:not(._HDAla):active{background-color:#0854a1!important}._Mn5Se._UBkiu._HDAla{opacity:.4}._Mn5Se._UBkiu._HDAla svg{background-color:transparent}._Mn5Se._3U-X7{border-color:#0b6ed0;background-color:#fff}._Mn5Se._3U-X7 svg{fill:#0b6ed0!important}._Mn5Se._3U-X7:not(._HDAla):hover{background-color:#eef5fc!important}._Mn5Se._3U-X7:not(._HDAla):active{background-color:#e1edf9!important}._Mn5Se._3U-X7._HDAla{opacity:.4}._Mn5Se._3U-X7._HDAla svg{background-color:transparent}._ehPYJ{width:260px}";
6
6
  styleInject(css_248z);
7
7
 
8
8
  export { styles as default, stylesheet };
@@ -43,14 +43,14 @@ const TimeDropdown = _ref => {
43
43
  "aria-label": ariaLabel,
44
44
  "aria-labelledby": ariaLabelledBy,
45
45
  "aria-describedby": ariaDescribedBy,
46
- "data-testid": dataTestId && `${dataTestId}-dropdown`,
46
+ "data-testid": dataTestId && "".concat(dataTestId, "-dropdown"),
47
47
  className: styles.flyout,
48
48
  onMouseOver: () => setIsOptionHovered(true),
49
49
  onMouseLeave: () => setIsOptionHovered(false)
50
50
  }, items.map((item, index) => /*#__PURE__*/React__default.createElement(FlyoutOption, {
51
51
  id: item.id,
52
52
  isHighlightedOnHover: true,
53
- isHighlighted: scrolledToItem?.index === index && scrolledToItem?.isFocused,
53
+ isHighlighted: (scrolledToItem === null || scrolledToItem === void 0 ? void 0 : scrolledToItem.index) === index && (scrolledToItem === null || scrolledToItem === void 0 ? void 0 : scrolledToItem.isFocused),
54
54
  key: item.label,
55
55
  ref: node => {
56
56
  if (node) {
@@ -59,9 +59,9 @@ const TimeDropdown = _ref => {
59
59
  }
60
60
  },
61
61
  onClick: () => onClick(index),
62
- "data-testid": dataTestId && `${dataTestId}-option-${index}`,
62
+ "data-testid": dataTestId && "".concat(dataTestId, "-option-").concat(index),
63
63
  className: classNames(styles.option, {
64
- [styles.exactMatch]: scrolledToItem?.index === index && scrolledToItem.isExactMatch && !isOptionHovered
64
+ [styles.exactMatch]: (scrolledToItem === null || scrolledToItem === void 0 ? void 0 : scrolledToItem.index) === index && scrolledToItem.isExactMatch && !isOptionHovered
65
65
  })
66
66
  }, item.label))),
67
67
  anchorNode: inputRef.current,
@@ -47,7 +47,7 @@ const TimeInput = /*#__PURE__*/forwardRef((_ref, ref) => {
47
47
  correctedTime,
48
48
  selectionModifier
49
49
  } = correctTime(next.value, is24HourClock, false);
50
- const newSelection = next?.selection;
50
+ const newSelection = next === null || next === void 0 ? void 0 : next.selection;
51
51
  if (newSelection) {
52
52
  const validTimeLength = mask.length;
53
53
  newSelection.start = shouldMoveSelectionToEnd ? validTimeLength : newSelection.start;
@@ -79,7 +79,7 @@ const TimeInput = /*#__PURE__*/forwardRef((_ref, ref) => {
79
79
  "aria-labelledby": ariaLabelledBy,
80
80
  "aria-describedby": ariaDescribedBy,
81
81
  "aria-activedescendant": ariaActiveDescendant,
82
- "data-testid": dataTestId && `${dataTestId}-input`
82
+ "data-testid": dataTestId && "".concat(dataTestId, "-input")
83
83
  }));
84
84
  });
85
85
 
@@ -34,8 +34,8 @@ const TimePicker = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
34
34
  'aria-describedby': ariaDescribedBy
35
35
  } = _ref;
36
36
  const timePickerId = useId(externalId);
37
- const inputId = `${timePickerId}-input`;
38
- const dropdownId = `${timePickerId}-dropdown`;
37
+ const inputId = "".concat(timePickerId, "-input");
38
+ const dropdownId = "".concat(timePickerId, "-dropdown");
39
39
  const [isOptionHovered, setIsOptionHovered] = useState(false);
40
40
  const [timeObject, setTimeObject] = useControllableState(DEFAULT_TIME, externalOnChange, externalValue);
41
41
  const defaultTimeString = convertTimeObjectToTimeString(timeObject, is24HourClock);
@@ -164,7 +164,7 @@ const TimePicker = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
164
164
  break;
165
165
  case 'Enter':
166
166
  e.preventDefault();
167
- if (scrolledToItem?.isFocused) {
167
+ if (scrolledToItem !== null && scrolledToItem !== void 0 && scrolledToItem.isFocused) {
168
168
  // "focus" is on the listbox
169
169
  handleSelectTime(scrolledToItem.index);
170
170
  } else {
@@ -187,7 +187,7 @@ const TimePicker = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
187
187
  }, /*#__PURE__*/React__default.createElement(TimeInput, {
188
188
  id: inputId,
189
189
  dataTestId: dataTestId,
190
- ariaActiveDescendant: isFlyoutOpen && scrolledToItem?.isFocused ? dropdownItems[scrolledToItem.index].id : undefined,
190
+ ariaActiveDescendant: isFlyoutOpen && scrolledToItem !== null && scrolledToItem !== void 0 && scrolledToItem.isFocused ? dropdownItems[scrolledToItem.index].id : undefined,
191
191
  ariaControls: dropdownId,
192
192
  ariaExpanded: isFlyoutOpen,
193
193
  onChange: handleType,
@@ -1,8 +1,8 @@
1
1
  import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
2
2
 
3
- var css_248z = "._6AuTd{display:inline-block;position:relative}._T8Igi{width:120px}._T8Igi ._oQAxS._1aRma{transform:rotate(-180deg)}._T8Igi ._oQAxS._yi66Q{fill:#9d9fa1;opacity:.4}._FoDQd>input:focus{box-shadow:none!important;border:1px solid #898989!important}._xcPSL{width:120px}._xcPSL ._oQ88Q._mh0Tq{background-color:#efefef;border-radius:6px}._oQAxS{position:absolute;right:4px;bottom:4px;height:28px;width:28px}._oQAxS._1aRma{transform:rotate(-180deg)}";
4
- var styles = {"container":"_6AuTd","input":"_T8Igi","icon":"_oQAxS","open":"_1aRma","disabled":"_yi66Q","ignoreFocusStyle":"_FoDQd","flyout":"_xcPSL","option":"_oQ88Q","exactMatch":"_mh0Tq"};
5
- var stylesheet="._6AuTd{display:inline-block;position:relative}._T8Igi{width:120px}._T8Igi ._oQAxS._1aRma{transform:rotate(-180deg)}._T8Igi ._oQAxS._yi66Q{fill:#9d9fa1;opacity:.4}._FoDQd>input:focus{box-shadow:none!important;border:1px solid #898989!important}._xcPSL{width:120px}._xcPSL ._oQ88Q._mh0Tq{background-color:#efefef;border-radius:6px}._oQAxS{position:absolute;right:4px;bottom:4px;height:28px;width:28px}._oQAxS._1aRma{transform:rotate(-180deg)}";
3
+ var css_248z = "._Li157{display:inline-block;position:relative}._qGkcS{width:120px}._qGkcS ._gv4Jw._9W5cr{transform:rotate(-180deg)}._qGkcS ._gv4Jw._g5S4T{fill:#9d9fa1;opacity:.4}._txezi>input:focus{box-shadow:none!important;border:1px solid #898989!important}._FjddE{width:120px}._FjddE ._Yf4jJ._QMeNI{background-color:#efefef;border-radius:6px}._gv4Jw{position:absolute;right:4px;bottom:4px;height:28px;width:28px}._gv4Jw._9W5cr{transform:rotate(-180deg)}";
4
+ var styles = {"container":"_Li157","input":"_qGkcS","icon":"_gv4Jw","open":"_9W5cr","disabled":"_g5S4T","ignoreFocusStyle":"_txezi","flyout":"_FjddE","option":"_Yf4jJ","exactMatch":"_QMeNI"};
5
+ var stylesheet="._Li157{display:inline-block;position:relative}._qGkcS{width:120px}._qGkcS ._gv4Jw._9W5cr{transform:rotate(-180deg)}._qGkcS ._gv4Jw._g5S4T{fill:#9d9fa1;opacity:.4}._txezi>input:focus{box-shadow:none!important;border:1px solid #898989!important}._FjddE{width:120px}._FjddE ._Yf4jJ._QMeNI{background-color:#efefef;border-radius:6px}._gv4Jw{position:absolute;right:4px;bottom:4px;height:28px;width:28px}._gv4Jw._9W5cr{transform:rotate(-180deg)}";
6
6
  styleInject(css_248z);
7
7
 
8
8
  export { styles as default, stylesheet };
@@ -23,8 +23,9 @@ const TimePickerIcon = _ref => {
23
23
  })
24
24
  }, /*#__PURE__*/React__default.createElement(ChevronDownIcon, {
25
25
  onClick: !isDisabled ? () => {
26
+ var _inputRef$current;
26
27
  setIsFlyoutOpen(i => !i);
27
- inputRef.current?.focus();
28
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
28
29
  } : undefined,
29
30
  onMouseDown: e => e.preventDefault(),
30
31
  ref: iconRef