@qualtrics/ui-react 2.19.0 → 2.19.1
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 +16 -0
- package/dist/__shared/cjs/{index-4e4cc354.js → index-384184bd.js} +994 -1872
- package/dist/__shared/cjs/{index-bf07471d.js → index-4a5425cc.js} +10 -7
- package/dist/components/Accordion/Accordion.js +1 -5
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/Accordion/AccordionHeader.js +4 -8
- package/dist/components/Accordion/AccordionPanel.js +3 -3
- package/dist/components/BreakpointSwitch/Breakpoint.js +0 -2
- package/dist/components/BreakpointSwitch/BreakpointSwitch.js +0 -3
- package/dist/components/Button/Button.js +3 -3
- package/dist/components/Button/Button2.js +2 -7
- package/dist/components/ButtonGroup/ButtonGroup.js +1 -2
- 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/VisualCheckbox.js +1 -1
- package/dist/components/Checkbox/VisualCheckbox2.js +3 -3
- package/dist/components/ColorPicker/Alpha.js +9 -30
- package/dist/components/ColorPicker/ColorPicker.js +33 -42
- package/dist/components/ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/ColorPicker/ColorPickerFlyout.js +2 -1
- package/dist/components/ColorPicker/ColorPickerFlyoutInputs.js +20 -23
- package/dist/components/ColorPicker/Hue.js +2 -19
- package/dist/components/ColorPicker/Palette.js +7 -27
- package/dist/components/ColorPicker/Saturation.js +8 -29
- package/dist/components/ColorPicker/utils/calculateTargetId.js +10 -20
- package/dist/components/ColorPicker/utils/getMousePosition.js +4 -3
- package/dist/components/ColorPicker/utils/hexToHsv.js +0 -5
- package/dist/components/ColorPicker/utils/hexToRgbaString.js +2 -4
- package/dist/components/ColorPicker/utils/hsvToHex.js +0 -3
- package/dist/components/ColorPicker/utils/rgbToHex.js +1 -1
- package/dist/components/ColorPicker/utils/validateHex.js +12 -19
- package/dist/components/Combobox/Combobox.js +57 -127
- package/dist/components/Combobox/Combobox2.js +3 -3
- package/dist/components/Combobox/ComboboxHeader.js +1 -1
- package/dist/components/Combobox/ComboboxIcon.js +2 -4
- package/dist/components/Combobox/ComboboxInput.js +4 -5
- package/dist/components/Combobox/ComboboxList.js +2 -2
- package/dist/components/ConfigPane/ConfigPane.js +0 -7
- package/dist/components/ConfigPane/ConfigPane2.js +3 -3
- package/dist/components/Divider/Divider2.js +3 -3
- package/dist/components/Dropdown/ChildIndexContext/index.js +0 -1
- package/dist/components/Dropdown/ChildIndexContext/reach-descendants.js +34 -30
- package/dist/components/Dropdown/Dropdown.js +17 -68
- package/dist/components/Dropdown/Dropdown2.js +3 -3
- package/dist/components/Dropdown/DropdownButton.js +23 -33
- package/dist/components/Dropdown/DropdownHeader.js +2 -1
- package/dist/components/Dropdown/DropdownList.js +8 -7
- package/dist/components/Dropdown/DropdownOption.js +3 -10
- package/dist/components/Dropdown/DropdownSearch.js +6 -24
- package/dist/components/FilePicker/FilePicker.js +15 -26
- 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 -6
- package/dist/components/FormField/ReadOnlyText.js +2 -1
- package/dist/components/FullScreenTakeover/FullScreenTakeover.js +5 -11
- package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
- package/dist/components/Icon/Icon.js +3 -6
- package/dist/components/Icon/IconTypes.js +1 -0
- package/dist/components/IconButton/IconButton.js +1 -6
- package/dist/components/IconButton/IconButton2.js +3 -3
- package/dist/components/InlineInput/InlineInput.js +16 -33
- package/dist/components/InlineInput/InlineInput2.js +3 -3
- package/dist/components/Input/Input.js +3 -2
- package/dist/components/Input/Input2.js +3 -3
- package/dist/components/Input/InputField.js +2 -5
- package/dist/components/InputGroup/InputGroup2.js +3 -3
- package/dist/components/InputGroup/InputGroupProvider.js +0 -2
- 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/ConditionContainer.js +0 -2
- package/dist/components/LogicEditor/ConditionSet.js +8 -25
- package/dist/components/LogicEditor/Controls.js +2 -2
- package/dist/components/LogicEditor/LogicEditor.js +3 -12
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/LogicEditor/utils.js +9 -34
- package/dist/components/Modal/Modal.js +22 -35
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/BaseMenu.js +43 -108
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NewMenu/SelectMenu/SelectMenu.js +2 -3
- package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +20 -32
- package/dist/components/NewMenu/parts/MenuItem.js +2 -3
- package/dist/components/NewMenu/parts/MenuSearchBox.js +2 -1
- package/dist/components/NumberStepper/NumberStepper.js +29 -44
- package/dist/components/NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/NumberStepper/NumberStepperDecrement.js +6 -5
- package/dist/components/NumberStepper/NumberStepperIncrement.js +6 -5
- package/dist/components/NumberStepper/NumberStepperInput.js +10 -12
- package/dist/components/PageLayout/PageLayout.js +3 -3
- package/dist/components/Pagination/Pagination.js +10 -6
- package/dist/components/Pagination/Pagination2.js +3 -3
- package/dist/components/Pagination/PaginationNextButton.js +8 -8
- package/dist/components/Pagination/PaginationPageInput.js +17 -22
- package/dist/components/Pagination/PaginationPreviousButton.js +8 -8
- package/dist/components/Popover/Popover.js +9 -18
- package/dist/components/Popover/Popover2.js +3 -3
- package/dist/components/QuickSearch/QuickSearch.js +3 -5
- package/dist/components/QuickSearch/QuickSearch2.js +3 -3
- package/dist/components/QuickSearch/QuickSearchInput.js +6 -23
- package/dist/components/Radio/Radio.js +11 -13
- package/dist/components/Radio/Radio2.js +3 -3
- package/dist/components/SearchInput/SearchInput.js +5 -11
- package/dist/components/SearchInput/SearchInput2.js +3 -3
- package/dist/components/SidebarNav/ExpandCollapseButton.js +0 -2
- package/dist/components/SidebarNav/SidebarNav.js +5 -4
- package/dist/components/SidebarNav/SidebarNav2.js +3 -3
- package/dist/components/SidebarNav/SidebarNavLink.js +1 -4
- package/dist/components/Slider/RangeSlider.js +8 -22
- package/dist/components/Slider/Slider.js +7 -26
- package/dist/components/Slider/Slider2.js +3 -3
- package/dist/components/Slider/SliderButton.js +7 -9
- 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/TabContextProvider.js +1 -1
- package/dist/components/Tabs/TabList.js +9 -17
- package/dist/components/Tabs/TabPanel.js +3 -3
- package/dist/components/Tabs/TabPanels.js +0 -2
- package/dist/components/Tabs/Tabs2.js +3 -3
- package/dist/components/Tooltip/Tooltip.js +12 -41
- package/dist/components/Tooltip/Tooltip2.js +3 -3
- package/dist/components/UIProvider/PortalTargetContext.js +0 -1
- package/dist/components/UIProvider/UIProvider.js +2 -2
- package/dist/components/deprecated_ColorPicker/Alpha.js +4 -11
- package/dist/components/deprecated_ColorPicker/Color.js +9 -66
- package/dist/components/deprecated_ColorPicker/ColorPicker.js +2 -8
- package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/deprecated_ColorPicker/HexInput.js +1 -7
- package/dist/components/deprecated_ColorPicker/Hue.js +3 -10
- package/dist/components/deprecated_ColorPicker/Saturation.js +7 -14
- package/dist/components/deprecated_ColorPicker/Swatch.js +2 -6
- package/dist/components/deprecated_ColorPicker/useMouseDrag.js +0 -3
- package/dist/components/deprecated_NumberStepper/NumberStepper.js +14 -20
- package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/deprecated_NumberStepper/NumberStepperDecrement.js +7 -6
- package/dist/components/deprecated_NumberStepper/NumberStepperIncrement.js +7 -6
- package/dist/components/deprecated_NumberStepper/NumberStepperInput.js +16 -17
- package/dist/components/deprecated_Tabs/Tabs.js +9 -25
- 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 +3 -17
- package/dist/components/deprecated_Toolbar/ToolbarTab.js +10 -26
- package/dist/components/deprecated_Toolbar/ToolbarTabs.js +6 -18
- package/dist/hooks/useBreakpoints/useBreakpoints.js +3 -4
- package/dist/hooks/useClickOutside/useClickOutside.js +2 -7
- package/dist/hooks/useClickOutsidePortals/useClickOutsidePortals.js +3 -6
- package/dist/hooks/useControllableState/useControllableState.js +5 -10
- package/dist/hooks/useDidUpdate/useDidUpdate.js +2 -4
- package/dist/hooks/useEventCallback/useEventCallback.js +2 -1
- package/dist/hooks/useEventListener/useEventListener.js +1 -4
- package/dist/hooks/useFocusSequence/useFocusSequence.js +10 -17
- package/dist/hooks/useId/useId.js +1 -2
- package/dist/hooks/useIsFocused/useIsFocused.js +0 -1
- package/dist/hooks/useIsHovered/useIsHovered.js +0 -1
- package/dist/hooks/useIsTruncated/useIsTruncated.js +4 -3
- package/dist/hooks/useLatest/useLatest.js +0 -1
- package/dist/hooks/useMounted/useMounted.js +0 -1
- package/dist/hooks/useMouseDrag/useMouseDrag.js +0 -4
- package/dist/hooks/useOverlay/useOverlay.js +4 -10
- package/dist/hooks/useOverlay/useOverlay2.js +3 -3
- package/dist/hooks/usePrevious/usePrevious.js +0 -1
- package/dist/hooks/useResponsiveValue/useResponsiveValue.js +1 -4
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +11 -16
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/components/HeadsetIcon.js +6 -0
- package/dist/icons/components/PauseCircleIcon.js +1 -1
- package/dist/icons/createIconComponent.js +2 -3
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.es.js +1 -0
- package/dist/icons/index.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +4 -3
- package/dist/index.js +6 -5
- package/dist/next/AdvancedTable/AdvancedTable.js +82 -188
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTableCell.js +4 -14
- package/dist/next/AdvancedTable/AdvancedTableCheckbox.js +0 -1
- package/dist/next/AdvancedTable/AdvancedTableColumnHeader.js +11 -41
- package/dist/next/AdvancedTable/AdvancedTableColumnHeaderMenu.js +8 -14
- package/dist/next/AdvancedTable/AdvancedTableDragPreview.js +4 -6
- package/dist/next/AdvancedTable/AdvancedTablePagination.js +1 -4
- package/dist/next/AdvancedTable/AdvancedTableRowExpandButton.js +0 -1
- package/dist/next/AdvancedTable/AdvancedTableTypes.js +1 -3
- package/dist/next/AdvancedTable/useAdvancedTableDragAndDrop.js +8 -13
- package/dist/next/AdvancedTable/useComputedWidth.js +1 -1
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput.js +5 -20
- 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 +3 -3
- package/dist/next/Combobox/ComboboxGroup.js +1 -1
- package/dist/next/Combobox/ComboboxInput.js +7 -20
- package/dist/next/Combobox/ComboboxOption.js +5 -6
- package/dist/next/Combobox/hooks/useComboboxFilteredGroup/useComboboxFilteredGroup.js +4 -5
- package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +37 -54
- package/dist/next/Combobox/hooks/useComboboxLoadingState/useComboboxLoadingState.js +4 -5
- package/dist/next/Combobox/hooks/useComboboxValue/useComboboxValue.js +5 -3
- package/dist/next/Combobox/hooks/useListboxFlyoutDimensions/useListboxFlyoutDimensions.js +10 -10
- package/dist/next/Combobox/hooks/useSelectedOptionScroll/useSelectedOptionScroll.js +1 -6
- package/dist/next/Combobox/hooks/useShouldRenderGroupHeader/useShouldRenderGroupHeader.js +6 -6
- package/dist/next/Combobox/utils/nodeRegistration/nodeRegistration.js +4 -6
- package/dist/next/Drawer/Drawer.js +5 -16
- package/dist/next/Drawer/Drawer2.js +3 -3
- package/dist/next/FilterAnchor/FilterAnchor.js +7 -5
- package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
- package/dist/next/Input/Input.js +5 -8
- package/dist/next/Input/Input2.js +3 -3
- package/dist/next/Menu/Menu.js +10 -23
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuContext.js +0 -2
- package/dist/next/Menu/MenuItem.js +11 -15
- package/dist/next/Menu/MenuPane.js +11 -25
- package/dist/next/Menu/MenuSearch.js +15 -22
- package/dist/next/Menu/SubMenu.js +10 -27
- package/dist/next/Menu/usePaneSearch.js +2 -1
- package/dist/next/PhoneNumberInput/PhoneNumberInput.js +12 -19
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/SplitButton/SplitButton.js +6 -12
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/Stack/Stack.js +0 -3
- package/dist/next/TimePicker/TimeDropdown.js +4 -5
- package/dist/next/TimePicker/TimeInput.js +4 -5
- package/dist/next/TimePicker/TimePicker.js +12 -30
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/TimePicker/TimePickerIcon.js +1 -3
- package/dist/next/TimePicker/utils.js +12 -52
- package/dist/next/ToggleButton/ToggleButton.js +0 -5
- package/dist/next/ToggleButton/ToggleButtonGroup.js +2 -1
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.js +376 -748
- package/dist/utils/Flyout/Flyout.js +4 -5
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/dist/utils/Popper/Popper.js +18 -25
- package/dist/utils/Portal/Portal.js +2 -1
- package/dist/utils/TextOverflowTooltip/TextOverflowTooltip.js +4 -4
- package/dist/utils/Translation/Translate.js +0 -4
- package/dist/utils/Translation/TranslationProvider.js +0 -1
- package/dist/utils/Translation/containsComponentOrElement.js +1 -5
- package/dist/utils/Translation/insertPlaceholders.js +0 -1
- package/dist/utils/Translation/useTranslation.js +7 -14
- package/dist/utils/concatIds/concatIds.js +0 -1
- package/dist/utils/constants.js +2 -2
- package/dist/utils/createContextUtilities/createContextUtilities.js +0 -4
- package/dist/utils/filterChildren/filterChildren.js +8 -17
- package/dist/utils/getSubDataTestId/getSubDataTestId.js +1 -2
- package/dist/utils/keyboardUser/keyboardUser.js +0 -1
- package/dist/utils/mediaQueryManager/mediaQueryManager.js +1 -12
- package/dist/utils/mergeRefs/mergeRefs.js +1 -2
- package/dist/utils/wrapAround/wrapAround.js +1 -2
- package/dist/utils/wrapEvent/wrapEvent.js +2 -4
- package/icons/package.json +2 -1
- package/next/package.json +5 -1
- package/package.json +9 -4
package/dist/next/index.js
CHANGED
|
@@ -9,8 +9,8 @@ var classNames = require('classnames');
|
|
|
9
9
|
var reactDnd = require('react-dnd');
|
|
10
10
|
var reactDndHtml5Backend = require('react-dnd-html5-backend');
|
|
11
11
|
var useResizeObserver = require('@react-hook/resize-observer');
|
|
12
|
-
var index = require('../__shared/cjs/index-
|
|
13
|
-
var icons_index = require('../__shared/cjs/index-
|
|
12
|
+
var index = require('../__shared/cjs/index-384184bd.js');
|
|
13
|
+
var icons_index = require('../__shared/cjs/index-4a5425cc.js');
|
|
14
14
|
var libphonenumberJs = require('libphonenumber-js');
|
|
15
15
|
var InputMask = require('react-input-mask');
|
|
16
16
|
var reactDropdownMenu = require('@radix-ui/react-dropdown-menu');
|
|
@@ -31,24 +31,22 @@ var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
|
31
31
|
var useResizeObserver__default = /*#__PURE__*/_interopDefaultLegacy(useResizeObserver);
|
|
32
32
|
var InputMask__default = /*#__PURE__*/_interopDefaultLegacy(InputMask);
|
|
33
33
|
|
|
34
|
-
var css_248z$a = ".
|
|
35
|
-
var styles$a = {"advancedTable":"
|
|
36
|
-
var stylesheet$a=".
|
|
34
|
+
var css_248z$a = "._AUKmI{overflow:auto;position:relative;max-width:100%;max-height:100%}._AUKmI,._oP-Ge{background-color:#fff}._oP-Ge{height:70px;z-index:100;display:flex;align-items:flex-end;justify-content:center;position:sticky;left:0}._zxwZ-{margin-bottom:4px}._AdIxC{position:sticky;top:0;z-index:100}._OmoT5{display:flex}._OmoT5:focus{outline:none}body.keyboard-user ._OmoT5:focus ._79bTf:after{content:\"\";display:block;position:absolute;top:0;bottom:0;left:0;right:0;border-bottom:2px solid #0a3f88;border-top:2px solid #0a3f88;z-index:50}body.keyboard-user ._OmoT5:focus ._79bTf:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._OmoT5:focus ._79bTf:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._OmoT5:focus ._79bTf._5bcOH:after{right:-3px;bottom:1px}._4aM3b{padding-right:3px}._1Y2rj{display:flex}._1Y2rj._cxzMx ._79bTf,._1Y2rj._cxzMx ._C9-Pl{cursor:pointer}._1Y2rj._NgEYT ._79bTf,._1Y2rj._NgEYT ._C9-Pl{background-color:rgba(11,110,208,.08);font-weight:500;box-shadow:inset 0 -1px 0 0 #0b6ed0}._1Y2rj._NgEYT ._79bTf._5bcOH,._1Y2rj._NgEYT ._C9-Pl._5bcOH{background-color:#fff;box-shadow:inset 0 -2px 0 0 #0b6ed0}._1Y2rj._NgEYT ._79bTf._5bcOH ._C9-Pl,._1Y2rj._NgEYT ._79bTf._5bcOH ._da00z,._1Y2rj._NgEYT ._79bTf._5bcOH ._IQLGk,._1Y2rj._NgEYT ._C9-Pl._5bcOH ._C9-Pl,._1Y2rj._NgEYT ._C9-Pl._5bcOH ._da00z,._1Y2rj._NgEYT ._C9-Pl._5bcOH ._IQLGk{background-color:rgba(11,110,208,.08)}._1Y2rj._cxzMx:hover:not(._NgEYT):not(._cKI4D) ._79bTf,._1Y2rj._cxzMx:hover:not(._NgEYT):not(._cKI4D) ._C9-Pl{background-color:#f9f9f9}._1Y2rj._cxzMx:active:not(._NgEYT):not(._cKI4D) ._79bTf,._1Y2rj._cxzMx:active:not(._NgEYT):not(._cKI4D) ._C9-Pl{background-color:#f3f3f3}._1Y2rj:focus{outline:none}body.keyboard-user ._1Y2rj:focus ._79bTf:after{content:\"\";display:block;position:absolute;top:-2px;bottom:-1px;left:0;right:0;border-bottom:2px solid #0a3f88;border-top:2px solid #0a3f88;z-index:50}body.keyboard-user ._1Y2rj:focus ._79bTf:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._1Y2rj:focus ._79bTf:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._1Y2rj:focus ._79bTf._5bcOH:after{right:-3px;bottom:0}._1Y2rj:last-of-type:focus{outline:none}body.keyboard-user ._1Y2rj:last-of-type:focus ._79bTf:after{content:\"\";display:block;position:absolute;top:-2px;bottom:0;left:0;right:0;border-bottom:2px solid #0a3f88;border-top:2px solid #0a3f88;z-index:50}body.keyboard-user ._1Y2rj:last-of-type:focus ._79bTf:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._1Y2rj:last-of-type:focus ._79bTf:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._1Y2rj:last-of-type:focus ._79bTf._5bcOH:after{right:-3px;bottom:1px}._1Y2rj:last-of-type ._IQLGk:focus{outline:none}body.keyboard-user ._1Y2rj:last-of-type ._IQLGk._BrawZ:after,body.keyboard-user ._1Y2rj:last-of-type ._IQLGk:focus:after{content:\"\";display:block;position:absolute;top:-2px;bottom:-1px;left:0;right:0;border-radius:2px;border:2px solid #0a3f88;z-index:10}._1Y2rj:first-of-type:focus{outline:none}body.keyboard-user ._1Y2rj:first-of-type:focus ._79bTf:after{content:\"\";display:block;position:absolute;top:0;bottom:-1px;left:0;right:0;border-bottom:2px solid #0a3f88;border-top:2px solid #0a3f88;z-index:50}body.keyboard-user ._1Y2rj:first-of-type:focus ._79bTf:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._1Y2rj:first-of-type:focus ._79bTf:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._1Y2rj:first-of-type:focus ._79bTf._5bcOH:after{right:-3px;bottom:0}._1Y2rj:first-of-type ._IQLGk:focus{outline:none}body.keyboard-user ._1Y2rj:first-of-type ._IQLGk._BrawZ:after,body.keyboard-user ._1Y2rj:first-of-type ._IQLGk:focus:after{content:\"\";display:block;position:absolute;top:0;bottom:-1px;left:0;right:0;border-radius:2px;border:2px solid #0a3f88;z-index:10}._vrjaS{display:flex;align-items:center;min-height:44px;width:200px;min-width:80px;border-bottom:1px solid #d9d9d9;flex-shrink:0;font-size:12px;line-height:16px;font-weight:700;color:#6a6d70;background-color:#fff;position:relative}._vrjaS._R4ZCZ{flex-grow:1}._vrjaS._4geF7{cursor:pointer}._vrjaS._4geF7:hover:not(._O3RXh){background-color:#f9f9f9;border-bottom-color:#6a6d70}._vrjaS._4geF7:active:not(._O3RXh){background-color:#f3f3f3}._vrjaS._LBxam:not(._O3RXh){color:#32363a;fill:#32363a;border-bottom-color:#8a8f94}._vrjaS._O3RXh{cursor:move;background-color:#efefef;border-bottom-color:#ccc;border-top-left-radius:4px;border-top-right-radius:4px}._vrjaS ._doELV{background-color:#d9d9d9;position:absolute;width:1px;top:0;pointer-events:none}._vrjaS ._doELV._bO67g{left:-1px}._vrjaS ._doELV._PofpO{right:0}._vrjaS ._rjk3l{background-color:#0a6ed1;position:absolute;width:3px;top:4px;bottom:4px;border-radius:4px;pointer-events:none}._vrjaS ._rjk3l._bO67g{left:-2px}._vrjaS ._rjk3l._PofpO{right:-1px}._vrjaS:first-of-type ._bO67g._doELV{left:0;width:2px;border-left:1px solid #fff}._vrjaS:first-of-type ._bO67g._rjk3l{left:0}._vrjaS:last-of-type ._PofpO._doELV{right:0;width:2px;border-right:1px solid #fff}._vrjaS:last-of-type ._PofpO._rjk3l{right:0}._vrjaS ._-WnPE{position:absolute;width:6px;right:-3px;top:0;cursor:ew-resize;z-index:50}._vrjaS ._-WnPE ._XZ8Hd{position:absolute;width:2px;right:2px;top:0;bottom:0}._vrjaS ._-WnPE ._XZ8Hd._ikKZB{background-color:#0a6ed1}._vrjaS ._-WnPE:hover ._XZ8Hd:not(._ikKZB){background-color:#d9d9d9}._vrjaS ._Ioe8l{display:flex;flex-grow:1;align-items:center;min-width:0;padding:14px 0 13px 12px}._vrjaS ._Ioe8l._FRI6a{flex-direction:row-reverse;justify-content:flex-start}._vrjaS ._Ioe8l._FRI6a ._3KIfa{margin:1px 7px 1px 1px}._vrjaS ._Ioe8l ._7Uryo{text-overflow:ellipsis;overflow:hidden;-webkit-hyphens:auto;hyphens:auto;pointer-events:none;overflow-wrap:break-word;display:-webkit-box;-webkit-box-orient:vertical}._vrjaS ._Ioe8l ._3KIfa{margin:1px 1px 1px 7px;flex-shrink:0}._vrjaS ._Ym5TG{margin-left:6px;margin-right:4px;flex-shrink:0}._vrjaS ._KnEw8{pointer-events:none;position:absolute;top:0;left:0;bottom:0;right:0}._vrjaS:focus{outline:none}body.keyboard-user ._vrjaS._BrawZ:after,body.keyboard-user ._vrjaS:focus:after{content:\"\";display:block;position:absolute;top:0;bottom:-1px;left:0;right:0;border-radius:2px;border:2px solid #0a3f88;z-index:10}._TCr9U{margin-right:6px}._5bcOH{display:flex;border-right:3px solid #e5e5e5;position:sticky;left:0;background-color:#fff;z-index:20}._5bcOH[focus-within]{z-index:30}._5bcOH:focus-within{z-index:30}._IQLGk{display:flex;align-items:center;min-height:44px;width:200px;min-width:80px;border-bottom:1px solid #eee;flex-shrink:0;font-size:14px;line-height:20px;overflow-wrap:break-word;color:#32363a;position:relative}._IQLGk ._PdHNd{width:100%;padding:12px 12px 11px;overflow:hidden}._IQLGk._O3RXh{background-color:#efefef;border-bottom-color:#dfdfe1}._IQLGk._R4ZCZ{flex-grow:1}._IQLGk:focus{outline:none}body.keyboard-user ._IQLGk._BrawZ:after,body.keyboard-user ._IQLGk:focus:after{content:\"\";display:block;position:absolute;top:-2px;bottom:-2px;left:0;right:0;border-radius:2px;border:2px solid #0a3f88;z-index:10}._C9-Pl{display:flex!important;min-height:44px!important;align-items:center;justify-content:right;border-bottom:1px solid #eee;flex-shrink:0}._C9-Pl._VfQbe{border-bottom-color:#d9d9d9;background-color:#fff}._da00z{display:flex;align-items:center;justify-content:center;min-height:44px;width:40px;border-bottom:1px solid #eee;padding:12px 12px 11px;flex-shrink:0;cursor:pointer}._da00z._VfQbe{border-bottom-color:#d9d9d9;padding:14px 12px 13px}._da00z:focus input~span,._da00z:hover input~span{border-color:#0b6ed0}._da00z ._LjMOK{position:relative;display:inline-flex}._da00z ._LjMOK ._pM-ZT{margin:0!important}._da00z ._LjMOK ._t9VOX{position:absolute;top:3px;left:3px;height:10px;width:10px;border-radius:2px;background-color:#0b6ed0}._k2Pvp{justify-content:flex-start}._YOll7{justify-content:center;text-align:center}._FRI6a{justify-content:flex-end;text-align:right}._fABxg{display:none}._s1LRQ{opacity:0;height:0;width:0;overflow:hidden}._r08bH,._s1LRQ{position:absolute}._r08bH{cursor:move;background-color:rgba(11,110,208,.08);border-radius:4px;z-index:1000;pointer-events:none}._lADRZ{width:246px}";
|
|
35
|
+
var styles$a = {"advancedTable":"_AUKmI","advancedTablePaginationContainer":"_oP-Ge","advancedTablePagination":"_zxwZ-","advancedTableColumnHeadersRowGroup":"_AdIxC","advancedTableColumnHeaders":"_OmoT5","advancedTableRowChild":"_79bTf","pinnedContainer":"_5bcOH","advancedTableRowGroup":"_4aM3b","advancedTableRow":"_1Y2rj","hasRowAction":"_cxzMx","advancedTableExpandRowSpacer":"_C9-Pl","isSelected":"_NgEYT","advancedTableCheckbox":"_da00z","advancedTableCell":"_IQLGk","isCheckboxHovered":"_cKI4D","showFocusRing":"_BrawZ","advancedTableColumnHeader":"_vrjaS","fillRemainingSpace":"_R4ZCZ","isSortable":"_4geF7","isDragging":"_O3RXh","isSorted":"_LBxam","dropTargetLine":"_doELV","dropTargetLeft":"_bO67g","dropTargetRight":"_PofpO","dropTargetMarker":"_rjk3l","resizeHandle":"_-WnPE","resizeLine":"_XZ8Hd","isResizing":"_ikKZB","advancedTableColumnHeaderLabel":"_Ioe8l","rightAligned":"_FRI6a","sortIcon":"_3KIfa","advancedTableColumnHeaderLabelText":"_7Uryo","advancedTableColumnHeaderMenu":"_Ym5TG","advancedTableColumnHeaderMenuHiddenAnchor":"_KnEw8","advancedTableColumnHeaderMenuItemIcon":"_TCr9U","advancedTableCellContainer":"_PdHNd","header":"_VfQbe","checkboxContainer":"_LjMOK","checkbox":"_pM-ZT","mixed":"_t9VOX","leftAligned":"_k2Pvp","centerAligned":"_YOll7","hiddenDescription":"_fABxg","hiddenLiveRegion":"_s1LRQ","dragPreview":"_r08bH","rowActionMenuPane":"_lADRZ"};
|
|
36
|
+
var stylesheet$a="._AUKmI{overflow:auto;position:relative;max-width:100%;max-height:100%}._AUKmI,._oP-Ge{background-color:#fff}._oP-Ge{height:70px;z-index:100;display:flex;align-items:flex-end;justify-content:center;position:sticky;left:0}._zxwZ-{margin-bottom:4px}._AdIxC{position:sticky;top:0;z-index:100}._OmoT5{display:flex}._OmoT5:focus{outline:none}body.keyboard-user ._OmoT5:focus ._79bTf:after{content:\"\";display:block;position:absolute;top:0;bottom:0;left:0;right:0;border-bottom:2px solid #0a3f88;border-top:2px solid #0a3f88;z-index:50}body.keyboard-user ._OmoT5:focus ._79bTf:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._OmoT5:focus ._79bTf:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._OmoT5:focus ._79bTf._5bcOH:after{right:-3px;bottom:1px}._4aM3b{padding-right:3px}._1Y2rj{display:flex}._1Y2rj._cxzMx ._79bTf,._1Y2rj._cxzMx ._C9-Pl{cursor:pointer}._1Y2rj._NgEYT ._79bTf,._1Y2rj._NgEYT ._C9-Pl{background-color:rgba(11,110,208,.08);font-weight:500;box-shadow:inset 0 -1px 0 0 #0b6ed0}._1Y2rj._NgEYT ._79bTf._5bcOH,._1Y2rj._NgEYT ._C9-Pl._5bcOH{background-color:#fff;box-shadow:inset 0 -2px 0 0 #0b6ed0}._1Y2rj._NgEYT ._79bTf._5bcOH ._C9-Pl,._1Y2rj._NgEYT ._79bTf._5bcOH ._da00z,._1Y2rj._NgEYT ._79bTf._5bcOH ._IQLGk,._1Y2rj._NgEYT ._C9-Pl._5bcOH ._C9-Pl,._1Y2rj._NgEYT ._C9-Pl._5bcOH ._da00z,._1Y2rj._NgEYT ._C9-Pl._5bcOH ._IQLGk{background-color:rgba(11,110,208,.08)}._1Y2rj._cxzMx:hover:not(._NgEYT):not(._cKI4D) ._79bTf,._1Y2rj._cxzMx:hover:not(._NgEYT):not(._cKI4D) ._C9-Pl{background-color:#f9f9f9}._1Y2rj._cxzMx:active:not(._NgEYT):not(._cKI4D) ._79bTf,._1Y2rj._cxzMx:active:not(._NgEYT):not(._cKI4D) ._C9-Pl{background-color:#f3f3f3}._1Y2rj:focus{outline:none}body.keyboard-user ._1Y2rj:focus ._79bTf:after{content:\"\";display:block;position:absolute;top:-2px;bottom:-1px;left:0;right:0;border-bottom:2px solid #0a3f88;border-top:2px solid #0a3f88;z-index:50}body.keyboard-user ._1Y2rj:focus ._79bTf:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._1Y2rj:focus ._79bTf:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._1Y2rj:focus ._79bTf._5bcOH:after{right:-3px;bottom:0}._1Y2rj:last-of-type:focus{outline:none}body.keyboard-user ._1Y2rj:last-of-type:focus ._79bTf:after{content:\"\";display:block;position:absolute;top:-2px;bottom:0;left:0;right:0;border-bottom:2px solid #0a3f88;border-top:2px solid #0a3f88;z-index:50}body.keyboard-user ._1Y2rj:last-of-type:focus ._79bTf:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._1Y2rj:last-of-type:focus ._79bTf:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._1Y2rj:last-of-type:focus ._79bTf._5bcOH:after{right:-3px;bottom:1px}._1Y2rj:last-of-type ._IQLGk:focus{outline:none}body.keyboard-user ._1Y2rj:last-of-type ._IQLGk._BrawZ:after,body.keyboard-user ._1Y2rj:last-of-type ._IQLGk:focus:after{content:\"\";display:block;position:absolute;top:-2px;bottom:-1px;left:0;right:0;border-radius:2px;border:2px solid #0a3f88;z-index:10}._1Y2rj:first-of-type:focus{outline:none}body.keyboard-user ._1Y2rj:first-of-type:focus ._79bTf:after{content:\"\";display:block;position:absolute;top:0;bottom:-1px;left:0;right:0;border-bottom:2px solid #0a3f88;border-top:2px solid #0a3f88;z-index:50}body.keyboard-user ._1Y2rj:first-of-type:focus ._79bTf:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._1Y2rj:first-of-type:focus ._79bTf:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._1Y2rj:first-of-type:focus ._79bTf._5bcOH:after{right:-3px;bottom:0}._1Y2rj:first-of-type ._IQLGk:focus{outline:none}body.keyboard-user ._1Y2rj:first-of-type ._IQLGk._BrawZ:after,body.keyboard-user ._1Y2rj:first-of-type ._IQLGk:focus:after{content:\"\";display:block;position:absolute;top:0;bottom:-1px;left:0;right:0;border-radius:2px;border:2px solid #0a3f88;z-index:10}._vrjaS{display:flex;align-items:center;min-height:44px;width:200px;min-width:80px;border-bottom:1px solid #d9d9d9;flex-shrink:0;font-size:12px;line-height:16px;font-weight:700;color:#6a6d70;background-color:#fff;position:relative}._vrjaS._R4ZCZ{flex-grow:1}._vrjaS._4geF7{cursor:pointer}._vrjaS._4geF7:hover:not(._O3RXh){background-color:#f9f9f9;border-bottom-color:#6a6d70}._vrjaS._4geF7:active:not(._O3RXh){background-color:#f3f3f3}._vrjaS._LBxam:not(._O3RXh){color:#32363a;fill:#32363a;border-bottom-color:#8a8f94}._vrjaS._O3RXh{cursor:move;background-color:#efefef;border-bottom-color:#ccc;border-top-left-radius:4px;border-top-right-radius:4px}._vrjaS ._doELV{background-color:#d9d9d9;position:absolute;width:1px;top:0;pointer-events:none}._vrjaS ._doELV._bO67g{left:-1px}._vrjaS ._doELV._PofpO{right:0}._vrjaS ._rjk3l{background-color:#0a6ed1;position:absolute;width:3px;top:4px;bottom:4px;border-radius:4px;pointer-events:none}._vrjaS ._rjk3l._bO67g{left:-2px}._vrjaS ._rjk3l._PofpO{right:-1px}._vrjaS:first-of-type ._bO67g._doELV{left:0;width:2px;border-left:1px solid #fff}._vrjaS:first-of-type ._bO67g._rjk3l{left:0}._vrjaS:last-of-type ._PofpO._doELV{right:0;width:2px;border-right:1px solid #fff}._vrjaS:last-of-type ._PofpO._rjk3l{right:0}._vrjaS ._-WnPE{position:absolute;width:6px;right:-3px;top:0;cursor:ew-resize;z-index:50}._vrjaS ._-WnPE ._XZ8Hd{position:absolute;width:2px;right:2px;top:0;bottom:0}._vrjaS ._-WnPE ._XZ8Hd._ikKZB{background-color:#0a6ed1}._vrjaS ._-WnPE:hover ._XZ8Hd:not(._ikKZB){background-color:#d9d9d9}._vrjaS ._Ioe8l{display:flex;flex-grow:1;align-items:center;min-width:0;padding:14px 0 13px 12px}._vrjaS ._Ioe8l._FRI6a{flex-direction:row-reverse;justify-content:flex-start}._vrjaS ._Ioe8l._FRI6a ._3KIfa{margin:1px 7px 1px 1px}._vrjaS ._Ioe8l ._7Uryo{text-overflow:ellipsis;overflow:hidden;-webkit-hyphens:auto;hyphens:auto;pointer-events:none;overflow-wrap:break-word;display:-webkit-box;-webkit-box-orient:vertical}._vrjaS ._Ioe8l ._3KIfa{margin:1px 1px 1px 7px;flex-shrink:0}._vrjaS ._Ym5TG{margin-left:6px;margin-right:4px;flex-shrink:0}._vrjaS ._KnEw8{pointer-events:none;position:absolute;top:0;left:0;bottom:0;right:0}._vrjaS:focus{outline:none}body.keyboard-user ._vrjaS._BrawZ:after,body.keyboard-user ._vrjaS:focus:after{content:\"\";display:block;position:absolute;top:0;bottom:-1px;left:0;right:0;border-radius:2px;border:2px solid #0a3f88;z-index:10}._TCr9U{margin-right:6px}._5bcOH{display:flex;border-right:3px solid #e5e5e5;position:sticky;left:0;background-color:#fff;z-index:20}._5bcOH[focus-within]{z-index:30}._5bcOH:focus-within{z-index:30}._IQLGk{display:flex;align-items:center;min-height:44px;width:200px;min-width:80px;border-bottom:1px solid #eee;flex-shrink:0;font-size:14px;line-height:20px;overflow-wrap:break-word;color:#32363a;position:relative}._IQLGk ._PdHNd{width:100%;padding:12px 12px 11px;overflow:hidden}._IQLGk._O3RXh{background-color:#efefef;border-bottom-color:#dfdfe1}._IQLGk._R4ZCZ{flex-grow:1}._IQLGk:focus{outline:none}body.keyboard-user ._IQLGk._BrawZ:after,body.keyboard-user ._IQLGk:focus:after{content:\"\";display:block;position:absolute;top:-2px;bottom:-2px;left:0;right:0;border-radius:2px;border:2px solid #0a3f88;z-index:10}._C9-Pl{display:flex!important;min-height:44px!important;align-items:center;justify-content:right;border-bottom:1px solid #eee;flex-shrink:0}._C9-Pl._VfQbe{border-bottom-color:#d9d9d9;background-color:#fff}._da00z{display:flex;align-items:center;justify-content:center;min-height:44px;width:40px;border-bottom:1px solid #eee;padding:12px 12px 11px;flex-shrink:0;cursor:pointer}._da00z._VfQbe{border-bottom-color:#d9d9d9;padding:14px 12px 13px}._da00z:focus input~span,._da00z:hover input~span{border-color:#0b6ed0}._da00z ._LjMOK{position:relative;display:inline-flex}._da00z ._LjMOK ._pM-ZT{margin:0!important}._da00z ._LjMOK ._t9VOX{position:absolute;top:3px;left:3px;height:10px;width:10px;border-radius:2px;background-color:#0b6ed0}._k2Pvp{justify-content:flex-start}._YOll7{justify-content:center;text-align:center}._FRI6a{justify-content:flex-end;text-align:right}._fABxg{display:none}._s1LRQ{opacity:0;height:0;width:0;overflow:hidden}._r08bH,._s1LRQ{position:absolute}._r08bH{cursor:move;background-color:rgba(11,110,208,.08);border-radius:4px;z-index:1000;pointer-events:none}._lADRZ{width:246px}";
|
|
37
37
|
icons_index.styleInject(css_248z$a);
|
|
38
38
|
|
|
39
39
|
// TODO: Move the imported types into this file to avoid a ciruclar dependency warning.
|
|
40
40
|
// Also Alignment, etc can be defined directly and have AdvancedTableColumnConfig use them instead of the reverse like now.
|
|
41
41
|
// Context: Zach was trying to make type-doc work better, but it's probably not worth the weird organization.
|
|
42
|
-
let SortDirections;
|
|
43
42
|
|
|
43
|
+
let SortDirections;
|
|
44
44
|
(function (SortDirections) {
|
|
45
45
|
SortDirections["Ascending"] = "ascending";
|
|
46
46
|
SortDirections["Descending"] = "descending";
|
|
47
47
|
SortDirections["None"] = "none";
|
|
48
48
|
})(SortDirections || (SortDirections = {}));
|
|
49
|
-
|
|
50
49
|
let Alignments;
|
|
51
|
-
|
|
52
50
|
(function (Alignments) {
|
|
53
51
|
Alignments["Left"] = "left";
|
|
54
52
|
Alignments["Right"] = "right";
|
|
@@ -76,7 +74,6 @@ const AdvancedTableColumnHeaderMenu = _ref => {
|
|
|
76
74
|
} = index.useTranslation();
|
|
77
75
|
const id = index.useId();
|
|
78
76
|
const selectedValue = JSON.stringify(selectedSortOption);
|
|
79
|
-
|
|
80
77
|
const getActionMenuItem = _ref2 => {
|
|
81
78
|
let {
|
|
82
79
|
onSelect,
|
|
@@ -88,13 +85,10 @@ const AdvancedTableColumnHeaderMenu = _ref => {
|
|
|
88
85
|
role: "menuitem" // Enables having an action menu item inside of a SelectMenu
|
|
89
86
|
,
|
|
90
87
|
onSelect: e => {
|
|
91
|
-
var _columnHeaderRef$curr;
|
|
92
|
-
|
|
93
88
|
e.preventDefault(); // prevents SelectMenu value from changing
|
|
94
|
-
|
|
95
89
|
setIsOpen(false);
|
|
96
|
-
|
|
97
|
-
onSelect
|
|
90
|
+
columnHeaderRef.current?.focus();
|
|
91
|
+
onSelect?.();
|
|
98
92
|
},
|
|
99
93
|
"date-testid": menuItemDataTestId
|
|
100
94
|
}, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
@@ -103,9 +97,7 @@ const AdvancedTableColumnHeaderMenu = _ref => {
|
|
|
103
97
|
"aria-hidden": "true"
|
|
104
98
|
}), label);
|
|
105
99
|
};
|
|
106
|
-
|
|
107
100
|
let pinItem;
|
|
108
|
-
|
|
109
101
|
if (onIsPinnedChange) {
|
|
110
102
|
const pinIcon = isPinned ? icons_index.UnpinIcon : icons_index.PinIcon;
|
|
111
103
|
const pinLabel = translate(isPinned ? 'advancedTable.unpinColumn' : 'advancedTable.pinColumn');
|
|
@@ -116,9 +108,9 @@ const AdvancedTableColumnHeaderMenu = _ref => {
|
|
|
116
108
|
'data-testid': index.getSubDataTestId(dataTestId, 'ColumnHeaderMenu-PinColumn')
|
|
117
109
|
});
|
|
118
110
|
}
|
|
119
|
-
|
|
120
111
|
return /*#__PURE__*/React__default["default"].createElement(index.SelectMenu, _extends__default["default"]({
|
|
121
|
-
key:
|
|
112
|
+
key:
|
|
113
|
+
// A hack since SelectMenu can't be controlled
|
|
122
114
|
selectedSortOption.columnId === columnId ? selectedValue : columnId,
|
|
123
115
|
id: id,
|
|
124
116
|
defaultValue: selectedValue,
|
|
@@ -127,7 +119,7 @@ const AdvancedTableColumnHeaderMenu = _ref => {
|
|
|
127
119
|
},
|
|
128
120
|
isOpen: isOpen,
|
|
129
121
|
onIsOpenChange: setIsOpen
|
|
130
|
-
}, rest), sortOptions
|
|
122
|
+
}, rest), sortOptions?.map((_ref3, index$1) => {
|
|
131
123
|
let {
|
|
132
124
|
ascendingLabel,
|
|
133
125
|
ascendingIcon,
|
|
@@ -150,7 +142,7 @@ const AdvancedTableColumnHeaderMenu = _ref => {
|
|
|
150
142
|
key: ascendingValue,
|
|
151
143
|
value: ascendingValue,
|
|
152
144
|
label: ascendingLabel,
|
|
153
|
-
"data-testid": index.getSubDataTestId(dataTestId,
|
|
145
|
+
"data-testid": index.getSubDataTestId(dataTestId, `ColumnHeaderMenu-Sort-${index$1}-${SortDirections.Ascending}`)
|
|
154
146
|
}, /*#__PURE__*/React__default["default"].createElement(AscendingIconComponent, {
|
|
155
147
|
size: "small",
|
|
156
148
|
className: styles$a.advancedTableColumnHeaderMenuItemIcon,
|
|
@@ -159,13 +151,13 @@ const AdvancedTableColumnHeaderMenu = _ref => {
|
|
|
159
151
|
key: descendingValue,
|
|
160
152
|
value: descendingValue,
|
|
161
153
|
label: descendingLabel,
|
|
162
|
-
"data-testid": index.getSubDataTestId(dataTestId,
|
|
154
|
+
"data-testid": index.getSubDataTestId(dataTestId, `ColumnHeaderMenu-Sort-${index$1}-${SortDirections.Descending}`)
|
|
163
155
|
}, /*#__PURE__*/React__default["default"].createElement(DescendingIconComponent, {
|
|
164
156
|
size: "small",
|
|
165
157
|
className: styles$a.advancedTableColumnHeaderMenuItemIcon,
|
|
166
158
|
"aria-hidden": "true"
|
|
167
159
|
}), descendingLabel)];
|
|
168
|
-
}),
|
|
160
|
+
}), sortOptions?.length && (onIsPinnedChange || onMoveLeft || onMoveRight) && /*#__PURE__*/React__default["default"].createElement(index.Divider, null), pinItem, onMoveLeft && getActionMenuItem({
|
|
169
161
|
onSelect: onMoveLeft,
|
|
170
162
|
Icon: icons_index.ArrowLeftIcon,
|
|
171
163
|
label: translate('advancedTable.moveColumnLeft'),
|
|
@@ -212,8 +204,9 @@ const useDragAndDrop = _ref => {
|
|
|
212
204
|
options: {
|
|
213
205
|
dropEffect: 'move'
|
|
214
206
|
}
|
|
215
|
-
}), [id, tableId, isPinned, columnIndex, isEnabled, setDragSource, setDropTarget, setDropTargetSide]);
|
|
207
|
+
}), [id, tableId, isPinned, columnIndex, isEnabled, setDragSource, setDropTarget, setDropTargetSide]);
|
|
216
208
|
|
|
209
|
+
// Remove HTML5 DnD preview
|
|
217
210
|
React.useEffect(() => {
|
|
218
211
|
dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), {
|
|
219
212
|
captureDraggingState: false
|
|
@@ -226,29 +219,25 @@ const useDragAndDrop = _ref => {
|
|
|
226
219
|
}, dropRef] = reactDnd.useDrop(() => ({
|
|
227
220
|
accept: tableId,
|
|
228
221
|
hover: (item, monitor) => {
|
|
229
|
-
var _monitor$getClientOff, _columnHeaderRef$curr;
|
|
230
|
-
|
|
231
222
|
const {
|
|
232
223
|
id: dragSourceId,
|
|
233
224
|
columnIndex: dragSourceColumnIndex,
|
|
234
225
|
isPinned: dragSourceIsPinned
|
|
235
226
|
} = item;
|
|
236
227
|
setDropTarget(id);
|
|
237
|
-
|
|
238
228
|
if (id === dragSourceId) {
|
|
239
229
|
setDropTargetSide(undefined);
|
|
240
230
|
return;
|
|
241
|
-
}
|
|
242
|
-
|
|
231
|
+
}
|
|
243
232
|
|
|
244
|
-
|
|
233
|
+
// Calculate which column line is closest
|
|
234
|
+
const dropX = monitor.getClientOffset()?.x;
|
|
245
235
|
const {
|
|
246
236
|
x,
|
|
247
237
|
width
|
|
248
|
-
} =
|
|
238
|
+
} = columnHeaderRef.current?.getBoundingClientRect();
|
|
249
239
|
const diffLeft = Math.abs(dropX - x) || 0;
|
|
250
240
|
const diffRight = Math.abs(dropX - (x + width)) || 0;
|
|
251
|
-
|
|
252
241
|
if (diffLeft < diffRight) {
|
|
253
242
|
// hover over left side
|
|
254
243
|
if (columnIndex - dragSourceColumnIndex === 1 && isPinned === dragSourceIsPinned) {
|
|
@@ -271,11 +260,9 @@ const useDragAndDrop = _ref => {
|
|
|
271
260
|
columnIndex: dragSourceColumnIndex,
|
|
272
261
|
isPinned: dragSourceIsPinned
|
|
273
262
|
} = item;
|
|
274
|
-
|
|
275
263
|
if (id === dragSourceId || dropTargetSideRef.current === undefined) {
|
|
276
264
|
return;
|
|
277
265
|
}
|
|
278
|
-
|
|
279
266
|
if (isPinned && !dragSourceIsPinned) {
|
|
280
267
|
// Dragging from an unpinned column onto a pinned column
|
|
281
268
|
setPinnedColumns(pinnedColumns => {
|
|
@@ -326,8 +313,9 @@ const useDragAndDrop = _ref => {
|
|
|
326
313
|
collect: monitor => ({
|
|
327
314
|
isOver: monitor.isOver()
|
|
328
315
|
})
|
|
329
|
-
}), [id, tableId, isPinned, columnIndex, isEnabled, setDropTarget, dropTargetSideRef, setDropTargetSide]);
|
|
316
|
+
}), [id, tableId, isPinned, columnIndex, isEnabled, setDropTarget, dropTargetSideRef, setDropTargetSide]);
|
|
330
317
|
|
|
318
|
+
// Clear dropTarget when header is no longer being hovered
|
|
331
319
|
React.useEffect(() => {
|
|
332
320
|
if (!isOver) {
|
|
333
321
|
setDropTarget(currentDropTarget => {
|
|
@@ -335,7 +323,6 @@ const useDragAndDrop = _ref => {
|
|
|
335
323
|
setDropTargetSide(undefined);
|
|
336
324
|
return '';
|
|
337
325
|
}
|
|
338
|
-
|
|
339
326
|
return currentDropTarget;
|
|
340
327
|
});
|
|
341
328
|
}
|
|
@@ -349,7 +336,7 @@ const useDragAndDrop = _ref => {
|
|
|
349
336
|
function useComputedWidth() {
|
|
350
337
|
let widthBuffer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
351
338
|
let defaultWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
|
|
352
|
-
return React.useMemo(() => typeof defaultWidth === 'number' ?
|
|
339
|
+
return React.useMemo(() => typeof defaultWidth === 'number' ? `${defaultWidth + widthBuffer}px` : `calc(${widthBuffer}px + ${defaultWidth})`, [widthBuffer, defaultWidth]);
|
|
353
340
|
}
|
|
354
341
|
|
|
355
342
|
const AdvancedTableColumnHeader = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
@@ -391,8 +378,8 @@ const AdvancedTableColumnHeader = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
391
378
|
const [ellipsisShown, setEllipsisShown] = React.useState();
|
|
392
379
|
const columnHeaderRef = React.useRef(null);
|
|
393
380
|
const labelContainerRef = React.useRef(null);
|
|
394
|
-
const isSortable = Boolean(sortOptions
|
|
395
|
-
const isSorted = isSortable && selectedSortOption.columnId === id && selectedSortOption.index >= 0 && selectedSortOption.index <
|
|
381
|
+
const isSortable = Boolean(sortOptions?.length);
|
|
382
|
+
const isSorted = isSortable && selectedSortOption.columnId === id && selectedSortOption.index >= 0 && selectedSortOption.index < sortOptions?.length && (selectedSortOption.direction === 'ascending' || selectedSortOption.direction === 'descending');
|
|
396
383
|
const selectedSortIndex = isSorted ? selectedSortOption.index : -1;
|
|
397
384
|
const arrowUpSvgContent = /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
398
385
|
fillRule: "evenodd",
|
|
@@ -444,41 +431,31 @@ const AdvancedTableColumnHeader = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
444
431
|
dropTargetSide,
|
|
445
432
|
setDropTargetSide
|
|
446
433
|
});
|
|
434
|
+
|
|
447
435
|
/**
|
|
448
436
|
* Note: Screen reader descriptions (aria-describedby) of column header keyboard shorcuts were not added due to a suboptimal
|
|
449
437
|
* VoiceOver experience in multiple browsers: description read twice, description read before the header contents, etc. Keep
|
|
450
438
|
* in mind this is not a WCAG 2.0 AA violation.
|
|
451
439
|
*/
|
|
452
|
-
|
|
453
440
|
const handleKeyDown = e => {
|
|
454
441
|
if (e.target !== e.currentTarget) return;
|
|
455
|
-
|
|
456
442
|
if (hasMenu && e.key === 'Enter') {
|
|
457
443
|
setIsHiddenMenuOpen(true);
|
|
458
444
|
setHiddenMenuHighlightedIndex(0);
|
|
459
445
|
} else if (onWidthChange && e.key === 'ArrowRight' && e.shiftKey) {
|
|
460
|
-
var _columnHeaderRef$curr;
|
|
461
|
-
|
|
462
446
|
e.preventDefault(); // prevent scroll
|
|
463
|
-
|
|
464
|
-
const newWidth = ((_columnHeaderRef$curr = columnHeaderRef.current) === null || _columnHeaderRef$curr === void 0 ? void 0 : _columnHeaderRef$curr.getBoundingClientRect().width) + 10;
|
|
447
|
+
const newWidth = columnHeaderRef.current?.getBoundingClientRect().width + 10;
|
|
465
448
|
onWidthChange(newWidth);
|
|
466
449
|
} else if (onWidthChange && e.key === 'ArrowLeft' && e.shiftKey) {
|
|
467
|
-
var _columnHeaderRef$curr2;
|
|
468
|
-
|
|
469
450
|
e.preventDefault(); // prevent scroll
|
|
470
|
-
|
|
471
|
-
const newWidth = Math.max(80, ((_columnHeaderRef$curr2 = columnHeaderRef.current) === null || _columnHeaderRef$curr2 === void 0 ? void 0 : _columnHeaderRef$curr2.getBoundingClientRect().width) - 10);
|
|
451
|
+
const newWidth = Math.max(80, columnHeaderRef.current?.getBoundingClientRect().width - 10);
|
|
472
452
|
onWidthChange(newWidth);
|
|
473
453
|
} else {
|
|
474
|
-
onKeyDown
|
|
454
|
+
onKeyDown?.(e);
|
|
475
455
|
}
|
|
476
456
|
};
|
|
477
|
-
|
|
478
457
|
const handleClick = e => {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
if (e.target === e.currentTarget || (_labelContainerRef$cu = labelContainerRef.current) !== null && _labelContainerRef$cu !== void 0 && _labelContainerRef$cu.contains(e.target)) {
|
|
458
|
+
if (e.target === e.currentTarget || labelContainerRef.current?.contains(e.target)) {
|
|
482
459
|
const newIndex = isSorted ? selectedSortIndex : 0;
|
|
483
460
|
const newDirection = isSorted && selectedSortOption.direction === 'ascending' ? 'descending' : 'ascending';
|
|
484
461
|
setSelectedSortOption({
|
|
@@ -488,17 +465,14 @@ const AdvancedTableColumnHeader = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
488
465
|
});
|
|
489
466
|
}
|
|
490
467
|
};
|
|
491
|
-
|
|
492
468
|
const handleIsPinnedChange = newIsPinned => {
|
|
493
469
|
if (newIsPinned) {
|
|
494
470
|
setPinnedColumns(currentPinnedColumns => [...currentPinnedColumns, id]);
|
|
495
471
|
} else {
|
|
496
472
|
setPinnedColumns(currentPinnedColumns => currentPinnedColumns.filter(pinnedColumnId => id !== pinnedColumnId));
|
|
497
473
|
}
|
|
498
|
-
|
|
499
474
|
setFocusedColumnId(id);
|
|
500
475
|
};
|
|
501
|
-
|
|
502
476
|
const handleMoveLeft = () => {
|
|
503
477
|
if (isPinned) {
|
|
504
478
|
setPinnedColumns(currentPinnedColumns => {
|
|
@@ -516,10 +490,8 @@ const AdvancedTableColumnHeader = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
516
490
|
return newColumnOrder;
|
|
517
491
|
});
|
|
518
492
|
}
|
|
519
|
-
|
|
520
493
|
setFocusedColumnId(id);
|
|
521
494
|
};
|
|
522
|
-
|
|
523
495
|
const handleMoveRight = () => {
|
|
524
496
|
if (isPinned) {
|
|
525
497
|
setPinnedColumns(currentPinnedColumns => {
|
|
@@ -537,36 +509,27 @@ const AdvancedTableColumnHeader = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
537
509
|
return newColumnOrder;
|
|
538
510
|
});
|
|
539
511
|
}
|
|
540
|
-
|
|
541
512
|
setFocusedColumnId(id);
|
|
542
513
|
};
|
|
543
|
-
|
|
544
514
|
const handleMouseDown = e => {
|
|
545
515
|
if (e.button === 0) {
|
|
546
516
|
// left mouse button
|
|
547
517
|
e.preventDefault(); // prevent focus from changing
|
|
548
|
-
|
|
549
518
|
e.stopPropagation(); // prevent columns from being clicked and changing sort direction
|
|
550
|
-
|
|
551
519
|
setIsResizing(true);
|
|
552
520
|
}
|
|
553
521
|
};
|
|
554
|
-
|
|
555
522
|
const handleMouseMove = e => {
|
|
556
|
-
var _columnHeaderRef$curr3;
|
|
557
|
-
|
|
558
523
|
const mouseX = e.clientX;
|
|
559
|
-
const headerX =
|
|
524
|
+
const headerX = columnHeaderRef.current?.getBoundingClientRect().x;
|
|
560
525
|
const newWidth = Math.max(80, mouseX - headerX);
|
|
561
|
-
onWidthChange
|
|
526
|
+
onWidthChange?.(newWidth);
|
|
562
527
|
};
|
|
563
|
-
|
|
564
528
|
const handleMouseUp = e => {
|
|
565
529
|
if (e.button === 0) {
|
|
566
530
|
setIsResizing(false);
|
|
567
531
|
}
|
|
568
532
|
};
|
|
569
|
-
|
|
570
533
|
const options = {
|
|
571
534
|
isDisabled: !isResizing
|
|
572
535
|
};
|
|
@@ -580,11 +543,7 @@ const AdvancedTableColumnHeader = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
580
543
|
onIsPinnedChange: disableUserPinnableColumns ? undefined : handleIsPinnedChange,
|
|
581
544
|
onMoveLeft: disableUserReorderableColumns || isPinned && columnIndex === 0 || !isPinned && columnIndex === minUnpinnedColumnIndex ? undefined : handleMoveLeft,
|
|
582
545
|
onMoveRight: disableUserReorderableColumns || isPinned && columnIndex === minUnpinnedColumnIndex - 1 || !isPinned && columnIndex === maxUnpinnedColumnIndex ? undefined : handleMoveRight,
|
|
583
|
-
onFocus: () =>
|
|
584
|
-
var _columnHeaderRef$curr4;
|
|
585
|
-
|
|
586
|
-
return (_columnHeaderRef$curr4 = columnHeaderRef.current) === null || _columnHeaderRef$curr4 === void 0 ? void 0 : _columnHeaderRef$curr4.focus();
|
|
587
|
-
},
|
|
546
|
+
onFocus: () => columnHeaderRef.current?.focus(),
|
|
588
547
|
columnId: id,
|
|
589
548
|
columnHeaderRef,
|
|
590
549
|
'data-testid': dataTestId
|
|
@@ -652,9 +611,7 @@ const AdvancedTableColumnHeader = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
652
611
|
tabIndex: -1,
|
|
653
612
|
"aria-hidden": "true",
|
|
654
613
|
onFocus: () => {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
(_columnHeaderRef$curr5 = columnHeaderRef.current) === null || _columnHeaderRef$curr5 === void 0 ? void 0 : _columnHeaderRef$curr5.focus();
|
|
614
|
+
columnHeaderRef.current?.focus();
|
|
658
615
|
},
|
|
659
616
|
className: styles$a.advancedTableColumnHeaderMenuHiddenAnchor
|
|
660
617
|
})
|
|
@@ -716,21 +673,16 @@ const AdvancedTableCell = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
716
673
|
e.stopPropagation(); // Prevent click event from causing row selection with interactive cell content
|
|
717
674
|
}
|
|
718
675
|
} : undefined;
|
|
719
|
-
|
|
720
676
|
const handleKeyDown = e => {
|
|
721
677
|
if (e.target === e.currentTarget && e.key === 'Enter' && isInteractive) {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
(_focusableElementRef$ = focusableElementRef.current) === null || _focusableElementRef$ === void 0 ? void 0 : _focusableElementRef$.focus();
|
|
678
|
+
focusableElementRef.current?.focus();
|
|
725
679
|
e.preventDefault(); // Prevent click event from occurring on the focusable element
|
|
726
680
|
}
|
|
727
681
|
|
|
728
|
-
onKeyDown
|
|
682
|
+
onKeyDown?.(e);
|
|
729
683
|
};
|
|
730
|
-
|
|
731
684
|
const handleFocus = e => {
|
|
732
|
-
onFocus
|
|
733
|
-
|
|
685
|
+
onFocus?.(e);
|
|
734
686
|
if (isInteractive) {
|
|
735
687
|
if (e.target !== e.currentTarget) {
|
|
736
688
|
setIsEditing(true);
|
|
@@ -739,19 +691,14 @@ const AdvancedTableCell = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
739
691
|
}
|
|
740
692
|
}
|
|
741
693
|
};
|
|
742
|
-
|
|
743
694
|
const handleBlur = isInteractive ? e => {
|
|
744
695
|
if (e.target !== e.currentTarget) {
|
|
745
696
|
setIsEditing(false);
|
|
746
697
|
}
|
|
747
698
|
} : undefined;
|
|
748
|
-
|
|
749
699
|
const focusCell = () => {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
(_cellRef$current = cellRef.current) === null || _cellRef$current === void 0 ? void 0 : _cellRef$current.focus();
|
|
700
|
+
cellRef.current?.focus();
|
|
753
701
|
};
|
|
754
|
-
|
|
755
702
|
const computedWidth = useComputedWidth(widthBuffer, width);
|
|
756
703
|
return /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({}, rest, {
|
|
757
704
|
role: "gridcell",
|
|
@@ -838,7 +785,6 @@ const AdvancedTableColumnHeaders = /*#__PURE__*/React.forwardRef((_ref, ref) =>
|
|
|
838
785
|
});
|
|
839
786
|
|
|
840
787
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
841
|
-
|
|
842
788
|
const AdvancedTableCheckbox = _ref => {
|
|
843
789
|
let {
|
|
844
790
|
state,
|
|
@@ -902,8 +848,6 @@ const AdvancedTableHiddenDescription = _ref => {
|
|
|
902
848
|
};
|
|
903
849
|
|
|
904
850
|
const AdvancedTableDragPreview = _ref => {
|
|
905
|
-
var _columnHeaderRefs$ite, _columnHeaderRefs$ite2, _tableRef$current, _tableRef$current$get;
|
|
906
|
-
|
|
907
851
|
let {
|
|
908
852
|
tableRef,
|
|
909
853
|
columnHeaderRefs
|
|
@@ -915,10 +859,10 @@ const AdvancedTableDragPreview = _ref => {
|
|
|
915
859
|
item: monitor.getItem(),
|
|
916
860
|
currentOffset: monitor.getSourceClientOffset()
|
|
917
861
|
}));
|
|
918
|
-
const width = columnHeaderRefs
|
|
919
|
-
const height =
|
|
920
|
-
const top =
|
|
921
|
-
const left =
|
|
862
|
+
const width = columnHeaderRefs?.[item?.columnIndex]?.getBoundingClientRect()?.width;
|
|
863
|
+
const height = tableRef.current?.getBoundingClientRect()?.height;
|
|
864
|
+
const top = currentOffset?.y || 0;
|
|
865
|
+
const left = currentOffset?.x || 0;
|
|
922
866
|
return /*#__PURE__*/React__default["default"].createElement(index.Portal, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
923
867
|
className: styles$a.dragPreview,
|
|
924
868
|
style: {
|
|
@@ -931,7 +875,6 @@ const AdvancedTableDragPreview = _ref => {
|
|
|
931
875
|
};
|
|
932
876
|
|
|
933
877
|
/* eslint-disable no-nested-ternary */
|
|
934
|
-
|
|
935
878
|
const AdvancedTablePagination = _ref => {
|
|
936
879
|
let {
|
|
937
880
|
rowsPerPage,
|
|
@@ -942,15 +885,13 @@ const AdvancedTablePagination = _ref => {
|
|
|
942
885
|
onPageChange,
|
|
943
886
|
'data-testid': dataTestId
|
|
944
887
|
} = _ref;
|
|
945
|
-
|
|
946
888
|
const handlePageChange = _ref2 => {
|
|
947
889
|
let {
|
|
948
890
|
page
|
|
949
891
|
} = _ref2;
|
|
950
892
|
setCurrentPage(page);
|
|
951
|
-
onPageChange
|
|
893
|
+
onPageChange?.(page);
|
|
952
894
|
};
|
|
953
|
-
|
|
954
895
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
955
896
|
className: styles$a.advancedTablePaginationContainer
|
|
956
897
|
}, /*#__PURE__*/React__default["default"].createElement(index.Pagination, {
|
|
@@ -964,7 +905,6 @@ const AdvancedTablePagination = _ref => {
|
|
|
964
905
|
};
|
|
965
906
|
|
|
966
907
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
967
|
-
|
|
968
908
|
const AdvancedTableRowExpandButton = _ref => {
|
|
969
909
|
let {
|
|
970
910
|
isRowExpanded,
|
|
@@ -1005,8 +945,6 @@ const AdvancedTableRowExpandButton = _ref => {
|
|
|
1005
945
|
};
|
|
1006
946
|
|
|
1007
947
|
const AdvancedTable = _ref => {
|
|
1008
|
-
var _ref5;
|
|
1009
|
-
|
|
1010
948
|
let {
|
|
1011
949
|
columnConfigs: externalColumnConfigs,
|
|
1012
950
|
rows: rowsPropExternal,
|
|
@@ -1048,21 +986,22 @@ const AdvancedTable = _ref => {
|
|
|
1048
986
|
// This handles an edge case where no rows are passed in
|
|
1049
987
|
// and the internal row transforms cause infinite state updates using a standard default assignment
|
|
1050
988
|
const stableDefaultArray = React.useMemo(() => [], []);
|
|
1051
|
-
const rowsProp = rowsPropExternal
|
|
989
|
+
const rowsProp = rowsPropExternal ?? stableDefaultArray;
|
|
1052
990
|
const [rows, setRows] = React.useState();
|
|
1053
991
|
const rowActionsColumnConfigId = index.useId();
|
|
1054
992
|
let rowActionsColumnConfig;
|
|
1055
|
-
const columnConfigs = React.useMemo(() => [...externalColumnConfigs],
|
|
993
|
+
const columnConfigs = React.useMemo(() => [...externalColumnConfigs],
|
|
994
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1056
995
|
[externalColumnConfigs, rows] // columnConfigs has an implicit dependency on rows because it is initially computed using rows data
|
|
1057
996
|
);
|
|
1058
|
-
|
|
997
|
+
|
|
998
|
+
const [currentPage, setCurrentPage] = React.useState(initialPage ?? 1);
|
|
1059
999
|
const [tableHeight, setTableHeight] = React.useState();
|
|
1060
1000
|
const getPaginatedRowIndex = React.useCallback(universalRowIndex => rowsPerPage ? universalRowIndex + rowsPerPage * (currentPage - 1) : universalRowIndex, [rowsPerPage, currentPage]);
|
|
1061
1001
|
const paginatedRows = React.useMemo(() => {
|
|
1062
1002
|
if (!rows || !rowsPerPage || !currentPage) {
|
|
1063
1003
|
return null;
|
|
1064
1004
|
}
|
|
1065
|
-
|
|
1066
1005
|
const startingRowIndex = (currentPage - 1) * rowsPerPage;
|
|
1067
1006
|
const endingRowIndex = startingRowIndex + rowsPerPage;
|
|
1068
1007
|
return rows.slice(startingRowIndex, endingRowIndex);
|
|
@@ -1073,7 +1012,6 @@ const AdvancedTable = _ref => {
|
|
|
1073
1012
|
if (currentPage > pageCount) setCurrentPage(Math.max(pageCount, 1));
|
|
1074
1013
|
}
|
|
1075
1014
|
}, [rows, rowsPerPage, paginatedRows, currentPage]);
|
|
1076
|
-
|
|
1077
1015
|
if (rowActions && columnConfigs[columnConfigs.length - 1].id !== rowActionsColumnConfigId) {
|
|
1078
1016
|
rowActionsColumnConfig = {
|
|
1079
1017
|
id: rowActionsColumnConfigId,
|
|
@@ -1099,28 +1037,26 @@ const AdvancedTable = _ref => {
|
|
|
1099
1037
|
}
|
|
1100
1038
|
}, /*#__PURE__*/React__default["default"].createElement(icons_index.EllipsisHorizontalIcon, null))), /*#__PURE__*/React__default["default"].createElement(index.DropdownList, {
|
|
1101
1039
|
className: styles$a.rowActionMenuPane
|
|
1102
|
-
}, !rows ? [] : rowActions
|
|
1103
|
-
var _actionGroup$actions;
|
|
1104
|
-
|
|
1040
|
+
}, !rows ? [] : rowActions?.map((actionGroup, groupIndex) => {
|
|
1105
1041
|
const row = rows[rowIndex];
|
|
1106
|
-
const actions = !row ? [] :
|
|
1042
|
+
const actions = !row ? [] : actionGroup.actions?.map((action, actionIndex) => /*#__PURE__*/React__default["default"].createElement(index.DropdownOption
|
|
1043
|
+
// React Docs: "We don't recommend using indexes for keys if the order of items may change." These will not change; the alternative is to require an id from the consumer.
|
|
1107
1044
|
// eslint-disable-next-line react/no-array-index-key
|
|
1108
1045
|
, {
|
|
1109
|
-
key:
|
|
1046
|
+
key: `${groupIndex}-${actionIndex}`,
|
|
1110
1047
|
disabled: typeof action.isDisabled === 'function' ? action.isDisabled(row && row.rowPropReference) : action.isDisabled,
|
|
1111
1048
|
onSelect: () => action.action(row && row.rowPropReference),
|
|
1112
1049
|
value: "",
|
|
1113
1050
|
label: ""
|
|
1114
1051
|
}, typeof action.label === 'function' ? action.label(row.rowPropReference) : action.label));
|
|
1115
|
-
|
|
1116
1052
|
if (actionGroup.header) {
|
|
1117
|
-
return /*#__PURE__*/React__default["default"].createElement(index.DropdownHeader
|
|
1053
|
+
return /*#__PURE__*/React__default["default"].createElement(index.DropdownHeader
|
|
1054
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
1118
1055
|
, {
|
|
1119
1056
|
key: groupIndex,
|
|
1120
1057
|
title: actionGroup.header
|
|
1121
1058
|
}, actions);
|
|
1122
1059
|
}
|
|
1123
|
-
|
|
1124
1060
|
return actions;
|
|
1125
1061
|
})));
|
|
1126
1062
|
},
|
|
@@ -1128,33 +1064,28 @@ const AdvancedTable = _ref => {
|
|
|
1128
1064
|
};
|
|
1129
1065
|
columnConfigs.push(rowActionsColumnConfig);
|
|
1130
1066
|
}
|
|
1131
|
-
|
|
1132
1067
|
const tableRef = React.useRef(null);
|
|
1133
1068
|
const hasOnRowSelect = typeof onRowSelect === 'function';
|
|
1134
1069
|
const hasCheckboxColumn = typeof onCheckedRowIdsChange === 'function';
|
|
1135
1070
|
const hasFocusableRows = hasOnRowSelect || hasCheckboxColumn;
|
|
1136
1071
|
const headerRowIndex = -1; // The header row (the first row in the table) gets an index of -1 so that the data rows can be zero-indexed
|
|
1137
|
-
|
|
1138
1072
|
const minRowIndex = React.useMemo(() => rowsPerPage ? rowsPerPage * (currentPage - 1) : 0, [rowsPerPage, currentPage]);
|
|
1139
1073
|
const maxRowIndex = React.useMemo(() => !rows ? 0 : rowsPerPage ? Math.min(rowsPerPage + rowsPerPage * (currentPage - 1) - 1, rows.length - 1) : rows.length - 1, [rowsPerPage, currentPage, rows]);
|
|
1140
1074
|
const maxRowDepth = React.useMemo(() => !rows ? 0 : Math.max(...rows.map(r => r.depth)), [rows]);
|
|
1141
1075
|
const widthBufferWidth = 36;
|
|
1142
1076
|
const columnWidthBuffers = React.useMemo(() => {
|
|
1143
1077
|
const buffers = [0];
|
|
1144
|
-
|
|
1145
1078
|
for (let i = 0; i < maxRowDepth + 1; i += 1) {
|
|
1146
1079
|
buffers[i] = widthBufferWidth * (maxRowDepth - i);
|
|
1147
1080
|
}
|
|
1148
|
-
|
|
1149
1081
|
return buffers;
|
|
1150
1082
|
}, [maxRowDepth]);
|
|
1151
1083
|
const minColumnIndex = hasFocusableRows ? -1 : 0; // When entire rows are focusable, they get an index of -1 so that the columns can be zero-indexed
|
|
1152
|
-
|
|
1153
1084
|
const maxColumnIndex = columnConfigs.length - 1;
|
|
1154
1085
|
const tableId = index.useId(externalTableId);
|
|
1155
|
-
const arrowKeyDescriptionId =
|
|
1156
|
-
const rowActionDescriptionId =
|
|
1157
|
-
const rowCheckboxDescriptionId =
|
|
1086
|
+
const arrowKeyDescriptionId = `${tableId}-arrowKeyDescription`;
|
|
1087
|
+
const rowActionDescriptionId = `${tableId}-rowActionDescription`;
|
|
1088
|
+
const rowCheckboxDescriptionId = `${tableId}-rowCheckboxDescription`;
|
|
1158
1089
|
useResizeObserver__default["default"](tableRef, entry => {
|
|
1159
1090
|
setTableHeight(entry.contentRect.height);
|
|
1160
1091
|
});
|
|
@@ -1162,16 +1093,17 @@ const AdvancedTable = _ref => {
|
|
|
1162
1093
|
const [pinnedColumns, setPinnedColumns] = index.useControllableState(initialPinnedColumns, onPinnedColumnsChange, exteralPinnedColumns);
|
|
1163
1094
|
const [columnWidths, setColumnWidths] = index.useControllableState({}, onColumnWidthsChange, externalColumnWidths);
|
|
1164
1095
|
const columnConfigsOrder = React.useMemo(() => columnConfigs.map(c => c.id), [columnConfigs]);
|
|
1165
|
-
const [internalColumnOrder, setInternalColumnOrder] = React.useState(columnConfigsOrder);
|
|
1096
|
+
const [internalColumnOrder, setInternalColumnOrder] = React.useState(columnConfigsOrder);
|
|
1166
1097
|
|
|
1098
|
+
// If columnConfigs changes, the internal column order may need to be updated (this is why useControllableState isn't being used).
|
|
1167
1099
|
index.useDidUpdate(() => {
|
|
1168
1100
|
setInternalColumnOrder(columnConfigsOrder);
|
|
1169
1101
|
}, [JSON.stringify(columnConfigsOrder)]);
|
|
1170
|
-
const columnOrder = externalColumnOrder
|
|
1102
|
+
const columnOrder = externalColumnOrder ?? internalColumnOrder;
|
|
1171
1103
|
const setColumnOrder = index.useEventCallback(value => {
|
|
1172
1104
|
const newColumnOrder = typeof value === 'function' ? value(columnOrder) : value;
|
|
1173
1105
|
setInternalColumnOrder(newColumnOrder);
|
|
1174
|
-
onColumnOrderChange
|
|
1106
|
+
onColumnOrderChange?.(newColumnOrder);
|
|
1175
1107
|
});
|
|
1176
1108
|
const {
|
|
1177
1109
|
pinnedColumnConfigs,
|
|
@@ -1200,10 +1132,11 @@ const AdvancedTable = _ref => {
|
|
|
1200
1132
|
const [dragSource, setDragSource] = React.useState('');
|
|
1201
1133
|
const [dropTarget, setDropTarget] = React.useState('');
|
|
1202
1134
|
const [dropTargetSide, setDropTargetSide] = React.useState();
|
|
1203
|
-
const [lastToggledRowId, setLastToggledRowId] = React.useState('');
|
|
1204
|
-
|
|
1205
|
-
const [isCheckboxHovered, setIsCheckboxHovered] = React.useState(false);
|
|
1135
|
+
const [lastToggledRowId, setLastToggledRowId] = React.useState('');
|
|
1136
|
+
// Enables disabling row hover styles when hovering on the checkbox. Needed since a CSS parent selector doesn't exist.
|
|
1137
|
+
const [isCheckboxHovered, setIsCheckboxHovered] = React.useState(false);
|
|
1206
1138
|
|
|
1139
|
+
// Enables using Set.prototype.has() vs Array.prototype.includes() for better performance at scale
|
|
1207
1140
|
const [checkedRowIdsSet, setCheckedRowIdsSet] = React.useState(new Set(checkedRowIds));
|
|
1208
1141
|
useSortedRows({
|
|
1209
1142
|
columnConfigs,
|
|
@@ -1227,13 +1160,11 @@ const AdvancedTable = _ref => {
|
|
|
1227
1160
|
rowProps: row.unsafe_rowProps,
|
|
1228
1161
|
rowPropReference: row
|
|
1229
1162
|
});
|
|
1230
|
-
|
|
1231
1163
|
if (row.isExpanded && row.childRows !== undefined && hasChildRows) {
|
|
1232
1164
|
row.childRows.forEach((child, i) => {
|
|
1233
1165
|
mappedRows = mappedRows.concat(mapExternalRowToInternalRows(child, row.childRows !== undefined ? row.childRows.length : 0, i, row.id, depth + 1));
|
|
1234
1166
|
});
|
|
1235
1167
|
}
|
|
1236
|
-
|
|
1237
1168
|
return mappedRows;
|
|
1238
1169
|
}, []);
|
|
1239
1170
|
React.useEffect(() => {
|
|
@@ -1242,6 +1173,7 @@ const AdvancedTable = _ref => {
|
|
|
1242
1173
|
filteredRows = filteredRows.concat(mapExternalRowToInternalRows(row, rowsProp.length + 1, i + 1) // add 1 to account for table header
|
|
1243
1174
|
);
|
|
1244
1175
|
});
|
|
1176
|
+
|
|
1245
1177
|
setRows(filteredRows);
|
|
1246
1178
|
}, [rowsProp, mapExternalRowToInternalRows]);
|
|
1247
1179
|
React.useEffect(() => {
|
|
@@ -1271,7 +1203,6 @@ const AdvancedTable = _ref => {
|
|
|
1271
1203
|
let ids = [];
|
|
1272
1204
|
rowsToScan.forEach(row => {
|
|
1273
1205
|
ids.push(row.id);
|
|
1274
|
-
|
|
1275
1206
|
if (row.childRows && row.childRows.length) {
|
|
1276
1207
|
ids = ids.concat(getAllRowIds(row.childRows));
|
|
1277
1208
|
}
|
|
@@ -1279,34 +1210,29 @@ const AdvancedTable = _ref => {
|
|
|
1279
1210
|
return ids;
|
|
1280
1211
|
}, [rowsProp]);
|
|
1281
1212
|
const totalRowsCountWithExpansion = React.useMemo(() => getAllRowIds().length, [getAllRowIds]);
|
|
1282
|
-
const hasExpandableRows = React.useMemo(() => rows
|
|
1213
|
+
const hasExpandableRows = React.useMemo(() => rows?.some(_ref3 => {
|
|
1283
1214
|
let {
|
|
1284
1215
|
hasChildRows
|
|
1285
1216
|
} = _ref3;
|
|
1286
1217
|
return hasChildRows;
|
|
1287
1218
|
}), [rows]);
|
|
1288
|
-
|
|
1289
1219
|
const updateExpandedRowIds = (index, expand) => {
|
|
1290
1220
|
if (!rows || !rows[index]) {
|
|
1291
1221
|
return;
|
|
1292
1222
|
}
|
|
1293
|
-
|
|
1294
1223
|
const {
|
|
1295
1224
|
isExpanded,
|
|
1296
1225
|
rowPropReference
|
|
1297
1226
|
} = rows[index];
|
|
1298
|
-
|
|
1299
1227
|
if (isExpanded && expand !== true) {
|
|
1300
1228
|
rowPropReference.isExpanded = false;
|
|
1301
1229
|
} else if (expand !== false) {
|
|
1302
1230
|
rowPropReference.isExpanded = true;
|
|
1303
1231
|
}
|
|
1304
|
-
|
|
1305
|
-
onRowsChange === null || onRowsChange === void 0 ? void 0 : onRowsChange([...rowsProp]);
|
|
1232
|
+
onRowsChange?.([...rowsProp]);
|
|
1306
1233
|
};
|
|
1307
|
-
|
|
1308
1234
|
const getLastToggledRowIndex = () => {
|
|
1309
|
-
const index = rows
|
|
1235
|
+
const index = rows?.findIndex(_ref4 => {
|
|
1310
1236
|
let {
|
|
1311
1237
|
id
|
|
1312
1238
|
} = _ref4;
|
|
@@ -1314,220 +1240,163 @@ const AdvancedTable = _ref => {
|
|
|
1314
1240
|
});
|
|
1315
1241
|
return index === -1 ? 0 : index;
|
|
1316
1242
|
};
|
|
1317
|
-
|
|
1318
1243
|
const getCheckboxStateForRow = row => {
|
|
1319
1244
|
if (checkedRowIdsSet.has(row.id)) {
|
|
1320
1245
|
return 'true';
|
|
1321
1246
|
}
|
|
1322
|
-
|
|
1323
1247
|
if (row.hasChildRows && getAllRowIds(row.rowPropReference.childRows).some(id => checkedRowIdsSet.has(id))) {
|
|
1324
1248
|
return 'mixed';
|
|
1325
1249
|
}
|
|
1326
|
-
|
|
1327
1250
|
return 'false';
|
|
1328
1251
|
};
|
|
1329
|
-
|
|
1330
1252
|
const handleColumnHeaderCheckboxToggle = () => {
|
|
1331
1253
|
setLastToggledRowId('');
|
|
1332
|
-
|
|
1333
1254
|
if (checkedRowIds.length === totalRowsCountWithExpansion) {
|
|
1334
1255
|
setCheckedRowIds([]);
|
|
1335
1256
|
} else {
|
|
1336
1257
|
setCheckedRowIds(getAllRowIds());
|
|
1337
1258
|
}
|
|
1338
1259
|
};
|
|
1339
|
-
|
|
1340
1260
|
const multiUpdateCheckedRowIds = (startIndex, endIndex) => {
|
|
1341
|
-
var _rows$endIndex;
|
|
1342
|
-
|
|
1343
1261
|
if (!rows || startIndex === headerRowIndex || endIndex === headerRowIndex) {
|
|
1344
1262
|
return;
|
|
1345
1263
|
}
|
|
1346
|
-
|
|
1347
|
-
const endRowId = rows === null || rows === void 0 ? void 0 : (_rows$endIndex = rows[endIndex]) === null || _rows$endIndex === void 0 ? void 0 : _rows$endIndex.id;
|
|
1264
|
+
const endRowId = rows?.[endIndex]?.id;
|
|
1348
1265
|
const isEndIndexChecked = checkedRowIdsSet.has(endRowId);
|
|
1349
1266
|
let newCheckedRowIds = [...checkedRowIds];
|
|
1350
1267
|
const increment = startIndex < endIndex ? 1 : -1;
|
|
1351
|
-
|
|
1352
1268
|
for (let i = startIndex; i !== endIndex + increment; i += increment) {
|
|
1353
1269
|
const {
|
|
1354
1270
|
id: rowId,
|
|
1355
1271
|
hasChildRows,
|
|
1356
1272
|
rowPropReference
|
|
1357
1273
|
} = rows[i];
|
|
1358
|
-
|
|
1359
1274
|
if (isEndIndexChecked) {
|
|
1360
1275
|
let idsToUncheck = [rowId];
|
|
1361
|
-
|
|
1362
1276
|
if (hasChildRows) {
|
|
1363
1277
|
idsToUncheck = idsToUncheck.concat(getAllRowIds(rowPropReference.childRows));
|
|
1364
1278
|
}
|
|
1365
|
-
|
|
1366
1279
|
if (hasChildRows) {
|
|
1367
1280
|
idsToUncheck = idsToUncheck.concat(getAllRowIds(rowPropReference.childRows));
|
|
1368
1281
|
}
|
|
1369
|
-
|
|
1370
1282
|
newCheckedRowIds = newCheckedRowIds.filter(id => !_includesInstanceProperty__default["default"](idsToUncheck).call(idsToUncheck, id));
|
|
1371
1283
|
} else if (!checkedRowIdsSet.has(rowId)) {
|
|
1372
1284
|
let idsToCheck = [rowId];
|
|
1373
|
-
|
|
1374
1285
|
if (hasChildRows) {
|
|
1375
1286
|
idsToCheck = idsToCheck.concat(getAllRowIds(rowPropReference.childRows));
|
|
1376
1287
|
}
|
|
1377
|
-
|
|
1378
1288
|
newCheckedRowIds = newCheckedRowIds.concat(idsToCheck);
|
|
1379
1289
|
}
|
|
1380
1290
|
}
|
|
1381
|
-
|
|
1382
1291
|
setLastToggledRowId(endRowId);
|
|
1383
1292
|
setCheckedRowIds(newCheckedRowIds);
|
|
1384
1293
|
};
|
|
1385
|
-
|
|
1386
1294
|
const singleUpdateCheckedRowIds = index => {
|
|
1387
1295
|
if (!rows) {
|
|
1388
1296
|
return;
|
|
1389
1297
|
}
|
|
1390
|
-
|
|
1391
1298
|
const {
|
|
1392
1299
|
id: rowId,
|
|
1393
1300
|
rowPropReference,
|
|
1394
1301
|
hasChildRows
|
|
1395
1302
|
} = rows[index];
|
|
1396
1303
|
setLastToggledRowId(rowId);
|
|
1397
|
-
|
|
1398
1304
|
if (checkedRowIdsSet.has(rowId)) {
|
|
1399
1305
|
let idsToUncheck = [rowId];
|
|
1400
|
-
|
|
1401
1306
|
if (hasChildRows) {
|
|
1402
1307
|
idsToUncheck = idsToUncheck.concat(getAllRowIds(rowPropReference.childRows));
|
|
1403
1308
|
}
|
|
1404
|
-
|
|
1405
1309
|
setCheckedRowIds(checkedRowIds.filter(id => !_includesInstanceProperty__default["default"](idsToUncheck).call(idsToUncheck, id)));
|
|
1406
1310
|
} else {
|
|
1407
1311
|
let idsToCheck = [rowId];
|
|
1408
|
-
|
|
1409
1312
|
if (hasChildRows) {
|
|
1410
1313
|
idsToCheck = idsToCheck.concat(getAllRowIds(rowPropReference.childRows).filter(r => !checkedRowIdsSet.has(r)));
|
|
1411
1314
|
}
|
|
1412
|
-
|
|
1413
1315
|
setCheckedRowIds([...checkedRowIds, ...idsToCheck]);
|
|
1414
1316
|
}
|
|
1415
1317
|
};
|
|
1416
|
-
|
|
1417
1318
|
const onCellFocus = (rowIndex, columnIndex) => () => {
|
|
1418
1319
|
updateRowFocusIndex(rowIndex);
|
|
1419
1320
|
updateColumnFocusIndex(columnIndex);
|
|
1420
1321
|
};
|
|
1421
|
-
|
|
1422
1322
|
const onRowFocus = (rowIndex, columnIndex) => e => {
|
|
1423
1323
|
if (e.target !== e.currentTarget) return;
|
|
1424
1324
|
updateRowFocusIndex(rowIndex);
|
|
1425
1325
|
updateColumnFocusIndex(columnIndex);
|
|
1426
1326
|
};
|
|
1427
|
-
|
|
1428
1327
|
const onKeyDown = rowIndex => e => {
|
|
1429
1328
|
if (!rows || e.target !== e.currentTarget) return; // Ensures only rows/cells trigger grid navigation
|
|
1430
|
-
|
|
1431
1329
|
let newFocusedRowIndex;
|
|
1432
1330
|
const currentRow = rows[rowIndex];
|
|
1433
1331
|
const rowOrFirstColumnIsFocused = focusedColumnIndex <= 0;
|
|
1434
|
-
const rowCanExpand =
|
|
1435
|
-
const rowCanCollapse =
|
|
1436
|
-
|
|
1332
|
+
const rowCanExpand = currentRow?.hasChildRows && !currentRow?.isExpanded;
|
|
1333
|
+
const rowCanCollapse = currentRow?.hasChildRows && currentRow?.isExpanded;
|
|
1437
1334
|
switch (e.key) {
|
|
1438
1335
|
case 'ArrowUp':
|
|
1439
1336
|
e.preventDefault(); // prevent scroll
|
|
1440
|
-
|
|
1441
1337
|
index.setIsKeyboardUser(true);
|
|
1442
1338
|
newFocusedRowIndex = updateRowFocusIndex(rowIndex === minRowIndex ? headerRowIndex : rowIndex - 1);
|
|
1443
|
-
|
|
1444
1339
|
if (e.shiftKey) {
|
|
1445
1340
|
multiUpdateCheckedRowIds(rowIndex, newFocusedRowIndex);
|
|
1446
1341
|
}
|
|
1447
|
-
|
|
1448
1342
|
break;
|
|
1449
|
-
|
|
1450
1343
|
case 'ArrowDown':
|
|
1451
1344
|
e.preventDefault(); // prevent scroll
|
|
1452
|
-
|
|
1453
1345
|
index.setIsKeyboardUser(true);
|
|
1454
1346
|
newFocusedRowIndex = updateRowFocusIndex(rowIndex === headerRowIndex ? minRowIndex : rowIndex + 1);
|
|
1455
|
-
|
|
1456
1347
|
if (e.shiftKey) {
|
|
1457
1348
|
multiUpdateCheckedRowIds(rowIndex, newFocusedRowIndex);
|
|
1458
1349
|
}
|
|
1459
|
-
|
|
1460
1350
|
break;
|
|
1461
|
-
|
|
1462
1351
|
case 'ArrowLeft':
|
|
1463
1352
|
e.preventDefault(); // prevent scroll
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1353
|
+
index.setIsKeyboardUser(true);
|
|
1354
|
+
// If the row is expanded and on the first cell, collapse the row
|
|
1467
1355
|
if (e.shiftKey || rowOrFirstColumnIsFocused && rowCanCollapse) {
|
|
1468
1356
|
updateExpandedRowIds(rowIndex, false);
|
|
1469
1357
|
break;
|
|
1470
1358
|
}
|
|
1471
|
-
|
|
1472
1359
|
updateColumnFocusIndex(focusedColumnIndex - 1);
|
|
1473
1360
|
break;
|
|
1474
|
-
|
|
1475
1361
|
case 'ArrowRight':
|
|
1476
1362
|
e.preventDefault(); // prevent scroll
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1363
|
+
index.setIsKeyboardUser(true);
|
|
1364
|
+
// If the row is collapsed and on the first cell, expand the row
|
|
1480
1365
|
if (e.shiftKey || rowOrFirstColumnIsFocused && rowCanExpand) {
|
|
1481
1366
|
updateExpandedRowIds(rowIndex, true);
|
|
1482
1367
|
break;
|
|
1483
1368
|
}
|
|
1484
|
-
|
|
1485
1369
|
updateColumnFocusIndex(focusedColumnIndex + 1);
|
|
1486
1370
|
break;
|
|
1487
|
-
|
|
1488
1371
|
case 'PageUp':
|
|
1489
1372
|
e.preventDefault(); // prevent scroll
|
|
1490
|
-
|
|
1491
1373
|
index.setIsKeyboardUser(true);
|
|
1492
1374
|
updateRowFocusIndex(headerRowIndex);
|
|
1493
1375
|
break;
|
|
1494
|
-
|
|
1495
1376
|
case 'PageDown':
|
|
1496
1377
|
e.preventDefault(); // prevent scroll
|
|
1497
|
-
|
|
1498
1378
|
index.setIsKeyboardUser(true);
|
|
1499
1379
|
updateRowFocusIndex(maxRowIndex);
|
|
1500
1380
|
break;
|
|
1501
|
-
|
|
1502
1381
|
case 'Home':
|
|
1503
1382
|
e.preventDefault(); // prevent scroll
|
|
1504
|
-
|
|
1505
1383
|
index.setIsKeyboardUser(true);
|
|
1506
1384
|
updateColumnFocusIndex(minColumnIndex);
|
|
1507
|
-
|
|
1508
1385
|
if (e.ctrlKey) {
|
|
1509
1386
|
updateRowFocusIndex(headerRowIndex);
|
|
1510
1387
|
}
|
|
1511
|
-
|
|
1512
1388
|
break;
|
|
1513
|
-
|
|
1514
1389
|
case 'End':
|
|
1515
1390
|
e.preventDefault(); // prevent scroll
|
|
1516
|
-
|
|
1517
1391
|
index.setIsKeyboardUser(true);
|
|
1518
1392
|
updateColumnFocusIndex(maxColumnIndex);
|
|
1519
|
-
|
|
1520
1393
|
if (e.ctrlKey) {
|
|
1521
1394
|
updateRowFocusIndex(maxRowIndex);
|
|
1522
1395
|
}
|
|
1523
|
-
|
|
1524
1396
|
break;
|
|
1525
|
-
|
|
1526
1397
|
case ' ':
|
|
1527
1398
|
e.preventDefault(); // prevent scroll
|
|
1528
|
-
|
|
1529
1399
|
index.setIsKeyboardUser(true);
|
|
1530
|
-
|
|
1531
1400
|
if (rowIndex === headerRowIndex) {
|
|
1532
1401
|
handleColumnHeaderCheckboxToggle();
|
|
1533
1402
|
} else if (e.shiftKey) {
|
|
@@ -1535,17 +1404,12 @@ const AdvancedTable = _ref => {
|
|
|
1535
1404
|
} else {
|
|
1536
1405
|
singleUpdateCheckedRowIds(rowIndex);
|
|
1537
1406
|
}
|
|
1538
|
-
|
|
1539
1407
|
break;
|
|
1540
|
-
|
|
1541
1408
|
default:
|
|
1542
1409
|
break;
|
|
1543
1410
|
}
|
|
1544
1411
|
};
|
|
1545
|
-
|
|
1546
1412
|
const getColumnHeaderProps = (columnConfig, columnIndex, isPinned) => {
|
|
1547
|
-
var _columnWidths$id;
|
|
1548
|
-
|
|
1549
1413
|
const rowIndex = headerRowIndex;
|
|
1550
1414
|
const {
|
|
1551
1415
|
id,
|
|
@@ -1558,9 +1422,9 @@ const AdvancedTable = _ref => {
|
|
|
1558
1422
|
return {
|
|
1559
1423
|
id,
|
|
1560
1424
|
isRowActionMenuColumn,
|
|
1561
|
-
'data-testid': dataTestId && id ?
|
|
1425
|
+
'data-testid': dataTestId && id ? `${dataTestId}-${id}` : undefined,
|
|
1562
1426
|
label: headerLabel,
|
|
1563
|
-
width:
|
|
1427
|
+
width: columnWidths[id] ?? width,
|
|
1564
1428
|
widthBuffer: columnIndex === 0 && maxRowDepth > 0 ? columnWidthBuffers[0] : undefined,
|
|
1565
1429
|
onWidthChange: disableUserResizableColumns || isRowActionMenuColumn ? undefined : newWidth => {
|
|
1566
1430
|
setColumnWidths(currentColumnWidths => {
|
|
@@ -1570,12 +1434,9 @@ const AdvancedTable = _ref => {
|
|
|
1570
1434
|
} else if (currentColumnWidths[colId]) {
|
|
1571
1435
|
map[colId] = currentColumnWidths[colId];
|
|
1572
1436
|
} else {
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
const colRef = (_cellRefs$current = cellRefs.current) === null || _cellRefs$current === void 0 ? void 0 : (_cellRefs$current$hea = _cellRefs$current[headerRowIndex]) === null || _cellRefs$current$hea === void 0 ? void 0 : _cellRefs$current$hea[index];
|
|
1576
|
-
map[colId] = colRef === null || colRef === void 0 ? void 0 : colRef.getBoundingClientRect().width;
|
|
1437
|
+
const colRef = cellRefs.current?.[headerRowIndex]?.[index];
|
|
1438
|
+
map[colId] = colRef?.getBoundingClientRect().width;
|
|
1577
1439
|
}
|
|
1578
|
-
|
|
1579
1440
|
return map;
|
|
1580
1441
|
}, {});
|
|
1581
1442
|
return newColumnsWidths;
|
|
@@ -1609,19 +1470,16 @@ const AdvancedTable = _ref => {
|
|
|
1609
1470
|
headerMaxLines
|
|
1610
1471
|
};
|
|
1611
1472
|
};
|
|
1612
|
-
|
|
1613
1473
|
const getAdvancedTableRowExpandButton = (rowId, isExpanded, rowIndex) => /*#__PURE__*/React__default["default"].createElement(AdvancedTableRowExpandButton, {
|
|
1614
|
-
"data-testid": dataTestId && rowId ?
|
|
1474
|
+
"data-testid": dataTestId && rowId ? `${dataTestId}-row-${rowId}-expand-button` : undefined,
|
|
1615
1475
|
isRowExpanded: !!isExpanded,
|
|
1616
1476
|
onClick: e => {
|
|
1617
1477
|
e.stopPropagation(); // prevent onRowSelect
|
|
1618
|
-
|
|
1619
1478
|
e.preventDefault();
|
|
1620
1479
|
updateExpandedRowIds(rowIndex);
|
|
1621
1480
|
},
|
|
1622
1481
|
onFocus: onRowFocus(rowIndex, minColumnIndex)
|
|
1623
1482
|
});
|
|
1624
|
-
|
|
1625
1483
|
const getExpandableRowsSpacer = function (width, inHeader) {
|
|
1626
1484
|
let children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
1627
1485
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -1633,10 +1491,7 @@ const AdvancedTable = _ref => {
|
|
|
1633
1491
|
}
|
|
1634
1492
|
}, children);
|
|
1635
1493
|
};
|
|
1636
|
-
|
|
1637
1494
|
const getCellProps = (columnConfig, columnIndex, data, rowIndex, rowId, depth) => {
|
|
1638
|
-
var _columnWidths$columnI;
|
|
1639
|
-
|
|
1640
1495
|
const {
|
|
1641
1496
|
id: columnId,
|
|
1642
1497
|
width,
|
|
@@ -1650,18 +1505,18 @@ const AdvancedTable = _ref => {
|
|
|
1650
1505
|
setValue: newValue => {
|
|
1651
1506
|
const newRows = [...rowsProp];
|
|
1652
1507
|
newRows[rowIndex].data[columnId] = newValue;
|
|
1653
|
-
onRowsChange
|
|
1508
|
+
onRowsChange?.(newRows);
|
|
1654
1509
|
},
|
|
1655
1510
|
renderCellContent,
|
|
1656
1511
|
isCellContentInteractive,
|
|
1657
|
-
width:
|
|
1512
|
+
width: columnWidths[columnId] ?? width,
|
|
1658
1513
|
widthBuffer: columnIndex === 0 && maxRowDepth > 0 ? columnWidthBuffers[depth] : undefined,
|
|
1659
1514
|
alignment,
|
|
1660
1515
|
rowId,
|
|
1661
1516
|
columnId,
|
|
1662
1517
|
rowIndex,
|
|
1663
1518
|
columnIndex,
|
|
1664
|
-
'data-testid': dataTestId && rowId && columnId ?
|
|
1519
|
+
'data-testid': dataTestId && rowId && columnId ? `${dataTestId}-cell-${rowId}-${columnId}` : undefined,
|
|
1665
1520
|
isFocused: rowIndex === focusedRowIndex && columnIndex === focusedColumnIndex,
|
|
1666
1521
|
onFocus: onCellFocus(rowIndex, columnIndex),
|
|
1667
1522
|
onKeyDown: onKeyDown(rowIndex),
|
|
@@ -1670,7 +1525,6 @@ const AdvancedTable = _ref => {
|
|
|
1670
1525
|
ref: createRef(rowIndex, columnIndex)
|
|
1671
1526
|
};
|
|
1672
1527
|
};
|
|
1673
|
-
|
|
1674
1528
|
return /*#__PURE__*/React__default["default"].createElement(reactDnd.DndProvider, {
|
|
1675
1529
|
backend: reactDndHtml5Backend.HTML5Backend
|
|
1676
1530
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -1703,6 +1557,7 @@ const AdvancedTable = _ref => {
|
|
|
1703
1557
|
"aria-rowindex": hasExpandableRows ? undefined : 1,
|
|
1704
1558
|
"aria-level": hasExpandableRows ? 1 : undefined // aria-level is one-indexed
|
|
1705
1559
|
,
|
|
1560
|
+
|
|
1706
1561
|
"aria-setsize": hasExpandableRows ? rowsProp.length + 1 : undefined,
|
|
1707
1562
|
"aria-posinset": hasExpandableRows ? 1 : undefined // aria-posinset is one-indexed
|
|
1708
1563
|
,
|
|
@@ -1721,16 +1576,16 @@ const AdvancedTable = _ref => {
|
|
|
1721
1576
|
onClick: handleColumnHeaderCheckboxToggle,
|
|
1722
1577
|
onFocus: onRowFocus(headerRowIndex, minColumnIndex),
|
|
1723
1578
|
variant: "header"
|
|
1724
|
-
}), hasExpandableRows && pinnedColumnConfigs.length ? getExpandableRowsSpacer(
|
|
1579
|
+
}), hasExpandableRows && pinnedColumnConfigs.length ? getExpandableRowsSpacer(`${widthBufferWidth}px`, true) : undefined, pinnedColumnConfigs.map((columnConfigs, i) => {
|
|
1725
1580
|
const props = getColumnHeaderProps(columnConfigs, i, true);
|
|
1726
1581
|
return /*#__PURE__*/React__default["default"].createElement(AdvancedTableColumnHeader, props);
|
|
1727
|
-
})) : undefined, hasExpandableRows && !pinnedColumnConfigs.length ? getExpandableRowsSpacer(
|
|
1582
|
+
})) : undefined, hasExpandableRows && !pinnedColumnConfigs.length ? getExpandableRowsSpacer(`${widthBufferWidth}px`, true) : undefined, unpinnedColumnConfigs.map((columnConfigs, i) => {
|
|
1728
1583
|
const props = getColumnHeaderProps(columnConfigs, i + pinnedColumnConfigs.length, false);
|
|
1729
1584
|
return /*#__PURE__*/React__default["default"].createElement(AdvancedTableColumnHeader, props);
|
|
1730
1585
|
}))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1731
1586
|
role: "rowgroup",
|
|
1732
1587
|
className: styles$a.advancedTableRowGroup
|
|
1733
|
-
}, (
|
|
1588
|
+
}, (paginatedRows ?? rows ?? []).map((row, rowIndex) => {
|
|
1734
1589
|
const {
|
|
1735
1590
|
id: rowId,
|
|
1736
1591
|
data,
|
|
@@ -1744,29 +1599,25 @@ const AdvancedTable = _ref => {
|
|
|
1744
1599
|
} = row;
|
|
1745
1600
|
const hasChildRows = rowPropReference.childRows && rowPropReference.childRows.length > 0;
|
|
1746
1601
|
const paginatedRowIndex = getPaginatedRowIndex(rowIndex);
|
|
1747
|
-
|
|
1748
1602
|
const onSelect = e => {
|
|
1749
1603
|
e.preventDefault(); // stops event from triggering on new target when focus is changed during onSelect
|
|
1750
|
-
|
|
1751
1604
|
if (hasOnRowSelect) {
|
|
1752
|
-
onRowSelect
|
|
1605
|
+
onRowSelect?.(row.rowPropReference);
|
|
1753
1606
|
setSelectedRowId(rowId);
|
|
1754
1607
|
}
|
|
1755
1608
|
};
|
|
1756
|
-
|
|
1757
1609
|
const onRowKeyDown = e => {
|
|
1758
1610
|
if (e.target !== e.currentTarget) return;
|
|
1759
1611
|
onKeyDown(paginatedRowIndex)(e);
|
|
1760
|
-
|
|
1761
1612
|
if (e.key === 'Enter') {
|
|
1762
1613
|
onSelect(e);
|
|
1763
1614
|
}
|
|
1764
1615
|
};
|
|
1765
|
-
|
|
1766
1616
|
return /*#__PURE__*/React__default["default"].createElement(AdvancedTableRow, _extends__default["default"]({}, rowProps, {
|
|
1767
1617
|
"aria-rowindex": hasExpandableRows ? undefined : paginatedRowIndex + 2 // aria-rowindex is one-indexed + the column headers row is the first row in the table
|
|
1768
1618
|
,
|
|
1769
|
-
|
|
1619
|
+
|
|
1620
|
+
"data-testid": dataTestId && rowId ? `${dataTestId}-row-${rowId}` : undefined,
|
|
1770
1621
|
hasOnRowSelect: hasOnRowSelect,
|
|
1771
1622
|
isFocusable: hasFocusableRows,
|
|
1772
1623
|
isFocused: paginatedRowIndex === focusedRowIndex && minColumnIndex === focusedColumnIndex,
|
|
@@ -1775,13 +1626,13 @@ const AdvancedTable = _ref => {
|
|
|
1775
1626
|
onKeyDown: onRowKeyDown,
|
|
1776
1627
|
onFocus: onRowFocus(paginatedRowIndex, minColumnIndex),
|
|
1777
1628
|
onClick: e => onSelect(e),
|
|
1778
|
-
key:
|
|
1629
|
+
key: `${rowId}${depth}${parentId}`,
|
|
1779
1630
|
ref: createRef(paginatedRowIndex, minColumnIndex),
|
|
1780
1631
|
"aria-level": hasExpandableRows ? depth + 1 : undefined // aria-level is one-indexed
|
|
1781
1632
|
,
|
|
1633
|
+
|
|
1782
1634
|
"aria-setsize": hasExpandableRows ? depthSize : undefined,
|
|
1783
1635
|
"aria-posinset": hasExpandableRows ? depthIndex + 1 : undefined // aria-posinset is one-indexed
|
|
1784
|
-
|
|
1785
1636
|
}), hasCheckboxColumn || pinnedColumnConfigs.length ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1786
1637
|
className: classNames__default["default"](styles$a.pinnedContainer, styles$a.advancedTableRowChild),
|
|
1787
1638
|
ref: createPinnedContainerRef(paginatedRowIndex)
|
|
@@ -1790,7 +1641,6 @@ const AdvancedTable = _ref => {
|
|
|
1790
1641
|
isRowFocused: paginatedRowIndex === focusedRowIndex,
|
|
1791
1642
|
onClick: e => {
|
|
1792
1643
|
e.stopPropagation(); // prevent onRowSelect
|
|
1793
|
-
|
|
1794
1644
|
if (e.shiftKey) {
|
|
1795
1645
|
multiUpdateCheckedRowIds(getLastToggledRowIndex(), paginatedRowIndex);
|
|
1796
1646
|
} else {
|
|
@@ -1800,22 +1650,20 @@ const AdvancedTable = _ref => {
|
|
|
1800
1650
|
onMouseEnter: () => setIsCheckboxHovered(true),
|
|
1801
1651
|
onMouseLeave: () => setIsCheckboxHovered(false),
|
|
1802
1652
|
onFocus: onRowFocus(paginatedRowIndex, minColumnIndex)
|
|
1803
|
-
}), hasExpandableRows && pinnedColumnConfigs.length ? getExpandableRowsSpacer(
|
|
1653
|
+
}), hasExpandableRows && pinnedColumnConfigs.length ? getExpandableRowsSpacer(`${widthBufferWidth * (depth + 1)}px`, false, hasChildRows ? getAdvancedTableRowExpandButton(rowId, isExpanded, rowIndex) : undefined) : undefined, pinnedColumnConfigs.map((c, i) => {
|
|
1804
1654
|
const props = getCellProps(c, i, data, paginatedRowIndex, rowId, depth);
|
|
1805
1655
|
return /*#__PURE__*/React__default["default"].createElement(AdvancedTableCell, _extends__default["default"]({}, props, {
|
|
1806
1656
|
"aria-rowindex": hasExpandableRows ? undefined : rowIndex + 2 // aria-rowindex is one-indexed + the column headers row is the first row in the table
|
|
1807
1657
|
,
|
|
1808
1658
|
"aria-colindex": i + 1 // aria-colindex is one-indexed
|
|
1809
|
-
|
|
1810
1659
|
}));
|
|
1811
|
-
})) : undefined, hasExpandableRows && !pinnedColumnConfigs.length ? getExpandableRowsSpacer(
|
|
1660
|
+
})) : undefined, hasExpandableRows && !pinnedColumnConfigs.length ? getExpandableRowsSpacer(`${widthBufferWidth * (depth + 1)}px`, false, hasChildRows ? getAdvancedTableRowExpandButton(rowId, isExpanded, rowIndex) : undefined) : undefined, unpinnedColumnConfigs.map((c, i) => {
|
|
1812
1661
|
const props = getCellProps(c, i + pinnedColumnConfigs.length, data, paginatedRowIndex, rowId, depth);
|
|
1813
1662
|
return /*#__PURE__*/React__default["default"].createElement(AdvancedTableCell, _extends__default["default"]({}, props, {
|
|
1814
1663
|
className: styles$a.advancedTableRowChild,
|
|
1815
1664
|
"aria-rowindex": hasExpandableRows ? undefined : rowIndex + 2 // aria-rowindex is one-indexed + the column headers row is the first row in the table
|
|
1816
1665
|
,
|
|
1817
1666
|
"aria-colindex": i + 1 // aria-colindex is one-indexed
|
|
1818
|
-
|
|
1819
1667
|
}));
|
|
1820
1668
|
}));
|
|
1821
1669
|
})), rowsPerPage ? /*#__PURE__*/React__default["default"].createElement(AdvancedTablePagination, {
|
|
@@ -1827,40 +1675,38 @@ const AdvancedTable = _ref => {
|
|
|
1827
1675
|
setCurrentPage: setCurrentPage,
|
|
1828
1676
|
"data-testid": index.getSubDataTestId(dataTestId, 'TablePagination')
|
|
1829
1677
|
}) : null));
|
|
1830
|
-
};
|
|
1678
|
+
};
|
|
1831
1679
|
|
|
1832
|
-
|
|
1680
|
+
// TODO: move hook to separate file
|
|
1681
|
+
function useSortedRows(_ref5) {
|
|
1833
1682
|
let {
|
|
1834
1683
|
columnConfigs,
|
|
1835
1684
|
onRowsChange,
|
|
1836
1685
|
selectedSortOption,
|
|
1837
1686
|
setCurrentPage
|
|
1838
|
-
} =
|
|
1687
|
+
} = _ref5;
|
|
1839
1688
|
const columnConfigsRef = index.useLatest(columnConfigs);
|
|
1840
1689
|
const onRowsChangeRef = index.useLatest(onRowsChange);
|
|
1841
1690
|
index.useDidUpdate(() => {
|
|
1842
|
-
var _columnConfigsRef$cur, _columnConfigsRef$cur2, _columnConfigsRef$cur3;
|
|
1843
|
-
|
|
1844
1691
|
const {
|
|
1845
1692
|
columnId,
|
|
1846
1693
|
index
|
|
1847
1694
|
} = selectedSortOption;
|
|
1848
|
-
const sort =
|
|
1695
|
+
const sort = columnConfigsRef.current.find(_ref6 => {
|
|
1849
1696
|
let {
|
|
1850
1697
|
id
|
|
1851
|
-
} =
|
|
1698
|
+
} = _ref6;
|
|
1852
1699
|
return id === columnId;
|
|
1853
|
-
})
|
|
1854
|
-
|
|
1700
|
+
})?.sortOptions?.[index]?.sort;
|
|
1855
1701
|
if (typeof sort === 'function' && onRowsChangeRef.current) {
|
|
1856
1702
|
onRowsChangeRef.current(sort(selectedSortOption));
|
|
1857
1703
|
setCurrentPage(1);
|
|
1858
1704
|
}
|
|
1859
1705
|
}, [columnConfigsRef, onRowsChangeRef, selectedSortOption]);
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1706
|
+
}
|
|
1862
1707
|
|
|
1863
|
-
|
|
1708
|
+
// TODO: move hook to separate file
|
|
1709
|
+
function useFocusState(_ref7) {
|
|
1864
1710
|
let {
|
|
1865
1711
|
headerRowIndex,
|
|
1866
1712
|
maxRowIndex,
|
|
@@ -1870,47 +1716,40 @@ function useFocusState(_ref8) {
|
|
|
1870
1716
|
pinnedUnpinnedColumnOrder,
|
|
1871
1717
|
tableRef,
|
|
1872
1718
|
currentPage
|
|
1873
|
-
} =
|
|
1719
|
+
} = _ref7;
|
|
1874
1720
|
const cellRefs = React.useRef({});
|
|
1875
1721
|
const pinnedContainersRef = React.useRef({});
|
|
1876
1722
|
const [focusedRowIndex, setFocusedRowIndex] = React.useState(headerRowIndex);
|
|
1877
1723
|
const [focusedColumnIndex, setFocusedColumnIndex] = React.useState(minColumnIndex);
|
|
1878
1724
|
const [focusedColumnId, setFocusedColumnId] = React.useState();
|
|
1879
|
-
|
|
1880
1725
|
const createRef = (rowIndex, columnIndex) => node => {
|
|
1881
1726
|
if (!cellRefs.current[rowIndex]) {
|
|
1882
1727
|
cellRefs.current[rowIndex] = {};
|
|
1883
1728
|
}
|
|
1884
|
-
|
|
1885
1729
|
cellRefs.current[rowIndex][columnIndex] = node;
|
|
1886
1730
|
};
|
|
1887
|
-
|
|
1888
1731
|
const createPinnedContainerRef = rowIndex => node => {
|
|
1889
1732
|
pinnedContainersRef.current[rowIndex] = node;
|
|
1890
1733
|
};
|
|
1891
|
-
|
|
1892
1734
|
const updateRowFocusIndex = index$1 => {
|
|
1893
1735
|
const newIndex = index.wrapAround(index$1, headerRowIndex, maxRowIndex);
|
|
1894
1736
|
setFocusedRowIndex(newIndex);
|
|
1895
1737
|
return newIndex;
|
|
1896
1738
|
};
|
|
1897
|
-
|
|
1898
1739
|
const updateColumnFocusIndex = index$1 => {
|
|
1899
1740
|
const newIndex = index.wrapAround(index$1, minColumnIndex, maxColumnIndex);
|
|
1900
1741
|
setFocusedColumnIndex(newIndex);
|
|
1901
1742
|
return newIndex;
|
|
1902
1743
|
};
|
|
1903
|
-
|
|
1904
1744
|
const focusCell = index.useEventCallback(cell => {
|
|
1905
1745
|
// Manually scroll cells/rows into view if needed
|
|
1906
1746
|
if (index.getIsKeyboardUser()) {
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
const
|
|
1910
|
-
|
|
1911
|
-
const headerPos = header === null || header === void 0 ? void 0 : header.getBoundingClientRect();
|
|
1912
|
-
let cellPos = cell === null || cell === void 0 ? void 0 : cell.getBoundingClientRect(); // Vertical scroll
|
|
1747
|
+
const tablePos = tableRef.current?.getBoundingClientRect();
|
|
1748
|
+
const header = cellRefs.current?.[headerRowIndex]?.[-1];
|
|
1749
|
+
const headerPos = header?.getBoundingClientRect();
|
|
1750
|
+
let cellPos = cell?.getBoundingClientRect();
|
|
1913
1751
|
|
|
1752
|
+
// Vertical scroll
|
|
1914
1753
|
if (cell !== header && !header.contains(cell)) {
|
|
1915
1754
|
if (cellPos.top < headerPos.top + headerPos.height) {
|
|
1916
1755
|
// Scroll down if cell covered by header
|
|
@@ -1922,15 +1761,13 @@ function useFocusState(_ref8) {
|
|
|
1922
1761
|
// Scroll up if cell out of view below table
|
|
1923
1762
|
tableRef.current.scrollTop += cellPos.bottom - tablePos.bottom;
|
|
1924
1763
|
}
|
|
1925
|
-
}
|
|
1926
|
-
// Scroll left if an entire row is focused
|
|
1927
|
-
|
|
1764
|
+
}
|
|
1928
1765
|
|
|
1766
|
+
// Horizontal scroll
|
|
1767
|
+
// Scroll left if an entire row is focused
|
|
1929
1768
|
if (minColumnIndex === -1 && focusedColumnIndex === minColumnIndex) {
|
|
1930
1769
|
tableRef.current.scrollLeft -= tablePos.left - cellPos.left;
|
|
1931
1770
|
} else {
|
|
1932
|
-
var _pinnedContainersRef$;
|
|
1933
|
-
|
|
1934
1771
|
if (cellPos.left < tablePos.left) {
|
|
1935
1772
|
// Scroll right if cell out of view to the left of the table
|
|
1936
1773
|
tableRef.current.scrollLeft -= tablePos.left - cellPos.left;
|
|
@@ -1938,39 +1775,36 @@ function useFocusState(_ref8) {
|
|
|
1938
1775
|
// Scroll left if cell out of view to the right of the table
|
|
1939
1776
|
tableRef.current.scrollLeft += cellPos.right - tablePos.right;
|
|
1940
1777
|
}
|
|
1778
|
+
const pinnedContainer = pinnedContainersRef.current?.[focusedRowIndex];
|
|
1779
|
+
const pinnedContainerPos = pinnedContainer?.getBoundingClientRect();
|
|
1780
|
+
cellPos = cell?.getBoundingClientRect();
|
|
1941
1781
|
|
|
1942
|
-
|
|
1943
|
-
const pinnedContainerPos = pinnedContainer === null || pinnedContainer === void 0 ? void 0 : pinnedContainer.getBoundingClientRect();
|
|
1944
|
-
cellPos = cell === null || cell === void 0 ? void 0 : cell.getBoundingClientRect(); // Scroll right if cell covered by pinned columns
|
|
1945
|
-
|
|
1782
|
+
// Scroll right if cell covered by pinned columns
|
|
1946
1783
|
if (pinnedContainer && cellPos.left < pinnedContainerPos.left + pinnedContainerPos.width && !pinnedContainer.contains(cell)) {
|
|
1947
1784
|
tableRef.current.scrollLeft -= pinnedContainerPos.left + pinnedContainerPos.width - cellPos.left;
|
|
1948
1785
|
}
|
|
1949
1786
|
}
|
|
1950
1787
|
}
|
|
1788
|
+
cell?.focus();
|
|
1789
|
+
});
|
|
1951
1790
|
|
|
1952
|
-
|
|
1953
|
-
}); // Focus header cell when the focused column id changes. Used when pinning/unpinning columns since a new DOM element is created.
|
|
1954
|
-
|
|
1791
|
+
// Focus header cell when the focused column id changes. Used when pinning/unpinning columns since a new DOM element is created.
|
|
1955
1792
|
index.useDidUpdate(() => {
|
|
1956
1793
|
if (focusedColumnId) {
|
|
1957
|
-
var _cellRefs$current3, _cellRefs$current3$fo;
|
|
1958
|
-
|
|
1959
1794
|
const columnIndex = pinnedUnpinnedColumnOrder.indexOf(focusedColumnId);
|
|
1960
|
-
focusCell(
|
|
1795
|
+
focusCell(cellRefs.current?.[focusedRowIndex]?.[columnIndex]);
|
|
1961
1796
|
setFocusedColumnIndex(columnIndex);
|
|
1962
1797
|
setFocusedColumnId(undefined);
|
|
1963
1798
|
}
|
|
1964
|
-
}, [focusedColumnId, pinnedUnpinnedColumnOrder]);
|
|
1799
|
+
}, [focusedColumnId, pinnedUnpinnedColumnOrder]);
|
|
1965
1800
|
|
|
1801
|
+
// Focus cell when the focused indices change
|
|
1966
1802
|
index.useDidUpdate(() => {
|
|
1967
|
-
|
|
1803
|
+
const newFocusedCell = cellRefs.current?.[focusedRowIndex]?.[focusedColumnIndex];
|
|
1968
1804
|
|
|
1969
|
-
const newFocusedCell = (_cellRefs$current4 = cellRefs.current) === null || _cellRefs$current4 === void 0 ? void 0 : (_cellRefs$current4$fo = _cellRefs$current4[focusedRowIndex]) === null || _cellRefs$current4$fo === void 0 ? void 0 : _cellRefs$current4$fo[focusedColumnIndex];
|
|
1970
1805
|
/* Prevent cells from stealing focus from their children when they
|
|
1971
1806
|
* receive focus, but still allow focus to move from a cell to a row.
|
|
1972
1807
|
*/
|
|
1973
|
-
|
|
1974
1808
|
if (!newFocusedCell.contains(document.activeElement) || hasFocusableRows && focusedColumnIndex === minColumnIndex) {
|
|
1975
1809
|
focusCell(newFocusedCell);
|
|
1976
1810
|
}
|
|
@@ -1993,9 +1827,9 @@ function useFocusState(_ref8) {
|
|
|
1993
1827
|
|
|
1994
1828
|
/* eslint-disable import/prefer-default-export */
|
|
1995
1829
|
|
|
1996
|
-
var css_248z$9 = ".
|
|
1997
|
-
var styles$9 = {"collapsibleSearchInput":"
|
|
1998
|
-
var stylesheet$9=".
|
|
1830
|
+
var css_248z$9 = "._a--Sb{display:inline-block;width:36px;transition:width .25s ease-out}._9zyFU{width:100%}._9WaFz>input{padding-right:0!important}._USWmA>svg{fill:#515559}";
|
|
1831
|
+
var styles$9 = {"collapsibleSearchInput":"_a--Sb","searchInput":"_9zyFU","searchInputCollapsed":"_9WaFz","iconButton":"_USWmA"};
|
|
1832
|
+
var stylesheet$9="._a--Sb{display:inline-block;width:36px;transition:width .25s ease-out}._9zyFU{width:100%}._9WaFz>input{padding-right:0!important}._USWmA>svg{fill:#515559}";
|
|
1999
1833
|
icons_index.styleInject(css_248z$9);
|
|
2000
1834
|
|
|
2001
1835
|
const CollapsibleSearchInputIconButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
@@ -2011,7 +1845,7 @@ const CollapsibleSearchInputIconButton = /*#__PURE__*/React.forwardRef((_ref, re
|
|
|
2011
1845
|
return /*#__PURE__*/React__default["default"].createElement(index.IconButton, _extends__default["default"]({}, rest, {
|
|
2012
1846
|
className: styles$9.iconButton,
|
|
2013
1847
|
"aria-label": label,
|
|
2014
|
-
tooltipContent: tooltipContent
|
|
1848
|
+
tooltipContent: tooltipContent ?? label,
|
|
2015
1849
|
tooltipPlacement: tooltipPlacement,
|
|
2016
1850
|
ref: ref
|
|
2017
1851
|
}), /*#__PURE__*/React__default["default"].createElement(icons_index.SearchIcon, null));
|
|
@@ -2040,81 +1874,66 @@ const CollapsibleSearchInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
2040
1874
|
'data-testid': dataTestId
|
|
2041
1875
|
} = _ref;
|
|
2042
1876
|
const [externalIsExpanded, setExternalIsExpanded] = index.useControllableState(defaultIsExpanded, onIsExpandedChange, isExpanded);
|
|
2043
|
-
const [internalExpandedState, setInternalExpandedState] = React.useState(externalIsExpanded ? expandedStates.EXPANDED : expandedStates.COLLAPSED);
|
|
1877
|
+
const [internalExpandedState, setInternalExpandedState] = React.useState(externalIsExpanded ? expandedStates.EXPANDED : expandedStates.COLLAPSED);
|
|
2044
1878
|
|
|
1879
|
+
// Set to true when either the `SearchInput` or the `IconButton` has focus
|
|
2045
1880
|
const [isComponentFocused, setIsComponentFocused] = React.useState(false);
|
|
2046
1881
|
const containerRef = React.useRef(null);
|
|
2047
1882
|
const iconButtonRef = React.useRef(null);
|
|
2048
1883
|
const searchInputRef = React.useRef(null);
|
|
2049
|
-
|
|
2050
1884
|
const handleContainerFocus = () => {
|
|
2051
1885
|
setIsComponentFocused(true);
|
|
2052
1886
|
};
|
|
2053
|
-
|
|
2054
1887
|
const handleContainerBlur = e => {
|
|
2055
1888
|
// The blur handler is triggered on the container when the focus moves between child elements, so the below check confirms that the blur is actually focus moving away from the composite component (i.e. no child has focus)
|
|
2056
1889
|
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
2057
1890
|
setIsComponentFocused(false);
|
|
2058
|
-
|
|
2059
1891
|
if (searchInputRef.current && !searchInputRef.current.value) {
|
|
2060
1892
|
setExternalIsExpanded(false);
|
|
2061
1893
|
}
|
|
2062
1894
|
}
|
|
2063
1895
|
};
|
|
2064
|
-
|
|
2065
1896
|
const handleContainerTransitionEnd = () => {
|
|
2066
1897
|
setInternalExpandedState(currentInternalExpandedState => {
|
|
2067
1898
|
switch (currentInternalExpandedState) {
|
|
2068
1899
|
case expandedStates.EXPANDING:
|
|
2069
1900
|
return expandedStates.EXPANDED;
|
|
2070
|
-
|
|
2071
1901
|
case expandedStates.COLLAPSING:
|
|
2072
1902
|
return expandedStates.COLLAPSED;
|
|
2073
|
-
|
|
2074
1903
|
default:
|
|
2075
1904
|
return currentInternalExpandedState;
|
|
2076
1905
|
}
|
|
2077
1906
|
});
|
|
2078
1907
|
};
|
|
2079
|
-
|
|
2080
1908
|
const handleIconButtonClick = () => {
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
(_iconButtonRef$curren = iconButtonRef.current) === null || _iconButtonRef$curren === void 0 ? void 0 : _iconButtonRef$curren.focus();
|
|
1909
|
+
iconButtonRef.current?.focus();
|
|
2084
1910
|
setExternalIsExpanded(true);
|
|
2085
1911
|
};
|
|
2086
|
-
|
|
2087
1912
|
index.useDidUpdate(() => {
|
|
2088
1913
|
setInternalExpandedState(currentInternalExpandedState => {
|
|
2089
1914
|
if (externalIsExpanded && currentInternalExpandedState !== expandedStates.EXPANDED) {
|
|
2090
1915
|
return expandedStates.EXPANDING;
|
|
2091
1916
|
}
|
|
2092
|
-
|
|
2093
1917
|
if (currentInternalExpandedState !== expandedStates.COLLAPSED) {
|
|
2094
1918
|
return expandedStates.COLLAPSING;
|
|
2095
1919
|
}
|
|
2096
|
-
|
|
2097
1920
|
return currentInternalExpandedState;
|
|
2098
1921
|
});
|
|
2099
1922
|
}, [externalIsExpanded]);
|
|
2100
1923
|
React.useEffect(() => {
|
|
2101
|
-
var _searchInputRef$curre, _iconButtonRef$curren2;
|
|
2102
|
-
|
|
2103
1924
|
if (isComponentFocused) {
|
|
2104
1925
|
switch (internalExpandedState) {
|
|
2105
1926
|
case expandedStates.EXPANDING:
|
|
2106
|
-
|
|
1927
|
+
searchInputRef.current?.focus();
|
|
2107
1928
|
break;
|
|
2108
|
-
|
|
2109
1929
|
case expandedStates.COLLAPSED:
|
|
2110
1930
|
/*
|
|
2111
1931
|
* Handles use-case when user clicks on search input to enter text and the component is collapsed while focus is still on the search input.
|
|
2112
1932
|
* This will show the focus ring on the icon button and allow the tooltip to appear.
|
|
2113
1933
|
*/
|
|
2114
1934
|
index.setIsKeyboardUser(true);
|
|
2115
|
-
|
|
1935
|
+
iconButtonRef.current?.focus();
|
|
2116
1936
|
break;
|
|
2117
|
-
|
|
2118
1937
|
default:
|
|
2119
1938
|
}
|
|
2120
1939
|
}
|
|
@@ -2149,9 +1968,9 @@ const CollapsibleSearchInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
2149
1968
|
}));
|
|
2150
1969
|
});
|
|
2151
1970
|
|
|
2152
|
-
var css_248z$8 = ".
|
|
2153
|
-
var styles$8 = {"input":"
|
|
2154
|
-
var stylesheet$8=".
|
|
1971
|
+
var css_248z$8 = "._ftIEg input{padding-left:76px!important}._xPSHb input{background-color:#e5e5e5!important;color:#9d9fa1!important;cursor:not-allowed!important;-webkit-text-fill-color:#9d9fa1}._xPSHb input::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._xPSHb input::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._S3MtE{position:absolute!important;left:4px;right:4px;bottom:4px;z-index:100;width:67px;height:28px!important;border-radius:4px}._S3MtE,._S3MtE._xPSHb:hover{background-color:transparent!important}._S3MtE:hover{background-color:rgba(50,54,58,.08)!important}._S3MtE:active{background-color:rgba(50,54,58,.11)!important}._S3MtE svg{top:2px!important}._zPLts{position:relative}._Lv6NS{position:absolute;top:18px;left:12px;line-height:0;font-size:14px;color:#32363a;z-index:101;pointer-events:none}";
|
|
1972
|
+
var styles$8 = {"input":"_ftIEg","disabled":"_xPSHb","dropdown":"_S3MtE","container":"_zPLts","countryCode":"_Lv6NS"};
|
|
1973
|
+
var stylesheet$8="._ftIEg input{padding-left:76px!important}._xPSHb input{background-color:#e5e5e5!important;color:#9d9fa1!important;cursor:not-allowed!important;-webkit-text-fill-color:#9d9fa1}._xPSHb input::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._xPSHb input::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._S3MtE{position:absolute!important;left:4px;right:4px;bottom:4px;z-index:100;width:67px;height:28px!important;border-radius:4px}._S3MtE,._S3MtE._xPSHb:hover{background-color:transparent!important}._S3MtE:hover{background-color:rgba(50,54,58,.08)!important}._S3MtE:active{background-color:rgba(50,54,58,.11)!important}._S3MtE svg{top:2px!important}._zPLts{position:relative}._Lv6NS{position:absolute;top:18px;left:12px;line-height:0;font-size:14px;color:#32363a;z-index:101;pointer-events:none}";
|
|
2155
1974
|
icons_index.styleInject(css_248z$8);
|
|
2156
1975
|
|
|
2157
1976
|
const PhoneNumberInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
@@ -2170,18 +1989,16 @@ const PhoneNumberInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
2170
1989
|
inputId
|
|
2171
1990
|
} = _ref;
|
|
2172
1991
|
const [countryCode, setCountryCode] = React.useState(initialCountryCode);
|
|
2173
|
-
const [mask, setMask] = React.useState();
|
|
2174
|
-
|
|
1992
|
+
const [mask, setMask] = React.useState();
|
|
1993
|
+
// As of the day of writing the longest number format is 15 numbers long. This is 5 places longer to be safe.
|
|
2175
1994
|
const genericMaxNumberLength = 20;
|
|
2176
1995
|
const {
|
|
2177
1996
|
translate
|
|
2178
1997
|
} = index.useTranslation();
|
|
2179
1998
|
const getMinMaxLength = React.useCallback(() => {
|
|
2180
|
-
var _metadata$numberingPl;
|
|
2181
|
-
|
|
2182
1999
|
const metadata = new libphonenumberJs.Metadata();
|
|
2183
2000
|
metadata.selectNumberingPlan(countryCode);
|
|
2184
|
-
const possibleLengths = metadata
|
|
2001
|
+
const possibleLengths = metadata?.numberingPlan?.possibleLengths();
|
|
2185
2002
|
return possibleLengths ? [Math.min(...possibleLengths), Math.max(...possibleLengths)] : [0, genericMaxNumberLength];
|
|
2186
2003
|
}, [countryCode]);
|
|
2187
2004
|
const shouldUseMask = Number(libphonenumberJs.getCountryCallingCode(countryCode)) === 1;
|
|
@@ -2195,33 +2012,28 @@ const PhoneNumberInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
2195
2012
|
React.useEffect(() => {
|
|
2196
2013
|
updateMask();
|
|
2197
2014
|
}, [countryCode, updateMask]);
|
|
2198
|
-
|
|
2199
|
-
const removeNonNumericCharacters = value => value === null || value === void 0 ? void 0 : value.replace(/\D/g, '');
|
|
2200
|
-
|
|
2015
|
+
const removeNonNumericCharacters = value => value?.replace(/\D/g, '');
|
|
2201
2016
|
const handleInputChange = a => {
|
|
2202
2017
|
// remove all non-numeric characters
|
|
2203
2018
|
const value = removeNonNumericCharacters(a.target.value);
|
|
2204
2019
|
let internationalNumber = null;
|
|
2205
2020
|
let isValidLength = false;
|
|
2206
|
-
|
|
2207
2021
|
if (!value) {
|
|
2208
2022
|
return;
|
|
2209
2023
|
}
|
|
2210
|
-
|
|
2211
2024
|
try {
|
|
2212
2025
|
const phoneNumber = libphonenumberJs.parsePhoneNumber(value, countryCode);
|
|
2213
2026
|
internationalNumber = phoneNumber.format('E.164');
|
|
2214
2027
|
isValidLength = phoneNumber.isPossible();
|
|
2215
|
-
} catch (e) {
|
|
2028
|
+
} catch (e) {
|
|
2029
|
+
// `parsePhoneNumber` throws an error if the inputs are invalid.
|
|
2216
2030
|
}
|
|
2217
|
-
|
|
2218
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(internationalNumber, isValidLength, countryCode, value);
|
|
2031
|
+
onChange?.(internationalNumber, isValidLength, countryCode, value);
|
|
2219
2032
|
};
|
|
2220
|
-
|
|
2221
2033
|
const inputClassNames = classNames__default["default"](styles$8.input, {
|
|
2222
2034
|
[styles$8.disabled]: isDisabled
|
|
2223
2035
|
});
|
|
2224
|
-
const dropdownLabel = React.useMemo(() => countryCode ?
|
|
2036
|
+
const dropdownLabel = React.useMemo(() => countryCode ? `+${libphonenumberJs.getCountryCallingCode(countryCode)}` : undefined, [countryCode]);
|
|
2225
2037
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2226
2038
|
className: styles$8.container,
|
|
2227
2039
|
"data-testid": dataTestId
|
|
@@ -2238,19 +2050,19 @@ const PhoneNumberInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
2238
2050
|
disabled: isDisabled,
|
|
2239
2051
|
"aria-label": buttonAriaLabel,
|
|
2240
2052
|
"aria-labelledby": buttonAriaLabelledBy
|
|
2241
|
-
}, (countryCodes
|
|
2053
|
+
}, (countryCodes ?? libphonenumberJs.getCountries()).map(individualCountryCode => {
|
|
2242
2054
|
if (!libphonenumberJs.isSupportedCountry(individualCountryCode)) {
|
|
2243
2055
|
return null;
|
|
2244
2056
|
}
|
|
2245
|
-
|
|
2246
2057
|
return /*#__PURE__*/React__default["default"].createElement(index.MenuItem, {
|
|
2247
2058
|
key: individualCountryCode,
|
|
2248
2059
|
value: individualCountryCode
|
|
2249
|
-
},
|
|
2060
|
+
}, `${translate(individualCountryCode)} +${libphonenumberJs.getCountryCallingCode(individualCountryCode)}`);
|
|
2250
2061
|
})), /*#__PURE__*/React__default["default"].createElement(InputMask__default["default"], {
|
|
2251
2062
|
value: isDisabled ? removeNonNumericCharacters(initialValue) : undefined,
|
|
2252
2063
|
type: "tel",
|
|
2253
|
-
alwaysShowMask: true
|
|
2064
|
+
alwaysShowMask: true
|
|
2065
|
+
// hide formatting if not using mask
|
|
2254
2066
|
,
|
|
2255
2067
|
maskChar: shouldUseMask ? '_' : '',
|
|
2256
2068
|
mask: mask,
|
|
@@ -2280,62 +2092,59 @@ const {
|
|
|
2280
2092
|
function insertOption(option, options) {
|
|
2281
2093
|
for (let i = 0; i < options.length; i += 1) {
|
|
2282
2094
|
const currentNode = options[i];
|
|
2283
|
-
|
|
2284
|
-
|
|
2095
|
+
if (
|
|
2096
|
+
// eslint-disable-next-line no-bitwise
|
|
2285
2097
|
currentNode.compareDocumentPosition(option) & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
2286
2098
|
options.splice(i, 0, option);
|
|
2287
2099
|
return;
|
|
2288
2100
|
}
|
|
2289
2101
|
}
|
|
2290
|
-
|
|
2291
2102
|
options.push(option);
|
|
2292
2103
|
}
|
|
2104
|
+
|
|
2293
2105
|
/**
|
|
2294
2106
|
* Deletes the `ComboboxOption` element from the options array.
|
|
2295
2107
|
* @param option - The `ComboboxOption` element to delete.
|
|
2296
2108
|
* @param options - The list of registered `ComboboxOption`s.
|
|
2297
2109
|
* @param hookFunctionName - The name of the hook function that is calling this function. Used for any error logs.
|
|
2298
2110
|
*/
|
|
2299
|
-
|
|
2300
2111
|
function deleteOption(option, options, hookFunctionName) {
|
|
2301
2112
|
const indexOfNodeToDelete = options.findIndex(n => n === option);
|
|
2302
|
-
|
|
2303
2113
|
if (indexOfNodeToDelete === -1) {
|
|
2304
2114
|
// eslint-disable-next-line no-console
|
|
2305
|
-
console.error(
|
|
2115
|
+
console.error(`[${hookFunctionName}] Attempt to delete node failed. This node does not exist in the list of registered nodes.`);
|
|
2306
2116
|
} else {
|
|
2307
2117
|
options.splice(indexOfNodeToDelete, 1);
|
|
2308
2118
|
}
|
|
2309
2119
|
}
|
|
2310
2120
|
|
|
2311
2121
|
/* eslint-disable consistent-return */
|
|
2122
|
+
|
|
2312
2123
|
/**
|
|
2313
2124
|
* Used to keep track of registered combobox options inside of a combobox group. Registered combobox options should be those that are part of the filtered list based on the input value.
|
|
2314
2125
|
* @returns An object containing the list of filtered options inside of the group and functions for registering/deregistering a combobox option.
|
|
2315
2126
|
*/
|
|
2316
|
-
|
|
2317
2127
|
function useComboboxFilteredGroup() {
|
|
2318
2128
|
const filteredOptionsRef = React.useRef([]);
|
|
2129
|
+
|
|
2319
2130
|
/**
|
|
2320
2131
|
* Registers the element as an option in the filtered list.
|
|
2321
2132
|
* @param option - The element to register.
|
|
2322
2133
|
*/
|
|
2323
|
-
|
|
2324
2134
|
const registerOption = React.useCallback(option => {
|
|
2325
2135
|
// NOTE: This function and its dependencies *must* not change during re-renders because it will cause ComboboxOptions to deregister and reregister, thus causing unexpected behavior
|
|
2326
2136
|
if (!option) {
|
|
2327
2137
|
// eslint-disable-next-line no-console
|
|
2328
|
-
console.warn(
|
|
2138
|
+
console.warn(`[${useComboboxFilteredGroup.name}] registerOption called without any parameters! Pass in "option" as parameter.`);
|
|
2329
2139
|
return;
|
|
2330
2140
|
}
|
|
2331
|
-
|
|
2332
2141
|
insertOption(option, filteredOptionsRef.current);
|
|
2333
2142
|
}, []);
|
|
2143
|
+
|
|
2334
2144
|
/**
|
|
2335
2145
|
* Deregisters the option, which means that the option is no longer in the filtered list.
|
|
2336
2146
|
* @param option - The element to deregister.
|
|
2337
2147
|
*/
|
|
2338
|
-
|
|
2339
2148
|
const deregisterOption = React.useCallback(option => {
|
|
2340
2149
|
// NOTE: This function and its dependencies *must* not change during re-renders because it will cause ComboboxOptions to deregister and reregister, thus causing unexpected behavior
|
|
2341
2150
|
deleteOption(option, filteredOptionsRef.current, useComboboxFilteredGroup.name);
|
|
@@ -2348,6 +2157,7 @@ function useComboboxFilteredGroup() {
|
|
|
2348
2157
|
}
|
|
2349
2158
|
|
|
2350
2159
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
2160
|
+
|
|
2351
2161
|
/**
|
|
2352
2162
|
* A list of utilities to manage focus inside of a combobox. The input element is included in the focus loop.
|
|
2353
2163
|
* @param isOpen - Inidicates if the flyout is open.
|
|
@@ -2358,55 +2168,51 @@ function useComboboxFilteredGroup() {
|
|
|
2358
2168
|
* @param isDisabled - Indicates if the input is disabled.
|
|
2359
2169
|
* @returns - A group of utils to register/deregister options in the flyout, handle focus management, and access the filtered options and current active descendant element.
|
|
2360
2170
|
*/
|
|
2361
|
-
|
|
2362
|
-
|
|
2171
|
+
function useComboboxFocusSequence(isOpen, setIsOpen, inputRef, isLoading, committedInputValue,
|
|
2172
|
+
// Don't use this parameter internally. Instead, use the internal `didCommittedInputValueChange` state
|
|
2363
2173
|
isDisabled) {
|
|
2364
2174
|
const [activeDescendant, setActiveDescendant] = React.useState(); // In a future version of `Combobox`, if we continue not to allow custom children inside of `ComboboxOption`s, we can remove `aria-activedescendant` and instead just let the screen reader read the new input value (e.g. see Google search box)
|
|
2365
2175
|
|
|
2366
2176
|
const activeDescendantRef = index.useLatest(activeDescendant); // Used to prevent returned `useCallback` functions from being re-created
|
|
2367
|
-
|
|
2368
2177
|
const latestFocusFunctionNameRef = React.useRef(); // Used to call the correct focus function after the flyout opens (if the flyout is currently closed)
|
|
2369
|
-
|
|
2370
2178
|
const filteredOptionsRef = React.useRef([]); // The list of `ComboboxOption`s that match the filter based on the input value
|
|
2371
2179
|
|
|
2372
2180
|
const [didCommittedInputValueChange, setDidCommittedInputValueChange] = React.useState(false);
|
|
2181
|
+
|
|
2373
2182
|
/*
|
|
2374
2183
|
* Triggers a re-render so that we can get the list of filtered options.
|
|
2375
2184
|
* The re-render is necessary because we need the `ComboboxOption`s to render and register themselves before running any logic on the list of filtered options.
|
|
2376
2185
|
*/
|
|
2377
|
-
|
|
2378
2186
|
React.useEffect(() => {
|
|
2379
2187
|
setDidCommittedInputValueChange(true);
|
|
2380
2188
|
}, [committedInputValue // Use of this variable is allowed here because it triggers the necessary re-render
|
|
2381
2189
|
]);
|
|
2190
|
+
|
|
2382
2191
|
/**
|
|
2383
2192
|
* Opens the flyout, which will cause an effect to call the original focus function again to focus the correct `ComboboxOption`.
|
|
2384
2193
|
* @param focusFunctionName - The name of the function that called this function (i.e. `myFunction.name`). Make sure that the function has the `name` property set on it.
|
|
2385
2194
|
*/
|
|
2386
|
-
|
|
2387
2195
|
const openFlyoutAndFocus = React.useCallback(focusFunctionName => {
|
|
2388
2196
|
latestFocusFunctionNameRef.current = focusFunctionName;
|
|
2389
2197
|
setIsOpen(true);
|
|
2390
2198
|
}, [setIsOpen]);
|
|
2199
|
+
|
|
2391
2200
|
/**
|
|
2392
2201
|
* Points `aria-activedescendant` to the passed in element and updates the `activeDescendantElement` state.
|
|
2393
2202
|
* @param descendantElement - The element to be marked as the active descendant element.
|
|
2394
2203
|
*/
|
|
2395
|
-
|
|
2396
2204
|
const focusDescendant = React.useCallback((descendantElement, index) => {
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.setAttribute('aria-activedescendant', descendantElement.id);
|
|
2205
|
+
inputRef.current?.setAttribute('aria-activedescendant', descendantElement.id);
|
|
2400
2206
|
setActiveDescendant({
|
|
2401
2207
|
element: descendantElement,
|
|
2402
2208
|
index
|
|
2403
2209
|
});
|
|
2404
2210
|
}, [inputRef]);
|
|
2211
|
+
|
|
2405
2212
|
/**
|
|
2406
2213
|
* Moves screen reader focus back to the input.
|
|
2407
2214
|
* This does not call `focus()` on the input because the input will always have DOM focus when the combobox is being used.
|
|
2408
2215
|
*/
|
|
2409
|
-
|
|
2410
2216
|
const focusInput = React.useCallback(() => {
|
|
2411
2217
|
/*
|
|
2412
2218
|
* This check is necessary because it's expected that this function will sometimes be called when `inputRef.current` is `null`.
|
|
@@ -2418,48 +2224,44 @@ isDisabled) {
|
|
|
2418
2224
|
setActiveDescendant(undefined);
|
|
2419
2225
|
}
|
|
2420
2226
|
}, [inputRef]);
|
|
2227
|
+
|
|
2421
2228
|
/**
|
|
2422
2229
|
* Registers the `ComboboxOption` element as an option in the filtered list.
|
|
2423
2230
|
* @param option - The element to register.
|
|
2424
2231
|
*/
|
|
2425
|
-
|
|
2426
2232
|
const registerOption = React.useCallback(option => {
|
|
2427
2233
|
// NOTE: This function and its dependencies *must* not change during re-renders because it will cause ComboboxOptions to deregister and reregister, thus causing unexpected behavior
|
|
2428
2234
|
if (!option) {
|
|
2429
2235
|
// eslint-disable-next-line no-console
|
|
2430
|
-
console.error(
|
|
2236
|
+
console.error(`[${useComboboxFocusSequence.name}] registerOption called without any parameters! Pass in a 'ComboboxOption' via the "option" parameter.`);
|
|
2431
2237
|
} else {
|
|
2432
2238
|
insertOption(option, filteredOptionsRef.current);
|
|
2433
2239
|
}
|
|
2434
2240
|
}, []);
|
|
2241
|
+
|
|
2435
2242
|
/**
|
|
2436
2243
|
* Deregisters the `ComboboxOption` element, which means that the option is no longer in the filtered list.
|
|
2437
2244
|
* @param option - The element to deregister.
|
|
2438
2245
|
*/
|
|
2439
|
-
|
|
2440
2246
|
const deregisterOption = React.useCallback(option => {
|
|
2441
2247
|
// NOTE: This function and its dependencies *must* not change during re-renders because it will cause ComboboxOptions to deregister and reregister, thus causing unexpected behavior
|
|
2442
2248
|
if (!option) {
|
|
2443
2249
|
// eslint-disable-next-line no-console
|
|
2444
|
-
console.error(
|
|
2250
|
+
console.error(`[${useComboboxFocusSequence.name}] deregisterOption called without any parameters! Pass in a 'ComboboxOption' via the "option" parameter.`);
|
|
2445
2251
|
} else {
|
|
2446
|
-
var _activeDescendantRef$;
|
|
2447
|
-
|
|
2448
2252
|
deleteOption(option, filteredOptionsRef.current, useComboboxFocusSequence.name);
|
|
2449
|
-
|
|
2450
|
-
if (option === ((_activeDescendantRef$ = activeDescendantRef.current) === null || _activeDescendantRef$ === void 0 ? void 0 : _activeDescendantRef$.element)) {
|
|
2253
|
+
if (option === activeDescendantRef.current?.element) {
|
|
2451
2254
|
setActiveDescendant(undefined);
|
|
2452
2255
|
}
|
|
2453
|
-
|
|
2454
2256
|
if (filteredOptionsRef.current.length === 0) {
|
|
2455
2257
|
focusInput();
|
|
2456
2258
|
}
|
|
2457
2259
|
}
|
|
2458
2260
|
}, [activeDescendantRef, focusInput]);
|
|
2261
|
+
|
|
2459
2262
|
/**
|
|
2460
2263
|
* Focuses the first option in the `ComboboxFlyout`.
|
|
2461
2264
|
*/
|
|
2462
|
-
|
|
2463
2265
|
const focusFirst = React.useCallback(function focusFirst() {
|
|
2464
2266
|
if (!isOpen) {
|
|
2465
2267
|
openFlyoutAndFocus(focusFirst.name);
|
|
@@ -2469,10 +2271,10 @@ isDisabled) {
|
|
|
2469
2271
|
logNoOptionsToFocusError(focusFirst.name);
|
|
2470
2272
|
}
|
|
2471
2273
|
}, [isOpen, openFlyoutAndFocus, focusDescendant]);
|
|
2274
|
+
|
|
2472
2275
|
/**
|
|
2473
2276
|
* Focuses the last option in the `ComboboxFlyout`.
|
|
2474
2277
|
*/
|
|
2475
|
-
|
|
2476
2278
|
const focusLast = React.useCallback(function focusLast() {
|
|
2477
2279
|
if (!isOpen) {
|
|
2478
2280
|
openFlyoutAndFocus(focusLast.name);
|
|
@@ -2482,18 +2284,15 @@ isDisabled) {
|
|
|
2482
2284
|
logNoOptionsToFocusError(focusLast.name);
|
|
2483
2285
|
}
|
|
2484
2286
|
}, [isOpen, openFlyoutAndFocus, focusDescendant]);
|
|
2287
|
+
|
|
2485
2288
|
/**
|
|
2486
2289
|
* Focuses the next option in the `ComboboxFlyout`. If the last option in the `ComboboxFlyout` is currently focused, the input will be focused.
|
|
2487
2290
|
*/
|
|
2488
|
-
|
|
2489
2291
|
const focusNext = React.useCallback(function focusNext() {
|
|
2490
2292
|
if (!isOpen) {
|
|
2491
2293
|
openFlyoutAndFocus(focusNext.name);
|
|
2492
2294
|
} else {
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
const currentFocusedNodeIndex = (_activeDescendantRef$2 = activeDescendantRef.current) === null || _activeDescendantRef$2 === void 0 ? void 0 : _activeDescendantRef$2.index;
|
|
2496
|
-
|
|
2295
|
+
const currentFocusedNodeIndex = activeDescendantRef.current?.index;
|
|
2497
2296
|
if (currentFocusedNodeIndex === filteredOptionsRef.current.length - 1) {
|
|
2498
2297
|
focusInput();
|
|
2499
2298
|
} else if (currentFocusedNodeIndex === undefined) {
|
|
@@ -2506,18 +2305,15 @@ isDisabled) {
|
|
|
2506
2305
|
}
|
|
2507
2306
|
}
|
|
2508
2307
|
}, [isOpen, openFlyoutAndFocus, activeDescendantRef, focusInput, focusFirst, focusDescendant]);
|
|
2308
|
+
|
|
2509
2309
|
/**
|
|
2510
2310
|
* Focuses the previous option in the list. If the first option in the list is currently focused, the input will be focused.
|
|
2511
2311
|
*/
|
|
2512
|
-
|
|
2513
2312
|
const focusPrevious = React.useCallback(function focusPrevious() {
|
|
2514
2313
|
if (!isOpen) {
|
|
2515
2314
|
openFlyoutAndFocus(focusPrevious.name);
|
|
2516
2315
|
} else {
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
const currentFocusedNodeIndex = (_activeDescendantRef$3 = activeDescendantRef.current) === null || _activeDescendantRef$3 === void 0 ? void 0 : _activeDescendantRef$3.index;
|
|
2520
|
-
|
|
2316
|
+
const currentFocusedNodeIndex = activeDescendantRef.current?.index;
|
|
2521
2317
|
if (currentFocusedNodeIndex === 0) {
|
|
2522
2318
|
focusInput();
|
|
2523
2319
|
} else if (currentFocusedNodeIndex === undefined) {
|
|
@@ -2529,67 +2325,68 @@ isDisabled) {
|
|
|
2529
2325
|
logNoOptionsToFocusError(focusPrevious.name);
|
|
2530
2326
|
}
|
|
2531
2327
|
}
|
|
2532
|
-
}, [isOpen, openFlyoutAndFocus, activeDescendantRef, focusInput, focusLast, focusDescendant]);
|
|
2328
|
+
}, [isOpen, openFlyoutAndFocus, activeDescendantRef, focusInput, focusLast, focusDescendant]);
|
|
2533
2329
|
|
|
2330
|
+
// If the flyout is currently open and there are no filtered options, the flyout is closed
|
|
2534
2331
|
React.useEffect(() => {
|
|
2535
2332
|
if (isOpen && filteredOptionsRef.current.length === 0) {
|
|
2536
2333
|
setIsOpen(false);
|
|
2537
2334
|
}
|
|
2538
|
-
}, [isOpen, setIsOpen]);
|
|
2335
|
+
}, [isOpen, setIsOpen]);
|
|
2539
2336
|
|
|
2337
|
+
// If the flyout was opened in order to focus an option, and filtered options exist, calls the proper focus function
|
|
2540
2338
|
React.useEffect(() => {
|
|
2541
2339
|
if (isOpen && filteredOptionsRef.current.length > 0) {
|
|
2542
2340
|
switch (latestFocusFunctionNameRef.current) {
|
|
2543
2341
|
case focusFirst.name:
|
|
2544
2342
|
focusFirst();
|
|
2545
2343
|
break;
|
|
2546
|
-
|
|
2547
2344
|
case focusLast.name:
|
|
2548
2345
|
focusLast();
|
|
2549
2346
|
break;
|
|
2550
|
-
|
|
2551
2347
|
case focusPrevious.name:
|
|
2552
2348
|
focusPrevious();
|
|
2553
2349
|
break;
|
|
2554
|
-
|
|
2555
2350
|
case focusNext.name:
|
|
2556
2351
|
focusNext();
|
|
2557
2352
|
break;
|
|
2558
|
-
|
|
2559
2353
|
default:
|
|
2560
2354
|
}
|
|
2561
2355
|
}
|
|
2562
|
-
|
|
2563
2356
|
latestFocusFunctionNameRef.current = undefined;
|
|
2564
|
-
}, [isOpen, focusFirst, focusLast, focusPrevious, focusNext]);
|
|
2357
|
+
}, [isOpen, focusFirst, focusLast, focusPrevious, focusNext]);
|
|
2565
2358
|
|
|
2359
|
+
// If the committed input value changes and there are no filtered options, the flyout is closed
|
|
2566
2360
|
React.useEffect(() => {
|
|
2567
2361
|
if (filteredOptionsRef.current.length === 0) {
|
|
2568
2362
|
setIsOpen(false);
|
|
2569
2363
|
}
|
|
2570
|
-
|
|
2571
2364
|
setDidCommittedInputValueChange(false); // Since the committed input value change was caught in this effect, the state needs to be reset to `false`
|
|
2572
2365
|
}, [setIsOpen, didCommittedInputValueChange // This dependency is needed in order to listen for a change to the committed input value
|
|
2573
|
-
]);
|
|
2366
|
+
]);
|
|
2574
2367
|
|
|
2368
|
+
// If options are loaded and there are no filtered options, the flyout is closed
|
|
2575
2369
|
React.useEffect(() => {
|
|
2576
2370
|
if (!isLoading && filteredOptionsRef.current.length === 0) {
|
|
2577
2371
|
setIsOpen(false);
|
|
2578
2372
|
}
|
|
2579
|
-
}, [isLoading, setIsOpen]);
|
|
2373
|
+
}, [isLoading, setIsOpen]);
|
|
2580
2374
|
|
|
2375
|
+
// Focuses the input when new options are loaded
|
|
2581
2376
|
React.useEffect(() => {
|
|
2582
2377
|
if (!isLoading) {
|
|
2583
2378
|
focusInput();
|
|
2584
2379
|
}
|
|
2585
|
-
}, [isLoading, focusInput]);
|
|
2380
|
+
}, [isLoading, focusInput]);
|
|
2586
2381
|
|
|
2382
|
+
// Focuses the input when the flyout closes
|
|
2587
2383
|
React.useEffect(() => {
|
|
2588
2384
|
if (!isOpen) {
|
|
2589
2385
|
focusInput();
|
|
2590
2386
|
}
|
|
2591
|
-
}, [isOpen, focusInput]);
|
|
2387
|
+
}, [isOpen, focusInput]);
|
|
2592
2388
|
|
|
2389
|
+
// Closes the flyout when the input becomes disabled
|
|
2593
2390
|
React.useEffect(() => {
|
|
2594
2391
|
if (isDisabled) {
|
|
2595
2392
|
setIsOpen(false);
|
|
@@ -2603,47 +2400,43 @@ isDisabled) {
|
|
|
2603
2400
|
focusLast,
|
|
2604
2401
|
focusNext,
|
|
2605
2402
|
focusPrevious,
|
|
2606
|
-
activeDescendantElement: activeDescendant
|
|
2403
|
+
activeDescendantElement: activeDescendant?.element,
|
|
2607
2404
|
filteredOptionsRef
|
|
2608
2405
|
};
|
|
2609
2406
|
}
|
|
2610
|
-
|
|
2611
2407
|
function logNoOptionsToFocusError(functionName) {
|
|
2612
2408
|
// eslint-disable-next-line no-console
|
|
2613
|
-
console.error(
|
|
2409
|
+
console.error(`[${useComboboxFocusSequence.name}] Invalid call to '${functionName}'. There are no registered nodes to focus.`);
|
|
2614
2410
|
}
|
|
2411
|
+
|
|
2615
2412
|
/**
|
|
2616
2413
|
* Gets the index of the next `ComboboxOption` in the filtered options list.
|
|
2617
2414
|
* @param currentIndex - The index of the currently selected `ComboboxOption`.
|
|
2618
2415
|
* @param numFilteredOptions - The number of filtered options in the list.
|
|
2619
2416
|
* @returns The index of the next `ComboboxOption` in the filtered options list (wraps to create looping focus).
|
|
2620
2417
|
*/
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
2418
|
function getNextIndex(currentIndex, numFilteredOptions) {
|
|
2624
2419
|
if (currentIndex === undefined || currentIndex === -1) {
|
|
2625
2420
|
return -1;
|
|
2626
2421
|
}
|
|
2627
|
-
|
|
2628
2422
|
return (currentIndex + 1) % numFilteredOptions;
|
|
2629
2423
|
}
|
|
2424
|
+
|
|
2630
2425
|
/**
|
|
2631
2426
|
* Gets the index of the previous `ComboboxOption` in the filtered options list.
|
|
2632
2427
|
* @param currentIndex - The index of the currently selected `ComboboxOption`.
|
|
2633
2428
|
* @param numFilteredOptions - The number of filtered options in the list.
|
|
2634
2429
|
* @returns The index of the previous `ComboboxOption` in the filtered options list (wraps to create looping focus).
|
|
2635
2430
|
*/
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
2431
|
function getPreviousIndex(currentIndex, numFilteredOptions) {
|
|
2639
2432
|
if (currentIndex === undefined || currentIndex === -1) {
|
|
2640
2433
|
return -1;
|
|
2641
2434
|
}
|
|
2642
|
-
|
|
2643
2435
|
return (currentIndex + numFilteredOptions - 1) % numFilteredOptions;
|
|
2644
2436
|
}
|
|
2645
2437
|
|
|
2646
2438
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2439
|
+
|
|
2647
2440
|
/**
|
|
2648
2441
|
* Updates the committed input value and makes a screen reader announcement when new options are loaded.
|
|
2649
2442
|
* @param isLoading - Indicates if new options are being loaded.
|
|
@@ -2652,21 +2445,19 @@ function getPreviousIndex(currentIndex, numFilteredOptions) {
|
|
|
2652
2445
|
* @param rawInputValue - The raw input value.
|
|
2653
2446
|
* @param setCommittedInputValue - A function that updates the committed input value.
|
|
2654
2447
|
*/
|
|
2655
|
-
|
|
2656
2448
|
function useComboboxLoadingState(isLoading, isComponentFocused, activeDescendantElement, rawInputValue, setCommittedInputValue) {
|
|
2657
2449
|
const previousIsLoadingRef = index.useLatest(index.usePrevious(isLoading)); // The value of `isLoading` during the previous call to this hook
|
|
2658
|
-
|
|
2659
2450
|
const newOptionsLoadingTimeoutIdRef = React.useRef();
|
|
2660
2451
|
const didNewOptionsLoadingAnnouncementOccurRef = React.useRef(false);
|
|
2661
2452
|
const announceToScreenReader = index.useScreenReaderAnnouncement('polite');
|
|
2662
2453
|
const {
|
|
2663
2454
|
translate
|
|
2664
2455
|
} = index.useTranslation();
|
|
2456
|
+
|
|
2665
2457
|
/* If the user is navigating through options in the flyout when new options are loaded or if a new options loading announcement was made during the current loading cycle:
|
|
2666
2458
|
* 1. Sends a message to the screen reader
|
|
2667
2459
|
* 2. Commits the currently selected value
|
|
2668
2460
|
*/
|
|
2669
|
-
|
|
2670
2461
|
React.useEffect(() => {
|
|
2671
2462
|
if (previousIsLoadingRef.current && !isLoading && isComponentFocused && (activeDescendantElement || didNewOptionsLoadingAnnouncementOccurRef.current)) {
|
|
2672
2463
|
// @ts-ignore - 'newOptionsLoaded' is not in the current list of translations
|
|
@@ -2674,8 +2465,9 @@ function useComboboxLoadingState(isLoading, isComponentFocused, activeDescendant
|
|
|
2674
2465
|
setCommittedInputValue(rawInputValue);
|
|
2675
2466
|
didNewOptionsLoadingAnnouncementOccurRef.current = false;
|
|
2676
2467
|
}
|
|
2677
|
-
}, [previousIsLoadingRef, isLoading, activeDescendantElement, isComponentFocused, announceToScreenReader, translate, setCommittedInputValue, rawInputValue]);
|
|
2468
|
+
}, [previousIsLoadingRef, isLoading, activeDescendantElement, isComponentFocused, announceToScreenReader, translate, setCommittedInputValue, rawInputValue]);
|
|
2678
2469
|
|
|
2470
|
+
// If new options are taking a while to load, make a screen reader announcement that new options are loading
|
|
2679
2471
|
React.useEffect(() => {
|
|
2680
2472
|
if (isLoading && isComponentFocused) {
|
|
2681
2473
|
newOptionsLoadingTimeoutIdRef.current = window.setTimeout(() => {
|
|
@@ -2684,7 +2476,6 @@ function useComboboxLoadingState(isLoading, isComponentFocused, activeDescendant
|
|
|
2684
2476
|
didNewOptionsLoadingAnnouncementOccurRef.current = true;
|
|
2685
2477
|
}, 3000);
|
|
2686
2478
|
}
|
|
2687
|
-
|
|
2688
2479
|
return () => {
|
|
2689
2480
|
clearTimeout(newOptionsLoadingTimeoutIdRef.current);
|
|
2690
2481
|
};
|
|
@@ -2692,6 +2483,7 @@ function useComboboxLoadingState(isLoading, isComponentFocused, activeDescendant
|
|
|
2692
2483
|
}
|
|
2693
2484
|
|
|
2694
2485
|
/* eslint-disable camelcase */
|
|
2486
|
+
|
|
2695
2487
|
/**
|
|
2696
2488
|
* Creates state for the different types of combobox values to keep track of.
|
|
2697
2489
|
* @param initialInputValue - The initial value of the input.
|
|
@@ -2699,14 +2491,15 @@ function useComboboxLoadingState(isLoading, isComponentFocused, activeDescendant
|
|
|
2699
2491
|
* @param externalOnChange - The function to be called when the input value changes.
|
|
2700
2492
|
* @returns - Utils that handle both types of input values: the raw value and the committed value.
|
|
2701
2493
|
*/
|
|
2702
|
-
|
|
2703
2494
|
function useComboboxValue(initialInputValue, externalInputValue, externalOnChange) {
|
|
2704
2495
|
// This is the `value` of the `input` element (what is displayed to the user)
|
|
2705
|
-
const [rawInputValue, setRawInputValue] = React.useState(externalInputValue
|
|
2496
|
+
const [rawInputValue, setRawInputValue] = React.useState(externalInputValue ?? initialInputValue);
|
|
2706
2497
|
|
|
2498
|
+
// The `value` of the `input` element will become this value by the time the `input` element is blurred
|
|
2707
2499
|
const [committedInputValue, setCommittedInputValue_DO_NOT_USE // A setter is created below so that the raw input value is also updated
|
|
2708
|
-
] = index.useControllableState(initialInputValue, externalOnChange, externalInputValue);
|
|
2500
|
+
] = index.useControllableState(initialInputValue, externalOnChange, externalInputValue);
|
|
2709
2501
|
|
|
2502
|
+
// Use of `setCommittedInputValue_DO_NOT_USE` is okay here because this function is used as the actual state updater
|
|
2710
2503
|
const setCommittedInputValue = React.useCallback(newValue => {
|
|
2711
2504
|
setCommittedInputValue_DO_NOT_USE(newValue);
|
|
2712
2505
|
setRawInputValue(newValue);
|
|
@@ -2724,30 +2517,28 @@ function getFlyoutDimensions(anchorDimensions) {
|
|
|
2724
2517
|
// TODO: If this hook becomes a reusable hook, an `isFocused` parameter should be added to determine if the focus ring width width should be added
|
|
2725
2518
|
// Adds the focus ring width to account for the box-shadow focus ring on each side of the anchor
|
|
2726
2519
|
minWidth: anchorDimensions.width + index.FOCUS_RING_WIDTH * 2,
|
|
2727
|
-
maxHeight: Math.min(350,
|
|
2520
|
+
maxHeight: Math.min(350,
|
|
2521
|
+
// Half of window height - flyout popper offset - half of anchor height
|
|
2728
2522
|
document.documentElement.clientHeight / 2 - index.FLYOUT_POPPER_OFFSET[1] - anchorDimensions.height / 2)
|
|
2729
2523
|
};
|
|
2730
2524
|
}
|
|
2525
|
+
|
|
2731
2526
|
/**
|
|
2732
2527
|
* Computes the sizing of a listbox flyout based on the size of the anchor element and the document.
|
|
2733
2528
|
* @param anchorElement The element acting as the anchor for the flyout.
|
|
2734
2529
|
* @returns A CSS style object containing styles to properly size the flyout.
|
|
2735
2530
|
*/
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
2531
|
function useListboxFlyoutDimensions(anchorElement) {
|
|
2739
|
-
var _anchorElement$offset, _anchorElement$offset2;
|
|
2740
|
-
|
|
2741
2532
|
const [anchorDimensions, setAnchorDimensions] = React.useState({
|
|
2742
|
-
width:
|
|
2743
|
-
height:
|
|
2533
|
+
width: anchorElement?.offsetWidth ?? 0,
|
|
2534
|
+
height: anchorElement?.offsetHeight ?? 18
|
|
2744
2535
|
});
|
|
2745
2536
|
const [flyoutDimensions, setFlyoutDimensions] = React.useState(getFlyoutDimensions(anchorDimensions));
|
|
2537
|
+
|
|
2746
2538
|
/*
|
|
2747
2539
|
* The element being passed in to this hook could be coming from a ref which may be null at first.
|
|
2748
2540
|
* This effect updates the anchor dimensions state whenever the anchor element changes.
|
|
2749
2541
|
*/
|
|
2750
|
-
|
|
2751
2542
|
React.useEffect(() => {
|
|
2752
2543
|
if (anchorElement) {
|
|
2753
2544
|
setAnchorDimensions({
|
|
@@ -2755,12 +2546,14 @@ function useListboxFlyoutDimensions(anchorElement) {
|
|
|
2755
2546
|
height: anchorElement.offsetHeight
|
|
2756
2547
|
});
|
|
2757
2548
|
}
|
|
2758
|
-
}, [anchorElement]);
|
|
2549
|
+
}, [anchorElement]);
|
|
2759
2550
|
|
|
2551
|
+
// Updates flyout dimensions when the anchor dimensions change
|
|
2760
2552
|
React.useEffect(() => {
|
|
2761
2553
|
setFlyoutDimensions(getFlyoutDimensions(anchorDimensions));
|
|
2762
|
-
}, [anchorDimensions]);
|
|
2554
|
+
}, [anchorDimensions]);
|
|
2763
2555
|
|
|
2556
|
+
// Updates flyout dimensions when the the window is resized
|
|
2764
2557
|
index.useEventListener(window, 'resize', () => setFlyoutDimensions(getFlyoutDimensions(anchorDimensions)));
|
|
2765
2558
|
return flyoutDimensions;
|
|
2766
2559
|
}
|
|
@@ -2772,22 +2565,17 @@ function useListboxFlyoutDimensions(anchorElement) {
|
|
|
2772
2565
|
* @param optionsRef - Options in the flyout.
|
|
2773
2566
|
* @param flyoutRef - The flyout container.
|
|
2774
2567
|
*/
|
|
2775
|
-
|
|
2776
2568
|
function useSelectedOptionScroll(isOpen, activeDescendantElement, optionsRef, flyoutRef) {
|
|
2777
2569
|
// Scrolls to the selected option if the selected option is out of view
|
|
2778
2570
|
React.useEffect(() => {
|
|
2779
2571
|
if (isOpen && activeDescendantElement && flyoutRef.current) {
|
|
2780
|
-
var _optionsRef$current;
|
|
2781
|
-
|
|
2782
2572
|
const flyoutContainerElement = flyoutRef.current;
|
|
2783
|
-
|
|
2784
|
-
if (activeDescendantElement === ((_optionsRef$current = optionsRef.current) === null || _optionsRef$current === void 0 ? void 0 : _optionsRef$current[0])) {
|
|
2573
|
+
if (activeDescendantElement === optionsRef.current?.[0]) {
|
|
2785
2574
|
// Scrolls the first header into view if one exists
|
|
2786
2575
|
flyoutContainerElement.scrollTop = 0;
|
|
2787
2576
|
} else if (flyoutContainerElement.scrollHeight > flyoutContainerElement.clientHeight) {
|
|
2788
2577
|
const scrollBottom = flyoutContainerElement.clientHeight + flyoutContainerElement.scrollTop;
|
|
2789
2578
|
const elementBottom = activeDescendantElement.offsetTop + activeDescendantElement.offsetHeight;
|
|
2790
|
-
|
|
2791
2579
|
if (elementBottom > scrollBottom) {
|
|
2792
2580
|
flyoutContainerElement.scrollTop = elementBottom - flyoutContainerElement.clientHeight;
|
|
2793
2581
|
} else if (activeDescendantElement.offsetTop < flyoutContainerElement.scrollTop) {
|
|
@@ -2804,21 +2592,21 @@ function useSelectedOptionScroll(isOpen, activeDescendantElement, optionsRef, fl
|
|
|
2804
2592
|
* @param committedInputValue - The committed value of the input.
|
|
2805
2593
|
* @returns A boolean indicating if the group includes at least one filtered option. If there are no filtered options, the group header should not be rendered.
|
|
2806
2594
|
*/
|
|
2807
|
-
|
|
2808
2595
|
function useShouldRenderGroupHeader(filteredOptionsRef, committedInputValue) {
|
|
2809
|
-
const [shouldRenderHeader, setShouldRenderHeader] = React.useState(true);
|
|
2596
|
+
const [shouldRenderHeader, setShouldRenderHeader] = React.useState(true);
|
|
2810
2597
|
|
|
2598
|
+
// Should render the header if the group includes at least one filtered option
|
|
2811
2599
|
React.useEffect(() => {
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
if (((_filteredOptionsRef$c = filteredOptionsRef.current) === null || _filteredOptionsRef$c === void 0 ? void 0 : _filteredOptionsRef$c.length) === 0) {
|
|
2600
|
+
if (filteredOptionsRef.current?.length === 0) {
|
|
2815
2601
|
setShouldRenderHeader(false);
|
|
2816
2602
|
} else {
|
|
2817
2603
|
setShouldRenderHeader(true);
|
|
2818
2604
|
}
|
|
2819
|
-
}, [filteredOptionsRef,
|
|
2605
|
+
}, [filteredOptionsRef,
|
|
2606
|
+
// This needs to be a ref to ensure that the effect doesn't run before options have a chance to register themselves
|
|
2820
2607
|
committedInputValue // Options will be registered/deregistered based on this value, so this effect needs to run every time this value changes
|
|
2821
2608
|
]);
|
|
2609
|
+
|
|
2822
2610
|
return shouldRenderHeader;
|
|
2823
2611
|
}
|
|
2824
2612
|
|
|
@@ -2894,9 +2682,9 @@ function Combobox(_ref) {
|
|
|
2894
2682
|
}, children);
|
|
2895
2683
|
}
|
|
2896
2684
|
|
|
2897
|
-
var css_248z$7 = ".
|
|
2898
|
-
var styles$7 = {"loadingSpinner":"
|
|
2899
|
-
var stylesheet$7=".
|
|
2685
|
+
var css_248z$7 = "._izwLE :after{background-color:#515559!important}._Xo90l>input:focus{box-shadow:none!important;border:1px solid #898989!important}._fxxtl{max-width:500px;padding:4px 0;background-color:#fff;border:1px solid #eee;border-radius:4px;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);z-index:1000;overflow-x:hidden;overflow-y:auto;overflow:hidden auto}._fxxtl ._OAeXr ._GNlMw{display:flex;align-items:center;min-height:40px;padding:10px 12px;color:#32363a;font-size:12px;line-height:16px;font-weight:700;word-break:break-word}._fxxtl ._OAeXr:first-child ._x-8a5{display:none}._fxxtl ._FhuBg{display:flex;align-items:center;min-height:40px;padding:10px 12px;font-size:14px;color:#32363a;word-break:break-word;outline:none;cursor:pointer}._fxxtl ._FhuBg:hover{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._fxxtl ._FhuBg:hover._L-S0B{background-color:#e4effa}._fxxtl ._FhuBg._L-S0B{background-color:#ebf3fb;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._fxxtl ._FhuBg:active:not(._L-S0B){background-color:#e8e9e9}";
|
|
2686
|
+
var styles$7 = {"loadingSpinner":"_izwLE","ignoreFocusStyle":"_Xo90l","flyout":"_fxxtl","group":"_OAeXr","header":"_GNlMw","divider":"_x-8a5","option":"_FhuBg","selected":"_L-S0B"};
|
|
2687
|
+
var stylesheet$7="._izwLE :after{background-color:#515559!important}._Xo90l>input:focus{box-shadow:none!important;border:1px solid #898989!important}._fxxtl{max-width:500px;padding:4px 0;background-color:#fff;border:1px solid #eee;border-radius:4px;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);z-index:1000;overflow-x:hidden;overflow-y:auto;overflow:hidden auto}._fxxtl ._OAeXr ._GNlMw{display:flex;align-items:center;min-height:40px;padding:10px 12px;color:#32363a;font-size:12px;line-height:16px;font-weight:700;word-break:break-word}._fxxtl ._OAeXr:first-child ._x-8a5{display:none}._fxxtl ._FhuBg{display:flex;align-items:center;min-height:40px;padding:10px 12px;font-size:14px;color:#32363a;word-break:break-word;outline:none;cursor:pointer}._fxxtl ._FhuBg:hover{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._fxxtl ._FhuBg:hover._L-S0B{background-color:#e4effa}._fxxtl ._FhuBg._L-S0B{background-color:#ebf3fb;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._fxxtl ._FhuBg:active:not(._L-S0B){background-color:#e8e9e9}";
|
|
2900
2688
|
icons_index.styleInject(css_248z$7);
|
|
2901
2689
|
|
|
2902
2690
|
const ComboboxInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
@@ -2936,39 +2724,38 @@ const ComboboxInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
2936
2724
|
hoveredOption,
|
|
2937
2725
|
setHoveredOption
|
|
2938
2726
|
} = useComboboxContext();
|
|
2727
|
+
|
|
2939
2728
|
/*
|
|
2940
2729
|
* Creates a variation of selection follows focus.
|
|
2941
2730
|
* The selected option label is not actually committed just by using arrow navigation, but the label does become the value of the input.
|
|
2942
2731
|
*/
|
|
2943
|
-
|
|
2944
2732
|
React.useEffect(() => {
|
|
2945
2733
|
if (activeDescendantElement) {
|
|
2946
2734
|
setRawInputValue(activeDescendantElement.innerHTML); // In a future version of Combobox, if we decide to allow custom children inside of `ComboboxOption`s, we can pass the `ComboboxOption`'s `label` to a `data-*` attribute and then access that attribute's value here instead of `innerHTML`.
|
|
2947
2735
|
}
|
|
2948
|
-
}, [activeDescendantElement, setRawInputValue]);
|
|
2736
|
+
}, [activeDescendantElement, setRawInputValue]);
|
|
2949
2737
|
|
|
2738
|
+
// Handles the case when looping flyout focus ends up focusing the input (the input is included in the focus loop)
|
|
2950
2739
|
React.useEffect(() => {
|
|
2951
2740
|
if (!activeDescendantElement && rawInputValue !== committedInputValue) {
|
|
2952
2741
|
setRawInputValue(committedInputValue);
|
|
2953
2742
|
}
|
|
2954
2743
|
}, [activeDescendantElement, rawInputValue, committedInputValue, setRawInputValue]);
|
|
2955
|
-
|
|
2956
2744
|
const commitCurrentRawInputValueAndCloseFlyout = () => {
|
|
2957
2745
|
setCommittedInputValue(rawInputValue);
|
|
2958
2746
|
setIsOpen(false);
|
|
2959
2747
|
setHoveredOption(null);
|
|
2960
2748
|
};
|
|
2961
|
-
|
|
2962
2749
|
const handleKeyDown = e => {
|
|
2963
2750
|
switch (e.key) {
|
|
2964
2751
|
case 'Escape':
|
|
2965
2752
|
if (isOpen) {
|
|
2966
2753
|
e.stopPropagation(); // Prevents event from closing modals or popovers
|
|
2967
2754
|
|
|
2968
|
-
if (committedInputValue !== '' &&
|
|
2755
|
+
if (committedInputValue !== '' &&
|
|
2756
|
+
// An empty string is not considered to be a committed input value when escape is pressed
|
|
2969
2757
|
rawInputValue !== committedInputValue) {
|
|
2970
2758
|
setRawInputValue(committedInputValue); // If a value was previously committed, revert back to that value
|
|
2971
|
-
|
|
2972
2759
|
focusInput();
|
|
2973
2760
|
} else {
|
|
2974
2761
|
commitCurrentRawInputValueAndCloseFlyout(); // If no value was previously committed, commit the current raw value
|
|
@@ -2976,41 +2763,29 @@ const ComboboxInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
2976
2763
|
}
|
|
2977
2764
|
|
|
2978
2765
|
break;
|
|
2979
|
-
|
|
2980
2766
|
case 'ArrowUp':
|
|
2981
2767
|
e.preventDefault(); // Prevents cursor movement inside of input
|
|
2982
|
-
|
|
2983
2768
|
focusPrevious();
|
|
2984
2769
|
break;
|
|
2985
|
-
|
|
2986
2770
|
case 'ArrowDown':
|
|
2987
2771
|
e.preventDefault(); // Prevents cursor movement inside of input
|
|
2988
|
-
|
|
2989
2772
|
focusNext();
|
|
2990
2773
|
break;
|
|
2991
|
-
|
|
2992
2774
|
case 'PageUp':
|
|
2993
2775
|
e.preventDefault(); // Prevents page scroll
|
|
2994
|
-
|
|
2995
2776
|
focusFirst();
|
|
2996
2777
|
break;
|
|
2997
|
-
|
|
2998
2778
|
case 'PageDown':
|
|
2999
2779
|
e.preventDefault(); // Prevents page scroll
|
|
3000
|
-
|
|
3001
2780
|
focusLast();
|
|
3002
2781
|
break;
|
|
3003
|
-
|
|
3004
2782
|
case 'Enter':
|
|
3005
2783
|
e.preventDefault(); // Prevents form submission
|
|
3006
|
-
|
|
3007
2784
|
commitCurrentRawInputValueAndCloseFlyout();
|
|
3008
2785
|
break;
|
|
3009
|
-
|
|
3010
2786
|
default:
|
|
3011
2787
|
}
|
|
3012
2788
|
};
|
|
3013
|
-
|
|
3014
2789
|
return /*#__PURE__*/React__default["default"].createElement(index.Input$1, {
|
|
3015
2790
|
role: "combobox",
|
|
3016
2791
|
className: classNames__default["default"](className, {
|
|
@@ -3041,8 +2816,8 @@ const ComboboxInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
3041
2816
|
onBlur: () => {
|
|
3042
2817
|
commitCurrentRawInputValueAndCloseFlyout();
|
|
3043
2818
|
},
|
|
3044
|
-
"aria-label": ariaLabel
|
|
3045
|
-
"aria-labelledby": ariaLabelledBy
|
|
2819
|
+
"aria-label": ariaLabel ?? rootAriaLabel,
|
|
2820
|
+
"aria-labelledby": ariaLabelledBy ?? rootAriaLabelledBy,
|
|
3046
2821
|
"aria-describedby": ariaDescribedBy,
|
|
3047
2822
|
"data-testid": index.getSubDataTestId(rootDataTestId, 'input'),
|
|
3048
2823
|
"aria-expanded": isOpen,
|
|
@@ -3077,17 +2852,17 @@ const ComboboxFlyout = _ref => {
|
|
|
3077
2852
|
name: 'offset',
|
|
3078
2853
|
options: {
|
|
3079
2854
|
offset: [-index.FOCUS_RING_WIDTH, index.FLYOUT_POPPER_OFFSET[1]] // The -FOCUS_RING_WIDTH skidding accounts for the box-shadow focus ring on the left side of the anchor
|
|
3080
|
-
|
|
3081
2855
|
}
|
|
3082
2856
|
}],
|
|
2857
|
+
|
|
3083
2858
|
anchorNode: inputRef.current,
|
|
3084
2859
|
popper: /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3085
2860
|
role: "listbox",
|
|
3086
2861
|
id: flyoutId,
|
|
3087
2862
|
className: styles$7.flyout,
|
|
3088
2863
|
style: flyoutDimensions,
|
|
3089
|
-
"aria-label": ariaLabel
|
|
3090
|
-
"aria-labelledby": ariaLabelledBy
|
|
2864
|
+
"aria-label": ariaLabel ?? rootAriaLabel,
|
|
2865
|
+
"aria-labelledby": ariaLabelledBy ?? rootAriaLabelledBy,
|
|
3091
2866
|
"aria-describedby": ariaDescribedBy,
|
|
3092
2867
|
"data-testid": index.getSubDataTestId(rootDataTestId, 'flyout'),
|
|
3093
2868
|
ref: flyoutRef
|
|
@@ -3139,7 +2914,7 @@ function ComboboxGroup(_ref) {
|
|
|
3139
2914
|
className: styles$7.group,
|
|
3140
2915
|
"aria-labelledby": headerElementId,
|
|
3141
2916
|
"aria-describedby": ariaDescribedBy,
|
|
3142
|
-
"data-testid": index.getSubDataTestId(rootDataTestId,
|
|
2917
|
+
"data-testid": index.getSubDataTestId(rootDataTestId, `group-${label}`)
|
|
3143
2918
|
}, /*#__PURE__*/React__default["default"].createElement(index.Divider, {
|
|
3144
2919
|
className: styles$7.divider
|
|
3145
2920
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -3172,28 +2947,27 @@ function ComboboxOption(_ref) {
|
|
|
3172
2947
|
deregisterOption: deregisterGroupOption
|
|
3173
2948
|
} = useComboboxGroupContext();
|
|
3174
2949
|
const lowercaseTrimmedCommittedInputValue = committedInputValue.trim().toLowerCase();
|
|
3175
|
-
const doesLabelMatchInputFilter = label.toLowerCase().startsWith(lowercaseTrimmedCommittedInputValue);
|
|
2950
|
+
const doesLabelMatchInputFilter = label.toLowerCase().startsWith(lowercaseTrimmedCommittedInputValue);
|
|
3176
2951
|
|
|
2952
|
+
// Handles registration and deregistration of the option
|
|
3177
2953
|
React.useEffect(() => {
|
|
3178
2954
|
const containerElement = containerElementRef.current;
|
|
3179
|
-
|
|
3180
2955
|
if (containerElement && doesLabelMatchInputFilter) {
|
|
3181
2956
|
registerListOption(containerElement);
|
|
3182
2957
|
registerGroupOption(containerElement);
|
|
3183
2958
|
}
|
|
3184
|
-
|
|
3185
2959
|
return () => {
|
|
3186
2960
|
if (containerElement) {
|
|
3187
2961
|
deregisterListOption(containerElement);
|
|
3188
2962
|
deregisterGroupOption(containerElement);
|
|
3189
2963
|
}
|
|
3190
2964
|
};
|
|
3191
|
-
}, [doesLabelMatchInputFilter, registerListOption, registerGroupOption, deregisterListOption, deregisterGroupOption]);
|
|
2965
|
+
}, [doesLabelMatchInputFilter, registerListOption, registerGroupOption, deregisterListOption, deregisterGroupOption]);
|
|
3192
2966
|
|
|
2967
|
+
// Doesn't render the option if its label doesn't match the input filter
|
|
3193
2968
|
if (!doesLabelMatchInputFilter) {
|
|
3194
2969
|
return null;
|
|
3195
2970
|
}
|
|
3196
|
-
|
|
3197
2971
|
const isOptionSelected = activeDescendantElement === containerElementRef.current;
|
|
3198
2972
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3199
2973
|
role: "option",
|
|
@@ -3211,14 +2985,14 @@ function ComboboxOption(_ref) {
|
|
|
3211
2985
|
onMouseDown: e => e.preventDefault() // Prevents the input from getting blurred
|
|
3212
2986
|
,
|
|
3213
2987
|
"aria-selected": isOptionSelected,
|
|
3214
|
-
"data-testid": index.getSubDataTestId(rootDataTestId,
|
|
2988
|
+
"data-testid": index.getSubDataTestId(rootDataTestId, `option-${label}`),
|
|
3215
2989
|
ref: containerElementRef
|
|
3216
2990
|
}, label);
|
|
3217
2991
|
}
|
|
3218
2992
|
|
|
3219
|
-
var css_248z$6 = ".
|
|
3220
|
-
var styles$6 = {"container":"
|
|
3221
|
-
var stylesheet$6=".
|
|
2993
|
+
var css_248z$6 = "._A2M2P{display:flex}._852aR{z-index:2;width:1px;margin-left:-1px;margin-right:-1px}._852aR._GTVJ2{background-color:#fff}._852aR._0j0cF,._852aR._GTVJ2._cqq5X:not(._852aR._GTVJ2._TT3cu),body.keyboard-user ._852aR._GTVJ2._Dxhld:not(._QDQOk){background-color:#0b6ed0}._852aR._0j0cF._QDQOk._Dxhld,._852aR._0j0cF._QDQOk._TT3cu,._852aR._0j0cF._TT3cu._cqq5X{opacity:.4}._il-WD{border-radius:4px 0 0 4px;border-right:none;padding-right:17px}._il-WD:focus{z-index:1}._PDkaA{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}._PDkaA svg{margin-left:1px}._PDkaA._GTVJ2{background-color:#0b6ed0;border-color:transparent}._PDkaA._GTVJ2 svg{fill:#fff!important}._PDkaA._GTVJ2:not(._ZArO2):hover{background-color:#085caf!important}._PDkaA._GTVJ2:not(._ZArO2):active{background-color:#0854a1!important}._PDkaA._GTVJ2._ZArO2{opacity:.4}._PDkaA._GTVJ2._ZArO2 svg{background-color:transparent}._PDkaA._0j0cF{border-color:#0b6ed0;background-color:#fff}._PDkaA._0j0cF svg{fill:#0b6ed0!important}._PDkaA._0j0cF:not(._ZArO2):hover{background-color:#eef5fc!important}._PDkaA._0j0cF:not(._ZArO2):active{background-color:#e1edf9!important}._PDkaA._0j0cF._ZArO2{opacity:.4}._PDkaA._0j0cF._ZArO2 svg{background-color:transparent}._jRrOX{width:260px}";
|
|
2994
|
+
var styles$6 = {"container":"_A2M2P","divider":"_852aR","primary":"_GTVJ2","mainButtonFocus":"_Dxhld","mainButtonDisabled":"_QDQOk","dropdownButtonFocus":"_cqq5X","dropdownButtonDisabled":"_TT3cu","secondary":"_0j0cF","mainButton":"_il-WD","dropdownButton":"_PDkaA","disabled":"_ZArO2","dropdownOption":"_jRrOX"};
|
|
2995
|
+
var stylesheet$6="._A2M2P{display:flex}._852aR{z-index:2;width:1px;margin-left:-1px;margin-right:-1px}._852aR._GTVJ2{background-color:#fff}._852aR._0j0cF,._852aR._GTVJ2._cqq5X:not(._852aR._GTVJ2._TT3cu),body.keyboard-user ._852aR._GTVJ2._Dxhld:not(._QDQOk){background-color:#0b6ed0}._852aR._0j0cF._QDQOk._Dxhld,._852aR._0j0cF._QDQOk._TT3cu,._852aR._0j0cF._TT3cu._cqq5X{opacity:.4}._il-WD{border-radius:4px 0 0 4px;border-right:none;padding-right:17px}._il-WD:focus{z-index:1}._PDkaA{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}._PDkaA svg{margin-left:1px}._PDkaA._GTVJ2{background-color:#0b6ed0;border-color:transparent}._PDkaA._GTVJ2 svg{fill:#fff!important}._PDkaA._GTVJ2:not(._ZArO2):hover{background-color:#085caf!important}._PDkaA._GTVJ2:not(._ZArO2):active{background-color:#0854a1!important}._PDkaA._GTVJ2._ZArO2{opacity:.4}._PDkaA._GTVJ2._ZArO2 svg{background-color:transparent}._PDkaA._0j0cF{border-color:#0b6ed0;background-color:#fff}._PDkaA._0j0cF svg{fill:#0b6ed0!important}._PDkaA._0j0cF:not(._ZArO2):hover{background-color:#eef5fc!important}._PDkaA._0j0cF:not(._ZArO2):active{background-color:#e1edf9!important}._PDkaA._0j0cF._ZArO2{opacity:.4}._PDkaA._0j0cF._ZArO2 svg{background-color:transparent}._jRrOX{width:260px}";
|
|
3222
2996
|
icons_index.styleInject(css_248z$6);
|
|
3223
2997
|
|
|
3224
2998
|
const SplitButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
@@ -3239,18 +3013,11 @@ const SplitButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
3239
3013
|
const mainButtonRef = React.useRef(null);
|
|
3240
3014
|
const dropdownButtonRef = React.useRef(null);
|
|
3241
3015
|
const [dropdownButtonHasFocus, setDropdownButtonHasFocus] = React.useState(false);
|
|
3242
|
-
const [mainButtonHasFocus, setMainButtonHasFocus] = React.useState(false);
|
|
3243
|
-
|
|
3244
|
-
index.useEventListener(mainButtonRef, 'keydown', e => {
|
|
3245
|
-
var _dropdownButtonRef$cu;
|
|
3246
|
-
|
|
3247
|
-
return e.key === 'ArrowRight' && ((_dropdownButtonRef$cu = dropdownButtonRef.current) === null || _dropdownButtonRef$cu === void 0 ? void 0 : _dropdownButtonRef$cu.focus());
|
|
3248
|
-
});
|
|
3249
|
-
index.useEventListener(dropdownButtonRef, 'keydown', e => {
|
|
3250
|
-
var _mainButtonRef$curren;
|
|
3016
|
+
const [mainButtonHasFocus, setMainButtonHasFocus] = React.useState(false);
|
|
3251
3017
|
|
|
3252
|
-
|
|
3253
|
-
|
|
3018
|
+
// 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.
|
|
3019
|
+
index.useEventListener(mainButtonRef, 'keydown', e => e.key === 'ArrowRight' && dropdownButtonRef.current?.focus());
|
|
3020
|
+
index.useEventListener(dropdownButtonRef, 'keydown', e => e.key === 'ArrowLeft' && mainButtonRef.current?.focus());
|
|
3254
3021
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3255
3022
|
"data-testid": dataTestId,
|
|
3256
3023
|
className: classNames__default["default"](styles$6.container, className),
|
|
@@ -3285,7 +3052,8 @@ const SplitButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
3285
3052
|
"aria-labelledby": dropdownAriaLabelledBy,
|
|
3286
3053
|
value: 0,
|
|
3287
3054
|
disabled: isDropdownDisabled
|
|
3288
|
-
}, /*#__PURE__*/React__default["default"].createElement(index.DropdownButton
|
|
3055
|
+
}, /*#__PURE__*/React__default["default"].createElement(index.DropdownButton
|
|
3056
|
+
// `label` of type `string` adds Dropdown's `isString` class, which causes a css bug in Safari
|
|
3289
3057
|
, {
|
|
3290
3058
|
label: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null),
|
|
3291
3059
|
className: classNames__default["default"](styles$6.dropdownButton, {
|
|
@@ -3318,9 +3086,9 @@ const SplitButtonOption = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
3318
3086
|
}, children);
|
|
3319
3087
|
});
|
|
3320
3088
|
|
|
3321
|
-
var css_248z$5 = ".
|
|
3322
|
-
var styles$5 = {"button":"
|
|
3323
|
-
var stylesheet$5=".
|
|
3089
|
+
var css_248z$5 = "._v8Zjy{display:flex;justify-content:space-between;align-items:center;max-width:100%;min-width:76px;height:36px;padding:0 6px 0 12px;outline:none;font-size:14px;background-color:#fff;border:1px solid #898989;border-radius:20px;cursor:pointer}._v8Zjy:hover:not(._Ku4-o){background-color:rgba(50,54,58,.08)}._v8Zjy:hover:not(._Ku4-o)._vH0o-{border-color:#085caf;background-color:rgba(11,110,208,.04)}._v8Zjy:hover:not(._Ku4-o)._vH0o- ._9m4Is{color:#32363a}._v8Zjy:hover:not(._Ku4-o)._vH0o- ._HGkjY{fill:#32363a}._v8Zjy:hover:not(._Ku4-o)._vH0o- ._uKrcM{fill:#085caf}._v8Zjy:hover:not(._Ku4-o)._vH0o- ._CXHed{background-color:rgba(11,110,208,.11)}._v8Zjy:hover:not(._Ku4-o)._vH0o- ._CXHed ._oHRZe{color:#085caf}._v8Zjy:active:not(._Ku4-o){background-color:#e8e9e9}._v8Zjy:active:not(._Ku4-o)._vH0o-{background-color:rgba(11,110,208,.11);border-color:#0854a1}._v8Zjy:active:not(._Ku4-o)._vH0o- ._uKrcM{fill:#0854a1}._v8Zjy:active:not(._Ku4-o)._vH0o- ._CXHed{background-color:rgba(11,110,208,.11)}._v8Zjy:active:not(._Ku4-o)._vH0o- ._CXHed ._oHRZe{color:#0854a1}._v8Zjy._Ku4-o{background-color:#fafafa;border-color:#e5e5e5;cursor:not-allowed}._v8Zjy._vH0o-{border-color:#0b6ed0}._HGkjY{fill:#515559;margin-right:4px}._9m4Is{max-width:180px;margin-right:3px;color:#515559;fill:#515559;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9m4Is+._CXHed{margin-left:6px}._9m4Is._Ku4-o{color:#74777a}._CXHed{display:flex;justify-content:center;align-items:center;max-width:350px;flex:1;min-width:0;height:24px;margin-right:3px;padding:0 10px;background-color:#ebf3fb;border-radius:20px}._oHRZe{color:#0b6ed0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._uKrcM{fill:#515559}._uKrcM._Ku4-o,._uKrcM._Ku4-o._vH0o-{fill:rgba(116,119,122,.4)}._uKrcM._vH0o-{fill:#0b6ed0}._uKrcM._MLQyb{transform:rotate(-180deg)}body.keyboard-user ._v8Zjy:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
|
|
3090
|
+
var styles$5 = {"button":"_v8Zjy","disabled":"_Ku4-o","selected":"_vH0o-","label":"_9m4Is","lockIcon":"_HGkjY","chevronIcon":"_uKrcM","selectedFiltersContainer":"_CXHed","selectedFilters":"_oHRZe","open":"_MLQyb"};
|
|
3091
|
+
var stylesheet$5="._v8Zjy{display:flex;justify-content:space-between;align-items:center;max-width:100%;min-width:76px;height:36px;padding:0 6px 0 12px;outline:none;font-size:14px;background-color:#fff;border:1px solid #898989;border-radius:20px;cursor:pointer}._v8Zjy:hover:not(._Ku4-o){background-color:rgba(50,54,58,.08)}._v8Zjy:hover:not(._Ku4-o)._vH0o-{border-color:#085caf;background-color:rgba(11,110,208,.04)}._v8Zjy:hover:not(._Ku4-o)._vH0o- ._9m4Is{color:#32363a}._v8Zjy:hover:not(._Ku4-o)._vH0o- ._HGkjY{fill:#32363a}._v8Zjy:hover:not(._Ku4-o)._vH0o- ._uKrcM{fill:#085caf}._v8Zjy:hover:not(._Ku4-o)._vH0o- ._CXHed{background-color:rgba(11,110,208,.11)}._v8Zjy:hover:not(._Ku4-o)._vH0o- ._CXHed ._oHRZe{color:#085caf}._v8Zjy:active:not(._Ku4-o){background-color:#e8e9e9}._v8Zjy:active:not(._Ku4-o)._vH0o-{background-color:rgba(11,110,208,.11);border-color:#0854a1}._v8Zjy:active:not(._Ku4-o)._vH0o- ._uKrcM{fill:#0854a1}._v8Zjy:active:not(._Ku4-o)._vH0o- ._CXHed{background-color:rgba(11,110,208,.11)}._v8Zjy:active:not(._Ku4-o)._vH0o- ._CXHed ._oHRZe{color:#0854a1}._v8Zjy._Ku4-o{background-color:#fafafa;border-color:#e5e5e5;cursor:not-allowed}._v8Zjy._vH0o-{border-color:#0b6ed0}._HGkjY{fill:#515559;margin-right:4px}._9m4Is{max-width:180px;margin-right:3px;color:#515559;fill:#515559;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9m4Is+._CXHed{margin-left:6px}._9m4Is._Ku4-o{color:#74777a}._CXHed{display:flex;justify-content:center;align-items:center;max-width:350px;flex:1;min-width:0;height:24px;margin-right:3px;padding:0 10px;background-color:#ebf3fb;border-radius:20px}._oHRZe{color:#0b6ed0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._uKrcM{fill:#515559}._uKrcM._Ku4-o,._uKrcM._Ku4-o._vH0o-{fill:rgba(116,119,122,.4)}._uKrcM._vH0o-{fill:#0b6ed0}._uKrcM._MLQyb{transform:rotate(-180deg)}body.keyboard-user ._v8Zjy:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
|
|
3324
3092
|
icons_index.styleInject(css_248z$5);
|
|
3325
3093
|
|
|
3326
3094
|
const FilterAnchor = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
@@ -3354,26 +3122,28 @@ const FilterAnchor = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
3354
3122
|
if (isDisabled) {
|
|
3355
3123
|
e.stopPropagation(); // Prevents "click" events from occurring on parent elements
|
|
3356
3124
|
} else {
|
|
3357
|
-
onClick
|
|
3125
|
+
onClick?.(e);
|
|
3358
3126
|
}
|
|
3359
3127
|
},
|
|
3360
3128
|
onKeyDown: e => {
|
|
3361
3129
|
if (isDisabled) {
|
|
3362
3130
|
e.stopPropagation(); // Prevents "keydown" events from occurring on parent elements
|
|
3363
3131
|
} else {
|
|
3364
|
-
onKeyDown
|
|
3132
|
+
onKeyDown?.(e);
|
|
3365
3133
|
}
|
|
3366
3134
|
},
|
|
3367
3135
|
disabled: undefined // This component uses aria-disabled instead of disabled
|
|
3368
3136
|
,
|
|
3369
3137
|
"aria-disabled": isDisabled,
|
|
3370
|
-
"aria-labelledby": index.concatIds(selectedFilters && selectedFiltersElementId,
|
|
3138
|
+
"aria-labelledby": index.concatIds(selectedFilters && selectedFiltersElementId,
|
|
3139
|
+
// The selected filters (i.e. value) id comes before the label id to match how VoiceOver reads native inputs.
|
|
3371
3140
|
label && labelElementId, isLocked && lockIconElementId, externalAriaLabelledBy),
|
|
3372
3141
|
ref: ref
|
|
3373
3142
|
}), isLocked && /*#__PURE__*/React__default["default"].createElement(icons_index.LockIcon, {
|
|
3374
3143
|
size: "small",
|
|
3375
3144
|
id: lockIconElementId,
|
|
3376
|
-
className: styles$5.lockIcon
|
|
3145
|
+
className: styles$5.lockIcon
|
|
3146
|
+
// @ts-ignore - 'locked' is not in the current list of translations
|
|
3377
3147
|
,
|
|
3378
3148
|
"aria-label": translate('locked')
|
|
3379
3149
|
}), label && /*#__PURE__*/React__default["default"].createElement(index.TextOverflowTooltip, {
|
|
@@ -3386,7 +3156,7 @@ const FilterAnchor = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
3386
3156
|
}, label)), isLoading ? /*#__PURE__*/React__default["default"].createElement(index.LoadingSpinner, {
|
|
3387
3157
|
show: true,
|
|
3388
3158
|
size: "xs",
|
|
3389
|
-
"aria-label": loadingSpinnerAriaLabel
|
|
3159
|
+
"aria-label": loadingSpinnerAriaLabel ?? translate('loading')
|
|
3390
3160
|
}) : selectedFilters && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3391
3161
|
className: styles$5.selectedFiltersContainer
|
|
3392
3162
|
}, /*#__PURE__*/React__default["default"].createElement(index.TextOverflowTooltip, {
|
|
@@ -3413,7 +3183,6 @@ const {
|
|
|
3413
3183
|
useContext: intermediaryUseMenuContext,
|
|
3414
3184
|
Provider: IntermediaryMenuContextProvider
|
|
3415
3185
|
} = index.createContextUtilities();
|
|
3416
|
-
|
|
3417
3186
|
const PaneContextProvider = _ref => {
|
|
3418
3187
|
let {
|
|
3419
3188
|
items,
|
|
@@ -3428,7 +3197,6 @@ const PaneContextProvider = _ref => {
|
|
|
3428
3197
|
value: value
|
|
3429
3198
|
}, children));
|
|
3430
3199
|
};
|
|
3431
|
-
|
|
3432
3200
|
const usePaneContext = childItemRef => {
|
|
3433
3201
|
const coreContext = intermediaryUseMenuContext();
|
|
3434
3202
|
const childIndex = index.useChildIndex({
|
|
@@ -3441,10 +3209,7 @@ const usePaneContext = childItemRef => {
|
|
|
3441
3209
|
};
|
|
3442
3210
|
|
|
3443
3211
|
/* eslint-disable max-classes-per-file */
|
|
3444
|
-
|
|
3445
3212
|
const Menu = _ref => {
|
|
3446
|
-
var _process$env;
|
|
3447
|
-
|
|
3448
3213
|
let {
|
|
3449
3214
|
'data-testid': dataTestId,
|
|
3450
3215
|
isOpen,
|
|
@@ -3452,33 +3217,25 @@ const Menu = _ref => {
|
|
|
3452
3217
|
isDisabled,
|
|
3453
3218
|
children
|
|
3454
3219
|
} = _ref;
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
window.ResizeObserver = (_window$ResizeObserve = window.ResizeObserver) !== null && _window$ResizeObserve !== void 0 ? _window$ResizeObserve : ResizeObserver;
|
|
3460
|
-
window.PointerEvent = (_window$PointerEvent = window.PointerEvent) !== null && _window$PointerEvent !== void 0 ? _window$PointerEvent : PointerEvent;
|
|
3220
|
+
if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'test' && window) {
|
|
3221
|
+
window.ResizeObserver = window.ResizeObserver ?? ResizeObserver;
|
|
3222
|
+
window.PointerEvent = window.PointerEvent ?? PointerEvent;
|
|
3461
3223
|
}
|
|
3462
|
-
|
|
3463
3224
|
const [open, setOpen] = index.useControllableState(isOpen, onIsOpenChange, isOpen);
|
|
3464
3225
|
const [maskHeight, setMaskHeight] = React.useState(null);
|
|
3465
3226
|
const [submenus, setSubmenus] = React.useState(new Set());
|
|
3466
3227
|
const triggerRef = React.useRef(null);
|
|
3467
|
-
|
|
3468
3228
|
const registerSubmenu = (submenuId, submenuIsOpen) => {
|
|
3469
3229
|
setSubmenus(subs => {
|
|
3470
3230
|
const clone = new Set(subs);
|
|
3471
|
-
|
|
3472
3231
|
if (submenuIsOpen) {
|
|
3473
3232
|
clone.add(submenuId);
|
|
3474
3233
|
} else {
|
|
3475
3234
|
clone.delete(submenuId);
|
|
3476
3235
|
}
|
|
3477
|
-
|
|
3478
3236
|
return clone;
|
|
3479
3237
|
});
|
|
3480
3238
|
};
|
|
3481
|
-
|
|
3482
3239
|
const openPaneDepth = React.useMemo(() => open ? submenus.size + 1 : 0, [submenus, open]);
|
|
3483
3240
|
return /*#__PURE__*/React__default["default"].createElement(MenuContextProvider, {
|
|
3484
3241
|
value: {
|
|
@@ -3497,11 +3254,11 @@ const Menu = _ref => {
|
|
|
3497
3254
|
}, children));
|
|
3498
3255
|
};
|
|
3499
3256
|
|
|
3257
|
+
// https://github.com/radix-ui/primitives/issues/420#issuecomment-771615182
|
|
3500
3258
|
class ResizeObserver {
|
|
3501
3259
|
constructor(cb) {
|
|
3502
3260
|
this.cb = cb;
|
|
3503
3261
|
}
|
|
3504
|
-
|
|
3505
3262
|
observe() {
|
|
3506
3263
|
this.cb([{
|
|
3507
3264
|
borderBoxSize: {
|
|
@@ -3509,17 +3266,16 @@ class ResizeObserver {
|
|
|
3509
3266
|
blockSize: 0
|
|
3510
3267
|
}
|
|
3511
3268
|
}]);
|
|
3512
|
-
}
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
unobserve() {} // eslint-disable-next-line class-methods-use-this
|
|
3269
|
+
}
|
|
3516
3270
|
|
|
3271
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3272
|
+
unobserve() {}
|
|
3517
3273
|
|
|
3274
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3518
3275
|
disconnect() {}
|
|
3276
|
+
}
|
|
3519
3277
|
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3278
|
+
// https://github.com/radix-ui/primitives/issues/1220#issuecomment-1087465026
|
|
3523
3279
|
class PointerEvent extends Event {
|
|
3524
3280
|
constructor(type, props) {
|
|
3525
3281
|
super(type, props);
|
|
@@ -3527,12 +3283,11 @@ class PointerEvent extends Event {
|
|
|
3527
3283
|
this.ctrlKey = props.ctrlKey || false;
|
|
3528
3284
|
this.pointerType = props.pointerType || 'mouse';
|
|
3529
3285
|
}
|
|
3530
|
-
|
|
3531
3286
|
}
|
|
3532
3287
|
|
|
3533
|
-
var css_248z$4 = ".
|
|
3534
|
-
var styles$4 = {"buttonContainer":"
|
|
3535
|
-
var stylesheet$4=".
|
|
3288
|
+
var css_248z$4 = "._zmXuy{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._zmXuy>._Au4JW{cursor:unset;width:100%;height:100%;padding:0 28px 0 12px;border-radius:4px;white-space:nowrap;line-height:20px;font-size:14px;text-align:left;outline:none;border:none;box-shadow:inset 0 0 0 1px #898989;color:#515559;background-color:#fafafa;overflow:hidden;text-overflow:ellipsis}._zmXuy>._Au4JW:hover:not([aria-disabled=true]){background-color:#f5f5f5}._zmXuy>._Au4JW:focus{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._zmXuy>._Au4JW+._aanC9{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._zmXuy>._Au4JW[data-state=open]+._aanC9{transform:rotate(-180deg) translateY(50%)}._zmXuy>._Au4JW[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._zmXuy>._Au4JW[aria-disabled=true]+._aanC9{fill:#515559;opacity:.4}._qv9PY>[data-radix-popper-content-wrapper]{overflow:hidden;background-color:#fff;width:var(--radix-dropdown-menu-trigger-width);min-width:200px!important;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);border-radius:4px;z-index:1!important}._qv9PY>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._aWGc6{margin:0;padding:4px 0;background:#fff;transition:.35s;opacity:1;overflow:auto;width:var(--radix-dropdown-menu-trigger-width);min-width:200px;max-height:350px}._aWGc6._o-zRb{padding-top:0}._aWGc6._gyNh8{margin-left:30px;opacity:0;pointer-events:none}._aWGc6._vBNoJ{margin-left:-30px;pointer-events:none}._iAMLH{position:relative;padding:10px 12px;min-height:40px;display:flex;flex-direction:row;align-items:center;cursor:pointer;outline:none;word-break:break-word;font-size:14px;color:#32363a;width:100%}._iAMLH._T29bC{cursor:unset}._iAMLH ._ua4oj{fill:#32363a;margin-right:4px}._iAMLH[data-highlighted]{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._iAMLH[aria-disabled=true]{cursor:not-allowed;opacity:.65}._iAMLH._-764L{padding-right:32px}._iAMLH._-764L ._aanC9{position:absolute;height:100%;right:3px;fill:#515559}._iAMLH._D2--X{pointer-events:none}._N7SZP{position:sticky;top:0;padding-top:4px;background-color:#fff;z-index:1;border-bottom:1px solid #e8e8e8}._N7SZP>._A8q8b{padding:4px 8px 8px;border-radius:4px 4px 0 0}._N7SZP>._A8q8b>._3vx7P{width:100%}._N7SZP>._A8q8b._D2--X{pointer-events:none}";
|
|
3289
|
+
var styles$4 = {"buttonContainer":"_zmXuy","button":"_Au4JW","rightIcon":"_aanC9","maskContainer":"_qv9PY","flyout":"_aWGc6","containsStickyBox":"_o-zRb","animatedRight":"_gyNh8","animatedLeft":"_vBNoJ","menuItem":"_iAMLH","noItems":"_T29bC","backIcon":"_ua4oj","subMenu":"_-764L","unresponsive":"_D2--X","stickyBox":"_N7SZP","searchBox":"_A8q8b","searchInput":"_3vx7P"};
|
|
3290
|
+
var stylesheet$4="._zmXuy{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._zmXuy>._Au4JW{cursor:unset;width:100%;height:100%;padding:0 28px 0 12px;border-radius:4px;white-space:nowrap;line-height:20px;font-size:14px;text-align:left;outline:none;border:none;box-shadow:inset 0 0 0 1px #898989;color:#515559;background-color:#fafafa;overflow:hidden;text-overflow:ellipsis}._zmXuy>._Au4JW:hover:not([aria-disabled=true]){background-color:#f5f5f5}._zmXuy>._Au4JW:focus{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._zmXuy>._Au4JW+._aanC9{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._zmXuy>._Au4JW[data-state=open]+._aanC9{transform:rotate(-180deg) translateY(50%)}._zmXuy>._Au4JW[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._zmXuy>._Au4JW[aria-disabled=true]+._aanC9{fill:#515559;opacity:.4}._qv9PY>[data-radix-popper-content-wrapper]{overflow:hidden;background-color:#fff;width:var(--radix-dropdown-menu-trigger-width);min-width:200px!important;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);border-radius:4px;z-index:1!important}._qv9PY>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._aWGc6{margin:0;padding:4px 0;background:#fff;transition:.35s;opacity:1;overflow:auto;width:var(--radix-dropdown-menu-trigger-width);min-width:200px;max-height:350px}._aWGc6._o-zRb{padding-top:0}._aWGc6._gyNh8{margin-left:30px;opacity:0;pointer-events:none}._aWGc6._vBNoJ{margin-left:-30px;pointer-events:none}._iAMLH{position:relative;padding:10px 12px;min-height:40px;display:flex;flex-direction:row;align-items:center;cursor:pointer;outline:none;word-break:break-word;font-size:14px;color:#32363a;width:100%}._iAMLH._T29bC{cursor:unset}._iAMLH ._ua4oj{fill:#32363a;margin-right:4px}._iAMLH[data-highlighted]{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._iAMLH[aria-disabled=true]{cursor:not-allowed;opacity:.65}._iAMLH._-764L{padding-right:32px}._iAMLH._-764L ._aanC9{position:absolute;height:100%;right:3px;fill:#515559}._iAMLH._D2--X{pointer-events:none}._N7SZP{position:sticky;top:0;padding-top:4px;background-color:#fff;z-index:1;border-bottom:1px solid #e8e8e8}._N7SZP>._A8q8b{padding:4px 8px 8px;border-radius:4px 4px 0 0}._N7SZP>._A8q8b>._3vx7P{width:100%}._N7SZP>._A8q8b._D2--X{pointer-events:none}";
|
|
3536
3291
|
icons_index.styleInject(css_248z$4);
|
|
3537
3292
|
|
|
3538
3293
|
/* eslint-disable import/prefer-default-export */
|
|
@@ -3596,17 +3351,15 @@ const MenuSearch = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
3596
3351
|
closeSubmenu,
|
|
3597
3352
|
flyoutRef
|
|
3598
3353
|
} = usePaneContext();
|
|
3599
|
-
const dataTestId = menuParentDataTestId
|
|
3354
|
+
const dataTestId = menuParentDataTestId?.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_SEARCH);
|
|
3600
3355
|
React.useEffect(() => () => setSearchValue(''), [setSearchValue]);
|
|
3601
|
-
const [previouslyFocusedElement, setPreviouslyFocusedElement] = React.useState();
|
|
3356
|
+
const [previouslyFocusedElement, setPreviouslyFocusedElement] = React.useState();
|
|
3602
3357
|
|
|
3358
|
+
// hack to keep focus on search input on mouse leave
|
|
3603
3359
|
index.useEventListener(flyoutRef, 'focus', e => {
|
|
3604
3360
|
if (e.target === e.currentTarget && previouslyFocusedElement === itemRef.current && isInteractive) {
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
3361
|
+
inputRef.current?.focus();
|
|
3608
3362
|
}
|
|
3609
|
-
|
|
3610
3363
|
setPreviouslyFocusedElement(e.target);
|
|
3611
3364
|
}, {
|
|
3612
3365
|
isCaptureEvent: true
|
|
@@ -3614,14 +3367,11 @@ const MenuSearch = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
3614
3367
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(reactDropdownMenu.Item, {
|
|
3615
3368
|
className: classNames__default["default"](styles$4.searchBox, {
|
|
3616
3369
|
[styles$4.unresponsive]: !isInteractive
|
|
3617
|
-
})
|
|
3370
|
+
})
|
|
3371
|
+
// prevents dropdown from closing
|
|
3618
3372
|
,
|
|
3619
3373
|
onSelect: e => e.preventDefault(),
|
|
3620
|
-
onFocus: () =>
|
|
3621
|
-
var _inputRef$current2;
|
|
3622
|
-
|
|
3623
|
-
return (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
|
|
3624
|
-
},
|
|
3374
|
+
onFocus: () => inputRef.current?.focus(),
|
|
3625
3375
|
role: undefined,
|
|
3626
3376
|
ref: index.mergeRefs(itemRef, ref)
|
|
3627
3377
|
}, /*#__PURE__*/React__default["default"].createElement(index.Input$1, {
|
|
@@ -3631,27 +3381,25 @@ const MenuSearch = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
3631
3381
|
onChange: e => setSearchValue(e.target.value),
|
|
3632
3382
|
placeholder: searchText,
|
|
3633
3383
|
onKeyDown: e => {
|
|
3634
|
-
var
|
|
3635
|
-
|
|
3384
|
+
var _context, _context2;
|
|
3636
3385
|
// stop propagation to prevent typeAhead
|
|
3637
|
-
e.stopPropagation();
|
|
3386
|
+
e.stopPropagation();
|
|
3638
3387
|
|
|
3639
|
-
|
|
3640
|
-
|
|
3388
|
+
// allow caret movement through text entry, but close searchable submenu if on the very left
|
|
3389
|
+
if (e.target?.selectionStart === 0 && _includesInstanceProperty__default["default"](_context = KEYS.CLOSE_SUBMENU).call(_context, e.key)) {
|
|
3390
|
+
closeSubmenu?.(e);
|
|
3641
3391
|
return;
|
|
3642
|
-
}
|
|
3643
|
-
|
|
3392
|
+
}
|
|
3644
3393
|
|
|
3394
|
+
// forward keypress directly to `Item` to let Radix handle keyboard navigation
|
|
3645
3395
|
if (_includesInstanceProperty__default["default"](_context2 = KEYS.IGNORED_BY_SEARCH_INPUT).call(_context2, e.key)) {
|
|
3646
|
-
var _itemRef$current;
|
|
3647
|
-
|
|
3648
3396
|
// `view` types are incompatible
|
|
3649
3397
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3650
3398
|
const {
|
|
3651
3399
|
view,
|
|
3652
3400
|
...eventClone
|
|
3653
3401
|
} = e;
|
|
3654
|
-
itemRef
|
|
3402
|
+
itemRef?.current?.dispatchEvent(new KeyboardEvent('keydown', eventClone));
|
|
3655
3403
|
}
|
|
3656
3404
|
},
|
|
3657
3405
|
leftAddOn: /*#__PURE__*/React__default["default"].createElement(icons_index.SearchIcon, null),
|
|
@@ -3660,6 +3408,7 @@ const MenuSearch = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
3660
3408
|
})));
|
|
3661
3409
|
});
|
|
3662
3410
|
|
|
3411
|
+
// abstracts the logic required for searching by both `MenuPane` and `SubMenu`
|
|
3663
3412
|
function usePaneSearch(externalSearchValue, onSearchValueChange, items) {
|
|
3664
3413
|
const [internalSearchValue, setSearchValue] = index.useControllableState(externalSearchValue, onSearchValueChange, externalSearchValue);
|
|
3665
3414
|
const [zeroSearchResults, setZeroSearchResults] = React.useState();
|
|
@@ -3668,7 +3417,7 @@ function usePaneSearch(externalSearchValue, onSearchValueChange, items) {
|
|
|
3668
3417
|
} = index.useTranslation();
|
|
3669
3418
|
const noMatchesText = translate('menu.noItemsToDisplay');
|
|
3670
3419
|
React.useEffect(() => {
|
|
3671
|
-
setZeroSearchResults(
|
|
3420
|
+
setZeroSearchResults(items?.filter(item => item.element.current).length === 0);
|
|
3672
3421
|
}, [items, internalSearchValue]);
|
|
3673
3422
|
return {
|
|
3674
3423
|
internalSearchValue,
|
|
@@ -3699,11 +3448,7 @@ const MenuPane = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3699
3448
|
noMatchesText
|
|
3700
3449
|
} = usePaneSearch(externalSearchValue, onSearchValueChange, items);
|
|
3701
3450
|
const portalTarget = index.usePortalTarget();
|
|
3702
|
-
const [side, align] = React.useMemo(() =>
|
|
3703
|
-
var _placement$split, _placement$split2;
|
|
3704
|
-
|
|
3705
|
-
return (_placement$split = placement === null || placement === void 0 ? void 0 : (_placement$split2 = placement.split) === null || _placement$split2 === void 0 ? void 0 : _placement$split2.call(placement, '-')) !== null && _placement$split !== void 0 ? _placement$split : [];
|
|
3706
|
-
}, [placement]);
|
|
3451
|
+
const [side, align] = React.useMemo(() => placement?.split?.('-') ?? [], [placement]);
|
|
3707
3452
|
const {
|
|
3708
3453
|
dataTestId: rootDataTestId,
|
|
3709
3454
|
openPaneDepth,
|
|
@@ -3711,17 +3456,16 @@ const MenuPane = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3711
3456
|
maskHeight,
|
|
3712
3457
|
open,
|
|
3713
3458
|
triggerRef
|
|
3714
|
-
} = useMenuContext();
|
|
3715
|
-
// We cache the pixel value here, to use it later if the user returns to this pane from a submenu.
|
|
3459
|
+
} = useMenuContext();
|
|
3716
3460
|
|
|
3461
|
+
// In order to preseve the css animation for vertical resizing, we cannot set the height of this pane to `auto`. It must be a pixel value.
|
|
3462
|
+
// We cache the pixel value here, to use it later if the user returns to this pane from a submenu.
|
|
3717
3463
|
const initialHeightOfThisPane = React.useRef(null);
|
|
3718
3464
|
index.useDidUpdate(() => {
|
|
3719
3465
|
if (openPaneDepth === 1) {
|
|
3720
3466
|
if (initialHeightOfThisPane.current === null) {
|
|
3721
3467
|
window.requestAnimationFrame(() => {
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
initialHeightOfThisPane.current = (_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;
|
|
3468
|
+
initialHeightOfThisPane.current = flyoutRef.current?.clientHeight ?? null;
|
|
3725
3469
|
setMaskHeight(initialHeightOfThisPane.current);
|
|
3726
3470
|
});
|
|
3727
3471
|
} else {
|
|
@@ -3733,7 +3477,6 @@ const MenuPane = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3733
3477
|
const animatedLeft = React.useMemo(() => openPaneDepth > 1, [openPaneDepth]);
|
|
3734
3478
|
index.useEventListener(flyoutRef, 'keydown', e => {
|
|
3735
3479
|
var _context;
|
|
3736
|
-
|
|
3737
3480
|
return _includesInstanceProperty__default["default"](_context = Object.values(KEYS).flat()).call(_context, e.key) && index.setIsKeyboardUser(true);
|
|
3738
3481
|
}, {
|
|
3739
3482
|
additionalDependencies: [openPaneDepth]
|
|
@@ -3742,36 +3485,27 @@ const MenuPane = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3742
3485
|
additionalDependencies: [openPaneDepth]
|
|
3743
3486
|
});
|
|
3744
3487
|
const defaultSide = React.useMemo(() => {
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
const rect = triggerRef === null || triggerRef === void 0 ? void 0 : (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.getBoundingClientRect();
|
|
3748
|
-
|
|
3488
|
+
const rect = triggerRef?.current?.getBoundingClientRect();
|
|
3749
3489
|
if (!rect) {
|
|
3750
3490
|
return 'bottom';
|
|
3751
|
-
}
|
|
3752
|
-
|
|
3491
|
+
}
|
|
3753
3492
|
|
|
3493
|
+
// hard coded in Menu.less
|
|
3754
3494
|
let maxHeight = 350;
|
|
3755
|
-
|
|
3756
3495
|
if (flyoutRef.current) {
|
|
3757
3496
|
const computedString = window.getComputedStyle(flyoutRef.current).maxHeight.slice(0, -2);
|
|
3758
|
-
|
|
3759
3497
|
if (computedString !== '' && !Number.isNaN(+computedString)) {
|
|
3760
3498
|
maxHeight = +computedString;
|
|
3761
3499
|
}
|
|
3762
3500
|
}
|
|
3763
|
-
|
|
3764
3501
|
const distanceToBottom = window.innerHeight - rect.bottom;
|
|
3765
3502
|
const distanceToTop = rect.top;
|
|
3766
|
-
|
|
3767
3503
|
if (distanceToBottom > maxHeight) {
|
|
3768
3504
|
return 'bottom';
|
|
3769
3505
|
}
|
|
3770
|
-
|
|
3771
3506
|
if (distanceToTop > maxHeight) {
|
|
3772
3507
|
return 'top';
|
|
3773
3508
|
}
|
|
3774
|
-
|
|
3775
3509
|
return 'bottom';
|
|
3776
3510
|
}, [open, triggerRef]);
|
|
3777
3511
|
return /*#__PURE__*/React__default["default"].createElement(PaneContextProvider, {
|
|
@@ -3799,8 +3533,9 @@ const MenuPane = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3799
3533
|
[styles$4.animatedLeft]: animatedLeft,
|
|
3800
3534
|
[styles$4.containsStickyBox]: isSearchable
|
|
3801
3535
|
}, styles$4.flyout),
|
|
3802
|
-
style: {
|
|
3803
|
-
|
|
3536
|
+
style: {
|
|
3537
|
+
...style,
|
|
3538
|
+
height: internalSearchValue && openPaneDepth === 1 ? undefined : maskHeight ?? undefined
|
|
3804
3539
|
}
|
|
3805
3540
|
}), isSearchable && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3806
3541
|
className: styles$4.stickyBox
|
|
@@ -3832,25 +3567,22 @@ const MenuItem = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3832
3567
|
closeSubmenu,
|
|
3833
3568
|
flyoutRef
|
|
3834
3569
|
} = usePaneContext(itemRef);
|
|
3835
|
-
const dataTestId = index.getSubDataTestId(menuParentDataTestId
|
|
3570
|
+
const dataTestId = index.getSubDataTestId(menuParentDataTestId?.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_ITEM), String(index$1));
|
|
3836
3571
|
const isVisible = React.useMemo(() => {
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
const searchMatcher = label !== null && label !== void 0 ? label : typeof children === 'string' ? children : undefined;
|
|
3840
|
-
return isSearchFilteringDisabled || !searchValue || (searchMatcher === null || searchMatcher === void 0 ? void 0 : _includesInstanceProperty__default["default"](_context = searchMatcher.toLowerCase()).call(_context, searchValue.toLowerCase()));
|
|
3572
|
+
const searchMatcher = label ?? (typeof children === 'string' ? children : undefined);
|
|
3573
|
+
return isSearchFilteringDisabled || !searchValue || searchMatcher?.toLowerCase().includes(searchValue.toLowerCase());
|
|
3841
3574
|
}, [children, searchValue, label, isSearchFilteringDisabled]);
|
|
3842
|
-
|
|
3843
3575
|
const handleFocus = () => {
|
|
3844
3576
|
if (itemRef.current && flyoutRef.current && index.getIsKeyboardUser()) {
|
|
3845
|
-
const stickyBoxHeight = 93;
|
|
3577
|
+
const stickyBoxHeight = 93;
|
|
3846
3578
|
|
|
3579
|
+
// if the top of the focused menu item is beneath the sticky box
|
|
3847
3580
|
if (itemRef.current.offsetTop < flyoutRef.current.scrollTop + stickyBoxHeight) {
|
|
3848
3581
|
// scroll down a little
|
|
3849
3582
|
flyoutRef.current.scrollTop = itemRef.current.offsetTop - stickyBoxHeight;
|
|
3850
3583
|
}
|
|
3851
3584
|
}
|
|
3852
3585
|
};
|
|
3853
|
-
|
|
3854
3586
|
return isVisible ? /*#__PURE__*/React__default["default"].createElement(reactDropdownMenu.Item, _extends__default["default"]({}, rest, {
|
|
3855
3587
|
asChild: asChild,
|
|
3856
3588
|
"aria-disabled": isDisabled,
|
|
@@ -3860,21 +3592,20 @@ const MenuItem = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3860
3592
|
"data-testid": dataTestId,
|
|
3861
3593
|
ref: index.mergeRefs(ref, itemRef),
|
|
3862
3594
|
onKeyDown: e => {
|
|
3863
|
-
var
|
|
3864
|
-
|
|
3595
|
+
var _context;
|
|
3865
3596
|
if (!isInteractive) {
|
|
3866
3597
|
e.preventDefault();
|
|
3867
3598
|
return;
|
|
3868
3599
|
}
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
closeSubmenu === null || closeSubmenu === void 0 ? void 0 : closeSubmenu(e);
|
|
3600
|
+
if (_includesInstanceProperty__default["default"](_context = KEYS.CLOSE_SUBMENU).call(_context, e.key)) {
|
|
3601
|
+
closeSubmenu?.(e);
|
|
3872
3602
|
}
|
|
3873
3603
|
},
|
|
3874
|
-
onFocus: handleFocus
|
|
3604
|
+
onFocus: handleFocus
|
|
3605
|
+
// stop radix from closing the menu on selection of disabled item
|
|
3875
3606
|
// other pointer and keyboard events still work, even when disabled
|
|
3876
3607
|
,
|
|
3877
|
-
onSelect: e => isDisabled ? e.preventDefault() : onSelect
|
|
3608
|
+
onSelect: e => isDisabled ? e.preventDefault() : onSelect?.()
|
|
3878
3609
|
}), (!children || typeof children === 'string') && label ? label : children) : null;
|
|
3879
3610
|
});
|
|
3880
3611
|
|
|
@@ -3918,11 +3649,10 @@ const SubMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
3918
3649
|
} = useMenuContext();
|
|
3919
3650
|
const thisPanesDepth = React.useRef(totalOpenPaneDepth + 1).current;
|
|
3920
3651
|
const paneDataTestId = index.getSubDataTestId(paneContainingTriggerDataTestId, String(triggerIndex));
|
|
3921
|
-
const backButtonDataTestId = paneDataTestId
|
|
3922
|
-
const triggerDataTestId = paneDataTestId
|
|
3652
|
+
const backButtonDataTestId = paneDataTestId?.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_BACK);
|
|
3653
|
+
const triggerDataTestId = paneDataTestId?.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_ITEM);
|
|
3923
3654
|
const triggerIsVisible = React.useMemo(() => {
|
|
3924
3655
|
var _context;
|
|
3925
|
-
|
|
3926
3656
|
return isSearchFilteringDisabledForPaneContainingTrigger || !paneContainingTriggerSearchValue || typeof label === 'string' && _includesInstanceProperty__default["default"](_context = label.toLowerCase()).call(_context, paneContainingTriggerSearchValue.toLowerCase());
|
|
3927
3657
|
}, [paneContainingTriggerSearchValue, label, isSearchFilteringDisabledForPaneContainingTrigger]);
|
|
3928
3658
|
const [isPaneInDOM, setIsPaneInDOM] = React.useState(false);
|
|
@@ -3930,63 +3660,49 @@ const SubMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
3930
3660
|
const [isTransitioningFromRight, setIsTransitioningFromRight] = React.useState(false);
|
|
3931
3661
|
index.useDidUpdate(() => {
|
|
3932
3662
|
if (isPaneInDOM) {
|
|
3933
|
-
setIsTransitioningFromRight(true);
|
|
3934
|
-
|
|
3663
|
+
setIsTransitioningFromRight(true);
|
|
3664
|
+
// trigger css transition
|
|
3935
3665
|
setIsFrameAfterPaneAddedToDOM(true);
|
|
3936
3666
|
window.requestAnimationFrame(() => setIsFrameAfterPaneAddedToDOM(false));
|
|
3937
3667
|
}
|
|
3938
|
-
|
|
3939
3668
|
registerSubmenu(internalId, isPaneInDOM);
|
|
3940
3669
|
}, [isPaneInDOM]);
|
|
3941
3670
|
React.useEffect(() => () => registerSubmenu(internalId, false), []);
|
|
3942
|
-
|
|
3943
3671
|
const closeThisSubmenu = e => {
|
|
3944
3672
|
// prevent closing the entire menu, and Radix keyboard navigation
|
|
3945
3673
|
e.preventDefault();
|
|
3946
3674
|
registerSubmenu(internalId, false);
|
|
3947
3675
|
};
|
|
3948
|
-
|
|
3949
3676
|
index.useDidUpdate(() => {
|
|
3950
3677
|
if (thisPanesDepth === totalOpenPaneDepth) {
|
|
3951
3678
|
window.requestAnimationFrame(() => {
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
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);
|
|
3679
|
+
setMaskHeight(flyoutRef.current?.clientHeight ?? null);
|
|
3955
3680
|
});
|
|
3956
3681
|
}
|
|
3957
3682
|
}, [totalOpenPaneDepth, internalSearchValue]);
|
|
3958
3683
|
const animatedLeft = React.useMemo(() => thisPanesDepth < totalOpenPaneDepth, [totalOpenPaneDepth]);
|
|
3959
3684
|
const animatedRight = React.useMemo(() => thisPanesDepth > totalOpenPaneDepth || isFrameAfterPaneAddedToDOM, [totalOpenPaneDepth, isFrameAfterPaneAddedToDOM]);
|
|
3960
|
-
|
|
3961
3685
|
const handlePaneTransitionEnd = () => {
|
|
3962
3686
|
if (animatedLeft) {
|
|
3963
3687
|
return;
|
|
3964
3688
|
}
|
|
3965
|
-
|
|
3966
3689
|
if (animatedRight) {
|
|
3967
3690
|
setIsPaneInDOM(false);
|
|
3968
|
-
|
|
3969
3691
|
if (index.getIsKeyboardUser()) {
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
(_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.focus();
|
|
3692
|
+
triggerRef.current?.focus();
|
|
3973
3693
|
}
|
|
3974
3694
|
} else {
|
|
3975
|
-
var _flyoutRef$current2;
|
|
3976
|
-
|
|
3977
3695
|
// if the newly closed submenu doesn't place the focus on its trigger
|
|
3978
|
-
if (!
|
|
3696
|
+
if (!flyoutRef.current?.contains(document.activeElement) && index.getIsKeyboardUser()) {
|
|
3979
3697
|
if (searchItemRef.current) {
|
|
3980
3698
|
searchItemRef.current.focus();
|
|
3981
3699
|
} else if (backButtonRef.current) {
|
|
3982
3700
|
backButtonRef.current.focus();
|
|
3983
3701
|
}
|
|
3984
3702
|
}
|
|
3985
|
-
|
|
3986
3703
|
setIsTransitioningFromRight(false);
|
|
3987
3704
|
}
|
|
3988
3705
|
};
|
|
3989
|
-
|
|
3990
3706
|
return triggerIsVisible ? /*#__PURE__*/React__default["default"].createElement(reactDropdownMenu.Sub, {
|
|
3991
3707
|
open: isPaneInDOM
|
|
3992
3708
|
}, /*#__PURE__*/React__default["default"].createElement(reactDropdownMenu.SubTrigger, {
|
|
@@ -3999,16 +3715,14 @@ const SubMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
3999
3715
|
onClick: () => !isDisabled && setIsPaneInDOM(true),
|
|
4000
3716
|
onKeyDown: e => {
|
|
4001
3717
|
var _context2, _context3;
|
|
4002
|
-
|
|
4003
3718
|
if (!paneContainingTriggerIsInteractive) {
|
|
4004
3719
|
e.preventDefault();
|
|
4005
3720
|
return;
|
|
4006
3721
|
}
|
|
4007
|
-
|
|
4008
3722
|
if (!isDisabled && _includesInstanceProperty__default["default"](_context2 = KEYS.OPEN_SUBMENU).call(_context2, e.key)) {
|
|
4009
3723
|
setIsPaneInDOM(true);
|
|
4010
3724
|
} else if (_includesInstanceProperty__default["default"](_context3 = KEYS.CLOSE_SUBMENU).call(_context3, e.key)) {
|
|
4011
|
-
closeSubmenuContainingTrigger
|
|
3725
|
+
closeSubmenuContainingTrigger?.(e);
|
|
4012
3726
|
}
|
|
4013
3727
|
}
|
|
4014
3728
|
}, label, /*#__PURE__*/React__default["default"].createElement(icons_index.ChevronRightIcon, {
|
|
@@ -4033,7 +3747,8 @@ const SubMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
4033
3747
|
[styles$4.animatedLeft]: animatedLeft
|
|
4034
3748
|
}),
|
|
4035
3749
|
onTransitionEnd: handlePaneTransitionEnd,
|
|
4036
|
-
style: {
|
|
3750
|
+
style: {
|
|
3751
|
+
...style,
|
|
4037
3752
|
zIndex: thisPanesDepth
|
|
4038
3753
|
}
|
|
4039
3754
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -4050,7 +3765,6 @@ const SubMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
4050
3765
|
ref: backButtonRef,
|
|
4051
3766
|
onKeyDown: e => {
|
|
4052
3767
|
var _context4;
|
|
4053
|
-
|
|
4054
3768
|
if (_includesInstanceProperty__default["default"](_context4 = KEYS.CLOSE_SUBMENU).call(_context4, e.key)) {
|
|
4055
3769
|
closeThisSubmenu(e);
|
|
4056
3770
|
}
|
|
@@ -4064,9 +3778,9 @@ const SubMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
4064
3778
|
}, noMatchesText), children))) : null;
|
|
4065
3779
|
});
|
|
4066
3780
|
|
|
4067
|
-
var css_248z$3 = ".
|
|
4068
|
-
var styles$3 = {"overlay":"
|
|
4069
|
-
var stylesheet$3=".
|
|
3781
|
+
var css_248z$3 = "._DAPa9{background-color:rgba(0,0,0,.5);width:100%;height:100%;position:absolute;top:0;left:0;right:0;bottom:0;display:grid;align-items:left;justify-items:left;place-items:left;overflow-y:auto}._duYYq{visibility:hidden}";
|
|
3782
|
+
var styles$3 = {"overlay":"_DAPa9","hidden":"_duYYq"};
|
|
3783
|
+
var stylesheet$3="._DAPa9{background-color:rgba(0,0,0,.5);width:100%;height:100%;position:absolute;top:0;left:0;right:0;bottom:0;display:grid;align-items:left;justify-items:left;place-items:left;overflow-y:auto}._duYYq{visibility:hidden}";
|
|
4070
3784
|
icons_index.styleInject(css_248z$3);
|
|
4071
3785
|
|
|
4072
3786
|
/**
|
|
@@ -4089,9 +3803,7 @@ const useOverlay = _ref => {
|
|
|
4089
3803
|
} = _ref;
|
|
4090
3804
|
const overlayId = index.useId();
|
|
4091
3805
|
React.useEffect(() => {
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
const containerNode = (_containerRef$current = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) !== null && _containerRef$current !== void 0 ? _containerRef$current : document.body;
|
|
3806
|
+
const containerNode = containerRef?.current ?? document.body;
|
|
4095
3807
|
const overlay = document.createElement('div');
|
|
4096
3808
|
overlay.id = overlayId;
|
|
4097
3809
|
overlay.classList.add(styles$3.overlay);
|
|
@@ -4107,23 +3819,19 @@ const useOverlay = _ref => {
|
|
|
4107
3819
|
};
|
|
4108
3820
|
}, [containerRef, overlayId, isVisible, onClick, dataTestId, zIndex]);
|
|
4109
3821
|
React.useEffect(() => {
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
const containerNode = (_containerRef$current2 = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) !== null && _containerRef$current2 !== void 0 ? _containerRef$current2 : document.body;
|
|
3822
|
+
const containerNode = containerRef?.current ?? document.body;
|
|
4113
3823
|
const overlayNode = document.getElementById(overlayId);
|
|
4114
|
-
|
|
4115
3824
|
if (isVisible) {
|
|
4116
3825
|
Array.from(containerNode.children).forEach(child => {
|
|
4117
3826
|
if (!_includesInstanceProperty__default["default"](ignoreIds).call(ignoreIds, child.id) && child.id !== overlayId) child.setAttribute('inert', '');
|
|
4118
3827
|
});
|
|
4119
|
-
overlayNode
|
|
3828
|
+
overlayNode?.classList.remove(styles$3.hidden);
|
|
4120
3829
|
} else {
|
|
4121
3830
|
Array.from(containerNode.children).forEach(child => {
|
|
4122
3831
|
child.removeAttribute('inert');
|
|
4123
3832
|
});
|
|
4124
|
-
overlayNode
|
|
3833
|
+
overlayNode?.classList.add(styles$3.hidden);
|
|
4125
3834
|
}
|
|
4126
|
-
|
|
4127
3835
|
return () => {
|
|
4128
3836
|
Array.from(containerNode.children).forEach(child => {
|
|
4129
3837
|
child.removeAttribute('inert');
|
|
@@ -4132,14 +3840,12 @@ const useOverlay = _ref => {
|
|
|
4132
3840
|
}, [containerRef, isVisible, ignoreIds, overlayId]);
|
|
4133
3841
|
};
|
|
4134
3842
|
|
|
4135
|
-
var css_248z$2 = ".
|
|
4136
|
-
var styles$2 = {"drawer":"
|
|
4137
|
-
var stylesheet$2=".
|
|
3843
|
+
var css_248z$2 = "._J7cVG{position:absolute;top:0;height:100%;color:#32363a;background-color:#fff;border-right:1px solid #eee;z-index:1000;padding:12px 20px 20px;transition:left .5s}._9XV1R{visibility:hidden}._Mdjdm{display:flex;justify-content:space-between;align-items:start;line-height:20px;font-size:16px;padding-bottom:12px}._XhETZ{padding-top:8px}._RT7Ji{margin-left:12px}";
|
|
3844
|
+
var styles$2 = {"drawer":"_J7cVG","hidden":"_9XV1R","header":"_Mdjdm","title":"_XhETZ","closeButton":"_RT7Ji"};
|
|
3845
|
+
var stylesheet$2="._J7cVG{position:absolute;top:0;height:100%;color:#32363a;background-color:#fff;border-right:1px solid #eee;z-index:1000;padding:12px 20px 20px;transition:left .5s}._9XV1R{visibility:hidden}._Mdjdm{display:flex;justify-content:space-between;align-items:start;line-height:20px;font-size:16px;padding-bottom:12px}._XhETZ{padding-top:8px}._RT7Ji{margin-left:12px}";
|
|
4138
3846
|
icons_index.styleInject(css_248z$2);
|
|
4139
3847
|
|
|
4140
3848
|
const Drawer = _ref => {
|
|
4141
|
-
var _containerRef$current;
|
|
4142
|
-
|
|
4143
3849
|
let {
|
|
4144
3850
|
id,
|
|
4145
3851
|
isOpen: externalIsOpen,
|
|
@@ -4171,15 +3877,12 @@ const Drawer = _ref => {
|
|
|
4171
3877
|
} = index.useTranslation();
|
|
4172
3878
|
const closeButtonAriaLabel = translate('close');
|
|
4173
3879
|
const closeButtonRef = React.useRef(null);
|
|
4174
|
-
|
|
4175
3880
|
const close = () => {
|
|
4176
3881
|
setIsOpen(false);
|
|
4177
3882
|
};
|
|
4178
|
-
|
|
4179
3883
|
const handleKeyDown = e => {
|
|
4180
3884
|
if (e.key === 'Escape') close();
|
|
4181
3885
|
};
|
|
4182
|
-
|
|
4183
3886
|
useOverlay({
|
|
4184
3887
|
containerRef,
|
|
4185
3888
|
isVisible: isOpen,
|
|
@@ -4194,29 +3897,23 @@ const Drawer = _ref => {
|
|
|
4194
3897
|
setIsHidden(false);
|
|
4195
3898
|
setElementUsedToOpenModal(document.activeElement);
|
|
4196
3899
|
} else {
|
|
4197
|
-
var _elementRefToFocusOnC;
|
|
4198
|
-
|
|
4199
3900
|
setIsClosing(true);
|
|
4200
|
-
if (elementRefToFocusOnClose !== undefined) elementRefToFocusOnClose
|
|
3901
|
+
if (elementRefToFocusOnClose !== undefined) elementRefToFocusOnClose?.current?.focus();else elementUsedToOpenModal?.focus();
|
|
4201
3902
|
}
|
|
4202
3903
|
}, [elementRefToFocusOnClose, isOpen]);
|
|
4203
3904
|
React.useEffect(() => {
|
|
4204
3905
|
if (isOpen && !isHidden) {
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
(_closeButtonRef$curre = closeButtonRef.current) === null || _closeButtonRef$curre === void 0 ? void 0 : _closeButtonRef$curre.focus();
|
|
3906
|
+
closeButtonRef.current?.focus();
|
|
4208
3907
|
}
|
|
4209
3908
|
}, [isOpen, isHidden]);
|
|
4210
|
-
|
|
4211
3909
|
const handleTransitionEnd = () => {
|
|
4212
3910
|
if (!isOpen) {
|
|
4213
3911
|
setIsClosing(false);
|
|
4214
3912
|
setIsHidden(true);
|
|
4215
3913
|
}
|
|
4216
3914
|
};
|
|
4217
|
-
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
4218
|
-
|
|
4219
3915
|
|
|
3916
|
+
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
4220
3917
|
return domReady ? /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React__default["default"].createElement("aside", {
|
|
4221
3918
|
id: drawerId,
|
|
4222
3919
|
className: classNames__default["default"](styles$2.drawer, {
|
|
@@ -4225,7 +3922,7 @@ const Drawer = _ref => {
|
|
|
4225
3922
|
}),
|
|
4226
3923
|
style: {
|
|
4227
3924
|
width,
|
|
4228
|
-
left:
|
|
3925
|
+
left: `${isHidden || isClosing ? `-${width}` : '0'}`,
|
|
4229
3926
|
zIndex
|
|
4230
3927
|
},
|
|
4231
3928
|
onKeyDown: handleKeyDown,
|
|
@@ -4250,12 +3947,12 @@ const Drawer = _ref => {
|
|
|
4250
3947
|
"aria-label": closeButtonAriaLabel
|
|
4251
3948
|
}, /*#__PURE__*/React__default["default"].createElement(icons_index.CloseIcon, null))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
4252
3949
|
"data-testid": index.getSubDataTestId(dataTestId, 'body')
|
|
4253
|
-
}, children))),
|
|
3950
|
+
}, children))), containerRef?.current ?? document.body) : null;
|
|
4254
3951
|
};
|
|
4255
3952
|
|
|
4256
|
-
var css_248z$1 = ".
|
|
4257
|
-
var styles$1 = {"container":"
|
|
4258
|
-
var stylesheet$1=".
|
|
3953
|
+
var css_248z$1 = "._7lOdN{display:inline-block;position:relative}._dLogP{width:120px}._dLogP ._SvLXS._sB9s6{transform:rotate(-180deg)}._dLogP ._SvLXS._93Jl7{fill:#9d9fa1;opacity:.4}._oy5-J>input:focus{box-shadow:none!important;border:1px solid #898989!important}._HKxEu{width:120px}._HKxEu ._IjBc3._ttgJu{background-color:#efefef;border-radius:6px}._SvLXS{position:absolute;right:4px;bottom:4px;height:28px;width:28px}._SvLXS._sB9s6{transform:rotate(-180deg)}";
|
|
3954
|
+
var styles$1 = {"container":"_7lOdN","input":"_dLogP","icon":"_SvLXS","open":"_sB9s6","disabled":"_93Jl7","ignoreFocusStyle":"_oy5-J","flyout":"_HKxEu","option":"_IjBc3","exactMatch":"_ttgJu"};
|
|
3955
|
+
var stylesheet$1="._7lOdN{display:inline-block;position:relative}._dLogP{width:120px}._dLogP ._SvLXS._sB9s6{transform:rotate(-180deg)}._dLogP ._SvLXS._93Jl7{fill:#9d9fa1;opacity:.4}._oy5-J>input:focus{box-shadow:none!important;border:1px solid #898989!important}._HKxEu{width:120px}._HKxEu ._IjBc3._ttgJu{background-color:#efefef;border-radius:6px}._SvLXS{position:absolute;right:4px;bottom:4px;height:28px;width:28px}._SvLXS._sB9s6{transform:rotate(-180deg)}";
|
|
4259
3956
|
icons_index.styleInject(css_248z$1);
|
|
4260
3957
|
|
|
4261
3958
|
const TimeDropdown = _ref => {
|
|
@@ -4277,7 +3974,6 @@ const TimeDropdown = _ref => {
|
|
|
4277
3974
|
const [refsInitialized, setRefsInitialized] = React.useState(false);
|
|
4278
3975
|
React.useEffect(() => {
|
|
4279
3976
|
const nodes = scrollRef.current;
|
|
4280
|
-
|
|
4281
3977
|
if (scrolledToItem && nodes[scrolledToItem.index]) {
|
|
4282
3978
|
nodes[scrolledToItem.index].scrollIntoView();
|
|
4283
3979
|
}
|
|
@@ -4296,14 +3992,14 @@ const TimeDropdown = _ref => {
|
|
|
4296
3992
|
"aria-label": ariaLabel,
|
|
4297
3993
|
"aria-labelledby": ariaLabelledBy,
|
|
4298
3994
|
"aria-describedby": ariaDescribedBy,
|
|
4299
|
-
"data-testid": dataTestId &&
|
|
3995
|
+
"data-testid": dataTestId && `${dataTestId}-dropdown`,
|
|
4300
3996
|
className: styles$1.flyout,
|
|
4301
3997
|
onMouseOver: () => setIsOptionHovered(true),
|
|
4302
3998
|
onMouseLeave: () => setIsOptionHovered(false)
|
|
4303
3999
|
}, items.map((item, index$1) => /*#__PURE__*/React__default["default"].createElement(index.FlyoutOption, {
|
|
4304
4000
|
id: item.id,
|
|
4305
4001
|
isHighlightedOnHover: true,
|
|
4306
|
-
isHighlighted:
|
|
4002
|
+
isHighlighted: scrolledToItem?.index === index$1 && scrolledToItem?.isFocused,
|
|
4307
4003
|
key: item.label,
|
|
4308
4004
|
ref: node => {
|
|
4309
4005
|
if (node) {
|
|
@@ -4312,9 +4008,9 @@ const TimeDropdown = _ref => {
|
|
|
4312
4008
|
}
|
|
4313
4009
|
},
|
|
4314
4010
|
onClick: () => onClick(index$1),
|
|
4315
|
-
"data-testid": dataTestId &&
|
|
4011
|
+
"data-testid": dataTestId && `${dataTestId}-option-${index$1}`,
|
|
4316
4012
|
className: classNames__default["default"](styles$1.option, {
|
|
4317
|
-
[styles$1.exactMatch]:
|
|
4013
|
+
[styles$1.exactMatch]: scrolledToItem?.index === index$1 && scrolledToItem.isExactMatch && !isOptionHovered
|
|
4318
4014
|
})
|
|
4319
4015
|
}, item.label))),
|
|
4320
4016
|
anchorNode: inputRef.current,
|
|
@@ -4337,11 +4033,9 @@ const formatUtcDate = (utcDate, is24HourClock) => {
|
|
|
4337
4033
|
});
|
|
4338
4034
|
const dateWithoutLeadingZeros = format(utcDate);
|
|
4339
4035
|
let dateWithLeadingZeros = dateWithoutLeadingZeros;
|
|
4340
|
-
|
|
4341
4036
|
if (dateWithLeadingZeros.split(':')[0].length === 1) {
|
|
4342
|
-
dateWithLeadingZeros =
|
|
4037
|
+
dateWithLeadingZeros = `0${dateWithLeadingZeros}`;
|
|
4343
4038
|
}
|
|
4344
|
-
|
|
4345
4039
|
return dateWithLeadingZeros.toLowerCase();
|
|
4346
4040
|
};
|
|
4347
4041
|
const convertTimeObjectToTimeString = (time, is24HourClock) => {
|
|
@@ -4352,13 +4046,11 @@ const convertTimeStringToTimeObject = completeTimeString => {
|
|
|
4352
4046
|
const [hourPart, minutePart, amPmPart] = completeTimeString.split(/:| /);
|
|
4353
4047
|
let hour = +hourPart;
|
|
4354
4048
|
const minute = +minutePart;
|
|
4355
|
-
|
|
4356
4049
|
if (amPmPart === 'am' && hour === 12) {
|
|
4357
4050
|
hour = 0;
|
|
4358
4051
|
} else if (amPmPart === 'pm' && hour < 12) {
|
|
4359
4052
|
hour += 12;
|
|
4360
4053
|
}
|
|
4361
|
-
|
|
4362
4054
|
return {
|
|
4363
4055
|
hour,
|
|
4364
4056
|
minute
|
|
@@ -4371,28 +4063,21 @@ const generateTimes = (step, is24HourClock) => {
|
|
|
4371
4063
|
return {
|
|
4372
4064
|
label: labelWithLeadingZeros,
|
|
4373
4065
|
value: i * step,
|
|
4374
|
-
id:
|
|
4066
|
+
id: `time-option-${i}`
|
|
4375
4067
|
};
|
|
4376
4068
|
});
|
|
4377
4069
|
};
|
|
4378
|
-
|
|
4379
4070
|
function getTimeStringCorrector(str, is24HourClock) {
|
|
4380
|
-
var _letterString;
|
|
4381
|
-
|
|
4382
4071
|
let [numberString, letterString] = str.replace(':', '').split(' ');
|
|
4383
|
-
letterString =
|
|
4072
|
+
letterString = letterString?.toLowerCase();
|
|
4384
4073
|
let selectionModifier = 0;
|
|
4385
|
-
|
|
4386
4074
|
const getTimeString = () => {
|
|
4387
|
-
const finalNumberString =
|
|
4388
|
-
return is24HourClock ? finalNumberString :
|
|
4075
|
+
const finalNumberString = `${numberString.slice(0, 2)}:${numberString.slice(2, 4)}`;
|
|
4076
|
+
return is24HourClock ? finalNumberString : `${finalNumberString} ${letterString}`;
|
|
4389
4077
|
};
|
|
4390
|
-
|
|
4391
4078
|
const getSelectionModifier = () => selectionModifier;
|
|
4392
|
-
|
|
4393
4079
|
const replaceDashes = () => {
|
|
4394
4080
|
numberString = numberString.replace(/-/g, '0');
|
|
4395
|
-
|
|
4396
4081
|
if (letterString) {
|
|
4397
4082
|
if (letterString[0] === '-' || letterString[0] === 'a') {
|
|
4398
4083
|
// Arbitrarily choose AM if user hasn't typed 'a' or 'p'
|
|
@@ -4402,55 +4087,39 @@ function getTimeStringCorrector(str, is24HourClock) {
|
|
|
4402
4087
|
}
|
|
4403
4088
|
}
|
|
4404
4089
|
};
|
|
4405
|
-
|
|
4406
4090
|
const shiftMinutesRight = () => {
|
|
4407
|
-
numberString =
|
|
4091
|
+
numberString = `${numberString.slice(0, 2)}0${numberString[2]}`;
|
|
4408
4092
|
selectionModifier += 1;
|
|
4409
4093
|
};
|
|
4410
|
-
|
|
4411
4094
|
const prependCharacter = character => {
|
|
4412
|
-
numberString =
|
|
4095
|
+
numberString = `${character}${numberString}`;
|
|
4413
4096
|
selectionModifier += 1;
|
|
4414
4097
|
};
|
|
4415
|
-
|
|
4416
4098
|
const setHoursTo12 = () => {
|
|
4417
|
-
numberString =
|
|
4099
|
+
numberString = `12${numberString.slice(2)}`;
|
|
4418
4100
|
};
|
|
4419
|
-
|
|
4420
4101
|
const clearSecondHoursDigit = () => {
|
|
4421
|
-
numberString =
|
|
4102
|
+
numberString = `${numberString.slice(0, 1)}0${numberString.slice(2)}`;
|
|
4422
4103
|
};
|
|
4423
|
-
|
|
4424
4104
|
const hoursAre00 = () => numberString[0] === '0' && numberString[1] === '0';
|
|
4425
|
-
|
|
4426
4105
|
const firstHourGreaterThan1 = () => {
|
|
4427
4106
|
var _context;
|
|
4428
|
-
|
|
4429
4107
|
return !_includesInstanceProperty__default["default"](_context = '01-').call(_context, numberString[0]);
|
|
4430
4108
|
};
|
|
4431
|
-
|
|
4432
4109
|
const firstHourGreaterThan2 = () => {
|
|
4433
4110
|
var _context2;
|
|
4434
|
-
|
|
4435
4111
|
return !_includesInstanceProperty__default["default"](_context2 = '012-').call(_context2, numberString[0]);
|
|
4436
4112
|
};
|
|
4437
|
-
|
|
4438
4113
|
const hoursGreaterThan12 = () => {
|
|
4439
4114
|
var _context3;
|
|
4440
|
-
|
|
4441
4115
|
return numberString[0] === '1' && !_includesInstanceProperty__default["default"](_context3 = '012-').call(_context3, numberString[1]);
|
|
4442
4116
|
};
|
|
4443
|
-
|
|
4444
4117
|
const hoursGreaterThan23 = () => {
|
|
4445
4118
|
var _context4;
|
|
4446
|
-
|
|
4447
4119
|
return numberString[0] === '2' && !_includesInstanceProperty__default["default"](_context4 = '0123-').call(_context4, numberString[1]);
|
|
4448
4120
|
};
|
|
4449
|
-
|
|
4450
4121
|
const firstMinuteGreaterThan5 = () => numberString[2] !== '-' && +numberString[2] > 5;
|
|
4451
|
-
|
|
4452
4122
|
const hasTypedMinutes = () => numberString[2] !== '-' && numberString[3] !== '-';
|
|
4453
|
-
|
|
4454
4123
|
return {
|
|
4455
4124
|
getTimeString,
|
|
4456
4125
|
getSelectionModifier,
|
|
@@ -4468,18 +4137,14 @@ function getTimeStringCorrector(str, is24HourClock) {
|
|
|
4468
4137
|
hasTypedMinutes
|
|
4469
4138
|
};
|
|
4470
4139
|
}
|
|
4471
|
-
|
|
4472
4140
|
const correct12HourTime = (time, mustCompleteTime) => {
|
|
4473
4141
|
const timeStringCorrector = getTimeStringCorrector(time, false);
|
|
4474
|
-
|
|
4475
4142
|
if (mustCompleteTime) {
|
|
4476
4143
|
timeStringCorrector.replaceDashes();
|
|
4477
4144
|
}
|
|
4478
|
-
|
|
4479
4145
|
if (timeStringCorrector.firstHourGreaterThan1()) {
|
|
4480
4146
|
timeStringCorrector.prependCharacter('0');
|
|
4481
4147
|
}
|
|
4482
|
-
|
|
4483
4148
|
if (timeStringCorrector.hoursGreaterThan12()) {
|
|
4484
4149
|
if (timeStringCorrector.hasTypedMinutes()) {
|
|
4485
4150
|
// User likely just edited the first digit and that made the
|
|
@@ -4492,30 +4157,24 @@ const correct12HourTime = (time, mustCompleteTime) => {
|
|
|
4492
4157
|
timeStringCorrector.prependCharacter('0');
|
|
4493
4158
|
}
|
|
4494
4159
|
}
|
|
4495
|
-
|
|
4496
4160
|
if (timeStringCorrector.hoursAre00()) {
|
|
4497
4161
|
timeStringCorrector.setHoursTo12();
|
|
4498
4162
|
}
|
|
4499
|
-
|
|
4500
4163
|
if (timeStringCorrector.firstMinuteGreaterThan5()) {
|
|
4501
4164
|
// Assume the user forgot a 0
|
|
4502
4165
|
// Example: we are changing 12:6- to 12:06
|
|
4503
4166
|
timeStringCorrector.shiftMinutesRight();
|
|
4504
4167
|
}
|
|
4505
|
-
|
|
4506
4168
|
return {
|
|
4507
4169
|
correctedTime: timeStringCorrector.getTimeString(),
|
|
4508
4170
|
selectionModifier: timeStringCorrector.getSelectionModifier()
|
|
4509
4171
|
};
|
|
4510
4172
|
};
|
|
4511
|
-
|
|
4512
4173
|
const correct24HourTime = (time, mustCompleteTime) => {
|
|
4513
4174
|
const timeStringCorrector = getTimeStringCorrector(time, true);
|
|
4514
|
-
|
|
4515
4175
|
if (mustCompleteTime) {
|
|
4516
4176
|
timeStringCorrector.replaceDashes();
|
|
4517
4177
|
}
|
|
4518
|
-
|
|
4519
4178
|
if (timeStringCorrector.hoursGreaterThan23()) {
|
|
4520
4179
|
// User likely just edited the first digit and that made the second
|
|
4521
4180
|
// digit invalid, e.g., changed '15:' to '25:'. They probably
|
|
@@ -4528,29 +4187,26 @@ const correct24HourTime = (time, mustCompleteTime) => {
|
|
|
4528
4187
|
timeStringCorrector.prependCharacter('0');
|
|
4529
4188
|
}
|
|
4530
4189
|
}
|
|
4531
|
-
|
|
4532
4190
|
if (timeStringCorrector.firstHourGreaterThan2()) {
|
|
4533
4191
|
// Assume the user forgot a leading 0
|
|
4534
4192
|
// Example: we are changing '3-:--' to '03:--'
|
|
4535
4193
|
timeStringCorrector.prependCharacter('0');
|
|
4536
4194
|
}
|
|
4537
|
-
|
|
4538
4195
|
if (timeStringCorrector.firstMinuteGreaterThan5()) {
|
|
4539
4196
|
// Assume the user forgot a 0
|
|
4540
4197
|
// Example: we are changing 12:6- to 12:06
|
|
4541
4198
|
timeStringCorrector.shiftMinutesRight();
|
|
4542
4199
|
}
|
|
4543
|
-
|
|
4544
4200
|
return {
|
|
4545
4201
|
correctedTime: timeStringCorrector.getTimeString(),
|
|
4546
4202
|
selectionModifier: timeStringCorrector.getSelectionModifier()
|
|
4547
4203
|
};
|
|
4548
|
-
};
|
|
4204
|
+
};
|
|
4205
|
+
|
|
4206
|
+
// We will follow the same process to correct the time regardless
|
|
4549
4207
|
// of what specific character changed.
|
|
4550
4208
|
// This simplifies logic for when multiple chars are pasted in
|
|
4551
4209
|
// and for when the input has to be shifted due to invalid entries.
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
4210
|
const correctTime = (time, is24HourClock, mustCompleteTime) => is24HourClock ? correct24HourTime(time, mustCompleteTime) : correct12HourTime(time, mustCompleteTime);
|
|
4555
4211
|
|
|
4556
4212
|
const TimeInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
@@ -4594,8 +4250,7 @@ const TimeInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
4594
4250
|
correctedTime,
|
|
4595
4251
|
selectionModifier
|
|
4596
4252
|
} = correctTime(next.value, is24HourClock, false);
|
|
4597
|
-
const newSelection = next
|
|
4598
|
-
|
|
4253
|
+
const newSelection = next?.selection;
|
|
4599
4254
|
if (newSelection) {
|
|
4600
4255
|
const validTimeLength = mask.length;
|
|
4601
4256
|
newSelection.start = shouldMoveSelectionToEnd ? validTimeLength : newSelection.start;
|
|
@@ -4603,9 +4258,9 @@ const TimeInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
4603
4258
|
newSelection.start = Math.min(newSelection.start + selectionModifier, validTimeLength);
|
|
4604
4259
|
newSelection.end = Math.min(newSelection.end + selectionModifier, validTimeLength);
|
|
4605
4260
|
}
|
|
4606
|
-
|
|
4607
4261
|
setShouldMoveSelectionToEnd(false);
|
|
4608
|
-
return {
|
|
4262
|
+
return {
|
|
4263
|
+
...next,
|
|
4609
4264
|
value: correctedTime,
|
|
4610
4265
|
selection: newSelection
|
|
4611
4266
|
};
|
|
@@ -4627,7 +4282,7 @@ const TimeInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
4627
4282
|
"aria-labelledby": ariaLabelledBy,
|
|
4628
4283
|
"aria-describedby": ariaDescribedBy,
|
|
4629
4284
|
"aria-activedescendant": ariaActiveDescendant,
|
|
4630
|
-
"data-testid": dataTestId &&
|
|
4285
|
+
"data-testid": dataTestId && `${dataTestId}-input`
|
|
4631
4286
|
}));
|
|
4632
4287
|
});
|
|
4633
4288
|
|
|
@@ -4648,10 +4303,8 @@ const TimePickerIcon = _ref => {
|
|
|
4648
4303
|
})
|
|
4649
4304
|
}, /*#__PURE__*/React__default["default"].createElement(icons_index.ChevronDownIcon, {
|
|
4650
4305
|
onClick: !isDisabled ? () => {
|
|
4651
|
-
var _inputRef$current;
|
|
4652
|
-
|
|
4653
4306
|
setIsFlyoutOpen(i => !i);
|
|
4654
|
-
|
|
4307
|
+
inputRef.current?.focus();
|
|
4655
4308
|
} : undefined,
|
|
4656
4309
|
onMouseDown: e => e.preventDefault(),
|
|
4657
4310
|
ref: iconRef
|
|
@@ -4667,7 +4320,6 @@ const DEFAULT_TIME = (() => {
|
|
|
4667
4320
|
minute
|
|
4668
4321
|
};
|
|
4669
4322
|
})();
|
|
4670
|
-
|
|
4671
4323
|
const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
|
|
4672
4324
|
let {
|
|
4673
4325
|
value: externalValue,
|
|
@@ -4682,12 +4334,13 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4682
4334
|
'aria-describedby': ariaDescribedBy
|
|
4683
4335
|
} = _ref;
|
|
4684
4336
|
const timePickerId = index.useId(externalId);
|
|
4685
|
-
const inputId =
|
|
4686
|
-
const dropdownId =
|
|
4337
|
+
const inputId = `${timePickerId}-input`;
|
|
4338
|
+
const dropdownId = `${timePickerId}-dropdown`;
|
|
4687
4339
|
const [isOptionHovered, setIsOptionHovered] = React.useState(false);
|
|
4688
4340
|
const [timeObject, setTimeObject] = index.useControllableState(DEFAULT_TIME, externalOnChange, externalValue);
|
|
4689
|
-
const defaultTimeString = convertTimeObjectToTimeString(timeObject, is24HourClock);
|
|
4341
|
+
const defaultTimeString = convertTimeObjectToTimeString(timeObject, is24HourClock);
|
|
4690
4342
|
|
|
4343
|
+
// timeString needs its own state instead of always being derived from timeObject, since typing doesn't "commit" a new time.
|
|
4691
4344
|
const [timeString, setTimeString] = React.useState(defaultTimeString);
|
|
4692
4345
|
const [isTimeStringDirty, setIsTimeStringDirty] = React.useState(false);
|
|
4693
4346
|
const step = 60 * 30;
|
|
@@ -4698,11 +4351,10 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4698
4351
|
} = correctTime(typedTime, is24HourClock, true);
|
|
4699
4352
|
const correctedTimeObject = convertTimeStringToTimeObject(correctedTime);
|
|
4700
4353
|
const correctedTimeValue = correctedTimeObject.hour * 60 * 60 + correctedTimeObject.minute * 60;
|
|
4701
|
-
let minDistance = correctedTimeValue - dropdownItems[0].value;
|
|
4702
|
-
|
|
4354
|
+
let minDistance = correctedTimeValue - dropdownItems[0].value;
|
|
4355
|
+
// Substring search up to first empty spot
|
|
4703
4356
|
for (let i = 1; i < dropdownItems.length; i += 1) {
|
|
4704
4357
|
const distance = correctedTimeValue - dropdownItems[i].value;
|
|
4705
|
-
|
|
4706
4358
|
if (distance > minDistance || distance < 0) {
|
|
4707
4359
|
return {
|
|
4708
4360
|
index: i - 1,
|
|
@@ -4710,10 +4362,8 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4710
4362
|
isExactMatch: minDistance === 0
|
|
4711
4363
|
};
|
|
4712
4364
|
}
|
|
4713
|
-
|
|
4714
4365
|
minDistance = distance;
|
|
4715
4366
|
}
|
|
4716
|
-
|
|
4717
4367
|
return {
|
|
4718
4368
|
index: dropdownItems.length - 1,
|
|
4719
4369
|
isFocused: false,
|
|
@@ -4721,8 +4371,9 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4721
4371
|
};
|
|
4722
4372
|
}, [is24HourClock, dropdownItems]);
|
|
4723
4373
|
const [scrolledToItem, setScrolledToItem] = React.useState(() => getScrolledToItemFromTimeString(timeString));
|
|
4724
|
-
const [shouldMoveSelectionToEnd, setShouldMoveSelectionToEnd] = React.useState(true);
|
|
4374
|
+
const [shouldMoveSelectionToEnd, setShouldMoveSelectionToEnd] = React.useState(true);
|
|
4725
4375
|
|
|
4376
|
+
// timeObject may be controlled and may change at any time, so we need to update timeString and the focused item whenever it changes.
|
|
4726
4377
|
React.useEffect(() => {
|
|
4727
4378
|
const newTimeString = convertTimeObjectToTimeString(timeObject, is24HourClock);
|
|
4728
4379
|
setTimeString(newTimeString);
|
|
@@ -4730,8 +4381,9 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4730
4381
|
setShouldMoveSelectionToEnd(true);
|
|
4731
4382
|
setScrolledToItem(getScrolledToItemFromTimeString(newTimeString));
|
|
4732
4383
|
}, [timeObject, is24HourClock, getScrolledToItemFromTimeString]);
|
|
4733
|
-
const [isFlyoutOpen, setIsFlyoutOpen] = React.useState(false);
|
|
4384
|
+
const [isFlyoutOpen, setIsFlyoutOpen] = React.useState(false);
|
|
4734
4385
|
|
|
4386
|
+
// Sets the actual time object and updates the flyout and focus state
|
|
4735
4387
|
const commitTimeString = function () {
|
|
4736
4388
|
let newTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : timeString;
|
|
4737
4389
|
const {
|
|
@@ -4741,12 +4393,10 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4741
4393
|
setTimeObject(newTimeObject);
|
|
4742
4394
|
setIsFlyoutOpen(false);
|
|
4743
4395
|
};
|
|
4744
|
-
|
|
4745
4396
|
const inputRef = React.useRef(null);
|
|
4746
4397
|
const dropdownRef = React.useRef(null);
|
|
4747
4398
|
const iconRef = React.useRef(null);
|
|
4748
4399
|
index.useClickOutside([inputRef, dropdownRef, iconRef], () => isTimeStringDirty ? commitTimeString() : setIsFlyoutOpen(false));
|
|
4749
|
-
|
|
4750
4400
|
const focusNext = () => {
|
|
4751
4401
|
setScrolledToItem(f => {
|
|
4752
4402
|
if (!f.isFocused) {
|
|
@@ -4758,11 +4408,9 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4758
4408
|
isExactMatch: false
|
|
4759
4409
|
};
|
|
4760
4410
|
}
|
|
4761
|
-
|
|
4762
4411
|
if (f.index === dropdownItems.length - 1) {
|
|
4763
4412
|
return f;
|
|
4764
4413
|
}
|
|
4765
|
-
|
|
4766
4414
|
return {
|
|
4767
4415
|
index: f.index + 1,
|
|
4768
4416
|
isFocused: true,
|
|
@@ -4770,7 +4418,6 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4770
4418
|
};
|
|
4771
4419
|
});
|
|
4772
4420
|
};
|
|
4773
|
-
|
|
4774
4421
|
const focusPrevious = () => {
|
|
4775
4422
|
setScrolledToItem(f => {
|
|
4776
4423
|
if (!f.isFocused) {
|
|
@@ -4782,11 +4429,9 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4782
4429
|
isExactMatch: false
|
|
4783
4430
|
};
|
|
4784
4431
|
}
|
|
4785
|
-
|
|
4786
4432
|
if (f.index === 0) {
|
|
4787
4433
|
return f;
|
|
4788
4434
|
}
|
|
4789
|
-
|
|
4790
4435
|
return {
|
|
4791
4436
|
index: f.index - 1,
|
|
4792
4437
|
isFocused: true,
|
|
@@ -4794,20 +4439,17 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4794
4439
|
};
|
|
4795
4440
|
});
|
|
4796
4441
|
};
|
|
4797
|
-
|
|
4798
4442
|
const handleType = typedTime => {
|
|
4799
4443
|
setIsFlyoutOpen(true);
|
|
4800
4444
|
setTimeString(typedTime);
|
|
4801
4445
|
setIsTimeStringDirty(true);
|
|
4802
4446
|
setScrolledToItem(getScrolledToItemFromTimeString(typedTime));
|
|
4803
4447
|
};
|
|
4804
|
-
|
|
4805
4448
|
const handleSelectTime = selectedIndex => {
|
|
4806
4449
|
const timeLabel = dropdownItems[selectedIndex].label;
|
|
4807
4450
|
setIsOptionHovered(false);
|
|
4808
4451
|
commitTimeString(timeLabel);
|
|
4809
4452
|
};
|
|
4810
|
-
|
|
4811
4453
|
const handleKeyDown = e => {
|
|
4812
4454
|
switch (e.key) {
|
|
4813
4455
|
case 'ArrowUp':
|
|
@@ -4815,44 +4457,37 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4815
4457
|
setIsFlyoutOpen(true);
|
|
4816
4458
|
focusPrevious();
|
|
4817
4459
|
break;
|
|
4818
|
-
|
|
4819
4460
|
case 'ArrowDown':
|
|
4820
4461
|
e.preventDefault();
|
|
4821
4462
|
setIsFlyoutOpen(true);
|
|
4822
4463
|
focusNext();
|
|
4823
4464
|
break;
|
|
4824
|
-
|
|
4825
4465
|
case 'Enter':
|
|
4826
4466
|
e.preventDefault();
|
|
4827
|
-
|
|
4828
|
-
if (scrolledToItem !== null && scrolledToItem !== void 0 && scrolledToItem.isFocused) {
|
|
4467
|
+
if (scrolledToItem?.isFocused) {
|
|
4829
4468
|
// "focus" is on the listbox
|
|
4830
4469
|
handleSelectTime(scrolledToItem.index);
|
|
4831
4470
|
} else {
|
|
4832
4471
|
// "focus" is on the input
|
|
4833
4472
|
commitTimeString();
|
|
4834
4473
|
}
|
|
4835
|
-
|
|
4836
4474
|
break;
|
|
4837
|
-
|
|
4838
4475
|
case 'Escape':
|
|
4839
4476
|
case 'Tab':
|
|
4840
4477
|
// use whatever time is closest to what's in the input
|
|
4841
4478
|
commitTimeString();
|
|
4842
4479
|
break;
|
|
4843
|
-
|
|
4844
4480
|
default:
|
|
4845
4481
|
break;
|
|
4846
4482
|
}
|
|
4847
4483
|
};
|
|
4848
|
-
|
|
4849
4484
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
4850
4485
|
id: timePickerId,
|
|
4851
4486
|
className: styles$1.container
|
|
4852
4487
|
}, /*#__PURE__*/React__default["default"].createElement(TimeInput, {
|
|
4853
4488
|
id: inputId,
|
|
4854
4489
|
dataTestId: dataTestId,
|
|
4855
|
-
ariaActiveDescendant: isFlyoutOpen && scrolledToItem
|
|
4490
|
+
ariaActiveDescendant: isFlyoutOpen && scrolledToItem?.isFocused ? dropdownItems[scrolledToItem.index].id : undefined,
|
|
4856
4491
|
ariaControls: dropdownId,
|
|
4857
4492
|
ariaExpanded: isFlyoutOpen,
|
|
4858
4493
|
onChange: handleType,
|
|
@@ -4896,9 +4531,9 @@ const {
|
|
|
4896
4531
|
Provider: ToggleButtonGroupContextProvider
|
|
4897
4532
|
} = index.createContextUtilities(null);
|
|
4898
4533
|
|
|
4899
|
-
var css_248z = ".
|
|
4900
|
-
var styles = {"default":"
|
|
4901
|
-
var stylesheet=".
|
|
4534
|
+
var css_248z = "._dQ2H3{border-color:transparent;background-color:transparent;color:#515559;cursor:pointer}._UHCUT{background-color:rgba(50,54,58,.08)}._IxOqH{color:#0b6ed0;background-color:rgba(11,110,208,.08)}._ViMDu{color:rgba(81,85,89,.4);cursor:not-allowed}._XfgD-{background:rgba(11,110,208,.08);color:#0b6ed0;border-color:#0b6ed0}._sjPfz{color:#085caf;border-color:#085caf}._sBKSB,._sjPfz{background:rgba(11,110,208,.11)}._sBKSB{color:#0854a1;border-color:#0854a1}._6-jnb{background:rgba(11,110,208,.032);color:rgba(11,110,208,.4);border-color:rgba(11,110,208,.4)}._MqILq{position:relative;display:inline-grid}._MqILq svg{fill:currentColor}._MqILq ._SZYjR{-webkit-appearance:none;-moz-appearance:none;appearance:none;grid-column:1;grid-row:1}._MqILq ._SZYjR+._-GaoZ{background-color:transparent;color:#515559;cursor:pointer;border:1px solid transparent;border-radius:4px;grid-column:1;grid-row:1;padding:0;min-width:76px;-webkit-user-select:none;-moz-user-select:none;user-select:none}._MqILq ._SZYjR+._-GaoZ._hPlTe{padding:5px;max-width:36px;min-width:36px}._MqILq ._SZYjR+._-GaoZ._Ikzts{padding:0 16px}._MqILq ._SZYjR+._-GaoZ._6-26f{padding:0 16px 0 12px}._MqILq ._SZYjR:hover+._-GaoZ{background-color:rgba(50,54,58,.08)}._MqILq ._SZYjR:disabled+._-GaoZ{color:rgba(81,85,89,.4);cursor:not-allowed}._MqILq ._SZYjR:active+._-GaoZ,._MqILq ._SZYjR:focus:active+._-GaoZ{color:#0b6ed0;background-color:rgba(11,110,208,.08)}._MqILq ._SZYjR:checked+._-GaoZ{background:rgba(11,110,208,.08);color:#0b6ed0;border-color:#0b6ed0}._MqILq ._SZYjR:checked:hover+._-GaoZ{background:rgba(11,110,208,.11);color:#085caf;border-color:#085caf}._MqILq ._SZYjR:checked:disabled+._-GaoZ{background:rgba(11,110,208,.032);color:rgba(11,110,208,.4);border-color:rgba(11,110,208,.4)}._MqILq ._SZYjR:checked:active+._-GaoZ,._MqILq ._SZYjR:checked:focus:active+._-GaoZ{background:rgba(11,110,208,.11);color:#0854a1;border-color:#0854a1}._RRJux{display:inline-flex;position:relative}._RRJux:before{content:\"\";border:1px solid #d9d9d9;border-radius:4px;position:absolute;top:0;bottom:0;right:0;left:0}._RRJux>*{flex-shrink:0;flex-grow:0}._VbbII{border:none;margin:0;padding:0}._VbbII legend{padding:0;display:block;font-size:14px;margin-bottom:6px;color:#515559}body.keyboard-user ._MqILq ._SZYjR:active:focus+._-GaoZ,body.keyboard-user ._MqILq ._SZYjR:focus+._-GaoZ{z-index:20;outline:none;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
|
|
4535
|
+
var styles = {"default":"_dQ2H3","hovered":"_UHCUT","pressed":"_IxOqH","disabled":"_ViMDu","selectedDefault":"_XfgD-","selectedHovered":"_sjPfz","selectedPressed":"_sBKSB","selectedDisabled":"_6-jnb","toggleContainer":"_MqILq","toggleInput":"_SZYjR","toggleButton":"_-GaoZ","iconOnly":"_hPlTe","text":"_Ikzts","iconText":"_6-26f","toggleButtonGroup":"_RRJux","toggleButtonGroupFieldset":"_VbbII"};
|
|
4536
|
+
var stylesheet="._dQ2H3{border-color:transparent;background-color:transparent;color:#515559;cursor:pointer}._UHCUT{background-color:rgba(50,54,58,.08)}._IxOqH{color:#0b6ed0;background-color:rgba(11,110,208,.08)}._ViMDu{color:rgba(81,85,89,.4);cursor:not-allowed}._XfgD-{background:rgba(11,110,208,.08);color:#0b6ed0;border-color:#0b6ed0}._sjPfz{color:#085caf;border-color:#085caf}._sBKSB,._sjPfz{background:rgba(11,110,208,.11)}._sBKSB{color:#0854a1;border-color:#0854a1}._6-jnb{background:rgba(11,110,208,.032);color:rgba(11,110,208,.4);border-color:rgba(11,110,208,.4)}._MqILq{position:relative;display:inline-grid}._MqILq svg{fill:currentColor}._MqILq ._SZYjR{-webkit-appearance:none;-moz-appearance:none;appearance:none;grid-column:1;grid-row:1}._MqILq ._SZYjR+._-GaoZ{background-color:transparent;color:#515559;cursor:pointer;border:1px solid transparent;border-radius:4px;grid-column:1;grid-row:1;padding:0;min-width:76px;-webkit-user-select:none;-moz-user-select:none;user-select:none}._MqILq ._SZYjR+._-GaoZ._hPlTe{padding:5px;max-width:36px;min-width:36px}._MqILq ._SZYjR+._-GaoZ._Ikzts{padding:0 16px}._MqILq ._SZYjR+._-GaoZ._6-26f{padding:0 16px 0 12px}._MqILq ._SZYjR:hover+._-GaoZ{background-color:rgba(50,54,58,.08)}._MqILq ._SZYjR:disabled+._-GaoZ{color:rgba(81,85,89,.4);cursor:not-allowed}._MqILq ._SZYjR:active+._-GaoZ,._MqILq ._SZYjR:focus:active+._-GaoZ{color:#0b6ed0;background-color:rgba(11,110,208,.08)}._MqILq ._SZYjR:checked+._-GaoZ{background:rgba(11,110,208,.08);color:#0b6ed0;border-color:#0b6ed0}._MqILq ._SZYjR:checked:hover+._-GaoZ{background:rgba(11,110,208,.11);color:#085caf;border-color:#085caf}._MqILq ._SZYjR:checked:disabled+._-GaoZ{background:rgba(11,110,208,.032);color:rgba(11,110,208,.4);border-color:rgba(11,110,208,.4)}._MqILq ._SZYjR:checked:active+._-GaoZ,._MqILq ._SZYjR:checked:focus:active+._-GaoZ{background:rgba(11,110,208,.11);color:#0854a1;border-color:#0854a1}._RRJux{display:inline-flex;position:relative}._RRJux:before{content:\"\";border:1px solid #d9d9d9;border-radius:4px;position:absolute;top:0;bottom:0;right:0;left:0}._RRJux>*{flex-shrink:0;flex-grow:0}._VbbII{border:none;margin:0;padding:0}._VbbII legend{padding:0;display:block;font-size:14px;margin-bottom:6px;color:#515559}body.keyboard-user ._MqILq ._SZYjR:active:focus+._-GaoZ,body.keyboard-user ._MqILq ._SZYjR:focus+._-GaoZ{z-index:20;outline:none;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
|
|
4902
4537
|
icons_index.styleInject(css_248z);
|
|
4903
4538
|
|
|
4904
4539
|
const ToggleButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
@@ -4922,7 +4557,8 @@ const ToggleButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
4922
4557
|
}
|
|
4923
4558
|
}, /*#__PURE__*/React__default["default"].createElement("fieldset", {
|
|
4924
4559
|
className: styles.toggleButtonGroupFieldset,
|
|
4925
|
-
disabled: isDisabled
|
|
4560
|
+
disabled: isDisabled
|
|
4561
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
4926
4562
|
,
|
|
4927
4563
|
role: "radiogroup",
|
|
4928
4564
|
"aria-label": ariaLabel,
|
|
@@ -4952,27 +4588,22 @@ const ToggleButton = /*#__PURE__*/React__default["default"].forwardRef((_ref, re
|
|
|
4952
4588
|
let checked = isActivated;
|
|
4953
4589
|
let disabled = isDisabled;
|
|
4954
4590
|
let name = inputName;
|
|
4955
|
-
|
|
4956
4591
|
let handleChange = () => {
|
|
4957
4592
|
if (onChange) {
|
|
4958
4593
|
onChange(checked);
|
|
4959
4594
|
}
|
|
4960
4595
|
};
|
|
4961
|
-
|
|
4962
4596
|
if (inGroup) {
|
|
4963
4597
|
checked = value === groupContext.value;
|
|
4964
4598
|
disabled = groupContext.isDisabled || isDisabled;
|
|
4965
4599
|
name = groupContext.name;
|
|
4966
|
-
|
|
4967
4600
|
handleChange = () => {
|
|
4968
4601
|
if (onChange) {
|
|
4969
4602
|
onChange(checked);
|
|
4970
4603
|
}
|
|
4971
|
-
|
|
4972
4604
|
groupContext.onChange(value);
|
|
4973
4605
|
};
|
|
4974
4606
|
}
|
|
4975
|
-
|
|
4976
4607
|
return /*#__PURE__*/React__default["default"].createElement("span", {
|
|
4977
4608
|
ref: ref,
|
|
4978
4609
|
className: styles.toggleContainer
|
|
@@ -5054,7 +4685,6 @@ const convertAlignment = alignment => {
|
|
|
5054
4685
|
};
|
|
5055
4686
|
return alignmentMap[alignment];
|
|
5056
4687
|
};
|
|
5057
|
-
|
|
5058
4688
|
// Explicitly listed props to prevent arbitrary prop spreading
|
|
5059
4689
|
const Stack = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
5060
4690
|
let {
|
|
@@ -5083,13 +4713,11 @@ const Stack = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
5083
4713
|
'aria-describedby': ariaDescribedBy,
|
|
5084
4714
|
'data-testid': dataTestId
|
|
5085
4715
|
} = _ref;
|
|
5086
|
-
|
|
5087
4716
|
const checkIsStackItem = child => {
|
|
5088
4717
|
if (!(child.type && (child.type === StackItem || child.type === HStack || child.type === VStack))) {
|
|
5089
4718
|
throw new Error('Stack received an invalid child. Only StackItems are valid children of Stacks.');
|
|
5090
4719
|
}
|
|
5091
4720
|
};
|
|
5092
|
-
|
|
5093
4721
|
React.useEffect(() => {
|
|
5094
4722
|
if (Array.isArray(children)) {
|
|
5095
4723
|
children.forEach(child => {
|