@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.
- package/CHANGELOG.md +17 -33
- package/dist/__shared/cjs/{index-90d4069b.js → index-025620bf.js} +718 -673
- package/dist/__shared/cjs/{index-579c4690.js → index-41a013d2.js} +4 -4
- package/dist/components/Accordion/Accordion.js +1 -1
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/Accordion/AccordionHeader.js +4 -4
- package/dist/components/Accordion/AccordionPanel.js +3 -3
- package/dist/components/Button/Button.js +3 -3
- package/dist/components/Button/Button2.js +2 -2
- package/dist/components/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
- package/dist/components/Checkbox/Checkbox.js +11 -11
- package/dist/components/Checkbox/Checkbox2.js +3 -3
- package/dist/components/Checkbox/VisualCheckbox2.js +3 -3
- package/dist/components/ColorPicker/Alpha.js +12 -16
- package/dist/components/ColorPicker/ColorPicker.js +15 -9
- package/dist/components/ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/ColorPicker/ColorPickerFlyout.js +9 -4
- package/dist/components/ColorPicker/ColorPickerFlyoutInputs.js +8 -6
- package/dist/components/ColorPicker/Hue.js +3 -9
- package/dist/components/ColorPicker/Palette.js +13 -9
- package/dist/components/ColorPicker/Saturation.js +9 -17
- package/dist/components/ColorPicker/utils/hexToRgbaString.js +3 -2
- package/dist/components/ColorPicker/utils/rgbToHex.js +1 -1
- package/dist/components/ColorPicker/utils/validateHex.js +10 -9
- package/dist/components/Combobox/Combobox.js +54 -31
- package/dist/components/Combobox/Combobox2.js +3 -3
- package/dist/components/Combobox/ComboboxHeader.js +1 -1
- package/dist/components/Combobox/ComboboxIcon.js +3 -2
- package/dist/components/Combobox/ComboboxInput.js +4 -4
- package/dist/components/Combobox/ComboboxList.js +2 -2
- package/dist/components/ConfigPane/ConfigPane2.js +3 -3
- package/dist/components/Divider/Divider2.js +3 -3
- package/dist/components/Dropdown/ChildIndexContext/reach-descendants.js +5 -2
- package/dist/components/Dropdown/Dropdown.js +14 -14
- package/dist/components/Dropdown/Dropdown2.js +3 -3
- package/dist/components/Dropdown/DropdownButton.js +23 -19
- package/dist/components/Dropdown/DropdownList.js +4 -4
- package/dist/components/Dropdown/DropdownOption.js +5 -7
- package/dist/components/Dropdown/DropdownSearch.js +12 -9
- package/dist/components/FilePicker/FilePicker.js +13 -13
- package/dist/components/FilePicker/FilePicker2.js +3 -3
- package/dist/components/FormField/Caption.js +3 -3
- package/dist/components/FormField/FormField.js +2 -2
- package/dist/components/FormField/FormField2.js +3 -3
- package/dist/components/FormField/FormFieldContext.js +3 -3
- package/dist/components/FullScreenTakeover/FullScreenTakeover.js +5 -3
- package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
- package/dist/components/Icon/Icon.js +2 -2
- package/dist/components/IconButton/IconButton2.js +3 -3
- package/dist/components/InlineInput/InlineInput.js +12 -9
- package/dist/components/InlineInput/InlineInput2.js +3 -3
- package/dist/components/Input/Input.js +1 -1
- package/dist/components/Input/Input2.js +3 -3
- package/dist/components/Input/InputField.js +2 -2
- package/dist/components/InputGroup/InputGroup2.js +3 -3
- package/dist/components/Label/Label2.js +3 -3
- package/dist/components/Link/Link2.js +3 -3
- package/dist/components/LoadingSpinner/LoadingSpinner.js +1 -1
- package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
- package/dist/components/LogicEditor/ConditionSet.js +5 -5
- package/dist/components/LogicEditor/LogicEditor.js +1 -1
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/LogicEditor/utils.js +2 -1
- package/dist/components/Modal/Modal.js +14 -13
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/BaseMenu.js +41 -30
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NewMenu/SelectMenu/SelectMenu.js +2 -2
- package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +19 -15
- package/dist/components/NewMenu/parts/MenuItem.js +1 -1
- package/dist/components/NumberStepper/NumberStepper.js +7 -6
- package/dist/components/NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/NumberStepper/NumberStepperDecrement.js +1 -1
- package/dist/components/NumberStepper/NumberStepperIncrement.js +1 -1
- package/dist/components/NumberStepper/NumberStepperInput.js +3 -3
- package/dist/components/PageLayout/PageLayout.js +3 -3
- package/dist/components/Pagination/Pagination.js +1 -1
- package/dist/components/Pagination/Pagination2.js +3 -3
- package/dist/components/Pagination/PaginationNextButton.js +5 -5
- package/dist/components/Pagination/PaginationPageInput.js +11 -9
- package/dist/components/Pagination/PaginationPreviousButton.js +5 -5
- package/dist/components/Popover/Popover.js +9 -7
- package/dist/components/Popover/Popover2.js +3 -3
- package/dist/components/QuickSearch/QuickSearch.js +4 -3
- package/dist/components/QuickSearch/QuickSearch2.js +3 -3
- package/dist/components/QuickSearch/QuickSearchInput.js +4 -4
- package/dist/components/Radio/Radio.js +12 -11
- package/dist/components/Radio/Radio2.js +3 -3
- package/dist/components/SearchInput/SearchInput.js +4 -3
- package/dist/components/SearchInput/SearchInput2.js +3 -3
- package/dist/components/SidebarNav/SidebarNav.js +2 -1
- package/dist/components/SidebarNav/SidebarNav2.js +3 -3
- package/dist/components/SidebarNav/SidebarNavLink.js +1 -1
- package/dist/components/Slider/RangeSlider.js +2 -2
- package/dist/components/Slider/Slider.js +1 -1
- package/dist/components/Slider/Slider2.js +3 -3
- package/dist/components/Slider/SliderButton.js +1 -1
- package/dist/components/Switch/Switch.js +11 -11
- package/dist/components/Switch/Switch2.js +3 -3
- package/dist/components/Table/Table2.js +3 -3
- package/dist/components/Tabs/Tab.js +3 -3
- package/dist/components/Tabs/TabList.js +6 -5
- package/dist/components/Tabs/TabPanel.js +3 -3
- package/dist/components/Tabs/Tabs2.js +3 -3
- package/dist/components/Tooltip/Tooltip.js +15 -7
- package/dist/components/Tooltip/Tooltip2.js +3 -3
- package/dist/components/UIProvider/UIProvider.js +2 -2
- package/dist/components/deprecated_ColorPicker/Alpha.js +4 -4
- package/dist/components/deprecated_ColorPicker/Color.js +6 -6
- package/dist/components/deprecated_ColorPicker/ColorPicker.js +2 -2
- package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/deprecated_ColorPicker/HexInput.js +1 -1
- package/dist/components/deprecated_ColorPicker/Hue.js +3 -3
- package/dist/components/deprecated_ColorPicker/Saturation.js +5 -5
- package/dist/components/deprecated_ColorPicker/Swatch.js +2 -2
- package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/deprecated_NumberStepper/NumberStepperDecrement.js +2 -2
- package/dist/components/deprecated_NumberStepper/NumberStepperIncrement.js +2 -2
- package/dist/components/deprecated_NumberStepper/NumberStepperInput.js +8 -8
- package/dist/components/deprecated_Tabs/Tabs.js +11 -7
- package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
- package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
- package/dist/components/deprecated_Toolbar/ToolbarPanel.js +3 -3
- package/dist/components/deprecated_Toolbar/ToolbarPanels.js +4 -29
- package/dist/components/deprecated_Toolbar/ToolbarTab.js +8 -8
- package/dist/components/deprecated_Toolbar/ToolbarTabs.js +6 -3
- package/dist/hooks/useBreakpoints/useBreakpoints.js +1 -1
- package/dist/hooks/useClickOutside/useClickOutside.js +2 -1
- package/dist/hooks/useControllableState/useControllableState.js +2 -1
- package/dist/hooks/useEventListener/useEventListener.js +4 -1
- package/dist/hooks/useId/useId.js +1 -1
- package/dist/hooks/useOverlay/useOverlay.js +11 -6
- package/dist/hooks/useOverlay/useOverlay2.js +3 -3
- package/dist/hooks/useResponsiveValue/useResponsiveValue.js +2 -1
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +4 -2
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/createIconComponent.js +1 -1
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +17 -8
- package/dist/index.es.js +1 -7
- package/dist/index.js +4 -7
- package/dist/next/AdvancedTable/AdvancedTable.js +86 -87
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTableCell.js +6 -4
- package/dist/next/AdvancedTable/AdvancedTableColumnHeader.js +18 -10
- package/dist/next/AdvancedTable/AdvancedTableColumnHeaderMenu.js +7 -6
- package/dist/next/AdvancedTable/AdvancedTableDragPreview.js +5 -4
- package/dist/next/AdvancedTable/AdvancedTablePagination.js +1 -1
- package/dist/next/AdvancedTable/useAdvancedTableDragAndDrop.js +3 -2
- package/dist/next/AdvancedTable/useComputedWidth.js +1 -1
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput.js +6 -5
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInputIconButton.js +1 -1
- package/dist/next/Combobox/Combobox2.js +3 -3
- package/dist/next/Combobox/ComboboxFlyout.js +2 -2
- package/dist/next/Combobox/ComboboxGroup.js +1 -1
- package/dist/next/Combobox/ComboboxInput.js +2 -2
- package/dist/next/Combobox/ComboboxOption.js +1 -1
- package/dist/next/Combobox/hooks/useComboboxFilteredGroup/useComboboxFilteredGroup.js +1 -1
- package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +12 -8
- package/dist/next/Combobox/hooks/useComboboxValue/useComboboxValue.js +1 -1
- package/dist/next/Combobox/hooks/useListboxFlyoutDimensions/useListboxFlyoutDimensions.js +3 -2
- package/dist/next/Combobox/hooks/useSelectedOptionScroll/useSelectedOptionScroll.js +2 -1
- package/dist/next/Combobox/hooks/useShouldRenderGroupHeader/useShouldRenderGroupHeader.js +2 -1
- package/dist/next/Combobox/utils/nodeRegistration/nodeRegistration.js +1 -1
- package/dist/next/Drawer/Drawer.js +7 -4
- package/dist/next/Drawer/Drawer2.js +3 -3
- package/dist/next/FilterAnchor/FilterAnchor.js +3 -3
- package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
- package/dist/next/Input/Input.js +2 -2
- package/dist/next/Input/Input2.js +3 -3
- package/dist/next/Menu/Menu.js +11 -5
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuItem.js +19 -11
- package/dist/next/Menu/MenuPane.js +70 -40
- package/dist/next/Menu/MenuSearch.js +16 -71
- package/dist/next/Menu/SubMenu.js +63 -46
- package/dist/next/Menu/constants.js +5 -1
- package/dist/next/Menu/useMutationObserver.js +17 -0
- package/dist/next/Menu/usePaneSearch.js +109 -7
- package/dist/next/PhoneNumberInput/PhoneNumberInput.js +7 -6
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/SplitButton/SplitButton.js +8 -2
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/TimePicker/TimeDropdown.js +4 -4
- package/dist/next/TimePicker/TimeInput.js +2 -2
- package/dist/next/TimePicker/TimePicker.js +4 -4
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/TimePicker/TimePickerIcon.js +2 -1
- package/dist/next/TimePicker/utils.js +10 -9
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.d.ts +2 -1
- package/dist/next/index.js +601 -432
- package/dist/utils/Flyout/Flyout.js +1 -1
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/dist/utils/Popper/Popper.js +9 -5
- package/dist/utils/TextOverflowTooltip/TextOverflowTooltip.js +2 -1
- package/dist/utils/Translation/useTranslation.js +4 -5
- package/dist/utils/filterChildren/filterChildren.js +2 -1
- package/dist/utils/getSubDataTestId/getSubDataTestId.js +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/mediaQueryManager/mediaQueryManager.js +1 -1
- package/dist/utils/mergeRefs/mergeRefs.js +1 -1
- package/dist/utils/wrapEvent/wrapEvent.js +2 -2
- package/icons/package.json +1 -0
- package/next/package.json +2 -1
- package/package.json +4 -4
- package/dist/utils/keyboardUser/index.js +0 -1
- 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
|
|
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
|
|
63
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
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 (
|
|
102
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
|
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:
|
|
171
|
+
loop: !isSearchable,
|
|
153
172
|
"data-testid": paneDataTestId,
|
|
154
173
|
ref: mergeRefs(ref, flyoutRef),
|
|
155
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
ref:
|
|
169
|
-
}
|
|
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)),
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
21
|
-
|
|
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
|
|
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
|
|
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
|
|
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 ?
|
|
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
|
|
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
|
-
},
|
|
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 = ".
|
|
4
|
-
var styles = {"input":"
|
|
5
|
-
var stylesheet=".
|
|
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 =>
|
|
37
|
-
|
|
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 = ".
|
|
4
|
-
var styles = {"container":"
|
|
5
|
-
var stylesheet=".
|
|
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 &&
|
|
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
|
|
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 &&
|
|
62
|
+
"data-testid": dataTestId && "".concat(dataTestId, "-option-").concat(index),
|
|
63
63
|
className: classNames(styles.option, {
|
|
64
|
-
[styles.exactMatch]: scrolledToItem
|
|
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
|
|
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 &&
|
|
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 =
|
|
38
|
-
const dropdownId =
|
|
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
|
|
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
|
|
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 = ".
|
|
4
|
-
var styles = {"container":"
|
|
5
|
-
var stylesheet=".
|
|
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
|
|
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
|