@elliemae/ds-menu-button 3.45.0-rc.1 → 3.45.0-rc.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/DSMenuButton.js +16 -5
- package/dist/cjs/DSMenuButton.js.map +2 -2
- package/dist/cjs/config/useMenuButton.js +49 -18
- package/dist/cjs/config/useMenuButton.js.map +3 -3
- package/dist/cjs/config/useSplitInherithedProps.js +141 -0
- package/dist/cjs/config/useSplitInherithedProps.js.map +7 -0
- package/dist/cjs/config/useValidateProps.js.map +2 -2
- package/dist/cjs/constants/index.js +17 -4
- package/dist/cjs/constants/index.js.map +2 -2
- package/dist/cjs/index.js +7 -3
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/parts/DSFlyoutMenu/DSFlyoutMenu.js +96 -0
- package/dist/cjs/parts/DSFlyoutMenu/DSFlyoutMenu.js.map +7 -0
- package/dist/cjs/parts/DSFlyoutMenu/config/useFlyoutMenu.js +54 -0
- package/dist/cjs/parts/DSFlyoutMenu/config/useFlyoutMenu.js.map +7 -0
- package/dist/cjs/parts/{ItemFactory.js → DSFlyoutMenu/config/useValidateProps.js} +9 -35
- package/dist/cjs/parts/DSFlyoutMenu/config/useValidateProps.js.map +7 -0
- package/dist/cjs/parts/DSFlyoutMenu/constants/index.js +46 -0
- package/dist/cjs/parts/DSFlyoutMenu/constants/index.js.map +7 -0
- package/dist/cjs/{DSMenuButtonCTX.js → parts/DSFlyoutMenu/index.js} +7 -8
- package/dist/cjs/parts/DSFlyoutMenu/index.js.map +7 -0
- package/dist/cjs/parts/DSFlyoutMenu/react-desc-prop-types.js +62 -0
- package/dist/cjs/parts/DSFlyoutMenu/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.js +70 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js +40 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useFocusTracker.js +186 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useFocusTracker.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useGlobalEvents.js +89 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useGlobalEvents.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuBehaviouralContextProvider.js +92 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuBehaviouralContextProvider.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js +315 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuOpenStatus.js +66 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuOpenStatus.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useValidateProps.js +40 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useValidateProps.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/constants/Errors.js +58 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/constants/Errors.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/constants/index.js +44 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/constants/index.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/index.js +37 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/index.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/react-desc-prop-types.js +53 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/utils/multipleSelectionHelpers.js +139 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/utils/multipleSelectionHelpers.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/utils/nodeGettersByCriterias.js +144 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/utils/nodeGettersByCriterias.js.map +7 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/utils/singleSelectionHelpers.js +44 -0
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/utils/singleSelectionHelpers.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/ActivableMenuItem.js +116 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/ActivableMenuItem.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/ActivableWithSubmenuMenuItem.js +159 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/ActivableWithSubmenuMenuItem.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/DSMenuItemRendererFactory.js +97 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/DSMenuItemRendererFactory.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/MultipleSelectMenuItem.js +122 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/MultipleSelectMenuItem.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/MultipleSelectWithSubmenuMenuItem.js +173 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/MultipleSelectWithSubmenuMenuItem.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/SingleSelectMenuItem.js +130 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/SingleSelectMenuItem.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/SingleSelectWithSubmenuMenuItem.js +176 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/SingleSelectWithSubmenuMenuItem.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/WithSubmenuMenuItem.js +162 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/WithSubmenuMenuItem.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/config/useMenuItemRendererFactory.js +57 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/config/useMenuItemRendererFactory.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/config/useValidateProps.js +40 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/config/useValidateProps.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/constants/index.js +48 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/constants/index.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/index.js +37 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/index.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/react-desc-prop-types.js +51 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/useMenuItemHighlightState.js +62 -0
- package/dist/cjs/parts/DSMenuItemRendererFactory/useMenuItemHighlightState.js.map +7 -0
- package/dist/cjs/parts/DSOpinionatedButton/DSOpinionatedButton.js +100 -0
- package/dist/cjs/parts/DSOpinionatedButton/DSOpinionatedButton.js.map +7 -0
- package/dist/cjs/parts/DSOpinionatedButton/config/useOpinionatedButton.js +80 -0
- package/dist/cjs/parts/DSOpinionatedButton/config/useOpinionatedButton.js.map +7 -0
- package/dist/cjs/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.js +98 -0
- package/dist/cjs/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.js.map +7 -0
- package/dist/cjs/parts/DSOpinionatedButton/config/useValidateProps.js +40 -0
- package/dist/cjs/parts/DSOpinionatedButton/config/useValidateProps.js.map +7 -0
- package/dist/cjs/parts/DSOpinionatedButton/constants/index.js +48 -0
- package/dist/cjs/parts/DSOpinionatedButton/constants/index.js.map +7 -0
- package/dist/cjs/parts/DSOpinionatedButton/index.js +37 -0
- package/dist/cjs/parts/DSOpinionatedButton/index.js.map +7 -0
- package/dist/cjs/parts/DSOpinionatedButton/react-desc-prop-types.js +53 -0
- package/dist/cjs/parts/DSOpinionatedButton/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +61 -25
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/utils/nodesTypeguardsAndGetters.js +123 -0
- package/dist/cjs/utils/nodesTypeguardsAndGetters.js.map +7 -0
- package/dist/cjs/utils/useOptionsArrayToDsTree.js +55 -0
- package/dist/cjs/utils/useOptionsArrayToDsTree.js.map +7 -0
- package/dist/esm/DSMenuButton.js +19 -8
- package/dist/esm/DSMenuButton.js.map +2 -2
- package/dist/esm/config/useMenuButton.js +51 -20
- package/dist/esm/config/useMenuButton.js.map +3 -3
- package/dist/esm/config/useSplitInherithedProps.js +111 -0
- package/dist/esm/config/useSplitInherithedProps.js.map +7 -0
- package/dist/esm/config/useValidateProps.js.map +2 -2
- package/dist/esm/constants/index.js +17 -4
- package/dist/esm/constants/index.js.map +2 -2
- package/dist/esm/index.js +8 -4
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/parts/DSFlyoutMenu/DSFlyoutMenu.js +66 -0
- package/dist/esm/parts/DSFlyoutMenu/DSFlyoutMenu.js.map +7 -0
- package/dist/esm/parts/DSFlyoutMenu/config/useFlyoutMenu.js +24 -0
- package/dist/esm/parts/DSFlyoutMenu/config/useFlyoutMenu.js.map +7 -0
- package/dist/esm/parts/DSFlyoutMenu/config/useValidateProps.js +10 -0
- package/dist/esm/parts/DSFlyoutMenu/config/useValidateProps.js.map +7 -0
- package/dist/esm/parts/DSFlyoutMenu/constants/index.js +16 -0
- package/dist/esm/parts/DSFlyoutMenu/constants/index.js.map +7 -0
- package/dist/esm/parts/DSFlyoutMenu/index.js +7 -0
- package/dist/esm/parts/DSFlyoutMenu/index.js.map +7 -0
- package/dist/esm/parts/DSFlyoutMenu/react-desc-prop-types.js +40 -0
- package/dist/esm/parts/DSFlyoutMenu/react-desc-prop-types.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.js +42 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js +10 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useFocusTracker.js +161 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useFocusTracker.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useGlobalEvents.js +59 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useGlobalEvents.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useMenuBehaviouralContextProvider.js +65 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useMenuBehaviouralContextProvider.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js +292 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useMenuOpenStatus.js +36 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useMenuOpenStatus.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useValidateProps.js +10 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useValidateProps.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/constants/Errors.js +28 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/constants/Errors.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/constants/index.js +14 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/constants/index.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/index.js +10 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/index.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/react-desc-prop-types.js +23 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/react-desc-prop-types.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/utils/multipleSelectionHelpers.js +113 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/utils/multipleSelectionHelpers.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/utils/nodeGettersByCriterias.js +123 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/utils/nodeGettersByCriterias.js.map +7 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/utils/singleSelectionHelpers.js +14 -0
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/utils/singleSelectionHelpers.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/ActivableMenuItem.js +91 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/ActivableMenuItem.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/ActivableWithSubmenuMenuItem.js +134 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/ActivableWithSubmenuMenuItem.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/DSMenuItemRendererFactory.js +78 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/DSMenuItemRendererFactory.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/MultipleSelectMenuItem.js +97 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/MultipleSelectMenuItem.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/MultipleSelectWithSubmenuMenuItem.js +148 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/MultipleSelectWithSubmenuMenuItem.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/SingleSelectMenuItem.js +105 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/SingleSelectMenuItem.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/SingleSelectWithSubmenuMenuItem.js +151 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/SingleSelectWithSubmenuMenuItem.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/WithSubmenuMenuItem.js +137 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/WithSubmenuMenuItem.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/config/useMenuItemRendererFactory.js +30 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/config/useMenuItemRendererFactory.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/config/useValidateProps.js +10 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/config/useValidateProps.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/constants/index.js +18 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/constants/index.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/index.js +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/index.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/react-desc-prop-types.js +26 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/react-desc-prop-types.js.map +7 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/useMenuItemHighlightState.js +32 -0
- package/dist/esm/parts/DSMenuItemRendererFactory/useMenuItemHighlightState.js.map +7 -0
- package/dist/esm/parts/DSOpinionatedButton/DSOpinionatedButton.js +70 -0
- package/dist/esm/parts/DSOpinionatedButton/DSOpinionatedButton.js.map +7 -0
- package/dist/esm/parts/DSOpinionatedButton/config/useOpinionatedButton.js +53 -0
- package/dist/esm/parts/DSOpinionatedButton/config/useOpinionatedButton.js.map +7 -0
- package/dist/esm/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.js +68 -0
- package/dist/esm/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.js.map +7 -0
- package/dist/esm/parts/DSOpinionatedButton/config/useValidateProps.js +10 -0
- package/dist/esm/parts/DSOpinionatedButton/config/useValidateProps.js.map +7 -0
- package/dist/esm/parts/DSOpinionatedButton/constants/index.js +18 -0
- package/dist/esm/parts/DSOpinionatedButton/constants/index.js.map +7 -0
- package/dist/esm/parts/DSOpinionatedButton/index.js +10 -0
- package/dist/esm/parts/DSOpinionatedButton/index.js.map +7 -0
- package/dist/esm/parts/DSOpinionatedButton/react-desc-prop-types.js +23 -0
- package/dist/esm/parts/DSOpinionatedButton/react-desc-prop-types.js.map +7 -0
- package/dist/esm/react-desc-prop-types.js +62 -26
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/utils/nodesTypeguardsAndGetters.js +93 -0
- package/dist/esm/utils/nodesTypeguardsAndGetters.js.map +7 -0
- package/dist/esm/utils/useOptionsArrayToDsTree.js +25 -0
- package/dist/esm/utils/useOptionsArrayToDsTree.js.map +7 -0
- package/dist/types/DSMenuButton.d.ts +4 -6
- package/dist/types/config/useMenuButton.d.ts +9 -13
- package/dist/types/config/useSplitInherithedProps.d.ts +495 -0
- package/dist/types/config/useValidateProps.d.ts +3 -3
- package/dist/types/constants/index.d.ts +14 -2
- package/dist/types/index.d.ts +4 -2
- package/dist/types/parts/DSFlyoutMenu/DSFlyoutMenu.d.ts +5 -0
- package/dist/types/parts/DSFlyoutMenu/config/useFlyoutMenu.d.ts +8 -0
- package/dist/types/parts/DSFlyoutMenu/config/useValidateProps.d.ts +3 -0
- package/dist/types/parts/DSFlyoutMenu/constants/index.d.ts +7 -0
- package/dist/types/parts/DSFlyoutMenu/index.d.ts +1 -0
- package/dist/types/parts/DSFlyoutMenu/react-desc-prop-types.d.ts +25 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.d.ts +5 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.d.ts +5 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/config/useFocusTracker.d.ts +15 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/config/useGlobalEvents.d.ts +15 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/config/useMenuBehaviouralContextProvider.d.ts +15 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.d.ts +18 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/config/useMenuOpenStatus.d.ts +17 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/config/useValidateProps.d.ts +3 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/constants/Errors.d.ts +15 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/constants/index.d.ts +7 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/index.d.ts +1 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/react-desc-prop-types.d.ts +24 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/utils/multipleSelectionHelpers.d.ts +6 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/utils/nodeGettersByCriterias.d.ts +35 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/utils/singleSelectionHelpers.d.ts +13 -0
- package/dist/types/parts/DSMenuItemRendererFactory/ActivableMenuItem.d.ts +5 -0
- package/dist/types/parts/DSMenuItemRendererFactory/ActivableWithSubmenuMenuItem.d.ts +7 -0
- package/dist/types/parts/DSMenuItemRendererFactory/DSMenuItemRendererFactory.d.ts +5 -0
- package/dist/types/parts/DSMenuItemRendererFactory/MultipleSelectMenuItem.d.ts +5 -0
- package/dist/types/parts/DSMenuItemRendererFactory/MultipleSelectWithSubmenuMenuItem.d.ts +7 -0
- package/dist/types/parts/DSMenuItemRendererFactory/SingleSelectMenuItem.d.ts +5 -0
- package/dist/types/parts/DSMenuItemRendererFactory/SingleSelectWithSubmenuMenuItem.d.ts +7 -0
- package/dist/types/parts/DSMenuItemRendererFactory/WithSubmenuMenuItem.d.ts +7 -0
- package/dist/types/parts/DSMenuItemRendererFactory/config/useMenuItemRendererFactory.d.ts +6 -0
- package/dist/types/parts/DSMenuItemRendererFactory/config/useValidateProps.d.ts +3 -0
- package/dist/types/parts/DSMenuItemRendererFactory/constants/index.d.ts +6 -0
- package/dist/types/parts/DSMenuItemRendererFactory/index.d.ts +1 -0
- package/dist/types/parts/DSMenuItemRendererFactory/react-desc-prop-types.d.ts +24 -0
- package/dist/types/parts/DSMenuItemRendererFactory/useMenuItemHighlightState.d.ts +12 -0
- package/dist/types/parts/DSOpinionatedButton/DSOpinionatedButton.d.ts +5 -0
- package/dist/types/parts/DSOpinionatedButton/config/useOpinionatedButton.d.ts +38 -0
- package/dist/types/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.d.ts +14 -0
- package/dist/types/parts/DSOpinionatedButton/config/useValidateProps.d.ts +3 -0
- package/dist/types/parts/DSOpinionatedButton/constants/index.d.ts +6 -0
- package/dist/types/parts/DSOpinionatedButton/index.d.ts +1 -0
- package/dist/types/parts/DSOpinionatedButton/react-desc-prop-types.d.ts +23 -0
- package/dist/types/react-desc-prop-types.d.ts +206 -41
- package/dist/types/utils/nodesTypeguardsAndGetters.d.ts +22 -0
- package/dist/types/utils/useOptionsArrayToDsTree.d.ts +8 -0
- package/package.json +18 -16
- package/dist/cjs/DSMenuButtonCTX.js.map +0 -7
- package/dist/cjs/parts/ItemFactory.js.map +0 -7
- package/dist/cjs/parts/Menu.js +0 -125
- package/dist/cjs/parts/Menu.js.map +0 -7
- package/dist/cjs/parts/MenuButtonContent.js +0 -156
- package/dist/cjs/parts/MenuButtonContent.js.map +0 -7
- package/dist/cjs/parts/MenuItem.js +0 -252
- package/dist/cjs/parts/MenuItem.js.map +0 -7
- package/dist/cjs/styled.js +0 -132
- package/dist/cjs/styled.js.map +0 -7
- package/dist/esm/DSMenuButtonCTX.js +0 -8
- package/dist/esm/DSMenuButtonCTX.js.map +0 -7
- package/dist/esm/parts/ItemFactory.js +0 -36
- package/dist/esm/parts/ItemFactory.js.map +0 -7
- package/dist/esm/parts/Menu.js +0 -95
- package/dist/esm/parts/Menu.js.map +0 -7
- package/dist/esm/parts/MenuButtonContent.js +0 -126
- package/dist/esm/parts/MenuButtonContent.js.map +0 -7
- package/dist/esm/parts/MenuItem.js +0 -229
- package/dist/esm/parts/MenuItem.js.map +0 -7
- package/dist/esm/styled.js +0 -102
- package/dist/esm/styled.js.map +0 -7
- package/dist/types/DSMenuButtonCTX.d.ts +0 -15
- package/dist/types/parts/ItemFactory.d.ts +0 -14
- package/dist/types/parts/Menu.d.ts +0 -14
- package/dist/types/parts/MenuButtonContent.d.ts +0 -1
- package/dist/types/parts/MenuItem.d.ts +0 -21
- package/dist/types/styled.d.ts +0 -16
@@ -0,0 +1,89 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var useGlobalEvents_exports = {};
|
30
|
+
__export(useGlobalEvents_exports, {
|
31
|
+
useGlobalEvents: () => useGlobalEvents
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(useGlobalEvents_exports);
|
34
|
+
var React = __toESM(require("react"));
|
35
|
+
var import_react = __toESM(require("react"));
|
36
|
+
const useGlobalEvents = ({
|
37
|
+
menuOpenStatus,
|
38
|
+
handleChangeOpenedSubItems,
|
39
|
+
propsWithDefault
|
40
|
+
}) => {
|
41
|
+
const { onOpinionatedClose, isMenuOpen } = menuOpenStatus;
|
42
|
+
const { buttonDOMNodeRef } = propsWithDefault;
|
43
|
+
const mainMenuRef = import_react.default.useRef(null);
|
44
|
+
const submenusRefs = import_react.default.useRef({});
|
45
|
+
const handleSubmenusRefChange = import_react.default.useCallback(
|
46
|
+
(htmlNode, dsId) => {
|
47
|
+
if (htmlNode) {
|
48
|
+
submenusRefs.current[dsId] = htmlNode;
|
49
|
+
} else {
|
50
|
+
delete submenusRefs.current[dsId];
|
51
|
+
}
|
52
|
+
},
|
53
|
+
[]
|
54
|
+
);
|
55
|
+
import_react.default.useEffect(() => {
|
56
|
+
const closeMenuAndSubmenus = (e) => {
|
57
|
+
handleChangeOpenedSubItems([], { itemNode: null, event: e });
|
58
|
+
onOpinionatedClose({ skipFocus: true });
|
59
|
+
};
|
60
|
+
const detectIfClickIsOutsideMenuAndCloseIfSo = (e) => {
|
61
|
+
if (!isMenuOpen) return;
|
62
|
+
if (buttonDOMNodeRef.current === e.target) return;
|
63
|
+
const isClickInsideMainMenu = mainMenuRef.current?.contains(e.target);
|
64
|
+
if (isClickInsideMainMenu) return;
|
65
|
+
const submenuNodesToCheck = Object.values(submenusRefs.current).filter(Boolean);
|
66
|
+
const isClickInsideAnySubmenu = submenuNodesToCheck.some((node) => node.contains(e.target));
|
67
|
+
if (isClickInsideAnySubmenu) return;
|
68
|
+
handleChangeOpenedSubItems([], { itemNode: null, event: e });
|
69
|
+
onOpinionatedClose({ skipFocus: true });
|
70
|
+
};
|
71
|
+
window.addEventListener("blur", closeMenuAndSubmenus);
|
72
|
+
document.addEventListener("mousedown", detectIfClickIsOutsideMenuAndCloseIfSo);
|
73
|
+
document.addEventListener("touchstart", detectIfClickIsOutsideMenuAndCloseIfSo);
|
74
|
+
return () => {
|
75
|
+
window.removeEventListener("blur", closeMenuAndSubmenus);
|
76
|
+
document.removeEventListener("mousedown", detectIfClickIsOutsideMenuAndCloseIfSo);
|
77
|
+
document.removeEventListener("touchstart", detectIfClickIsOutsideMenuAndCloseIfSo);
|
78
|
+
};
|
79
|
+
}, [buttonDOMNodeRef, handleChangeOpenedSubItems, isMenuOpen, onOpinionatedClose]);
|
80
|
+
return import_react.default.useMemo(
|
81
|
+
() => ({
|
82
|
+
mainMenuRef,
|
83
|
+
submenusRefs,
|
84
|
+
handleSubmenusRefChange
|
85
|
+
}),
|
86
|
+
[handleSubmenusRefChange]
|
87
|
+
);
|
88
|
+
};
|
89
|
+
//# sourceMappingURL=useGlobalEvents.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../src/parts/DSMenuBehaviouralContextProvider/config/useGlobalEvents.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport type { DSMenuButtonT } from '../../../react-desc-prop-types.js';\nimport type { useMenuOpenStatus } from './useMenuOpenStatus.js';\nimport type { DSMenuBehaviouralContextProviderT } from '../react-desc-prop-types.js';\n\ntype UseGlobalEventsConfig = {\n menuOpenStatus: ReturnType<typeof useMenuOpenStatus>;\n handleChangeOpenedSubItems: Required<DSMenuButtonT.MenuBehaviouralLayerOptionalProps>['onDisplayedSubmenuChange'];\n propsWithDefault: DSMenuBehaviouralContextProviderT.InternalProps;\n};\n\nexport const useGlobalEvents = ({\n menuOpenStatus,\n handleChangeOpenedSubItems,\n propsWithDefault,\n}: UseGlobalEventsConfig) => {\n const { onOpinionatedClose, isMenuOpen } = menuOpenStatus;\n const { buttonDOMNodeRef } = propsWithDefault;\n const mainMenuRef = React.useRef<HTMLDivElement | null>(null);\n // we are using \"portal\" but then we check the native evenet to check if \"on click outside\" the menu\n // for such reason, we need to track the current HTML NODES of the submenus (topmost parent)\n // this will allow us to check if the click event is outside the menu or any of it's submenus\n const submenusRefs = React.useRef<Record<DSMenuButtonT.WithSubmenuMenuNodes['dsId'], HTMLElement>>({});\n const handleSubmenusRefChange = React.useCallback(\n (htmlNode: HTMLElement | null, dsId: DSMenuButtonT.WithSubmenuMenuNodes['dsId']) => {\n if (htmlNode) {\n submenusRefs.current[dsId] = htmlNode;\n } else {\n delete submenusRefs.current[dsId];\n }\n },\n [],\n );\n React.useEffect(() => {\n // when the window loses focus, close all the menus and submenus\n const closeMenuAndSubmenus = (e: FocusEvent) => {\n handleChangeOpenedSubItems([], { itemNode: null, event: e });\n onOpinionatedClose({ skipFocus: true });\n };\n // when the user clicks \"outside\" the menu and submenus, close all the menus and submenus\n const detectIfClickIsOutsideMenuAndCloseIfSo = (e: MouseEvent | TouchEvent) => {\n // we are running this on literally ALL the clicks that happen on the window\n // we don't want to be consuming resources that are not strictly necessary\n // if the main menu is not open, we don't need to check if the click is outside the menu ofc\n if (!isMenuOpen) return;\n // we discard the fastest to check \"trigger\" click first\n if (buttonDOMNodeRef.current === e.target) return;\n // fastest check is the mainmenu, cuz we don't loop through all the submenus\n const isClickInsideMainMenu = mainMenuRef.current?.contains(e.target as Node);\n if (isClickInsideMainMenu) return;\n const submenuNodesToCheck = Object.values(submenusRefs.current).filter(Boolean);\n // we check if the event.target is a child of any of our known HTML nodes (via native .contains)\n const isClickInsideAnySubmenu = submenuNodesToCheck.some((node) => node.contains(e.target as Node));\n if (isClickInsideAnySubmenu) return;\n handleChangeOpenedSubItems([], { itemNode: null, event: e });\n onOpinionatedClose({ skipFocus: true });\n };\n\n window.addEventListener('blur', closeMenuAndSubmenus);\n document.addEventListener('mousedown', detectIfClickIsOutsideMenuAndCloseIfSo);\n document.addEventListener('touchstart', detectIfClickIsOutsideMenuAndCloseIfSo);\n return () => {\n window.removeEventListener('blur', closeMenuAndSubmenus);\n document.removeEventListener('mousedown', detectIfClickIsOutsideMenuAndCloseIfSo);\n document.removeEventListener('touchstart', detectIfClickIsOutsideMenuAndCloseIfSo);\n };\n }, [buttonDOMNodeRef, handleChangeOpenedSubItems, isMenuOpen, onOpinionatedClose]);\n\n return React.useMemo(\n () => ({\n mainMenuRef,\n submenusRefs,\n handleSubmenusRefChange,\n }),\n [handleSubmenusRefChange],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAWX,MAAM,kBAAkB,CAAC;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACF,MAA6B;AAC3B,QAAM,EAAE,oBAAoB,WAAW,IAAI;AAC3C,QAAM,EAAE,iBAAiB,IAAI;AAC7B,QAAM,cAAc,aAAAA,QAAM,OAA8B,IAAI;AAI5D,QAAM,eAAe,aAAAA,QAAM,OAAwE,CAAC,CAAC;AACrG,QAAM,0BAA0B,aAAAA,QAAM;AAAA,IACpC,CAAC,UAA8B,SAAqD;AAClF,UAAI,UAAU;AACZ,qBAAa,QAAQ,IAAI,IAAI;AAAA,MAC/B,OAAO;AACL,eAAO,aAAa,QAAQ,IAAI;AAAA,MAClC;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AACA,eAAAA,QAAM,UAAU,MAAM;AAEpB,UAAM,uBAAuB,CAAC,MAAkB;AAC9C,iCAA2B,CAAC,GAAG,EAAE,UAAU,MAAM,OAAO,EAAE,CAAC;AAC3D,yBAAmB,EAAE,WAAW,KAAK,CAAC;AAAA,IACxC;AAEA,UAAM,yCAAyC,CAAC,MAA+B;AAI7E,UAAI,CAAC,WAAY;AAEjB,UAAI,iBAAiB,YAAY,EAAE,OAAQ;AAE3C,YAAM,wBAAwB,YAAY,SAAS,SAAS,EAAE,MAAc;AAC5E,UAAI,sBAAuB;AAC3B,YAAM,sBAAsB,OAAO,OAAO,aAAa,OAAO,EAAE,OAAO,OAAO;AAE9E,YAAM,0BAA0B,oBAAoB,KAAK,CAAC,SAAS,KAAK,SAAS,EAAE,MAAc,CAAC;AAClG,UAAI,wBAAyB;AAC7B,iCAA2B,CAAC,GAAG,EAAE,UAAU,MAAM,OAAO,EAAE,CAAC;AAC3D,yBAAmB,EAAE,WAAW,KAAK,CAAC;AAAA,IACxC;AAEA,WAAO,iBAAiB,QAAQ,oBAAoB;AACpD,aAAS,iBAAiB,aAAa,sCAAsC;AAC7E,aAAS,iBAAiB,cAAc,sCAAsC;AAC9E,WAAO,MAAM;AACX,aAAO,oBAAoB,QAAQ,oBAAoB;AACvD,eAAS,oBAAoB,aAAa,sCAAsC;AAChF,eAAS,oBAAoB,cAAc,sCAAsC;AAAA,IACnF;AAAA,EACF,GAAG,CAAC,kBAAkB,4BAA4B,YAAY,kBAAkB,CAAC;AAEjF,SAAO,aAAAA,QAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,uBAAuB;AAAA,EAC1B;AACF;",
|
6
|
+
"names": ["React"]
|
7
|
+
}
|
package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuBehaviouralContextProvider.js
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var useMenuBehaviouralContextProvider_exports = {};
|
30
|
+
__export(useMenuBehaviouralContextProvider_exports, {
|
31
|
+
useMenuBehaviouralContextProvider: () => useMenuBehaviouralContextProvider
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(useMenuBehaviouralContextProvider_exports);
|
34
|
+
var React = __toESM(require("react"));
|
35
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
36
|
+
var import_react = __toESM(require("react"));
|
37
|
+
var import_uid = require("uid");
|
38
|
+
var import_react_desc_prop_types = require("../react-desc-prop-types.js");
|
39
|
+
var import_useFocusTracker = require("./useFocusTracker.js");
|
40
|
+
var import_useMenuItemEventsHandlers = require("./useMenuItemEventsHandlers.js");
|
41
|
+
var import_useMenuOpenStatus = require("./useMenuOpenStatus.js");
|
42
|
+
var import_useValidateProps = require("./useValidateProps.js");
|
43
|
+
var import_useGlobalEvents = require("./useGlobalEvents.js");
|
44
|
+
const useMenuBehaviouralContextProvider = (propsFromUser) => {
|
45
|
+
const propsWithDefault = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(
|
46
|
+
propsFromUser,
|
47
|
+
import_react_desc_prop_types.defaultProps
|
48
|
+
);
|
49
|
+
(0, import_useValidateProps.useValidateProps)(propsWithDefault, import_react_desc_prop_types.DSMenuBehaviouralContextProviderPropTypesSchema);
|
50
|
+
const { onDisplayedSubmenuChange } = propsWithDefault;
|
51
|
+
const instanceUid = import_react.default.useMemo(() => `ds-menu-behavioural-context-provider-${(0, import_uid.uid)(5)}`, []);
|
52
|
+
const [openedSubItems, setOpenedSubItems] = import_react.default.useState([]);
|
53
|
+
const handleChangeOpenedSubItems = import_react.default.useCallback(
|
54
|
+
(newOpenedItems, metainfo) => {
|
55
|
+
setOpenedSubItems(newOpenedItems);
|
56
|
+
onDisplayedSubmenuChange?.(newOpenedItems, metainfo);
|
57
|
+
},
|
58
|
+
[onDisplayedSubmenuChange]
|
59
|
+
);
|
60
|
+
const focusTrackers = (0, import_useFocusTracker.useFocusTracker)();
|
61
|
+
const menuOpenStatus = (0, import_useMenuOpenStatus.useMenuOpenStatus)({ propsWithDefault, focusTrackers });
|
62
|
+
const menuItemEventsHandlers = (0, import_useMenuItemEventsHandlers.useMenuItemEventsHandlers)({
|
63
|
+
propsWithDefault,
|
64
|
+
focusTrackers,
|
65
|
+
menuOpenStatus,
|
66
|
+
handleChangeOpenedSubItems
|
67
|
+
});
|
68
|
+
const globalEventsHelpers = (0, import_useGlobalEvents.useGlobalEvents)({ menuOpenStatus, handleChangeOpenedSubItems, propsWithDefault });
|
69
|
+
return import_react.default.useMemo(
|
70
|
+
() => ({
|
71
|
+
propsWithDefault,
|
72
|
+
instanceUid,
|
73
|
+
...focusTrackers,
|
74
|
+
...menuOpenStatus,
|
75
|
+
menuItemEventsHandlers,
|
76
|
+
openedSubItems,
|
77
|
+
handleChangeOpenedSubItems,
|
78
|
+
globalEventsHelpers
|
79
|
+
}),
|
80
|
+
[
|
81
|
+
propsWithDefault,
|
82
|
+
instanceUid,
|
83
|
+
focusTrackers,
|
84
|
+
menuOpenStatus,
|
85
|
+
menuItemEventsHandlers,
|
86
|
+
openedSubItems,
|
87
|
+
handleChangeOpenedSubItems,
|
88
|
+
globalEventsHelpers
|
89
|
+
]
|
90
|
+
);
|
91
|
+
};
|
92
|
+
//# sourceMappingURL=useMenuBehaviouralContextProvider.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../src/parts/DSMenuBehaviouralContextProvider/config/useMenuBehaviouralContextProvider.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport React from 'react';\nimport { uid } from 'uid';\nimport type { DSMenuButtonT } from '../../../react-desc-prop-types.js';\nimport {\n DSMenuBehaviouralContextProviderPropTypesSchema,\n defaultProps,\n type DSMenuBehaviouralContextProviderT,\n} from '../react-desc-prop-types.js';\nimport { useFocusTracker } from './useFocusTracker.js';\nimport { useMenuItemEventsHandlers } from './useMenuItemEventsHandlers.js';\nimport { useMenuOpenStatus } from './useMenuOpenStatus.js';\nimport { useValidateProps } from './useValidateProps.js';\nimport { useGlobalEvents } from './useGlobalEvents.js';\n\nexport interface MenuBehaviouralContextProviderCTX\n extends ReturnType<typeof useFocusTracker>,\n ReturnType<typeof useMenuOpenStatus> {\n propsWithDefault: DSMenuBehaviouralContextProviderT.InternalProps;\n instanceUid: string;\n menuItemEventsHandlers: ReturnType<typeof useMenuItemEventsHandlers>;\n openedSubItems: DSMenuButtonT.WithSubmenuMenuNodes[];\n handleChangeOpenedSubItems: Required<DSMenuButtonT.MenuBehaviouralLayerOptionalProps>['onDisplayedSubmenuChange'];\n globalEventsHelpers: ReturnType<typeof useGlobalEvents>;\n}\n\nexport const useMenuBehaviouralContextProvider = (propsFromUser: DSMenuBehaviouralContextProviderT.Props) => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSMenuBehaviouralContextProviderT.InternalProps>(\n propsFromUser,\n defaultProps,\n );\n useValidateProps(propsWithDefault, DSMenuBehaviouralContextProviderPropTypesSchema);\n // =============================================================================\n // XSTYLED PROPS\n // =============================================================================\n // NO XSTYLED PROPS\n // this is 100% a pure logic context provider, it's not a visual component\n\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n // custom code goes here, this is an example\n const { onDisplayedSubmenuChange } = propsWithDefault;\n const instanceUid = React.useMemo(() => `ds-menu-behavioural-context-provider-${uid(5)}`, []);\n const [openedSubItems, setOpenedSubItems] = React.useState<DSMenuButtonT.WithSubmenuMenuNodes[]>([]);\n\n const handleChangeOpenedSubItems = React.useCallback<\n Required<DSMenuButtonT.MenuBehaviouralLayerOptionalProps>['onDisplayedSubmenuChange']\n >(\n (newOpenedItems, metainfo) => {\n setOpenedSubItems(newOpenedItems);\n onDisplayedSubmenuChange?.(newOpenedItems, metainfo);\n },\n [onDisplayedSubmenuChange],\n );\n\n // =============================================================================\n // HELPERS HOOKS CONFIGS\n // =============================================================================\n const focusTrackers = useFocusTracker();\n const menuOpenStatus = useMenuOpenStatus({ propsWithDefault, focusTrackers });\n\n // why item events handlers declared in the menu behaviour context provider and not in the menu item itself?\n // 1 - each menu item depending on it's own type (single select, multiple select, with submenu) will have different behaviours\n // having each menu item to declare it's own events handlers would make the single event handler way easier to create per se\n // BUT we would lose the big picture of how the menu items are interacting with each other\n // 2 - having each item to declare it's own event handler repeatdly is a waste of resources (even if it's a useless micro-optimization, it hurts me)\n const menuItemEventsHandlers = useMenuItemEventsHandlers({\n propsWithDefault,\n focusTrackers,\n menuOpenStatus,\n handleChangeOpenedSubItems,\n });\n\n // handle \"onClickOutside\" + on window blur...\n // the helpers contain a way to register the submenu refs/mainmenu refs, used in checking \"if click is outside\"\n const globalEventsHelpers = useGlobalEvents({ menuOpenStatus, handleChangeOpenedSubItems, propsWithDefault });\n\n return React.useMemo<MenuBehaviouralContextProviderCTX>(\n () => ({\n propsWithDefault,\n instanceUid,\n ...focusTrackers,\n ...menuOpenStatus,\n menuItemEventsHandlers,\n openedSubItems,\n handleChangeOpenedSubItems,\n globalEventsHelpers,\n }),\n [\n propsWithDefault,\n instanceUid,\n focusTrackers,\n menuOpenStatus,\n menuItemEventsHandlers,\n openedSubItems,\n handleChangeOpenedSubItems,\n globalEventsHelpers,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,8BAA6C;AAC7C,mBAAkB;AAClB,iBAAoB;AAEpB,mCAIO;AACP,6BAAgC;AAChC,uCAA0C;AAC1C,+BAAkC;AAClC,8BAAiC;AACjC,6BAAgC;AAazB,MAAM,oCAAoC,CAAC,kBAA2D;AAI3G,QAAM,uBAAmB;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACA,gDAAiB,kBAAkB,4EAA+C;AAWlF,QAAM,EAAE,yBAAyB,IAAI;AACrC,QAAM,cAAc,aAAAA,QAAM,QAAQ,MAAM,4CAAwC,gBAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AAC5F,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,aAAAA,QAAM,SAA+C,CAAC,CAAC;AAEnG,QAAM,6BAA6B,aAAAA,QAAM;AAAA,IAGvC,CAAC,gBAAgB,aAAa;AAC5B,wBAAkB,cAAc;AAChC,iCAA2B,gBAAgB,QAAQ;AAAA,IACrD;AAAA,IACA,CAAC,wBAAwB;AAAA,EAC3B;AAKA,QAAM,oBAAgB,wCAAgB;AACtC,QAAM,qBAAiB,4CAAkB,EAAE,kBAAkB,cAAc,CAAC;AAO5E,QAAM,6BAAyB,4DAA0B;AAAA,IACvD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAID,QAAM,0BAAsB,wCAAgB,EAAE,gBAAgB,4BAA4B,iBAAiB,CAAC;AAE5G,SAAO,aAAAA,QAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,GAAG;AAAA,MACH,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
6
|
+
"names": ["React"]
|
7
|
+
}
|
@@ -0,0 +1,315 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var useMenuItemEventsHandlers_exports = {};
|
30
|
+
__export(useMenuItemEventsHandlers_exports, {
|
31
|
+
useMenuItemEventsHandlers: () => useMenuItemEventsHandlers
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(useMenuItemEventsHandlers_exports);
|
34
|
+
var React = __toESM(require("react"));
|
35
|
+
var import_debounce = __toESM(require("lodash/debounce"));
|
36
|
+
var import_react = __toESM(require("react"));
|
37
|
+
var import_nodesTypeguardsAndGetters = require("../../../utils/nodesTypeguardsAndGetters.js");
|
38
|
+
var import_Errors = require("../constants/Errors.js");
|
39
|
+
var import_multipleSelectionHelpers = require("../utils/multipleSelectionHelpers.js");
|
40
|
+
var import_nodeGettersByCriterias = require("../utils/nodeGettersByCriterias.js");
|
41
|
+
var import_singleSelectionHelpers = require("../utils/singleSelectionHelpers.js");
|
42
|
+
const useMenuItemEventsHandlers = ({
|
43
|
+
propsWithDefault,
|
44
|
+
focusTrackers,
|
45
|
+
menuOpenStatus,
|
46
|
+
handleChangeOpenedSubItems
|
47
|
+
}) => {
|
48
|
+
const { onItemSelected, onActivateItem, selectedItems } = propsWithDefault;
|
49
|
+
const { onOpinionatedClose } = menuOpenStatus;
|
50
|
+
const {
|
51
|
+
trackFocusFirstChildItem,
|
52
|
+
trackFocusLastChildItem,
|
53
|
+
trackFocusNextItem,
|
54
|
+
trackFocusPreviousItem,
|
55
|
+
trackFocusParentItem,
|
56
|
+
trackFocusNode,
|
57
|
+
focusedElementItemNode
|
58
|
+
} = focusTrackers;
|
59
|
+
const openSubmenu = import_react.default.useCallback(
|
60
|
+
({
|
61
|
+
itemNode,
|
62
|
+
event
|
63
|
+
}) => {
|
64
|
+
if (!(0, import_nodesTypeguardsAndGetters.isWithSubmenuNode)(itemNode)) {
|
65
|
+
console.log("openSubmenu -> itemNode:", itemNode);
|
66
|
+
throw import_Errors.FORBIDDEN_BEHAVIOURS.TRYING_TO_OPEN_SUBMENU_OF_NODE_WITHOUT_SUBMENU;
|
67
|
+
}
|
68
|
+
const subMenuNodesPath = (0, import_nodeGettersByCriterias.getSubMenusPath)(itemNode);
|
69
|
+
const metainfo = { itemNode, event };
|
70
|
+
const newOpenedItems = [...subMenuNodesPath, itemNode];
|
71
|
+
handleChangeOpenedSubItems(newOpenedItems, metainfo);
|
72
|
+
},
|
73
|
+
[handleChangeOpenedSubItems]
|
74
|
+
);
|
75
|
+
const closeCurrentSubmenu = import_react.default.useCallback(
|
76
|
+
({
|
77
|
+
itemNode,
|
78
|
+
event
|
79
|
+
}) => {
|
80
|
+
const metainfo = { itemNode, event };
|
81
|
+
const subMenuNodesPath = (0, import_nodeGettersByCriterias.getSubMenusPath)(itemNode);
|
82
|
+
if (subMenuNodesPath.length === 0) {
|
83
|
+
handleChangeOpenedSubItems([], metainfo);
|
84
|
+
return { currentSubmenuWasMainMenu: true };
|
85
|
+
}
|
86
|
+
subMenuNodesPath.pop();
|
87
|
+
handleChangeOpenedSubItems(subMenuNodesPath, metainfo);
|
88
|
+
return { currentSubmenuWasMainMenu: false };
|
89
|
+
},
|
90
|
+
[handleChangeOpenedSubItems]
|
91
|
+
);
|
92
|
+
const handleMenuItemEnterKeyDown = import_react.default.useCallback(
|
93
|
+
({ pseudoFocusedItemNode, event }) => {
|
94
|
+
if ((0, import_nodesTypeguardsAndGetters.isWithSubmenuOnlyNode)(pseudoFocusedItemNode)) {
|
95
|
+
openSubmenu({ itemNode: pseudoFocusedItemNode, event });
|
96
|
+
trackFocusFirstChildItem(pseudoFocusedItemNode);
|
97
|
+
} else {
|
98
|
+
if ((0, import_nodesTypeguardsAndGetters.isMultipleSelectNode)(pseudoFocusedItemNode)) {
|
99
|
+
const newSelection = (0, import_multipleSelectionHelpers.getNewSelectionMultipleSelect)(selectedItems, pseudoFocusedItemNode);
|
100
|
+
onItemSelected(newSelection, { itemNode: pseudoFocusedItemNode, event });
|
101
|
+
} else if ((0, import_nodesTypeguardsAndGetters.isSingleSelectNode)(pseudoFocusedItemNode)) {
|
102
|
+
const newSelection = (0, import_singleSelectionHelpers.getNewSelectionSingleSelect)(selectedItems, pseudoFocusedItemNode);
|
103
|
+
onItemSelected(newSelection, { itemNode: pseudoFocusedItemNode, event });
|
104
|
+
} else {
|
105
|
+
onActivateItem(pseudoFocusedItemNode, { itemNode: pseudoFocusedItemNode, event });
|
106
|
+
}
|
107
|
+
const metainfo = { itemNode: pseudoFocusedItemNode, event };
|
108
|
+
const newOpenedItems = [];
|
109
|
+
handleChangeOpenedSubItems(newOpenedItems, metainfo);
|
110
|
+
onOpinionatedClose();
|
111
|
+
}
|
112
|
+
},
|
113
|
+
[
|
114
|
+
trackFocusFirstChildItem,
|
115
|
+
openSubmenu,
|
116
|
+
handleChangeOpenedSubItems,
|
117
|
+
onOpinionatedClose,
|
118
|
+
selectedItems,
|
119
|
+
onItemSelected,
|
120
|
+
onActivateItem
|
121
|
+
]
|
122
|
+
);
|
123
|
+
const handleMenuItemSpaceKeyDown = import_react.default.useCallback(
|
124
|
+
({ pseudoFocusedItemNode, event }) => {
|
125
|
+
if ((0, import_nodesTypeguardsAndGetters.isWithSubmenuOnlyNode)(pseudoFocusedItemNode)) {
|
126
|
+
openSubmenu({ itemNode: pseudoFocusedItemNode, event });
|
127
|
+
trackFocusFirstChildItem(pseudoFocusedItemNode);
|
128
|
+
return;
|
129
|
+
}
|
130
|
+
if ((0, import_nodesTypeguardsAndGetters.isMultipleSelectNode)(pseudoFocusedItemNode)) {
|
131
|
+
const newSelection = (0, import_multipleSelectionHelpers.getNewSelectionMultipleSelect)(selectedItems, pseudoFocusedItemNode);
|
132
|
+
onItemSelected(newSelection, { itemNode: pseudoFocusedItemNode, event });
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
if ((0, import_nodesTypeguardsAndGetters.isSingleSelectNode)(pseudoFocusedItemNode)) {
|
136
|
+
const newSelection = (0, import_singleSelectionHelpers.getNewSelectionSingleSelect)(selectedItems, pseudoFocusedItemNode);
|
137
|
+
onItemSelected(newSelection, { itemNode: pseudoFocusedItemNode, event });
|
138
|
+
return;
|
139
|
+
}
|
140
|
+
onActivateItem(pseudoFocusedItemNode, { itemNode: pseudoFocusedItemNode, event });
|
141
|
+
const metainfo = { itemNode: pseudoFocusedItemNode, event };
|
142
|
+
const newOpenedItems = [];
|
143
|
+
handleChangeOpenedSubItems(newOpenedItems, metainfo);
|
144
|
+
onOpinionatedClose();
|
145
|
+
},
|
146
|
+
[
|
147
|
+
onActivateItem,
|
148
|
+
handleChangeOpenedSubItems,
|
149
|
+
onOpinionatedClose,
|
150
|
+
trackFocusFirstChildItem,
|
151
|
+
openSubmenu,
|
152
|
+
selectedItems,
|
153
|
+
onItemSelected
|
154
|
+
]
|
155
|
+
);
|
156
|
+
const handleMenuItemRightArrowKeyDown = import_react.default.useCallback(
|
157
|
+
({ pseudoFocusedItemNode, event }) => {
|
158
|
+
if ((0, import_nodesTypeguardsAndGetters.isWithSubmenuNode)(pseudoFocusedItemNode)) {
|
159
|
+
openSubmenu({ itemNode: pseudoFocusedItemNode, event });
|
160
|
+
trackFocusFirstChildItem(pseudoFocusedItemNode);
|
161
|
+
return;
|
162
|
+
}
|
163
|
+
return;
|
164
|
+
},
|
165
|
+
[openSubmenu, trackFocusFirstChildItem]
|
166
|
+
);
|
167
|
+
const handleMenuItemLeftArrowKeyDown = import_react.default.useCallback(
|
168
|
+
({ pseudoFocusedItemNode, event }) => {
|
169
|
+
const { currentSubmenuWasMainMenu } = closeCurrentSubmenu({ itemNode: pseudoFocusedItemNode, event });
|
170
|
+
if (!currentSubmenuWasMainMenu) {
|
171
|
+
trackFocusParentItem(pseudoFocusedItemNode);
|
172
|
+
}
|
173
|
+
},
|
174
|
+
[closeCurrentSubmenu, trackFocusParentItem]
|
175
|
+
);
|
176
|
+
const handleFocusableMenuItemKeyDown = import_react.default.useCallback(
|
177
|
+
(event) => {
|
178
|
+
const pseudoFocusedItemNode = focusedElementItemNode.current;
|
179
|
+
if (pseudoFocusedItemNode === null) throw import_Errors.UNEXPECTED_INTERNAL_ERRORS.FOCUSED_ITEM_NODE_NOT_SET;
|
180
|
+
if (pseudoFocusedItemNode.plainItem.onKeyDown) pseudoFocusedItemNode.plainItem.onKeyDown(event);
|
181
|
+
if (event.key === "ArrowDown") {
|
182
|
+
trackFocusNextItem(pseudoFocusedItemNode);
|
183
|
+
return;
|
184
|
+
}
|
185
|
+
if (event.key === "ArrowUp") {
|
186
|
+
trackFocusPreviousItem(pseudoFocusedItemNode);
|
187
|
+
return;
|
188
|
+
}
|
189
|
+
if (event.key === "ArrowLeft") {
|
190
|
+
handleMenuItemLeftArrowKeyDown({ pseudoFocusedItemNode, event });
|
191
|
+
return;
|
192
|
+
}
|
193
|
+
if (event.key === "Home") {
|
194
|
+
if (!pseudoFocusedItemNode.parent) {
|
195
|
+
console.log("handleFocusableMenuItemKeyDown -> Home > focused item node", pseudoFocusedItemNode);
|
196
|
+
throw import_Errors.UNEXPECTED_INTERNAL_ERRORS.FOCUSED_ITEM_HAS_NO_PARENT;
|
197
|
+
}
|
198
|
+
trackFocusFirstChildItem(pseudoFocusedItemNode.parent);
|
199
|
+
return;
|
200
|
+
}
|
201
|
+
if (event.key === "End") {
|
202
|
+
if (!pseudoFocusedItemNode.parent) {
|
203
|
+
console.log("handleFocusableMenuItemKeyDown -> Home > focused item node", pseudoFocusedItemNode);
|
204
|
+
throw import_Errors.UNEXPECTED_INTERNAL_ERRORS.FOCUSED_ITEM_HAS_NO_PARENT;
|
205
|
+
}
|
206
|
+
trackFocusLastChildItem(pseudoFocusedItemNode.parent);
|
207
|
+
return;
|
208
|
+
}
|
209
|
+
if (event.key === "Escape") {
|
210
|
+
const { currentSubmenuWasMainMenu } = closeCurrentSubmenu({ itemNode: pseudoFocusedItemNode, event });
|
211
|
+
trackFocusParentItem(pseudoFocusedItemNode);
|
212
|
+
if (currentSubmenuWasMainMenu) {
|
213
|
+
onOpinionatedClose();
|
214
|
+
}
|
215
|
+
return;
|
216
|
+
}
|
217
|
+
if (pseudoFocusedItemNode.plainItem.disabled) return;
|
218
|
+
if (event.key === "Enter") {
|
219
|
+
handleMenuItemEnterKeyDown({ pseudoFocusedItemNode, event });
|
220
|
+
return;
|
221
|
+
}
|
222
|
+
if (event.key === " ") {
|
223
|
+
handleMenuItemSpaceKeyDown({ pseudoFocusedItemNode, event });
|
224
|
+
return;
|
225
|
+
}
|
226
|
+
if (event.key === "ArrowRight") {
|
227
|
+
handleMenuItemRightArrowKeyDown({ pseudoFocusedItemNode, event });
|
228
|
+
return;
|
229
|
+
}
|
230
|
+
},
|
231
|
+
[
|
232
|
+
focusedElementItemNode,
|
233
|
+
handleMenuItemEnterKeyDown,
|
234
|
+
handleMenuItemSpaceKeyDown,
|
235
|
+
trackFocusNextItem,
|
236
|
+
trackFocusPreviousItem,
|
237
|
+
handleMenuItemRightArrowKeyDown,
|
238
|
+
handleMenuItemLeftArrowKeyDown,
|
239
|
+
trackFocusFirstChildItem,
|
240
|
+
trackFocusLastChildItem,
|
241
|
+
closeCurrentSubmenu,
|
242
|
+
trackFocusParentItem,
|
243
|
+
onOpinionatedClose
|
244
|
+
]
|
245
|
+
);
|
246
|
+
const handleFocusableMenuItemOnMouseEnter = import_react.default.useCallback(
|
247
|
+
(itemNode, event) => {
|
248
|
+
if (!(0, import_nodesTypeguardsAndGetters.isFocusableNode)(itemNode)) {
|
249
|
+
console.log("handleFocusableMenuItemOnMouseEnter > itemNode:", itemNode);
|
250
|
+
throw import_Errors.FORBIDDEN_BEHAVIOURS.TRYING_TO_FOCUS_NON_FOCUSABLE_NODE;
|
251
|
+
}
|
252
|
+
trackFocusNode(itemNode);
|
253
|
+
if (!(0, import_nodesTypeguardsAndGetters.isWithSubmenuNode)(itemNode)) {
|
254
|
+
const subMenuNodesPath = (0, import_nodeGettersByCriterias.getSubMenusPath)(itemNode);
|
255
|
+
const metainfo = { itemNode, event };
|
256
|
+
const newOpenedItems = [...subMenuNodesPath];
|
257
|
+
handleChangeOpenedSubItems(newOpenedItems, metainfo);
|
258
|
+
return;
|
259
|
+
}
|
260
|
+
if (itemNode.plainItem.disabled) return;
|
261
|
+
openSubmenu({ itemNode, event });
|
262
|
+
},
|
263
|
+
[handleChangeOpenedSubItems, openSubmenu, trackFocusNode]
|
264
|
+
);
|
265
|
+
const handleFocusableMenuItemClick = import_react.default.useCallback(
|
266
|
+
(event) => {
|
267
|
+
const pseudoFocusedItemNode = focusedElementItemNode.current;
|
268
|
+
if (pseudoFocusedItemNode === null) throw import_Errors.UNEXPECTED_INTERNAL_ERRORS.FOCUSED_ITEM_NODE_NOT_SET;
|
269
|
+
if (pseudoFocusedItemNode.plainItem.disabled) return;
|
270
|
+
const parentMenuNode = pseudoFocusedItemNode.parent;
|
271
|
+
if ((0, import_nodesTypeguardsAndGetters.isRootNode)(parentMenuNode)) {
|
272
|
+
const metainfo = { itemNode: pseudoFocusedItemNode, event };
|
273
|
+
const newOpenedItems = [];
|
274
|
+
handleChangeOpenedSubItems(newOpenedItems, metainfo);
|
275
|
+
} else {
|
276
|
+
const newOpenedItems = [...(0, import_nodeGettersByCriterias.getSubMenusPath)(pseudoFocusedItemNode)];
|
277
|
+
if ((0, import_nodesTypeguardsAndGetters.isWithSubmenuNode)(pseudoFocusedItemNode)) {
|
278
|
+
newOpenedItems.push(pseudoFocusedItemNode);
|
279
|
+
}
|
280
|
+
const metainfo = { itemNode: pseudoFocusedItemNode, event };
|
281
|
+
handleChangeOpenedSubItems(newOpenedItems, metainfo);
|
282
|
+
}
|
283
|
+
handleMenuItemSpaceKeyDown({ pseudoFocusedItemNode, event });
|
284
|
+
if (pseudoFocusedItemNode.plainItem.onClick) pseudoFocusedItemNode.plainItem.onClick(event);
|
285
|
+
},
|
286
|
+
[focusedElementItemNode, handleMenuItemSpaceKeyDown, handleChangeOpenedSubItems]
|
287
|
+
);
|
288
|
+
const handleMenuItemFocusReconciliation = import_react.default.useCallback(
|
289
|
+
(itemNode) => {
|
290
|
+
(0, import_debounce.default)(
|
291
|
+
() => {
|
292
|
+
if (focusedElementItemNode.current?.dsId !== itemNode.dsId) trackFocusNode(itemNode);
|
293
|
+
},
|
294
|
+
10,
|
295
|
+
{ leading: false, trailing: true }
|
296
|
+
);
|
297
|
+
},
|
298
|
+
[focusedElementItemNode, trackFocusNode]
|
299
|
+
);
|
300
|
+
return import_react.default.useMemo(
|
301
|
+
() => ({
|
302
|
+
handleFocusableMenuItemKeyDown,
|
303
|
+
handleFocusableMenuItemClick,
|
304
|
+
handleFocusableMenuItemOnMouseEnter,
|
305
|
+
handleMenuItemFocusReconciliation
|
306
|
+
}),
|
307
|
+
[
|
308
|
+
handleFocusableMenuItemClick,
|
309
|
+
handleFocusableMenuItemKeyDown,
|
310
|
+
handleFocusableMenuItemOnMouseEnter,
|
311
|
+
handleMenuItemFocusReconciliation
|
312
|
+
]
|
313
|
+
);
|
314
|
+
};
|
315
|
+
//# sourceMappingURL=useMenuItemEventsHandlers.js.map
|
package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js.map
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../src/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["/* eslint-disable no-console */\n/* eslint-disable max-lines */\n// in this files the returns are not useless, they are used to clearly demark the intended behavior shortcircuit for the next developer that reads the code\n/* eslint-disable no-useless-return */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport debounce from 'lodash/debounce';\nimport React from 'react';\nimport { type DSMenuButtonT } from '../../../react-desc-prop-types.js';\nimport {\n isFocusableNode,\n isMultipleSelectNode,\n isRootNode,\n isSingleSelectNode,\n isWithSubmenuNode,\n isWithSubmenuOnlyNode,\n} from '../../../utils/nodesTypeguardsAndGetters.js';\nimport { FORBIDDEN_BEHAVIOURS, UNEXPECTED_INTERNAL_ERRORS } from '../constants/Errors.js';\nimport { type DSMenuBehaviouralContextProviderT } from '../react-desc-prop-types.js';\nimport { getNewSelectionMultipleSelect } from '../utils/multipleSelectionHelpers.js';\nimport { getSubMenusPath } from '../utils/nodeGettersByCriterias.js';\nimport { getNewSelectionSingleSelect } from '../utils/singleSelectionHelpers.js';\nimport type { useFocusTracker } from './useFocusTracker.js';\nimport type { useMenuOpenStatus } from './useMenuOpenStatus.js';\n\ntype ItemKeydownHelpersArgs = {\n pseudoFocusedItemNode: DSMenuButtonT.PseudoFocusableMenuNodes;\n event?: React.KeyboardEvent | React.MouseEvent;\n};\ntype SubmenuChangeMetainfo = {\n itemNode: DSMenuButtonT.PseudoFocusableMenuNodes;\n event?: React.SyntheticEvent;\n};\n\ntype UseMenuItemEventsHandlersConfig = {\n propsWithDefault: DSMenuBehaviouralContextProviderT.InternalProps;\n focusTrackers: ReturnType<typeof useFocusTracker>;\n menuOpenStatus: ReturnType<typeof useMenuOpenStatus>;\n handleChangeOpenedSubItems: Required<DSMenuButtonT.MenuBehaviouralLayerOptionalProps>['onDisplayedSubmenuChange'];\n};\n\nexport const useMenuItemEventsHandlers = ({\n propsWithDefault,\n focusTrackers,\n menuOpenStatus,\n handleChangeOpenedSubItems,\n}: UseMenuItemEventsHandlersConfig) => {\n const { onItemSelected, onActivateItem, selectedItems } = propsWithDefault;\n const { onOpinionatedClose } = menuOpenStatus;\n const {\n trackFocusFirstChildItem,\n trackFocusLastChildItem,\n trackFocusNextItem,\n trackFocusPreviousItem,\n trackFocusParentItem,\n trackFocusNode,\n focusedElementItemNode,\n } = focusTrackers;\n\n const openSubmenu = React.useCallback(\n ({\n itemNode,\n event,\n }: {\n itemNode: DSMenuButtonT.WithSubmenuMenuNodes;\n event?: React.KeyboardEvent | React.MouseEvent;\n }) => {\n if (!isWithSubmenuNode(itemNode)) {\n console.log('openSubmenu -> itemNode:', itemNode);\n throw FORBIDDEN_BEHAVIOURS.TRYING_TO_OPEN_SUBMENU_OF_NODE_WITHOUT_SUBMENU;\n }\n const subMenuNodesPath = getSubMenusPath(itemNode);\n const metainfo: SubmenuChangeMetainfo = { itemNode, event };\n const newOpenedItems: DSMenuButtonT.WithSubmenuMenuNodes[] = [...subMenuNodesPath, itemNode];\n handleChangeOpenedSubItems(newOpenedItems, metainfo);\n },\n [handleChangeOpenedSubItems],\n );\n const closeCurrentSubmenu = React.useCallback(\n ({\n itemNode,\n event,\n }: {\n itemNode: DSMenuButtonT.PseudoFocusableMenuNodes;\n event?: React.KeyboardEvent | React.MouseEvent;\n }) => {\n const metainfo: SubmenuChangeMetainfo = { itemNode, event };\n const subMenuNodesPath = getSubMenusPath(itemNode);\n // if length is 0, it means the parent is the root node, so we close all the submenus\n if (subMenuNodesPath.length === 0) {\n handleChangeOpenedSubItems([], metainfo);\n return { currentSubmenuWasMainMenu: true };\n }\n\n // we want to close current submenu, so we pop the last element\n // getSubMenusPath guarantees the order by walkParents + reverse at the end\n subMenuNodesPath.pop();\n handleChangeOpenedSubItems(subMenuNodesPath, metainfo);\n return { currentSubmenuWasMainMenu: false };\n },\n [handleChangeOpenedSubItems],\n );\n /*\n * 13th August 2024:\n * https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/\n * Additional roles, states, and properties needed for the menu element are described in the Menu and Menubar Pattern.\n * https://www.w3.org/WAI/ARIA/apg/patterns/menubar/\n * Because menubar and menu elements are composite widgets as described in the practice for Keyboard Navigation Inside Components,\n * Tab and Shift + Tab do not move focus among the items in the menu.\n * Instead, the keyboard commands described in this section enable users to move focus among the elements in a menubar or menu.\n * Tab and Shift + Tab:\n * - Move focus into a menubar <- Not relevant for this component, this is ONLY FOR MENU, not for MENUBARS\n * - When focus is on a menuitem in a menu or menubar, move focus out of the menu or menubar, and close all menus and submenus.\n * ************************************************************************************************************************************\n * this will be implemented by not setting document.activeElement to the menuitem but keeping it on the trigger button\n * why? because there is no javascript API to trigger a \"tab\"/\"shift+tab\" navigation and any algorithm trying to do so is fragile\n * also, this is enforced by w3.org too as per:\n * ************************************************************************************************************************************\n * Note that Tab and Shift + Tab do not move focus into a menu.\n * Unlike a menubar, a menu is not visually persistent,\n * and authors are responsible for ensuring focus moves to an item inside of a menu when the menu opens.\n *\n */\n const handleMenuItemEnterKeyDown = React.useCallback(\n ({ pseudoFocusedItemNode, event }: ItemKeydownHelpersArgs) => {\n // Enter:\n // - When focus is on a menuitem that has a submenu, opens the submenu and places focus on its first item.\n // ...\n if (isWithSubmenuOnlyNode(pseudoFocusedItemNode)) {\n openSubmenu({ itemNode: pseudoFocusedItemNode, event });\n trackFocusFirstChildItem(pseudoFocusedItemNode);\n } else {\n // - Otherwise, activates the item...\n\n // ----------------------------------\n // 4. Although it is recommended that authors avoid doing so,\n // some implementations of navigation menubars may have menuitem elements that both perform a function and open a submenu.\n // In such implementations, Enter and Space perform a navigation function,\n // e.g., load new content, while Down Arrow, in a horizontal menubar, opens the submenu associated with that same menuitem.\n // ---------------------------------\n // Based on an investigation, the above statement is not specific to \"navigation\" nor to ONLY \"menubars\", it really is about \"menuitems\" in general\n // as long as the role=\"menuitem\" & aria-haspopup=\"${id-of-the-submenu}\" & aria-expanded=\"${true/false}\" (& aria-orientation=\"vertical/horizontal\" if non-default)\n // are set, the Screen Readers will provide the same announcement for the menuitem regardless of the parent role\n\n // \"activation\" is a concept,\n // WCAG here implies that for menuitemscheckbox and menuitemsradio this triggers the selection\n // for menuitems (that doesn't fit selection nor submenus) it triggers the action\n // this also triggers enter -> single-select-item-with-submenu as expected\n if (isMultipleSelectNode(pseudoFocusedItemNode)) {\n const newSelection = getNewSelectionMultipleSelect(selectedItems, pseudoFocusedItemNode);\n onItemSelected(newSelection, { itemNode: pseudoFocusedItemNode, event });\n } else if (isSingleSelectNode(pseudoFocusedItemNode)) {\n const newSelection = getNewSelectionSingleSelect(selectedItems, pseudoFocusedItemNode);\n onItemSelected(newSelection, { itemNode: pseudoFocusedItemNode, event });\n } else {\n onActivateItem(pseudoFocusedItemNode, { itemNode: pseudoFocusedItemNode, event });\n }\n // ... and closes the menu.\n const metainfo: SubmenuChangeMetainfo = { itemNode: pseudoFocusedItemNode, event };\n const newOpenedItems: DSMenuButtonT.WithSubmenuMenuNodes[] = [];\n handleChangeOpenedSubItems(newOpenedItems, metainfo);\n onOpinionatedClose();\n }\n },\n [\n trackFocusFirstChildItem,\n openSubmenu,\n handleChangeOpenedSubItems,\n onOpinionatedClose,\n selectedItems,\n onItemSelected,\n onActivateItem,\n ],\n );\n const handleMenuItemSpaceKeyDown = React.useCallback(\n ({ pseudoFocusedItemNode, event }: ItemKeydownHelpersArgs) => {\n // Space:\n // [X] (Optional): When focus is on a menuitem that has a submenu, opens the submenu and places focus on its first item.\n // ----------------------------------\n // 4. Although it is recommended that authors avoid doing so,\n // some implementations of navigation menubars may have menuitem elements that both perform a function and open a submenu.\n // In such implementations, Enter and Space perform a navigation function,\n // e.g., load new content, while Down Arrow, in a horizontal menubar, opens the submenu associated with that same menuitem.\n // ---------------------------------\n // Based on an investigation, the above statement is not specific to \"navigation\" nor to ONLY \"menubars\", it really is about \"menuitems\" in general\n // as long as the role=\"menuitem\" & aria-haspopup=\"${id-of-the-submenu}\" & aria-expanded=\"${true/false}\" (& aria-orientation=\"vertical/horizontal\" if non-default)\n // are set, the Screen Readers will provide the same announcement for the menuitem regardless of the parent role\n if (isWithSubmenuOnlyNode(pseudoFocusedItemNode)) {\n openSubmenu({ itemNode: pseudoFocusedItemNode, event });\n trackFocusFirstChildItem(pseudoFocusedItemNode);\n return;\n }\n // [X] (Optional): When focus is on a menuitemcheckbox, changes the state without closing the menu.\n if (isMultipleSelectNode(pseudoFocusedItemNode)) {\n const newSelection = getNewSelectionMultipleSelect(selectedItems, pseudoFocusedItemNode);\n onItemSelected(newSelection, { itemNode: pseudoFocusedItemNode, event });\n return;\n }\n // [X] (Optional): When focus is on a menuitemradio that is not checked, without closing the menu,\n // checks the focused menuitemradio and unchecks any other checked menuitemradio element in the same group.\n if (isSingleSelectNode(pseudoFocusedItemNode)) {\n const newSelection = getNewSelectionSingleSelect(selectedItems, pseudoFocusedItemNode);\n onItemSelected(newSelection, { itemNode: pseudoFocusedItemNode, event });\n return;\n }\n // [X] (Optional): When focus is on a menuitem that does not have a submenu, activates the menuitem and closes the menu.\n onActivateItem(pseudoFocusedItemNode, { itemNode: pseudoFocusedItemNode, event });\n\n const metainfo: SubmenuChangeMetainfo = { itemNode: pseudoFocusedItemNode, event };\n const newOpenedItems: DSMenuButtonT.WithSubmenuMenuNodes[] = [];\n handleChangeOpenedSubItems(newOpenedItems, metainfo);\n onOpinionatedClose();\n },\n [\n onActivateItem,\n handleChangeOpenedSubItems,\n onOpinionatedClose,\n trackFocusFirstChildItem,\n openSubmenu,\n selectedItems,\n onItemSelected,\n ],\n );\n const handleMenuItemRightArrowKeyDown = React.useCallback(\n ({ pseudoFocusedItemNode, event }: ItemKeydownHelpersArgs) => {\n // Right Arrow:\n // [N/A] When focus is in a menubar, moves focus to the next item, optionally wrapping from the last to the first.\n // /\\ Not relevant for this component, this is ONLY FOR MENU, not for MENUBARS\n\n // [X] When focus is in a menu and on a menuitem that has a submenu, opens the submenu and places focus on its first item.\n // [N/A] When focus is in a menu and on an item that does not have a submenu, performs the following 3 actions:\n // [N/A] Closes the submenu and any parent menus.\n // [N/A] Moves focus to the next item in the menubar.\n // /\\ Not relevant for this component, this is ONLY FOR MENU, not for MENUBARS\n\n // [X] If focus is now on a menuitem with a submenu, either:\n // [X] (Recommended) opens the submenu of that menuitem without moving focus into the submenu,\n // /\\ we choose the recommended option\n // OR\n // [N/A] opens the submenu of that menuitem and places focus on the first item in the submenu.\n // ***********************************************************\n // Dimsum implements IoC, if APP side for whatever reason wants to open the new sub sub menu,\n // it's up to them to listen to the pseudo focus event and open the sub sub menu\n // ***********************************************************\n if (isWithSubmenuNode(pseudoFocusedItemNode)) {\n openSubmenu({ itemNode: pseudoFocusedItemNode, event });\n trackFocusFirstChildItem(pseudoFocusedItemNode);\n return;\n }\n // Note that if the menubar were not present, e.g., the menus were opened from a menubutton,\n // Right Arrow would not do anything when focus is on an item that does not have a submenu.\n return;\n },\n [openSubmenu, trackFocusFirstChildItem],\n );\n\n const handleMenuItemLeftArrowKeyDown = React.useCallback(\n ({ pseudoFocusedItemNode, event }: ItemKeydownHelpersArgs) => {\n // Left Arrow:\n // [N/A] When focus is in a menubar, moves focus to the previous item, optionally wrapping from the first to the last.\n // /\\ Not relevant for this component, this is ONLY FOR MENU, not for MENUBARS\n\n // [X] When focus is in a submenu of an item in a menu, closes the submenu and returns focus to the parent menuitem.\n const { currentSubmenuWasMainMenu } = closeCurrentSubmenu({ itemNode: pseudoFocusedItemNode, event });\n if (!currentSubmenuWasMainMenu) {\n trackFocusParentItem(pseudoFocusedItemNode);\n }\n\n // [N/A] When focus is in a submenu of an item in a menubar, performs the following 3 actions:\n // [N/A] Closes the submenu.\n // [N/A] Moves focus to the previous item in the menubar.\n // [N/A] If focus is now on a menuitem with a submenu, either:\n // (Recommended) opens the submenu of that menuitem without moving focus into the submenu,\n // or\n // opens the submenu of that menuitem and places focus on the first item in the submenu.\n // /\\ Not relevant for this component, this is ONLY FOR MENU, not for MENUBARS\n },\n [closeCurrentSubmenu, trackFocusParentItem],\n );\n\n const handleFocusableMenuItemKeyDown = React.useCallback<React.KeyboardEventHandler<HTMLDivElement>>(\n (event) => {\n const pseudoFocusedItemNode = focusedElementItemNode.current;\n // if there is no focused item, we can't handle the logics\n if (pseudoFocusedItemNode === null) throw UNEXPECTED_INTERNAL_ERRORS.FOCUSED_ITEM_NODE_NOT_SET;\n // if the item contains an `onKeyDown` prop, we trigger it\n if (pseudoFocusedItemNode.plainItem.onKeyDown) pseudoFocusedItemNode.plainItem.onKeyDown(event);\n\n // Down Arrow:\n // [N/A] When focus is on a menuitem in a menubar, and that menuitem has a submenu, opens the submenu and places focus on the first item in the submenu.\n // /\\ Not relevant for this component, this is ONLY FOR MENU, not for MENUBARS\n // [X] When focus is in a menu, moves focus to the next item,\n // [X] optionally wrapping from the last to the first.\n if (event.key === 'ArrowDown') {\n trackFocusNextItem(pseudoFocusedItemNode);\n return;\n }\n // Up Arrow:\n // [X] When focus is in a menu, moves focus to the previous item,\n // [X] optionally wrapping from the first to the last.\n // [N/A] (Optional): When focus is on a menuitem in a menubar, and that menuitem has a submenu, opens the submenu and places focus on the last item in the submenu.\n // /\\ Not relevant for this component, this is ONLY FOR MENU, not for MENUBARS\n if (event.key === 'ArrowUp') {\n trackFocusPreviousItem(pseudoFocusedItemNode);\n return;\n }\n // Left Arrow:\n if (event.key === 'ArrowLeft') {\n handleMenuItemLeftArrowKeyDown({ pseudoFocusedItemNode, event });\n return;\n }\n // Home: If arrow key wrapping is not supported, moves focus to the first item in the current menu or menubar.\n if (event.key === 'Home') {\n if (!pseudoFocusedItemNode.parent) {\n console.log('handleFocusableMenuItemKeyDown -> Home > focused item node', pseudoFocusedItemNode);\n // should be impossible, at most the .parent is the root node, which is not able to trigger this event\n throw UNEXPECTED_INTERNAL_ERRORS.FOCUSED_ITEM_HAS_NO_PARENT;\n }\n trackFocusFirstChildItem(pseudoFocusedItemNode.parent);\n return;\n }\n // End: If arrow key wrapping is not supported, moves focus to the last item in the current menu or menubar.\n if (event.key === 'End') {\n if (!pseudoFocusedItemNode.parent) {\n console.log('handleFocusableMenuItemKeyDown -> Home > focused item node', pseudoFocusedItemNode);\n // should be impossible, at most the .parent is the root node, which is not able to trigger this event\n throw UNEXPECTED_INTERNAL_ERRORS.FOCUSED_ITEM_HAS_NO_PARENT;\n }\n trackFocusLastChildItem(pseudoFocusedItemNode.parent);\n return;\n }\n // Escape: Close the menu that contains focus and return focus to the element or context, e.g., menu button or parent menuitem, from which the menu was opened\n if (event.key === 'Escape') {\n const { currentSubmenuWasMainMenu } = closeCurrentSubmenu({ itemNode: pseudoFocusedItemNode, event });\n trackFocusParentItem(pseudoFocusedItemNode);\n // if the menu we are trying to close is the main menu, we adittionally close the main menu itself\n if (currentSubmenuWasMainMenu) {\n // if parent is the root node, we close also the main menu\n onOpinionatedClose();\n }\n return;\n }\n /* ************************************************************************************\n * ******* ACTIVATION & SUBMENU keys doesn't apply if the item is \"disabled\" **********\n * ************************************************************************************ */\n if (pseudoFocusedItemNode.plainItem.disabled) return;\n // Enter:\n if (event.key === 'Enter') {\n handleMenuItemEnterKeyDown({ pseudoFocusedItemNode, event });\n return;\n }\n // Space:\n if (event.key === ' ') {\n handleMenuItemSpaceKeyDown({ pseudoFocusedItemNode, event });\n return;\n }\n // Right Arrow:\n if (event.key === 'ArrowRight') {\n handleMenuItemRightArrowKeyDown({ pseudoFocusedItemNode, event });\n return;\n }\n },\n [\n focusedElementItemNode,\n handleMenuItemEnterKeyDown,\n handleMenuItemSpaceKeyDown,\n trackFocusNextItem,\n trackFocusPreviousItem,\n handleMenuItemRightArrowKeyDown,\n handleMenuItemLeftArrowKeyDown,\n trackFocusFirstChildItem,\n trackFocusLastChildItem,\n closeCurrentSubmenu,\n trackFocusParentItem,\n onOpinionatedClose,\n ],\n );\n\n const handleFocusableMenuItemOnMouseEnter = React.useCallback(\n (itemNode: DSMenuButtonT.PseudoFocusableMenuNodes, event: React.MouseEvent) => {\n if (!isFocusableNode(itemNode)) {\n console.log('handleFocusableMenuItemOnMouseEnter > itemNode:', itemNode);\n throw FORBIDDEN_BEHAVIOURS.TRYING_TO_FOCUS_NON_FOCUSABLE_NODE;\n }\n // on hover -> we track the hovered item as the focused one on top of which events should work on\n trackFocusNode(itemNode);\n if (!isWithSubmenuNode(itemNode)) {\n // if the item has nosubmenu we close all the siblings submenus\n const subMenuNodesPath = getSubMenusPath(itemNode);\n const metainfo: SubmenuChangeMetainfo = { itemNode, event };\n const newOpenedItems: DSMenuButtonT.WithSubmenuMenuNodes[] = [...subMenuNodesPath];\n handleChangeOpenedSubItems(newOpenedItems, metainfo);\n return;\n }\n // if the item is disabled, we don't open the submenu\n if (itemNode.plainItem.disabled) return;\n // if not disabled and it has a submenu, we open it\n openSubmenu({ itemNode, event });\n },\n [handleChangeOpenedSubItems, openSubmenu, trackFocusNode],\n );\n\n const handleFocusableMenuItemClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n const pseudoFocusedItemNode = focusedElementItemNode.current;\n if (pseudoFocusedItemNode === null) throw UNEXPECTED_INTERNAL_ERRORS.FOCUSED_ITEM_NODE_NOT_SET;\n // if the item is disabled, we don't do anything\n if (pseudoFocusedItemNode.plainItem.disabled) return;\n // we need to handle which submenu needs to close automagically based on the click\n // starting from the itemNode, we check:\n // - the parent of the itemNode is root?\n // - yes -> we close all the submenus\n const parentMenuNode = pseudoFocusedItemNode.parent;\n if (isRootNode(parentMenuNode)) {\n const metainfo: SubmenuChangeMetainfo = { itemNode: pseudoFocusedItemNode, event };\n const newOpenedItems: DSMenuButtonT.WithSubmenuMenuNodes[] = [];\n handleChangeOpenedSubItems(newOpenedItems, metainfo);\n } else {\n // - no -> we close all the submenus that are not in the path to the root of the itemNode\n // this is necessary on click because the user can still interact with other (visual) depths of the menu\n // during keyboard navigation, the user is limited to the current (visual) depth\n const newOpenedItems: DSMenuButtonT.WithSubmenuMenuNodes[] = [...getSubMenusPath(pseudoFocusedItemNode)];\n // - if the clicked node has a submenu, keep it open\n if (isWithSubmenuNode(pseudoFocusedItemNode)) {\n newOpenedItems.push(pseudoFocusedItemNode);\n }\n const metainfo: SubmenuChangeMetainfo = { itemNode: pseudoFocusedItemNode, event };\n handleChangeOpenedSubItems(newOpenedItems, metainfo);\n }\n\n // to all effects and purposes, the click event is the same as the space key\n // the main difference between enter and space is that\n // - enter ALWAYS closes the menu excepts for submenus\n // - space closes the menu if \"activable\", selections doesn't, submenus doesn't\n handleMenuItemSpaceKeyDown({ pseudoFocusedItemNode, event });\n // if the item contains an `onClick` prop, we trigger it\n if (pseudoFocusedItemNode.plainItem.onClick) pseudoFocusedItemNode.plainItem.onClick(event);\n },\n [focusedElementItemNode, handleMenuItemSpaceKeyDown, handleChangeOpenedSubItems],\n );\n\n // SR softwares have a setting (that is on by default in mac VoiceOver)\n // that express the will from the user to have the \"voice over pseudo navigation\"\n // also \"act as a navigation\", it usually isn't so easy to catch/see this\n // because usually special key navigation is a secondary way to navigate\n // BUT, some role (surprise suprise, menu falls into this category)\n // inverts the \"navigation\" and \"special key navigation\" when SR is on by default\n // Long story short, if when the item triggers a focus event, we don't track it\n // and the user uses the \"special key navigation\" to navigate\n // weird navigation and visual feedbacks will happen\n // This handler ensures that\n // the focus is tracked when the item is focused via special key navigation in the SR software preference asking for it is on\n // IMPORTANT:\n // we need to make sure this is only invoked for the last focused item if many focus events are triggered in quick succession\n // so we MUST debounce this\n const handleMenuItemFocusReconciliation: (itemNode: DSMenuButtonT.PseudoFocusableMenuNodes) => void =\n React.useCallback(\n (itemNode) => {\n debounce(\n () => {\n if (focusedElementItemNode.current?.dsId !== itemNode.dsId) trackFocusNode(itemNode);\n },\n 10,\n { leading: false, trailing: true },\n );\n },\n\n [focusedElementItemNode, trackFocusNode],\n );\n return React.useMemo(\n () => ({\n handleFocusableMenuItemKeyDown,\n handleFocusableMenuItemClick,\n handleFocusableMenuItemOnMouseEnter,\n handleMenuItemFocusReconciliation,\n }),\n [\n handleFocusableMenuItemClick,\n handleFocusableMenuItemKeyDown,\n handleFocusableMenuItemOnMouseEnter,\n handleMenuItemFocusReconciliation,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADMvB,sBAAqB;AACrB,m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