@elliemae/ds-menu-button 3.45.0-rc.1 → 3.45.0-rc.2
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,91 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
3
|
+
import {
|
4
|
+
StyleMenuItemLabel,
|
5
|
+
StyleMenuItemSecondaryLabel,
|
6
|
+
StyledContentWrapper,
|
7
|
+
StyledGlobalMenuItemWrapper
|
8
|
+
} from "@elliemae/ds-menu-items-commons";
|
9
|
+
import React2 from "react";
|
10
|
+
import { MenuBehaviouralContextProviderContext } from "../DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js";
|
11
|
+
import { MENU_FOCUS_REGIONS } from "../DSMenuBehaviouralContextProvider/constants/index.js";
|
12
|
+
const ActivableMenuItem = ({
|
13
|
+
itemNode
|
14
|
+
}) => {
|
15
|
+
const { dsId, plainItem } = itemNode;
|
16
|
+
const { label, secondaryLabel, leftDecoration: LeftDecComponent, minWidth, disabled } = plainItem;
|
17
|
+
const {
|
18
|
+
focusRegion,
|
19
|
+
menuItemEventsHandlers: {
|
20
|
+
handleFocusableMenuItemKeyDown,
|
21
|
+
handleFocusableMenuItemClick,
|
22
|
+
handleFocusableMenuItemOnMouseEnter,
|
23
|
+
handleMenuItemFocusReconciliation
|
24
|
+
}
|
25
|
+
} = React2.useContext(MenuBehaviouralContextProviderContext);
|
26
|
+
const gridLayout = React2.useMemo(() => {
|
27
|
+
const cols = LeftDecComponent ? ["min-content", "auto"] : ["auto"];
|
28
|
+
if (secondaryLabel) cols.push("auto");
|
29
|
+
return cols;
|
30
|
+
}, [LeftDecComponent, secondaryLabel]);
|
31
|
+
const focusedRegionPerformanceHelper = React2.useRef(focusRegion);
|
32
|
+
focusedRegionPerformanceHelper.current = focusRegion;
|
33
|
+
const isFocused = focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId);
|
34
|
+
const handleFocusOnRender = React2.useCallback(
|
35
|
+
(node) => {
|
36
|
+
if (node && focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId)) {
|
37
|
+
node.focus();
|
38
|
+
}
|
39
|
+
},
|
40
|
+
// we need to change the callback reference every time the focusRegion changes or else the focus will not be set
|
41
|
+
[dsId, focusRegion]
|
42
|
+
// we are using the "as='div'", typescript is not able to infer the correct type
|
43
|
+
// the logic here actually receives a ref to a HTMLDivElement,
|
44
|
+
// but the component must think this is a HTMLLIElement ref callback
|
45
|
+
);
|
46
|
+
const handleOnMouseEnter = React2.useCallback(
|
47
|
+
(e) => {
|
48
|
+
handleFocusableMenuItemOnMouseEnter(itemNode, e);
|
49
|
+
},
|
50
|
+
[handleFocusableMenuItemOnMouseEnter, itemNode]
|
51
|
+
);
|
52
|
+
const handleOnFocusReconciliation = React2.useCallback(() => {
|
53
|
+
handleMenuItemFocusReconciliation(itemNode);
|
54
|
+
}, [handleMenuItemFocusReconciliation, itemNode]);
|
55
|
+
const spacelessDsIdForDom = `ds-menu-item-${`${dsId}`.replace(/\s/g, "")}`;
|
56
|
+
return /* @__PURE__ */ jsx(
|
57
|
+
StyledGlobalMenuItemWrapper,
|
58
|
+
{
|
59
|
+
innerRef: handleFocusOnRender,
|
60
|
+
onKeyDown: handleFocusableMenuItemKeyDown,
|
61
|
+
onClick: handleFocusableMenuItemClick,
|
62
|
+
onMouseEnter: handleOnMouseEnter,
|
63
|
+
onFocus: handleOnFocusReconciliation,
|
64
|
+
as: "div",
|
65
|
+
id: `${spacelessDsIdForDom}`,
|
66
|
+
role: "menuitem",
|
67
|
+
tabIndex: isFocused ? 0 : -1,
|
68
|
+
"aria-disabled": disabled,
|
69
|
+
applyAriaDisabled: disabled,
|
70
|
+
children: /* @__PURE__ */ jsxs(
|
71
|
+
StyledContentWrapper,
|
72
|
+
{
|
73
|
+
cols: gridLayout,
|
74
|
+
minHeight: "16px",
|
75
|
+
gutter: "xxs",
|
76
|
+
alignItems: "center",
|
77
|
+
minWidth: minWidth ?? void 0,
|
78
|
+
children: [
|
79
|
+
LeftDecComponent ? /* @__PURE__ */ jsx(LeftDecComponent, {}) : null,
|
80
|
+
/* @__PURE__ */ jsx(StyleMenuItemLabel, { children: label }),
|
81
|
+
secondaryLabel !== void 0 && /* @__PURE__ */ jsx(StyleMenuItemSecondaryLabel, { children: secondaryLabel })
|
82
|
+
]
|
83
|
+
}
|
84
|
+
)
|
85
|
+
}
|
86
|
+
);
|
87
|
+
};
|
88
|
+
export {
|
89
|
+
ActivableMenuItem
|
90
|
+
};
|
91
|
+
//# sourceMappingURL=ActivableMenuItem.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSMenuItemRendererFactory/ActivableMenuItem.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport {\n StyleMenuItemLabel,\n StyleMenuItemSecondaryLabel,\n StyledContentWrapper,\n StyledGlobalMenuItemWrapper,\n} from '@elliemae/ds-menu-items-commons';\nimport React from 'react';\nimport type { DSMenuButtonT } from '../../react-desc-prop-types.js';\nimport { MenuBehaviouralContextProviderContext } from '../DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js';\nimport { MENU_FOCUS_REGIONS } from '../DSMenuBehaviouralContextProvider/constants/index.js';\n\nexport const ActivableMenuItem: React.ComponentType<{ itemNode: DSMenuButtonT.MenuNodeActivableItem }> = ({\n itemNode,\n}) => {\n const { dsId, plainItem } = itemNode;\n const { label, secondaryLabel, leftDecoration: LeftDecComponent, minWidth, disabled } = plainItem;\n\n const {\n focusRegion,\n menuItemEventsHandlers: {\n handleFocusableMenuItemKeyDown,\n handleFocusableMenuItemClick,\n handleFocusableMenuItemOnMouseEnter,\n handleMenuItemFocusReconciliation,\n },\n } = React.useContext(MenuBehaviouralContextProviderContext);\n\n const gridLayout = React.useMemo(() => {\n const cols = LeftDecComponent ? ['min-content', 'auto'] : ['auto'];\n if (secondaryLabel) cols.push('auto');\n return cols;\n }, [LeftDecComponent, secondaryLabel]);\n\n const focusedRegionPerformanceHelper = React.useRef(focusRegion);\n focusedRegionPerformanceHelper.current = focusRegion;\n\n const isFocused = focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId);\n\n const handleFocusOnRender = React.useCallback(\n (node: HTMLDivElement) => {\n if (node && focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId)) {\n node.focus();\n }\n },\n // we need to change the callback reference every time the focusRegion changes or else the focus will not be set\n [dsId, focusRegion],\n // we are using the \"as='div'\", typescript is not able to infer the correct type\n // the logic here actually receives a ref to a HTMLDivElement,\n // but the component must think this is a HTMLLIElement ref callback\n ) as unknown as React.RefCallback<HTMLLIElement>;\n const handleOnMouseEnter = React.useCallback<React.MouseEventHandler<HTMLDivElement>>(\n (e) => {\n handleFocusableMenuItemOnMouseEnter(itemNode, e);\n },\n [handleFocusableMenuItemOnMouseEnter, itemNode],\n );\n const handleOnFocusReconciliation = React.useCallback(() => {\n handleMenuItemFocusReconciliation(itemNode);\n }, [handleMenuItemFocusReconciliation, itemNode]);\n\n const spacelessDsIdForDom = `ds-menu-item-${`${dsId}`.replace(/\\s/g, '')}`;\n\n return (\n <StyledGlobalMenuItemWrapper\n innerRef={handleFocusOnRender}\n onKeyDown={handleFocusableMenuItemKeyDown}\n onClick={handleFocusableMenuItemClick}\n onMouseEnter={handleOnMouseEnter}\n onFocus={handleOnFocusReconciliation}\n as=\"div\"\n id={`${spacelessDsIdForDom}`}\n role=\"menuitem\"\n tabIndex={isFocused ? 0 : -1}\n aria-disabled={disabled}\n applyAriaDisabled={disabled}\n >\n <StyledContentWrapper\n cols={gridLayout}\n minHeight=\"16px\"\n gutter=\"xxs\"\n alignItems=\"center\"\n minWidth={minWidth ?? undefined}\n >\n {LeftDecComponent ? <LeftDecComponent /> : null}\n <StyleMenuItemLabel>{label}</StyleMenuItemLabel>\n {secondaryLabel !== undefined && <StyleMenuItemSecondaryLabel>{secondaryLabel}</StyleMenuItemSecondaryLabel>}\n </StyledContentWrapper>\n </StyledGlobalMenuItemWrapper>\n );\n};\n"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC6EjB,SAOsB,KAPtB;AA5EN;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAOA,YAAW;AAElB,SAAS,6CAA6C;AACtD,SAAS,0BAA0B;AAE5B,MAAM,oBAA4F,CAAC;AAAA,EACxG;AACF,MAAM;AACJ,QAAM,EAAE,MAAM,UAAU,IAAI;AAC5B,QAAM,EAAE,OAAO,gBAAgB,gBAAgB,kBAAkB,UAAU,SAAS,IAAI;AAExF,QAAM;AAAA,IACJ;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,IAAIA,OAAM,WAAW,qCAAqC;AAE1D,QAAM,aAAaA,OAAM,QAAQ,MAAM;AACrC,UAAM,OAAO,mBAAmB,CAAC,eAAe,MAAM,IAAI,CAAC,MAAM;AACjE,QAAI,eAAgB,MAAK,KAAK,MAAM;AACpC,WAAO;AAAA,EACT,GAAG,CAAC,kBAAkB,cAAc,CAAC;AAErC,QAAM,iCAAiCA,OAAM,OAAO,WAAW;AAC/D,iCAA+B,UAAU;AAEzC,QAAM,YAAY,gBAAgB,mBAAmB,aAAa,IAAI;AAEtE,QAAM,sBAAsBA,OAAM;AAAA,IAChC,CAAC,SAAyB;AACxB,UAAI,QAAQ,gBAAgB,mBAAmB,aAAa,IAAI,GAAG;AACjE,aAAK,MAAM;AAAA,MACb;AAAA,IACF;AAAA;AAAA,IAEA,CAAC,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA,EAIpB;AACA,QAAM,qBAAqBA,OAAM;AAAA,IAC/B,CAAC,MAAM;AACL,0CAAoC,UAAU,CAAC;AAAA,IACjD;AAAA,IACA,CAAC,qCAAqC,QAAQ;AAAA,EAChD;AACA,QAAM,8BAA8BA,OAAM,YAAY,MAAM;AAC1D,sCAAkC,QAAQ;AAAA,EAC5C,GAAG,CAAC,mCAAmC,QAAQ,CAAC;AAEhD,QAAM,sBAAsB,gBAAgB,GAAG,IAAI,GAAG,QAAQ,OAAO,EAAE,CAAC;AAExE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,WAAW;AAAA,MACX,SAAS;AAAA,MACT,cAAc;AAAA,MACd,SAAS;AAAA,MACT,IAAG;AAAA,MACH,IAAI,GAAG,mBAAmB;AAAA,MAC1B,MAAK;AAAA,MACL,UAAU,YAAY,IAAI;AAAA,MAC1B,iBAAe;AAAA,MACf,mBAAmB;AAAA,MAEnB;AAAA,QAAC;AAAA;AAAA,UACC,MAAM;AAAA,UACN,WAAU;AAAA,UACV,QAAO;AAAA,UACP,YAAW;AAAA,UACX,UAAU,YAAY;AAAA,UAErB;AAAA,+BAAmB,oBAAC,oBAAiB,IAAK;AAAA,YAC3C,oBAAC,sBAAoB,iBAAM;AAAA,YAC1B,mBAAmB,UAAa,oBAAC,+BAA6B,0BAAe;AAAA;AAAA;AAAA,MAChF;AAAA;AAAA,EACF;AAEJ;",
|
6
|
+
"names": ["React"]
|
7
|
+
}
|
@@ -0,0 +1,134 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
3
|
+
import {
|
4
|
+
StyleMenuItemLabel,
|
5
|
+
StyleMenuItemSecondaryLabel,
|
6
|
+
StyledContentWrapper,
|
7
|
+
StyledGlobalMenuItemWrapper
|
8
|
+
} from "@elliemae/ds-menu-items-commons";
|
9
|
+
import React2 from "react";
|
10
|
+
import { useFloatingContext } from "@elliemae/ds-floating-context";
|
11
|
+
import { MenuBehaviouralContextProviderContext } from "../DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js";
|
12
|
+
import { MENU_FOCUS_REGIONS } from "../DSMenuBehaviouralContextProvider/constants/index.js";
|
13
|
+
const placementOrderPreference = [
|
14
|
+
"right-start",
|
15
|
+
"right-start",
|
16
|
+
"right",
|
17
|
+
"left-start",
|
18
|
+
"left-end",
|
19
|
+
"left"
|
20
|
+
];
|
21
|
+
const ActivableWithSubmenuMenuItem = ({ itemNode, FlyoutMenuCircularDepInject }) => {
|
22
|
+
const { dsId, plainItem } = itemNode;
|
23
|
+
const { label, secondaryLabel, leftDecoration: LeftDecComponent, minWidth, disabled } = plainItem;
|
24
|
+
const floatingContext = useFloatingContext({
|
25
|
+
placement: placementOrderPreference[0],
|
26
|
+
placementOrderPreference,
|
27
|
+
animationDuration: 100,
|
28
|
+
customOffset: [0, 0]
|
29
|
+
});
|
30
|
+
const {
|
31
|
+
refs: { setReference }
|
32
|
+
} = floatingContext;
|
33
|
+
const {
|
34
|
+
focusRegion,
|
35
|
+
openedSubItems,
|
36
|
+
menuItemEventsHandlers: {
|
37
|
+
handleFocusableMenuItemKeyDown,
|
38
|
+
handleFocusableMenuItemClick,
|
39
|
+
handleFocusableMenuItemOnMouseEnter,
|
40
|
+
handleMenuItemFocusReconciliation
|
41
|
+
}
|
42
|
+
} = React2.useContext(MenuBehaviouralContextProviderContext);
|
43
|
+
const gridLayout = React2.useMemo(() => {
|
44
|
+
const cols = LeftDecComponent ? ["min-content", "auto"] : ["auto"];
|
45
|
+
if (secondaryLabel) cols.push("auto");
|
46
|
+
return cols;
|
47
|
+
}, [LeftDecComponent, secondaryLabel]);
|
48
|
+
const focusedRegionPerformanceHelper = React2.useRef(focusRegion);
|
49
|
+
focusedRegionPerformanceHelper.current = focusRegion;
|
50
|
+
const isExpanded = openedSubItems.some((itemWithOpenSubmenu) => itemWithOpenSubmenu.dsId === dsId);
|
51
|
+
const isFocused = focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId);
|
52
|
+
const handleFocusOnRender = React2.useCallback(
|
53
|
+
(node) => {
|
54
|
+
setReference(node);
|
55
|
+
if (node && focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId)) {
|
56
|
+
node.focus();
|
57
|
+
}
|
58
|
+
},
|
59
|
+
// we need to change the callback reference every time the focusRegion changes or else the focus will not be set
|
60
|
+
[dsId, focusRegion, setReference]
|
61
|
+
// we are using the "as='div'", typescript is not able to infer the correct type
|
62
|
+
// the logic here actually receives a ref to a HTMLDivElement,
|
63
|
+
// but the component must think this is a HTMLLIElement ref callback
|
64
|
+
);
|
65
|
+
const handleOnMouseEnter = React2.useCallback(
|
66
|
+
(e) => {
|
67
|
+
handleFocusableMenuItemOnMouseEnter(itemNode, e);
|
68
|
+
},
|
69
|
+
[handleFocusableMenuItemOnMouseEnter, itemNode]
|
70
|
+
);
|
71
|
+
const handleOnFocusReconciliation = React2.useCallback(() => {
|
72
|
+
handleMenuItemFocusReconciliation(itemNode);
|
73
|
+
}, [handleMenuItemFocusReconciliation, itemNode]);
|
74
|
+
const spacelessDsIdForDom = `ds-menu-item-${`${dsId}`.replace(/\s/g, "")}`;
|
75
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
76
|
+
/* @__PURE__ */ jsx(
|
77
|
+
StyledGlobalMenuItemWrapper,
|
78
|
+
{
|
79
|
+
innerRef: handleFocusOnRender,
|
80
|
+
onKeyDown: handleFocusableMenuItemKeyDown,
|
81
|
+
onClick: handleFocusableMenuItemClick,
|
82
|
+
onMouseEnter: handleOnMouseEnter,
|
83
|
+
onFocus: handleOnFocusReconciliation,
|
84
|
+
as: "div",
|
85
|
+
id: `${spacelessDsIdForDom}`,
|
86
|
+
tabIndex: isFocused ? 0 : -1,
|
87
|
+
role: "menuitem",
|
88
|
+
"aria-controls": (
|
89
|
+
/* ********************************************************************************************************************
|
90
|
+
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-controls
|
91
|
+
* The aria-controls only needs to be set when the popup is visible, but it is valid and easier to program to reference an element that is not visible.
|
92
|
+
* ********************************************************************************************************************
|
93
|
+
* ^^^ some automated tools will mark an error if the aria-controls references an element that does (yet) exist in the DOM
|
94
|
+
* so, while technically valid to not check if expanded, we are doing it to avoid automated tools marking an error
|
95
|
+
* ******************************************************************************************************************** */
|
96
|
+
isExpanded ? itemNode.plainChildren.map((child) => `ds-menu-item-${`${child.dsId}`.replace(/\s/g, "")}`).join(" ") : void 0
|
97
|
+
),
|
98
|
+
"aria-haspopup": "menu",
|
99
|
+
"aria-expanded": isExpanded,
|
100
|
+
"aria-disabled": disabled,
|
101
|
+
applyAriaDisabled: disabled,
|
102
|
+
children: /* @__PURE__ */ jsxs(
|
103
|
+
StyledContentWrapper,
|
104
|
+
{
|
105
|
+
cols: gridLayout,
|
106
|
+
minHeight: "16px",
|
107
|
+
gutter: "xxs",
|
108
|
+
alignItems: "center",
|
109
|
+
minWidth: minWidth ?? void 0,
|
110
|
+
children: [
|
111
|
+
LeftDecComponent ? /* @__PURE__ */ jsx(LeftDecComponent, {}) : null,
|
112
|
+
/* @__PURE__ */ jsx(StyleMenuItemLabel, { children: label }),
|
113
|
+
secondaryLabel !== void 0 && /* @__PURE__ */ jsx(StyleMenuItemSecondaryLabel, { children: secondaryLabel })
|
114
|
+
]
|
115
|
+
}
|
116
|
+
)
|
117
|
+
}
|
118
|
+
),
|
119
|
+
/* @__PURE__ */ jsx(
|
120
|
+
FlyoutMenuCircularDepInject,
|
121
|
+
{
|
122
|
+
isMenuOpen: isExpanded,
|
123
|
+
floatingContext: floatingContext.context,
|
124
|
+
floatingStyles: floatingContext.floatingStyles,
|
125
|
+
setFloatingRef: floatingContext.refs.setFloating,
|
126
|
+
itemNode
|
127
|
+
}
|
128
|
+
)
|
129
|
+
] });
|
130
|
+
};
|
131
|
+
export {
|
132
|
+
ActivableWithSubmenuMenuItem
|
133
|
+
};
|
134
|
+
//# sourceMappingURL=ActivableWithSubmenuMenuItem.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSMenuItemRendererFactory/ActivableWithSubmenuMenuItem.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport {\n StyleMenuItemLabel,\n StyleMenuItemSecondaryLabel,\n StyledContentWrapper,\n StyledGlobalMenuItemWrapper,\n} from '@elliemae/ds-menu-items-commons';\nimport React from 'react';\nimport { useFloatingContext, type DSHookFloatingContextT } from '@elliemae/ds-floating-context';\nimport type { DSMenuButtonT } from '../../react-desc-prop-types.js';\nimport { MenuBehaviouralContextProviderContext } from '../DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js';\nimport { MENU_FOCUS_REGIONS } from '../DSMenuBehaviouralContextProvider/constants/index.js';\nimport { type DSMenuItemRendererFactoryT } from './react-desc-prop-types.js';\nconst placementOrderPreference: Required<DSHookFloatingContextT.Props>['placementOrderPreference'] = [\n 'right-start',\n 'right-start',\n 'right',\n 'left-start',\n 'left-end',\n 'left',\n];\nexport const ActivableWithSubmenuMenuItem: React.ComponentType<{\n itemNode: DSMenuButtonT.MenuNodeActivableWithSubmenuItem;\n FlyoutMenuCircularDepInject: DSMenuItemRendererFactoryT.RequiredProps['FlyoutMenuCircularDepInject'];\n}> = ({ itemNode, FlyoutMenuCircularDepInject }) => {\n const { dsId, plainItem } = itemNode;\n const { label, secondaryLabel, leftDecoration: LeftDecComponent, minWidth, disabled } = plainItem;\n const floatingContext = useFloatingContext({\n placement: placementOrderPreference[0],\n placementOrderPreference,\n animationDuration: 100,\n customOffset: [0, 0],\n });\n const {\n refs: { setReference },\n } = floatingContext;\n\n const {\n focusRegion,\n openedSubItems,\n menuItemEventsHandlers: {\n handleFocusableMenuItemKeyDown,\n handleFocusableMenuItemClick,\n handleFocusableMenuItemOnMouseEnter,\n handleMenuItemFocusReconciliation,\n },\n } = React.useContext(MenuBehaviouralContextProviderContext);\n\n const gridLayout = React.useMemo(() => {\n const cols = LeftDecComponent ? ['min-content', 'auto'] : ['auto'];\n if (secondaryLabel) cols.push('auto');\n return cols;\n }, [LeftDecComponent, secondaryLabel]);\n\n const focusedRegionPerformanceHelper = React.useRef(focusRegion);\n focusedRegionPerformanceHelper.current = focusRegion;\n\n const isExpanded = openedSubItems.some((itemWithOpenSubmenu) => itemWithOpenSubmenu.dsId === dsId);\n const isFocused = focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId);\n\n const handleFocusOnRender = React.useCallback(\n (node: HTMLDivElement) => {\n setReference(node);\n if (node && focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId)) {\n node.focus();\n }\n },\n // we need to change the callback reference every time the focusRegion changes or else the focus will not be set\n [dsId, focusRegion, setReference],\n // we are using the \"as='div'\", typescript is not able to infer the correct type\n // the logic here actually receives a ref to a HTMLDivElement,\n // but the component must think this is a HTMLLIElement ref callback\n ) as unknown as React.RefCallback<HTMLLIElement>;\n\n const handleOnMouseEnter = React.useCallback<React.MouseEventHandler<HTMLDivElement>>(\n (e) => {\n handleFocusableMenuItemOnMouseEnter(itemNode, e);\n },\n [handleFocusableMenuItemOnMouseEnter, itemNode],\n );\n const handleOnFocusReconciliation = React.useCallback(() => {\n handleMenuItemFocusReconciliation(itemNode);\n }, [handleMenuItemFocusReconciliation, itemNode]);\n\n const spacelessDsIdForDom = `ds-menu-item-${`${dsId}`.replace(/\\s/g, '')}`;\n return (\n <>\n <StyledGlobalMenuItemWrapper\n innerRef={handleFocusOnRender}\n onKeyDown={handleFocusableMenuItemKeyDown}\n onClick={handleFocusableMenuItemClick}\n onMouseEnter={handleOnMouseEnter}\n onFocus={handleOnFocusReconciliation}\n as=\"div\"\n id={`${spacelessDsIdForDom}`}\n tabIndex={isFocused ? 0 : -1}\n role=\"menuitem\"\n aria-controls={\n /* ********************************************************************************************************************\n * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-controls\n * The aria-controls only needs to be set when the popup is visible, but it is valid and easier to program to reference an element that is not visible.\n * ********************************************************************************************************************\n * ^^^ some automated tools will mark an error if the aria-controls references an element that does (yet) exist in the DOM\n * so, while technically valid to not check if expanded, we are doing it to avoid automated tools marking an error\n * ******************************************************************************************************************** */\n isExpanded\n ? itemNode.plainChildren.map((child) => `ds-menu-item-${`${child.dsId}`.replace(/\\s/g, '')}`).join(' ')\n : undefined\n }\n aria-haspopup=\"menu\"\n aria-expanded={isExpanded}\n aria-disabled={disabled}\n applyAriaDisabled={disabled}\n >\n <StyledContentWrapper\n cols={gridLayout}\n minHeight=\"16px\"\n gutter=\"xxs\"\n alignItems=\"center\"\n minWidth={minWidth ?? undefined}\n >\n {LeftDecComponent ? <LeftDecComponent /> : null}\n <StyleMenuItemLabel>{label}</StyleMenuItemLabel>\n {secondaryLabel !== undefined && <StyleMenuItemSecondaryLabel>{secondaryLabel}</StyleMenuItemSecondaryLabel>}\n </StyledContentWrapper>\n </StyledGlobalMenuItemWrapper>\n <FlyoutMenuCircularDepInject\n isMenuOpen={isExpanded}\n floatingContext={floatingContext.context}\n floatingStyles={floatingContext.floatingStyles}\n setFloatingRef={floatingContext.refs.setFloating}\n itemNode={itemNode}\n />\n </>\n );\n};\n"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACsFnB,mBAmC0B,KAPtB,YA5BJ;AArFJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAOA,YAAW;AAClB,SAAS,0BAAuD;AAEhE,SAAS,6CAA6C;AACtD,SAAS,0BAA0B;AAEnC,MAAM,2BAA+F;AAAA,EACnG;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACO,MAAM,+BAGR,CAAC,EAAE,UAAU,4BAA4B,MAAM;AAClD,QAAM,EAAE,MAAM,UAAU,IAAI;AAC5B,QAAM,EAAE,OAAO,gBAAgB,gBAAgB,kBAAkB,UAAU,SAAS,IAAI;AACxF,QAAM,kBAAkB,mBAAmB;AAAA,IACzC,WAAW,yBAAyB,CAAC;AAAA,IACrC;AAAA,IACA,mBAAmB;AAAA,IACnB,cAAc,CAAC,GAAG,CAAC;AAAA,EACrB,CAAC;AACD,QAAM;AAAA,IACJ,MAAM,EAAE,aAAa;AAAA,EACvB,IAAI;AAEJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,IAAIA,OAAM,WAAW,qCAAqC;AAE1D,QAAM,aAAaA,OAAM,QAAQ,MAAM;AACrC,UAAM,OAAO,mBAAmB,CAAC,eAAe,MAAM,IAAI,CAAC,MAAM;AACjE,QAAI,eAAgB,MAAK,KAAK,MAAM;AACpC,WAAO;AAAA,EACT,GAAG,CAAC,kBAAkB,cAAc,CAAC;AAErC,QAAM,iCAAiCA,OAAM,OAAO,WAAW;AAC/D,iCAA+B,UAAU;AAEzC,QAAM,aAAa,eAAe,KAAK,CAAC,wBAAwB,oBAAoB,SAAS,IAAI;AACjG,QAAM,YAAY,gBAAgB,mBAAmB,aAAa,IAAI;AAEtE,QAAM,sBAAsBA,OAAM;AAAA,IAChC,CAAC,SAAyB;AACxB,mBAAa,IAAI;AACjB,UAAI,QAAQ,gBAAgB,mBAAmB,aAAa,IAAI,GAAG;AACjE,aAAK,MAAM;AAAA,MACb;AAAA,IACF;AAAA;AAAA,IAEA,CAAC,MAAM,aAAa,YAAY;AAAA;AAAA;AAAA;AAAA,EAIlC;AAEA,QAAM,qBAAqBA,OAAM;AAAA,IAC/B,CAAC,MAAM;AACL,0CAAoC,UAAU,CAAC;AAAA,IACjD;AAAA,IACA,CAAC,qCAAqC,QAAQ;AAAA,EAChD;AACA,QAAM,8BAA8BA,OAAM,YAAY,MAAM;AAC1D,sCAAkC,QAAQ;AAAA,EAC5C,GAAG,CAAC,mCAAmC,QAAQ,CAAC;AAEhD,QAAM,sBAAsB,gBAAgB,GAAG,IAAI,GAAG,QAAQ,OAAO,EAAE,CAAC;AACxE,SACE,iCACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,UAAU;AAAA,QACV,WAAW;AAAA,QACX,SAAS;AAAA,QACT,cAAc;AAAA,QACd,SAAS;AAAA,QACT,IAAG;AAAA,QACH,IAAI,GAAG,mBAAmB;AAAA,QAC1B,UAAU,YAAY,IAAI;AAAA,QAC1B,MAAK;AAAA,QACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAQE,aACI,SAAS,cAAc,IAAI,CAAC,UAAU,gBAAgB,GAAG,MAAM,IAAI,GAAG,QAAQ,OAAO,EAAE,CAAC,EAAE,EAAE,KAAK,GAAG,IACpG;AAAA;AAAA,QAEN,iBAAc;AAAA,QACd,iBAAe;AAAA,QACf,iBAAe;AAAA,QACf,mBAAmB;AAAA,QAEnB;AAAA,UAAC;AAAA;AAAA,YACC,MAAM;AAAA,YACN,WAAU;AAAA,YACV,QAAO;AAAA,YACP,YAAW;AAAA,YACX,UAAU,YAAY;AAAA,YAErB;AAAA,iCAAmB,oBAAC,oBAAiB,IAAK;AAAA,cAC3C,oBAAC,sBAAoB,iBAAM;AAAA,cAC1B,mBAAmB,UAAa,oBAAC,+BAA6B,0BAAe;AAAA;AAAA;AAAA,QAChF;AAAA;AAAA,IACF;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,YAAY;AAAA,QACZ,iBAAiB,gBAAgB;AAAA,QACjC,gBAAgB,gBAAgB;AAAA,QAChC,gBAAgB,gBAAgB,KAAK;AAAA,QACrC;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;",
|
6
|
+
"names": ["React"]
|
7
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
3
|
+
import { Grid } from "@elliemae/ds-grid";
|
4
|
+
import { describe } from "@elliemae/ds-props-helpers";
|
5
|
+
import { StyledGroupLabel } from "@elliemae/ds-menu-items-commons";
|
6
|
+
import { useMenuItemRendererFactory } from "./config/useMenuItemRendererFactory.js";
|
7
|
+
import { DSMenuItemRendererFactoryName } from "./constants/index.js";
|
8
|
+
import { DSMenuItemRendererFactoryPropTypesSchema } from "./react-desc-prop-types.js";
|
9
|
+
import { ActivableMenuItem } from "./ActivableMenuItem.js";
|
10
|
+
import { SingleSelectMenuItem } from "./SingleSelectMenuItem.js";
|
11
|
+
import { SingleSelectWithSubmenuMenuItem } from "./SingleSelectWithSubmenuMenuItem.js";
|
12
|
+
import { MultipleSelectMenuItem } from "./MultipleSelectMenuItem.js";
|
13
|
+
import { WithSubmenuMenuItem } from "./WithSubmenuMenuItem.js";
|
14
|
+
import { MultipleSelectWithSubmenuMenuItem } from "./MultipleSelectWithSubmenuMenuItem.js";
|
15
|
+
import { ActivableWithSubmenuMenuItem } from "./ActivableWithSubmenuMenuItem.js";
|
16
|
+
import {
|
17
|
+
isActivableNode,
|
18
|
+
isSkeletonNode,
|
19
|
+
isMultipleSelectOnlyNode,
|
20
|
+
isSingleSelectOnlyNode,
|
21
|
+
isSeparatorNode,
|
22
|
+
isGroup,
|
23
|
+
isWithSubmenuOnlyNode,
|
24
|
+
isSingleSelectNodeWithSubmenu,
|
25
|
+
isMultipleSelectWithSubmenuNode,
|
26
|
+
isActivableWithSubmenuNode
|
27
|
+
} from "../../utils/nodesTypeguardsAndGetters.js";
|
28
|
+
const DSMenuItemRendererFactory = (props) => {
|
29
|
+
const { propsWithDefault, instanceUid } = useMenuItemRendererFactory(props);
|
30
|
+
const { itemNode, ItemRenderer, FlyoutMenuCircularDepInject } = propsWithDefault;
|
31
|
+
if (ItemRenderer) return /* @__PURE__ */ jsx(ItemRenderer, { itemNode });
|
32
|
+
if (isSeparatorNode(itemNode)) return /* @__PURE__ */ jsx("hr", {});
|
33
|
+
if (isSkeletonNode(itemNode)) return /* @__PURE__ */ jsx("li", { children: "loading..." });
|
34
|
+
if (isActivableNode(itemNode)) return /* @__PURE__ */ jsx(ActivableMenuItem, { itemNode });
|
35
|
+
if (isMultipleSelectOnlyNode(itemNode)) return /* @__PURE__ */ jsx(MultipleSelectMenuItem, { itemNode });
|
36
|
+
if (isSingleSelectOnlyNode(itemNode)) return /* @__PURE__ */ jsx(SingleSelectMenuItem, { itemNode });
|
37
|
+
if (isWithSubmenuOnlyNode(itemNode))
|
38
|
+
return /* @__PURE__ */ jsx(WithSubmenuMenuItem, { itemNode, FlyoutMenuCircularDepInject });
|
39
|
+
if (isSingleSelectNodeWithSubmenu(itemNode))
|
40
|
+
return /* @__PURE__ */ jsx(SingleSelectWithSubmenuMenuItem, { itemNode, FlyoutMenuCircularDepInject });
|
41
|
+
if (isMultipleSelectWithSubmenuNode(itemNode))
|
42
|
+
return /* @__PURE__ */ jsx(
|
43
|
+
MultipleSelectWithSubmenuMenuItem,
|
44
|
+
{
|
45
|
+
itemNode,
|
46
|
+
FlyoutMenuCircularDepInject
|
47
|
+
}
|
48
|
+
);
|
49
|
+
if (isActivableWithSubmenuNode(itemNode))
|
50
|
+
return /* @__PURE__ */ jsx(ActivableWithSubmenuMenuItem, { itemNode, FlyoutMenuCircularDepInject });
|
51
|
+
if (isGroup(itemNode)) {
|
52
|
+
const { leftDecoration: LeftDecComponent, label, minWidth } = itemNode.plainItem;
|
53
|
+
const spacelessIdForGroup = label ? `label-${label.replace(/\s/g, "")}` : void 0;
|
54
|
+
return /* @__PURE__ */ jsxs("div", { role: "group", "aria-labelledby": spacelessIdForGroup, style: minWidth ? { minWidth } : {}, children: [
|
55
|
+
label ? /* @__PURE__ */ jsxs(Grid, { cols: LeftDecComponent ? ["min-content", "1fr"] : ["1fr"], children: [
|
56
|
+
LeftDecComponent ? /* @__PURE__ */ jsx(LeftDecComponent, {}) : null,
|
57
|
+
/* @__PURE__ */ jsx(StyledGroupLabel, { role: "presentation", id: spacelessIdForGroup, children: label })
|
58
|
+
] }) : null,
|
59
|
+
itemNode.children.map((subItemNode) => /* @__PURE__ */ jsx(
|
60
|
+
DSMenuItemRendererFactory,
|
61
|
+
{
|
62
|
+
itemNode: subItemNode,
|
63
|
+
FlyoutMenuCircularDepInject
|
64
|
+
},
|
65
|
+
`item-factory-${subItemNode.dsId}-${instanceUid}`
|
66
|
+
))
|
67
|
+
] });
|
68
|
+
}
|
69
|
+
throw new Error(`Invalid item type: ${JSON.stringify(itemNode)}`);
|
70
|
+
};
|
71
|
+
DSMenuItemRendererFactory.displayName = DSMenuItemRendererFactoryName;
|
72
|
+
const DSMenuItemRendererFactoryWithSchema = describe(DSMenuItemRendererFactory);
|
73
|
+
DSMenuItemRendererFactoryWithSchema.propTypes = DSMenuItemRendererFactoryPropTypesSchema;
|
74
|
+
export {
|
75
|
+
DSMenuItemRendererFactory,
|
76
|
+
DSMenuItemRendererFactoryWithSchema
|
77
|
+
};
|
78
|
+
//# sourceMappingURL=DSMenuItemRendererFactory.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSMenuItemRendererFactory/DSMenuItemRendererFactory.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport { Grid } from '@elliemae/ds-grid';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { StyledGroupLabel } from '@elliemae/ds-menu-items-commons';\nimport React from 'react';\nimport { useMenuItemRendererFactory } from './config/useMenuItemRendererFactory.js';\nimport { DSMenuItemRendererFactoryName } from './constants/index.js';\nimport { DSMenuItemRendererFactoryPropTypesSchema, type DSMenuItemRendererFactoryT } from './react-desc-prop-types.js';\nimport { ActivableMenuItem } from './ActivableMenuItem.js';\nimport { SingleSelectMenuItem } from './SingleSelectMenuItem.js';\nimport { SingleSelectWithSubmenuMenuItem } from './SingleSelectWithSubmenuMenuItem.js';\nimport { MultipleSelectMenuItem } from './MultipleSelectMenuItem.js';\nimport { WithSubmenuMenuItem } from './WithSubmenuMenuItem.js';\nimport { MultipleSelectWithSubmenuMenuItem } from './MultipleSelectWithSubmenuMenuItem.js';\nimport { ActivableWithSubmenuMenuItem } from './ActivableWithSubmenuMenuItem.js';\nimport {\n isActivableNode,\n isSkeletonNode,\n isMultipleSelectOnlyNode,\n isSingleSelectOnlyNode,\n isSeparatorNode,\n isGroup,\n isWithSubmenuOnlyNode,\n isSingleSelectNodeWithSubmenu,\n isMultipleSelectWithSubmenuNode,\n isActivableWithSubmenuNode,\n} from '../../utils/nodesTypeguardsAndGetters.js';\n\nconst DSMenuItemRendererFactory: React.ComponentType<DSMenuItemRendererFactoryT.Props> = (props) => {\n const { propsWithDefault, instanceUid } = useMenuItemRendererFactory(props);\n const { itemNode, ItemRenderer, FlyoutMenuCircularDepInject } = propsWithDefault;\n\n if (ItemRenderer) return <ItemRenderer itemNode={itemNode} />;\n\n if (isSeparatorNode(itemNode)) return <hr />;\n if (isSkeletonNode(itemNode)) return <li>loading...</li>;\n if (isActivableNode(itemNode)) return <ActivableMenuItem itemNode={itemNode} />;\n if (isMultipleSelectOnlyNode(itemNode)) return <MultipleSelectMenuItem itemNode={itemNode} />;\n if (isSingleSelectOnlyNode(itemNode)) return <SingleSelectMenuItem itemNode={itemNode} />;\n\n if (isWithSubmenuOnlyNode(itemNode))\n return <WithSubmenuMenuItem itemNode={itemNode} FlyoutMenuCircularDepInject={FlyoutMenuCircularDepInject} />;\n if (isSingleSelectNodeWithSubmenu(itemNode))\n return (\n <SingleSelectWithSubmenuMenuItem itemNode={itemNode} FlyoutMenuCircularDepInject={FlyoutMenuCircularDepInject} />\n );\n if (isMultipleSelectWithSubmenuNode(itemNode))\n return (\n <MultipleSelectWithSubmenuMenuItem\n itemNode={itemNode}\n FlyoutMenuCircularDepInject={FlyoutMenuCircularDepInject}\n />\n );\n if (isActivableWithSubmenuNode(itemNode))\n return (\n <ActivableWithSubmenuMenuItem itemNode={itemNode} FlyoutMenuCircularDepInject={FlyoutMenuCircularDepInject} />\n );\n\n // defined in this file to avoid to have to inject the ItemRendererFactory prop in the \"GroupMenuItem\" component\n // if we eventually move this to a separate file,\n // we will have to inject the ItemRendererFactory prop in the \"GroupMenuItem\" component to avoid circular dependencies\n if (isGroup(itemNode)) {\n const { leftDecoration: LeftDecComponent, label, minWidth } = itemNode.plainItem;\n const spacelessIdForGroup = label ? `label-${label.replace(/\\s/g, '')}` : undefined;\n\n return (\n <div role=\"group\" aria-labelledby={spacelessIdForGroup} style={minWidth ? { minWidth } : {}}>\n {label ? (\n <Grid cols={LeftDecComponent ? ['min-content', '1fr'] : ['1fr']}>\n {LeftDecComponent ? <LeftDecComponent /> : null}\n <StyledGroupLabel role=\"presentation\" id={spacelessIdForGroup}>\n {label}\n </StyledGroupLabel>\n </Grid>\n ) : null}\n {itemNode.children.map((subItemNode) => (\n <DSMenuItemRendererFactory\n key={`item-factory-${subItemNode.dsId}-${instanceUid}`}\n itemNode={subItemNode}\n FlyoutMenuCircularDepInject={FlyoutMenuCircularDepInject}\n />\n ))}\n </div>\n );\n }\n\n // if we get here either\n // - a new type of item has been added and this component wasn't updated\n // -> update this component to handle the new type\n // - developer provided an invalid type for the item\n // -> developer should fix the item type\n // ----------\n // the following rule is disabled because this is LITERALLY an error throwing section,\n // of course typescript thinks type is never, that's why we are throwing an error...\n // ----------\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new Error(`Invalid item type: ${JSON.stringify(itemNode)}`);\n};\n\nDSMenuItemRendererFactory.displayName = DSMenuItemRendererFactoryName;\nconst DSMenuItemRendererFactoryWithSchema = describe(DSMenuItemRendererFactory);\nDSMenuItemRendererFactoryWithSchema.propTypes = DSMenuItemRendererFactoryPropTypesSchema;\n\nexport { DSMenuItemRendererFactory, DSMenuItemRendererFactoryWithSchema };\n"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACgCI,cAoCjB,YApCiB;AA/B3B,SAAS,YAAY;AACrB,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AAEjC,SAAS,kCAAkC;AAC3C,SAAS,qCAAqC;AAC9C,SAAS,gDAAiF;AAC1F,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,uCAAuC;AAChD,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AACpC,SAAS,yCAAyC;AAClD,SAAS,oCAAoC;AAC7C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,4BAAmF,CAAC,UAAU;AAClG,QAAM,EAAE,kBAAkB,YAAY,IAAI,2BAA2B,KAAK;AAC1E,QAAM,EAAE,UAAU,cAAc,4BAA4B,IAAI;AAEhE,MAAI,aAAc,QAAO,oBAAC,gBAAa,UAAoB;AAE3D,MAAI,gBAAgB,QAAQ,EAAG,QAAO,oBAAC,QAAG;AAC1C,MAAI,eAAe,QAAQ,EAAG,QAAO,oBAAC,QAAG,wBAAU;AACnD,MAAI,gBAAgB,QAAQ,EAAG,QAAO,oBAAC,qBAAkB,UAAoB;AAC7E,MAAI,yBAAyB,QAAQ,EAAG,QAAO,oBAAC,0BAAuB,UAAoB;AAC3F,MAAI,uBAAuB,QAAQ,EAAG,QAAO,oBAAC,wBAAqB,UAAoB;AAEvF,MAAI,sBAAsB,QAAQ;AAChC,WAAO,oBAAC,uBAAoB,UAAoB,6BAA0D;AAC5G,MAAI,8BAA8B,QAAQ;AACxC,WACE,oBAAC,mCAAgC,UAAoB,6BAA0D;AAEnH,MAAI,gCAAgC,QAAQ;AAC1C,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA;AAAA,IACF;AAEJ,MAAI,2BAA2B,QAAQ;AACrC,WACE,oBAAC,gCAA6B,UAAoB,6BAA0D;AAMhH,MAAI,QAAQ,QAAQ,GAAG;AACrB,UAAM,EAAE,gBAAgB,kBAAkB,OAAO,SAAS,IAAI,SAAS;AACvE,UAAM,sBAAsB,QAAQ,SAAS,MAAM,QAAQ,OAAO,EAAE,CAAC,KAAK;AAE1E,WACE,qBAAC,SAAI,MAAK,SAAQ,mBAAiB,qBAAqB,OAAO,WAAW,EAAE,SAAS,IAAI,CAAC,GACvF;AAAA,cACC,qBAAC,QAAK,MAAM,mBAAmB,CAAC,eAAe,KAAK,IAAI,CAAC,KAAK,GAC3D;AAAA,2BAAmB,oBAAC,oBAAiB,IAAK;AAAA,QAC3C,oBAAC,oBAAiB,MAAK,gBAAe,IAAI,qBACvC,iBACH;AAAA,SACF,IACE;AAAA,MACH,SAAS,SAAS,IAAI,CAAC,gBACtB;AAAA,QAAC;AAAA;AAAA,UAEC,UAAU;AAAA,UACV;AAAA;AAAA,QAFK,gBAAgB,YAAY,IAAI,IAAI,WAAW;AAAA,MAGtD,CACD;AAAA,OACH;AAAA,EAEJ;AAYA,QAAM,IAAI,MAAM,sBAAsB,KAAK,UAAU,QAAQ,CAAC,EAAE;AAClE;AAEA,0BAA0B,cAAc;AACxC,MAAM,sCAAsC,SAAS,yBAAyB;AAC9E,oCAAoC,YAAY;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
3
|
+
import { Grid } from "@elliemae/ds-grid";
|
4
|
+
import { Checkmark } from "@elliemae/ds-icons";
|
5
|
+
import {
|
6
|
+
StyleMenuItemLabel,
|
7
|
+
StyleMenuItemSecondaryLabel,
|
8
|
+
StyledContentWrapper,
|
9
|
+
StyledGlobalMenuItemWrapper
|
10
|
+
} from "@elliemae/ds-menu-items-commons";
|
11
|
+
import React2 from "react";
|
12
|
+
import { MenuBehaviouralContextProviderContext } from "../DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js";
|
13
|
+
import { MENU_FOCUS_REGIONS } from "../DSMenuBehaviouralContextProvider/constants/index.js";
|
14
|
+
const LeftBoxlessCheckbox = React2.memo(({ isSelected }) => /* @__PURE__ */ jsx(Grid, { width: "16px", children: isSelected ? /* @__PURE__ */ jsx(Checkmark, { size: "s", color: ["brand-primary", "600"] }) : /* @__PURE__ */ jsx("div", {}) }));
|
15
|
+
const MultipleSelectMenuItem = ({ itemNode }) => {
|
16
|
+
const { dsId, plainItem } = itemNode;
|
17
|
+
const { label, secondaryLabel, leftDecoration: LeftDecComponent, minWidth, disabled } = plainItem;
|
18
|
+
const {
|
19
|
+
focusRegion,
|
20
|
+
propsWithDefault,
|
21
|
+
menuItemEventsHandlers: {
|
22
|
+
handleFocusableMenuItemKeyDown,
|
23
|
+
handleFocusableMenuItemClick,
|
24
|
+
handleFocusableMenuItemOnMouseEnter,
|
25
|
+
handleMenuItemFocusReconciliation
|
26
|
+
}
|
27
|
+
} = React2.useContext(MenuBehaviouralContextProviderContext);
|
28
|
+
const { selectedItems } = propsWithDefault;
|
29
|
+
const gridLayout = React2.useMemo(() => {
|
30
|
+
const cols = LeftDecComponent ? ["min-content", "min-content", "auto"] : ["min-content", "auto"];
|
31
|
+
if (secondaryLabel) cols.push("auto");
|
32
|
+
return cols;
|
33
|
+
}, [LeftDecComponent, secondaryLabel]);
|
34
|
+
const focusedRegionPerformanceHelper = React2.useRef(focusRegion);
|
35
|
+
focusedRegionPerformanceHelper.current = focusRegion;
|
36
|
+
const isFocused = focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId);
|
37
|
+
const isSelected = selectedItems.some((itemMarkesAsSelected) => itemMarkesAsSelected.dsId === dsId);
|
38
|
+
const handleFocusOnRender = React2.useCallback(
|
39
|
+
(node) => {
|
40
|
+
if (node && focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId)) {
|
41
|
+
node.focus();
|
42
|
+
}
|
43
|
+
},
|
44
|
+
// we need to change the callback reference every time the focusRegion changes or else the focus will not be set
|
45
|
+
[dsId, focusRegion]
|
46
|
+
// we are using the "as='div'", typescript is not able to infer the correct type
|
47
|
+
// the logic here actually receives a ref to a HTMLDivElement,
|
48
|
+
// but the component must think this is a HTMLLIElement ref callback
|
49
|
+
);
|
50
|
+
const handleOnMouseEnter = React2.useCallback(
|
51
|
+
(e) => {
|
52
|
+
handleFocusableMenuItemOnMouseEnter(itemNode, e);
|
53
|
+
},
|
54
|
+
[handleFocusableMenuItemOnMouseEnter, itemNode]
|
55
|
+
);
|
56
|
+
const handleOnFocusReconciliation = React2.useCallback(() => {
|
57
|
+
handleMenuItemFocusReconciliation(itemNode);
|
58
|
+
}, [handleMenuItemFocusReconciliation, itemNode]);
|
59
|
+
const spacelessDsIdForDom = `ds-menu-item-${`${dsId}`.replace(/\s/g, "")}`;
|
60
|
+
return /* @__PURE__ */ jsx(
|
61
|
+
StyledGlobalMenuItemWrapper,
|
62
|
+
{
|
63
|
+
innerRef: handleFocusOnRender,
|
64
|
+
onKeyDown: handleFocusableMenuItemKeyDown,
|
65
|
+
onClick: handleFocusableMenuItemClick,
|
66
|
+
onMouseEnter: handleOnMouseEnter,
|
67
|
+
as: "div",
|
68
|
+
onFocus: handleOnFocusReconciliation,
|
69
|
+
id: `${spacelessDsIdForDom}`,
|
70
|
+
tabIndex: isFocused ? 0 : -1,
|
71
|
+
role: "menuitemcheckbox",
|
72
|
+
"aria-checked": isSelected,
|
73
|
+
"aria-disabled": disabled,
|
74
|
+
applyAriaDisabled: disabled,
|
75
|
+
children: /* @__PURE__ */ jsxs(
|
76
|
+
StyledContentWrapper,
|
77
|
+
{
|
78
|
+
cols: gridLayout,
|
79
|
+
minHeight: "16px",
|
80
|
+
gutter: "xxs",
|
81
|
+
alignItems: "center",
|
82
|
+
minWidth: minWidth ?? void 0,
|
83
|
+
children: [
|
84
|
+
/* @__PURE__ */ jsx(LeftBoxlessCheckbox, { isSelected }),
|
85
|
+
LeftDecComponent ? /* @__PURE__ */ jsx(LeftDecComponent, {}) : null,
|
86
|
+
/* @__PURE__ */ jsx(StyleMenuItemLabel, { children: label }),
|
87
|
+
secondaryLabel !== void 0 && /* @__PURE__ */ jsx(StyleMenuItemSecondaryLabel, { children: secondaryLabel })
|
88
|
+
]
|
89
|
+
}
|
90
|
+
)
|
91
|
+
}
|
92
|
+
);
|
93
|
+
};
|
94
|
+
export {
|
95
|
+
MultipleSelectMenuItem
|
96
|
+
};
|
97
|
+
//# sourceMappingURL=MultipleSelectMenuItem.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSMenuItemRendererFactory/MultipleSelectMenuItem.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { Grid } from '@elliemae/ds-grid';\nimport { Checkmark } from '@elliemae/ds-icons';\nimport {\n StyleMenuItemLabel,\n StyleMenuItemSecondaryLabel,\n StyledContentWrapper,\n StyledGlobalMenuItemWrapper,\n} from '@elliemae/ds-menu-items-commons';\nimport React from 'react';\nimport type { DSMenuButtonT } from '../../react-desc-prop-types.js';\nimport { MenuBehaviouralContextProviderContext } from '../DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js';\nimport { MENU_FOCUS_REGIONS } from '../DSMenuBehaviouralContextProvider/constants/index.js';\n\nconst LeftBoxlessCheckbox = React.memo(({ isSelected }: { isSelected: boolean }) => (\n <Grid width=\"16px\">{isSelected ? <Checkmark size=\"s\" color={['brand-primary', '600']} /> : <div />}</Grid>\n));\nexport const MultipleSelectMenuItem: React.ComponentType<{\n itemNode: DSMenuButtonT.MenuNodeMultipleSelectItem;\n}> = ({ itemNode }) => {\n const { dsId, plainItem } = itemNode;\n const { label, secondaryLabel, leftDecoration: LeftDecComponent, minWidth, disabled } = plainItem;\n const {\n focusRegion,\n propsWithDefault,\n menuItemEventsHandlers: {\n handleFocusableMenuItemKeyDown,\n handleFocusableMenuItemClick,\n handleFocusableMenuItemOnMouseEnter,\n handleMenuItemFocusReconciliation,\n },\n } = React.useContext(MenuBehaviouralContextProviderContext);\n const { selectedItems } = propsWithDefault;\n\n const gridLayout = React.useMemo(() => {\n const cols = LeftDecComponent ? ['min-content', 'min-content', 'auto'] : ['min-content', 'auto'];\n if (secondaryLabel) cols.push('auto');\n return cols;\n }, [LeftDecComponent, secondaryLabel]);\n\n const focusedRegionPerformanceHelper = React.useRef(focusRegion);\n focusedRegionPerformanceHelper.current = focusRegion;\n\n const isFocused = focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId);\n const isSelected = selectedItems.some((itemMarkesAsSelected) => itemMarkesAsSelected.dsId === dsId);\n\n const handleFocusOnRender = React.useCallback(\n (node: HTMLDivElement) => {\n if (node && focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId)) {\n node.focus();\n }\n },\n // we need to change the callback reference every time the focusRegion changes or else the focus will not be set\n [dsId, focusRegion],\n // we are using the \"as='div'\", typescript is not able to infer the correct type\n // the logic here actually receives a ref to a HTMLDivElement,\n // but the component must think this is a HTMLLIElement ref callback\n ) as unknown as React.RefCallback<HTMLLIElement>;\n\n const handleOnMouseEnter = React.useCallback<React.MouseEventHandler<HTMLDivElement>>(\n (e) => {\n handleFocusableMenuItemOnMouseEnter(itemNode, e);\n },\n [handleFocusableMenuItemOnMouseEnter, itemNode],\n );\n const handleOnFocusReconciliation = React.useCallback(() => {\n handleMenuItemFocusReconciliation(itemNode);\n }, [handleMenuItemFocusReconciliation, itemNode]);\n\n const spacelessDsIdForDom = `ds-menu-item-${`${dsId}`.replace(/\\s/g, '')}`;\n return (\n <StyledGlobalMenuItemWrapper\n innerRef={handleFocusOnRender}\n onKeyDown={handleFocusableMenuItemKeyDown}\n onClick={handleFocusableMenuItemClick}\n onMouseEnter={handleOnMouseEnter}\n as=\"div\"\n onFocus={handleOnFocusReconciliation}\n id={`${spacelessDsIdForDom}`}\n tabIndex={isFocused ? 0 : -1}\n role=\"menuitemcheckbox\"\n aria-checked={isSelected}\n aria-disabled={disabled}\n applyAriaDisabled={disabled}\n >\n <StyledContentWrapper\n cols={gridLayout}\n minHeight=\"16px\"\n gutter=\"xxs\"\n alignItems=\"center\"\n minWidth={minWidth ?? undefined}\n >\n <LeftBoxlessCheckbox isSelected={isSelected} />\n {LeftDecComponent ? <LeftDecComponent /> : null}\n <StyleMenuItemLabel>{label}</StyleMenuItemLabel>\n {secondaryLabel !== undefined && <StyleMenuItemSecondaryLabel>{secondaryLabel}</StyleMenuItemSecondaryLabel>}\n </StyledContentWrapper>\n </StyledGlobalMenuItemWrapper>\n );\n};\n"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACcY,cAsE7B,YAtE6B;AAdnC,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAOA,YAAW;AAElB,SAAS,6CAA6C;AACtD,SAAS,0BAA0B;AAEnC,MAAM,sBAAsBA,OAAM,KAAK,CAAC,EAAE,WAAW,MACnD,oBAAC,QAAK,OAAM,QAAQ,uBAAa,oBAAC,aAAU,MAAK,KAAI,OAAO,CAAC,iBAAiB,KAAK,GAAG,IAAK,oBAAC,SAAI,GAAG,CACpG;AACM,MAAM,yBAER,CAAC,EAAE,SAAS,MAAM;AACrB,QAAM,EAAE,MAAM,UAAU,IAAI;AAC5B,QAAM,EAAE,OAAO,gBAAgB,gBAAgB,kBAAkB,UAAU,SAAS,IAAI;AACxF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,IAAIA,OAAM,WAAW,qCAAqC;AAC1D,QAAM,EAAE,cAAc,IAAI;AAE1B,QAAM,aAAaA,OAAM,QAAQ,MAAM;AACrC,UAAM,OAAO,mBAAmB,CAAC,eAAe,eAAe,MAAM,IAAI,CAAC,eAAe,MAAM;AAC/F,QAAI,eAAgB,MAAK,KAAK,MAAM;AACpC,WAAO;AAAA,EACT,GAAG,CAAC,kBAAkB,cAAc,CAAC;AAErC,QAAM,iCAAiCA,OAAM,OAAO,WAAW;AAC/D,iCAA+B,UAAU;AAEzC,QAAM,YAAY,gBAAgB,mBAAmB,aAAa,IAAI;AACtE,QAAM,aAAa,cAAc,KAAK,CAAC,yBAAyB,qBAAqB,SAAS,IAAI;AAElG,QAAM,sBAAsBA,OAAM;AAAA,IAChC,CAAC,SAAyB;AACxB,UAAI,QAAQ,gBAAgB,mBAAmB,aAAa,IAAI,GAAG;AACjE,aAAK,MAAM;AAAA,MACb;AAAA,IACF;AAAA;AAAA,IAEA,CAAC,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA,EAIpB;AAEA,QAAM,qBAAqBA,OAAM;AAAA,IAC/B,CAAC,MAAM;AACL,0CAAoC,UAAU,CAAC;AAAA,IACjD;AAAA,IACA,CAAC,qCAAqC,QAAQ;AAAA,EAChD;AACA,QAAM,8BAA8BA,OAAM,YAAY,MAAM;AAC1D,sCAAkC,QAAQ;AAAA,EAC5C,GAAG,CAAC,mCAAmC,QAAQ,CAAC;AAEhD,QAAM,sBAAsB,gBAAgB,GAAG,IAAI,GAAG,QAAQ,OAAO,EAAE,CAAC;AACxE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,WAAW;AAAA,MACX,SAAS;AAAA,MACT,cAAc;AAAA,MACd,IAAG;AAAA,MACH,SAAS;AAAA,MACT,IAAI,GAAG,mBAAmB;AAAA,MAC1B,UAAU,YAAY,IAAI;AAAA,MAC1B,MAAK;AAAA,MACL,gBAAc;AAAA,MACd,iBAAe;AAAA,MACf,mBAAmB;AAAA,MAEnB;AAAA,QAAC;AAAA;AAAA,UACC,MAAM;AAAA,UACN,WAAU;AAAA,UACV,QAAO;AAAA,UACP,YAAW;AAAA,UACX,UAAU,YAAY;AAAA,UAEtB;AAAA,gCAAC,uBAAoB,YAAwB;AAAA,YAC5C,mBAAmB,oBAAC,oBAAiB,IAAK;AAAA,YAC3C,oBAAC,sBAAoB,iBAAM;AAAA,YAC1B,mBAAmB,UAAa,oBAAC,+BAA6B,0BAAe;AAAA;AAAA;AAAA,MAChF;AAAA;AAAA,EACF;AAEJ;",
|
6
|
+
"names": ["React"]
|
7
|
+
}
|
@@ -0,0 +1,148 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
3
|
+
import { useFloatingContext } from "@elliemae/ds-floating-context";
|
4
|
+
import { Grid } from "@elliemae/ds-grid";
|
5
|
+
import { Checkmark, ChevronSmallRight, ParenthesisRemove } from "@elliemae/ds-icons";
|
6
|
+
import {
|
7
|
+
StyleMenuItemLabel,
|
8
|
+
StyleMenuItemSecondaryLabel,
|
9
|
+
StyledContentWrapper,
|
10
|
+
StyledGlobalMenuItemWrapper
|
11
|
+
} from "@elliemae/ds-menu-items-commons";
|
12
|
+
import React2 from "react";
|
13
|
+
import { MenuBehaviouralContextProviderContext } from "../DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js";
|
14
|
+
import { MENU_FOCUS_REGIONS } from "../DSMenuBehaviouralContextProvider/constants/index.js";
|
15
|
+
import { getIsMultipleSelectNodeWithSubmenuSelected } from "../DSMenuBehaviouralContextProvider/utils/multipleSelectionHelpers.js";
|
16
|
+
const placementOrderPreference = [
|
17
|
+
"right-start",
|
18
|
+
"right-start",
|
19
|
+
"right",
|
20
|
+
"left-start",
|
21
|
+
"left-end",
|
22
|
+
"left"
|
23
|
+
];
|
24
|
+
const LeftBoxlessCheckbox = React2.memo(({ isSelected }) => /* @__PURE__ */ jsx(Grid, { width: "16px", children: isSelected ? isSelected === "mixed" ? /* @__PURE__ */ jsx(ParenthesisRemove, { size: "s", color: ["brand-primary", "600"] }) : /* @__PURE__ */ jsx(Checkmark, { size: "s", color: ["brand-primary", "600"] }) : /* @__PURE__ */ jsx("div", {}) }));
|
25
|
+
const MultipleSelectWithSubmenuMenuItem = ({ itemNode, FlyoutMenuCircularDepInject }) => {
|
26
|
+
const { dsId, plainItem } = itemNode;
|
27
|
+
const { label, secondaryLabel, leftDecoration: LeftDecComponent, minWidth, disabled } = plainItem;
|
28
|
+
const floatingContext = useFloatingContext({
|
29
|
+
placement: placementOrderPreference[0],
|
30
|
+
placementOrderPreference,
|
31
|
+
animationDuration: 100,
|
32
|
+
customOffset: [0, 0]
|
33
|
+
});
|
34
|
+
const {
|
35
|
+
refs: { setReference }
|
36
|
+
} = floatingContext;
|
37
|
+
const {
|
38
|
+
focusRegion,
|
39
|
+
propsWithDefault,
|
40
|
+
openedSubItems,
|
41
|
+
menuItemEventsHandlers: {
|
42
|
+
handleFocusableMenuItemKeyDown,
|
43
|
+
handleFocusableMenuItemClick,
|
44
|
+
handleFocusableMenuItemOnMouseEnter,
|
45
|
+
handleMenuItemFocusReconciliation
|
46
|
+
}
|
47
|
+
} = React2.useContext(MenuBehaviouralContextProviderContext);
|
48
|
+
const { selectedItems } = propsWithDefault;
|
49
|
+
const gridLayout = React2.useMemo(() => {
|
50
|
+
const cols = LeftDecComponent ? ["min-content", "min-content", "auto"] : ["min-content", "auto"];
|
51
|
+
if (secondaryLabel) cols.push("auto");
|
52
|
+
cols.push("min-content");
|
53
|
+
return cols;
|
54
|
+
}, [LeftDecComponent, secondaryLabel]);
|
55
|
+
const focusedRegionPerformanceHelper = React2.useRef(focusRegion);
|
56
|
+
focusedRegionPerformanceHelper.current = focusRegion;
|
57
|
+
const isExpanded = openedSubItems.some((itemWithOpenSubmenu) => itemWithOpenSubmenu.dsId === dsId);
|
58
|
+
const isFocused = focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId);
|
59
|
+
const isSelected = React2.useMemo(
|
60
|
+
() => getIsMultipleSelectNodeWithSubmenuSelected({ itemNode, selectedItems }),
|
61
|
+
[itemNode, selectedItems]
|
62
|
+
);
|
63
|
+
const handleFocusOnRender = React2.useCallback(
|
64
|
+
(node) => {
|
65
|
+
setReference(node);
|
66
|
+
if (node && focusRegion === MENU_FOCUS_REGIONS.ITEM_BY_DSID(dsId)) {
|
67
|
+
node.focus();
|
68
|
+
}
|
69
|
+
},
|
70
|
+
// we need to change the callback reference every time the focusRegion changes or else the focus will not be set
|
71
|
+
[dsId, focusRegion, setReference]
|
72
|
+
// we are using the "as='div'", typescript is not able to infer the correct type
|
73
|
+
// the logic here actually receives a ref to a HTMLDivElement,
|
74
|
+
// but the component must think this is a HTMLLIElement ref callback
|
75
|
+
);
|
76
|
+
const handleOnMouseEnter = React2.useCallback(
|
77
|
+
(e) => {
|
78
|
+
handleFocusableMenuItemOnMouseEnter(itemNode, e);
|
79
|
+
},
|
80
|
+
[handleFocusableMenuItemOnMouseEnter, itemNode]
|
81
|
+
);
|
82
|
+
const handleOnFocusReconciliation = React2.useCallback(() => {
|
83
|
+
handleMenuItemFocusReconciliation(itemNode);
|
84
|
+
}, [handleMenuItemFocusReconciliation, itemNode]);
|
85
|
+
const spacelessDsIdForDom = `ds-menu-item-${`${dsId}`.replace(/\s/g, "")}`;
|
86
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
87
|
+
/* @__PURE__ */ jsx(
|
88
|
+
StyledGlobalMenuItemWrapper,
|
89
|
+
{
|
90
|
+
innerRef: handleFocusOnRender,
|
91
|
+
onKeyDown: handleFocusableMenuItemKeyDown,
|
92
|
+
onClick: handleFocusableMenuItemClick,
|
93
|
+
onMouseEnter: handleOnMouseEnter,
|
94
|
+
onFocus: handleOnFocusReconciliation,
|
95
|
+
as: "div",
|
96
|
+
id: `${spacelessDsIdForDom}`,
|
97
|
+
tabIndex: isFocused ? 0 : -1,
|
98
|
+
role: "menuitemcheckbox",
|
99
|
+
"aria-checked": isSelected,
|
100
|
+
"aria-controls": (
|
101
|
+
/* ********************************************************************************************************************
|
102
|
+
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-controls
|
103
|
+
* The aria-controls only needs to be set when the popup is visible, but it is valid and easier to program to reference an element that is not visible.
|
104
|
+
* ********************************************************************************************************************
|
105
|
+
* ^^^ some automated tools will mark an error if the aria-controls references an element that does (yet) exist in the DOM
|
106
|
+
* so, while technically valid to not check if expanded, we are doing it to avoid automated tools marking an error
|
107
|
+
* ******************************************************************************************************************** */
|
108
|
+
isExpanded ? itemNode.plainChildren.map((child) => `ds-menu-item-${`${child.dsId}`.replace(/\s/g, "")}`).join(" ") : void 0
|
109
|
+
),
|
110
|
+
"aria-haspopup": "menu",
|
111
|
+
"aria-expanded": isExpanded,
|
112
|
+
"aria-disabled": disabled,
|
113
|
+
applyAriaDisabled: disabled,
|
114
|
+
children: /* @__PURE__ */ jsxs(
|
115
|
+
StyledContentWrapper,
|
116
|
+
{
|
117
|
+
cols: gridLayout,
|
118
|
+
minHeight: "16px",
|
119
|
+
gutter: "xxs",
|
120
|
+
alignItems: "center",
|
121
|
+
minWidth: minWidth ?? void 0,
|
122
|
+
children: [
|
123
|
+
/* @__PURE__ */ jsx(LeftBoxlessCheckbox, { isSelected }),
|
124
|
+
LeftDecComponent ? /* @__PURE__ */ jsx(LeftDecComponent, {}) : null,
|
125
|
+
/* @__PURE__ */ jsx(StyleMenuItemLabel, { children: label }),
|
126
|
+
secondaryLabel !== void 0 && /* @__PURE__ */ jsx(StyleMenuItemSecondaryLabel, { children: secondaryLabel }),
|
127
|
+
/* @__PURE__ */ jsx(ChevronSmallRight, {})
|
128
|
+
]
|
129
|
+
}
|
130
|
+
)
|
131
|
+
}
|
132
|
+
),
|
133
|
+
/* @__PURE__ */ jsx(
|
134
|
+
FlyoutMenuCircularDepInject,
|
135
|
+
{
|
136
|
+
isMenuOpen: isExpanded,
|
137
|
+
floatingContext: floatingContext.context,
|
138
|
+
floatingStyles: floatingContext.floatingStyles,
|
139
|
+
setFloatingRef: floatingContext.refs.setFloating,
|
140
|
+
itemNode
|
141
|
+
}
|
142
|
+
)
|
143
|
+
] });
|
144
|
+
};
|
145
|
+
export {
|
146
|
+
MultipleSelectWithSubmenuMenuItem
|
147
|
+
};
|
148
|
+
//# sourceMappingURL=MultipleSelectWithSubmenuMenuItem.js.map
|