@qualtrics/ui-react 2.19.0 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/dist/__shared/cjs/{index-bf07471d.js → index-579c4690.js} +10 -7
- package/dist/__shared/cjs/{index-4e4cc354.js → index-90d4069b.js} +999 -1875
- package/dist/components/Accordion/Accordion.js +1 -5
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/Accordion/AccordionHeader.js +8 -10
- 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 +13 -42
- 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 +4 -3
- 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/MenuButton.js +13 -6
- 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.d.ts +5 -4
- package/dist/next/index.js +389 -754
- 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-90d4069b.js');
|
|
13
|
+
var icons_index = require('../__shared/cjs/index-579c4690.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 = "._y6IPO{overflow:auto;position:relative;max-width:100%;max-height:100%}._eLW3D,._y6IPO{background-color:#fff}._eLW3D{height:70px;z-index:100;display:flex;align-items:flex-end;justify-content:center;position:sticky;left:0}._fMRlc{margin-bottom:4px}._R5dF-{position:sticky;top:0;z-index:100}._LcNei{display:flex}._LcNei:focus{outline:none}body.keyboard-user ._LcNei:focus ._xiVGF: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 ._LcNei:focus ._xiVGF:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._LcNei:focus ._xiVGF:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._LcNei:focus ._xiVGF._C9aKv:after{right:-3px;bottom:1px}._-n1z3{padding-right:3px}._LLZfo{display:flex}._LLZfo._SSaoO ._S8g7r,._LLZfo._SSaoO ._xiVGF{cursor:pointer}._LLZfo._c5VPU ._S8g7r,._LLZfo._c5VPU ._xiVGF{background-color:rgba(11,110,208,.08);font-weight:500;box-shadow:inset 0 -1px 0 0 #0b6ed0}._LLZfo._c5VPU ._S8g7r._C9aKv,._LLZfo._c5VPU ._xiVGF._C9aKv{background-color:#fff;box-shadow:inset 0 -2px 0 0 #0b6ed0}._LLZfo._c5VPU ._S8g7r._C9aKv ._B-WjT,._LLZfo._c5VPU ._S8g7r._C9aKv ._JDRrf,._LLZfo._c5VPU ._S8g7r._C9aKv ._S8g7r,._LLZfo._c5VPU ._xiVGF._C9aKv ._B-WjT,._LLZfo._c5VPU ._xiVGF._C9aKv ._JDRrf,._LLZfo._c5VPU ._xiVGF._C9aKv ._S8g7r{background-color:rgba(11,110,208,.08)}._LLZfo._SSaoO:hover:not(._c5VPU):not(._enirl) ._S8g7r,._LLZfo._SSaoO:hover:not(._c5VPU):not(._enirl) ._xiVGF{background-color:#f9f9f9}._LLZfo._SSaoO:active:not(._c5VPU):not(._enirl) ._S8g7r,._LLZfo._SSaoO:active:not(._c5VPU):not(._enirl) ._xiVGF{background-color:#f3f3f3}._LLZfo:focus{outline:none}body.keyboard-user ._LLZfo:focus ._xiVGF: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 ._LLZfo:focus ._xiVGF:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._LLZfo:focus ._xiVGF:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._LLZfo:focus ._xiVGF._C9aKv:after{right:-3px;bottom:0}._LLZfo:last-of-type:focus{outline:none}body.keyboard-user ._LLZfo:last-of-type:focus ._xiVGF: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 ._LLZfo:last-of-type:focus ._xiVGF:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._LLZfo:last-of-type:focus ._xiVGF:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._LLZfo:last-of-type:focus ._xiVGF._C9aKv:after{right:-3px;bottom:1px}._LLZfo:last-of-type ._JDRrf:focus{outline:none}body.keyboard-user ._LLZfo:last-of-type ._JDRrf._hxpYA:after,body.keyboard-user ._LLZfo:last-of-type ._JDRrf: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}._LLZfo:first-of-type:focus{outline:none}body.keyboard-user ._LLZfo:first-of-type:focus ._xiVGF: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 ._LLZfo:first-of-type:focus ._xiVGF:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._LLZfo:first-of-type:focus ._xiVGF:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._LLZfo:first-of-type:focus ._xiVGF._C9aKv:after{right:-3px;bottom:0}._LLZfo:first-of-type ._JDRrf:focus{outline:none}body.keyboard-user ._LLZfo:first-of-type ._JDRrf._hxpYA:after,body.keyboard-user ._LLZfo:first-of-type ._JDRrf: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}._mI5Tb{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}._mI5Tb._wpx-6{flex-grow:1}._mI5Tb._Qm8VB{cursor:pointer}._mI5Tb._Qm8VB:hover:not(._t4ws-){background-color:#f9f9f9;border-bottom-color:#6a6d70}._mI5Tb._Qm8VB:active:not(._t4ws-){background-color:#f3f3f3}._mI5Tb._kekjL:not(._t4ws-){color:#32363a;fill:#32363a;border-bottom-color:#8a8f94}._mI5Tb._t4ws-{cursor:move;background-color:#efefef;border-bottom-color:#ccc;border-top-left-radius:4px;border-top-right-radius:4px}._mI5Tb ._CSHW0{background-color:#d9d9d9;position:absolute;width:1px;top:0;pointer-events:none}._mI5Tb ._CSHW0._0cS8F{left:-1px}._mI5Tb ._CSHW0._Xefhu{right:0}._mI5Tb ._ViJD-{background-color:#0a6ed1;position:absolute;width:3px;top:4px;bottom:4px;border-radius:4px;pointer-events:none}._mI5Tb ._ViJD-._0cS8F{left:-2px}._mI5Tb ._ViJD-._Xefhu{right:-1px}._mI5Tb:first-of-type ._0cS8F._CSHW0{left:0;width:2px;border-left:1px solid #fff}._mI5Tb:first-of-type ._0cS8F._ViJD-{left:0}._mI5Tb:last-of-type ._Xefhu._CSHW0{right:0;width:2px;border-right:1px solid #fff}._mI5Tb:last-of-type ._Xefhu._ViJD-{right:0}._mI5Tb ._SHZL3{position:absolute;width:6px;right:-3px;top:0;cursor:ew-resize;z-index:50}._mI5Tb ._SHZL3 ._MjxLB{position:absolute;width:2px;right:2px;top:0;bottom:0}._mI5Tb ._SHZL3 ._MjxLB._BhSpS{background-color:#0a6ed1}._mI5Tb ._SHZL3:hover ._MjxLB:not(._BhSpS){background-color:#d9d9d9}._mI5Tb ._A93nF{display:flex;flex-grow:1;align-items:center;min-width:0;padding:14px 0 13px 12px}._mI5Tb ._A93nF._JmCZv{flex-direction:row-reverse;justify-content:flex-start}._mI5Tb ._A93nF._JmCZv ._gSscp{margin:1px 7px 1px 1px}._mI5Tb ._A93nF ._YDSVm{text-overflow:ellipsis;overflow:hidden;-webkit-hyphens:auto;hyphens:auto;pointer-events:none;overflow-wrap:break-word;display:-webkit-box;-webkit-box-orient:vertical}._mI5Tb ._A93nF ._gSscp{margin:1px 1px 1px 7px;flex-shrink:0}._mI5Tb ._IF7re{margin-left:6px;margin-right:4px;flex-shrink:0}._mI5Tb ._RAYRH{pointer-events:none;position:absolute;top:0;left:0;bottom:0;right:0}._mI5Tb:focus{outline:none}body.keyboard-user ._mI5Tb._hxpYA:after,body.keyboard-user ._mI5Tb: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}._kYT41{margin-right:6px}._C9aKv{display:flex;border-right:3px solid #e5e5e5;position:sticky;left:0;background-color:#fff;z-index:20}._C9aKv[focus-within]{z-index:30}._C9aKv:focus-within{z-index:30}._JDRrf{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}._JDRrf ._j5pr3{width:100%;padding:12px 12px 11px;overflow:hidden}._JDRrf._t4ws-{background-color:#efefef;border-bottom-color:#dfdfe1}._JDRrf._wpx-6{flex-grow:1}._JDRrf:focus{outline:none}body.keyboard-user ._JDRrf._hxpYA:after,body.keyboard-user ._JDRrf: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}._S8g7r{display:flex!important;min-height:44px!important;align-items:center;justify-content:right;border-bottom:1px solid #eee;flex-shrink:0}._S8g7r._kpRMd{border-bottom-color:#d9d9d9;background-color:#fff}._B-WjT{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}._B-WjT._kpRMd{border-bottom-color:#d9d9d9;padding:14px 12px 13px}._B-WjT:focus input~span,._B-WjT:hover input~span{border-color:#0b6ed0}._B-WjT ._C8Dch{position:relative;display:inline-flex}._B-WjT ._C8Dch ._xZ3WO{margin:0!important}._B-WjT ._C8Dch ._ay2Sd{position:absolute;top:3px;left:3px;height:10px;width:10px;border-radius:2px;background-color:#0b6ed0}._ihamV{justify-content:flex-start}._-PYET{justify-content:center;text-align:center}._JmCZv{justify-content:flex-end;text-align:right}._C6xBg{display:none}._Lk3Me{opacity:0;height:0;width:0;overflow:hidden}._Lk3Me,._RlQyJ{position:absolute}._RlQyJ{cursor:move;background-color:rgba(11,110,208,.08);border-radius:4px;z-index:1000;pointer-events:none}._akeWj{width:246px}";
|
|
35
|
+
var styles$a = {"advancedTable":"_y6IPO","advancedTablePaginationContainer":"_eLW3D","advancedTablePagination":"_fMRlc","advancedTableColumnHeadersRowGroup":"_R5dF-","advancedTableColumnHeaders":"_LcNei","advancedTableRowChild":"_xiVGF","pinnedContainer":"_C9aKv","advancedTableRowGroup":"_-n1z3","advancedTableRow":"_LLZfo","hasRowAction":"_SSaoO","advancedTableExpandRowSpacer":"_S8g7r","isSelected":"_c5VPU","advancedTableCheckbox":"_B-WjT","advancedTableCell":"_JDRrf","isCheckboxHovered":"_enirl","showFocusRing":"_hxpYA","advancedTableColumnHeader":"_mI5Tb","fillRemainingSpace":"_wpx-6","isSortable":"_Qm8VB","isDragging":"_t4ws-","isSorted":"_kekjL","dropTargetLine":"_CSHW0","dropTargetLeft":"_0cS8F","dropTargetRight":"_Xefhu","dropTargetMarker":"_ViJD-","resizeHandle":"_SHZL3","resizeLine":"_MjxLB","isResizing":"_BhSpS","advancedTableColumnHeaderLabel":"_A93nF","rightAligned":"_JmCZv","sortIcon":"_gSscp","advancedTableColumnHeaderLabelText":"_YDSVm","advancedTableColumnHeaderMenu":"_IF7re","advancedTableColumnHeaderMenuHiddenAnchor":"_RAYRH","advancedTableColumnHeaderMenuItemIcon":"_kYT41","advancedTableCellContainer":"_j5pr3","header":"_kpRMd","checkboxContainer":"_C8Dch","checkbox":"_xZ3WO","mixed":"_ay2Sd","leftAligned":"_ihamV","centerAligned":"_-PYET","hiddenDescription":"_C6xBg","hiddenLiveRegion":"_Lk3Me","dragPreview":"_RlQyJ","rowActionMenuPane":"_akeWj"};
|
|
36
|
+
var stylesheet$a="._y6IPO{overflow:auto;position:relative;max-width:100%;max-height:100%}._eLW3D,._y6IPO{background-color:#fff}._eLW3D{height:70px;z-index:100;display:flex;align-items:flex-end;justify-content:center;position:sticky;left:0}._fMRlc{margin-bottom:4px}._R5dF-{position:sticky;top:0;z-index:100}._LcNei{display:flex}._LcNei:focus{outline:none}body.keyboard-user ._LcNei:focus ._xiVGF: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 ._LcNei:focus ._xiVGF:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._LcNei:focus ._xiVGF:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._LcNei:focus ._xiVGF._C9aKv:after{right:-3px;bottom:1px}._-n1z3{padding-right:3px}._LLZfo{display:flex}._LLZfo._SSaoO ._S8g7r,._LLZfo._SSaoO ._xiVGF{cursor:pointer}._LLZfo._c5VPU ._S8g7r,._LLZfo._c5VPU ._xiVGF{background-color:rgba(11,110,208,.08);font-weight:500;box-shadow:inset 0 -1px 0 0 #0b6ed0}._LLZfo._c5VPU ._S8g7r._C9aKv,._LLZfo._c5VPU ._xiVGF._C9aKv{background-color:#fff;box-shadow:inset 0 -2px 0 0 #0b6ed0}._LLZfo._c5VPU ._S8g7r._C9aKv ._B-WjT,._LLZfo._c5VPU ._S8g7r._C9aKv ._JDRrf,._LLZfo._c5VPU ._S8g7r._C9aKv ._S8g7r,._LLZfo._c5VPU ._xiVGF._C9aKv ._B-WjT,._LLZfo._c5VPU ._xiVGF._C9aKv ._JDRrf,._LLZfo._c5VPU ._xiVGF._C9aKv ._S8g7r{background-color:rgba(11,110,208,.08)}._LLZfo._SSaoO:hover:not(._c5VPU):not(._enirl) ._S8g7r,._LLZfo._SSaoO:hover:not(._c5VPU):not(._enirl) ._xiVGF{background-color:#f9f9f9}._LLZfo._SSaoO:active:not(._c5VPU):not(._enirl) ._S8g7r,._LLZfo._SSaoO:active:not(._c5VPU):not(._enirl) ._xiVGF{background-color:#f3f3f3}._LLZfo:focus{outline:none}body.keyboard-user ._LLZfo:focus ._xiVGF: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 ._LLZfo:focus ._xiVGF:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._LLZfo:focus ._xiVGF:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._LLZfo:focus ._xiVGF._C9aKv:after{right:-3px;bottom:0}._LLZfo:last-of-type:focus{outline:none}body.keyboard-user ._LLZfo:last-of-type:focus ._xiVGF: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 ._LLZfo:last-of-type:focus ._xiVGF:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._LLZfo:last-of-type:focus ._xiVGF:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._LLZfo:last-of-type:focus ._xiVGF._C9aKv:after{right:-3px;bottom:1px}._LLZfo:last-of-type ._JDRrf:focus{outline:none}body.keyboard-user ._LLZfo:last-of-type ._JDRrf._hxpYA:after,body.keyboard-user ._LLZfo:last-of-type ._JDRrf: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}._LLZfo:first-of-type:focus{outline:none}body.keyboard-user ._LLZfo:first-of-type:focus ._xiVGF: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 ._LLZfo:first-of-type:focus ._xiVGF:last-of-type:after{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:2px solid #0a3f88}body.keyboard-user ._LLZfo:first-of-type:focus ._xiVGF:first-of-type:after{border-top-left-radius:2px;border-bottom-left-radius:2px;border-left:2px solid #0a3f88}body.keyboard-user ._LLZfo:first-of-type:focus ._xiVGF._C9aKv:after{right:-3px;bottom:0}._LLZfo:first-of-type ._JDRrf:focus{outline:none}body.keyboard-user ._LLZfo:first-of-type ._JDRrf._hxpYA:after,body.keyboard-user ._LLZfo:first-of-type ._JDRrf: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}._mI5Tb{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}._mI5Tb._wpx-6{flex-grow:1}._mI5Tb._Qm8VB{cursor:pointer}._mI5Tb._Qm8VB:hover:not(._t4ws-){background-color:#f9f9f9;border-bottom-color:#6a6d70}._mI5Tb._Qm8VB:active:not(._t4ws-){background-color:#f3f3f3}._mI5Tb._kekjL:not(._t4ws-){color:#32363a;fill:#32363a;border-bottom-color:#8a8f94}._mI5Tb._t4ws-{cursor:move;background-color:#efefef;border-bottom-color:#ccc;border-top-left-radius:4px;border-top-right-radius:4px}._mI5Tb ._CSHW0{background-color:#d9d9d9;position:absolute;width:1px;top:0;pointer-events:none}._mI5Tb ._CSHW0._0cS8F{left:-1px}._mI5Tb ._CSHW0._Xefhu{right:0}._mI5Tb ._ViJD-{background-color:#0a6ed1;position:absolute;width:3px;top:4px;bottom:4px;border-radius:4px;pointer-events:none}._mI5Tb ._ViJD-._0cS8F{left:-2px}._mI5Tb ._ViJD-._Xefhu{right:-1px}._mI5Tb:first-of-type ._0cS8F._CSHW0{left:0;width:2px;border-left:1px solid #fff}._mI5Tb:first-of-type ._0cS8F._ViJD-{left:0}._mI5Tb:last-of-type ._Xefhu._CSHW0{right:0;width:2px;border-right:1px solid #fff}._mI5Tb:last-of-type ._Xefhu._ViJD-{right:0}._mI5Tb ._SHZL3{position:absolute;width:6px;right:-3px;top:0;cursor:ew-resize;z-index:50}._mI5Tb ._SHZL3 ._MjxLB{position:absolute;width:2px;right:2px;top:0;bottom:0}._mI5Tb ._SHZL3 ._MjxLB._BhSpS{background-color:#0a6ed1}._mI5Tb ._SHZL3:hover ._MjxLB:not(._BhSpS){background-color:#d9d9d9}._mI5Tb ._A93nF{display:flex;flex-grow:1;align-items:center;min-width:0;padding:14px 0 13px 12px}._mI5Tb ._A93nF._JmCZv{flex-direction:row-reverse;justify-content:flex-start}._mI5Tb ._A93nF._JmCZv ._gSscp{margin:1px 7px 1px 1px}._mI5Tb ._A93nF ._YDSVm{text-overflow:ellipsis;overflow:hidden;-webkit-hyphens:auto;hyphens:auto;pointer-events:none;overflow-wrap:break-word;display:-webkit-box;-webkit-box-orient:vertical}._mI5Tb ._A93nF ._gSscp{margin:1px 1px 1px 7px;flex-shrink:0}._mI5Tb ._IF7re{margin-left:6px;margin-right:4px;flex-shrink:0}._mI5Tb ._RAYRH{pointer-events:none;position:absolute;top:0;left:0;bottom:0;right:0}._mI5Tb:focus{outline:none}body.keyboard-user ._mI5Tb._hxpYA:after,body.keyboard-user ._mI5Tb: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}._kYT41{margin-right:6px}._C9aKv{display:flex;border-right:3px solid #e5e5e5;position:sticky;left:0;background-color:#fff;z-index:20}._C9aKv[focus-within]{z-index:30}._C9aKv:focus-within{z-index:30}._JDRrf{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}._JDRrf ._j5pr3{width:100%;padding:12px 12px 11px;overflow:hidden}._JDRrf._t4ws-{background-color:#efefef;border-bottom-color:#dfdfe1}._JDRrf._wpx-6{flex-grow:1}._JDRrf:focus{outline:none}body.keyboard-user ._JDRrf._hxpYA:after,body.keyboard-user ._JDRrf: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}._S8g7r{display:flex!important;min-height:44px!important;align-items:center;justify-content:right;border-bottom:1px solid #eee;flex-shrink:0}._S8g7r._kpRMd{border-bottom-color:#d9d9d9;background-color:#fff}._B-WjT{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}._B-WjT._kpRMd{border-bottom-color:#d9d9d9;padding:14px 12px 13px}._B-WjT:focus input~span,._B-WjT:hover input~span{border-color:#0b6ed0}._B-WjT ._C8Dch{position:relative;display:inline-flex}._B-WjT ._C8Dch ._xZ3WO{margin:0!important}._B-WjT ._C8Dch ._ay2Sd{position:absolute;top:3px;left:3px;height:10px;width:10px;border-radius:2px;background-color:#0b6ed0}._ihamV{justify-content:flex-start}._-PYET{justify-content:center;text-align:center}._JmCZv{justify-content:flex-end;text-align:right}._C6xBg{display:none}._Lk3Me{opacity:0;height:0;width:0;overflow:hidden}._Lk3Me,._RlQyJ{position:absolute}._RlQyJ{cursor:move;background-color:rgba(11,110,208,.08);border-radius:4px;z-index:1000;pointer-events:none}._akeWj{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 = "._3rCa-{display:inline-block;width:36px;transition:width .25s ease-out}._HAbKN{width:100%}._tJ2WS>input{padding-right:0!important}._dZaQi>svg{fill:#515559}";
|
|
1831
|
+
var styles$9 = {"collapsibleSearchInput":"_3rCa-","searchInput":"_HAbKN","searchInputCollapsed":"_tJ2WS","iconButton":"_dZaQi"};
|
|
1832
|
+
var stylesheet$9="._3rCa-{display:inline-block;width:36px;transition:width .25s ease-out}._HAbKN{width:100%}._tJ2WS>input{padding-right:0!important}._dZaQi>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 = "._0ugqV input{padding-left:76px!important}._5fTUE input{background-color:#e5e5e5!important;color:#9d9fa1!important;cursor:not-allowed!important;-webkit-text-fill-color:#9d9fa1}._5fTUE input::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._5fTUE input::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._jzrnt{position:absolute!important;left:4px;right:4px;bottom:4px;z-index:100;width:67px;height:28px!important;border-radius:4px}._jzrnt,._jzrnt._5fTUE:hover{background-color:transparent!important}._jzrnt:hover{background-color:rgba(50,54,58,.08)!important}._jzrnt:active{background-color:rgba(50,54,58,.11)!important}._jzrnt svg{top:2px!important}._Wv-Ld{position:relative}._Qcs1E{position:absolute;top:18px;left:12px;line-height:0;font-size:14px;color:#32363a;z-index:101;pointer-events:none}";
|
|
1972
|
+
var styles$8 = {"input":"_0ugqV","disabled":"_5fTUE","dropdown":"_jzrnt","container":"_Wv-Ld","countryCode":"_Qcs1E"};
|
|
1973
|
+
var stylesheet$8="._0ugqV input{padding-left:76px!important}._5fTUE input{background-color:#e5e5e5!important;color:#9d9fa1!important;cursor:not-allowed!important;-webkit-text-fill-color:#9d9fa1}._5fTUE input::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._5fTUE input::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._jzrnt{position:absolute!important;left:4px;right:4px;bottom:4px;z-index:100;width:67px;height:28px!important;border-radius:4px}._jzrnt,._jzrnt._5fTUE:hover{background-color:transparent!important}._jzrnt:hover{background-color:rgba(50,54,58,.08)!important}._jzrnt:active{background-color:rgba(50,54,58,.11)!important}._jzrnt svg{top:2px!important}._Wv-Ld{position:relative}._Qcs1E{position:absolute;top:18px;left:12px;line-height:0;font-size:14px;color:#32363a;z-index:101;pointer-events:none}";
|
|
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 = "._LDGfS :after{background-color:#515559!important}._H0dQ0>input:focus{box-shadow:none!important;border:1px solid #898989!important}._6CJ9Z{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}._6CJ9Z ._0Ks6j ._dr1ot{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}._6CJ9Z ._0Ks6j:first-child ._91-Z5{display:none}._6CJ9Z ._3CtWe{display:flex;align-items:center;min-height:40px;padding:10px 12px;font-size:14px;color:#32363a;word-break:break-word;outline:none;cursor:pointer}._6CJ9Z ._3CtWe:hover{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._6CJ9Z ._3CtWe:hover._o9zQZ{background-color:#e4effa}._6CJ9Z ._3CtWe._o9zQZ{background-color:#ebf3fb;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._6CJ9Z ._3CtWe:active:not(._o9zQZ){background-color:#e8e9e9}";
|
|
2686
|
+
var styles$7 = {"loadingSpinner":"_LDGfS","ignoreFocusStyle":"_H0dQ0","flyout":"_6CJ9Z","group":"_0Ks6j","header":"_dr1ot","divider":"_91-Z5","option":"_3CtWe","selected":"_o9zQZ"};
|
|
2687
|
+
var stylesheet$7="._LDGfS :after{background-color:#515559!important}._H0dQ0>input:focus{box-shadow:none!important;border:1px solid #898989!important}._6CJ9Z{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}._6CJ9Z ._0Ks6j ._dr1ot{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}._6CJ9Z ._0Ks6j:first-child ._91-Z5{display:none}._6CJ9Z ._3CtWe{display:flex;align-items:center;min-height:40px;padding:10px 12px;font-size:14px;color:#32363a;word-break:break-word;outline:none;cursor:pointer}._6CJ9Z ._3CtWe:hover{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._6CJ9Z ._3CtWe:hover._o9zQZ{background-color:#e4effa}._6CJ9Z ._3CtWe._o9zQZ{background-color:#ebf3fb;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._6CJ9Z ._3CtWe:active:not(._o9zQZ){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 = "._m7pGf{display:flex}._QN3kF{z-index:2;width:1px;margin-left:-1px;margin-right:-1px}._QN3kF._rQAGM{background-color:#fff}._QN3kF._rQAGM._eo5P0:not(._QN3kF._rQAGM._nnjid),._QN3kF._rZ4iL,body.keyboard-user ._QN3kF._rQAGM._42-Ca:not(._KWjQZ){background-color:#0b6ed0}._QN3kF._rZ4iL._KWjQZ._42-Ca,._QN3kF._rZ4iL._KWjQZ._nnjid,._QN3kF._rZ4iL._nnjid._eo5P0{opacity:.4}._ySQpY{border-radius:4px 0 0 4px;border-right:none;padding-right:17px}._ySQpY:focus{z-index:1}._WKbWy{border-radius:0 4px 4px 0;transition:border .2s,background .2s,color .2s;border-left:none;min-width:35px!important;padding:0!important;justify-content:center!important}._WKbWy svg{margin-left:1px}._WKbWy._rQAGM{background-color:#0b6ed0;border-color:transparent}._WKbWy._rQAGM svg{fill:#fff!important}._WKbWy._rQAGM:not(._KFkhb):hover{background-color:#085caf!important}._WKbWy._rQAGM:not(._KFkhb):active{background-color:#0854a1!important}._WKbWy._rQAGM._KFkhb{opacity:.4}._WKbWy._rQAGM._KFkhb svg{background-color:transparent}._WKbWy._rZ4iL{border-color:#0b6ed0;background-color:#fff}._WKbWy._rZ4iL svg{fill:#0b6ed0!important}._WKbWy._rZ4iL:not(._KFkhb):hover{background-color:#eef5fc!important}._WKbWy._rZ4iL:not(._KFkhb):active{background-color:#e1edf9!important}._WKbWy._rZ4iL._KFkhb{opacity:.4}._WKbWy._rZ4iL._KFkhb svg{background-color:transparent}._mpYIf{width:260px}";
|
|
2994
|
+
var styles$6 = {"container":"_m7pGf","divider":"_QN3kF","primary":"_rQAGM","mainButtonFocus":"_42-Ca","mainButtonDisabled":"_KWjQZ","dropdownButtonFocus":"_eo5P0","dropdownButtonDisabled":"_nnjid","secondary":"_rZ4iL","mainButton":"_ySQpY","dropdownButton":"_WKbWy","disabled":"_KFkhb","dropdownOption":"_mpYIf"};
|
|
2995
|
+
var stylesheet$6="._m7pGf{display:flex}._QN3kF{z-index:2;width:1px;margin-left:-1px;margin-right:-1px}._QN3kF._rQAGM{background-color:#fff}._QN3kF._rQAGM._eo5P0:not(._QN3kF._rQAGM._nnjid),._QN3kF._rZ4iL,body.keyboard-user ._QN3kF._rQAGM._42-Ca:not(._KWjQZ){background-color:#0b6ed0}._QN3kF._rZ4iL._KWjQZ._42-Ca,._QN3kF._rZ4iL._KWjQZ._nnjid,._QN3kF._rZ4iL._nnjid._eo5P0{opacity:.4}._ySQpY{border-radius:4px 0 0 4px;border-right:none;padding-right:17px}._ySQpY:focus{z-index:1}._WKbWy{border-radius:0 4px 4px 0;transition:border .2s,background .2s,color .2s;border-left:none;min-width:35px!important;padding:0!important;justify-content:center!important}._WKbWy svg{margin-left:1px}._WKbWy._rQAGM{background-color:#0b6ed0;border-color:transparent}._WKbWy._rQAGM svg{fill:#fff!important}._WKbWy._rQAGM:not(._KFkhb):hover{background-color:#085caf!important}._WKbWy._rQAGM:not(._KFkhb):active{background-color:#0854a1!important}._WKbWy._rQAGM._KFkhb{opacity:.4}._WKbWy._rQAGM._KFkhb svg{background-color:transparent}._WKbWy._rZ4iL{border-color:#0b6ed0;background-color:#fff}._WKbWy._rZ4iL svg{fill:#0b6ed0!important}._WKbWy._rZ4iL:not(._KFkhb):hover{background-color:#eef5fc!important}._WKbWy._rZ4iL:not(._KFkhb):active{background-color:#e1edf9!important}._WKbWy._rZ4iL._KFkhb{opacity:.4}._WKbWy._rZ4iL._KFkhb svg{background-color:transparent}._mpYIf{width:260px}";
|
|
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);
|
|
3016
|
+
const [mainButtonHasFocus, setMainButtonHasFocus] = React.useState(false);
|
|
3243
3017
|
|
|
3244
|
-
|
|
3245
|
-
|
|
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;
|
|
3251
|
-
|
|
3252
|
-
return e.key === 'ArrowLeft' && ((_mainButtonRef$curren = mainButtonRef.current) === null || _mainButtonRef$curren === void 0 ? void 0 : _mainButtonRef$curren.focus());
|
|
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 = "._YHjrn{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}._YHjrn:hover:not(._LclMR){background-color:rgba(50,54,58,.08)}._YHjrn:hover:not(._LclMR)._-pnaJ{border-color:#085caf;background-color:rgba(11,110,208,.04)}._YHjrn:hover:not(._LclMR)._-pnaJ ._cvqh9{color:#32363a}._YHjrn:hover:not(._LclMR)._-pnaJ ._iQb6j{fill:#32363a}._YHjrn:hover:not(._LclMR)._-pnaJ ._QNoQ-{fill:#085caf}._YHjrn:hover:not(._LclMR)._-pnaJ ._vullW{background-color:rgba(11,110,208,.11)}._YHjrn:hover:not(._LclMR)._-pnaJ ._vullW ._vTpBi{color:#085caf}._YHjrn:active:not(._LclMR){background-color:#e8e9e9}._YHjrn:active:not(._LclMR)._-pnaJ{background-color:rgba(11,110,208,.11);border-color:#0854a1}._YHjrn:active:not(._LclMR)._-pnaJ ._QNoQ-{fill:#0854a1}._YHjrn:active:not(._LclMR)._-pnaJ ._vullW{background-color:rgba(11,110,208,.11)}._YHjrn:active:not(._LclMR)._-pnaJ ._vullW ._vTpBi{color:#0854a1}._YHjrn._LclMR{background-color:#fafafa;border-color:#e5e5e5;cursor:not-allowed}._YHjrn._-pnaJ{border-color:#0b6ed0}._iQb6j{fill:#515559;margin-right:4px}._cvqh9{max-width:180px;margin-right:3px;color:#515559;fill:#515559;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._cvqh9+._vullW{margin-left:6px}._cvqh9._LclMR{color:#74777a}._vullW{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}._vTpBi{color:#0b6ed0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._QNoQ-{fill:#515559}._QNoQ-._LclMR,._QNoQ-._LclMR._-pnaJ{fill:rgba(116,119,122,.4)}._QNoQ-._-pnaJ{fill:#0b6ed0}._QNoQ-._1WT0l{transform:rotate(-180deg)}body.keyboard-user ._YHjrn:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
|
|
3090
|
+
var styles$5 = {"button":"_YHjrn","disabled":"_LclMR","selected":"_-pnaJ","label":"_cvqh9","lockIcon":"_iQb6j","chevronIcon":"_QNoQ-","selectedFiltersContainer":"_vullW","selectedFilters":"_vTpBi","open":"_1WT0l"};
|
|
3091
|
+
var stylesheet$5="._YHjrn{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}._YHjrn:hover:not(._LclMR){background-color:rgba(50,54,58,.08)}._YHjrn:hover:not(._LclMR)._-pnaJ{border-color:#085caf;background-color:rgba(11,110,208,.04)}._YHjrn:hover:not(._LclMR)._-pnaJ ._cvqh9{color:#32363a}._YHjrn:hover:not(._LclMR)._-pnaJ ._iQb6j{fill:#32363a}._YHjrn:hover:not(._LclMR)._-pnaJ ._QNoQ-{fill:#085caf}._YHjrn:hover:not(._LclMR)._-pnaJ ._vullW{background-color:rgba(11,110,208,.11)}._YHjrn:hover:not(._LclMR)._-pnaJ ._vullW ._vTpBi{color:#085caf}._YHjrn:active:not(._LclMR){background-color:#e8e9e9}._YHjrn:active:not(._LclMR)._-pnaJ{background-color:rgba(11,110,208,.11);border-color:#0854a1}._YHjrn:active:not(._LclMR)._-pnaJ ._QNoQ-{fill:#0854a1}._YHjrn:active:not(._LclMR)._-pnaJ ._vullW{background-color:rgba(11,110,208,.11)}._YHjrn:active:not(._LclMR)._-pnaJ ._vullW ._vTpBi{color:#0854a1}._YHjrn._LclMR{background-color:#fafafa;border-color:#e5e5e5;cursor:not-allowed}._YHjrn._-pnaJ{border-color:#0b6ed0}._iQb6j{fill:#515559;margin-right:4px}._cvqh9{max-width:180px;margin-right:3px;color:#515559;fill:#515559;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._cvqh9+._vullW{margin-left:6px}._cvqh9._LclMR{color:#74777a}._vullW{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}._vTpBi{color:#0b6ed0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._QNoQ-{fill:#515559}._QNoQ-._LclMR,._QNoQ-._LclMR._-pnaJ{fill:rgba(116,119,122,.4)}._QNoQ-._-pnaJ{fill:#0b6ed0}._QNoQ-._1WT0l{transform:rotate(-180deg)}body.keyboard-user ._YHjrn: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 = "._XWalP{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._XWalP>._TBIBJ{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}._XWalP>._TBIBJ:hover:not([aria-disabled=true]){background-color:#f5f5f5}._XWalP>._TBIBJ:focus{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._XWalP>._TBIBJ+._217EJ{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._XWalP>._TBIBJ[data-state=open]+._217EJ{transform:rotate(-180deg) translateY(50%)}._XWalP>._TBIBJ[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._XWalP>._TBIBJ[aria-disabled=true]+._217EJ{fill:#515559;opacity:.4}._OtqSt>[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}._OtqSt>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._lA5c4{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}._lA5c4._09TTD{padding-top:0}._lA5c4._6uOho{margin-left:30px;opacity:0;pointer-events:none}._lA5c4._X3JdL{margin-left:-30px;pointer-events:none}._AMMxy{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%}._AMMxy._WbYY2{cursor:unset}._AMMxy ._-FGT-{fill:#32363a;margin-right:4px}._AMMxy[data-highlighted]{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._AMMxy[aria-disabled=true]{cursor:not-allowed;opacity:.65}._AMMxy._Fz048{padding-right:32px}._AMMxy._Fz048 ._217EJ{position:absolute;height:100%;right:3px;fill:#515559}._AMMxy._fFAl5{pointer-events:none}._MSrlX{position:sticky;top:0;padding-top:4px;background-color:#fff;z-index:1;border-bottom:1px solid #e8e8e8}._MSrlX>._ROoCs{padding:4px 8px 8px;border-radius:4px 4px 0 0}._MSrlX>._ROoCs>._ZjAxE{width:100%}._MSrlX>._ROoCs._fFAl5{pointer-events:none}";
|
|
3289
|
+
var styles$4 = {"buttonContainer":"_XWalP","button":"_TBIBJ","rightIcon":"_217EJ","maskContainer":"_OtqSt","flyout":"_lA5c4","containsStickyBox":"_09TTD","animatedRight":"_6uOho","animatedLeft":"_X3JdL","menuItem":"_AMMxy","noItems":"_WbYY2","backIcon":"_-FGT-","subMenu":"_Fz048","unresponsive":"_fFAl5","stickyBox":"_MSrlX","searchBox":"_ROoCs","searchInput":"_ZjAxE"};
|
|
3290
|
+
var stylesheet$4="._XWalP{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._XWalP>._TBIBJ{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}._XWalP>._TBIBJ:hover:not([aria-disabled=true]){background-color:#f5f5f5}._XWalP>._TBIBJ:focus{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._XWalP>._TBIBJ+._217EJ{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._XWalP>._TBIBJ[data-state=open]+._217EJ{transform:rotate(-180deg) translateY(50%)}._XWalP>._TBIBJ[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._XWalP>._TBIBJ[aria-disabled=true]+._217EJ{fill:#515559;opacity:.4}._OtqSt>[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}._OtqSt>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._lA5c4{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}._lA5c4._09TTD{padding-top:0}._lA5c4._6uOho{margin-left:30px;opacity:0;pointer-events:none}._lA5c4._X3JdL{margin-left:-30px;pointer-events:none}._AMMxy{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%}._AMMxy._WbYY2{cursor:unset}._AMMxy ._-FGT-{fill:#32363a;margin-right:4px}._AMMxy[data-highlighted]{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._AMMxy[aria-disabled=true]{cursor:not-allowed;opacity:.65}._AMMxy._Fz048{padding-right:32px}._AMMxy._Fz048 ._217EJ{position:absolute;height:100%;right:3px;fill:#515559}._AMMxy._fFAl5{pointer-events:none}._MSrlX{position:sticky;top:0;padding-top:4px;background-color:#fff;z-index:1;border-bottom:1px solid #e8e8e8}._MSrlX>._ROoCs{padding:4px 8px 8px;border-radius:4px 4px 0 0}._MSrlX>._ROoCs>._ZjAxE{width:100%}._MSrlX>._ROoCs._fFAl5{pointer-events:none}";
|
|
3536
3291
|
icons_index.styleInject(css_248z$4);
|
|
3537
3292
|
|
|
3538
3293
|
/* eslint-disable import/prefer-default-export */
|
|
@@ -3549,22 +3304,29 @@ const KEYS = {
|
|
|
3549
3304
|
IGNORED_BY_SEARCH_INPUT: ['Escape', 'ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End']
|
|
3550
3305
|
};
|
|
3551
3306
|
|
|
3552
|
-
const
|
|
3307
|
+
const AsChildWrapper = _ref => {
|
|
3308
|
+
let {
|
|
3309
|
+
asChild,
|
|
3310
|
+
children
|
|
3311
|
+
} = _ref;
|
|
3312
|
+
return asChild ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, children) : /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3313
|
+
className: styles$4.buttonContainer
|
|
3314
|
+
}, children);
|
|
3315
|
+
};
|
|
3316
|
+
const MenuButton = /*#__PURE__*/React__default["default"].forwardRef((_ref2, ref) => {
|
|
3553
3317
|
let {
|
|
3554
3318
|
asChild,
|
|
3555
3319
|
children,
|
|
3556
3320
|
className,
|
|
3557
3321
|
...rest
|
|
3558
|
-
} =
|
|
3322
|
+
} = _ref2;
|
|
3559
3323
|
const {
|
|
3560
3324
|
dataTestId: rootDataTestId,
|
|
3561
3325
|
isDisabled,
|
|
3562
3326
|
triggerRef
|
|
3563
3327
|
} = useMenuContext();
|
|
3564
|
-
return /*#__PURE__*/React__default["default"].createElement(
|
|
3565
|
-
|
|
3566
|
-
[styles$4.buttonContainer]: !asChild
|
|
3567
|
-
})
|
|
3328
|
+
return /*#__PURE__*/React__default["default"].createElement(AsChildWrapper, {
|
|
3329
|
+
asChild: asChild
|
|
3568
3330
|
}, /*#__PURE__*/React__default["default"].createElement(reactDropdownMenu.Trigger, _extends__default["default"]({}, rest, {
|
|
3569
3331
|
"aria-disabled": isDisabled,
|
|
3570
3332
|
className: classNames__default["default"](className, {
|
|
@@ -3596,17 +3358,15 @@ const MenuSearch = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
3596
3358
|
closeSubmenu,
|
|
3597
3359
|
flyoutRef
|
|
3598
3360
|
} = usePaneContext();
|
|
3599
|
-
const dataTestId = menuParentDataTestId
|
|
3361
|
+
const dataTestId = menuParentDataTestId?.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_SEARCH);
|
|
3600
3362
|
React.useEffect(() => () => setSearchValue(''), [setSearchValue]);
|
|
3601
|
-
const [previouslyFocusedElement, setPreviouslyFocusedElement] = React.useState();
|
|
3363
|
+
const [previouslyFocusedElement, setPreviouslyFocusedElement] = React.useState();
|
|
3602
3364
|
|
|
3365
|
+
// hack to keep focus on search input on mouse leave
|
|
3603
3366
|
index.useEventListener(flyoutRef, 'focus', e => {
|
|
3604
3367
|
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();
|
|
3368
|
+
inputRef.current?.focus();
|
|
3608
3369
|
}
|
|
3609
|
-
|
|
3610
3370
|
setPreviouslyFocusedElement(e.target);
|
|
3611
3371
|
}, {
|
|
3612
3372
|
isCaptureEvent: true
|
|
@@ -3614,14 +3374,11 @@ const MenuSearch = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
3614
3374
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(reactDropdownMenu.Item, {
|
|
3615
3375
|
className: classNames__default["default"](styles$4.searchBox, {
|
|
3616
3376
|
[styles$4.unresponsive]: !isInteractive
|
|
3617
|
-
})
|
|
3377
|
+
})
|
|
3378
|
+
// prevents dropdown from closing
|
|
3618
3379
|
,
|
|
3619
3380
|
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
|
-
},
|
|
3381
|
+
onFocus: () => inputRef.current?.focus(),
|
|
3625
3382
|
role: undefined,
|
|
3626
3383
|
ref: index.mergeRefs(itemRef, ref)
|
|
3627
3384
|
}, /*#__PURE__*/React__default["default"].createElement(index.Input$1, {
|
|
@@ -3631,27 +3388,25 @@ const MenuSearch = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
3631
3388
|
onChange: e => setSearchValue(e.target.value),
|
|
3632
3389
|
placeholder: searchText,
|
|
3633
3390
|
onKeyDown: e => {
|
|
3634
|
-
var
|
|
3635
|
-
|
|
3391
|
+
var _context, _context2;
|
|
3636
3392
|
// stop propagation to prevent typeAhead
|
|
3637
|
-
e.stopPropagation();
|
|
3393
|
+
e.stopPropagation();
|
|
3638
3394
|
|
|
3639
|
-
|
|
3640
|
-
|
|
3395
|
+
// allow caret movement through text entry, but close searchable submenu if on the very left
|
|
3396
|
+
if (e.target?.selectionStart === 0 && _includesInstanceProperty__default["default"](_context = KEYS.CLOSE_SUBMENU).call(_context, e.key)) {
|
|
3397
|
+
closeSubmenu?.(e);
|
|
3641
3398
|
return;
|
|
3642
|
-
}
|
|
3643
|
-
|
|
3399
|
+
}
|
|
3644
3400
|
|
|
3401
|
+
// forward keypress directly to `Item` to let Radix handle keyboard navigation
|
|
3645
3402
|
if (_includesInstanceProperty__default["default"](_context2 = KEYS.IGNORED_BY_SEARCH_INPUT).call(_context2, e.key)) {
|
|
3646
|
-
var _itemRef$current;
|
|
3647
|
-
|
|
3648
3403
|
// `view` types are incompatible
|
|
3649
3404
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3650
3405
|
const {
|
|
3651
3406
|
view,
|
|
3652
3407
|
...eventClone
|
|
3653
3408
|
} = e;
|
|
3654
|
-
itemRef
|
|
3409
|
+
itemRef?.current?.dispatchEvent(new KeyboardEvent('keydown', eventClone));
|
|
3655
3410
|
}
|
|
3656
3411
|
},
|
|
3657
3412
|
leftAddOn: /*#__PURE__*/React__default["default"].createElement(icons_index.SearchIcon, null),
|
|
@@ -3660,6 +3415,7 @@ const MenuSearch = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
3660
3415
|
})));
|
|
3661
3416
|
});
|
|
3662
3417
|
|
|
3418
|
+
// abstracts the logic required for searching by both `MenuPane` and `SubMenu`
|
|
3663
3419
|
function usePaneSearch(externalSearchValue, onSearchValueChange, items) {
|
|
3664
3420
|
const [internalSearchValue, setSearchValue] = index.useControllableState(externalSearchValue, onSearchValueChange, externalSearchValue);
|
|
3665
3421
|
const [zeroSearchResults, setZeroSearchResults] = React.useState();
|
|
@@ -3668,7 +3424,7 @@ function usePaneSearch(externalSearchValue, onSearchValueChange, items) {
|
|
|
3668
3424
|
} = index.useTranslation();
|
|
3669
3425
|
const noMatchesText = translate('menu.noItemsToDisplay');
|
|
3670
3426
|
React.useEffect(() => {
|
|
3671
|
-
setZeroSearchResults(
|
|
3427
|
+
setZeroSearchResults(items?.filter(item => item.element.current).length === 0);
|
|
3672
3428
|
}, [items, internalSearchValue]);
|
|
3673
3429
|
return {
|
|
3674
3430
|
internalSearchValue,
|
|
@@ -3699,11 +3455,7 @@ const MenuPane = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3699
3455
|
noMatchesText
|
|
3700
3456
|
} = usePaneSearch(externalSearchValue, onSearchValueChange, items);
|
|
3701
3457
|
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]);
|
|
3458
|
+
const [side, align] = React.useMemo(() => placement?.split?.('-') ?? [], [placement]);
|
|
3707
3459
|
const {
|
|
3708
3460
|
dataTestId: rootDataTestId,
|
|
3709
3461
|
openPaneDepth,
|
|
@@ -3711,17 +3463,16 @@ const MenuPane = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3711
3463
|
maskHeight,
|
|
3712
3464
|
open,
|
|
3713
3465
|
triggerRef
|
|
3714
|
-
} = useMenuContext();
|
|
3715
|
-
// We cache the pixel value here, to use it later if the user returns to this pane from a submenu.
|
|
3466
|
+
} = useMenuContext();
|
|
3716
3467
|
|
|
3468
|
+
// 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.
|
|
3469
|
+
// We cache the pixel value here, to use it later if the user returns to this pane from a submenu.
|
|
3717
3470
|
const initialHeightOfThisPane = React.useRef(null);
|
|
3718
3471
|
index.useDidUpdate(() => {
|
|
3719
3472
|
if (openPaneDepth === 1) {
|
|
3720
3473
|
if (initialHeightOfThisPane.current === null) {
|
|
3721
3474
|
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;
|
|
3475
|
+
initialHeightOfThisPane.current = flyoutRef.current?.clientHeight ?? null;
|
|
3725
3476
|
setMaskHeight(initialHeightOfThisPane.current);
|
|
3726
3477
|
});
|
|
3727
3478
|
} else {
|
|
@@ -3733,7 +3484,6 @@ const MenuPane = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3733
3484
|
const animatedLeft = React.useMemo(() => openPaneDepth > 1, [openPaneDepth]);
|
|
3734
3485
|
index.useEventListener(flyoutRef, 'keydown', e => {
|
|
3735
3486
|
var _context;
|
|
3736
|
-
|
|
3737
3487
|
return _includesInstanceProperty__default["default"](_context = Object.values(KEYS).flat()).call(_context, e.key) && index.setIsKeyboardUser(true);
|
|
3738
3488
|
}, {
|
|
3739
3489
|
additionalDependencies: [openPaneDepth]
|
|
@@ -3742,36 +3492,27 @@ const MenuPane = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3742
3492
|
additionalDependencies: [openPaneDepth]
|
|
3743
3493
|
});
|
|
3744
3494
|
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
|
-
|
|
3495
|
+
const rect = triggerRef?.current?.getBoundingClientRect();
|
|
3749
3496
|
if (!rect) {
|
|
3750
3497
|
return 'bottom';
|
|
3751
|
-
}
|
|
3752
|
-
|
|
3498
|
+
}
|
|
3753
3499
|
|
|
3500
|
+
// hard coded in Menu.less
|
|
3754
3501
|
let maxHeight = 350;
|
|
3755
|
-
|
|
3756
3502
|
if (flyoutRef.current) {
|
|
3757
3503
|
const computedString = window.getComputedStyle(flyoutRef.current).maxHeight.slice(0, -2);
|
|
3758
|
-
|
|
3759
3504
|
if (computedString !== '' && !Number.isNaN(+computedString)) {
|
|
3760
3505
|
maxHeight = +computedString;
|
|
3761
3506
|
}
|
|
3762
3507
|
}
|
|
3763
|
-
|
|
3764
3508
|
const distanceToBottom = window.innerHeight - rect.bottom;
|
|
3765
3509
|
const distanceToTop = rect.top;
|
|
3766
|
-
|
|
3767
3510
|
if (distanceToBottom > maxHeight) {
|
|
3768
3511
|
return 'bottom';
|
|
3769
3512
|
}
|
|
3770
|
-
|
|
3771
3513
|
if (distanceToTop > maxHeight) {
|
|
3772
3514
|
return 'top';
|
|
3773
3515
|
}
|
|
3774
|
-
|
|
3775
3516
|
return 'bottom';
|
|
3776
3517
|
}, [open, triggerRef]);
|
|
3777
3518
|
return /*#__PURE__*/React__default["default"].createElement(PaneContextProvider, {
|
|
@@ -3799,8 +3540,9 @@ const MenuPane = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3799
3540
|
[styles$4.animatedLeft]: animatedLeft,
|
|
3800
3541
|
[styles$4.containsStickyBox]: isSearchable
|
|
3801
3542
|
}, styles$4.flyout),
|
|
3802
|
-
style: {
|
|
3803
|
-
|
|
3543
|
+
style: {
|
|
3544
|
+
...style,
|
|
3545
|
+
height: internalSearchValue && openPaneDepth === 1 ? undefined : maskHeight ?? undefined
|
|
3804
3546
|
}
|
|
3805
3547
|
}), isSearchable && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3806
3548
|
className: styles$4.stickyBox
|
|
@@ -3832,25 +3574,22 @@ const MenuItem = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3832
3574
|
closeSubmenu,
|
|
3833
3575
|
flyoutRef
|
|
3834
3576
|
} = usePaneContext(itemRef);
|
|
3835
|
-
const dataTestId = index.getSubDataTestId(menuParentDataTestId
|
|
3577
|
+
const dataTestId = index.getSubDataTestId(menuParentDataTestId?.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_ITEM), String(index$1));
|
|
3836
3578
|
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()));
|
|
3579
|
+
const searchMatcher = label ?? (typeof children === 'string' ? children : undefined);
|
|
3580
|
+
return isSearchFilteringDisabled || !searchValue || searchMatcher?.toLowerCase().includes(searchValue.toLowerCase());
|
|
3841
3581
|
}, [children, searchValue, label, isSearchFilteringDisabled]);
|
|
3842
|
-
|
|
3843
3582
|
const handleFocus = () => {
|
|
3844
3583
|
if (itemRef.current && flyoutRef.current && index.getIsKeyboardUser()) {
|
|
3845
|
-
const stickyBoxHeight = 93;
|
|
3584
|
+
const stickyBoxHeight = 93;
|
|
3846
3585
|
|
|
3586
|
+
// if the top of the focused menu item is beneath the sticky box
|
|
3847
3587
|
if (itemRef.current.offsetTop < flyoutRef.current.scrollTop + stickyBoxHeight) {
|
|
3848
3588
|
// scroll down a little
|
|
3849
3589
|
flyoutRef.current.scrollTop = itemRef.current.offsetTop - stickyBoxHeight;
|
|
3850
3590
|
}
|
|
3851
3591
|
}
|
|
3852
3592
|
};
|
|
3853
|
-
|
|
3854
3593
|
return isVisible ? /*#__PURE__*/React__default["default"].createElement(reactDropdownMenu.Item, _extends__default["default"]({}, rest, {
|
|
3855
3594
|
asChild: asChild,
|
|
3856
3595
|
"aria-disabled": isDisabled,
|
|
@@ -3860,21 +3599,20 @@ const MenuItem = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
3860
3599
|
"data-testid": dataTestId,
|
|
3861
3600
|
ref: index.mergeRefs(ref, itemRef),
|
|
3862
3601
|
onKeyDown: e => {
|
|
3863
|
-
var
|
|
3864
|
-
|
|
3602
|
+
var _context;
|
|
3865
3603
|
if (!isInteractive) {
|
|
3866
3604
|
e.preventDefault();
|
|
3867
3605
|
return;
|
|
3868
3606
|
}
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
closeSubmenu === null || closeSubmenu === void 0 ? void 0 : closeSubmenu(e);
|
|
3607
|
+
if (_includesInstanceProperty__default["default"](_context = KEYS.CLOSE_SUBMENU).call(_context, e.key)) {
|
|
3608
|
+
closeSubmenu?.(e);
|
|
3872
3609
|
}
|
|
3873
3610
|
},
|
|
3874
|
-
onFocus: handleFocus
|
|
3611
|
+
onFocus: handleFocus
|
|
3612
|
+
// stop radix from closing the menu on selection of disabled item
|
|
3875
3613
|
// other pointer and keyboard events still work, even when disabled
|
|
3876
3614
|
,
|
|
3877
|
-
onSelect: e => isDisabled ? e.preventDefault() : onSelect
|
|
3615
|
+
onSelect: e => isDisabled ? e.preventDefault() : onSelect?.()
|
|
3878
3616
|
}), (!children || typeof children === 'string') && label ? label : children) : null;
|
|
3879
3617
|
});
|
|
3880
3618
|
|
|
@@ -3918,11 +3656,10 @@ const SubMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
3918
3656
|
} = useMenuContext();
|
|
3919
3657
|
const thisPanesDepth = React.useRef(totalOpenPaneDepth + 1).current;
|
|
3920
3658
|
const paneDataTestId = index.getSubDataTestId(paneContainingTriggerDataTestId, String(triggerIndex));
|
|
3921
|
-
const backButtonDataTestId = paneDataTestId
|
|
3922
|
-
const triggerDataTestId = paneDataTestId
|
|
3659
|
+
const backButtonDataTestId = paneDataTestId?.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_BACK);
|
|
3660
|
+
const triggerDataTestId = paneDataTestId?.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_ITEM);
|
|
3923
3661
|
const triggerIsVisible = React.useMemo(() => {
|
|
3924
3662
|
var _context;
|
|
3925
|
-
|
|
3926
3663
|
return isSearchFilteringDisabledForPaneContainingTrigger || !paneContainingTriggerSearchValue || typeof label === 'string' && _includesInstanceProperty__default["default"](_context = label.toLowerCase()).call(_context, paneContainingTriggerSearchValue.toLowerCase());
|
|
3927
3664
|
}, [paneContainingTriggerSearchValue, label, isSearchFilteringDisabledForPaneContainingTrigger]);
|
|
3928
3665
|
const [isPaneInDOM, setIsPaneInDOM] = React.useState(false);
|
|
@@ -3930,63 +3667,49 @@ const SubMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
3930
3667
|
const [isTransitioningFromRight, setIsTransitioningFromRight] = React.useState(false);
|
|
3931
3668
|
index.useDidUpdate(() => {
|
|
3932
3669
|
if (isPaneInDOM) {
|
|
3933
|
-
setIsTransitioningFromRight(true);
|
|
3934
|
-
|
|
3670
|
+
setIsTransitioningFromRight(true);
|
|
3671
|
+
// trigger css transition
|
|
3935
3672
|
setIsFrameAfterPaneAddedToDOM(true);
|
|
3936
3673
|
window.requestAnimationFrame(() => setIsFrameAfterPaneAddedToDOM(false));
|
|
3937
3674
|
}
|
|
3938
|
-
|
|
3939
3675
|
registerSubmenu(internalId, isPaneInDOM);
|
|
3940
3676
|
}, [isPaneInDOM]);
|
|
3941
3677
|
React.useEffect(() => () => registerSubmenu(internalId, false), []);
|
|
3942
|
-
|
|
3943
3678
|
const closeThisSubmenu = e => {
|
|
3944
3679
|
// prevent closing the entire menu, and Radix keyboard navigation
|
|
3945
3680
|
e.preventDefault();
|
|
3946
3681
|
registerSubmenu(internalId, false);
|
|
3947
3682
|
};
|
|
3948
|
-
|
|
3949
3683
|
index.useDidUpdate(() => {
|
|
3950
3684
|
if (thisPanesDepth === totalOpenPaneDepth) {
|
|
3951
3685
|
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);
|
|
3686
|
+
setMaskHeight(flyoutRef.current?.clientHeight ?? null);
|
|
3955
3687
|
});
|
|
3956
3688
|
}
|
|
3957
3689
|
}, [totalOpenPaneDepth, internalSearchValue]);
|
|
3958
3690
|
const animatedLeft = React.useMemo(() => thisPanesDepth < totalOpenPaneDepth, [totalOpenPaneDepth]);
|
|
3959
3691
|
const animatedRight = React.useMemo(() => thisPanesDepth > totalOpenPaneDepth || isFrameAfterPaneAddedToDOM, [totalOpenPaneDepth, isFrameAfterPaneAddedToDOM]);
|
|
3960
|
-
|
|
3961
3692
|
const handlePaneTransitionEnd = () => {
|
|
3962
3693
|
if (animatedLeft) {
|
|
3963
3694
|
return;
|
|
3964
3695
|
}
|
|
3965
|
-
|
|
3966
3696
|
if (animatedRight) {
|
|
3967
3697
|
setIsPaneInDOM(false);
|
|
3968
|
-
|
|
3969
3698
|
if (index.getIsKeyboardUser()) {
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
(_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.focus();
|
|
3699
|
+
triggerRef.current?.focus();
|
|
3973
3700
|
}
|
|
3974
3701
|
} else {
|
|
3975
|
-
var _flyoutRef$current2;
|
|
3976
|
-
|
|
3977
3702
|
// if the newly closed submenu doesn't place the focus on its trigger
|
|
3978
|
-
if (!
|
|
3703
|
+
if (!flyoutRef.current?.contains(document.activeElement) && index.getIsKeyboardUser()) {
|
|
3979
3704
|
if (searchItemRef.current) {
|
|
3980
3705
|
searchItemRef.current.focus();
|
|
3981
3706
|
} else if (backButtonRef.current) {
|
|
3982
3707
|
backButtonRef.current.focus();
|
|
3983
3708
|
}
|
|
3984
3709
|
}
|
|
3985
|
-
|
|
3986
3710
|
setIsTransitioningFromRight(false);
|
|
3987
3711
|
}
|
|
3988
3712
|
};
|
|
3989
|
-
|
|
3990
3713
|
return triggerIsVisible ? /*#__PURE__*/React__default["default"].createElement(reactDropdownMenu.Sub, {
|
|
3991
3714
|
open: isPaneInDOM
|
|
3992
3715
|
}, /*#__PURE__*/React__default["default"].createElement(reactDropdownMenu.SubTrigger, {
|
|
@@ -3999,16 +3722,14 @@ const SubMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
3999
3722
|
onClick: () => !isDisabled && setIsPaneInDOM(true),
|
|
4000
3723
|
onKeyDown: e => {
|
|
4001
3724
|
var _context2, _context3;
|
|
4002
|
-
|
|
4003
3725
|
if (!paneContainingTriggerIsInteractive) {
|
|
4004
3726
|
e.preventDefault();
|
|
4005
3727
|
return;
|
|
4006
3728
|
}
|
|
4007
|
-
|
|
4008
3729
|
if (!isDisabled && _includesInstanceProperty__default["default"](_context2 = KEYS.OPEN_SUBMENU).call(_context2, e.key)) {
|
|
4009
3730
|
setIsPaneInDOM(true);
|
|
4010
3731
|
} else if (_includesInstanceProperty__default["default"](_context3 = KEYS.CLOSE_SUBMENU).call(_context3, e.key)) {
|
|
4011
|
-
closeSubmenuContainingTrigger
|
|
3732
|
+
closeSubmenuContainingTrigger?.(e);
|
|
4012
3733
|
}
|
|
4013
3734
|
}
|
|
4014
3735
|
}, label, /*#__PURE__*/React__default["default"].createElement(icons_index.ChevronRightIcon, {
|
|
@@ -4033,7 +3754,8 @@ const SubMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
4033
3754
|
[styles$4.animatedLeft]: animatedLeft
|
|
4034
3755
|
}),
|
|
4035
3756
|
onTransitionEnd: handlePaneTransitionEnd,
|
|
4036
|
-
style: {
|
|
3757
|
+
style: {
|
|
3758
|
+
...style,
|
|
4037
3759
|
zIndex: thisPanesDepth
|
|
4038
3760
|
}
|
|
4039
3761
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -4050,7 +3772,6 @@ const SubMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
4050
3772
|
ref: backButtonRef,
|
|
4051
3773
|
onKeyDown: e => {
|
|
4052
3774
|
var _context4;
|
|
4053
|
-
|
|
4054
3775
|
if (_includesInstanceProperty__default["default"](_context4 = KEYS.CLOSE_SUBMENU).call(_context4, e.key)) {
|
|
4055
3776
|
closeThisSubmenu(e);
|
|
4056
3777
|
}
|
|
@@ -4064,9 +3785,9 @@ const SubMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
4064
3785
|
}, noMatchesText), children))) : null;
|
|
4065
3786
|
});
|
|
4066
3787
|
|
|
4067
|
-
var css_248z$3 = ".
|
|
4068
|
-
var styles$3 = {"overlay":"
|
|
4069
|
-
var stylesheet$3=".
|
|
3788
|
+
var css_248z$3 = "._ygg2k{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}._09LWV{visibility:hidden}";
|
|
3789
|
+
var styles$3 = {"overlay":"_ygg2k","hidden":"_09LWV"};
|
|
3790
|
+
var stylesheet$3="._ygg2k{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}._09LWV{visibility:hidden}";
|
|
4070
3791
|
icons_index.styleInject(css_248z$3);
|
|
4071
3792
|
|
|
4072
3793
|
/**
|
|
@@ -4089,9 +3810,7 @@ const useOverlay = _ref => {
|
|
|
4089
3810
|
} = _ref;
|
|
4090
3811
|
const overlayId = index.useId();
|
|
4091
3812
|
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;
|
|
3813
|
+
const containerNode = containerRef?.current ?? document.body;
|
|
4095
3814
|
const overlay = document.createElement('div');
|
|
4096
3815
|
overlay.id = overlayId;
|
|
4097
3816
|
overlay.classList.add(styles$3.overlay);
|
|
@@ -4107,23 +3826,19 @@ const useOverlay = _ref => {
|
|
|
4107
3826
|
};
|
|
4108
3827
|
}, [containerRef, overlayId, isVisible, onClick, dataTestId, zIndex]);
|
|
4109
3828
|
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;
|
|
3829
|
+
const containerNode = containerRef?.current ?? document.body;
|
|
4113
3830
|
const overlayNode = document.getElementById(overlayId);
|
|
4114
|
-
|
|
4115
3831
|
if (isVisible) {
|
|
4116
3832
|
Array.from(containerNode.children).forEach(child => {
|
|
4117
3833
|
if (!_includesInstanceProperty__default["default"](ignoreIds).call(ignoreIds, child.id) && child.id !== overlayId) child.setAttribute('inert', '');
|
|
4118
3834
|
});
|
|
4119
|
-
overlayNode
|
|
3835
|
+
overlayNode?.classList.remove(styles$3.hidden);
|
|
4120
3836
|
} else {
|
|
4121
3837
|
Array.from(containerNode.children).forEach(child => {
|
|
4122
3838
|
child.removeAttribute('inert');
|
|
4123
3839
|
});
|
|
4124
|
-
overlayNode
|
|
3840
|
+
overlayNode?.classList.add(styles$3.hidden);
|
|
4125
3841
|
}
|
|
4126
|
-
|
|
4127
3842
|
return () => {
|
|
4128
3843
|
Array.from(containerNode.children).forEach(child => {
|
|
4129
3844
|
child.removeAttribute('inert');
|
|
@@ -4132,14 +3847,12 @@ const useOverlay = _ref => {
|
|
|
4132
3847
|
}, [containerRef, isVisible, ignoreIds, overlayId]);
|
|
4133
3848
|
};
|
|
4134
3849
|
|
|
4135
|
-
var css_248z$2 = ".
|
|
4136
|
-
var styles$2 = {"drawer":"
|
|
4137
|
-
var stylesheet$2=".
|
|
3850
|
+
var css_248z$2 = "._qjffl{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}._HItSr{visibility:hidden}._G-q2r{display:flex;justify-content:space-between;align-items:start;line-height:20px;font-size:16px;padding-bottom:12px}._iiyNj{padding-top:8px}._bPPA8{margin-left:12px}";
|
|
3851
|
+
var styles$2 = {"drawer":"_qjffl","hidden":"_HItSr","header":"_G-q2r","title":"_iiyNj","closeButton":"_bPPA8"};
|
|
3852
|
+
var stylesheet$2="._qjffl{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}._HItSr{visibility:hidden}._G-q2r{display:flex;justify-content:space-between;align-items:start;line-height:20px;font-size:16px;padding-bottom:12px}._iiyNj{padding-top:8px}._bPPA8{margin-left:12px}";
|
|
4138
3853
|
icons_index.styleInject(css_248z$2);
|
|
4139
3854
|
|
|
4140
3855
|
const Drawer = _ref => {
|
|
4141
|
-
var _containerRef$current;
|
|
4142
|
-
|
|
4143
3856
|
let {
|
|
4144
3857
|
id,
|
|
4145
3858
|
isOpen: externalIsOpen,
|
|
@@ -4171,15 +3884,12 @@ const Drawer = _ref => {
|
|
|
4171
3884
|
} = index.useTranslation();
|
|
4172
3885
|
const closeButtonAriaLabel = translate('close');
|
|
4173
3886
|
const closeButtonRef = React.useRef(null);
|
|
4174
|
-
|
|
4175
3887
|
const close = () => {
|
|
4176
3888
|
setIsOpen(false);
|
|
4177
3889
|
};
|
|
4178
|
-
|
|
4179
3890
|
const handleKeyDown = e => {
|
|
4180
3891
|
if (e.key === 'Escape') close();
|
|
4181
3892
|
};
|
|
4182
|
-
|
|
4183
3893
|
useOverlay({
|
|
4184
3894
|
containerRef,
|
|
4185
3895
|
isVisible: isOpen,
|
|
@@ -4194,29 +3904,23 @@ const Drawer = _ref => {
|
|
|
4194
3904
|
setIsHidden(false);
|
|
4195
3905
|
setElementUsedToOpenModal(document.activeElement);
|
|
4196
3906
|
} else {
|
|
4197
|
-
var _elementRefToFocusOnC;
|
|
4198
|
-
|
|
4199
3907
|
setIsClosing(true);
|
|
4200
|
-
if (elementRefToFocusOnClose !== undefined) elementRefToFocusOnClose
|
|
3908
|
+
if (elementRefToFocusOnClose !== undefined) elementRefToFocusOnClose?.current?.focus();else elementUsedToOpenModal?.focus();
|
|
4201
3909
|
}
|
|
4202
3910
|
}, [elementRefToFocusOnClose, isOpen]);
|
|
4203
3911
|
React.useEffect(() => {
|
|
4204
3912
|
if (isOpen && !isHidden) {
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
(_closeButtonRef$curre = closeButtonRef.current) === null || _closeButtonRef$curre === void 0 ? void 0 : _closeButtonRef$curre.focus();
|
|
3913
|
+
closeButtonRef.current?.focus();
|
|
4208
3914
|
}
|
|
4209
3915
|
}, [isOpen, isHidden]);
|
|
4210
|
-
|
|
4211
3916
|
const handleTransitionEnd = () => {
|
|
4212
3917
|
if (!isOpen) {
|
|
4213
3918
|
setIsClosing(false);
|
|
4214
3919
|
setIsHidden(true);
|
|
4215
3920
|
}
|
|
4216
3921
|
};
|
|
4217
|
-
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
4218
|
-
|
|
4219
3922
|
|
|
3923
|
+
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
4220
3924
|
return domReady ? /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React__default["default"].createElement("aside", {
|
|
4221
3925
|
id: drawerId,
|
|
4222
3926
|
className: classNames__default["default"](styles$2.drawer, {
|
|
@@ -4225,7 +3929,7 @@ const Drawer = _ref => {
|
|
|
4225
3929
|
}),
|
|
4226
3930
|
style: {
|
|
4227
3931
|
width,
|
|
4228
|
-
left:
|
|
3932
|
+
left: `${isHidden || isClosing ? `-${width}` : '0'}`,
|
|
4229
3933
|
zIndex
|
|
4230
3934
|
},
|
|
4231
3935
|
onKeyDown: handleKeyDown,
|
|
@@ -4250,12 +3954,12 @@ const Drawer = _ref => {
|
|
|
4250
3954
|
"aria-label": closeButtonAriaLabel
|
|
4251
3955
|
}, /*#__PURE__*/React__default["default"].createElement(icons_index.CloseIcon, null))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
4252
3956
|
"data-testid": index.getSubDataTestId(dataTestId, 'body')
|
|
4253
|
-
}, children))),
|
|
3957
|
+
}, children))), containerRef?.current ?? document.body) : null;
|
|
4254
3958
|
};
|
|
4255
3959
|
|
|
4256
|
-
var css_248z$1 = ".
|
|
4257
|
-
var styles$1 = {"container":"
|
|
4258
|
-
var stylesheet$1=".
|
|
3960
|
+
var css_248z$1 = "._6AuTd{display:inline-block;position:relative}._T8Igi{width:120px}._T8Igi ._oQAxS._1aRma{transform:rotate(-180deg)}._T8Igi ._oQAxS._yi66Q{fill:#9d9fa1;opacity:.4}._FoDQd>input:focus{box-shadow:none!important;border:1px solid #898989!important}._xcPSL{width:120px}._xcPSL ._oQ88Q._mh0Tq{background-color:#efefef;border-radius:6px}._oQAxS{position:absolute;right:4px;bottom:4px;height:28px;width:28px}._oQAxS._1aRma{transform:rotate(-180deg)}";
|
|
3961
|
+
var styles$1 = {"container":"_6AuTd","input":"_T8Igi","icon":"_oQAxS","open":"_1aRma","disabled":"_yi66Q","ignoreFocusStyle":"_FoDQd","flyout":"_xcPSL","option":"_oQ88Q","exactMatch":"_mh0Tq"};
|
|
3962
|
+
var stylesheet$1="._6AuTd{display:inline-block;position:relative}._T8Igi{width:120px}._T8Igi ._oQAxS._1aRma{transform:rotate(-180deg)}._T8Igi ._oQAxS._yi66Q{fill:#9d9fa1;opacity:.4}._FoDQd>input:focus{box-shadow:none!important;border:1px solid #898989!important}._xcPSL{width:120px}._xcPSL ._oQ88Q._mh0Tq{background-color:#efefef;border-radius:6px}._oQAxS{position:absolute;right:4px;bottom:4px;height:28px;width:28px}._oQAxS._1aRma{transform:rotate(-180deg)}";
|
|
4259
3963
|
icons_index.styleInject(css_248z$1);
|
|
4260
3964
|
|
|
4261
3965
|
const TimeDropdown = _ref => {
|
|
@@ -4277,7 +3981,6 @@ const TimeDropdown = _ref => {
|
|
|
4277
3981
|
const [refsInitialized, setRefsInitialized] = React.useState(false);
|
|
4278
3982
|
React.useEffect(() => {
|
|
4279
3983
|
const nodes = scrollRef.current;
|
|
4280
|
-
|
|
4281
3984
|
if (scrolledToItem && nodes[scrolledToItem.index]) {
|
|
4282
3985
|
nodes[scrolledToItem.index].scrollIntoView();
|
|
4283
3986
|
}
|
|
@@ -4296,14 +3999,14 @@ const TimeDropdown = _ref => {
|
|
|
4296
3999
|
"aria-label": ariaLabel,
|
|
4297
4000
|
"aria-labelledby": ariaLabelledBy,
|
|
4298
4001
|
"aria-describedby": ariaDescribedBy,
|
|
4299
|
-
"data-testid": dataTestId &&
|
|
4002
|
+
"data-testid": dataTestId && `${dataTestId}-dropdown`,
|
|
4300
4003
|
className: styles$1.flyout,
|
|
4301
4004
|
onMouseOver: () => setIsOptionHovered(true),
|
|
4302
4005
|
onMouseLeave: () => setIsOptionHovered(false)
|
|
4303
4006
|
}, items.map((item, index$1) => /*#__PURE__*/React__default["default"].createElement(index.FlyoutOption, {
|
|
4304
4007
|
id: item.id,
|
|
4305
4008
|
isHighlightedOnHover: true,
|
|
4306
|
-
isHighlighted:
|
|
4009
|
+
isHighlighted: scrolledToItem?.index === index$1 && scrolledToItem?.isFocused,
|
|
4307
4010
|
key: item.label,
|
|
4308
4011
|
ref: node => {
|
|
4309
4012
|
if (node) {
|
|
@@ -4312,9 +4015,9 @@ const TimeDropdown = _ref => {
|
|
|
4312
4015
|
}
|
|
4313
4016
|
},
|
|
4314
4017
|
onClick: () => onClick(index$1),
|
|
4315
|
-
"data-testid": dataTestId &&
|
|
4018
|
+
"data-testid": dataTestId && `${dataTestId}-option-${index$1}`,
|
|
4316
4019
|
className: classNames__default["default"](styles$1.option, {
|
|
4317
|
-
[styles$1.exactMatch]:
|
|
4020
|
+
[styles$1.exactMatch]: scrolledToItem?.index === index$1 && scrolledToItem.isExactMatch && !isOptionHovered
|
|
4318
4021
|
})
|
|
4319
4022
|
}, item.label))),
|
|
4320
4023
|
anchorNode: inputRef.current,
|
|
@@ -4337,11 +4040,9 @@ const formatUtcDate = (utcDate, is24HourClock) => {
|
|
|
4337
4040
|
});
|
|
4338
4041
|
const dateWithoutLeadingZeros = format(utcDate);
|
|
4339
4042
|
let dateWithLeadingZeros = dateWithoutLeadingZeros;
|
|
4340
|
-
|
|
4341
4043
|
if (dateWithLeadingZeros.split(':')[0].length === 1) {
|
|
4342
|
-
dateWithLeadingZeros =
|
|
4044
|
+
dateWithLeadingZeros = `0${dateWithLeadingZeros}`;
|
|
4343
4045
|
}
|
|
4344
|
-
|
|
4345
4046
|
return dateWithLeadingZeros.toLowerCase();
|
|
4346
4047
|
};
|
|
4347
4048
|
const convertTimeObjectToTimeString = (time, is24HourClock) => {
|
|
@@ -4352,13 +4053,11 @@ const convertTimeStringToTimeObject = completeTimeString => {
|
|
|
4352
4053
|
const [hourPart, minutePart, amPmPart] = completeTimeString.split(/:| /);
|
|
4353
4054
|
let hour = +hourPart;
|
|
4354
4055
|
const minute = +minutePart;
|
|
4355
|
-
|
|
4356
4056
|
if (amPmPart === 'am' && hour === 12) {
|
|
4357
4057
|
hour = 0;
|
|
4358
4058
|
} else if (amPmPart === 'pm' && hour < 12) {
|
|
4359
4059
|
hour += 12;
|
|
4360
4060
|
}
|
|
4361
|
-
|
|
4362
4061
|
return {
|
|
4363
4062
|
hour,
|
|
4364
4063
|
minute
|
|
@@ -4371,28 +4070,21 @@ const generateTimes = (step, is24HourClock) => {
|
|
|
4371
4070
|
return {
|
|
4372
4071
|
label: labelWithLeadingZeros,
|
|
4373
4072
|
value: i * step,
|
|
4374
|
-
id:
|
|
4073
|
+
id: `time-option-${i}`
|
|
4375
4074
|
};
|
|
4376
4075
|
});
|
|
4377
4076
|
};
|
|
4378
|
-
|
|
4379
4077
|
function getTimeStringCorrector(str, is24HourClock) {
|
|
4380
|
-
var _letterString;
|
|
4381
|
-
|
|
4382
4078
|
let [numberString, letterString] = str.replace(':', '').split(' ');
|
|
4383
|
-
letterString =
|
|
4079
|
+
letterString = letterString?.toLowerCase();
|
|
4384
4080
|
let selectionModifier = 0;
|
|
4385
|
-
|
|
4386
4081
|
const getTimeString = () => {
|
|
4387
|
-
const finalNumberString =
|
|
4388
|
-
return is24HourClock ? finalNumberString :
|
|
4082
|
+
const finalNumberString = `${numberString.slice(0, 2)}:${numberString.slice(2, 4)}`;
|
|
4083
|
+
return is24HourClock ? finalNumberString : `${finalNumberString} ${letterString}`;
|
|
4389
4084
|
};
|
|
4390
|
-
|
|
4391
4085
|
const getSelectionModifier = () => selectionModifier;
|
|
4392
|
-
|
|
4393
4086
|
const replaceDashes = () => {
|
|
4394
4087
|
numberString = numberString.replace(/-/g, '0');
|
|
4395
|
-
|
|
4396
4088
|
if (letterString) {
|
|
4397
4089
|
if (letterString[0] === '-' || letterString[0] === 'a') {
|
|
4398
4090
|
// Arbitrarily choose AM if user hasn't typed 'a' or 'p'
|
|
@@ -4402,55 +4094,39 @@ function getTimeStringCorrector(str, is24HourClock) {
|
|
|
4402
4094
|
}
|
|
4403
4095
|
}
|
|
4404
4096
|
};
|
|
4405
|
-
|
|
4406
4097
|
const shiftMinutesRight = () => {
|
|
4407
|
-
numberString =
|
|
4098
|
+
numberString = `${numberString.slice(0, 2)}0${numberString[2]}`;
|
|
4408
4099
|
selectionModifier += 1;
|
|
4409
4100
|
};
|
|
4410
|
-
|
|
4411
4101
|
const prependCharacter = character => {
|
|
4412
|
-
numberString =
|
|
4102
|
+
numberString = `${character}${numberString}`;
|
|
4413
4103
|
selectionModifier += 1;
|
|
4414
4104
|
};
|
|
4415
|
-
|
|
4416
4105
|
const setHoursTo12 = () => {
|
|
4417
|
-
numberString =
|
|
4106
|
+
numberString = `12${numberString.slice(2)}`;
|
|
4418
4107
|
};
|
|
4419
|
-
|
|
4420
4108
|
const clearSecondHoursDigit = () => {
|
|
4421
|
-
numberString =
|
|
4109
|
+
numberString = `${numberString.slice(0, 1)}0${numberString.slice(2)}`;
|
|
4422
4110
|
};
|
|
4423
|
-
|
|
4424
4111
|
const hoursAre00 = () => numberString[0] === '0' && numberString[1] === '0';
|
|
4425
|
-
|
|
4426
4112
|
const firstHourGreaterThan1 = () => {
|
|
4427
4113
|
var _context;
|
|
4428
|
-
|
|
4429
4114
|
return !_includesInstanceProperty__default["default"](_context = '01-').call(_context, numberString[0]);
|
|
4430
4115
|
};
|
|
4431
|
-
|
|
4432
4116
|
const firstHourGreaterThan2 = () => {
|
|
4433
4117
|
var _context2;
|
|
4434
|
-
|
|
4435
4118
|
return !_includesInstanceProperty__default["default"](_context2 = '012-').call(_context2, numberString[0]);
|
|
4436
4119
|
};
|
|
4437
|
-
|
|
4438
4120
|
const hoursGreaterThan12 = () => {
|
|
4439
4121
|
var _context3;
|
|
4440
|
-
|
|
4441
4122
|
return numberString[0] === '1' && !_includesInstanceProperty__default["default"](_context3 = '012-').call(_context3, numberString[1]);
|
|
4442
4123
|
};
|
|
4443
|
-
|
|
4444
4124
|
const hoursGreaterThan23 = () => {
|
|
4445
4125
|
var _context4;
|
|
4446
|
-
|
|
4447
4126
|
return numberString[0] === '2' && !_includesInstanceProperty__default["default"](_context4 = '0123-').call(_context4, numberString[1]);
|
|
4448
4127
|
};
|
|
4449
|
-
|
|
4450
4128
|
const firstMinuteGreaterThan5 = () => numberString[2] !== '-' && +numberString[2] > 5;
|
|
4451
|
-
|
|
4452
4129
|
const hasTypedMinutes = () => numberString[2] !== '-' && numberString[3] !== '-';
|
|
4453
|
-
|
|
4454
4130
|
return {
|
|
4455
4131
|
getTimeString,
|
|
4456
4132
|
getSelectionModifier,
|
|
@@ -4468,18 +4144,14 @@ function getTimeStringCorrector(str, is24HourClock) {
|
|
|
4468
4144
|
hasTypedMinutes
|
|
4469
4145
|
};
|
|
4470
4146
|
}
|
|
4471
|
-
|
|
4472
4147
|
const correct12HourTime = (time, mustCompleteTime) => {
|
|
4473
4148
|
const timeStringCorrector = getTimeStringCorrector(time, false);
|
|
4474
|
-
|
|
4475
4149
|
if (mustCompleteTime) {
|
|
4476
4150
|
timeStringCorrector.replaceDashes();
|
|
4477
4151
|
}
|
|
4478
|
-
|
|
4479
4152
|
if (timeStringCorrector.firstHourGreaterThan1()) {
|
|
4480
4153
|
timeStringCorrector.prependCharacter('0');
|
|
4481
4154
|
}
|
|
4482
|
-
|
|
4483
4155
|
if (timeStringCorrector.hoursGreaterThan12()) {
|
|
4484
4156
|
if (timeStringCorrector.hasTypedMinutes()) {
|
|
4485
4157
|
// User likely just edited the first digit and that made the
|
|
@@ -4492,30 +4164,24 @@ const correct12HourTime = (time, mustCompleteTime) => {
|
|
|
4492
4164
|
timeStringCorrector.prependCharacter('0');
|
|
4493
4165
|
}
|
|
4494
4166
|
}
|
|
4495
|
-
|
|
4496
4167
|
if (timeStringCorrector.hoursAre00()) {
|
|
4497
4168
|
timeStringCorrector.setHoursTo12();
|
|
4498
4169
|
}
|
|
4499
|
-
|
|
4500
4170
|
if (timeStringCorrector.firstMinuteGreaterThan5()) {
|
|
4501
4171
|
// Assume the user forgot a 0
|
|
4502
4172
|
// Example: we are changing 12:6- to 12:06
|
|
4503
4173
|
timeStringCorrector.shiftMinutesRight();
|
|
4504
4174
|
}
|
|
4505
|
-
|
|
4506
4175
|
return {
|
|
4507
4176
|
correctedTime: timeStringCorrector.getTimeString(),
|
|
4508
4177
|
selectionModifier: timeStringCorrector.getSelectionModifier()
|
|
4509
4178
|
};
|
|
4510
4179
|
};
|
|
4511
|
-
|
|
4512
4180
|
const correct24HourTime = (time, mustCompleteTime) => {
|
|
4513
4181
|
const timeStringCorrector = getTimeStringCorrector(time, true);
|
|
4514
|
-
|
|
4515
4182
|
if (mustCompleteTime) {
|
|
4516
4183
|
timeStringCorrector.replaceDashes();
|
|
4517
4184
|
}
|
|
4518
|
-
|
|
4519
4185
|
if (timeStringCorrector.hoursGreaterThan23()) {
|
|
4520
4186
|
// User likely just edited the first digit and that made the second
|
|
4521
4187
|
// digit invalid, e.g., changed '15:' to '25:'. They probably
|
|
@@ -4528,29 +4194,26 @@ const correct24HourTime = (time, mustCompleteTime) => {
|
|
|
4528
4194
|
timeStringCorrector.prependCharacter('0');
|
|
4529
4195
|
}
|
|
4530
4196
|
}
|
|
4531
|
-
|
|
4532
4197
|
if (timeStringCorrector.firstHourGreaterThan2()) {
|
|
4533
4198
|
// Assume the user forgot a leading 0
|
|
4534
4199
|
// Example: we are changing '3-:--' to '03:--'
|
|
4535
4200
|
timeStringCorrector.prependCharacter('0');
|
|
4536
4201
|
}
|
|
4537
|
-
|
|
4538
4202
|
if (timeStringCorrector.firstMinuteGreaterThan5()) {
|
|
4539
4203
|
// Assume the user forgot a 0
|
|
4540
4204
|
// Example: we are changing 12:6- to 12:06
|
|
4541
4205
|
timeStringCorrector.shiftMinutesRight();
|
|
4542
4206
|
}
|
|
4543
|
-
|
|
4544
4207
|
return {
|
|
4545
4208
|
correctedTime: timeStringCorrector.getTimeString(),
|
|
4546
4209
|
selectionModifier: timeStringCorrector.getSelectionModifier()
|
|
4547
4210
|
};
|
|
4548
|
-
};
|
|
4211
|
+
};
|
|
4212
|
+
|
|
4213
|
+
// We will follow the same process to correct the time regardless
|
|
4549
4214
|
// of what specific character changed.
|
|
4550
4215
|
// This simplifies logic for when multiple chars are pasted in
|
|
4551
4216
|
// and for when the input has to be shifted due to invalid entries.
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
4217
|
const correctTime = (time, is24HourClock, mustCompleteTime) => is24HourClock ? correct24HourTime(time, mustCompleteTime) : correct12HourTime(time, mustCompleteTime);
|
|
4555
4218
|
|
|
4556
4219
|
const TimeInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
@@ -4594,8 +4257,7 @@ const TimeInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
4594
4257
|
correctedTime,
|
|
4595
4258
|
selectionModifier
|
|
4596
4259
|
} = correctTime(next.value, is24HourClock, false);
|
|
4597
|
-
const newSelection = next
|
|
4598
|
-
|
|
4260
|
+
const newSelection = next?.selection;
|
|
4599
4261
|
if (newSelection) {
|
|
4600
4262
|
const validTimeLength = mask.length;
|
|
4601
4263
|
newSelection.start = shouldMoveSelectionToEnd ? validTimeLength : newSelection.start;
|
|
@@ -4603,9 +4265,9 @@ const TimeInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
4603
4265
|
newSelection.start = Math.min(newSelection.start + selectionModifier, validTimeLength);
|
|
4604
4266
|
newSelection.end = Math.min(newSelection.end + selectionModifier, validTimeLength);
|
|
4605
4267
|
}
|
|
4606
|
-
|
|
4607
4268
|
setShouldMoveSelectionToEnd(false);
|
|
4608
|
-
return {
|
|
4269
|
+
return {
|
|
4270
|
+
...next,
|
|
4609
4271
|
value: correctedTime,
|
|
4610
4272
|
selection: newSelection
|
|
4611
4273
|
};
|
|
@@ -4627,7 +4289,7 @@ const TimeInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
4627
4289
|
"aria-labelledby": ariaLabelledBy,
|
|
4628
4290
|
"aria-describedby": ariaDescribedBy,
|
|
4629
4291
|
"aria-activedescendant": ariaActiveDescendant,
|
|
4630
|
-
"data-testid": dataTestId &&
|
|
4292
|
+
"data-testid": dataTestId && `${dataTestId}-input`
|
|
4631
4293
|
}));
|
|
4632
4294
|
});
|
|
4633
4295
|
|
|
@@ -4648,10 +4310,8 @@ const TimePickerIcon = _ref => {
|
|
|
4648
4310
|
})
|
|
4649
4311
|
}, /*#__PURE__*/React__default["default"].createElement(icons_index.ChevronDownIcon, {
|
|
4650
4312
|
onClick: !isDisabled ? () => {
|
|
4651
|
-
var _inputRef$current;
|
|
4652
|
-
|
|
4653
4313
|
setIsFlyoutOpen(i => !i);
|
|
4654
|
-
|
|
4314
|
+
inputRef.current?.focus();
|
|
4655
4315
|
} : undefined,
|
|
4656
4316
|
onMouseDown: e => e.preventDefault(),
|
|
4657
4317
|
ref: iconRef
|
|
@@ -4667,7 +4327,6 @@ const DEFAULT_TIME = (() => {
|
|
|
4667
4327
|
minute
|
|
4668
4328
|
};
|
|
4669
4329
|
})();
|
|
4670
|
-
|
|
4671
4330
|
const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
|
|
4672
4331
|
let {
|
|
4673
4332
|
value: externalValue,
|
|
@@ -4682,12 +4341,13 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4682
4341
|
'aria-describedby': ariaDescribedBy
|
|
4683
4342
|
} = _ref;
|
|
4684
4343
|
const timePickerId = index.useId(externalId);
|
|
4685
|
-
const inputId =
|
|
4686
|
-
const dropdownId =
|
|
4344
|
+
const inputId = `${timePickerId}-input`;
|
|
4345
|
+
const dropdownId = `${timePickerId}-dropdown`;
|
|
4687
4346
|
const [isOptionHovered, setIsOptionHovered] = React.useState(false);
|
|
4688
4347
|
const [timeObject, setTimeObject] = index.useControllableState(DEFAULT_TIME, externalOnChange, externalValue);
|
|
4689
|
-
const defaultTimeString = convertTimeObjectToTimeString(timeObject, is24HourClock);
|
|
4348
|
+
const defaultTimeString = convertTimeObjectToTimeString(timeObject, is24HourClock);
|
|
4690
4349
|
|
|
4350
|
+
// timeString needs its own state instead of always being derived from timeObject, since typing doesn't "commit" a new time.
|
|
4691
4351
|
const [timeString, setTimeString] = React.useState(defaultTimeString);
|
|
4692
4352
|
const [isTimeStringDirty, setIsTimeStringDirty] = React.useState(false);
|
|
4693
4353
|
const step = 60 * 30;
|
|
@@ -4698,11 +4358,10 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4698
4358
|
} = correctTime(typedTime, is24HourClock, true);
|
|
4699
4359
|
const correctedTimeObject = convertTimeStringToTimeObject(correctedTime);
|
|
4700
4360
|
const correctedTimeValue = correctedTimeObject.hour * 60 * 60 + correctedTimeObject.minute * 60;
|
|
4701
|
-
let minDistance = correctedTimeValue - dropdownItems[0].value;
|
|
4702
|
-
|
|
4361
|
+
let minDistance = correctedTimeValue - dropdownItems[0].value;
|
|
4362
|
+
// Substring search up to first empty spot
|
|
4703
4363
|
for (let i = 1; i < dropdownItems.length; i += 1) {
|
|
4704
4364
|
const distance = correctedTimeValue - dropdownItems[i].value;
|
|
4705
|
-
|
|
4706
4365
|
if (distance > minDistance || distance < 0) {
|
|
4707
4366
|
return {
|
|
4708
4367
|
index: i - 1,
|
|
@@ -4710,10 +4369,8 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4710
4369
|
isExactMatch: minDistance === 0
|
|
4711
4370
|
};
|
|
4712
4371
|
}
|
|
4713
|
-
|
|
4714
4372
|
minDistance = distance;
|
|
4715
4373
|
}
|
|
4716
|
-
|
|
4717
4374
|
return {
|
|
4718
4375
|
index: dropdownItems.length - 1,
|
|
4719
4376
|
isFocused: false,
|
|
@@ -4721,8 +4378,9 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4721
4378
|
};
|
|
4722
4379
|
}, [is24HourClock, dropdownItems]);
|
|
4723
4380
|
const [scrolledToItem, setScrolledToItem] = React.useState(() => getScrolledToItemFromTimeString(timeString));
|
|
4724
|
-
const [shouldMoveSelectionToEnd, setShouldMoveSelectionToEnd] = React.useState(true);
|
|
4381
|
+
const [shouldMoveSelectionToEnd, setShouldMoveSelectionToEnd] = React.useState(true);
|
|
4725
4382
|
|
|
4383
|
+
// timeObject may be controlled and may change at any time, so we need to update timeString and the focused item whenever it changes.
|
|
4726
4384
|
React.useEffect(() => {
|
|
4727
4385
|
const newTimeString = convertTimeObjectToTimeString(timeObject, is24HourClock);
|
|
4728
4386
|
setTimeString(newTimeString);
|
|
@@ -4730,8 +4388,9 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4730
4388
|
setShouldMoveSelectionToEnd(true);
|
|
4731
4389
|
setScrolledToItem(getScrolledToItemFromTimeString(newTimeString));
|
|
4732
4390
|
}, [timeObject, is24HourClock, getScrolledToItemFromTimeString]);
|
|
4733
|
-
const [isFlyoutOpen, setIsFlyoutOpen] = React.useState(false);
|
|
4391
|
+
const [isFlyoutOpen, setIsFlyoutOpen] = React.useState(false);
|
|
4734
4392
|
|
|
4393
|
+
// Sets the actual time object and updates the flyout and focus state
|
|
4735
4394
|
const commitTimeString = function () {
|
|
4736
4395
|
let newTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : timeString;
|
|
4737
4396
|
const {
|
|
@@ -4741,12 +4400,10 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4741
4400
|
setTimeObject(newTimeObject);
|
|
4742
4401
|
setIsFlyoutOpen(false);
|
|
4743
4402
|
};
|
|
4744
|
-
|
|
4745
4403
|
const inputRef = React.useRef(null);
|
|
4746
4404
|
const dropdownRef = React.useRef(null);
|
|
4747
4405
|
const iconRef = React.useRef(null);
|
|
4748
4406
|
index.useClickOutside([inputRef, dropdownRef, iconRef], () => isTimeStringDirty ? commitTimeString() : setIsFlyoutOpen(false));
|
|
4749
|
-
|
|
4750
4407
|
const focusNext = () => {
|
|
4751
4408
|
setScrolledToItem(f => {
|
|
4752
4409
|
if (!f.isFocused) {
|
|
@@ -4758,11 +4415,9 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4758
4415
|
isExactMatch: false
|
|
4759
4416
|
};
|
|
4760
4417
|
}
|
|
4761
|
-
|
|
4762
4418
|
if (f.index === dropdownItems.length - 1) {
|
|
4763
4419
|
return f;
|
|
4764
4420
|
}
|
|
4765
|
-
|
|
4766
4421
|
return {
|
|
4767
4422
|
index: f.index + 1,
|
|
4768
4423
|
isFocused: true,
|
|
@@ -4770,7 +4425,6 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4770
4425
|
};
|
|
4771
4426
|
});
|
|
4772
4427
|
};
|
|
4773
|
-
|
|
4774
4428
|
const focusPrevious = () => {
|
|
4775
4429
|
setScrolledToItem(f => {
|
|
4776
4430
|
if (!f.isFocused) {
|
|
@@ -4782,11 +4436,9 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4782
4436
|
isExactMatch: false
|
|
4783
4437
|
};
|
|
4784
4438
|
}
|
|
4785
|
-
|
|
4786
4439
|
if (f.index === 0) {
|
|
4787
4440
|
return f;
|
|
4788
4441
|
}
|
|
4789
|
-
|
|
4790
4442
|
return {
|
|
4791
4443
|
index: f.index - 1,
|
|
4792
4444
|
isFocused: true,
|
|
@@ -4794,20 +4446,17 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4794
4446
|
};
|
|
4795
4447
|
});
|
|
4796
4448
|
};
|
|
4797
|
-
|
|
4798
4449
|
const handleType = typedTime => {
|
|
4799
4450
|
setIsFlyoutOpen(true);
|
|
4800
4451
|
setTimeString(typedTime);
|
|
4801
4452
|
setIsTimeStringDirty(true);
|
|
4802
4453
|
setScrolledToItem(getScrolledToItemFromTimeString(typedTime));
|
|
4803
4454
|
};
|
|
4804
|
-
|
|
4805
4455
|
const handleSelectTime = selectedIndex => {
|
|
4806
4456
|
const timeLabel = dropdownItems[selectedIndex].label;
|
|
4807
4457
|
setIsOptionHovered(false);
|
|
4808
4458
|
commitTimeString(timeLabel);
|
|
4809
4459
|
};
|
|
4810
|
-
|
|
4811
4460
|
const handleKeyDown = e => {
|
|
4812
4461
|
switch (e.key) {
|
|
4813
4462
|
case 'ArrowUp':
|
|
@@ -4815,44 +4464,37 @@ const TimePicker = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
4815
4464
|
setIsFlyoutOpen(true);
|
|
4816
4465
|
focusPrevious();
|
|
4817
4466
|
break;
|
|
4818
|
-
|
|
4819
4467
|
case 'ArrowDown':
|
|
4820
4468
|
e.preventDefault();
|
|
4821
4469
|
setIsFlyoutOpen(true);
|
|
4822
4470
|
focusNext();
|
|
4823
4471
|
break;
|
|
4824
|
-
|
|
4825
4472
|
case 'Enter':
|
|
4826
4473
|
e.preventDefault();
|
|
4827
|
-
|
|
4828
|
-
if (scrolledToItem !== null && scrolledToItem !== void 0 && scrolledToItem.isFocused) {
|
|
4474
|
+
if (scrolledToItem?.isFocused) {
|
|
4829
4475
|
// "focus" is on the listbox
|
|
4830
4476
|
handleSelectTime(scrolledToItem.index);
|
|
4831
4477
|
} else {
|
|
4832
4478
|
// "focus" is on the input
|
|
4833
4479
|
commitTimeString();
|
|
4834
4480
|
}
|
|
4835
|
-
|
|
4836
4481
|
break;
|
|
4837
|
-
|
|
4838
4482
|
case 'Escape':
|
|
4839
4483
|
case 'Tab':
|
|
4840
4484
|
// use whatever time is closest to what's in the input
|
|
4841
4485
|
commitTimeString();
|
|
4842
4486
|
break;
|
|
4843
|
-
|
|
4844
4487
|
default:
|
|
4845
4488
|
break;
|
|
4846
4489
|
}
|
|
4847
4490
|
};
|
|
4848
|
-
|
|
4849
4491
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
4850
4492
|
id: timePickerId,
|
|
4851
4493
|
className: styles$1.container
|
|
4852
4494
|
}, /*#__PURE__*/React__default["default"].createElement(TimeInput, {
|
|
4853
4495
|
id: inputId,
|
|
4854
4496
|
dataTestId: dataTestId,
|
|
4855
|
-
ariaActiveDescendant: isFlyoutOpen && scrolledToItem
|
|
4497
|
+
ariaActiveDescendant: isFlyoutOpen && scrolledToItem?.isFocused ? dropdownItems[scrolledToItem.index].id : undefined,
|
|
4856
4498
|
ariaControls: dropdownId,
|
|
4857
4499
|
ariaExpanded: isFlyoutOpen,
|
|
4858
4500
|
onChange: handleType,
|
|
@@ -4896,9 +4538,9 @@ const {
|
|
|
4896
4538
|
Provider: ToggleButtonGroupContextProvider
|
|
4897
4539
|
} = index.createContextUtilities(null);
|
|
4898
4540
|
|
|
4899
|
-
var css_248z = ".
|
|
4900
|
-
var styles = {"default":"
|
|
4901
|
-
var stylesheet=".
|
|
4541
|
+
var css_248z = "._PuI9l{border-color:transparent;background-color:transparent;color:#515559;cursor:pointer}._-duka{background-color:rgba(50,54,58,.08)}._SKJcD{color:#0b6ed0;background-color:rgba(11,110,208,.08)}._WKCxg{color:rgba(81,85,89,.4);cursor:not-allowed}._1neWE{background:rgba(11,110,208,.08);color:#0b6ed0;border-color:#0b6ed0}._kHxeD{color:#085caf;border-color:#085caf}._kHxeD,._PvYtr{background:rgba(11,110,208,.11)}._PvYtr{color:#0854a1;border-color:#0854a1}._QMIYy{background:rgba(11,110,208,.032);color:rgba(11,110,208,.4);border-color:rgba(11,110,208,.4)}._6Ukbw{position:relative;display:inline-grid}._6Ukbw svg{fill:currentColor}._6Ukbw ._TmGvX{-webkit-appearance:none;-moz-appearance:none;appearance:none;grid-column:1;grid-row:1}._6Ukbw ._TmGvX+._Wgw18{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}._6Ukbw ._TmGvX+._Wgw18._6xCAS{padding:5px;max-width:36px;min-width:36px}._6Ukbw ._TmGvX+._Wgw18._jcIXo{padding:0 16px}._6Ukbw ._TmGvX+._Wgw18._7WNP6{padding:0 16px 0 12px}._6Ukbw ._TmGvX:hover+._Wgw18{background-color:rgba(50,54,58,.08)}._6Ukbw ._TmGvX:disabled+._Wgw18{color:rgba(81,85,89,.4);cursor:not-allowed}._6Ukbw ._TmGvX:active+._Wgw18,._6Ukbw ._TmGvX:focus:active+._Wgw18{color:#0b6ed0;background-color:rgba(11,110,208,.08)}._6Ukbw ._TmGvX:checked+._Wgw18{background:rgba(11,110,208,.08);color:#0b6ed0;border-color:#0b6ed0}._6Ukbw ._TmGvX:checked:hover+._Wgw18{background:rgba(11,110,208,.11);color:#085caf;border-color:#085caf}._6Ukbw ._TmGvX:checked:disabled+._Wgw18{background:rgba(11,110,208,.032);color:rgba(11,110,208,.4);border-color:rgba(11,110,208,.4)}._6Ukbw ._TmGvX:checked:active+._Wgw18,._6Ukbw ._TmGvX:checked:focus:active+._Wgw18{background:rgba(11,110,208,.11);color:#0854a1;border-color:#0854a1}._whLDV{display:inline-flex;position:relative}._whLDV:before{content:\"\";border:1px solid #d9d9d9;border-radius:4px;position:absolute;top:0;bottom:0;right:0;left:0}._whLDV>*{flex-shrink:0;flex-grow:0}._jfy3v{border:none;margin:0;padding:0}._jfy3v legend{padding:0;display:block;font-size:14px;margin-bottom:6px;color:#515559}body.keyboard-user ._6Ukbw ._TmGvX:active:focus+._Wgw18,body.keyboard-user ._6Ukbw ._TmGvX:focus+._Wgw18{z-index:20;outline:none;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
|
|
4542
|
+
var styles = {"default":"_PuI9l","hovered":"_-duka","pressed":"_SKJcD","disabled":"_WKCxg","selectedDefault":"_1neWE","selectedHovered":"_kHxeD","selectedPressed":"_PvYtr","selectedDisabled":"_QMIYy","toggleContainer":"_6Ukbw","toggleInput":"_TmGvX","toggleButton":"_Wgw18","iconOnly":"_6xCAS","text":"_jcIXo","iconText":"_7WNP6","toggleButtonGroup":"_whLDV","toggleButtonGroupFieldset":"_jfy3v"};
|
|
4543
|
+
var stylesheet="._PuI9l{border-color:transparent;background-color:transparent;color:#515559;cursor:pointer}._-duka{background-color:rgba(50,54,58,.08)}._SKJcD{color:#0b6ed0;background-color:rgba(11,110,208,.08)}._WKCxg{color:rgba(81,85,89,.4);cursor:not-allowed}._1neWE{background:rgba(11,110,208,.08);color:#0b6ed0;border-color:#0b6ed0}._kHxeD{color:#085caf;border-color:#085caf}._kHxeD,._PvYtr{background:rgba(11,110,208,.11)}._PvYtr{color:#0854a1;border-color:#0854a1}._QMIYy{background:rgba(11,110,208,.032);color:rgba(11,110,208,.4);border-color:rgba(11,110,208,.4)}._6Ukbw{position:relative;display:inline-grid}._6Ukbw svg{fill:currentColor}._6Ukbw ._TmGvX{-webkit-appearance:none;-moz-appearance:none;appearance:none;grid-column:1;grid-row:1}._6Ukbw ._TmGvX+._Wgw18{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}._6Ukbw ._TmGvX+._Wgw18._6xCAS{padding:5px;max-width:36px;min-width:36px}._6Ukbw ._TmGvX+._Wgw18._jcIXo{padding:0 16px}._6Ukbw ._TmGvX+._Wgw18._7WNP6{padding:0 16px 0 12px}._6Ukbw ._TmGvX:hover+._Wgw18{background-color:rgba(50,54,58,.08)}._6Ukbw ._TmGvX:disabled+._Wgw18{color:rgba(81,85,89,.4);cursor:not-allowed}._6Ukbw ._TmGvX:active+._Wgw18,._6Ukbw ._TmGvX:focus:active+._Wgw18{color:#0b6ed0;background-color:rgba(11,110,208,.08)}._6Ukbw ._TmGvX:checked+._Wgw18{background:rgba(11,110,208,.08);color:#0b6ed0;border-color:#0b6ed0}._6Ukbw ._TmGvX:checked:hover+._Wgw18{background:rgba(11,110,208,.11);color:#085caf;border-color:#085caf}._6Ukbw ._TmGvX:checked:disabled+._Wgw18{background:rgba(11,110,208,.032);color:rgba(11,110,208,.4);border-color:rgba(11,110,208,.4)}._6Ukbw ._TmGvX:checked:active+._Wgw18,._6Ukbw ._TmGvX:checked:focus:active+._Wgw18{background:rgba(11,110,208,.11);color:#0854a1;border-color:#0854a1}._whLDV{display:inline-flex;position:relative}._whLDV:before{content:\"\";border:1px solid #d9d9d9;border-radius:4px;position:absolute;top:0;bottom:0;right:0;left:0}._whLDV>*{flex-shrink:0;flex-grow:0}._jfy3v{border:none;margin:0;padding:0}._jfy3v legend{padding:0;display:block;font-size:14px;margin-bottom:6px;color:#515559}body.keyboard-user ._6Ukbw ._TmGvX:active:focus+._Wgw18,body.keyboard-user ._6Ukbw ._TmGvX:focus+._Wgw18{z-index:20;outline:none;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
|
|
4902
4544
|
icons_index.styleInject(css_248z);
|
|
4903
4545
|
|
|
4904
4546
|
const ToggleButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
@@ -4922,7 +4564,8 @@ const ToggleButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
4922
4564
|
}
|
|
4923
4565
|
}, /*#__PURE__*/React__default["default"].createElement("fieldset", {
|
|
4924
4566
|
className: styles.toggleButtonGroupFieldset,
|
|
4925
|
-
disabled: isDisabled
|
|
4567
|
+
disabled: isDisabled
|
|
4568
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
4926
4569
|
,
|
|
4927
4570
|
role: "radiogroup",
|
|
4928
4571
|
"aria-label": ariaLabel,
|
|
@@ -4952,27 +4595,22 @@ const ToggleButton = /*#__PURE__*/React__default["default"].forwardRef((_ref, re
|
|
|
4952
4595
|
let checked = isActivated;
|
|
4953
4596
|
let disabled = isDisabled;
|
|
4954
4597
|
let name = inputName;
|
|
4955
|
-
|
|
4956
4598
|
let handleChange = () => {
|
|
4957
4599
|
if (onChange) {
|
|
4958
4600
|
onChange(checked);
|
|
4959
4601
|
}
|
|
4960
4602
|
};
|
|
4961
|
-
|
|
4962
4603
|
if (inGroup) {
|
|
4963
4604
|
checked = value === groupContext.value;
|
|
4964
4605
|
disabled = groupContext.isDisabled || isDisabled;
|
|
4965
4606
|
name = groupContext.name;
|
|
4966
|
-
|
|
4967
4607
|
handleChange = () => {
|
|
4968
4608
|
if (onChange) {
|
|
4969
4609
|
onChange(checked);
|
|
4970
4610
|
}
|
|
4971
|
-
|
|
4972
4611
|
groupContext.onChange(value);
|
|
4973
4612
|
};
|
|
4974
4613
|
}
|
|
4975
|
-
|
|
4976
4614
|
return /*#__PURE__*/React__default["default"].createElement("span", {
|
|
4977
4615
|
ref: ref,
|
|
4978
4616
|
className: styles.toggleContainer
|
|
@@ -5054,7 +4692,6 @@ const convertAlignment = alignment => {
|
|
|
5054
4692
|
};
|
|
5055
4693
|
return alignmentMap[alignment];
|
|
5056
4694
|
};
|
|
5057
|
-
|
|
5058
4695
|
// Explicitly listed props to prevent arbitrary prop spreading
|
|
5059
4696
|
const Stack = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
5060
4697
|
let {
|
|
@@ -5083,13 +4720,11 @@ const Stack = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
5083
4720
|
'aria-describedby': ariaDescribedBy,
|
|
5084
4721
|
'data-testid': dataTestId
|
|
5085
4722
|
} = _ref;
|
|
5086
|
-
|
|
5087
4723
|
const checkIsStackItem = child => {
|
|
5088
4724
|
if (!(child.type && (child.type === StackItem || child.type === HStack || child.type === VStack))) {
|
|
5089
4725
|
throw new Error('Stack received an invalid child. Only StackItems are valid children of Stacks.');
|
|
5090
4726
|
}
|
|
5091
4727
|
};
|
|
5092
|
-
|
|
5093
4728
|
React.useEffect(() => {
|
|
5094
4729
|
if (Array.isArray(children)) {
|
|
5095
4730
|
children.forEach(child => {
|