@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,53 @@
|
|
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 react_desc_prop_types_exports = {};
|
30
|
+
__export(react_desc_prop_types_exports, {
|
31
|
+
DSOpinionatedButtonPropTypes: () => DSOpinionatedButtonPropTypes,
|
32
|
+
DSOpinionatedButtonPropTypesSchema: () => DSOpinionatedButtonPropTypesSchema,
|
33
|
+
defaultProps: () => defaultProps
|
34
|
+
});
|
35
|
+
module.exports = __toCommonJS(react_desc_prop_types_exports);
|
36
|
+
var React = __toESM(require("react"));
|
37
|
+
var import_ds_button_v2 = require("@elliemae/ds-button-v2");
|
38
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
39
|
+
var import_react_desc_prop_types = require("../../react-desc-prop-types.js");
|
40
|
+
var import_constants = require("./constants/index.js");
|
41
|
+
const defaultProps = {
|
42
|
+
...import_ds_button_v2.DSButtonV3DefaultProps
|
43
|
+
};
|
44
|
+
const DSOpinionatedButtonPropTypes = {
|
45
|
+
...(0, import_ds_props_helpers.getPropsPerSlotPropTypes)(import_constants.DSOpinionatedButtonName, import_constants.OPINIONATED_BUTTON_SLOTS),
|
46
|
+
...import_ds_button_v2.DSButtonV3PropTypes,
|
47
|
+
menuSpecificProps: import_ds_props_helpers.PropTypes.shape(import_react_desc_prop_types.DSMenuSpecificPropTypes).description("Props for the main flyout menu").isRequired,
|
48
|
+
innerRef: import_ds_props_helpers.PropTypes.func.description(
|
49
|
+
"Ref callback for the button, if not provided how is the flyout menu being positioned?"
|
50
|
+
).isRequired
|
51
|
+
};
|
52
|
+
const DSOpinionatedButtonPropTypesSchema = DSOpinionatedButtonPropTypes;
|
53
|
+
//# sourceMappingURL=react-desc-prop-types.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../src/parts/DSOpinionatedButton/react-desc-prop-types.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-empty-interface */\nimport React from 'react';\nimport { DSButtonV3DefaultProps, DSButtonV3PropTypes } from '@elliemae/ds-button-v2';\nimport type { DSPropTypesSchema, ValidationMap } from '@elliemae/ds-props-helpers';\nimport { getPropsPerSlotPropTypes, PropTypes } from '@elliemae/ds-props-helpers';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { type DSMenuButtonT, DSMenuSpecificPropTypes } from '../../react-desc-prop-types.js';\nimport { DSOpinionatedButtonName, OPINIONATED_BUTTON_SLOTS } from './constants/index.js';\n\nexport declare namespace DSOpinionatedButtonT {\n /*\n * everything that is specifically added in this namespace declaration and is not part of the original component\n * is because the original component is an \"opinionated widget\" that offloads a chunk of responsibilities from dev to dimsum\n * as such, the widget generates those interfaces,\n * but the app developer is not supposed to know about them\n * untill they go atomic composition (this namespace)\n */\n export interface RequiredProps extends DSMenuButtonT.ButtonInheritedRequiredProps {\n menuSpecificProps: DSMenuButtonT.MenuSpecificProps;\n }\n\n export interface DefaultProps extends DSMenuButtonT.ButtonInheiredDefaultProps {}\n\n export interface OptionalProps\n extends TypescriptHelpersT.PropsForGlobalOnSlots<typeof DSOpinionatedButtonName, typeof OPINIONATED_BUTTON_SLOTS>,\n DSMenuButtonT.ButtonInheritedOptionalProps {}\n\n export interface Props\n extends RequiredProps,\n Partial<DefaultProps>,\n OptionalProps,\n // this is where global/xstyled props are inherited from DSButtonV3\n DSMenuButtonT.ButtonInheritedProps {\n innerRef: React.RefCallback<HTMLButtonElement>;\n }\n\n export interface InternalProps\n extends RequiredProps,\n DefaultProps,\n OptionalProps,\n // this is where global/xstyled props are inherited from DSButtonV3\n DSMenuButtonT.ButtonInheritedInternalProps {\n innerRef: React.RefCallback<HTMLButtonElement>;\n }\n}\n\nexport const defaultProps: DSOpinionatedButtonT.DefaultProps = {\n ...DSButtonV3DefaultProps,\n};\n\nexport const DSOpinionatedButtonPropTypes: DSPropTypesSchema<DSOpinionatedButtonT.Props> = {\n ...getPropsPerSlotPropTypes(DSOpinionatedButtonName, OPINIONATED_BUTTON_SLOTS),\n ...DSButtonV3PropTypes,\n menuSpecificProps: PropTypes.shape(DSMenuSpecificPropTypes).description('Props for the main flyout menu').isRequired,\n innerRef: PropTypes.func.description(\n 'Ref callback for the button, if not provided how is the flyout menu being positioned?',\n ).isRequired,\n};\n\nexport const DSOpinionatedButtonPropTypesSchema =\n DSOpinionatedButtonPropTypes as unknown as ValidationMap<DSOpinionatedButtonT.Props>;\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,0BAA4D;AAE5D,8BAAoD;AAEpD,mCAA4D;AAC5D,uBAAkE;AAuC3D,MAAM,eAAkD;AAAA,EAC7D,GAAG;AACL;AAEO,MAAM,+BAA8E;AAAA,EACzF,OAAG,kDAAyB,0CAAyB,yCAAwB;AAAA,EAC7E,GAAG;AAAA,EACH,mBAAmB,kCAAU,MAAM,oDAAuB,EAAE,YAAY,gCAAgC,EAAE;AAAA,EAC1G,UAAU,kCAAU,KAAK;AAAA,IACvB;AAAA,EACF,EAAE;AACJ;AAEO,MAAM,qCACX;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -28,37 +28,73 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
29
|
var react_desc_prop_types_exports = {};
|
30
30
|
__export(react_desc_prop_types_exports, {
|
31
|
-
|
32
|
-
|
31
|
+
DSMenuButtonPropTypes: () => DSMenuButtonPropTypes,
|
32
|
+
DSMenuButtonPropTypesSchema: () => DSMenuButtonPropTypesSchema,
|
33
|
+
DSMenuSpecificPropTypes: () => DSMenuSpecificPropTypes,
|
34
|
+
MenuBehaviouralLayerPropTypes: () => MenuBehaviouralLayerPropTypes,
|
33
35
|
defaultProps: () => defaultProps
|
34
36
|
});
|
35
37
|
module.exports = __toCommonJS(react_desc_prop_types_exports);
|
36
38
|
var React = __toESM(require("react"));
|
37
39
|
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
40
|
+
var import_ds_button_v2 = require("@elliemae/ds-button-v2");
|
41
|
+
var import_constants = require("./constants/index.js");
|
38
42
|
const defaultProps = {
|
39
|
-
|
40
|
-
|
41
|
-
|
43
|
+
selectedOptions: {},
|
44
|
+
onClickOutside: () => null,
|
45
|
+
onOptionClick: () => null,
|
46
|
+
openedSubmenus: {},
|
47
|
+
onSubmenuToggle: () => null,
|
48
|
+
isLoading: false,
|
49
|
+
isSkeleton: false
|
50
|
+
};
|
51
|
+
const MenuBehaviouralLayerPropTypes = {
|
52
|
+
selectedItems: import_ds_props_helpers.PropTypes.arrayOf(import_ds_props_helpers.PropTypes.object).description(
|
53
|
+
"an array of tree-nodes that have to be marked as selected in the GUI"
|
54
|
+
).isRequired,
|
55
|
+
onItemSelected: import_ds_props_helpers.PropTypes.func.description("IoC function in charge of handling the selection of a menu item").signature(`((
|
56
|
+
newSelection: DSMenuButtonT.PseudoFocusableMenuNodes[],
|
57
|
+
metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event?: React.SyntheticEvent },
|
58
|
+
) => void)`).isRequired,
|
59
|
+
onActivateItem: import_ds_props_helpers.PropTypes.func.description(
|
60
|
+
"IoC function in charge of handling the activation (NOT INVOKED ON SELECTION) of a menu item"
|
61
|
+
).signature(`((
|
62
|
+
itemNode: DSMenuButtonT.PseudoFocusableMenuNodes,
|
63
|
+
metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event?: React.SyntheticEvent },
|
64
|
+
) => void)`).isRequired,
|
65
|
+
onOpen: import_ds_props_helpers.PropTypes.func.description("function triggered when the widget opens the menu").signature(`(()=>void)`),
|
66
|
+
onClose: import_ds_props_helpers.PropTypes.func.description("function triggered when the widget closes the menu").signature(`(()=>void)`),
|
67
|
+
onDisplayedSubmenuChange: import_ds_props_helpers.PropTypes.func.description("function triggered when the widget's closes or opens a submenu").signature(`((
|
68
|
+
newOpenedItems: DSMenuButtonT.PseudoFocusableMenuNodes[],
|
69
|
+
metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event?: React.SyntheticEvent },
|
70
|
+
) => void)`)
|
71
|
+
};
|
72
|
+
const DSMenuSpecificPropTypes = {
|
73
|
+
ItemRenderer: import_ds_props_helpers.PropTypes.node.description("Component to be used to render the items"),
|
74
|
+
onClickOutside: import_ds_props_helpers.PropTypes.func.description("Callback executed when you click outside the dropdown menu, or press the Esc key").defaultValue(() => null),
|
75
|
+
selectedOptions: import_ds_props_helpers.PropTypes.object.description(
|
76
|
+
"Object with the ids of the options as keys, and booleans as keys. Represents the state of the current selection in the dropdown menu"
|
77
|
+
).defaultValue({}),
|
78
|
+
onOptionClick: import_ds_props_helpers.PropTypes.func.description(
|
79
|
+
"Callback triggered when an item is clicked or pressed. We provide the next selected options, the clicked option and the event, in that order"
|
80
|
+
).defaultValue(() => null),
|
81
|
+
openedSubmenus: import_ds_props_helpers.PropTypes.object.description(
|
82
|
+
"Object with the ids of the submenus as keys, and booleans as keys. Represents the state of the current opened submenus"
|
83
|
+
).defaultValue({}),
|
84
|
+
onSubmenuToggle: import_ds_props_helpers.PropTypes.func.description("Callback triggered when a submenu is opened or closed.").signature(
|
85
|
+
"((nextOpenedSubmenus: Record<string, boolean>, submenu: Item, e: React.MouseEvent | React.KeyboardEvent) => void)"
|
86
|
+
).defaultValue(() => null),
|
87
|
+
isLoading: import_ds_props_helpers.PropTypes.bool.description("Whether the flyout menu should render the loading indicator").defaultValue(false),
|
88
|
+
isSkeleton: import_ds_props_helpers.PropTypes.bool.description("Whether the flyout menu should render the skeleton").defaultValue(false)
|
42
89
|
};
|
43
|
-
const
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
})
|
52
|
-
).description("Array of items to be displayed in the dropdown").isRequired,
|
53
|
-
TriggerElement: import_ds_props_helpers.PropTypes.node.description("Component to be used as the trigger element").isRequired,
|
54
|
-
selectedKeys: import_ds_props_helpers.PropTypes.arrayOf(import_ds_props_helpers.PropTypes.string).description("Array of selected keys"),
|
55
|
-
onSelectionChange: import_ds_props_helpers.PropTypes.func.description("Function to be called when selection changes"),
|
56
|
-
triggerElementProps: import_ds_props_helpers.PropTypes.object.description("Props to be passed to the trigger element"),
|
57
|
-
selectionMode: import_ds_props_helpers.PropTypes.oneOf(["single", "multiple"]).description("Selection mode"),
|
58
|
-
menuMinWidth: import_ds_props_helpers.PropTypes.oneOfType([import_ds_props_helpers.PropTypes.string, import_ds_props_helpers.PropTypes.number]).description(
|
59
|
-
"Minimum width of the main dropdown"
|
60
|
-
),
|
61
|
-
ItemRenderer: import_ds_props_helpers.PropTypes.node.description("Component to be used to render the items")
|
90
|
+
const DSMenuButtonPropTypes = {
|
91
|
+
options: import_ds_props_helpers.PropTypes.oneOfType([import_ds_props_helpers.PropTypes.array, import_ds_props_helpers.PropTypes.object]).description(
|
92
|
+
"Array of options to display in the menu or a DSTree node to build branches from"
|
93
|
+
).isRequired,
|
94
|
+
...import_ds_button_v2.DSButtonV3PropTypes,
|
95
|
+
...MenuBehaviouralLayerPropTypes,
|
96
|
+
...DSMenuSpecificPropTypes,
|
97
|
+
...(0, import_ds_props_helpers.getPropsPerSlotPropTypes)(import_constants.DSMenuButtonName, import_constants.MENU_BUTTON_SLOTS)
|
62
98
|
};
|
63
|
-
const
|
99
|
+
const DSMenuButtonPropTypesSchema = DSMenuButtonPropTypes;
|
64
100
|
//# sourceMappingURL=react-desc-prop-types.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/react-desc-prop-types.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type { GlobalAttributesT, XstyledProps, DSPropTypesSchema } from '@elliemae/ds-props-helpers';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport type { WeakValidationMap } from 'react';\n\nexport declare namespace MenuButtonT {\n export interface RequiredProps<T> {\n items: Item[];\n TriggerElement: React.ComponentType<TriggerElementProps<T>>;\n }\n\n export interface DefaultProps {\n selectedKeys: string[];\n onSelectionChange: (selectedKeys: string[], parentId: string, item: MenuButtonT.Item) => void;\n }\n\n export interface OptionalProps<T extends object> {\n triggerElementProps?: T;\n selectionMode?: 'single' | 'multiple';\n menuMinWidth?: string | number;\n ItemRenderer?: ItemRendererT;\n }\n\n export interface Props<T extends object = object>\n extends Partial<DefaultProps>,\n OptionalProps<T>,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof OptionalProps<T> | keyof XstyledProps>,\n XstyledProps,\n RequiredProps<T> {}\n\n export interface InternalProps<T extends object = object>\n extends DefaultProps,\n OptionalProps<T>,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof OptionalProps<T> | keyof XstyledProps>,\n XstyledProps,\n RequiredProps<T> {}\n\n export type Item = {\n dsId: string;\n label: string;\n type?: 'separator' | 'section';\n childrens?: Item[];\n subitems?: Item[];\n selectionMode?: 'single' | 'multiple';\n minWidth?: string | number;\n disabled?: boolean;\n };\n\n export interface TriggerElementProps<T2> {\n isOpen: boolean;\n innerRef: TypescriptHelpersT.AnyRef<HTMLButtonElement | null>;\n setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;\n attributes: {\n 'aria-haspopup'?: boolean | 'true' | 'false' | 'dialog' | 'grid' | 'listbox' | 'menu' | 'tree';\n 'aria-expanded': boolean;\n };\n listeners: {\n onKeyDown: (e: React.KeyboardEvent) => void;\n };\n triggerElementProps: T2;\n }\n\n export type ItemRendererT = React.ComponentType<{ item: Item; isSelected: boolean }>;\n}\n\nexport const defaultProps: MenuButtonT.DefaultProps = {\n selectedKeys: [],\n onSelectionChange: () => {},\n};\n\nexport const DSDMenuButtonPropTypes: DSPropTypesSchema<MenuButtonT.Props<object>> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n items: PropTypes.arrayOf(\n PropTypes.shape({\n dsId: PropTypes.string.isRequired,\n label: PropTypes.string,\n type: PropTypes.oneOf(['separator', 'section', 'single', 'multiple', undefined]),\n }),\n ).description('Array of items to be displayed in the dropdown').isRequired,\n TriggerElement: PropTypes.node.description('Component to be used as the trigger element').isRequired,\n selectedKeys: PropTypes.arrayOf(PropTypes.string).description('Array of selected keys'),\n onSelectionChange: PropTypes.func.description('Function to be called when selection changes'),\n triggerElementProps: PropTypes.object.description('Props to be passed to the trigger element'),\n selectionMode: PropTypes.oneOf(['single', 'multiple']).description('Selection mode'),\n menuMinWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(\n 'Minimum width of the main dropdown',\n ),\n ItemRenderer: PropTypes.node.description('Component to be used to render the items'),\n};\n\nexport const DSDMenuButtonPropTypesSchema = DSDMenuButtonPropTypes as unknown as WeakValidationMap<\n MenuButtonT.Props<object>\n>;\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport { PropTypes, getPropsPerSlotPropTypes } from '@elliemae/ds-props-helpers';\nimport { DSButtonV3PropTypes } from '@elliemae/ds-button-v2';\nimport type { DSPropTypesSchema, ValidationMap } from '@elliemae/ds-props-helpers';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport type { DSButtonV3T } from '@elliemae/ds-button-v2';\nimport type { UseDSTreeT } from '@elliemae/ds-tree-model';\n\nimport { DSMenuButtonName, MENU_BUTTON_SLOTS, type MENU_ITEMS_TYPES } from './constants/index.js';\nexport declare namespace DSMenuButtonT {\n /* *******************************************************\n * YURI's NOTE:\n *\n * This polymorphic interface \"looks similar\" between the diffent types\n * but it's actually different upon closer inspection\n *\n * If you are smarter then me, you can probably find a way to make this more DRY\n * but I prefeer AHA (Avoid Hasty Abstractions) that gives me an easier to mantain code\n * ESPECIALLY when the types are so similar but not the same & in typescript (polymorphism is hard in TS)\n *\n * So I'm going to keep them separate and explicit\n * key difference is what's required to exist and what is required to explicitly NOT exist\n *\n * If someone's review this and make this DRY, I'm NOT going to mantain this code moving forward\n * whoever makes this TS DRY will be responsible for it and own it.\n ******************************************************* */\n export interface RootItem extends UseDSTreeT.AnyObjectWithoutReservedKeys {\n type: 'ROOT_ITEM'; // HARDCODED BECAUSE THIS IS NOT A MENU ITEM, IT'S EXCLUSIVE TO THE ROOT NODE\n dsId: string;\n label?: undefined;\n secondaryLabel?: undefined;\n leftDecoration?: undefined;\n minWidth?: undefined;\n disabled?: undefined;\n onClick?: undefined;\n onKeyDown?: undefined;\n }\n export interface SeparatorItem extends UseDSTreeT.AnyObjectWithoutReservedKeys {\n type: (typeof MENU_ITEMS_TYPES)['SEPARATOR'];\n dsId: string;\n label?: undefined;\n secondaryLabel?: undefined;\n leftDecoration?: undefined;\n minWidth?: undefined;\n disabled?: undefined;\n onClick?: undefined;\n onKeyDown?: undefined;\n }\n export interface ActivableItem extends UseDSTreeT.AnyObjectWithoutReservedKeys {\n type: (typeof MENU_ITEMS_TYPES)['ACTIVABLE_ITEM'];\n dsId: string;\n label: string;\n secondaryLabel?: string;\n leftDecoration?: React.ComponentType;\n minWidth?: string | number;\n disabled?: boolean;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => null;\n }\n export interface ActionableWithSubmenuItem extends UseDSTreeT.AnyObjectWithoutReservedKeys {\n type: (typeof MENU_ITEMS_TYPES)['ACTIVABLE_WITH_SUBMENU_ITEM'];\n dsId: string;\n label: string;\n secondaryLabel?: string;\n leftDecoration?: React.ComponentType;\n minWidth?: string | number;\n disabled?: boolean;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => null;\n }\n export interface SkeletonItem extends UseDSTreeT.AnyObjectWithoutReservedKeys {\n type: (typeof MENU_ITEMS_TYPES)['SKELETON_ITEM'];\n dsId: string;\n minWidth?: string | number;\n label?: undefined;\n secondaryLabel?: undefined;\n leftDecoration?: undefined;\n disabled?: undefined;\n onClick?: undefined;\n onKeyDown?: undefined;\n }\n export interface MultipleSelectItem extends UseDSTreeT.AnyObjectWithoutReservedKeys {\n type: (typeof MENU_ITEMS_TYPES)['MULTIPLE_SELECT_ITEM'];\n dsId: string;\n label: string;\n secondaryLabel?: string;\n leftDecoration?: React.ComponentType;\n minWidth?: string | number;\n disabled?: boolean;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => null;\n }\n\n export interface MultiSelectWithSubmenuItem extends UseDSTreeT.AnyObjectWithoutReservedKeys {\n type: (typeof MENU_ITEMS_TYPES)['MULTIPLE_SELECT_WITH_SUBMENU_ITEM'];\n dsId: string;\n label: string;\n secondaryLabel?: string;\n leftDecoration?: React.ComponentType;\n minWidth?: string | number;\n disabled?: boolean;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => null;\n }\n export interface WithSubmenuItem extends UseDSTreeT.AnyObjectWithoutReservedKeys {\n type: (typeof MENU_ITEMS_TYPES)['WITH_SUBMENU_ITEM'];\n dsId: string;\n label: string;\n secondaryLabel?: string;\n leftDecoration?: React.ComponentType;\n minWidth?: string | number;\n disabled?: boolean;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => null;\n }\n\n /* ***********************************************************************\n * Single select items MUST always have a \"group\" as parent\n * Failing the condition fails ADA announcements (role='group' -> role='menuitemradio')\n *********************************************************************** */\n export interface SingleSelectItem extends UseDSTreeT.AnyObjectWithoutReservedKeys {\n type: (typeof MENU_ITEMS_TYPES)['SINGLE_SELECT_ITEM'];\n dsId: string;\n label: string;\n secondaryLabel?: string;\n leftDecoration?: React.ComponentType;\n minWidth?: string | number;\n disabled?: boolean;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => null;\n }\n export interface SingleSelectWithSubmenuItem extends UseDSTreeT.AnyObjectWithoutReservedKeys {\n type: (typeof MENU_ITEMS_TYPES)['SINGLE_SELECT_WITH_SUBMENU_ITEM'];\n dsId: string;\n label: string;\n secondaryLabel?: string;\n leftDecoration?: React.ComponentType;\n minWidth?: string | number;\n disabled?: boolean;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => null;\n }\n\n export interface GroupItem extends UseDSTreeT.AnyObjectWithoutReservedKeys {\n type: (typeof MENU_ITEMS_TYPES)['GROUP'];\n dsId: string;\n label?: string; // if present, add a title to the group\n leftDecoration?: React.ComponentType; // if present, a label must also be present\n minWidth?: string | number;\n }\n\n export type MenuItemInterface =\n | SeparatorItem\n | ActivableItem\n | ActionableWithSubmenuItem\n | SkeletonItem\n | MultipleSelectItem\n | MultiSelectWithSubmenuItem\n | WithSubmenuItem\n | GroupItem;\n\n export type PseudoFocusableItemInterface =\n | ActivableItem\n | ActionableWithSubmenuItem\n | SkeletonItem\n | MultipleSelectItem\n | MultiSelectWithSubmenuItem\n | WithSubmenuItem\n | SingleSelectItem\n | SingleSelectWithSubmenuItem;\n\n // Define MenuNode types directly\n export type MenuNodeRootItem = UseDSTreeT.TreeNode<RootItem>; // MenuNodesAllowedToHaveChildren is the only expected reference to this type\n export type MenuNodeSeparatorItem = UseDSTreeT.TreeNode<SeparatorItem>;\n export type MenuNodeActivableItem = UseDSTreeT.TreeNode<ActivableItem>;\n export type MenuNodeActivableWithSubmenuItem = UseDSTreeT.TreeNode<ActionableWithSubmenuItem>;\n export type MenuNodeSkeletonItem = UseDSTreeT.TreeNode<SkeletonItem>;\n export type MenuNodeMultipleSelectItem = UseDSTreeT.TreeNode<MultipleSelectItem>;\n export type MenuNodeMultipleSelectWithSubmenuItem = UseDSTreeT.TreeNode<MultiSelectWithSubmenuItem>;\n export type MenuNodeWithSubmenuItem = UseDSTreeT.TreeNode<WithSubmenuItem>;\n export type MenuNodeSingleSelectItem = UseDSTreeT.TreeNode<SingleSelectItem>;\n export type MenuNodeSingleSelectWithSubmenuItem = UseDSTreeT.TreeNode<SingleSelectWithSubmenuItem>;\n export type MenuNodeGroupItem = UseDSTreeT.TreeNode<GroupItem>;\n\n // in the future we want to better describe the polymorphic nature of the MenuNode\n // having each type be able to have it's own \"subitems\" type that isn't necessarily the same as the parent\n // but currenctly the DS tree model typescript definitions don't support this\n // will be addresssed via PUI-XXXX\n export type MenuNode =\n // DO NOT ADD MenuNodeRootItem HERE, WILL BREAK THE SUBTREES\n | MenuNodeSeparatorItem\n | MenuNodeActivableItem\n | MenuNodeActivableWithSubmenuItem\n | MenuNodeSkeletonItem\n | MenuNodeMultipleSelectItem\n | MenuNodeMultipleSelectWithSubmenuItem\n | MenuNodeWithSubmenuItem\n | MenuNodeSingleSelectItem\n | MenuNodeSingleSelectWithSubmenuItem\n | MenuNodeGroupItem;\n\n export type PseudoFocusableMenuNodes =\n | MenuNodeActivableItem\n | MenuNodeActivableWithSubmenuItem\n | MenuNodeSkeletonItem\n | MenuNodeSingleSelectItem\n | MenuNodeMultipleSelectItem\n | MenuNodeMultipleSelectWithSubmenuItem\n | MenuNodeWithSubmenuItem\n | MenuNodeSingleSelectWithSubmenuItem;\n\n export type MenuNodesAllowedToHaveChildren =\n | MenuNodeRootItem\n | MenuNodeWithSubmenuItem\n | MenuNodeGroupItem\n | MenuNodeActivableWithSubmenuItem\n | MenuNodeMultipleSelectWithSubmenuItem\n | MenuNodeSingleSelectWithSubmenuItem;\n\n export type ItemRendererT = React.ComponentType<{ itemNode: MenuNode }>;\n\n export type SelectionableMenuNodes =\n | DSMenuButtonT.MenuNodeMultipleSelectItem\n | DSMenuButtonT.MenuNodeMultipleSelectWithSubmenuItem\n | DSMenuButtonT.MenuNodeSingleSelectItem\n | DSMenuButtonT.MenuNodeSingleSelectWithSubmenuItem;\n\n export type MultipleSelectionableMenuNodes =\n | DSMenuButtonT.MenuNodeMultipleSelectItem\n | DSMenuButtonT.MenuNodeMultipleSelectWithSubmenuItem;\n\n export type SingleSelectionableMenuNodes =\n | DSMenuButtonT.MenuNodeSingleSelectItem\n | DSMenuButtonT.MenuNodeSingleSelectWithSubmenuItem;\n\n export type WithSubmenuMenuNodes =\n | DSMenuButtonT.MenuNodeWithSubmenuItem\n | DSMenuButtonT.MenuNodeActivableWithSubmenuItem\n | DSMenuButtonT.MenuNodeMultipleSelectWithSubmenuItem\n | DSMenuButtonT.MenuNodeSingleSelectWithSubmenuItem;\n\n export type SelectionablesWithSubmenuMenuNodes =\n | DSMenuButtonT.MenuNodeMultipleSelectWithSubmenuItem\n | DSMenuButtonT.MenuNodeSingleSelectWithSubmenuItem;\n /* *******************************************************\n * From official source definition\n *\n * Menu Button Pattern\n * About This Pattern:\n * A menu button is a button\n * that opens a menu\n * (as described in the Menu and Menubar Pattern).\n *\n * Since the menu button is a button, it inherits all the props from the Button component.\n * Since the menu button MUST have a menu, it also have a set of specific props used to handle the menu.\n * Because we build with atomic composition in mind, the \"logic layer\" is separated and has a yet another set of props.\n *\n * This is effectively an OOP \"extension\" of the Button component,\n * so it has the same props,\n * BUT also a few more to handle the specific behavior of the menu.\n ******************************************************* */\n\n export interface MenuBehaviouralLayerRequiredProps {\n selectedItems: SelectionableMenuNodes[];\n onItemSelected: (\n newSelection: SelectionableMenuNodes[],\n metainfo: { itemNode: DSMenuButtonT.SelectionableMenuNodes; event?: React.SyntheticEvent },\n ) => void | TypescriptHelpersT.StateSetter<DSMenuButtonT.SelectionableMenuNodes[]>;\n onActivateItem: (\n itemNode: DSMenuButtonT.PseudoFocusableMenuNodes,\n metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event?: React.SyntheticEvent },\n ) => void;\n }\n\n export interface MenuSpecificRequiredProps {}\n /* *******************************************************\n * Required Props + Inherited Required Props\n * - We inherit the required props from the button\n * - We add the required props for the menu\n *\n * - if a collision occurs, the menu specific are meant to be the most important and specific ones\n ******************************************************* */\n export interface ButtonInheritedRequiredProps\n // by using Omit, we remove the keys that are present in the MenuSpecificRequiredProps to ensure collision are handled as expected\n extends Omit<DSButtonV3T.RequiredProps, keyof MenuSpecificRequiredProps> {}\n // the final RequiredProps will be the combination of the two with proper collision handling\n export interface RequiredProps\n extends MenuSpecificRequiredProps,\n ButtonInheritedRequiredProps,\n MenuBehaviouralLayerRequiredProps {\n // it's the Menu Widget sole responsibility to receive the options and convert them to a tree\n options: MenuItemInterface[] | MenuNode;\n }\n\n /* *******************************************************\n * Since the menu button is a button, it inherits all the props from the Button component.\n * Since the menu button MUST have a menu, it also have a set of specific props used to handle the menu.\n * Because we build with atomic composition in mind, the \"logic layer\" is separated and has a yet another set of props.\n ******************************************************* */\n export interface MenuBehaviouralLayerDefaultProps {}\n export interface MenuSpecifiDefaultProps {\n onClickOutside: (e: MouseEvent | React.KeyboardEvent | TouchEvent) => void;\n onOptionClick: (\n nextSelectedOptions: Record<string, boolean>,\n clickedOption: MenuItemInterface,\n e: React.MouseEvent | React.KeyboardEvent,\n ) => void;\n openedSubmenus: Record<string, boolean>;\n onSubmenuToggle: (\n nextOpenedSubmenus: Record<string, boolean>,\n submenu: MenuItemInterface,\n e: React.MouseEvent | React.KeyboardEvent,\n ) => void;\n isLoading: boolean;\n isSkeleton: boolean;\n selectedOptions: Record<string, boolean>;\n }\n\n /* *******************************************************\n * Default Props + Inherited Default Props\n * - We inherit the default props from the button\n * - We add the default props for the menu\n *\n * - if a collision occurs, the menu specific are meant to be the most important and specific ones\n ******************************************************* */\n // by using Omit, we remove the keys that are present in the MenuSpecificDefaultProps to ensure collision are handled as expected\n export interface ButtonInheiredDefaultProps extends Omit<DSButtonV3T.DefaultProps, keyof MenuSpecifiDefaultProps> {}\n // the final DefaultProps will be the combination of the two with proper collision handling\n export interface DefaultProps\n extends MenuSpecifiDefaultProps,\n ButtonInheiredDefaultProps,\n MenuBehaviouralLayerDefaultProps {}\n\n /* *******************************************************\n * Since the menu button is a button, it inherits all the props from the Button component.\n * Since the menu button MUST have a menu, it also have a set of specific props used to handle the menu.\n * Because we build with atomic composition in mind, the \"logic layer\" is separated and has a yet another set of props.\n ******************************************************* */\n export interface MenuBehaviouralLayerOptionalProps {\n onOpen?: () => void;\n onClose?: () => void;\n onDisplayedSubmenuChange?: (\n newOpenedItems: DSMenuButtonT.WithSubmenuMenuNodes[],\n metainfo: {\n itemNode: DSMenuButtonT.PseudoFocusableMenuNodes | null;\n event?: React.SyntheticEvent | FocusEvent | TouchEvent;\n },\n ) => void | TypescriptHelpersT.StateSetter<DSMenuButtonT.WithSubmenuMenuNodes[]>;\n }\n export interface MenuSpecificOptionalProps {\n ItemRenderer?: ItemRendererT;\n }\n /* *******************************************************\n * Optional Props + Inherited Optional Props\n * - We inherit the optional props from the button\n * - We add the optional props for the menu\n *\n * - if a collision occurs, the menu specific are meant to be the most important and specific ones\n ******************************************************* */\n export interface ButtonInheritedOptionalProps\n // by using Omit, we remove the keys that are present in the MenuSpecificOptionalProps to ensure collision are handled as expected\n extends Omit<DSButtonV3T.OptionalProps, keyof MenuSpecificOptionalProps> {}\n export interface OptionalProps\n extends MenuSpecificOptionalProps,\n ButtonInheritedOptionalProps,\n MenuBehaviouralLayerOptionalProps,\n TypescriptHelpersT.PropsForGlobalOnSlots<typeof DSMenuButtonName, typeof MENU_BUTTON_SLOTS> {}\n\n /* *******************************************************\n * Since the menu button is a button, it inherits all the props from the Button component.\n * Since the menu button MUST have a menu, it also have a set of specific props used to handle the menu.\n * Because we build with atomic composition in mind, the \"logic layer\" is separated and has a yet another set of props.\n ******************************************************* */\n export interface MenuBehaviouralLayerProps\n extends Partial<MenuBehaviouralLayerDefaultProps>,\n MenuBehaviouralLayerOptionalProps,\n MenuBehaviouralLayerRequiredProps {}\n export interface MenuSpecificProps\n extends Partial<MenuSpecifiDefaultProps>,\n MenuSpecificOptionalProps,\n MenuSpecificRequiredProps {}\n /* *******************************************************\n * Props + Inherited Props\n * - We inherit the props from the button\n * - We add the props for the menu\n *\n * - if a collision occurs, the menu specific are meant to be the most important and specific ones\n ******************************************************* */\n // by using Omit, we remove the keys that are present in the MenuSpecificProps to ensure collision are handled as expected\n // THIS IS ALSO INHERITING THE GLOBAL ATTRIBUTES & XSTYLED PROPS FROM THE BUTTON!!!\n export interface ButtonInheritedProps extends Omit<DSButtonV3T.Props, keyof MenuSpecificProps> {}\n\n export interface Props extends RequiredProps, Partial<DefaultProps>, OptionalProps {}\n\n /* *******************************************************\n * Since the menu button is a button, it inherits all the props from the Button component.\n * Since the menu button MUST have a menu, it also have a set of specific props used to handle the menu.\n * Because we build with atomic composition in mind, the \"logic layer\" is separated and has a yet another set of props.\n ******************************************************* */\n export interface MenuBehaviouralLayerInternalProps\n extends MenuBehaviouralLayerDefaultProps,\n MenuBehaviouralLayerOptionalProps,\n MenuBehaviouralLayerRequiredProps {}\n export interface MenuSpecificInternalProps\n extends MenuSpecifiDefaultProps,\n MenuSpecificOptionalProps,\n MenuSpecificRequiredProps {}\n\n /* *******************************************************\n * Internal Props\n * - We inherit the internal props from the button\n * - We add the internal props for the menu\n *\n * - if a collision occurs, the menu specific are meant to be the most important and specific ones\n ******************************************************* */\n export interface ButtonInheritedInternalProps\n // by using Omit, we remove the keys that are present in the MenuSpecificInternalProps to ensure collision are handled as expected\n // THIS IS ALSO INHERITING THE GLOBAL ATTRIBUTES & XSTYLED PROPS FROM THE BUTTON!!!\n extends Omit<DSButtonV3T.InternalProps, keyof MenuSpecificInternalProps> {}\n export interface InternalProps extends RequiredProps, DefaultProps, OptionalProps {}\n}\n\nexport const defaultProps: DSMenuButtonT.MenuSpecifiDefaultProps = {\n selectedOptions: {},\n onClickOutside: () => null,\n onOptionClick: () => null,\n openedSubmenus: {},\n onSubmenuToggle: () => null,\n isLoading: false,\n isSkeleton: false,\n};\n\nexport const MenuBehaviouralLayerPropTypes: DSPropTypesSchema<DSMenuButtonT.MenuBehaviouralLayerProps> = {\n selectedItems: PropTypes.arrayOf(PropTypes.object).description(\n 'an array of tree-nodes that have to be marked as selected in the GUI',\n ).isRequired,\n\n onItemSelected: PropTypes.func.description('IoC function in charge of handling the selection of a menu item')\n .signature(`((\n newSelection: DSMenuButtonT.PseudoFocusableMenuNodes[],\n metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event?: React.SyntheticEvent },\n ) => void)`).isRequired,\n onActivateItem: PropTypes.func.description(\n 'IoC function in charge of handling the activation (NOT INVOKED ON SELECTION) of a menu item',\n ).signature(`((\n itemNode: DSMenuButtonT.PseudoFocusableMenuNodes,\n metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event?: React.SyntheticEvent },\n ) => void)`).isRequired,\n onOpen: PropTypes.func.description('function triggered when the widget opens the menu').signature(`(()=>void)`),\n onClose: PropTypes.func.description('function triggered when the widget closes the menu').signature(`(()=>void)`),\n onDisplayedSubmenuChange: PropTypes.func.description(\"function triggered when the widget's closes or opens a submenu\")\n .signature(`((\n newOpenedItems: DSMenuButtonT.PseudoFocusableMenuNodes[],\n metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event?: React.SyntheticEvent },\n ) => void)`),\n};\n\nexport const DSMenuSpecificPropTypes: DSPropTypesSchema<DSMenuButtonT.MenuSpecificProps> = {\n ItemRenderer: PropTypes.node.description('Component to be used to render the items'),\n onClickOutside: PropTypes.func\n .description('Callback executed when you click outside the dropdown menu, or press the Esc key')\n .defaultValue(() => null),\n selectedOptions: PropTypes.object\n .description(\n 'Object with the ids of the options as keys, and booleans as keys. Represents the state of the current selection in the dropdown menu',\n )\n .defaultValue({}),\n onOptionClick: PropTypes.func\n .description(\n 'Callback triggered when an item is clicked or pressed. We provide the next selected options, the clicked option and the event, in that order',\n )\n .defaultValue(() => null),\n openedSubmenus: PropTypes.object\n .description(\n 'Object with the ids of the submenus as keys, and booleans as keys. Represents the state of the current opened submenus',\n )\n .defaultValue({}),\n onSubmenuToggle: PropTypes.func\n .description('Callback triggered when a submenu is opened or closed.')\n .signature(\n '((nextOpenedSubmenus: Record<string, boolean>, submenu: Item, e: React.MouseEvent | React.KeyboardEvent) => void)',\n )\n .defaultValue(() => null),\n isLoading: PropTypes.bool\n .description('Whether the flyout menu should render the loading indicator')\n .defaultValue(false),\n isSkeleton: PropTypes.bool.description('Whether the flyout menu should render the skeleton').defaultValue(false),\n};\n\nexport const DSMenuButtonPropTypes: DSPropTypesSchema<DSMenuButtonT.Props> = {\n options: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).description(\n 'Array of options to display in the menu or a DSTree node to build branches from',\n ).isRequired,\n ...DSButtonV3PropTypes,\n ...MenuBehaviouralLayerPropTypes,\n ...DSMenuSpecificPropTypes,\n ...getPropsPerSlotPropTypes(DSMenuButtonName, MENU_BUTTON_SLOTS),\n};\n\nexport const DSMenuButtonPropTypesSchema = DSMenuButtonPropTypes as unknown as ValidationMap<DSMenuButtonT.Props>;\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,8BAAoD;AACpD,0BAAoC;AAMpC,uBAA2E;AA8ZpE,MAAM,eAAsD;AAAA,EACjE,iBAAiB,CAAC;AAAA,EAClB,gBAAgB,MAAM;AAAA,EACtB,eAAe,MAAM;AAAA,EACrB,gBAAgB,CAAC;AAAA,EACjB,iBAAiB,MAAM;AAAA,EACvB,WAAW;AAAA,EACX,YAAY;AACd;AAEO,MAAM,gCAA4F;AAAA,EACvG,eAAe,kCAAU,QAAQ,kCAAU,MAAM,EAAE;AAAA,IACjD;AAAA,EACF,EAAE;AAAA,EAEF,gBAAgB,kCAAU,KAAK,YAAY,iEAAiE,EACzG,UAAU;AAAA;AAAA;AAAA,eAGA,EAAE;AAAA,EACf,gBAAgB,kCAAU,KAAK;AAAA,IAC7B;AAAA,EACF,EAAE,UAAU;AAAA;AAAA;AAAA,eAGC,EAAE;AAAA,EACf,QAAQ,kCAAU,KAAK,YAAY,mDAAmD,EAAE,UAAU,YAAY;AAAA,EAC9G,SAAS,kCAAU,KAAK,YAAY,oDAAoD,EAAE,UAAU,YAAY;AAAA,EAChH,0BAA0B,kCAAU,KAAK,YAAY,gEAAgE,EAClH,UAAU;AAAA;AAAA;AAAA,eAGA;AACf;AAEO,MAAM,0BAA8E;AAAA,EACzF,cAAc,kCAAU,KAAK,YAAY,0CAA0C;AAAA,EACnF,gBAAgB,kCAAU,KACvB,YAAY,kFAAkF,EAC9F,aAAa,MAAM,IAAI;AAAA,EAC1B,iBAAiB,kCAAU,OACxB;AAAA,IACC;AAAA,EACF,EACC,aAAa,CAAC,CAAC;AAAA,EAClB,eAAe,kCAAU,KACtB;AAAA,IACC;AAAA,EACF,EACC,aAAa,MAAM,IAAI;AAAA,EAC1B,gBAAgB,kCAAU,OACvB;AAAA,IACC;AAAA,EACF,EACC,aAAa,CAAC,CAAC;AAAA,EAClB,iBAAiB,kCAAU,KACxB,YAAY,wDAAwD,EACpE;AAAA,IACC;AAAA,EACF,EACC,aAAa,MAAM,IAAI;AAAA,EAC1B,WAAW,kCAAU,KAClB,YAAY,6DAA6D,EACzE,aAAa,KAAK;AAAA,EACrB,YAAY,kCAAU,KAAK,YAAY,oDAAoD,EAAE,aAAa,KAAK;AACjH;AAEO,MAAM,wBAAgE;AAAA,EAC3E,SAAS,kCAAU,UAAU,CAAC,kCAAU,OAAO,kCAAU,MAAM,CAAC,EAAE;AAAA,IAChE;AAAA,EACF,EAAE;AAAA,EACF,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,OAAG,kDAAyB,mCAAkB,kCAAiB;AACjE;AAEO,MAAM,8BAA8B;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -0,0 +1,123 @@
|
|
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 nodesTypeguardsAndGetters_exports = {};
|
30
|
+
__export(nodesTypeguardsAndGetters_exports, {
|
31
|
+
getFocusableNodes: () => getFocusableNodes,
|
32
|
+
getSelectionableNodes: () => getSelectionableNodes,
|
33
|
+
getWithSubmenuNodes: () => getWithSubmenuNodes,
|
34
|
+
isActivableNode: () => isActivableNode,
|
35
|
+
isActivableWithSubmenuNode: () => isActivableWithSubmenuNode,
|
36
|
+
isFocusableNode: () => isFocusableNode,
|
37
|
+
isGroup: () => isGroup,
|
38
|
+
isMenuNodeAllowedToHaveChildren: () => isMenuNodeAllowedToHaveChildren,
|
39
|
+
isMultipleSelectNode: () => isMultipleSelectNode,
|
40
|
+
isMultipleSelectOnlyNode: () => isMultipleSelectOnlyNode,
|
41
|
+
isMultipleSelectWithSubmenuNode: () => isMultipleSelectWithSubmenuNode,
|
42
|
+
isRootNode: () => isRootNode,
|
43
|
+
isSelectionableNode: () => isSelectionableNode,
|
44
|
+
isSelectionableWithSubmenuNode: () => isSelectionableWithSubmenuNode,
|
45
|
+
isSeparatorNode: () => isSeparatorNode,
|
46
|
+
isSingleSelectNode: () => isSingleSelectNode,
|
47
|
+
isSingleSelectNodeWithSubmenu: () => isSingleSelectNodeWithSubmenu,
|
48
|
+
isSingleSelectOnlyNode: () => isSingleSelectOnlyNode,
|
49
|
+
isSkeletonNode: () => isSkeletonNode,
|
50
|
+
isWithSubmenuNode: () => isWithSubmenuNode,
|
51
|
+
isWithSubmenuOnlyNode: () => isWithSubmenuOnlyNode
|
52
|
+
});
|
53
|
+
module.exports = __toCommonJS(nodesTypeguardsAndGetters_exports);
|
54
|
+
var React = __toESM(require("react"));
|
55
|
+
var import_constants = require("../constants/index.js");
|
56
|
+
const isActivableNode = (item) => {
|
57
|
+
const node = item;
|
58
|
+
return typeof item === "object" && item !== null && typeof node.plainItem === "object" && node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.ACTIVABLE_ITEM;
|
59
|
+
};
|
60
|
+
const isActivableWithSubmenuNode = (item) => {
|
61
|
+
const node = item;
|
62
|
+
return typeof item === "object" && item !== null && typeof node.plainItem === "object" && node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.ACTIVABLE_WITH_SUBMENU_ITEM;
|
63
|
+
};
|
64
|
+
const isSkeletonNode = (item) => {
|
65
|
+
const node = item;
|
66
|
+
return typeof item === "object" && item !== null && typeof node.plainItem === "object" && node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.SKELETON_ITEM;
|
67
|
+
};
|
68
|
+
const isMultipleSelectOnlyNode = (item) => {
|
69
|
+
const node = item;
|
70
|
+
return typeof item === "object" && item !== null && typeof node.plainItem === "object" && node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.MULTIPLE_SELECT_ITEM;
|
71
|
+
};
|
72
|
+
const isMultipleSelectWithSubmenuNode = (item) => {
|
73
|
+
const node = item;
|
74
|
+
return typeof item === "object" && item !== null && typeof node.plainItem === "object" && node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.MULTIPLE_SELECT_WITH_SUBMENU_ITEM;
|
75
|
+
};
|
76
|
+
const isMultipleSelectNode = (item) => isMultipleSelectOnlyNode(item) || isMultipleSelectWithSubmenuNode(item);
|
77
|
+
const isSingleSelectOnlyNode = (item) => {
|
78
|
+
const node = item;
|
79
|
+
return typeof item === "object" && item !== null && typeof node.plainItem === "object" && node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.SINGLE_SELECT_ITEM;
|
80
|
+
};
|
81
|
+
const isSingleSelectNodeWithSubmenu = (item) => {
|
82
|
+
const node = item;
|
83
|
+
return typeof item === "object" && item !== null && typeof node.plainItem === "object" && node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.SINGLE_SELECT_WITH_SUBMENU_ITEM;
|
84
|
+
};
|
85
|
+
const isSingleSelectNode = (item) => isSingleSelectOnlyNode(item) || isSingleSelectNodeWithSubmenu(item);
|
86
|
+
const isSelectionableNode = (item) => isMultipleSelectNode(item) || isSingleSelectNode(item);
|
87
|
+
const getSelectionableNodes = (tree) => {
|
88
|
+
const flattenNodes = tree.flatten();
|
89
|
+
return flattenNodes.filter(isSelectionableNode);
|
90
|
+
};
|
91
|
+
const isWithSubmenuOnlyNode = (item) => {
|
92
|
+
const node = item;
|
93
|
+
return typeof item === "object" && item !== null && typeof node.plainItem === "object" && node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.WITH_SUBMENU_ITEM;
|
94
|
+
};
|
95
|
+
const isSelectionableWithSubmenuNode = (item) => isSingleSelectNodeWithSubmenu(item) || isMultipleSelectWithSubmenuNode(item);
|
96
|
+
const isWithSubmenuNode = (item) => isWithSubmenuOnlyNode(item) || isSingleSelectNodeWithSubmenu(item) || isMultipleSelectWithSubmenuNode(item) || isActivableWithSubmenuNode(item);
|
97
|
+
const getWithSubmenuNodes = (tree) => {
|
98
|
+
const flattenNodes = tree.flatten();
|
99
|
+
return flattenNodes.filter(isWithSubmenuNode);
|
100
|
+
};
|
101
|
+
const isFocusableNode = (item) => {
|
102
|
+
const node = item;
|
103
|
+
return typeof item === "object" && item !== null && typeof node.plainItem === "object" && typeof node.plainItem.type === "string" && (node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.WITH_SUBMENU_ITEM || node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.MULTIPLE_SELECT_ITEM || node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.MULTIPLE_SELECT_WITH_SUBMENU_ITEM || node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.SINGLE_SELECT_ITEM || node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.SINGLE_SELECT_WITH_SUBMENU_ITEM || node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.ACTIVABLE_ITEM || node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.ACTIVABLE_WITH_SUBMENU_ITEM || node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.SKELETON_ITEM);
|
104
|
+
};
|
105
|
+
const getFocusableNodes = (tree) => {
|
106
|
+
const flattenNodes = tree.flatten();
|
107
|
+
return flattenNodes.filter(isFocusableNode);
|
108
|
+
};
|
109
|
+
const isSeparatorNode = (item) => {
|
110
|
+
const node = item;
|
111
|
+
return typeof item === "object" && item !== null && typeof node.plainItem === "object" && node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.SEPARATOR;
|
112
|
+
};
|
113
|
+
const isGroup = (item) => {
|
114
|
+
const node = item;
|
115
|
+
return typeof item === "object" && item !== null && typeof node.plainItem === "object" && node.plainItem?.type === import_constants.MENU_ITEMS_TYPES.GROUP;
|
116
|
+
};
|
117
|
+
const isRootNode = (item) => {
|
118
|
+
const node = item;
|
119
|
+
return typeof item === "object" && item !== null && typeof node.plainItem === "object" && // hardcoded string because the root item is not a renderable item and must always be treated with special care
|
120
|
+
node.plainItem?.type === "ROOT_ITEM";
|
121
|
+
};
|
122
|
+
const isMenuNodeAllowedToHaveChildren = (item) => isRootNode(item) || isWithSubmenuNode(item) || isGroup(item) || isSingleSelectNodeWithSubmenu(item) || isMultipleSelectWithSubmenuNode(item) || isActivableWithSubmenuNode(item);
|
123
|
+
//# sourceMappingURL=nodesTypeguardsAndGetters.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/utils/nodesTypeguardsAndGetters.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\nimport { type DSMenuButtonT } from '../react-desc-prop-types.js';\n\nimport { MENU_ITEMS_TYPES } from '../constants/index.js';\n// =============================================================================\n// Focusable nodes\n// =============================================================================\nexport const isActivableNode = (item: unknown): item is DSMenuButtonT.MenuNodeActivableItem => {\n const node = item as { plainItem?: { type?: unknown } };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n node.plainItem?.type === MENU_ITEMS_TYPES.ACTIVABLE_ITEM\n );\n};\nexport const isActivableWithSubmenuNode = (item: unknown): item is DSMenuButtonT.MenuNodeActivableWithSubmenuItem => {\n const node = item as { plainItem?: { type?: unknown } };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n node.plainItem?.type === MENU_ITEMS_TYPES.ACTIVABLE_WITH_SUBMENU_ITEM\n );\n};\nexport const isSkeletonNode = (item: unknown): item is DSMenuButtonT.MenuNodeSkeletonItem => {\n const node = item as { plainItem?: { type?: unknown } };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n node.plainItem?.type === MENU_ITEMS_TYPES.SKELETON_ITEM\n );\n};\n// =============================================================================\n// Focusable but more specifically specifically selectable nodes\n// =============================================================================\nexport const isMultipleSelectOnlyNode = (item: unknown): item is DSMenuButtonT.MenuNodeMultipleSelectItem => {\n const node = item as { plainItem?: { type?: unknown } };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n node.plainItem?.type === MENU_ITEMS_TYPES.MULTIPLE_SELECT_ITEM\n );\n};\n\nexport const isMultipleSelectWithSubmenuNode = (\n item: unknown,\n): item is DSMenuButtonT.MenuNodeMultipleSelectWithSubmenuItem => {\n const node = item as { plainItem?: { type?: unknown } };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n node.plainItem?.type === MENU_ITEMS_TYPES.MULTIPLE_SELECT_WITH_SUBMENU_ITEM\n );\n};\nexport const isMultipleSelectNode = (item: unknown): item is DSMenuButtonT.MultipleSelectionableMenuNodes =>\n isMultipleSelectOnlyNode(item) || isMultipleSelectWithSubmenuNode(item);\n\nexport const isSingleSelectOnlyNode = (item: unknown): item is DSMenuButtonT.MenuNodeSingleSelectItem => {\n const node = item as { plainItem?: { type?: unknown } };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n node.plainItem?.type === MENU_ITEMS_TYPES.SINGLE_SELECT_ITEM\n );\n};\n\nexport const isSingleSelectNodeWithSubmenu = (\n item: unknown,\n): item is DSMenuButtonT.MenuNodeSingleSelectWithSubmenuItem => {\n const node = item as { plainItem?: { type?: unknown } };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n node.plainItem?.type === MENU_ITEMS_TYPES.SINGLE_SELECT_WITH_SUBMENU_ITEM\n );\n};\n\nexport const isSingleSelectNode = (item: unknown): item is DSMenuButtonT.SingleSelectionableMenuNodes =>\n isSingleSelectOnlyNode(item) || isSingleSelectNodeWithSubmenu(item);\n\nexport const isSelectionableNode = (item: unknown): item is DSMenuButtonT.SelectionableMenuNodes =>\n isMultipleSelectNode(item) || isSingleSelectNode(item);\n\nexport const getSelectionableNodes = (tree: DSMenuButtonT.MenuNode): DSMenuButtonT.SelectionableMenuNodes[] => {\n const flattenNodes = tree.flatten();\n return flattenNodes.filter(isSelectionableNode);\n};\n\n// =============================================================================\n// Focusable but more specifically with submenu nodes\n// =============================================================================\nexport const isWithSubmenuOnlyNode = (item: unknown): item is DSMenuButtonT.MenuNodeWithSubmenuItem => {\n const node = item as { plainItem?: { type?: unknown } };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n node.plainItem?.type === MENU_ITEMS_TYPES.WITH_SUBMENU_ITEM\n );\n};\n\nexport const isSelectionableWithSubmenuNode = (\n item: unknown,\n): item is DSMenuButtonT.SelectionablesWithSubmenuMenuNodes =>\n isSingleSelectNodeWithSubmenu(item) || isMultipleSelectWithSubmenuNode(item);\n\nexport const isWithSubmenuNode = (item: unknown): item is DSMenuButtonT.WithSubmenuMenuNodes =>\n isWithSubmenuOnlyNode(item) ||\n isSingleSelectNodeWithSubmenu(item) ||\n isMultipleSelectWithSubmenuNode(item) ||\n isActivableWithSubmenuNode(item);\n\nexport const getWithSubmenuNodes = (tree: DSMenuButtonT.MenuNode): DSMenuButtonT.PseudoFocusableMenuNodes[] => {\n const flattenNodes = tree.flatten();\n return flattenNodes.filter(isWithSubmenuNode);\n};\n\nexport const isFocusableNode = (item: unknown): item is DSMenuButtonT.PseudoFocusableMenuNodes => {\n const node = item as { plainItem?: { type?: unknown } };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n typeof node.plainItem.type === 'string' &&\n (node.plainItem?.type === MENU_ITEMS_TYPES.WITH_SUBMENU_ITEM ||\n node.plainItem?.type === MENU_ITEMS_TYPES.MULTIPLE_SELECT_ITEM ||\n node.plainItem?.type === MENU_ITEMS_TYPES.MULTIPLE_SELECT_WITH_SUBMENU_ITEM ||\n node.plainItem?.type === MENU_ITEMS_TYPES.SINGLE_SELECT_ITEM ||\n node.plainItem?.type === MENU_ITEMS_TYPES.SINGLE_SELECT_WITH_SUBMENU_ITEM ||\n node.plainItem?.type === MENU_ITEMS_TYPES.ACTIVABLE_ITEM ||\n node.plainItem?.type === MENU_ITEMS_TYPES.ACTIVABLE_WITH_SUBMENU_ITEM ||\n node.plainItem?.type === MENU_ITEMS_TYPES.SKELETON_ITEM)\n );\n};\n\nexport const getFocusableNodes = (tree: DSMenuButtonT.MenuNode): DSMenuButtonT.PseudoFocusableMenuNodes[] => {\n const flattenNodes = tree.flatten();\n return flattenNodes.filter(isFocusableNode);\n};\n\n// =============================================================================\n// Non focusable nodes\n// =============================================================================\nexport const isSeparatorNode = (item: unknown): item is DSMenuButtonT.MenuNodeSeparatorItem => {\n const node = item as { plainItem?: { type?: unknown } };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n node.plainItem?.type === MENU_ITEMS_TYPES.SEPARATOR\n );\n};\n\nexport const isGroup = (item: unknown): item is DSMenuButtonT.MenuNodeGroupItem => {\n const node = item as { plainItem?: { type?: unknown } };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n node.plainItem?.type === MENU_ITEMS_TYPES.GROUP\n );\n};\nexport const isRootNode = (item: unknown): item is DSMenuButtonT.MenuNodeRootItem => {\n const node = item as { plainItem?: { type?: unknown } };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n // hardcoded string because the root item is not a renderable item and must always be treated with special care\n node.plainItem?.type === 'ROOT_ITEM'\n );\n};\n// =============================================================================\n// Nodes allowed/expected to have subItems/children\n// (the node not necessarily needs to be focusable or a submenu)\n// =============================================================================\nexport const isMenuNodeAllowedToHaveChildren = (item: unknown): item is DSMenuButtonT.MenuNodesAllowedToHaveChildren =>\n isRootNode(item) ||\n isWithSubmenuNode(item) ||\n isGroup(item) ||\n isSingleSelectNodeWithSubmenu(item) ||\n isMultipleSelectWithSubmenuNode(item) ||\n isActivableWithSubmenuNode(item);\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,uBAAiC;AAI1B,MAAM,kBAAkB,CAAC,SAA+D;AAC7F,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc,YAC1B,KAAK,WAAW,SAAS,kCAAiB;AAE9C;AACO,MAAM,6BAA6B,CAAC,SAA0E;AACnH,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc,YAC1B,KAAK,WAAW,SAAS,kCAAiB;AAE9C;AACO,MAAM,iBAAiB,CAAC,SAA8D;AAC3F,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc,YAC1B,KAAK,WAAW,SAAS,kCAAiB;AAE9C;AAIO,MAAM,2BAA2B,CAAC,SAAoE;AAC3G,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc,YAC1B,KAAK,WAAW,SAAS,kCAAiB;AAE9C;AAEO,MAAM,kCAAkC,CAC7C,SACgE;AAChE,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc,YAC1B,KAAK,WAAW,SAAS,kCAAiB;AAE9C;AACO,MAAM,uBAAuB,CAAC,SACnC,yBAAyB,IAAI,KAAK,gCAAgC,IAAI;AAEjE,MAAM,yBAAyB,CAAC,SAAkE;AACvG,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc,YAC1B,KAAK,WAAW,SAAS,kCAAiB;AAE9C;AAEO,MAAM,gCAAgC,CAC3C,SAC8D;AAC9D,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc,YAC1B,KAAK,WAAW,SAAS,kCAAiB;AAE9C;AAEO,MAAM,qBAAqB,CAAC,SACjC,uBAAuB,IAAI,KAAK,8BAA8B,IAAI;AAE7D,MAAM,sBAAsB,CAAC,SAClC,qBAAqB,IAAI,KAAK,mBAAmB,IAAI;AAEhD,MAAM,wBAAwB,CAAC,SAAyE;AAC7G,QAAM,eAAe,KAAK,QAAQ;AAClC,SAAO,aAAa,OAAO,mBAAmB;AAChD;AAKO,MAAM,wBAAwB,CAAC,SAAiE;AACrG,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc,YAC1B,KAAK,WAAW,SAAS,kCAAiB;AAE9C;AAEO,MAAM,iCAAiC,CAC5C,SAEA,8BAA8B,IAAI,KAAK,gCAAgC,IAAI;AAEtE,MAAM,oBAAoB,CAAC,SAChC,sBAAsB,IAAI,KAC1B,8BAA8B,IAAI,KAClC,gCAAgC,IAAI,KACpC,2BAA2B,IAAI;AAE1B,MAAM,sBAAsB,CAAC,SAA2E;AAC7G,QAAM,eAAe,KAAK,QAAQ;AAClC,SAAO,aAAa,OAAO,iBAAiB;AAC9C;AAEO,MAAM,kBAAkB,CAAC,SAAkE;AAChG,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc,YAC1B,OAAO,KAAK,UAAU,SAAS,aAC9B,KAAK,WAAW,SAAS,kCAAiB,qBACzC,KAAK,WAAW,SAAS,kCAAiB,wBAC1C,KAAK,WAAW,SAAS,kCAAiB,qCAC1C,KAAK,WAAW,SAAS,kCAAiB,sBAC1C,KAAK,WAAW,SAAS,kCAAiB,mCAC1C,KAAK,WAAW,SAAS,kCAAiB,kBAC1C,KAAK,WAAW,SAAS,kCAAiB,+BAC1C,KAAK,WAAW,SAAS,kCAAiB;AAEhD;AAEO,MAAM,oBAAoB,CAAC,SAA2E;AAC3G,QAAM,eAAe,KAAK,QAAQ;AAClC,SAAO,aAAa,OAAO,eAAe;AAC5C;AAKO,MAAM,kBAAkB,CAAC,SAA+D;AAC7F,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc,YAC1B,KAAK,WAAW,SAAS,kCAAiB;AAE9C;AAEO,MAAM,UAAU,CAAC,SAA2D;AACjF,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc,YAC1B,KAAK,WAAW,SAAS,kCAAiB;AAE9C;AACO,MAAM,aAAa,CAAC,SAA0D;AACnF,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc;AAAA,EAE1B,KAAK,WAAW,SAAS;AAE7B;AAKO,MAAM,kCAAkC,CAAC,SAC9C,WAAW,IAAI,KACf,kBAAkB,IAAI,KACtB,QAAQ,IAAI,KACZ,8BAA8B,IAAI,KAClC,gCAAgC,IAAI,KACpC,2BAA2B,IAAI;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,55 @@
|
|
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 useOptionsArrayToDsTree_exports = {};
|
30
|
+
__export(useOptionsArrayToDsTree_exports, {
|
31
|
+
useOptionsArrayToDsTree: () => useOptionsArrayToDsTree
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(useOptionsArrayToDsTree_exports);
|
34
|
+
var React = __toESM(require("react"));
|
35
|
+
var import_react = __toESM(require("react"));
|
36
|
+
var import_ds_tree_model = require("@elliemae/ds-tree-model");
|
37
|
+
const useDsTreeOpts = {
|
38
|
+
getUniqueId: (item) => item.dsId
|
39
|
+
};
|
40
|
+
const useOptionsArrayToDsTree = ({ options, instanceUid }) => {
|
41
|
+
const rootNode = import_react.default.useMemo(
|
42
|
+
() => ({
|
43
|
+
dsId: `root-${instanceUid}`,
|
44
|
+
type: "ROOT_ITEM",
|
45
|
+
subitems: options
|
46
|
+
// as unknown as RootNodeType is because currently
|
47
|
+
// the DS tree model doesn't support the type of the root node being different from the subitems
|
48
|
+
// in practice, this is fine because the root node is never rendered & the subitems are the only thing that matters
|
49
|
+
// will be addresssed via PUI-XXXX
|
50
|
+
}),
|
51
|
+
[instanceUid, options]
|
52
|
+
);
|
53
|
+
return (0, import_ds_tree_model.useDSTree)(rootNode, useDsTreeOpts);
|
54
|
+
};
|
55
|
+
//# sourceMappingURL=useOptionsArrayToDsTree.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/utils/useOptionsArrayToDsTree.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { useDSTree } from '@elliemae/ds-tree-model';\nimport type { UseDSTreeT } from '@elliemae/ds-tree-model';\nimport { type DSMenuButtonT } from '../react-desc-prop-types.js';\n\nconst useDsTreeOpts: UseDSTreeT.SecondParameter<DSMenuButtonT.MenuItemInterface> = {\n getUniqueId: (item) => item.dsId,\n};\n\ntype UseOptionsArrayToDsTreeRootNodeConfig = {\n options: DSMenuButtonT.MenuItemInterface[];\n instanceUid: string;\n};\n\ntype RootNodeType = UseDSTreeT.Item<DSMenuButtonT.MenuItemInterface>;\n\nexport const useOptionsArrayToDsTree = ({ options, instanceUid }: UseOptionsArrayToDsTreeRootNodeConfig) => {\n // we need to create the root node that the app dev doesn't need to worry about\n const rootNode = React.useMemo<RootNodeType>(\n () =>\n ({\n dsId: `root-${instanceUid}`,\n type: 'ROOT_ITEM',\n subitems: options,\n // as unknown as RootNodeType is because currently\n // the DS tree model doesn't support the type of the root node being different from the subitems\n // in practice, this is fine because the root node is never rendered & the subitems are the only thing that matters\n // will be addresssed via PUI-XXXX\n }) as unknown as RootNodeType,\n [instanceUid, options],\n );\n return useDSTree<DSMenuButtonT.MenuItemInterface>(rootNode, useDsTreeOpts);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,2BAA0B;AAI1B,MAAM,gBAA6E;AAAA,EACjF,aAAa,CAAC,SAAS,KAAK;AAC9B;AASO,MAAM,0BAA0B,CAAC,EAAE,SAAS,YAAY,MAA6C;AAE1G,QAAM,WAAW,aAAAA,QAAM;AAAA,IACrB,OACG;AAAA,MACC,MAAM,QAAQ,WAAW;AAAA,MACzB,MAAM;AAAA,MACN,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,IAKZ;AAAA,IACF,CAAC,aAAa,OAAO;AAAA,EACvB;AACA,aAAO,gCAA2C,UAAU,aAAa;AAC3E;",
|
6
|
+
"names": ["React"]
|
7
|
+
}
|
package/dist/esm/DSMenuButton.js
CHANGED
@@ -1,18 +1,29 @@
|
|
1
1
|
import * as React from "react";
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
3
|
+
import { styled } from "@elliemae/ds-system";
|
4
|
+
import { Grid } from "@elliemae/ds-grid";
|
3
5
|
import { describe } from "@elliemae/ds-props-helpers";
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
import {
|
6
|
+
import { DSMenuButtonPropTypesSchema } from "./react-desc-prop-types.js";
|
7
|
+
import { useMenuButton } from "./config/useMenuButton.js";
|
8
|
+
import { DSOpinionatedButton } from "./parts/DSOpinionatedButton/index.js";
|
9
|
+
import { DSMenuButtonName, MENU_BUTTON_SLOTS, MENU_BUTTON_DATA_TESTID } from "./constants/index.js";
|
10
|
+
import { DSMenuBehaviouralContextProvider } from "./parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.js";
|
11
|
+
const StyledWrapper = styled(Grid, { name: DSMenuButtonName, slot: MENU_BUTTON_SLOTS.ROOT })``;
|
9
12
|
const DSMenuButton = (props) => {
|
10
|
-
const
|
11
|
-
return /* @__PURE__ */ jsx(
|
13
|
+
const { propsWithDefault, opinionatedButtonProps, menuBehaviouralLayerProps } = useMenuButton(props);
|
14
|
+
return /* @__PURE__ */ jsx(
|
15
|
+
StyledWrapper,
|
16
|
+
{
|
17
|
+
"data-testid": MENU_BUTTON_DATA_TESTID.ROOT,
|
18
|
+
getOwnerProps: () => propsWithDefault,
|
19
|
+
getOwnerPropsArguments: () => ({}),
|
20
|
+
children: /* @__PURE__ */ jsx(DSMenuBehaviouralContextProvider, { ...menuBehaviouralLayerProps, children: /* @__PURE__ */ jsx(DSOpinionatedButton, { ...opinionatedButtonProps, children: opinionatedButtonProps.children }) })
|
21
|
+
}
|
22
|
+
);
|
12
23
|
};
|
13
24
|
DSMenuButton.displayName = DSMenuButtonName;
|
14
25
|
const DSMenuButtonWithSchema = describe(DSMenuButton);
|
15
|
-
DSMenuButtonWithSchema.propTypes =
|
26
|
+
DSMenuButtonWithSchema.propTypes = DSMenuButtonPropTypesSchema;
|
16
27
|
export {
|
17
28
|
DSMenuButton,
|
18
29
|
DSMenuButtonWithSchema
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSMenuButton.tsx"],
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { type
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { type DSMenuButtonT, DSMenuButtonPropTypesSchema } from './react-desc-prop-types.js';\nimport { useMenuButton } from './config/useMenuButton.js';\nimport { DSOpinionatedButton } from './parts/DSOpinionatedButton/index.js';\nimport { DSMenuButtonName, MENU_BUTTON_SLOTS, MENU_BUTTON_DATA_TESTID } from './constants/index.js';\nimport { DSMenuBehaviouralContextProvider } from './parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.js';\n\nconst StyledWrapper = styled(Grid, { name: DSMenuButtonName, slot: MENU_BUTTON_SLOTS.ROOT })``;\n\n// what are the responsability of this widget?\n// 1 - receive an API \"A\" and correctly split it into\n// what goes to the \"menu\"\n// what goes to the \"button\"\n// what goes to the \"behavioural layer\"\n// 2 - ensure the behavioural layer is parent of the button & menu\n// 3 - parse any API \"A\" into the correct data structures / high-level concerns\n// E.G. Accept array of options\n// -> convert to DSTree\n// receive an innerRef that goes to the button\n// -> make it so we still have a ref to the button in the behavioural layer\nconst DSMenuButton: React.ComponentType<DSMenuButtonT.Props> = (props) => {\n const { propsWithDefault, opinionatedButtonProps, menuBehaviouralLayerProps } = useMenuButton(props);\n return (\n <StyledWrapper\n data-testid={MENU_BUTTON_DATA_TESTID.ROOT}\n getOwnerProps={() => propsWithDefault}\n getOwnerPropsArguments={() => ({})}\n >\n <DSMenuBehaviouralContextProvider {...menuBehaviouralLayerProps}>\n <DSOpinionatedButton {...opinionatedButtonProps}>{opinionatedButtonProps.children}</DSOpinionatedButton>\n </DSMenuBehaviouralContextProvider>\n </StyledWrapper>\n );\n};\n\nDSMenuButton.displayName = DSMenuButtonName;\nconst DSMenuButtonWithSchema = describe(DSMenuButton);\nDSMenuButtonWithSchema.propTypes = DSMenuButtonPropTypesSchema;\n\nexport { DSMenuButton, DSMenuButtonWithSchema };\n"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACgCf;AA/BR,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,gBAAgB;AACzB,SAA6B,mCAAmC;AAChE,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,kBAAkB,mBAAmB,+BAA+B;AAC7E,SAAS,wCAAwC;AAEjD,MAAM,gBAAgB,OAAO,MAAM,EAAE,MAAM,kBAAkB,MAAM,kBAAkB,KAAK,CAAC;AAa3F,MAAM,eAAyD,CAAC,UAAU;AACxE,QAAM,EAAE,kBAAkB,wBAAwB,0BAA0B,IAAI,cAAc,KAAK;AACnG,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAa,wBAAwB;AAAA,MACrC,eAAe,MAAM;AAAA,MACrB,wBAAwB,OAAO,CAAC;AAAA,MAEhC,8BAAC,oCAAkC,GAAG,2BACpC,8BAAC,uBAAqB,GAAG,wBAAyB,iCAAuB,UAAS,GACpF;AAAA;AAAA,EACF;AAEJ;AAEA,aAAa,cAAc;AAC3B,MAAM,yBAAyB,SAAS,YAAY;AACpD,uBAAuB,YAAY;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -1,31 +1,62 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
import
|
3
|
-
import { useMemoMergePropsWithDefault } from "@elliemae/ds-props-helpers";
|
4
|
-
import {
|
2
|
+
import React2 from "react";
|
3
|
+
import { useGetXstyledProps, useMemoMergePropsWithDefault } from "@elliemae/ds-props-helpers";
|
4
|
+
import { uid } from "uid";
|
5
|
+
import { DSMenuButtonPropTypes, defaultProps } from "../react-desc-prop-types.js";
|
5
6
|
import { useValidateProps } from "./useValidateProps.js";
|
6
|
-
|
7
|
+
import { useSplitInherithedProps } from "./useSplitInherithedProps.js";
|
8
|
+
import { useOptionsArrayToDsTree } from "../utils/useOptionsArrayToDsTree.js";
|
9
|
+
import { getFocusableNodes } from "../utils/nodesTypeguardsAndGetters.js";
|
10
|
+
const useMenuButton = (propsFromUser) => {
|
7
11
|
const propsWithDefault = useMemoMergePropsWithDefault(propsFromUser, defaultProps);
|
8
|
-
useValidateProps(propsWithDefault,
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const [
|
12
|
-
const
|
13
|
-
|
12
|
+
useValidateProps(propsWithDefault, DSMenuButtonPropTypes);
|
13
|
+
const xstyledProps = useGetXstyledProps(propsWithDefault);
|
14
|
+
const instanceUid = React2.useMemo(() => `menu-button${uid(5)}`, []);
|
15
|
+
const [buttonDOMNode, setButtonDOMNode] = React2.useState(null);
|
16
|
+
const { options: appOptions } = propsWithDefault;
|
17
|
+
const optionsArray = Array.isArray(appOptions) ? appOptions : [];
|
18
|
+
const treeRootNodeFromOptionsArrayIfArray = useOptionsArrayToDsTree({
|
19
|
+
options: optionsArray,
|
20
|
+
instanceUid
|
21
|
+
// this typecast is a safe type reconciliation, typescript checks they are compatible
|
22
|
+
// this typecast let us avoid to have to do the ` | OtherCompatibleType` dance
|
23
|
+
}).getRoot();
|
24
|
+
const treeRootNode = React2.useMemo(
|
25
|
+
() => Array.isArray(appOptions) ? treeRootNodeFromOptionsArrayIfArray : appOptions,
|
26
|
+
[appOptions, treeRootNodeFromOptionsArrayIfArray]
|
27
|
+
);
|
28
|
+
const focusableNodes = React2.useMemo(() => getFocusableNodes(treeRootNode), [treeRootNode]);
|
29
|
+
const splitInherithedProps = useSplitInherithedProps({
|
30
|
+
propsWithDefault,
|
31
|
+
setButtonDOMNode,
|
32
|
+
buttonDOMNode,
|
33
|
+
focusableNodes,
|
34
|
+
treeRootNode
|
35
|
+
});
|
36
|
+
const allNodes = treeRootNode.flatten();
|
37
|
+
const nodesWithRepeatedDsId = allNodes.filter(
|
38
|
+
(node, index, self) => self.findIndex((n) => n.dsId === node.dsId) !== index
|
39
|
+
);
|
40
|
+
if (nodesWithRepeatedDsId.length > 0) {
|
41
|
+
throw new Error(
|
42
|
+
`DSMenuButton:
|
43
|
+
The following dsId are repeated:
|
44
|
+
${nodesWithRepeatedDsId.map((n) => n.dsId).join("\n ")}
|
45
|
+
|
46
|
+
The dsId must be unique.`
|
47
|
+
);
|
48
|
+
}
|
49
|
+
return React2.useMemo(
|
14
50
|
() => ({
|
15
51
|
propsWithDefault,
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
onSelectionChange,
|
20
|
-
triggerElementRef,
|
21
|
-
setTriggerElementRef,
|
22
|
-
isOpen,
|
23
|
-
setIsOpen
|
52
|
+
xstyledProps,
|
53
|
+
instanceUid,
|
54
|
+
...splitInherithedProps
|
24
55
|
}),
|
25
|
-
[propsWithDefault,
|
56
|
+
[propsWithDefault, xstyledProps, instanceUid, splitInherithedProps]
|
26
57
|
);
|
27
58
|
};
|
28
59
|
export {
|
29
|
-
|
60
|
+
useMenuButton
|
30
61
|
};
|
31
62
|
//# sourceMappingURL=useMenuButton.js.map
|