@elliemae/ds-menu-button 3.80.0-next.72 → 3.80.0-next.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js +8 -5
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js.map +2 -2
- package/dist/cjs/parts/DSMenuItemRendererFactory/ActivableMenuItem.js +6 -3
- package/dist/cjs/parts/DSMenuItemRendererFactory/ActivableMenuItem.js.map +2 -2
- package/dist/cjs/parts/DSMenuItemRendererFactory/ActivableWithSubmenuMenuItem.js +6 -3
- package/dist/cjs/parts/DSMenuItemRendererFactory/ActivableWithSubmenuMenuItem.js.map +2 -2
- package/dist/cjs/parts/DSMenuItemRendererFactory/MultipleSelectMenuItem.js +8 -5
- package/dist/cjs/parts/DSMenuItemRendererFactory/MultipleSelectMenuItem.js.map +2 -2
- package/dist/cjs/parts/DSMenuItemRendererFactory/MultipleSelectWithSubmenuMenuItem.js +8 -5
- package/dist/cjs/parts/DSMenuItemRendererFactory/MultipleSelectWithSubmenuMenuItem.js.map +2 -2
- package/dist/cjs/parts/DSMenuItemRendererFactory/SingleSelectMenuItem.js +6 -3
- package/dist/cjs/parts/DSMenuItemRendererFactory/SingleSelectMenuItem.js.map +2 -2
- package/dist/cjs/parts/DSMenuItemRendererFactory/SingleSelectWithSubmenuMenuItem.js +6 -3
- package/dist/cjs/parts/DSMenuItemRendererFactory/SingleSelectWithSubmenuMenuItem.js.map +2 -2
- package/dist/cjs/parts/DSMenuItemRendererFactory/SkeletonMenuItem.js +9 -1
- package/dist/cjs/parts/DSMenuItemRendererFactory/SkeletonMenuItem.js.map +2 -2
- package/dist/cjs/parts/DSMenuItemRendererFactory/WithSubmenuMenuItem.js +6 -3
- package/dist/cjs/parts/DSMenuItemRendererFactory/WithSubmenuMenuItem.js.map +2 -2
- package/dist/cjs/parts/DSOpinionatedButton/DSOpinionatedButton.js +9 -2
- package/dist/cjs/parts/DSOpinionatedButton/DSOpinionatedButton.js.map +2 -2
- package/dist/cjs/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.js +36 -14
- package/dist/cjs/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/utils/nodesTypeguardsAndGetters.js +9 -0
- package/dist/cjs/utils/nodesTypeguardsAndGetters.js.map +2 -2
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js +10 -5
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js.map +2 -2
- package/dist/esm/parts/DSMenuItemRendererFactory/ActivableMenuItem.js +6 -3
- package/dist/esm/parts/DSMenuItemRendererFactory/ActivableMenuItem.js.map +2 -2
- package/dist/esm/parts/DSMenuItemRendererFactory/ActivableWithSubmenuMenuItem.js +6 -3
- package/dist/esm/parts/DSMenuItemRendererFactory/ActivableWithSubmenuMenuItem.js.map +2 -2
- package/dist/esm/parts/DSMenuItemRendererFactory/MultipleSelectMenuItem.js +8 -5
- package/dist/esm/parts/DSMenuItemRendererFactory/MultipleSelectMenuItem.js.map +2 -2
- package/dist/esm/parts/DSMenuItemRendererFactory/MultipleSelectWithSubmenuMenuItem.js +8 -5
- package/dist/esm/parts/DSMenuItemRendererFactory/MultipleSelectWithSubmenuMenuItem.js.map +2 -2
- package/dist/esm/parts/DSMenuItemRendererFactory/SingleSelectMenuItem.js +6 -3
- package/dist/esm/parts/DSMenuItemRendererFactory/SingleSelectMenuItem.js.map +2 -2
- package/dist/esm/parts/DSMenuItemRendererFactory/SingleSelectWithSubmenuMenuItem.js +6 -3
- package/dist/esm/parts/DSMenuItemRendererFactory/SingleSelectWithSubmenuMenuItem.js.map +2 -2
- package/dist/esm/parts/DSMenuItemRendererFactory/SkeletonMenuItem.js +9 -1
- package/dist/esm/parts/DSMenuItemRendererFactory/SkeletonMenuItem.js.map +2 -2
- package/dist/esm/parts/DSMenuItemRendererFactory/WithSubmenuMenuItem.js +6 -3
- package/dist/esm/parts/DSMenuItemRendererFactory/WithSubmenuMenuItem.js.map +2 -2
- package/dist/esm/parts/DSOpinionatedButton/DSOpinionatedButton.js +9 -2
- package/dist/esm/parts/DSOpinionatedButton/DSOpinionatedButton.js.map +2 -2
- package/dist/esm/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.js +36 -14
- package/dist/esm/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/utils/nodesTypeguardsAndGetters.js +9 -0
- package/dist/esm/utils/nodesTypeguardsAndGetters.js.map +2 -2
- package/dist/types/config/useSplitInherithedProps.d.ts +2 -1
- package/dist/types/parts/DSOpinionatedButton/config/useOpinionatedButton.d.ts +1 -0
- package/dist/types/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.d.ts +1 -0
- package/dist/types/react-desc-prop-types.d.ts +42 -0
- package/dist/types/utils/nodesTypeguardsAndGetters.d.ts +21 -0
- package/package.json +13 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import type { DSButtonV3T } from '@elliemae/ds-button-v2';\nimport { type useFloatingContext } from '@elliemae/ds-floating-context';\nimport React from 'react';\nimport { resolveRef } from '../../../utils/resolveRef.js';\nimport { MenuBehaviouralContextProviderContext } from '../../DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js';\nimport { MENU_FOCUS_REGIONS } from '../../DSMenuBehaviouralContextProvider/constants/index.js';\nimport { type DSOpinionatedButtonT } from '../react-desc-prop-types.js';\n\ntype UseTriggerEventsHandlersConfig = {\n propsWithDefault: DSOpinionatedButtonT.InternalProps;\n floatingContext: ReturnType<typeof useFloatingContext>;\n};\n\nexport const useTriggerEventsHandlers = ({ propsWithDefault, floatingContext }: UseTriggerEventsHandlersConfig) => {\n // =============================================================================\n // on click -> open the submenu\n // if the props already include an onClick, we will wrap it\n // =============================================================================\n const {\n focusRegion,\n triggerFocusRequestId,\n isMenuOpen,\n onOpinionatedOpen,\n onOpinionatedClose,\n trackFocusTrigger,\n shouldFocusImmediately,\n shouldRefocusTrigger,\n } = React.useContext(MenuBehaviouralContextProviderContext);\n const { onClick, onFocus, innerRef, onKeyDown } = propsWithDefault;\n const { firstOpenAxis } = propsWithDefault.menuSpecificProps;\n const {\n refs: { setReference },\n } = floatingContext;\n\n // only read by the passive focus tracking below; assigning the current value is idempotent, so it is safe to do during render\n const focusedRegionPerformanceHelper = React.useRef(focusRegion);\n focusedRegionPerformanceHelper.current = focusRegion;\n\n // each request to return focus to the trigger changes `triggerFocusRequestId`, which changes the reference of the ref\n // callback below so React invokes it again with the node, and it focuses itself. Requests are consumed here, in the\n // commit phase, never while rendering: a render can run more than once (StrictMode) before it commits.\n const lastHandledTriggerFocusRequestId = React.useRef(triggerFocusRequestId);\n\n const mutableIsMenuOpen = React.useRef(isMenuOpen);\n // this is a boolean, so a primitive value,\n // we don't need to useEffect to change it\n // because we don't need to ensure referencial equality\n mutableIsMenuOpen.current = isMenuOpen;\n\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAkB;AAClB,wBAA2B;AAC3B,+CAAsD;AACtD,uBAAmC;AAQ5B,MAAM,2BAA2B,CAAC,EAAE,kBAAkB,gBAAgB,MAAsC;AAKjH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,aAAAA,QAAM,WAAW,8EAAqC;AAC1D,QAAM,EAAE,SAAS,SAAS,UAAU,
|
|
4
|
+
"sourcesContent": ["import type { DSButtonV3T } from '@elliemae/ds-button-v2';\nimport { type useFloatingContext } from '@elliemae/ds-floating-context';\nimport React from 'react';\nimport { resolveRef } from '../../../utils/resolveRef.js';\nimport { MenuBehaviouralContextProviderContext } from '../../DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js';\nimport { MENU_FOCUS_REGIONS } from '../../DSMenuBehaviouralContextProvider/constants/index.js';\nimport { type DSOpinionatedButtonT } from '../react-desc-prop-types.js';\n\ntype UseTriggerEventsHandlersConfig = {\n propsWithDefault: DSOpinionatedButtonT.InternalProps;\n floatingContext: ReturnType<typeof useFloatingContext>;\n};\n\nexport const useTriggerEventsHandlers = ({ propsWithDefault, floatingContext }: UseTriggerEventsHandlersConfig) => {\n // =============================================================================\n // on click -> open the submenu\n // if the props already include an onClick, we will wrap it\n // =============================================================================\n const {\n focusRegion,\n triggerFocusRequestId,\n isMenuOpen,\n onOpinionatedOpen,\n onOpinionatedClose,\n trackFocusTrigger,\n shouldFocusImmediately,\n shouldRefocusTrigger,\n } = React.useContext(MenuBehaviouralContextProviderContext);\n const { onClick, onFocus, innerRef, onKeyDown, disabled } = propsWithDefault;\n const { firstOpenAxis } = propsWithDefault.menuSpecificProps;\n const {\n refs: { setReference },\n } = floatingContext;\n\n // only read by the passive focus tracking below; assigning the current value is idempotent, so it is safe to do during render\n const focusedRegionPerformanceHelper = React.useRef(focusRegion);\n focusedRegionPerformanceHelper.current = focusRegion;\n\n // each request to return focus to the trigger changes `triggerFocusRequestId`, which changes the reference of the ref\n // callback below so React invokes it again with the node, and it focuses itself. Requests are consumed here, in the\n // commit phase, never while rendering: a render can run more than once (StrictMode) before it commits.\n const lastHandledTriggerFocusRequestId = React.useRef(triggerFocusRequestId);\n\n const mutableIsMenuOpen = React.useRef(isMenuOpen);\n // this is a boolean, so a primitive value,\n // we don't need to useEffect to change it\n // because we don't need to ensure referencial equality\n mutableIsMenuOpen.current = isMenuOpen;\n\n // opening the menu is not an action of the lock: the trigger is a view-only disclosure, what the user selects inside it\n // is the responsibility of the menu items. So a soft-locked trigger (applyAriaDisabled, readOnly) toggles the menu\n // through DSButton's `onDeliberateActivationWhileSoftLocked`, while the consumer's onClick stays withheld.\n // A `disabled` trigger is a hard lock: it never opens.\n const toggleMenu = React.useCallback(\n (e: React.MouseEvent | React.KeyboardEvent) => {\n // no reason to change this function reference every time the menu opens/closes\n // so we are using a mutable ref to optimize this\n if (mutableIsMenuOpen.current) {\n onOpinionatedClose({ reason: 'trigger-toggle', event: e });\n } else {\n onOpinionatedOpen({ reason: 'trigger-click', event: e });\n }\n },\n [onOpinionatedClose, onOpinionatedOpen],\n );\n const handleOnClick = React.useCallback<Required<DSButtonV3T.Props>['onClick']>(\n (e, ...args) => {\n if (onClick) onClick(e, ...args);\n toggleMenu(e);\n },\n [onClick, toggleMenu],\n );\n const handleOnDeliberateActivationWhileSoftLocked = React.useCallback<\n Required<DSButtonV3T.Props>['onDeliberateActivationWhileSoftLocked']\n >((e) => toggleMenu(e), [toggleMenu]);\n const handleOnFocus = React.useCallback<Required<DSButtonV3T.Props>['onFocus']>(\n (e, ...args) => {\n if (focusedRegionPerformanceHelper.current !== MENU_FOCUS_REGIONS.TRIGGER)\n // passive tracking only: focus is ALREADY on the trigger by definition of this event,\n // so it must not be re-requested \u2014 a deferred refocus would race a Tab\n // that has already legitimately moved focus to the next element, and could win, stealing it back\n trackFocusTrigger({ shouldFocusImmediately: false, refocusTrigger: false });\n if (onFocus) onFocus(e, ...args);\n },\n [onFocus, trackFocusTrigger],\n );\n\n const handleFocusIfTriggerIsFocusRegion = React.useCallback<React.RefCallback<HTMLButtonElement>>(\n (node) => {\n const isNewTriggerFocusRequest = lastHandledTriggerFocusRequestId.current !== triggerFocusRequestId;\n if (node && isNewTriggerFocusRequest) lastHandledTriggerFocusRequestId.current = triggerFocusRequestId;\n if (node && isNewTriggerFocusRequest && shouldRefocusTrigger.current) {\n // when user presses \"Enter\" different things happen depending on top of what element the focus is\n // if it is in the trigger (this function) then it spawns the submenu and focuses the first item\n // if it is in a menu item, it activates the item and closes the menu, triggering this function again\n // So, why do we need the requestAnimationFrame?\n // pressing enter in an item will focus the trigger\n // -> current react behaviour means the menu button \"keyDown\" event will also trigger with \"Enter\"\n // -> which will open the menu again\n // as of react 18 and 28/october/2025, this requestAnimationFrame prevents the keyDown event from triggering on top of the button\n if (!shouldFocusImmediately.current) {\n requestAnimationFrame(() => {\n node.focus();\n });\n } else {\n // In some cases, like when user presses \"Tab\" within a menu, we want to focus the trigger immediately.\n // So that the tab flow occurs from the trigger to the next focusable element in the page.\n // Therefore, we don't need to wait for the next frame.\n node.focus();\n }\n }\n setReference(node);\n if (innerRef) resolveRef(innerRef, node);\n },\n [innerRef, setReference, shouldFocusImmediately, shouldRefocusTrigger, triggerFocusRequestId],\n );\n\n /*\n * 13th August 2024:\n * https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/\n * With focus on the button:\n * Enter: opens the menu and places focus on the first menu item.\n * Space: Opens the menu and places focus on the first menu item.\n * (Optional) Down Arrow: opens the menu and moves focus to the first menu item.\n * (Optional) Up Arrow: opens the menu and moves focus to the last menu item.\n *\n * Those optional keys assume the menu button sits on a horizontal bar (or on none): the menu opens below the\n * trigger. On a vertical bar Down and Up move between the items of the bar and the menus open to the side, so\n * with `firstOpenAxis: 'vertical'` the same two optional keys are Right Arrow (first item) and Left Arrow (last\n * item), and Down/Up are not used by the trigger at all: they reach the bar.\n */\n const handleTriggerKeyDown = React.useCallback<Required<DSButtonV3T.Props>['onKeyDown']>(\n (event, ...args) => {\n // DSButtonV3 triggers the onClick on Enter and Space, so we don't need to handle it here\n // if (event.key === 'Enter' || event.key === ' ') {\n // onOpinionatedOpen();\n // }\n // a soft-locked trigger still opens with the arrows (opening is not an action of the lock, see toggleMenu);\n // a disabled trigger leaves the page and never gets the key\n if (!disabled) {\n if (firstOpenAxis === 'vertical') {\n if (event.key === 'ArrowRight') onOpinionatedOpen({ reason: 'trigger-arrow-right', event });\n if (event.key === 'ArrowLeft')\n onOpinionatedOpen({ focusLastChild: true, reason: 'trigger-arrow-left', event });\n } else {\n if (event.key === 'ArrowDown') onOpinionatedOpen({ reason: 'trigger-arrow-down', event });\n if (event.key === 'ArrowUp') onOpinionatedOpen({ focusLastChild: true, reason: 'trigger-arrow-up', event });\n }\n }\n if (event.key === 'Escape') {\n // the menu consumes the Escape only when it is open: the event must not also reach an ancestor that closes on\n // Escape (DSDialog, DSModalSlide... React bubbles through portals). A closed menu has nothing to close,\n // so the Escape keeps propagating and the ancestor still gets it.\n if (mutableIsMenuOpen.current) event.stopPropagation();\n onOpinionatedClose({ reason: 'escape', event });\n }\n if (onKeyDown) onKeyDown(event, ...args);\n },\n [firstOpenAxis, disabled, onKeyDown, onOpinionatedOpen, onOpinionatedClose],\n );\n\n return React.useMemo(\n () => ({\n handleTriggerKeyDown,\n handleOnClick,\n handleOnDeliberateActivationWhileSoftLocked,\n handleOnFocus,\n handleFocusIfTriggerIsFocusRegion,\n }),\n [\n handleFocusIfTriggerIsFocusRegion,\n handleOnClick,\n handleOnDeliberateActivationWhileSoftLocked,\n handleOnFocus,\n handleTriggerKeyDown,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAkB;AAClB,wBAA2B;AAC3B,+CAAsD;AACtD,uBAAmC;AAQ5B,MAAM,2BAA2B,CAAC,EAAE,kBAAkB,gBAAgB,MAAsC;AAKjH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,aAAAA,QAAM,WAAW,8EAAqC;AAC1D,QAAM,EAAE,SAAS,SAAS,UAAU,WAAW,SAAS,IAAI;AAC5D,QAAM,EAAE,cAAc,IAAI,iBAAiB;AAC3C,QAAM;AAAA,IACJ,MAAM,EAAE,aAAa;AAAA,EACvB,IAAI;AAGJ,QAAM,iCAAiC,aAAAA,QAAM,OAAO,WAAW;AAC/D,iCAA+B,UAAU;AAKzC,QAAM,mCAAmC,aAAAA,QAAM,OAAO,qBAAqB;AAE3E,QAAM,oBAAoB,aAAAA,QAAM,OAAO,UAAU;AAIjD,oBAAkB,UAAU;AAM5B,QAAM,aAAa,aAAAA,QAAM;AAAA,IACvB,CAAC,MAA8C;AAG7C,UAAI,kBAAkB,SAAS;AAC7B,2BAAmB,EAAE,QAAQ,kBAAkB,OAAO,EAAE,CAAC;AAAA,MAC3D,OAAO;AACL,0BAAkB,EAAE,QAAQ,iBAAiB,OAAO,EAAE,CAAC;AAAA,MACzD;AAAA,IACF;AAAA,IACA,CAAC,oBAAoB,iBAAiB;AAAA,EACxC;AACA,QAAM,gBAAgB,aAAAA,QAAM;AAAA,IAC1B,CAAC,MAAM,SAAS;AACd,UAAI,QAAS,SAAQ,GAAG,GAAG,IAAI;AAC/B,iBAAW,CAAC;AAAA,IACd;AAAA,IACA,CAAC,SAAS,UAAU;AAAA,EACtB;AACA,QAAM,8CAA8C,aAAAA,QAAM,YAExD,CAAC,MAAM,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC;AACpC,QAAM,gBAAgB,aAAAA,QAAM;AAAA,IAC1B,CAAC,MAAM,SAAS;AACd,UAAI,+BAA+B,YAAY,oCAAmB;AAIhE,0BAAkB,EAAE,wBAAwB,OAAO,gBAAgB,MAAM,CAAC;AAC5E,UAAI,QAAS,SAAQ,GAAG,GAAG,IAAI;AAAA,IACjC;AAAA,IACA,CAAC,SAAS,iBAAiB;AAAA,EAC7B;AAEA,QAAM,oCAAoC,aAAAA,QAAM;AAAA,IAC9C,CAAC,SAAS;AACR,YAAM,2BAA2B,iCAAiC,YAAY;AAC9E,UAAI,QAAQ,yBAA0B,kCAAiC,UAAU;AACjF,UAAI,QAAQ,4BAA4B,qBAAqB,SAAS;AASpE,YAAI,CAAC,uBAAuB,SAAS;AACnC,gCAAsB,MAAM;AAC1B,iBAAK,MAAM;AAAA,UACb,CAAC;AAAA,QACH,OAAO;AAIL,eAAK,MAAM;AAAA,QACb;AAAA,MACF;AACA,mBAAa,IAAI;AACjB,UAAI,SAAU,mCAAW,UAAU,IAAI;AAAA,IACzC;AAAA,IACA,CAAC,UAAU,cAAc,wBAAwB,sBAAsB,qBAAqB;AAAA,EAC9F;AAgBA,QAAM,uBAAuB,aAAAA,QAAM;AAAA,IACjC,CAAC,UAAU,SAAS;AAOlB,UAAI,CAAC,UAAU;AACb,YAAI,kBAAkB,YAAY;AAChC,cAAI,MAAM,QAAQ,aAAc,mBAAkB,EAAE,QAAQ,uBAAuB,MAAM,CAAC;AAC1F,cAAI,MAAM,QAAQ;AAChB,8BAAkB,EAAE,gBAAgB,MAAM,QAAQ,sBAAsB,MAAM,CAAC;AAAA,QACnF,OAAO;AACL,cAAI,MAAM,QAAQ,YAAa,mBAAkB,EAAE,QAAQ,sBAAsB,MAAM,CAAC;AACxF,cAAI,MAAM,QAAQ,UAAW,mBAAkB,EAAE,gBAAgB,MAAM,QAAQ,oBAAoB,MAAM,CAAC;AAAA,QAC5G;AAAA,MACF;AACA,UAAI,MAAM,QAAQ,UAAU;AAI1B,YAAI,kBAAkB,QAAS,OAAM,gBAAgB;AACrD,2BAAmB,EAAE,QAAQ,UAAU,MAAM,CAAC;AAAA,MAChD;AACA,UAAI,UAAW,WAAU,OAAO,GAAG,IAAI;AAAA,IACzC;AAAA,IACA,CAAC,eAAe,UAAU,WAAW,mBAAmB,kBAAkB;AAAA,EAC5E;AAEA,SAAO,aAAAA,QAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -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 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';\nimport type { DSHookFloatingContextT } from '@elliemae/ds-floating-context';\n\nimport { DSMenuButtonName, MENU_BUTTON_SLOTS, type MENU_ITEMS_TYPES } from './constants/index.js';\nexport declare namespace DSMenuButtonT {\n /* *******************************************************\n * Slot function-form prop arguments \u2014 one entry per slot in MENU_BUTTON_SLOTS.\n * Backs the typescript-testing/slot-props.ts exhaustiveness check.\n ******************************************************* */\n export type SlotFunctionArguments = {\n dsMenubuttonRoot: () => object;\n };\n\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\n /* **************************************************************************************************************\n *********************************** POLYMORPHIC INTERFACES FOR MENU ITEMS *************************************\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 maxHeight?: string | number; // was available in dropdownmenu-v2, have to provide for retrocompatibility\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 maxHeight?: string | number; // was available in dropdownmenu-v2, have to provide for retrocompatibility\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 maxHeight?: string | number; // was available in dropdownmenu-v2, have to provide for retrocompatibility\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 maxHeight?: string | number; // was available in dropdownmenu-v2, have to provide for retrocompatibility\n disabled?: boolean;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => null;\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 maxHeight: string | number; // was available in dropdownmenu-v2, have to provide for retrocompatibility\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 | SingleSelectItem\n | SingleSelectWithSubmenuItem;\n\n export type PseudoFocusableItemInterface =\n | ActivableItem\n | ActionableWithSubmenuItem\n | SkeletonItem\n | MultipleSelectItem\n | MultiSelectWithSubmenuItem\n | WithSubmenuItem\n | SingleSelectItem\n | SingleSelectWithSubmenuItem;\n\n export type SelectionableMenuItemInterface =\n MultipleSelectItem | MultiSelectWithSubmenuItem | SingleSelectItem | SingleSelectWithSubmenuItem;\n\n /* **************************************************************************************************************\n *************************** POLYMORPHIC INTERFACES FOR ITEMS USING DSTREE *************************************\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 SelectionableMenuNodes =\n | DSMenuButtonT.MenuNodeMultipleSelectItem\n | DSMenuButtonT.MenuNodeMultipleSelectWithSubmenuItem\n | DSMenuButtonT.MenuNodeSingleSelectItem\n | DSMenuButtonT.MenuNodeSingleSelectWithSubmenuItem;\n\n export type MultipleSelectionableMenuNodes =\n DSMenuButtonT.MenuNodeMultipleSelectItem | DSMenuButtonT.MenuNodeMultipleSelectWithSubmenuItem;\n\n export type SingleSelectionableMenuNodes =\n DSMenuButtonT.MenuNodeSingleSelectItem | 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 | DSMenuButtonT.MenuNodeSingleSelectWithSubmenuItem;\n\n /* **************************************************************************************************************\n ********************************** PROPS/INTERNAL PROPS DEFINITIONS *******************************************\n ************************************************************************************************************** */\n\n export type ItemRendererT = React.ComponentType<{ itemNode: MenuNode }>;\n\n /* **************************************************************************************************************\n ******************************************* \"REQUIRED\" PROPS **************************************************\n ************************************************************************************************************** */\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 export interface MenuBehaviouralLayerRequiredProps {}\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, ButtonInheritedRequiredProps, 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 ******************************************** \"DEFAULT\" PROPS **************************************************\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 /*\n * The keys that open the menu from the trigger, by the axis of the bar the menu button sits on (the first open: a\n * click, Enter and Space open it on any axis).\n * - 'horizontal' (default): Down Arrow opens the menu with the focus on the first item, Up Arrow on the last one\n * (APG: optional keys of the menu button). Left and Right are not used by the trigger.\n * - 'vertical': the menu button is an item of a vertical bar, where Down and Up move between the items of the bar\n * and the menus open to the side. Right Arrow opens the menu with the focus on the first item, Left Arrow on\n * the last one. Down and Up are not used by the trigger: they reach the bar.\n */\n firstOpenAxis: FirstOpenAxis;\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 maxHeight: string | number; // was available in dropdownmenu-v2, have to provide for retrocompatibility\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, ButtonInheiredDefaultProps, MenuBehaviouralLayerDefaultProps {}\n\n /* **************************************************************************************************************\n ******************************************* \"OPTIONAL\" PROPS **************************************************\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 type MenuOpenReason =\n 'trigger-click' | 'trigger-arrow-down' | 'trigger-arrow-up' | 'trigger-arrow-right' | 'trigger-arrow-left';\n // the axis of the bar the menu button sits on, which decides the keys of the first open (see `firstOpenAxis`)\n export type FirstOpenAxis = 'horizontal' | 'vertical';\n export type MenuCloseReason =\n 'outside-click' | 'window-blur' | 'escape' | 'tab' | 'item-activation' | 'trigger-toggle';\n export interface MenuOpenMetainfo {\n reason: MenuOpenReason;\n event?: React.SyntheticEvent;\n }\n export interface MenuCloseMetainfo {\n reason: MenuCloseReason;\n event?: React.SyntheticEvent | MouseEvent | TouchEvent | FocusEvent;\n }\n export interface ItemKeyDownMetainfo {\n // the node of the focused item; `itemNode.plainItem` is the item as the consumer provided it\n itemNode: PseudoFocusableMenuNodes;\n event: React.KeyboardEvent;\n // how many submenus deep the focused item is: 0 is an item of the main menu (not inside a submenu), 1 is an item\n // inside a first-level submenu, and so on. Groups do not count, they do not open a menu of their own\n nestLevel: number;\n // the focused item opens a submenu (a disabled item that has one included)\n hasSubmenu: boolean;\n }\n export interface MenuBehaviouralLayerOptionalProps {\n // **********************************************************************************************\n // IoC Pattern\n // - in scenarios where not \"selectionable\" items are present,\n // - the \"selectedItems\" prop is not required\n // - the \"onItemSelected\" prop is not required\n // - in scenarios where no \"activation\" items are present,\n // - the \"onActivateItem\" prop is not required\n // AFAIK Typescipt doesn't support this kind of \"conditional\" required props\n // so we will rely on javascript error throwing to handle this + documentation\n // **********************************************************************************************\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 // both carry the intent that triggered them (`reason`) and the originating event, so consumers that own the\n // open state (a11yDangerouslyConsumerOwnedMenuOpenState) can tell WHY the widget asks to open/close\n onOpen?: (metainfo: DSMenuButtonT.MenuOpenMetainfo) => void;\n onClose?: (metainfo: DSMenuButtonT.MenuCloseMetainfo) => void;\n /*\n * A key was pressed with focus on a menu item. The menu-level counterpart of the per-item `onKeyDown`, so one\n * callback covers the whole tree (submenus and skeleton items included).\n * It is called first: after the item's own `onKeyDown`, before the menu handles the key and before it consumes it\n * (`event` is still untouched: not default-prevented, propagation not stopped). It is an observation point: the\n * menu still does what it does with the key. Tab is not reported, it is handled at the root of the menu.\n * Why it exists: Left and Right Arrow are consumed on every item (see the keyboard section of the documentation),\n * so they never bubble out of the menu. A host that wants menubar behaviour (Right/Left moves to the neighbour\n * menu) cannot get them from bubbling: it reads them here, together with `nestLevel` and `hasSubmenu`, which\n * tell it whether the key is the menu's own (Right on an item with a submenu, Left inside a submenu) or free.\n */\n onItemKeyDown?: (metainfo: DSMenuButtonT.ItemKeyDownMetainfo) => void;\n /*\n * Escape hatch \u2014 when a boolean is provided the consumer OWNS the menu open state\n * and the widget's internal open bookkeeping degrades to an *intent* signal:\n * `onOpen`/`onClose` fire for each open/close intent that changes the effective state (trigger click, Escape,\n * click-outside, item activation, window blur; an intent that matches the current state, like a close\n * while closed, is ignored) and the consumer is expected to sync this prop accordingly or the menu will\n * not reflect the requested state.\n * Reaching for it invalidates the widget's open-state-related a11y guarantees\n * (focus is still returned/tracked on intent, not on the effective transition \u2014\n * if the consumer does not flip the prop, focus can leave a panel that stays open).\n * Named \"long on purpose\": it must not be missable when skimming code.\n */\n a11yDangerouslyConsumerOwnedMenuOpenState?: boolean;\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 floatingConfig?: Partial<Omit<DSHookFloatingContextT.Props, 'externallyControlledIsOpen' | 'onOpen' | 'onClose'>>;\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\n MenuSpecificOptionalProps,\n ButtonInheritedOptionalProps,\n // we convert the (selected) options to a Nodes as part of the widget's logic\n MenuBehaviouralLayerOptionalProps,\n TypescriptHelpersT.PropsForGlobalOnSlots<typeof DSMenuButtonName, typeof MENU_BUTTON_SLOTS> {\n // we convert the (selected) options to a Nodes as part of the widget's logic\n selectedItems?: SelectionableMenuNodes[] | SelectionableMenuItemInterface[];\n }\n\n /* **************************************************************************************************************\n ************************************************ PROPS *******************************************************\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\n Partial<MenuBehaviouralLayerDefaultProps>,\n MenuBehaviouralLayerOptionalProps,\n MenuBehaviouralLayerRequiredProps {}\n export interface MenuSpecificProps\n extends Partial<MenuSpecifiDefaultProps>, MenuSpecificOptionalProps, 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\n extends\n RequiredProps,\n Partial<DefaultProps>,\n OptionalProps,\n // the global and xstyled props are only part of \"props\"/\"internalProps\" in our namespaces\n // to properly inherith button's global & xstyled props, we need to also include the following\n Omit<DSButtonV3T.Props, keyof RequiredProps | keyof DefaultProps | keyof OptionalProps> {}\n\n /* **************************************************************************************************************\n ******************************************** INTERNAL PROPS ***************************************************\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, MenuBehaviouralLayerOptionalProps, MenuBehaviouralLayerRequiredProps {}\n export interface MenuSpecificInternalProps\n extends MenuSpecifiDefaultProps, MenuSpecificOptionalProps, 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\n extends\n RequiredProps,\n DefaultProps,\n OptionalProps,\n // the global and xstyled props are only part of \"props\"/\"internalProps\" in our namespaces\n // to properly inherith button's global & xstyled props, we need to also include the following\n Omit<DSButtonV3T.Props, keyof RequiredProps | keyof DefaultProps | keyof OptionalProps> {}\n}\n\nexport const menuSpecificDefaultProps: DSMenuButtonT.MenuSpecifiDefaultProps = {\n firstOpenAxis: 'horizontal',\n onClickOutside: () => null,\n onOptionClick: () => null,\n openedSubmenus: {},\n onSubmenuToggle: () => null,\n isLoading: false,\n isSkeleton: false,\n maxHeight: '256px', // was available in dropdownmenu-v2, have to provide for retrocompatibility\n};\n/* *******************************************************\n * We are building a widget composed of 3 ATOMIC composition components\n * - Button\n * - Menu\n * - Behavioural Layer\n * The final API facing the users is a sum of all 3 interfaces\n * THOSE INTERFACES ARE NOT EQUAL TO THE FINAL \"PARTS\" INTERFACES\n * The widget embeds \"assumptions\" (as all widgets do) that are AGNOSTIC to the \"parts\" interfaces\n * The \"Parts\" interfaces \"mostly\" inherit the following interfaces, but with meaningful meant and planned differences\n * (E.G. the widget accepts an array of options, but the Menu part accepts a DSTree only)\n ******************************************************* */\nexport const MenuBehaviouralLayerPropTypes: DSPropTypesSchema<DSMenuButtonT.MenuBehaviouralLayerProps> = {\n onItemSelected: PropTypes.func.description(\n 'IoC function in charge of handling the selection of a menu item, required if the menu has selectionable items',\n ).signature(`((\n newSelection: DSMenuButtonT.PseudoFocusableMenuNodes[],\n metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event?: React.SyntheticEvent },\n ) => void)`),\n\n onActivateItem: PropTypes.func.description(\n 'IoC function in charge of handling the activation (NOT INVOKED ON SELECTION) of a menu item, required if the menu has activable items',\n ).signature(`((\n itemNode: DSMenuButtonT.PseudoFocusableMenuNodes,\n metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event?: React.SyntheticEvent },\n ) => void)`),\n\n onOpen: PropTypes.func\n .description('function triggered when the widget opens the menu, with the reason (intent) that triggered it')\n .signature(\n `((metainfo: { reason: 'trigger-click' | 'trigger-arrow-down' | 'trigger-arrow-up' | 'trigger-arrow-right' | 'trigger-arrow-left'; event?: React.SyntheticEvent }) => void)`,\n ),\n onClose: PropTypes.func\n .description('function triggered when the widget closes the menu, with the reason (intent) that triggered it')\n .signature(\n `((metainfo: { reason: 'outside-click' | 'window-blur' | 'escape' | 'tab' | 'item-activation' | 'trigger-toggle'; event?: React.SyntheticEvent | MouseEvent | TouchEvent | FocusEvent }) => void)`,\n ),\n onItemKeyDown: PropTypes.func\n .description(\n 'Function triggered when a key is pressed with focus on a menu item, before the menu handles or consumes it (Tab is not reported). `nestLevel` is how many submenus deep the item is (0: an item of the main menu), `hasSubmenu` tells whether the item opens a submenu. Left and Right Arrow never bubble out of the menu, this is how a host implements menubar behaviour',\n )\n .signature(\n `((metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event: React.KeyboardEvent; nestLevel: number; hasSubmenu: boolean }) => void)`,\n ),\n a11yDangerouslyConsumerOwnedMenuOpenState: PropTypes.bool.description(\n 'Escape hatch: when a boolean is provided, the consumer owns the menu open state; onOpen/onClose fire for each intent that changes the effective state, and the consumer is expected to sync the prop from them. Invalidates the open-state-related a11y guarantees of the widget',\n ),\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 firstOpenAxis: PropTypes.oneOf(['horizontal', 'vertical'])\n .description(\n \"The axis of the bar the menu button sits on, which decides the keys that open the menu from the trigger. 'horizontal': Down Arrow opens it with the focus on the first item and Up Arrow on the last one. 'vertical': Right Arrow opens it with the focus on the first item and Left Arrow on the last one, and Down and Up are left to the bar. A click, Enter and Space open it on any axis\",\n )\n .defaultValue('horizontal'),\n onClickOutside: PropTypes.func\n .description('Callback executed when you click outside the dropdown menu, or press the Esc key')\n .defaultValue(() => null),\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 maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number])\n .description('The maximum height of the flyout menu')\n .defaultValue('256px'),\n floatingConfig: PropTypes.object.description(\n 'Configuration object for the floating context (placement, placementOrderPreference, customOffset, animationDuration, withoutPortal, withoutAnimation, portalDOMContainer)',\n ),\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 selectedItems: PropTypes.arrayOf(PropTypes.object).description(\n 'an array of tree-nodes or tree-items that have to be marked as selected in the GUI, required if the menu has selectionable items',\n ),\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;AAOpC,uBAA2E;
|
|
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';\nimport type { DSHookFloatingContextT } from '@elliemae/ds-floating-context';\n\nimport { DSMenuButtonName, MENU_BUTTON_SLOTS, type MENU_ITEMS_TYPES } from './constants/index.js';\nexport declare namespace DSMenuButtonT {\n /* *******************************************************\n * Slot function-form prop arguments \u2014 one entry per slot in MENU_BUTTON_SLOTS.\n * Backs the typescript-testing/slot-props.ts exhaustiveness check.\n ******************************************************* */\n export type SlotFunctionArguments = {\n dsMenubuttonRoot: () => object;\n };\n\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\n /* **************************************************************************************************************\n *********************************** POLYMORPHIC INTERFACES FOR MENU ITEMS *************************************\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 maxHeight?: string | number; // was available in dropdownmenu-v2, have to provide for retrocompatibility\n label?: undefined;\n secondaryLabel?: undefined;\n leftDecoration?: undefined;\n minWidth?: undefined;\n disabled?: undefined;\n applyAriaDisabled?: 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 applyAriaDisabled?: 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 /**\n * Whether to apply disabled styling and announce as disabled in SR.\n * CAN STILL RECEIVE FOCUS. IGNORES EVERY ACTION (click, Enter, Space) AND THE ITEM'S onClick FOR THEM.\n */\n applyAriaDisabled?: 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 maxHeight?: string | number; // was available in dropdownmenu-v2, have to provide for retrocompatibility\n disabled?: boolean;\n /**\n * Whether to apply disabled styling and announce as disabled in SR.\n * CAN STILL RECEIVE FOCUS. IGNORES EVERY ACTION (click, Enter, Space) AND THE ITEM'S onClick FOR THEM.\n * Opening its submenu is not an action: a soft-locked item still opens it, and what is inside is locked on its own.\n */\n applyAriaDisabled?: 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 applyAriaDisabled?: 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 /**\n * Whether to apply disabled styling and announce as disabled in SR.\n * CAN STILL RECEIVE FOCUS. IGNORES EVERY ACTION (click, Enter, Space) AND THE ITEM'S onClick FOR THEM.\n */\n applyAriaDisabled?: 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 maxHeight?: string | number; // was available in dropdownmenu-v2, have to provide for retrocompatibility\n disabled?: boolean;\n /**\n * Whether to apply disabled styling and announce as disabled in SR.\n * CAN STILL RECEIVE FOCUS. IGNORES EVERY ACTION (click, Enter, Space) AND THE ITEM'S onClick FOR THEM.\n * Opening its submenu is not an action: a soft-locked item still opens it, and what is inside is locked on its own.\n */\n applyAriaDisabled?: 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 maxHeight?: string | number; // was available in dropdownmenu-v2, have to provide for retrocompatibility\n disabled?: boolean;\n /**\n * Whether to apply disabled styling and announce as disabled in SR.\n * CAN STILL RECEIVE FOCUS. IGNORES EVERY ACTION (click, Enter, Space) AND THE ITEM'S onClick FOR THEM.\n * Opening its submenu is not an action: a soft-locked item still opens it, and what is inside is locked on its own.\n */\n applyAriaDisabled?: boolean;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => null;\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 /**\n * Whether to apply disabled styling and announce as disabled in SR.\n * CAN STILL RECEIVE FOCUS. IGNORES EVERY ACTION (click, Enter, Space) AND THE ITEM'S onClick FOR THEM.\n */\n applyAriaDisabled?: 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 maxHeight: string | number; // was available in dropdownmenu-v2, have to provide for retrocompatibility\n disabled?: boolean;\n /**\n * Whether to apply disabled styling and announce as disabled in SR.\n * CAN STILL RECEIVE FOCUS. IGNORES EVERY ACTION (click, Enter, Space) AND THE ITEM'S onClick FOR THEM.\n * Opening its submenu is not an action: a soft-locked item still opens it, and what is inside is locked on its own.\n */\n applyAriaDisabled?: 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 | SingleSelectItem\n | SingleSelectWithSubmenuItem;\n\n export type PseudoFocusableItemInterface =\n | ActivableItem\n | ActionableWithSubmenuItem\n | SkeletonItem\n | MultipleSelectItem\n | MultiSelectWithSubmenuItem\n | WithSubmenuItem\n | SingleSelectItem\n | SingleSelectWithSubmenuItem;\n\n export type SelectionableMenuItemInterface =\n MultipleSelectItem | MultiSelectWithSubmenuItem | SingleSelectItem | SingleSelectWithSubmenuItem;\n\n /* **************************************************************************************************************\n *************************** POLYMORPHIC INTERFACES FOR ITEMS USING DSTREE *************************************\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 SelectionableMenuNodes =\n | DSMenuButtonT.MenuNodeMultipleSelectItem\n | DSMenuButtonT.MenuNodeMultipleSelectWithSubmenuItem\n | DSMenuButtonT.MenuNodeSingleSelectItem\n | DSMenuButtonT.MenuNodeSingleSelectWithSubmenuItem;\n\n export type MultipleSelectionableMenuNodes =\n DSMenuButtonT.MenuNodeMultipleSelectItem | DSMenuButtonT.MenuNodeMultipleSelectWithSubmenuItem;\n\n export type SingleSelectionableMenuNodes =\n DSMenuButtonT.MenuNodeSingleSelectItem | 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 | DSMenuButtonT.MenuNodeSingleSelectWithSubmenuItem;\n\n /* **************************************************************************************************************\n ********************************** PROPS/INTERNAL PROPS DEFINITIONS *******************************************\n ************************************************************************************************************** */\n\n export type ItemRendererT = React.ComponentType<{ itemNode: MenuNode }>;\n\n /* **************************************************************************************************************\n ******************************************* \"REQUIRED\" PROPS **************************************************\n ************************************************************************************************************** */\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 export interface MenuBehaviouralLayerRequiredProps {}\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, ButtonInheritedRequiredProps, 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 ******************************************** \"DEFAULT\" PROPS **************************************************\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 /*\n * The keys that open the menu from the trigger, by the axis of the bar the menu button sits on (the first open: a\n * click, Enter and Space open it on any axis).\n * - 'horizontal' (default): Down Arrow opens the menu with the focus on the first item, Up Arrow on the last one\n * (APG: optional keys of the menu button). Left and Right are not used by the trigger.\n * - 'vertical': the menu button is an item of a vertical bar, where Down and Up move between the items of the bar\n * and the menus open to the side. Right Arrow opens the menu with the focus on the first item, Left Arrow on\n * the last one. Down and Up are not used by the trigger: they reach the bar.\n */\n firstOpenAxis: FirstOpenAxis;\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 maxHeight: string | number; // was available in dropdownmenu-v2, have to provide for retrocompatibility\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, ButtonInheiredDefaultProps, MenuBehaviouralLayerDefaultProps {}\n\n /* **************************************************************************************************************\n ******************************************* \"OPTIONAL\" PROPS **************************************************\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 type MenuOpenReason =\n 'trigger-click' | 'trigger-arrow-down' | 'trigger-arrow-up' | 'trigger-arrow-right' | 'trigger-arrow-left';\n // the axis of the bar the menu button sits on, which decides the keys of the first open (see `firstOpenAxis`)\n export type FirstOpenAxis = 'horizontal' | 'vertical';\n export type MenuCloseReason =\n 'outside-click' | 'window-blur' | 'escape' | 'tab' | 'item-activation' | 'trigger-toggle';\n export interface MenuOpenMetainfo {\n reason: MenuOpenReason;\n event?: React.SyntheticEvent;\n }\n export interface MenuCloseMetainfo {\n reason: MenuCloseReason;\n event?: React.SyntheticEvent | MouseEvent | TouchEvent | FocusEvent;\n }\n export interface ItemKeyDownMetainfo {\n // the node of the focused item; `itemNode.plainItem` is the item as the consumer provided it\n itemNode: PseudoFocusableMenuNodes;\n event: React.KeyboardEvent;\n // how many submenus deep the focused item is: 0 is an item of the main menu (not inside a submenu), 1 is an item\n // inside a first-level submenu, and so on. Groups do not count, they do not open a menu of their own\n nestLevel: number;\n // the focused item opens a submenu (a disabled item that has one included)\n hasSubmenu: boolean;\n }\n export interface MenuBehaviouralLayerOptionalProps {\n // **********************************************************************************************\n // IoC Pattern\n // - in scenarios where not \"selectionable\" items are present,\n // - the \"selectedItems\" prop is not required\n // - the \"onItemSelected\" prop is not required\n // - in scenarios where no \"activation\" items are present,\n // - the \"onActivateItem\" prop is not required\n // AFAIK Typescipt doesn't support this kind of \"conditional\" required props\n // so we will rely on javascript error throwing to handle this + documentation\n // **********************************************************************************************\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 // both carry the intent that triggered them (`reason`) and the originating event, so consumers that own the\n // open state (a11yDangerouslyConsumerOwnedMenuOpenState) can tell WHY the widget asks to open/close\n onOpen?: (metainfo: DSMenuButtonT.MenuOpenMetainfo) => void;\n onClose?: (metainfo: DSMenuButtonT.MenuCloseMetainfo) => void;\n /*\n * A key was pressed with focus on a menu item. The menu-level counterpart of the per-item `onKeyDown`, so one\n * callback covers the whole tree (submenus and skeleton items included).\n * It is called first: after the item's own `onKeyDown`, before the menu handles the key and before it consumes it\n * (`event` is still untouched: not default-prevented, propagation not stopped). It is an observation point: the\n * menu still does what it does with the key. Tab is not reported, it is handled at the root of the menu.\n * Why it exists: Left and Right Arrow are consumed on every item (see the keyboard section of the documentation),\n * so they never bubble out of the menu. A host that wants menubar behaviour (Right/Left moves to the neighbour\n * menu) cannot get them from bubbling: it reads them here, together with `nestLevel` and `hasSubmenu`, which\n * tell it whether the key is the menu's own (Right on an item with a submenu, Left inside a submenu) or free.\n */\n onItemKeyDown?: (metainfo: DSMenuButtonT.ItemKeyDownMetainfo) => void;\n /*\n * Escape hatch \u2014 when a boolean is provided the consumer OWNS the menu open state\n * and the widget's internal open bookkeeping degrades to an *intent* signal:\n * `onOpen`/`onClose` fire for each open/close intent that changes the effective state (trigger click, Escape,\n * click-outside, item activation, window blur; an intent that matches the current state, like a close\n * while closed, is ignored) and the consumer is expected to sync this prop accordingly or the menu will\n * not reflect the requested state.\n * Reaching for it invalidates the widget's open-state-related a11y guarantees\n * (focus is still returned/tracked on intent, not on the effective transition \u2014\n * if the consumer does not flip the prop, focus can leave a panel that stays open).\n * Named \"long on purpose\": it must not be missable when skimming code.\n */\n a11yDangerouslyConsumerOwnedMenuOpenState?: boolean;\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 floatingConfig?: Partial<Omit<DSHookFloatingContextT.Props, 'externallyControlledIsOpen' | 'onOpen' | 'onClose'>>;\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\n MenuSpecificOptionalProps,\n ButtonInheritedOptionalProps,\n // we convert the (selected) options to a Nodes as part of the widget's logic\n MenuBehaviouralLayerOptionalProps,\n TypescriptHelpersT.PropsForGlobalOnSlots<typeof DSMenuButtonName, typeof MENU_BUTTON_SLOTS> {\n // we convert the (selected) options to a Nodes as part of the widget's logic\n selectedItems?: SelectionableMenuNodes[] | SelectionableMenuItemInterface[];\n }\n\n /* **************************************************************************************************************\n ************************************************ PROPS *******************************************************\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\n Partial<MenuBehaviouralLayerDefaultProps>,\n MenuBehaviouralLayerOptionalProps,\n MenuBehaviouralLayerRequiredProps {}\n export interface MenuSpecificProps\n extends Partial<MenuSpecifiDefaultProps>, MenuSpecificOptionalProps, 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\n extends\n RequiredProps,\n Partial<DefaultProps>,\n OptionalProps,\n // the global and xstyled props are only part of \"props\"/\"internalProps\" in our namespaces\n // to properly inherith button's global & xstyled props, we need to also include the following\n Omit<DSButtonV3T.Props, keyof RequiredProps | keyof DefaultProps | keyof OptionalProps> {}\n\n /* **************************************************************************************************************\n ******************************************** INTERNAL PROPS ***************************************************\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, MenuBehaviouralLayerOptionalProps, MenuBehaviouralLayerRequiredProps {}\n export interface MenuSpecificInternalProps\n extends MenuSpecifiDefaultProps, MenuSpecificOptionalProps, 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\n extends\n RequiredProps,\n DefaultProps,\n OptionalProps,\n // the global and xstyled props are only part of \"props\"/\"internalProps\" in our namespaces\n // to properly inherith button's global & xstyled props, we need to also include the following\n Omit<DSButtonV3T.Props, keyof RequiredProps | keyof DefaultProps | keyof OptionalProps> {}\n}\n\nexport const menuSpecificDefaultProps: DSMenuButtonT.MenuSpecifiDefaultProps = {\n firstOpenAxis: 'horizontal',\n onClickOutside: () => null,\n onOptionClick: () => null,\n openedSubmenus: {},\n onSubmenuToggle: () => null,\n isLoading: false,\n isSkeleton: false,\n maxHeight: '256px', // was available in dropdownmenu-v2, have to provide for retrocompatibility\n};\n/* *******************************************************\n * We are building a widget composed of 3 ATOMIC composition components\n * - Button\n * - Menu\n * - Behavioural Layer\n * The final API facing the users is a sum of all 3 interfaces\n * THOSE INTERFACES ARE NOT EQUAL TO THE FINAL \"PARTS\" INTERFACES\n * The widget embeds \"assumptions\" (as all widgets do) that are AGNOSTIC to the \"parts\" interfaces\n * The \"Parts\" interfaces \"mostly\" inherit the following interfaces, but with meaningful meant and planned differences\n * (E.G. the widget accepts an array of options, but the Menu part accepts a DSTree only)\n ******************************************************* */\nexport const MenuBehaviouralLayerPropTypes: DSPropTypesSchema<DSMenuButtonT.MenuBehaviouralLayerProps> = {\n onItemSelected: PropTypes.func.description(\n 'IoC function in charge of handling the selection of a menu item, required if the menu has selectionable items',\n ).signature(`((\n newSelection: DSMenuButtonT.PseudoFocusableMenuNodes[],\n metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event?: React.SyntheticEvent },\n ) => void)`),\n\n onActivateItem: PropTypes.func.description(\n 'IoC function in charge of handling the activation (NOT INVOKED ON SELECTION) of a menu item, required if the menu has activable items',\n ).signature(`((\n itemNode: DSMenuButtonT.PseudoFocusableMenuNodes,\n metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event?: React.SyntheticEvent },\n ) => void)`),\n\n onOpen: PropTypes.func\n .description('function triggered when the widget opens the menu, with the reason (intent) that triggered it')\n .signature(\n `((metainfo: { reason: 'trigger-click' | 'trigger-arrow-down' | 'trigger-arrow-up' | 'trigger-arrow-right' | 'trigger-arrow-left'; event?: React.SyntheticEvent }) => void)`,\n ),\n onClose: PropTypes.func\n .description('function triggered when the widget closes the menu, with the reason (intent) that triggered it')\n .signature(\n `((metainfo: { reason: 'outside-click' | 'window-blur' | 'escape' | 'tab' | 'item-activation' | 'trigger-toggle'; event?: React.SyntheticEvent | MouseEvent | TouchEvent | FocusEvent }) => void)`,\n ),\n onItemKeyDown: PropTypes.func\n .description(\n 'Function triggered when a key is pressed with focus on a menu item, before the menu handles or consumes it (Tab is not reported). `nestLevel` is how many submenus deep the item is (0: an item of the main menu), `hasSubmenu` tells whether the item opens a submenu. Left and Right Arrow never bubble out of the menu, this is how a host implements menubar behaviour',\n )\n .signature(\n `((metainfo: { itemNode: DSMenuButtonT.PseudoFocusableMenuNodes; event: React.KeyboardEvent; nestLevel: number; hasSubmenu: boolean }) => void)`,\n ),\n a11yDangerouslyConsumerOwnedMenuOpenState: PropTypes.bool.description(\n 'Escape hatch: when a boolean is provided, the consumer owns the menu open state; onOpen/onClose fire for each intent that changes the effective state, and the consumer is expected to sync the prop from them. Invalidates the open-state-related a11y guarantees of the widget',\n ),\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 firstOpenAxis: PropTypes.oneOf(['horizontal', 'vertical'])\n .description(\n \"The axis of the bar the menu button sits on, which decides the keys that open the menu from the trigger. 'horizontal': Down Arrow opens it with the focus on the first item and Up Arrow on the last one. 'vertical': Right Arrow opens it with the focus on the first item and Left Arrow on the last one, and Down and Up are left to the bar. A click, Enter and Space open it on any axis\",\n )\n .defaultValue('horizontal'),\n onClickOutside: PropTypes.func\n .description('Callback executed when you click outside the dropdown menu, or press the Esc key')\n .defaultValue(() => null),\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 maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number])\n .description('The maximum height of the flyout menu')\n .defaultValue('256px'),\n floatingConfig: PropTypes.object.description(\n 'Configuration object for the floating context (placement, placementOrderPreference, customOffset, animationDuration, withoutPortal, withoutAnimation, portalDOMContainer)',\n ),\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 selectedItems: PropTypes.arrayOf(PropTypes.object).description(\n 'an array of tree-nodes or tree-items that have to be marked as selected in the GUI, required if the menu has selectionable items',\n ),\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;AAOpC,uBAA2E;AA4jBpE,MAAM,2BAAkE;AAAA,EAC7E,eAAe;AAAA,EACf,gBAAgB,MAAM;AAAA,EACtB,eAAe,MAAM;AAAA,EACrB,gBAAgB,CAAC;AAAA,EACjB,iBAAiB,MAAM;AAAA,EACvB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA;AACb;AAYO,MAAM,gCAA4F;AAAA,EACvG,gBAAgB,kCAAU,KAAK;AAAA,IAC7B;AAAA,EACF,EAAE,UAAU;AAAA;AAAA;AAAA,eAGC;AAAA,EAEb,gBAAgB,kCAAU,KAAK;AAAA,IAC7B;AAAA,EACF,EAAE,UAAU;AAAA;AAAA;AAAA,eAGC;AAAA,EAEb,QAAQ,kCAAU,KACf,YAAY,+FAA+F,EAC3G;AAAA,IACC;AAAA,EACF;AAAA,EACF,SAAS,kCAAU,KAChB,YAAY,gGAAgG,EAC5G;AAAA,IACC;AAAA,EACF;AAAA,EACF,eAAe,kCAAU,KACtB;AAAA,IACC;AAAA,EACF,EACC;AAAA,IACC;AAAA,EACF;AAAA,EACF,2CAA2C,kCAAU,KAAK;AAAA,IACxD;AAAA,EACF;AAAA,EACA,0BAA0B,kCAAU,KAAK,YAAY,gEAAgE,EAClH,UAAU;AAAA;AAAA;AAAA,eAGA;AACf;AAEO,MAAM,0BAA8E;AAAA,EACzF,cAAc,kCAAU,KAAK,YAAY,0CAA0C;AAAA,EACnF,eAAe,kCAAU,MAAM,CAAC,cAAc,UAAU,CAAC,EACtD;AAAA,IACC;AAAA,EACF,EACC,aAAa,YAAY;AAAA,EAC5B,gBAAgB,kCAAU,KACvB,YAAY,kFAAkF,EAC9F,aAAa,MAAM,IAAI;AAAA,EAC1B,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;AAAA,EAC/G,WAAW,kCAAU,UAAU,CAAC,kCAAU,QAAQ,kCAAU,MAAM,CAAC,EAChE,YAAY,uCAAuC,EACnD,aAAa,OAAO;AAAA,EACvB,gBAAgB,kCAAU,OAAO;AAAA,IAC/B;AAAA,EACF;AACF;AAEO,MAAM,wBAAgE;AAAA,EAC3E,SAAS,kCAAU,UAAU,CAAC,kCAAU,OAAO,kCAAU,MAAM,CAAC,EAAE;AAAA,IAChE;AAAA,EACF,EAAE;AAAA,EACF,eAAe,kCAAU,QAAQ,kCAAU,MAAM,EAAE;AAAA,IACjD;AAAA,EACF;AAAA,EACA,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,OAAG,kDAAyB,mCAAkB,kCAAiB;AACjE;AAEO,MAAM,8BAA8B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -36,6 +36,8 @@ __export(nodesTypeguardsAndGetters_exports, {
|
|
|
36
36
|
isActivableWithSubmenuNode: () => isActivableWithSubmenuNode,
|
|
37
37
|
isFocusableNode: () => isFocusableNode,
|
|
38
38
|
isGroup: () => isGroup,
|
|
39
|
+
isItemDisabled: () => isItemDisabled,
|
|
40
|
+
isItemLocked: () => isItemLocked,
|
|
39
41
|
isMenuNodeAllowedToHaveChildren: () => isMenuNodeAllowedToHaveChildren,
|
|
40
42
|
isMultipleSelectNode: () => isMultipleSelectNode,
|
|
41
43
|
isMultipleSelectOnlyNode: () => isMultipleSelectOnlyNode,
|
|
@@ -54,6 +56,7 @@ __export(nodesTypeguardsAndGetters_exports, {
|
|
|
54
56
|
});
|
|
55
57
|
module.exports = __toCommonJS(nodesTypeguardsAndGetters_exports);
|
|
56
58
|
var React = __toESM(require("react"));
|
|
59
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
57
60
|
var import_constants = require("../constants/index.js");
|
|
58
61
|
const isObjectAMenuNode = (item) => {
|
|
59
62
|
const node = item;
|
|
@@ -88,4 +91,10 @@ const getAriaSetSizeAndPosInSetBySiblingList = (siblingNodes) => {
|
|
|
88
91
|
return new Map(focusableSiblings.map((node, index) => [node.dsId, { ariaPosInSet: index + 1, ariaSetSize }]));
|
|
89
92
|
};
|
|
90
93
|
const isMenuNodeAllowedToHaveChildren = (item) => isRootNode(item) || isWithSubmenuNode(item) || isGroup(item) || isSingleSelectNodeWithSubmenu(item) || isMultipleSelectWithSubmenuNode(item) || isActivableWithSubmenuNode(item);
|
|
94
|
+
const isItemLocked = ({
|
|
95
|
+
disabled,
|
|
96
|
+
applyAriaDisabled,
|
|
97
|
+
readOnly
|
|
98
|
+
}) => (0, import_ds_props_helpers.isLocked)({ disabled, applyAriaDisabled, readOnly });
|
|
99
|
+
const isItemDisabled = ({ disabled }) => Boolean(disabled);
|
|
91
100
|
//# sourceMappingURL=nodesTypeguardsAndGetters.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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/**\n * Heuristic to determine if the selected item is an item or a node.\n * Not perfect because JavaScript is not typed.\n * If app devs provide an object that matches all of those conditions, it's an edge case the app devs should handle.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is (heuristically) a menu node, false otherwise.\n */\nexport const isObjectAMenuNode = (item: unknown): item is DSMenuButtonT.MenuNode => {\n const node = item as { plainItem?: { type?: unknown }; dsId?: unknown };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n node.plainItem?.type !== undefined &&\n node.dsId !== undefined\n );\n};\n\n// =============================================================================\n// Focusable nodes\n// =============================================================================\n/**\n * Checks if the item is an activable node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is an activable node, false otherwise.\n */\nexport const isActivableNode = (item: unknown): item is DSMenuButtonT.MenuNodeActivableItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.ACTIVABLE_ITEM;\n\n/**\n * Checks if the item is a skeleton node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a skeleton node, false otherwise.\n */\nexport const isSkeletonNode = (item: unknown): item is DSMenuButtonT.MenuNodeSkeletonItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.SKELETON_ITEM;\n\n// =============================================================================\n// Focusable but more specifically selectable nodes\n// =============================================================================\n\n/**\n * Checks if the item is a multiple select only node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a multiple select only node, false otherwise.\n */\nexport const isMultipleSelectOnlyNode = (item: unknown): item is DSMenuButtonT.MenuNodeMultipleSelectItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.MULTIPLE_SELECT_ITEM;\n\n/**\n * Checks if the item is a multiple select node with a submenu.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a multiple select node with a submenu, false otherwise.\n */\nexport const isMultipleSelectWithSubmenuNode = (\n item: unknown,\n): item is DSMenuButtonT.MenuNodeMultipleSelectWithSubmenuItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.MULTIPLE_SELECT_WITH_SUBMENU_ITEM;\n\n/**\n * Checks if the item is a multiple select node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a multiple select node, false otherwise.\n */\nexport const isMultipleSelectNode = (item: unknown): item is DSMenuButtonT.MultipleSelectionableMenuNodes =>\n isMultipleSelectOnlyNode(item) || isMultipleSelectWithSubmenuNode(item);\n\n/**\n * Checks if the item is a single select only node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a single select only node, false otherwise.\n */\nexport const isSingleSelectOnlyNode = (item: unknown): item is DSMenuButtonT.MenuNodeSingleSelectItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.SINGLE_SELECT_ITEM;\n\n/**\n * Checks if the item is a single select node with a submenu.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a single select node with a submenu, false otherwise.\n */\nexport const isSingleSelectNodeWithSubmenu = (\n item: unknown,\n): item is DSMenuButtonT.MenuNodeSingleSelectWithSubmenuItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.SINGLE_SELECT_WITH_SUBMENU_ITEM;\n\n/**\n * Checks if the item is a single select node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a single select node, false otherwise.\n */\nexport const isSingleSelectNode = (item: unknown): item is DSMenuButtonT.SingleSelectionableMenuNodes =>\n isSingleSelectOnlyNode(item) || isSingleSelectNodeWithSubmenu(item);\n\n/**\n * Checks if the item is a selectionable node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a selectionable node, false otherwise.\n */\nexport const isSelectionableNode = (item: unknown): item is DSMenuButtonT.SelectionableMenuNodes =>\n isMultipleSelectNode(item) || isSingleSelectNode(item);\n\n/**\n * Gets all selectionable nodes from the tree.\n * @param {DSMenuButtonT.MenuNode} tree - The tree to search.\n * @returns {DSMenuButtonT.SelectionableMenuNodes[]} - An array of selectionable nodes.\n */\nexport const getSelectionableNodes = (tree: DSMenuButtonT.MenuNode): DSMenuButtonT.SelectionableMenuNodes[] =>\n tree.flatten().filter(isSelectionableNode);\n// =============================================================================\n// Focusable but more specifically with submenu nodes\n// =============================================================================\n/**\n * Checks if the item is a node with a submenu (and nothing else).\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a node with a submenu, false otherwise.\n */\nexport const isWithSubmenuOnlyNode = (item: unknown): item is DSMenuButtonT.MenuNodeWithSubmenuItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.WITH_SUBMENU_ITEM;\n\n/**\n * Checks if the item is a selectionable node with a submenu.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a selectionable node with a submenu, false otherwise.\n */\nexport const isSelectionableWithSubmenuNode = (\n item: unknown,\n): item is DSMenuButtonT.SelectionablesWithSubmenuMenuNodes =>\n isSingleSelectNodeWithSubmenu(item) || isMultipleSelectWithSubmenuNode(item);\n/**\n * Checks if the item is an activable node with a submenu.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is an activable node with a submenu, false otherwise.\n */\nexport const isActivableWithSubmenuNode = (item: unknown): item is DSMenuButtonT.MenuNodeActivableWithSubmenuItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.ACTIVABLE_WITH_SUBMENU_ITEM;\n\n/**\n * Checks if the item is a node with a submenu.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a node with a submenu, false otherwise.\n */\nexport const isWithSubmenuNode = (item: unknown): item is DSMenuButtonT.WithSubmenuMenuNodes =>\n isWithSubmenuOnlyNode(item) || isSelectionableWithSubmenuNode(item) || isActivableWithSubmenuNode(item);\n\n/**\n * Gets all nodes with a submenu from the tree.\n * @param {DSMenuButtonT.MenuNode} tree - The tree to search.\n * @returns {DSMenuButtonT.PseudoFocusableMenuNodes[]} - An array of nodes with a submenu.\n */\nexport const getWithSubmenuNodes = (tree: DSMenuButtonT.MenuNode): DSMenuButtonT.PseudoFocusableMenuNodes[] =>\n tree.flatten().filter(isWithSubmenuNode);\n/**\n * Checks if the item is a node that can be focused.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a node that can be focused, false otherwise.\n */\nexport const isFocusableNode = (item: unknown): item is DSMenuButtonT.PseudoFocusableMenuNodes =>\n isSelectionableNode(item) || isActivableNode(item) || isWithSubmenuNode(item) || isSkeletonNode(item);\n\n/**\n * Gets all nodes that can be focused from the tree.\n * @param {DSMenuButtonT.MenuNode} tree - The tree to search.\n * @returns {DSMenuButtonT.PseudoFocusableMenuNodes[]} - An array of nodes that can be focused.\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// =============================================================================\n/**\n * Checks if the item is a separator node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a separator node, false otherwise.\n */\nexport const isSeparatorNode = (item: unknown): item is DSMenuButtonT.MenuNodeSeparatorItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.SEPARATOR;\n/**\n * Checks if the item is a group node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a group node, false otherwise.\n */\nexport const isGroup = (item: unknown): item is DSMenuButtonT.MenuNodeGroupItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.GROUP;\n\n/**\n * Checks if the given item is a root node of the menu.\n * @param {DSMenuButtonT.MenuNode} tree - The tree to search.\n * @returns {DSMenuButtonT.PseudoFocusableMenuNodes[]} - An array of nodes that can be focused.\n * @remarks\n * The root item is not a renderable item and must always be treated with special care.\n *\n * This function uses a hardcoded string to identify the root item.\n */\nexport const isRootNode = (item: unknown): item is DSMenuButtonT.MenuNodeRootItem =>\n isObjectAMenuNode(item) && (item.plainItem?.type as string) === 'ROOT_ITEM';\n\n// =============================================================================\n// aria-setsize / aria-posinset\n// =============================================================================\n/**\n * Computes aria-posinset/aria-setsize for the focusable nodes within a single sibling\n * list \u2014 either the flyout menu's top-level children, or one group's subitems.\n * @param {DSMenuButtonT.MenuNode[]} siblingNodes - Immediate sibling nodes sharing one list level.\n * @returns {Map<DSMenuButtonT.MenuNode['dsId'], { ariaPosInSet: number; ariaSetSize: number }>} keyed by dsId.\n * @remarks\n * PUI-18614: the browser/AT native inference of a menu's item count and an item's position\n * breaks once a `role=\"group\"` wrapper has no accessible name (a supported, label-less GROUP\n * usage). Making both values explicit removes the dependency on that inference. Separators and\n * nested groups are excluded \u2014 they are not part of the ARIA \"set of items\".\n */\nexport const getAriaSetSizeAndPosInSetBySiblingList = (\n siblingNodes: DSMenuButtonT.MenuNode[],\n): Map<DSMenuButtonT.MenuNode['dsId'], { ariaPosInSet: number; ariaSetSize: number }> => {\n const focusableSiblings = siblingNodes.filter(isFocusableNode);\n const ariaSetSize = focusableSiblings.length;\n return new Map(focusableSiblings.map((node, index) => [node.dsId, { ariaPosInSet: index + 1, ariaSetSize }]));\n};\n\n// =============================================================================\n// Nodes allowed/expected to have subItems/children\n// (the node not necessarily needs to be focusable or a submenu, E.G. a group)\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;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\nimport { isLocked } from '@elliemae/ds-props-helpers';\nimport { type DSMenuButtonT } from '../react-desc-prop-types.js';\n\nimport { MENU_ITEMS_TYPES } from '../constants/index.js';\n\n/**\n * Heuristic to determine if the selected item is an item or a node.\n * Not perfect because JavaScript is not typed.\n * If app devs provide an object that matches all of those conditions, it's an edge case the app devs should handle.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is (heuristically) a menu node, false otherwise.\n */\nexport const isObjectAMenuNode = (item: unknown): item is DSMenuButtonT.MenuNode => {\n const node = item as { plainItem?: { type?: unknown }; dsId?: unknown };\n return (\n typeof item === 'object' &&\n item !== null &&\n typeof node.plainItem === 'object' &&\n node.plainItem?.type !== undefined &&\n node.dsId !== undefined\n );\n};\n\n// =============================================================================\n// Focusable nodes\n// =============================================================================\n/**\n * Checks if the item is an activable node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is an activable node, false otherwise.\n */\nexport const isActivableNode = (item: unknown): item is DSMenuButtonT.MenuNodeActivableItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.ACTIVABLE_ITEM;\n\n/**\n * Checks if the item is a skeleton node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a skeleton node, false otherwise.\n */\nexport const isSkeletonNode = (item: unknown): item is DSMenuButtonT.MenuNodeSkeletonItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.SKELETON_ITEM;\n\n// =============================================================================\n// Focusable but more specifically selectable nodes\n// =============================================================================\n\n/**\n * Checks if the item is a multiple select only node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a multiple select only node, false otherwise.\n */\nexport const isMultipleSelectOnlyNode = (item: unknown): item is DSMenuButtonT.MenuNodeMultipleSelectItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.MULTIPLE_SELECT_ITEM;\n\n/**\n * Checks if the item is a multiple select node with a submenu.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a multiple select node with a submenu, false otherwise.\n */\nexport const isMultipleSelectWithSubmenuNode = (\n item: unknown,\n): item is DSMenuButtonT.MenuNodeMultipleSelectWithSubmenuItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.MULTIPLE_SELECT_WITH_SUBMENU_ITEM;\n\n/**\n * Checks if the item is a multiple select node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a multiple select node, false otherwise.\n */\nexport const isMultipleSelectNode = (item: unknown): item is DSMenuButtonT.MultipleSelectionableMenuNodes =>\n isMultipleSelectOnlyNode(item) || isMultipleSelectWithSubmenuNode(item);\n\n/**\n * Checks if the item is a single select only node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a single select only node, false otherwise.\n */\nexport const isSingleSelectOnlyNode = (item: unknown): item is DSMenuButtonT.MenuNodeSingleSelectItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.SINGLE_SELECT_ITEM;\n\n/**\n * Checks if the item is a single select node with a submenu.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a single select node with a submenu, false otherwise.\n */\nexport const isSingleSelectNodeWithSubmenu = (\n item: unknown,\n): item is DSMenuButtonT.MenuNodeSingleSelectWithSubmenuItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.SINGLE_SELECT_WITH_SUBMENU_ITEM;\n\n/**\n * Checks if the item is a single select node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a single select node, false otherwise.\n */\nexport const isSingleSelectNode = (item: unknown): item is DSMenuButtonT.SingleSelectionableMenuNodes =>\n isSingleSelectOnlyNode(item) || isSingleSelectNodeWithSubmenu(item);\n\n/**\n * Checks if the item is a selectionable node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a selectionable node, false otherwise.\n */\nexport const isSelectionableNode = (item: unknown): item is DSMenuButtonT.SelectionableMenuNodes =>\n isMultipleSelectNode(item) || isSingleSelectNode(item);\n\n/**\n * Gets all selectionable nodes from the tree.\n * @param {DSMenuButtonT.MenuNode} tree - The tree to search.\n * @returns {DSMenuButtonT.SelectionableMenuNodes[]} - An array of selectionable nodes.\n */\nexport const getSelectionableNodes = (tree: DSMenuButtonT.MenuNode): DSMenuButtonT.SelectionableMenuNodes[] =>\n tree.flatten().filter(isSelectionableNode);\n// =============================================================================\n// Focusable but more specifically with submenu nodes\n// =============================================================================\n/**\n * Checks if the item is a node with a submenu (and nothing else).\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a node with a submenu, false otherwise.\n */\nexport const isWithSubmenuOnlyNode = (item: unknown): item is DSMenuButtonT.MenuNodeWithSubmenuItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.WITH_SUBMENU_ITEM;\n\n/**\n * Checks if the item is a selectionable node with a submenu.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a selectionable node with a submenu, false otherwise.\n */\nexport const isSelectionableWithSubmenuNode = (\n item: unknown,\n): item is DSMenuButtonT.SelectionablesWithSubmenuMenuNodes =>\n isSingleSelectNodeWithSubmenu(item) || isMultipleSelectWithSubmenuNode(item);\n/**\n * Checks if the item is an activable node with a submenu.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is an activable node with a submenu, false otherwise.\n */\nexport const isActivableWithSubmenuNode = (item: unknown): item is DSMenuButtonT.MenuNodeActivableWithSubmenuItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.ACTIVABLE_WITH_SUBMENU_ITEM;\n\n/**\n * Checks if the item is a node with a submenu.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a node with a submenu, false otherwise.\n */\nexport const isWithSubmenuNode = (item: unknown): item is DSMenuButtonT.WithSubmenuMenuNodes =>\n isWithSubmenuOnlyNode(item) || isSelectionableWithSubmenuNode(item) || isActivableWithSubmenuNode(item);\n\n/**\n * Gets all nodes with a submenu from the tree.\n * @param {DSMenuButtonT.MenuNode} tree - The tree to search.\n * @returns {DSMenuButtonT.PseudoFocusableMenuNodes[]} - An array of nodes with a submenu.\n */\nexport const getWithSubmenuNodes = (tree: DSMenuButtonT.MenuNode): DSMenuButtonT.PseudoFocusableMenuNodes[] =>\n tree.flatten().filter(isWithSubmenuNode);\n/**\n * Checks if the item is a node that can be focused.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a node that can be focused, false otherwise.\n */\nexport const isFocusableNode = (item: unknown): item is DSMenuButtonT.PseudoFocusableMenuNodes =>\n isSelectionableNode(item) || isActivableNode(item) || isWithSubmenuNode(item) || isSkeletonNode(item);\n\n/**\n * Gets all nodes that can be focused from the tree.\n * @param {DSMenuButtonT.MenuNode} tree - The tree to search.\n * @returns {DSMenuButtonT.PseudoFocusableMenuNodes[]} - An array of nodes that can be focused.\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// =============================================================================\n/**\n * Checks if the item is a separator node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a separator node, false otherwise.\n */\nexport const isSeparatorNode = (item: unknown): item is DSMenuButtonT.MenuNodeSeparatorItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.SEPARATOR;\n/**\n * Checks if the item is a group node.\n * @param {unknown} item - The item to check.\n * @returns {boolean} - True if the item is a group node, false otherwise.\n */\nexport const isGroup = (item: unknown): item is DSMenuButtonT.MenuNodeGroupItem =>\n isObjectAMenuNode(item) && item.plainItem?.type === MENU_ITEMS_TYPES.GROUP;\n\n/**\n * Checks if the given item is a root node of the menu.\n * @param {DSMenuButtonT.MenuNode} tree - The tree to search.\n * @returns {DSMenuButtonT.PseudoFocusableMenuNodes[]} - An array of nodes that can be focused.\n * @remarks\n * The root item is not a renderable item and must always be treated with special care.\n *\n * This function uses a hardcoded string to identify the root item.\n */\nexport const isRootNode = (item: unknown): item is DSMenuButtonT.MenuNodeRootItem =>\n isObjectAMenuNode(item) && (item.plainItem?.type as string) === 'ROOT_ITEM';\n\n// =============================================================================\n// aria-setsize / aria-posinset\n// =============================================================================\n/**\n * Computes aria-posinset/aria-setsize for the focusable nodes within a single sibling\n * list \u2014 either the flyout menu's top-level children, or one group's subitems.\n * @param {DSMenuButtonT.MenuNode[]} siblingNodes - Immediate sibling nodes sharing one list level.\n * @returns {Map<DSMenuButtonT.MenuNode['dsId'], { ariaPosInSet: number; ariaSetSize: number }>} keyed by dsId.\n * @remarks\n * PUI-18614: the browser/AT native inference of a menu's item count and an item's position\n * breaks once a `role=\"group\"` wrapper has no accessible name (a supported, label-less GROUP\n * usage). Making both values explicit removes the dependency on that inference. Separators and\n * nested groups are excluded \u2014 they are not part of the ARIA \"set of items\".\n */\nexport const getAriaSetSizeAndPosInSetBySiblingList = (\n siblingNodes: DSMenuButtonT.MenuNode[],\n): Map<DSMenuButtonT.MenuNode['dsId'], { ariaPosInSet: number; ariaSetSize: number }> => {\n const focusableSiblings = siblingNodes.filter(isFocusableNode);\n const ariaSetSize = focusableSiblings.length;\n return new Map(focusableSiblings.map((node, index) => [node.dsId, { ariaPosInSet: index + 1, ariaSetSize }]));\n};\n\n// =============================================================================\n// Nodes allowed/expected to have subItems/children\n// (the node not necessarily needs to be focusable or a submenu, E.G. a group)\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\n// =============================================================================\n// Locked items\n// =============================================================================\n/**\n * Checks if the item is locked: `disabled`, `applyAriaDisabled` and `readOnly` lock a menu item. A locked item keeps its\n * focus and hover, it announces as disabled, and it ignores every action (click, Enter, Space) and withholds the consumer's\n * activation handlers. The rule is the one of the menu-items atoms (`isLocked` in ds-props-helpers).\n * @param {object} plainItem - The options of the item (the `plainItem` of its node).\n * @returns {boolean} - True if the item is locked, false otherwise.\n */\nexport const isItemLocked = ({\n disabled,\n applyAriaDisabled,\n readOnly,\n}: {\n disabled?: boolean;\n applyAriaDisabled?: boolean;\n readOnly?: boolean;\n}): boolean => isLocked({ disabled, applyAriaDisabled, readOnly });\n\n/**\n * Checks if the item is disabled, the hard lock of the menu item (PUI-16695): it never opens its\n * submenu, on hover, on arrow or on click. A soft lock (`applyAriaDisabled`) is not disabled: it still opens its submenu on hover and ArrowRight, while its click and Enter are withheld.\n * @param {object} plainItem - The options of the item (the `plainItem` of its node).\n * @returns {boolean} - True if the item is disabled, false otherwise.\n */\nexport const isItemDisabled = ({ disabled }: { disabled?: boolean }): boolean => Boolean(disabled);\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;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,8BAAyB;AAGzB,uBAAiC;AAS1B,MAAM,oBAAoB,CAAC,SAAkD;AAClF,QAAM,OAAO;AACb,SACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAO,KAAK,cAAc,YAC1B,KAAK,WAAW,SAAS,UACzB,KAAK,SAAS;AAElB;AAUO,MAAM,kBAAkB,CAAC,SAC9B,kBAAkB,IAAI,KAAK,KAAK,WAAW,SAAS,kCAAiB;AAOhE,MAAM,iBAAiB,CAAC,SAC7B,kBAAkB,IAAI,KAAK,KAAK,WAAW,SAAS,kCAAiB;AAWhE,MAAM,2BAA2B,CAAC,SACvC,kBAAkB,IAAI,KAAK,KAAK,WAAW,SAAS,kCAAiB;AAOhE,MAAM,kCAAkC,CAC7C,SAEA,kBAAkB,IAAI,KAAK,KAAK,WAAW,SAAS,kCAAiB;AAOhE,MAAM,uBAAuB,CAAC,SACnC,yBAAyB,IAAI,KAAK,gCAAgC,IAAI;AAOjE,MAAM,yBAAyB,CAAC,SACrC,kBAAkB,IAAI,KAAK,KAAK,WAAW,SAAS,kCAAiB;AAOhE,MAAM,gCAAgC,CAC3C,SAEA,kBAAkB,IAAI,KAAK,KAAK,WAAW,SAAS,kCAAiB;AAOhE,MAAM,qBAAqB,CAAC,SACjC,uBAAuB,IAAI,KAAK,8BAA8B,IAAI;AAO7D,MAAM,sBAAsB,CAAC,SAClC,qBAAqB,IAAI,KAAK,mBAAmB,IAAI;AAOhD,MAAM,wBAAwB,CAAC,SACpC,KAAK,QAAQ,EAAE,OAAO,mBAAmB;AASpC,MAAM,wBAAwB,CAAC,SACpC,kBAAkB,IAAI,KAAK,KAAK,WAAW,SAAS,kCAAiB;AAOhE,MAAM,iCAAiC,CAC5C,SAEA,8BAA8B,IAAI,KAAK,gCAAgC,IAAI;AAMtE,MAAM,6BAA6B,CAAC,SACzC,kBAAkB,IAAI,KAAK,KAAK,WAAW,SAAS,kCAAiB;AAOhE,MAAM,oBAAoB,CAAC,SAChC,sBAAsB,IAAI,KAAK,+BAA+B,IAAI,KAAK,2BAA2B,IAAI;AAOjG,MAAM,sBAAsB,CAAC,SAClC,KAAK,QAAQ,EAAE,OAAO,iBAAiB;AAMlC,MAAM,kBAAkB,CAAC,SAC9B,oBAAoB,IAAI,KAAK,gBAAgB,IAAI,KAAK,kBAAkB,IAAI,KAAK,eAAe,IAAI;AAO/F,MAAM,oBAAoB,CAAC,SAA2E;AAC3G,QAAM,eAAe,KAAK,QAAQ;AAClC,SAAO,aAAa,OAAO,eAAe;AAC5C;AAUO,MAAM,kBAAkB,CAAC,SAC9B,kBAAkB,IAAI,KAAK,KAAK,WAAW,SAAS,kCAAiB;AAMhE,MAAM,UAAU,CAAC,SACtB,kBAAkB,IAAI,KAAK,KAAK,WAAW,SAAS,kCAAiB;AAWhE,MAAM,aAAa,CAAC,SACzB,kBAAkB,IAAI,KAAM,KAAK,WAAW,SAAoB;AAgB3D,MAAM,yCAAyC,CACpD,iBACuF;AACvF,QAAM,oBAAoB,aAAa,OAAO,eAAe;AAC7D,QAAM,cAAc,kBAAkB;AACtC,SAAO,IAAI,IAAI,kBAAkB,IAAI,CAAC,MAAM,UAAU,CAAC,KAAK,MAAM,EAAE,cAAc,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC;AAC9G;AAMO,MAAM,kCAAkC,CAAC,SAC9C,WAAW,IAAI,KACf,kBAAkB,IAAI,KACtB,QAAQ,IAAI,KACZ,8BAA8B,IAAI,KAClC,gCAAgC,IAAI,KACpC,2BAA2B,IAAI;AAY1B,MAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AACF,UAIe,kCAAS,EAAE,UAAU,mBAAmB,SAAS,CAAC;AAQ1D,MAAM,iBAAiB,CAAC,EAAE,SAAS,MAAuC,QAAQ,QAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { isActivationKey } from "@elliemae/ds-props-helpers";
|
|
2
3
|
import React2 from "react";
|
|
3
4
|
import {
|
|
4
5
|
isFocusableNode,
|
|
6
|
+
isItemDisabled,
|
|
7
|
+
isItemLocked,
|
|
5
8
|
isMultipleSelectNode,
|
|
6
9
|
isRootNode,
|
|
7
10
|
isSingleSelectNode,
|
|
@@ -184,7 +187,9 @@ const useMenuItemEventsHandlers = ({
|
|
|
184
187
|
};
|
|
185
188
|
const pseudoFocusedItemNode = focusedElementItemNode.current;
|
|
186
189
|
if (pseudoFocusedItemNode === null) throw UNEXPECTED_INTERNAL_ERRORS.FOCUSED_ITEM_NODE_NOT_SET;
|
|
187
|
-
|
|
190
|
+
const isLockedActivation = isItemLocked(pseudoFocusedItemNode.plainItem) && isActivationKey(event);
|
|
191
|
+
if (pseudoFocusedItemNode.plainItem.onKeyDown && !isLockedActivation)
|
|
192
|
+
pseudoFocusedItemNode.plainItem.onKeyDown(event);
|
|
188
193
|
if (onItemKeyDown) {
|
|
189
194
|
onItemKeyDown({
|
|
190
195
|
itemNode: pseudoFocusedItemNode,
|
|
@@ -210,7 +215,7 @@ const useMenuItemEventsHandlers = ({
|
|
|
210
215
|
}
|
|
211
216
|
if (event.key === "ArrowRight") {
|
|
212
217
|
consumeKey();
|
|
213
|
-
if (!pseudoFocusedItemNode.plainItem
|
|
218
|
+
if (!isItemDisabled(pseudoFocusedItemNode.plainItem))
|
|
214
219
|
handleMenuItemRightArrowKeyDown({ pseudoFocusedItemNode, event });
|
|
215
220
|
return;
|
|
216
221
|
}
|
|
@@ -247,7 +252,7 @@ const useMenuItemEventsHandlers = ({
|
|
|
247
252
|
}
|
|
248
253
|
return;
|
|
249
254
|
}
|
|
250
|
-
if (pseudoFocusedItemNode.plainItem
|
|
255
|
+
if (isItemLocked(pseudoFocusedItemNode.plainItem)) return;
|
|
251
256
|
if (event.key === "Enter") {
|
|
252
257
|
event.stopPropagation();
|
|
253
258
|
handleMenuItemEnterKeyDown({ pseudoFocusedItemNode, event });
|
|
@@ -281,7 +286,7 @@ const useMenuItemEventsHandlers = ({
|
|
|
281
286
|
(event) => {
|
|
282
287
|
const pseudoFocusedItemNode = focusedElementItemNode.current;
|
|
283
288
|
if (pseudoFocusedItemNode === null) throw UNEXPECTED_INTERNAL_ERRORS.FOCUSED_ITEM_NODE_NOT_SET;
|
|
284
|
-
if (pseudoFocusedItemNode.plainItem
|
|
289
|
+
if (isItemLocked(pseudoFocusedItemNode.plainItem)) return;
|
|
285
290
|
const parentMenuNode = pseudoFocusedItemNode.parent;
|
|
286
291
|
if (isRootNode(parentMenuNode)) {
|
|
287
292
|
const metainfo = { itemNode: pseudoFocusedItemNode, event };
|
|
@@ -319,7 +324,7 @@ const useMenuItemEventsHandlers = ({
|
|
|
319
324
|
handleChangeOpenedSubItems(newOpenedItems, metainfo);
|
|
320
325
|
return;
|
|
321
326
|
}
|
|
322
|
-
if (itemNode.plainItem
|
|
327
|
+
if (isItemDisabled(itemNode.plainItem)) return;
|
|
323
328
|
openSubmenu({ itemNode, event });
|
|
324
329
|
},
|
|
325
330
|
[handleChangeOpenedSubItems, openSubmenu, trackFocusNode]
|