@elliemae/ds-menu-button 3.80.0-next.6 → 3.80.0-next.61
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/config/useLatestValueReferenciallyStable.js +43 -0
- package/dist/cjs/config/useLatestValueReferenciallyStable.js.map +7 -0
- package/dist/cjs/config/useSideEffectSyntheticEvent.js +44 -0
- package/dist/cjs/config/useSideEffectSyntheticEvent.js.map +7 -0
- package/dist/cjs/config/useSplitInherithedProps.js +19 -2
- package/dist/cjs/config/useSplitInherithedProps.js.map +2 -2
- package/dist/cjs/parts/DSFlyoutMenu/DSFlyoutMenu.js +22 -1
- package/dist/cjs/parts/DSFlyoutMenu/DSFlyoutMenu.js.map +2 -2
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.js +4 -3
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.js.map +2 -2
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useFocusTracker.js +10 -1
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useFocusTracker.js.map +2 -2
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useGlobalEvents.js +4 -3
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useGlobalEvents.js.map +2 -2
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js +52 -20
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js.map +2 -2
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuOpenStatus.js +14 -8
- package/dist/cjs/parts/DSMenuBehaviouralContextProvider/config/useMenuOpenStatus.js.map +2 -2
- package/dist/cjs/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.js +29 -14
- package/dist/cjs/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js +18 -2
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/esm/config/useLatestValueReferenciallyStable.js +13 -0
- package/dist/esm/config/useLatestValueReferenciallyStable.js.map +7 -0
- package/dist/esm/config/useSideEffectSyntheticEvent.js +14 -0
- package/dist/esm/config/useSideEffectSyntheticEvent.js.map +7 -0
- package/dist/esm/config/useSplitInherithedProps.js +19 -2
- package/dist/esm/config/useSplitInherithedProps.js.map +2 -2
- package/dist/esm/parts/DSFlyoutMenu/DSFlyoutMenu.js +22 -1
- package/dist/esm/parts/DSFlyoutMenu/DSFlyoutMenu.js.map +2 -2
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.js +4 -3
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.js.map +2 -2
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useFocusTracker.js +10 -1
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useFocusTracker.js.map +2 -2
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useGlobalEvents.js +4 -3
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useGlobalEvents.js.map +2 -2
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js +52 -20
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.js.map +2 -2
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useMenuOpenStatus.js +14 -8
- package/dist/esm/parts/DSMenuBehaviouralContextProvider/config/useMenuOpenStatus.js.map +2 -2
- package/dist/esm/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.js +29 -14
- package/dist/esm/parts/DSOpinionatedButton/config/useTriggerEventsHandlers.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js +18 -2
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/types/config/useLatestValueReferenciallyStable.d.ts +4 -0
- package/dist/types/config/useSideEffectSyntheticEvent.d.ts +9 -0
- package/dist/types/config/useSplitInherithedProps.d.ts +5 -2
- package/dist/types/parts/DSMenuBehaviouralContextProvider/config/useFocusTracker.d.ts +4 -1
- package/dist/types/parts/DSMenuBehaviouralContextProvider/config/useMenuItemEventsHandlers.d.ts +1 -0
- package/dist/types/parts/DSMenuBehaviouralContextProvider/config/useMenuOpenStatus.d.ts +12 -4
- package/dist/types/react-desc-prop-types.d.ts +22 -2
- package/package.json +14 -13
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useLatestValueReferenciallyStable_exports = {};
|
|
30
|
+
__export(useLatestValueReferenciallyStable_exports, {
|
|
31
|
+
useLatestValueReferenciallyStable: () => useLatestValueReferenciallyStable
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useLatestValueReferenciallyStable_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
const useLatestValueReferenciallyStable = (referenceVar) => {
|
|
37
|
+
const mutable = (0, import_react.useRef)(referenceVar);
|
|
38
|
+
(0, import_react.useEffect)(() => {
|
|
39
|
+
mutable.current = referenceVar;
|
|
40
|
+
}, [referenceVar]);
|
|
41
|
+
return mutable;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=useLatestValueReferenciallyStable.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/config/useLatestValueReferenciallyStable.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import type React from 'react';\nimport { useRef, useEffect } from 'react';\ntype UseMakeMutable = <T>(referenceVar: T) => React.MutableRefObject<T>;\n\nexport const useLatestValueReferenciallyStable: UseMakeMutable = (referenceVar) => {\n const mutable = useRef(referenceVar);\n useEffect(() => {\n mutable.current = referenceVar;\n }, [referenceVar]);\n return mutable;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkC;AAG3B,MAAM,oCAAoD,CAAC,iBAAiB;AACjF,QAAM,cAAU,qBAAO,YAAY;AACnC,8BAAU,MAAM;AACd,YAAQ,UAAU;AAAA,EACpB,GAAG,CAAC,YAAY,CAAC;AACjB,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useSideEffectSyntheticEvent_exports = {};
|
|
30
|
+
__export(useSideEffectSyntheticEvent_exports, {
|
|
31
|
+
useSideEffectSyntheticEvent: () => useSideEffectSyntheticEvent
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useSideEffectSyntheticEvent_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_useLatestValueReferenciallyStable = require("./useLatestValueReferenciallyStable.js");
|
|
37
|
+
const useSideEffectSyntheticEvent = (dependency, callback, callbackOpts) => {
|
|
38
|
+
const refCb = (0, import_useLatestValueReferenciallyStable.useLatestValueReferenciallyStable)(callback);
|
|
39
|
+
const refCbOpts = (0, import_useLatestValueReferenciallyStable.useLatestValueReferenciallyStable)(callbackOpts);
|
|
40
|
+
import_react.default.useEffect(() => {
|
|
41
|
+
refCb?.current?.(dependency, refCbOpts.current);
|
|
42
|
+
}, [dependency, refCb, refCbOpts]);
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=useSideEffectSyntheticEvent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/config/useSideEffectSyntheticEvent.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { useLatestValueReferenciallyStable } from './useLatestValueReferenciallyStable.js';\n/**\n * This is a custom hook that allows us to simulate a synthetic event. This ensure we only trigger a side effect when a specific variable(dependency) changes.\n * @param {any} dependency - the variable that we want to listen to\n * @param {Function} callback - the callback that we want to execute when the dependency changes\n * @param {object} callbackOpts - the options to be passed to the callback function\n * @returns {void}\n * @invoke useLatestValueReferenciallyStable\n */\nexport const useSideEffectSyntheticEvent = <T, CBOpts>(\n dependency: T,\n callback: (latestVal: T, opts: CBOpts) => void,\n callbackOpts: CBOpts,\n) => {\n const refCb = useLatestValueReferenciallyStable(callback);\n const refCbOpts = useLatestValueReferenciallyStable(callbackOpts);\n // this is the useEffect that simulates the event\n React.useEffect(() => {\n refCb?.current?.(dependency, refCbOpts.current);\n // the point of this custom hook is making sure we only listen to the dependency and nothing else\n // without violating the rules of hooks/exhaustive-deps rule and making it explicit that we want to simulate an event\n // refCb & refCbOpts are forced to be referentially stable, so we can safely put it in the dependency array\n }, [dependency, refCb, refCbOpts]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,+CAAkD;AAS3C,MAAM,8BAA8B,CACzC,YACA,UACA,iBACG;AACH,QAAM,YAAQ,4EAAkC,QAAQ;AACxD,QAAM,gBAAY,4EAAkC,YAAY;AAEhE,eAAAA,QAAM,UAAU,MAAM;AACpB,WAAO,UAAU,YAAY,UAAU,OAAO;AAAA,EAIhD,GAAG,CAAC,YAAY,OAAO,SAAS,CAAC;AACnC;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -72,6 +72,7 @@ const useSplitInherithedProps = ({
|
|
|
72
72
|
isSkeleton,
|
|
73
73
|
ItemRenderer,
|
|
74
74
|
floatingConfig,
|
|
75
|
+
firstOpenAxis,
|
|
75
76
|
innerRef,
|
|
76
77
|
selectedItems,
|
|
77
78
|
onDisplayedSubmenuChange,
|
|
@@ -79,6 +80,8 @@ const useSplitInherithedProps = ({
|
|
|
79
80
|
onActivateItem,
|
|
80
81
|
onOpen,
|
|
81
82
|
onClose,
|
|
83
|
+
onItemKeyDown,
|
|
84
|
+
a11yDangerouslyConsumerOwnedMenuOpenState,
|
|
82
85
|
maxHeight,
|
|
83
86
|
// this is not shared with anything at all, it's instead a property of the "root" node, each node (with a submenu) can have its own maxHeight
|
|
84
87
|
...buttonInheritedProps
|
|
@@ -98,6 +101,14 @@ const useSplitInherithedProps = ({
|
|
|
98
101
|
}
|
|
99
102
|
return [];
|
|
100
103
|
}, [selectedItems, treeRootNode]);
|
|
104
|
+
const onCloseAndDismissal = import_react.default.useCallback(
|
|
105
|
+
(metainfo) => {
|
|
106
|
+
if (onClose) onClose(metainfo);
|
|
107
|
+
if (metainfo.reason === "outside-click" || metainfo.reason === "escape")
|
|
108
|
+
onClickOutside(metainfo.event);
|
|
109
|
+
},
|
|
110
|
+
[onClose, onClickOutside]
|
|
111
|
+
);
|
|
101
112
|
const menuSpecificProps = import_react.default.useMemo(
|
|
102
113
|
() => ({
|
|
103
114
|
options,
|
|
@@ -108,6 +119,7 @@ const useSplitInherithedProps = ({
|
|
|
108
119
|
isLoading,
|
|
109
120
|
isSkeleton,
|
|
110
121
|
ItemRenderer,
|
|
122
|
+
firstOpenAxis,
|
|
111
123
|
...floatingConfig !== void 0 ? { floatingConfig } : {}
|
|
112
124
|
}),
|
|
113
125
|
[
|
|
@@ -119,6 +131,7 @@ const useSplitInherithedProps = ({
|
|
|
119
131
|
isLoading,
|
|
120
132
|
isSkeleton,
|
|
121
133
|
ItemRenderer,
|
|
134
|
+
firstOpenAxis,
|
|
122
135
|
floatingConfig
|
|
123
136
|
]
|
|
124
137
|
);
|
|
@@ -133,7 +146,9 @@ const useSplitInherithedProps = ({
|
|
|
133
146
|
onItemSelected,
|
|
134
147
|
onActivateItem,
|
|
135
148
|
onOpen,
|
|
136
|
-
onClose
|
|
149
|
+
onClose: onCloseAndDismissal,
|
|
150
|
+
onItemKeyDown,
|
|
151
|
+
a11yDangerouslyConsumerOwnedMenuOpenState
|
|
137
152
|
},
|
|
138
153
|
opinionatedButtonProps: {
|
|
139
154
|
...buttonInheritedProps,
|
|
@@ -149,7 +164,9 @@ const useSplitInherithedProps = ({
|
|
|
149
164
|
onItemSelected,
|
|
150
165
|
onActivateItem,
|
|
151
166
|
onOpen,
|
|
152
|
-
|
|
167
|
+
onCloseAndDismissal,
|
|
168
|
+
onItemKeyDown,
|
|
169
|
+
a11yDangerouslyConsumerOwnedMenuOpenState,
|
|
153
170
|
buttonInheritedProps,
|
|
154
171
|
innerRefSnatchingNode,
|
|
155
172
|
menuSpecificProps
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/config/useSplitInherithedProps.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* *******************************************************\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 * this hooks is meant to take all the DSMenuButtonT.InternalProps with default already merged\n * and spit out menuSpecificProps & buttonInheritedProps\n ******************************************************* */\nimport type {} from '@elliemae/ds-system';\nimport type {} from '@elliemae/pui-theme';\nimport React from 'react';\nimport { type DSMenuButtonT } from '../react-desc-prop-types.js';\nimport { isObjectAMenuNode, isSelectionableNode } from '../utils/nodesTypeguardsAndGetters.js';\nimport { resolveRef } from '../utils/resolveRef.js';\n\n/**\n * Converts selected options to a map of selected nodes.\n * @param {DSMenuButtonT.SelectionableMenuNodes[]} selectedItems - The selected options, as provided by the user (either items or nodes).\n * @param {DSMenuButtonT.MenuNode} treeRootNode - The root node of the menu tree.\n * @returns {DSMenuButtonT.SelectionableMenuNodes[]} - The map of selected nodes.\n * @throws Will throw an error if a selected option is not found in the tree.\n */\nconst convertSelectedOptionsToNodes = (\n selectedItems: DSMenuButtonT.SelectionableMenuNodes[] | DSMenuButtonT.SelectionableMenuItemInterface[],\n treeRootNode: DSMenuButtonT.MenuNode,\n): DSMenuButtonT.SelectionableMenuNodes[] => {\n const convertedSelection: DSMenuButtonT.SelectionableMenuNodes[] = [];\n\n selectedItems.forEach((selectedItem) => {\n const needsConversion = !isObjectAMenuNode(selectedItem);\n if (!needsConversion) {\n convertedSelection.push(selectedItem);\n return;\n }\n\n const { dsId } = selectedItem;\n const selectedNode = treeRootNode.findNode((node: DSMenuButtonT.MenuNode) => node.dsId === dsId);\n if (!selectedNode) {\n throw new Error(`Selected option with dsId ${dsId} not found in the menu tree.`);\n }\n if (!isSelectionableNode(selectedNode)) {\n // eslint-disable-next-line no-console\n console.warn(`Selected option with dsId ${dsId} is not a selectionable node and will be ignored.`);\n return;\n }\n convertedSelection.push(selectedNode);\n });\n\n return convertedSelection;\n};\n\ntype UseSplitInherithedPropsConfig = {\n propsWithDefault: DSMenuButtonT.InternalProps;\n focusableNodes: DSMenuButtonT.PseudoFocusableMenuNodes[];\n treeRootNode: DSMenuButtonT.MenuNode;\n};\nexport const useSplitInherithedProps = ({\n propsWithDefault,\n focusableNodes,\n treeRootNode,\n}: UseSplitInherithedPropsConfig) => {\n const buttonDOMNodeRef = React.useRef<HTMLElement | null>(null);\n // when this component has been wrote\n // =============================================================================\n // MENU BUTTON props are:\n // Required\n // optionsTree, menuSpecificProps\n // Default (we already have a value because props for this hook are already merged with default props)\n // onClickOutside, onOptionClick, openedSubmenus, onSubmenuToggle, isLoading, isSkeleton, selectedOptions\n // Optional (may or may not be present)\n // ItemRenderer\n // =============================================================================\n // Props for the DSMenuBehaviouralContextProvider\n // =============================================================================\n // Required\n // selectedItems, onItemSelected, onActivateItem,\n // Optional\n // onDisplayedSubmenuChange, onOpen, onClose\n\n const {\n options,\n onClickOutside,\n onOptionClick,\n openedSubmenus,\n onSubmenuToggle,\n isLoading,\n isSkeleton,\n ItemRenderer,\n floatingConfig,\n innerRef,\n selectedItems,\n onDisplayedSubmenuChange,\n onItemSelected,\n onActivateItem,\n onOpen,\n onClose,\n maxHeight, // this is not shared with anything at all, it's instead a property of the \"root\" node, each node (with a submenu) can have its own maxHeight\n ...buttonInheritedProps\n } = propsWithDefault;\n\n // the button is allowed to receive innerRef, but we also need to invoke the setButtonDOMNode to store the button node\n // so we create a functional ref to do both\n const innerRefSnatchingNode: Required<DSMenuButtonT.Props>['innerRef'] = React.useCallback(\n (node: HTMLButtonElement) => {\n buttonDOMNodeRef.current = node;\n if (innerRef) {\n resolveRef(innerRef, node);\n }\n },\n [innerRef],\n );\n // in the WIDGET API, the user can provide selectedItems as an array of \"items\" or an array of \"nodes\"\n // the component needs the \"nodes\" to handle the logic and rendering & accessibility\n // if the user provides \"items\", we convert them to \"nodes\" here\n const selectedNodesMap = React.useMemo(() => {\n if (selectedItems) {\n return convertSelectedOptionsToNodes(selectedItems, treeRootNode);\n }\n return [];\n }, [selectedItems, treeRootNode]);\n\n const menuSpecificProps = React.useMemo(\n () => ({\n options,\n onClickOutside,\n onOptionClick,\n openedSubmenus,\n onSubmenuToggle,\n isLoading,\n isSkeleton,\n ItemRenderer,\n ...(floatingConfig !== undefined ? { floatingConfig } : {}),\n }),\n [\n options,\n onClickOutside,\n onOptionClick,\n openedSubmenus,\n onSubmenuToggle,\n isLoading,\n isSkeleton,\n ItemRenderer,\n floatingConfig,\n ],\n );\n\n return React.useMemo(\n () => ({\n menuBehaviouralLayerProps: {\n buttonDOMNodeRef,\n selectedNodes: selectedNodesMap,\n focusableNodes,\n optionsTree: treeRootNode,\n onDisplayedSubmenuChange,\n onItemSelected,\n onActivateItem,\n onOpen,\n onClose,\n },\n opinionatedButtonProps: {\n ...(buttonInheritedProps as DSMenuButtonT.ButtonInheritedProps),\n innerRef: innerRefSnatchingNode,\n menuSpecificProps,\n },\n }),\n [\n selectedNodesMap,\n focusableNodes,\n treeRootNode,\n onDisplayedSubmenuChange,\n onItemSelected,\n onActivateItem,\n onOpen,\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADsBvB,mBAAkB;AAElB,uCAAuD;AACvD,wBAA2B;AAS3B,MAAM,gCAAgC,CACpC,eACA,iBAC2C;AAC3C,QAAM,qBAA6D,CAAC;AAEpE,gBAAc,QAAQ,CAAC,iBAAiB;AACtC,UAAM,kBAAkB,KAAC,oDAAkB,YAAY;AACvD,QAAI,CAAC,iBAAiB;AACpB,yBAAmB,KAAK,YAAY;AACpC;AAAA,IACF;AAEA,UAAM,EAAE,KAAK,IAAI;AACjB,UAAM,eAAe,aAAa,SAAS,CAAC,SAAiC,KAAK,SAAS,IAAI;AAC/F,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,MAAM,6BAA6B,IAAI,8BAA8B;AAAA,IACjF;AACA,QAAI,KAAC,sDAAoB,YAAY,GAAG;AAEtC,cAAQ,KAAK,6BAA6B,IAAI,mDAAmD;AACjG;AAAA,IACF;AACA,uBAAmB,KAAK,YAAY;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAOO,MAAM,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACF,MAAqC;AACnC,QAAM,mBAAmB,aAAAA,QAAM,OAA2B,IAAI;AAkB9D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAIJ,QAAM,wBAAmE,aAAAA,QAAM;AAAA,IAC7E,CAAC,SAA4B;AAC3B,uBAAiB,UAAU;AAC3B,UAAI,UAAU;AACZ,0CAAW,UAAU,IAAI;AAAA,MAC3B;AAAA,IACF;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAIA,QAAM,mBAAmB,aAAAA,QAAM,QAAQ,MAAM;AAC3C,QAAI,eAAe;AACjB,aAAO,8BAA8B,eAAe,YAAY;AAAA,IAClE;AACA,WAAO,CAAC;AAAA,EACV,GAAG,CAAC,eAAe,YAAY,CAAC;
|
|
4
|
+
"sourcesContent": ["/* *******************************************************\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 * this hooks is meant to take all the DSMenuButtonT.InternalProps with default already merged\n * and spit out menuSpecificProps & buttonInheritedProps\n ******************************************************* */\nimport type {} from '@elliemae/ds-system';\nimport type {} from '@elliemae/pui-theme';\nimport React from 'react';\nimport { type DSMenuButtonT } from '../react-desc-prop-types.js';\nimport { isObjectAMenuNode, isSelectionableNode } from '../utils/nodesTypeguardsAndGetters.js';\nimport { resolveRef } from '../utils/resolveRef.js';\n\n/**\n * Converts selected options to a map of selected nodes.\n * @param {DSMenuButtonT.SelectionableMenuNodes[]} selectedItems - The selected options, as provided by the user (either items or nodes).\n * @param {DSMenuButtonT.MenuNode} treeRootNode - The root node of the menu tree.\n * @returns {DSMenuButtonT.SelectionableMenuNodes[]} - The map of selected nodes.\n * @throws Will throw an error if a selected option is not found in the tree.\n */\nconst convertSelectedOptionsToNodes = (\n selectedItems: DSMenuButtonT.SelectionableMenuNodes[] | DSMenuButtonT.SelectionableMenuItemInterface[],\n treeRootNode: DSMenuButtonT.MenuNode,\n): DSMenuButtonT.SelectionableMenuNodes[] => {\n const convertedSelection: DSMenuButtonT.SelectionableMenuNodes[] = [];\n\n selectedItems.forEach((selectedItem) => {\n const needsConversion = !isObjectAMenuNode(selectedItem);\n if (!needsConversion) {\n convertedSelection.push(selectedItem);\n return;\n }\n\n const { dsId } = selectedItem;\n const selectedNode = treeRootNode.findNode((node: DSMenuButtonT.MenuNode) => node.dsId === dsId);\n if (!selectedNode) {\n throw new Error(`Selected option with dsId ${dsId} not found in the menu tree.`);\n }\n if (!isSelectionableNode(selectedNode)) {\n // eslint-disable-next-line no-console\n console.warn(`Selected option with dsId ${dsId} is not a selectionable node and will be ignored.`);\n return;\n }\n convertedSelection.push(selectedNode);\n });\n\n return convertedSelection;\n};\n\ntype UseSplitInherithedPropsConfig = {\n propsWithDefault: DSMenuButtonT.InternalProps;\n focusableNodes: DSMenuButtonT.PseudoFocusableMenuNodes[];\n treeRootNode: DSMenuButtonT.MenuNode;\n};\nexport const useSplitInherithedProps = ({\n propsWithDefault,\n focusableNodes,\n treeRootNode,\n}: UseSplitInherithedPropsConfig) => {\n const buttonDOMNodeRef = React.useRef<HTMLElement | null>(null);\n // when this component has been wrote\n // =============================================================================\n // MENU BUTTON props are:\n // Required\n // optionsTree, menuSpecificProps\n // Default (we already have a value because props for this hook are already merged with default props)\n // onClickOutside, onOptionClick, openedSubmenus, onSubmenuToggle, isLoading, isSkeleton, selectedOptions\n // Optional (may or may not be present)\n // ItemRenderer\n // =============================================================================\n // Props for the DSMenuBehaviouralContextProvider\n // =============================================================================\n // Required\n // selectedItems, onItemSelected, onActivateItem,\n // Optional\n // onDisplayedSubmenuChange, onOpen, onClose, onItemKeyDown\n\n const {\n options,\n onClickOutside,\n onOptionClick,\n openedSubmenus,\n onSubmenuToggle,\n isLoading,\n isSkeleton,\n ItemRenderer,\n floatingConfig,\n firstOpenAxis,\n innerRef,\n selectedItems,\n onDisplayedSubmenuChange,\n onItemSelected,\n onActivateItem,\n onOpen,\n onClose,\n onItemKeyDown,\n a11yDangerouslyConsumerOwnedMenuOpenState,\n maxHeight, // this is not shared with anything at all, it's instead a property of the \"root\" node, each node (with a submenu) can have its own maxHeight\n ...buttonInheritedProps\n } = propsWithDefault;\n\n // the button is allowed to receive innerRef, but we also need to invoke the setButtonDOMNode to store the button node\n // so we create a functional ref to do both\n const innerRefSnatchingNode: Required<DSMenuButtonT.Props>['innerRef'] = React.useCallback(\n (node: HTMLButtonElement) => {\n buttonDOMNodeRef.current = node;\n if (innerRef) {\n resolveRef(innerRef, node);\n }\n },\n [innerRef],\n );\n // in the WIDGET API, the user can provide selectedItems as an array of \"items\" or an array of \"nodes\"\n // the component needs the \"nodes\" to handle the logic and rendering & accessibility\n // if the user provides \"items\", we convert them to \"nodes\" here\n const selectedNodesMap = React.useMemo(() => {\n if (selectedItems) {\n return convertSelectedOptionsToNodes(selectedItems, treeRootNode);\n }\n return [];\n }, [selectedItems, treeRootNode]);\n\n // `onClickOutside` is the dismissal channel \u2014 a pointer interaction outside the menu, or the Escape key \u2014\n // it is a subset of the close intents, so it is derived from `onClose`'s `reason` instead of a second code path\n const onCloseAndDismissal = React.useCallback<Required<DSMenuButtonT.MenuBehaviouralLayerOptionalProps>['onClose']>(\n (metainfo) => {\n if (onClose) onClose(metainfo);\n if (metainfo.reason === 'outside-click' || metainfo.reason === 'escape')\n onClickOutside(metainfo.event as Parameters<typeof onClickOutside>[0]);\n },\n [onClose, onClickOutside],\n );\n\n const menuSpecificProps = React.useMemo(\n () => ({\n options,\n onClickOutside,\n onOptionClick,\n openedSubmenus,\n onSubmenuToggle,\n isLoading,\n isSkeleton,\n ItemRenderer,\n firstOpenAxis,\n ...(floatingConfig !== undefined ? { floatingConfig } : {}),\n }),\n [\n options,\n onClickOutside,\n onOptionClick,\n openedSubmenus,\n onSubmenuToggle,\n isLoading,\n isSkeleton,\n ItemRenderer,\n firstOpenAxis,\n floatingConfig,\n ],\n );\n\n return React.useMemo(\n () => ({\n menuBehaviouralLayerProps: {\n buttonDOMNodeRef,\n selectedNodes: selectedNodesMap,\n focusableNodes,\n optionsTree: treeRootNode,\n onDisplayedSubmenuChange,\n onItemSelected,\n onActivateItem,\n onOpen,\n onClose: onCloseAndDismissal,\n onItemKeyDown,\n a11yDangerouslyConsumerOwnedMenuOpenState,\n },\n opinionatedButtonProps: {\n ...(buttonInheritedProps as DSMenuButtonT.ButtonInheritedProps),\n innerRef: innerRefSnatchingNode,\n menuSpecificProps,\n },\n }),\n [\n selectedNodesMap,\n focusableNodes,\n treeRootNode,\n onDisplayedSubmenuChange,\n onItemSelected,\n onActivateItem,\n onOpen,\n onCloseAndDismissal,\n onItemKeyDown,\n a11yDangerouslyConsumerOwnedMenuOpenState,\n buttonInheritedProps,\n innerRefSnatchingNode,\n menuSpecificProps,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADsBvB,mBAAkB;AAElB,uCAAuD;AACvD,wBAA2B;AAS3B,MAAM,gCAAgC,CACpC,eACA,iBAC2C;AAC3C,QAAM,qBAA6D,CAAC;AAEpE,gBAAc,QAAQ,CAAC,iBAAiB;AACtC,UAAM,kBAAkB,KAAC,oDAAkB,YAAY;AACvD,QAAI,CAAC,iBAAiB;AACpB,yBAAmB,KAAK,YAAY;AACpC;AAAA,IACF;AAEA,UAAM,EAAE,KAAK,IAAI;AACjB,UAAM,eAAe,aAAa,SAAS,CAAC,SAAiC,KAAK,SAAS,IAAI;AAC/F,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,MAAM,6BAA6B,IAAI,8BAA8B;AAAA,IACjF;AACA,QAAI,KAAC,sDAAoB,YAAY,GAAG;AAEtC,cAAQ,KAAK,6BAA6B,IAAI,mDAAmD;AACjG;AAAA,IACF;AACA,uBAAmB,KAAK,YAAY;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAOO,MAAM,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACF,MAAqC;AACnC,QAAM,mBAAmB,aAAAA,QAAM,OAA2B,IAAI;AAkB9D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAIJ,QAAM,wB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,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -47,6 +47,7 @@ var import_constants = require("./constants/index.js");
|
|
|
47
47
|
var import_react_desc_prop_types2 = require("./react-desc-prop-types.js");
|
|
48
48
|
var import_nodesTypeguardsAndGetters = require("../../utils/nodesTypeguardsAndGetters.js");
|
|
49
49
|
var import_MenuButtonContextProviderCTX = require("../../MenuButtonContextProviderCTX.js");
|
|
50
|
+
var import_useSideEffectSyntheticEvent = require("../../config/useSideEffectSyntheticEvent.js");
|
|
50
51
|
const StyledWrapper = (0, import_ds_system.styled)(import_ds_grid.Grid, {
|
|
51
52
|
name: import_constants.DSFlyoutMenuName,
|
|
52
53
|
slot: import_constants.FLYOUT_MENU_SLOTS.ROOT
|
|
@@ -67,6 +68,14 @@ const StyledMenu = (0, import_ds_system.styled)("div", { name: import_constants.
|
|
|
67
68
|
margin: 0;
|
|
68
69
|
`;
|
|
69
70
|
const NoComponentPlaceholder = () => null;
|
|
71
|
+
const handleMenuOpenStateChange = (isMenuOpen, opts) => {
|
|
72
|
+
const { itemNode, focusableNodes, openIntentPendingRef, trackFocusFirstChildItem, isOpenStateOwnedByConsumer } = opts;
|
|
73
|
+
if (!isMenuOpen || !(0, import_nodesTypeguardsAndGetters.isRootNode)(itemNode)) return;
|
|
74
|
+
const wasIntentArmed = openIntentPendingRef.current;
|
|
75
|
+
openIntentPendingRef.current = false;
|
|
76
|
+
if (isOpenStateOwnedByConsumer && !wasIntentArmed && focusableNodes.length > 0)
|
|
77
|
+
trackFocusFirstChildItem(itemNode);
|
|
78
|
+
};
|
|
70
79
|
const DSFlyoutMenu = (props) => {
|
|
71
80
|
const { propsWithDefault, xstyledProps } = (0, import_useFlyoutMenu.useFlyoutMenu)(props);
|
|
72
81
|
const {
|
|
@@ -74,7 +83,11 @@ const DSFlyoutMenu = (props) => {
|
|
|
74
83
|
} = import_react.default.useContext(import_MenuButtonContextProviderCTX.MenuButtonContextProvider);
|
|
75
84
|
const {
|
|
76
85
|
instanceUid,
|
|
77
|
-
globalEventsHelpers: { mainMenuRef, handleSubmenusRefChange }
|
|
86
|
+
globalEventsHelpers: { mainMenuRef, handleSubmenusRefChange },
|
|
87
|
+
openIntentPendingRef,
|
|
88
|
+
menuItemEventsHandlers: { handleMenuTabKeyDownCapture },
|
|
89
|
+
trackFocusFirstChildItem,
|
|
90
|
+
propsWithDefault: { focusableNodes, a11yDangerouslyConsumerOwnedMenuOpenState }
|
|
78
91
|
} = import_react.default.useContext(import_MenuBehaviouralContextProviderCTX.MenuBehaviouralContextProviderContext);
|
|
79
92
|
const [didAnimationEnd, setDidAnimationEnd] = import_react.default.useState(false);
|
|
80
93
|
const { setFloatingRef, floatingStyles, floatingContext, ItemRenderer, isMenuOpen, itemNode } = propsWithDefault;
|
|
@@ -93,6 +106,13 @@ const DSFlyoutMenu = (props) => {
|
|
|
93
106
|
},
|
|
94
107
|
[handleSubmenusRefChange, itemNode, mainMenuRef]
|
|
95
108
|
);
|
|
109
|
+
(0, import_useSideEffectSyntheticEvent.useSideEffectSyntheticEvent)(isMenuOpen, handleMenuOpenStateChange, {
|
|
110
|
+
itemNode,
|
|
111
|
+
focusableNodes,
|
|
112
|
+
openIntentPendingRef,
|
|
113
|
+
trackFocusFirstChildItem,
|
|
114
|
+
isOpenStateOwnedByConsumer: a11yDangerouslyConsumerOwnedMenuOpenState !== void 0
|
|
115
|
+
});
|
|
96
116
|
const handleAnimationStartTrigger = import_react.default.useCallback(() => {
|
|
97
117
|
setDidAnimationEnd(false);
|
|
98
118
|
}, []);
|
|
@@ -115,6 +135,7 @@ const DSFlyoutMenu = (props) => {
|
|
|
115
135
|
StyledMenu,
|
|
116
136
|
{
|
|
117
137
|
role: "menu",
|
|
138
|
+
onKeyDownCapture: (0, import_nodesTypeguardsAndGetters.isRootNode)(itemNode) ? handleMenuTabKeyDownCapture : void 0,
|
|
118
139
|
innerRef: handleRefChange,
|
|
119
140
|
$maxHeight: itemNode.plainItem.maxHeight ?? import_react_desc_prop_types.menuSpecificDefaultProps.maxHeight,
|
|
120
141
|
getOwnerProps,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/DSFlyoutMenu/DSFlyoutMenu.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { FloatingWrapper } from '@elliemae/ds-floating-context';\nimport { Grid } from '@elliemae/ds-grid';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { styled, xStyledCommonProps } from '@elliemae/ds-system';\n\nimport React from 'react';\nimport { type DSMenuButtonT, menuSpecificDefaultProps } from '../../react-desc-prop-types.js';\nimport { MenuBehaviouralContextProviderContext } from '../DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js';\nimport { DSMenuItemRendererFactory } from '../DSMenuItemRendererFactory/index.js';\nimport { useFlyoutMenu } from './config/useFlyoutMenu.js';\nimport { DSFlyoutMenuName, FLYOUT_MENU_SLOTS } from './constants/index.js';\nimport { DSFlyoutMenuPropTypesSchema, type DSFlyoutMenuT } from './react-desc-prop-types.js';\nimport { getAriaSetSizeAndPosInSetBySiblingList, isRootNode } from '../../utils/nodesTypeguardsAndGetters.js';\nimport { MenuButtonContextProvider } from '../../MenuButtonContextProviderCTX.js';\nconst StyledWrapper = styled(Grid, {\n name: DSFlyoutMenuName,\n slot: FLYOUT_MENU_SLOTS.ROOT,\n})`\n min-width: 1px;\n background-color: white;\n padding: ${({ theme }) => theme.space.xxxs} 0;\n ${xStyledCommonProps}\n`;\n\nconst StyledFloatingWrapper = styled(FloatingWrapper, {\n name: DSFlyoutMenuName,\n slot: FLYOUT_MENU_SLOTS.FLOATING_WRAPPER,\n})``;\n\nconst StyledMenu = styled('div', { name: DSFlyoutMenuName, slot: FLYOUT_MENU_SLOTS.LIST_WRAPPER })<{\n $maxHeight: string | number;\n}>`\n max-height: ${({ $maxHeight }) => (typeof $maxHeight === 'number' ? `${$maxHeight}px` : $maxHeight)};\n overflow-y: auto;\n padding: 0;\n margin: 0;\n`;\n\nconst NoComponentPlaceholder = () => null;\n\nconst DSFlyoutMenu: React.ComponentType<DSFlyoutMenuT.Props> = (props) => {\n const { propsWithDefault, xstyledProps } = useFlyoutMenu(props);\n const {\n ownerProps: { getOwnerProps, getOwnerPropsArguments },\n } = React.useContext(MenuButtonContextProvider);\n const {\n instanceUid,\n globalEventsHelpers: { mainMenuRef, handleSubmenusRefChange },\n } = React.useContext(MenuBehaviouralContextProviderContext);\n const [didAnimationEnd, setDidAnimationEnd] = React.useState(false);\n\n const { setFloatingRef, floatingStyles, floatingContext, ItemRenderer, isMenuOpen, itemNode } = propsWithDefault;\n const ariaPositionsByDsId = React.useMemo(\n // DSTree doesn't support children having a polymorphic type, so we need to cast it manually (same as below)\n () => getAriaSetSizeAndPosInSetBySiblingList(itemNode.children as DSMenuButtonT.MenuNode[]),\n [itemNode.children],\n );\n const handleRefChange = React.useCallback(\n (node: HTMLDivElement) => {\n if (isRootNode(itemNode)) {\n mainMenuRef.current = node;\n return;\n }\n handleSubmenusRefChange(node, itemNode.dsId);\n },\n [handleSubmenusRefChange, itemNode, mainMenuRef],\n );\n\n const handleAnimationStartTrigger = React.useCallback(() => {\n setDidAnimationEnd(false);\n }, []);\n const handleAnimationEnd = React.useCallback(() => {\n setDidAnimationEnd(true);\n }, []);\n\n return (\n <StyledFloatingWrapper\n innerRef={setFloatingRef}\n floatingStyles={floatingStyles}\n isOpen={isMenuOpen}\n context={floatingContext}\n onAnimationStartTriggered={handleAnimationStartTrigger}\n onAnimationEnd={handleAnimationEnd}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n // Adding a data-testid for legacy e2e tests\n data-testid=\"ds-floating-wrapper-root\"\n >\n <StyledWrapper getOwnerProps={getOwnerProps} getOwnerPropsArguments={getOwnerPropsArguments} {...xstyledProps}>\n <StyledMenu\n role=\"menu\"\n innerRef={handleRefChange}\n $maxHeight={itemNode.plainItem.maxHeight ?? menuSpecificDefaultProps.maxHeight}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n {itemNode.children.map((optionNode) => {\n const ariaPosition = ariaPositionsByDsId.get(optionNode.dsId);\n return (\n <DSMenuItemRendererFactory\n key={`flyout-menu-item-${optionNode.dsId}-${instanceUid}`}\n // DSTree doesn't support children having a polymorphic type, so we need to cast it manually\n itemNode={optionNode as DSMenuButtonT.MenuNode}\n ItemRenderer={ItemRenderer}\n // we are passing the DSFlyoutMenu component as a prop to the DSMenuItemRendererFactory\n // this solves the circular-ish dependency\n // the conditional `didAnimationEnd` solves the visual artefact of nested FloatingWrapper wrongly positioned due to animation\n FlyoutMenuCircularDepInject={didAnimationEnd ? DSFlyoutMenu : NoComponentPlaceholder}\n aria-posinset={ariaPosition?.ariaPosInSet}\n aria-setsize={ariaPosition?.ariaSetSize}\n />\n );\n })}\n </StyledMenu>\n </StyledWrapper>\n </StyledFloatingWrapper>\n );\n};\n\nDSFlyoutMenu.displayName = DSFlyoutMenuName;\nconst DSFlyoutMenuWithSchema = describe(DSFlyoutMenu);\nDSFlyoutMenuWithSchema.propTypes = DSFlyoutMenuPropTypesSchema;\n\nexport { DSFlyoutMenu, DSFlyoutMenuWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import { FloatingWrapper } from '@elliemae/ds-floating-context';\nimport { Grid } from '@elliemae/ds-grid';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { styled, xStyledCommonProps } from '@elliemae/ds-system';\n\nimport React from 'react';\nimport { type DSMenuButtonT, menuSpecificDefaultProps } from '../../react-desc-prop-types.js';\nimport { MenuBehaviouralContextProviderContext } from '../DSMenuBehaviouralContextProvider/MenuBehaviouralContextProviderCTX.js';\nimport { DSMenuItemRendererFactory } from '../DSMenuItemRendererFactory/index.js';\nimport { useFlyoutMenu } from './config/useFlyoutMenu.js';\nimport { DSFlyoutMenuName, FLYOUT_MENU_SLOTS } from './constants/index.js';\nimport { DSFlyoutMenuPropTypesSchema, type DSFlyoutMenuT } from './react-desc-prop-types.js';\nimport { getAriaSetSizeAndPosInSetBySiblingList, isRootNode } from '../../utils/nodesTypeguardsAndGetters.js';\nimport { MenuButtonContextProvider } from '../../MenuButtonContextProviderCTX.js';\nimport { useSideEffectSyntheticEvent } from '../../config/useSideEffectSyntheticEvent.js';\nimport type { MenuBehaviouralContextProviderCTX } from '../DSMenuBehaviouralContextProvider/config/useMenuBehaviouralContextProvider.js';\nconst StyledWrapper = styled(Grid, {\n name: DSFlyoutMenuName,\n slot: FLYOUT_MENU_SLOTS.ROOT,\n})`\n min-width: 1px;\n background-color: white;\n padding: ${({ theme }) => theme.space.xxxs} 0;\n ${xStyledCommonProps}\n`;\n\nconst StyledFloatingWrapper = styled(FloatingWrapper, {\n name: DSFlyoutMenuName,\n slot: FLYOUT_MENU_SLOTS.FLOATING_WRAPPER,\n})``;\n\nconst StyledMenu = styled('div', { name: DSFlyoutMenuName, slot: FLYOUT_MENU_SLOTS.LIST_WRAPPER })<{\n $maxHeight: string | number;\n}>`\n max-height: ${({ $maxHeight }) => (typeof $maxHeight === 'number' ? `${$maxHeight}px` : $maxHeight)};\n overflow-y: auto;\n padding: 0;\n margin: 0;\n`;\n\nconst NoComponentPlaceholder = () => null;\n\ntype MenuOpenStateChangeOpts = {\n itemNode: DSFlyoutMenuT.Props['itemNode'];\n focusableNodes: MenuBehaviouralContextProviderCTX['propsWithDefault']['focusableNodes'];\n openIntentPendingRef: MenuBehaviouralContextProviderCTX['openIntentPendingRef'];\n trackFocusFirstChildItem: MenuBehaviouralContextProviderCTX['trackFocusFirstChildItem'];\n isOpenStateOwnedByConsumer: boolean;\n};\n\n// Runs when the open state changes (and once on mount), so only an open reaches past the first line: a closed -> open\n// edge, or a menu that mounts already open. The flyout of a closed menu stays mounted, so a mount is not an open.\n// An open INTENT of the widget (click, ArrowDown/Up) already declared where the focus goes. When the consumer owns the\n// open state, a menu can also be opened by something that never went through the widget's own intents (an external\n// button, a menubar switching menus...), so nobody declared it: declare the default intent, like every open does,\n// \"the first item\", never the item the menu had focused when it was closed.\n// The items focus themselves from their own ref callbacks, as they do for every other focus intent.\nconst handleMenuOpenStateChange = (isMenuOpen: boolean, opts: MenuOpenStateChangeOpts) => {\n const { itemNode, focusableNodes, openIntentPendingRef, trackFocusFirstChildItem, isOpenStateOwnedByConsumer } = opts;\n if (!isMenuOpen || !isRootNode(itemNode)) return;\n const wasIntentArmed = openIntentPendingRef.current;\n // eslint-disable-next-line no-param-reassign\n openIntentPendingRef.current = false;\n if (isOpenStateOwnedByConsumer && !wasIntentArmed && focusableNodes.length > 0)\n trackFocusFirstChildItem(itemNode as unknown as DSMenuButtonT.PseudoFocusableMenuNodes);\n};\n\nconst DSFlyoutMenu: React.ComponentType<DSFlyoutMenuT.Props> = (props) => {\n const { propsWithDefault, xstyledProps } = useFlyoutMenu(props);\n const {\n ownerProps: { getOwnerProps, getOwnerPropsArguments },\n } = React.useContext(MenuButtonContextProvider);\n const {\n instanceUid,\n globalEventsHelpers: { mainMenuRef, handleSubmenusRefChange },\n openIntentPendingRef,\n menuItemEventsHandlers: { handleMenuTabKeyDownCapture },\n trackFocusFirstChildItem,\n propsWithDefault: { focusableNodes, a11yDangerouslyConsumerOwnedMenuOpenState },\n } = React.useContext(MenuBehaviouralContextProviderContext);\n const [didAnimationEnd, setDidAnimationEnd] = React.useState(false);\n\n const { setFloatingRef, floatingStyles, floatingContext, ItemRenderer, isMenuOpen, itemNode } = propsWithDefault;\n const ariaPositionsByDsId = React.useMemo(\n // DSTree doesn't support children having a polymorphic type, so we need to cast it manually (same as below)\n () => getAriaSetSizeAndPosInSetBySiblingList(itemNode.children as DSMenuButtonT.MenuNode[]),\n [itemNode.children],\n );\n const handleRefChange = React.useCallback(\n (node: HTMLDivElement) => {\n if (isRootNode(itemNode)) {\n mainMenuRef.current = node;\n return;\n }\n handleSubmenusRefChange(node, itemNode.dsId);\n },\n [handleSubmenusRefChange, itemNode, mainMenuRef],\n );\n\n // The open state is owned by someone else when `a11yDangerouslyConsumerOwnedMenuOpenState` is set: from this component\n // nothing observable tells how or why it flipped, so reacting to it is a sync with external state, the one case where\n // a side effect is the right tool (see `useSideEffectSyntheticEvent`). It is kept to this single call.\n useSideEffectSyntheticEvent(isMenuOpen, handleMenuOpenStateChange, {\n itemNode,\n focusableNodes,\n openIntentPendingRef,\n trackFocusFirstChildItem,\n isOpenStateOwnedByConsumer: a11yDangerouslyConsumerOwnedMenuOpenState !== undefined,\n });\n\n const handleAnimationStartTrigger = React.useCallback(() => {\n setDidAnimationEnd(false);\n }, []);\n const handleAnimationEnd = React.useCallback(() => {\n setDidAnimationEnd(true);\n }, []);\n\n return (\n <StyledFloatingWrapper\n innerRef={setFloatingRef}\n floatingStyles={floatingStyles}\n isOpen={isMenuOpen}\n context={floatingContext}\n onAnimationStartTriggered={handleAnimationStartTrigger}\n onAnimationEnd={handleAnimationEnd}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n // Adding a data-testid for legacy e2e tests\n data-testid=\"ds-floating-wrapper-root\"\n >\n <StyledWrapper getOwnerProps={getOwnerProps} getOwnerPropsArguments={getOwnerPropsArguments} {...xstyledProps}>\n <StyledMenu\n role=\"menu\"\n // Tab is handled in the capture phase of the ROOT menu only: nested submenus are React descendants of it (their\n // events reach it too), attaching it to them as well would run the handler twice per keypress\n onKeyDownCapture={isRootNode(itemNode) ? handleMenuTabKeyDownCapture : undefined}\n innerRef={handleRefChange}\n $maxHeight={itemNode.plainItem.maxHeight ?? menuSpecificDefaultProps.maxHeight}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n {itemNode.children.map((optionNode) => {\n const ariaPosition = ariaPositionsByDsId.get(optionNode.dsId);\n return (\n <DSMenuItemRendererFactory\n key={`flyout-menu-item-${optionNode.dsId}-${instanceUid}`}\n // DSTree doesn't support children having a polymorphic type, so we need to cast it manually\n itemNode={optionNode as DSMenuButtonT.MenuNode}\n ItemRenderer={ItemRenderer}\n // we are passing the DSFlyoutMenu component as a prop to the DSMenuItemRendererFactory\n // this solves the circular-ish dependency\n // the conditional `didAnimationEnd` solves the visual artefact of nested FloatingWrapper wrongly positioned due to animation\n FlyoutMenuCircularDepInject={didAnimationEnd ? DSFlyoutMenu : NoComponentPlaceholder}\n aria-posinset={ariaPosition?.ariaPosInSet}\n aria-setsize={ariaPosition?.ariaSetSize}\n />\n );\n })}\n </StyledMenu>\n </StyledWrapper>\n </StyledFloatingWrapper>\n );\n};\n\nDSFlyoutMenu.displayName = DSFlyoutMenuName;\nconst DSFlyoutMenuWithSchema = describe(DSFlyoutMenu);\nDSFlyoutMenuWithSchema.propTypes = DSFlyoutMenuPropTypesSchema;\n\nexport { DSFlyoutMenu, DSFlyoutMenuWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADgJT;AAhJd,iCAAgC;AAChC,qBAAqB;AACrB,8BAAyB;AACzB,uBAA2C;AAE3C,mBAAkB;AAClB,mCAA6D;AAC7D,+CAAsD;AACtD,uCAA0C;AAC1C,2BAA8B;AAC9B,uBAAoD;AACpD,IAAAA,gCAAgE;AAChE,uCAAmE;AACnE,0CAA0C;AAC1C,yCAA4C;AAE5C,MAAM,oBAAgB,yBAAO,qBAAM;AAAA,EACjC,MAAM;AAAA,EACN,MAAM,mCAAkB;A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AAe;AAAA,gBAC9D,iBAAe,cAAc;AAAA,gBAC7B,gBAAc,cAAc;AAAA;AAAA,cATvB,oBAAoB,WAAW,IAAI,IAAI,WAAW;AAAA,YAUzD;AAAA,UAEJ,CAAC;AAAA;AAAA,MACH,GACF;AAAA;AAAA,EACF;AAEJ;AAEA,aAAa,cAAc;AAC3B,MAAM,6BAAyB,kCAAS,YAAY;AACpD,uBAAuB,YAAY;",
|
|
6
6
|
"names": ["import_react_desc_prop_types", "React"]
|
|
7
7
|
}
|
|
@@ -46,12 +46,13 @@ const DSMenuBehaviouralContextProvider = (props) => {
|
|
|
46
46
|
const {
|
|
47
47
|
trackFocusRegionReset,
|
|
48
48
|
propsWithDefault: { children },
|
|
49
|
-
preventBlurReset
|
|
49
|
+
preventBlurReset,
|
|
50
|
+
isMenuOpen
|
|
50
51
|
} = ctx;
|
|
51
52
|
const config = import_react.default.useMemo(
|
|
52
53
|
() => ({
|
|
53
54
|
onBlur: () => {
|
|
54
|
-
if (!preventBlurReset.current) {
|
|
55
|
+
if (!preventBlurReset.current && !isMenuOpen) {
|
|
55
56
|
trackFocusRegionReset();
|
|
56
57
|
setTimeout(() => {
|
|
57
58
|
preventBlurReset.current = false;
|
|
@@ -59,7 +60,7 @@ const DSMenuBehaviouralContextProvider = (props) => {
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
}),
|
|
62
|
-
[preventBlurReset, trackFocusRegionReset]
|
|
63
|
+
[isMenuOpen, preventBlurReset, trackFocusRegionReset]
|
|
63
64
|
);
|
|
64
65
|
const handleOnBlurOut = (0, import_ds_hooks_on_blur_out.useOnBlurOut)(config);
|
|
65
66
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MenuBehaviouralContextProviderCTX.MenuBehaviouralContextProviderContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { onBlur: handleOnBlurOut, children }) });
|
package/dist/cjs/parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/DSMenuBehaviouralContextProvider/DSMenuBehaviouralContextProvider.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["// this not interactive per se, the implementation is listening the bubble phase of the events\n// from the children, this is the MVC pattern in action\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { useOnBlurOut } from '@elliemae/ds-hooks-on-blur-out';\nimport {\n type DSMenuBehaviouralContextProviderT,\n DSMenuBehaviouralContextProviderPropTypesSchema,\n} from './react-desc-prop-types.js';\nimport { useMenuBehaviouralContextProvider } from './config/useMenuBehaviouralContextProvider.js';\nimport { MenuBehaviouralContextProviderContext } from './MenuBehaviouralContextProviderCTX.js';\nimport { DSMenuBehaviouralContextProviderName } from './constants/index.js';\n\nconst DSMenuBehaviouralContextProvider: React.ComponentType<DSMenuBehaviouralContextProviderT.Props> = (props) => {\n const ctx = useMenuBehaviouralContextProvider(props);\n const {\n trackFocusRegionReset,\n propsWithDefault: { children },\n preventBlurReset,\n } = ctx;\n\n const config = React.useMemo(\n () => ({\n onBlur: () => {\n // we have a portal, the portal temporarily steals the focus\n // invoking the blur event\n // when the blur event is invoked because the focus is stolen we do not want to reset the focus\n // any other blur event should reset the focus\n if (!preventBlurReset.current) {\n trackFocusRegionReset();\n setTimeout(() => {\n preventBlurReset.current = false;\n });\n }\n },\n }),\n [preventBlurReset, trackFocusRegionReset],\n );\n const handleOnBlurOut = useOnBlurOut(config);\n return (\n <MenuBehaviouralContextProviderContext.Provider value={ctx}>\n <div onBlur={handleOnBlurOut}>{children}</div>\n </MenuBehaviouralContextProviderContext.Provider>\n );\n};\n\nDSMenuBehaviouralContextProvider.displayName = DSMenuBehaviouralContextProviderName;\nconst DSMenuBehaviouralContextProviderWithSchema = describe(DSMenuBehaviouralContextProvider);\nDSMenuBehaviouralContextProviderWithSchema.propTypes = DSMenuBehaviouralContextProviderPropTypesSchema;\n\nexport { DSMenuBehaviouralContextProvider, DSMenuBehaviouralContextProviderWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["// this not interactive per se, the implementation is listening the bubble phase of the events\n// from the children, this is the MVC pattern in action\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { useOnBlurOut } from '@elliemae/ds-hooks-on-blur-out';\nimport {\n type DSMenuBehaviouralContextProviderT,\n DSMenuBehaviouralContextProviderPropTypesSchema,\n} from './react-desc-prop-types.js';\nimport { useMenuBehaviouralContextProvider } from './config/useMenuBehaviouralContextProvider.js';\nimport { MenuBehaviouralContextProviderContext } from './MenuBehaviouralContextProviderCTX.js';\nimport { DSMenuBehaviouralContextProviderName } from './constants/index.js';\n\nconst DSMenuBehaviouralContextProvider: React.ComponentType<DSMenuBehaviouralContextProviderT.Props> = (props) => {\n const ctx = useMenuBehaviouralContextProvider(props);\n const {\n trackFocusRegionReset,\n propsWithDefault: { children },\n preventBlurReset,\n isMenuOpen,\n } = ctx;\n\n const config = React.useMemo(\n () => ({\n onBlur: () => {\n // we have a portal, the portal temporarily steals the focus\n // invoking the blur event\n // when the blur event is invoked because the focus is stolen we do not want to reset the focus\n // any other blur event should reset the focus\n // `preventBlurReset` is armed by the menu's own open intents, so a menu that the consumer opened by owning its\n // open state (a11yDangerouslyConsumerOwnedMenuOpenState) never armed it: while the menu is open, whoever\n // opened it, a blur is the portal stealing the focus and must not reset the focus tracker either\n if (!preventBlurReset.current && !isMenuOpen) {\n trackFocusRegionReset();\n setTimeout(() => {\n preventBlurReset.current = false;\n });\n }\n },\n }),\n [isMenuOpen, preventBlurReset, trackFocusRegionReset],\n );\n const handleOnBlurOut = useOnBlurOut(config);\n return (\n <MenuBehaviouralContextProviderContext.Provider value={ctx}>\n <div onBlur={handleOnBlurOut}>{children}</div>\n </MenuBehaviouralContextProviderContext.Provider>\n );\n};\n\nDSMenuBehaviouralContextProvider.displayName = DSMenuBehaviouralContextProviderName;\nconst DSMenuBehaviouralContextProviderWithSchema = describe(DSMenuBehaviouralContextProvider);\nDSMenuBehaviouralContextProviderWithSchema.propTypes = DSMenuBehaviouralContextProviderPropTypesSchema;\n\nexport { DSMenuBehaviouralContextProvider, DSMenuBehaviouralContextProviderWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD8CjB;AA3CN,mBAAkB;AAClB,8BAAyB;AACzB,kCAA6B;AAC7B,mCAGO;AACP,+CAAkD;AAClD,+CAAsD;AACtD,uBAAqD;AAErD,MAAM,mCAAiG,CAAC,UAAU;AAChH,QAAM,UAAM,4EAAkC,KAAK;AACnD,QAAM;AAAA,IACJ;AAAA,IACA,kBAAkB,EAAE,SAAS;AAAA,IAC7B;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,SAAS,aAAAA,QAAM;AAAA,IACnB,OAAO;AAAA,MACL,QAAQ,MAAM;AAQZ,YAAI,CAAC,iBAAiB,WAAW,CAAC,YAAY;AAC5C,gCAAsB;AACtB,qBAAW,MAAM;AACf,6BAAiB,UAAU;AAAA,UAC7B,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,YAAY,kBAAkB,qBAAqB;AAAA,EACtD;AACA,QAAM,sBAAkB,0CAAa,MAAM;AAC3C,SACE,4CAAC,+EAAsC,UAAtC,EAA+C,OAAO,KACrD,sDAAC,SAAI,QAAQ,iBAAkB,UAAS,GAC1C;AAEJ;AAEA,iCAAiC,cAAc;AAC/C,MAAM,iDAA6C,kCAAS,gCAAgC;AAC5F,2CAA2C,YAAY;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -40,6 +40,8 @@ var import_constants = require("../constants/index.js");
|
|
|
40
40
|
var import_nodeGettersByCriterias = require("../utils/nodeGettersByCriterias.js");
|
|
41
41
|
const useFocusTracker = () => {
|
|
42
42
|
const shouldFocusImmediately = import_react.default.useRef(false);
|
|
43
|
+
const shouldRefocusTrigger = import_react.default.useRef(true);
|
|
44
|
+
const [triggerFocusRequestId, setTriggerFocusRequestId] = import_react.default.useState(0);
|
|
43
45
|
const [focusRegion, setFocusRegion] = import_react.default.useState("");
|
|
44
46
|
const focusedRegionPerformanceHelper = import_react.default.useRef("");
|
|
45
47
|
const preventBlurReset = import_react.default.useRef(false);
|
|
@@ -53,6 +55,10 @@ const useFocusTracker = () => {
|
|
|
53
55
|
focusedRegionPerformanceHelper.current = newFocusRegion;
|
|
54
56
|
focusedElementItemNode.current = focusNode;
|
|
55
57
|
shouldFocusImmediately.current = flags?.shouldFocusImmediately ?? false;
|
|
58
|
+
shouldRefocusTrigger.current = flags?.refocusTrigger ?? true;
|
|
59
|
+
if (newFocusRegion === import_constants.MENU_FOCUS_REGIONS.TRIGGER && shouldRefocusTrigger.current) {
|
|
60
|
+
setTriggerFocusRequestId((previousRequestId) => previousRequestId + 1);
|
|
61
|
+
}
|
|
56
62
|
return focusNode;
|
|
57
63
|
},
|
|
58
64
|
50,
|
|
@@ -61,7 +67,7 @@ const useFocusTracker = () => {
|
|
|
61
67
|
[]
|
|
62
68
|
);
|
|
63
69
|
const trackFocusTrigger = import_react.default.useCallback(
|
|
64
|
-
(options = {
|
|
70
|
+
(options = {}) => racingConditionDebounceTrackFocus(import_constants.MENU_FOCUS_REGIONS.TRIGGER, null, options),
|
|
65
71
|
[racingConditionDebounceTrackFocus]
|
|
66
72
|
);
|
|
67
73
|
const trackFocusNode = import_react.default.useCallback(
|
|
@@ -166,8 +172,10 @@ const useFocusTracker = () => {
|
|
|
166
172
|
() => ({
|
|
167
173
|
preventBlurReset,
|
|
168
174
|
focusRegion,
|
|
175
|
+
triggerFocusRequestId,
|
|
169
176
|
focusedElementItemNode,
|
|
170
177
|
shouldFocusImmediately,
|
|
178
|
+
shouldRefocusTrigger,
|
|
171
179
|
trackFocusTrigger,
|
|
172
180
|
trackFocusNode,
|
|
173
181
|
trackFocusRegionReset,
|
|
@@ -179,6 +187,7 @@ const useFocusTracker = () => {
|
|
|
179
187
|
}),
|
|
180
188
|
[
|
|
181
189
|
focusRegion,
|
|
190
|
+
triggerFocusRequestId,
|
|
182
191
|
trackFocusFirstChildItem,
|
|
183
192
|
trackFocusLastChildItem,
|
|
184
193
|
trackFocusNextItem,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/parts/DSMenuBehaviouralContextProvider/config/useFocusTracker.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable no-console */\n/* eslint-disable max-lines */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable prettier/prettier */\nimport { throttle } from 'lodash-es';\nimport React from 'react';\nimport type { DSMenuButtonT } from '../../../react-desc-prop-types.js';\nimport {\n isFocusableNode,\n isGroup,\n isMenuNodeAllowedToHaveChildren,\n isRootNode,\n} from '../../../utils/nodesTypeguardsAndGetters.js';\nimport { TREE_STRUCTURE_ERRORS } from '../constants/Errors.js';\nimport { MENU_FOCUS_REGIONS } from '../constants/index.js';\nimport { getFocusableSiblingsList } from '../utils/nodeGettersByCriterias.js';\n\ntype MenuFocusRegionsValues = (typeof MENU_FOCUS_REGIONS)[keyof typeof MENU_FOCUS_REGIONS];\n// if MenuFocusRegionsValues may be a string or a function that returns a string, we want only the resolved strings\ntype ValidRegionsValues<T extends MenuFocusRegionsValues = MenuFocusRegionsValues> = T extends string\n ? T\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends (...args: any) => any\n ? ReturnType<T>\n : never;\n\nexport const useFocusTracker = () => {\n const shouldFocusImmediately = React.useRef(false);\n const [focusRegion, setFocusRegion] = React.useState<ValidRegionsValues>('');\n // we want to keep the focus region trackers as stable as possible to avoid unnecessary re-renders\n // there is no need to change the trackers reference when the focus region changes,\n // since changing the focus region is always triggered by a final user interaction (so after reacts reconciliation)\n const focusedRegionPerformanceHelper = React.useRef('') as React.MutableRefObject<ValidRegionsValues>;\n const preventBlurReset = React.useRef(false);\n\n const focusedElementItemNode = React.useRef(\n null,\n ) as React.MutableRefObject<DSMenuButtonT.PseudoFocusableMenuNodes | null>;\n\n // typescript with debounce doesn't work well, so we need to disable the exhaustive deps rule here\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const racingConditionDebounceTrackFocus = React.useCallback(\n throttle(\n (\n newFocusRegion: ValidRegionsValues,\n focusNode: DSMenuButtonT.PseudoFocusableMenuNodes | null,\n flags?: { shouldFocusImmediately?: boolean },\n ) => {\n setFocusRegion(newFocusRegion);\n focusedRegionPerformanceHelper.current = newFocusRegion;\n focusedElementItemNode.current = focusNode;\n\n shouldFocusImmediately.current = flags?.shouldFocusImmediately ?? false;\n\n return focusNode;\n },\n 50,\n { leading: true, trailing: true },\n ),\n [],\n );\n\n const trackFocusTrigger = React.useCallback(\n (options = { shouldFocusImmediately: false }) =>\n racingConditionDebounceTrackFocus(MENU_FOCUS_REGIONS.TRIGGER, null, options),\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusNode = React.useCallback(\n (nodeToFocus: DSMenuButtonT.PseudoFocusableMenuNodes) => {\n const newFocusRegion = MENU_FOCUS_REGIONS.ITEM_BY_DSID(nodeToFocus.dsId);\n racingConditionDebounceTrackFocus(newFocusRegion, nodeToFocus);\n },\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusRegionReset = React.useCallback(\n () => racingConditionDebounceTrackFocus(MENU_FOCUS_REGIONS.RESET, null),\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusFirstChildItem = React.useCallback(\n (itemNode: DSMenuButtonT.PseudoFocusableMenuNodes) => {\n if (!isMenuNodeAllowedToHaveChildren(itemNode)) {\n console.log('focus first child item > itemNode', itemNode);\n throw TREE_STRUCTURE_ERRORS.NODE_CANNOT_HAVE_CHILDREN;\n }\n if (itemNode.children.length === 0) {\n console.log(itemNode);\n throw new Error('No children found in the item node');\n }\n const focusableChildrenNodes = getFocusableSiblingsList(itemNode.children[0]);\n if (focusableChildrenNodes.length === 0) {\n console.log('focus first child item > itemNode', itemNode);\n throw new Error('No focusable nodes found in the children of the item node');\n }\n\n const newFocusedNode = focusableChildrenNodes[0];\n return racingConditionDebounceTrackFocus(MENU_FOCUS_REGIONS.ITEM_BY_DSID(newFocusedNode.dsId), newFocusedNode);\n },\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusLastChildItem = React.useCallback(\n (itemNode: DSMenuButtonT.PseudoFocusableMenuNodes) => {\n if (!isMenuNodeAllowedToHaveChildren(itemNode)) {\n console.log('focus last child item > itemNode', itemNode);\n throw new Error('Item node is not allowed to have children');\n }\n if (itemNode.children.length === 0) {\n console.log(itemNode);\n throw new Error('No children found in the item node');\n }\n const focusableChildrenNodes = getFocusableSiblingsList(itemNode.children[0]);\n if (focusableChildrenNodes.length === 0) {\n console.log('focus last child item > itemNode', itemNode);\n throw new Error('No focusable nodes found in the children of the item node');\n }\n return racingConditionDebounceTrackFocus(\n MENU_FOCUS_REGIONS.ITEM_BY_DSID(focusableChildrenNodes[focusableChildrenNodes.length - 1].dsId),\n focusableChildrenNodes[focusableChildrenNodes.length - 1],\n );\n },\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusNextItem = React.useCallback(\n (itemNode: DSMenuButtonT.PseudoFocusableMenuNodes) => {\n const focusableSiblingsNodes = getFocusableSiblingsList(itemNode);\n // we find the current item node index in the focusableSiblingsNodes array\n const currIndex = focusableSiblingsNodes.findIndex((node) => node.dsId === itemNode.dsId);\n\n const nextIndex = currIndex + 1 < focusableSiblingsNodes.length ? currIndex + 1 : 0;\n const newFocusedNode = focusableSiblingsNodes[nextIndex];\n return racingConditionDebounceTrackFocus(MENU_FOCUS_REGIONS.ITEM_BY_DSID(newFocusedNode.dsId), newFocusedNode);\n },\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusPreviousItem = React.useCallback(\n (itemNode: DSMenuButtonT.PseudoFocusableMenuNodes) => {\n const focusableSiblingsNodes = getFocusableSiblingsList(itemNode);\n // we find the current item node index in the focusableSiblingsNodes array\n const currIndex = focusableSiblingsNodes.findIndex((node) => node.dsId === itemNode.dsId);\n\n const previousIndex = currIndex - 1 >= 0 ? currIndex - 1 : focusableSiblingsNodes.length - 1;\n const newFocusNode = focusableSiblingsNodes[previousIndex];\n return racingConditionDebounceTrackFocus(MENU_FOCUS_REGIONS.ITEM_BY_DSID(newFocusNode.dsId), newFocusNode);\n },\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusParentItem = React.useCallback(\n (itemNode: DSMenuButtonT.PseudoFocusableMenuNodes) => {\n const { parent } = itemNode;\n // this typecast is required because we are reading the parent property from the itemNode\n // while this function can receive any PseudoFocusableMenuNodes,\n // the parent property may be a non-pseudo focusable node (specifically when the parent property is group node)\n const parentNode = parent;\n if (!parentNode) {\n console.log('focus parent item', { itemNode, parentNode });\n throw new Error(`No parent node found for the item node`);\n }\n\n let nodeToFocus: DSMenuButtonT.PseudoFocusableMenuNodes | null = parentNode;\n // if parent is SingleSelectGroupNode then we can't focus it\n if (isGroup(parentNode)) {\n const groupParent = parentNode.parent;\n if (!isFocusableNode(groupParent) && !isRootNode(groupParent)) {\n console.log('focus parent item', { itemNode, parentNode, groupParent });\n throw new Error('No focusable parent node found for the item node');\n }\n nodeToFocus = groupParent;\n }\n\n const focusableNode = isRootNode(nodeToFocus) ? null : nodeToFocus;\n const newFocusNode = focusableNode;\n if (!newFocusNode) trackFocusTrigger();\n else trackFocusNode(newFocusNode);\n\n return focusableNode;\n },\n [trackFocusNode, trackFocusTrigger],\n );\n\n return React.useMemo(\n () => ({\n preventBlurReset,\n focusRegion,\n focusedElementItemNode,\n shouldFocusImmediately,\n trackFocusTrigger,\n trackFocusNode,\n trackFocusRegionReset,\n trackFocusFirstChildItem,\n trackFocusLastChildItem,\n trackFocusNextItem,\n trackFocusPreviousItem,\n trackFocusParentItem,\n }),\n [\n focusRegion,\n trackFocusFirstChildItem,\n trackFocusLastChildItem,\n trackFocusNextItem,\n trackFocusNode,\n trackFocusParentItem,\n trackFocusPreviousItem,\n trackFocusRegionReset,\n trackFocusTrigger,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,uBAAyB;AACzB,mBAAkB;AAElB,uCAKO;AACP,oBAAsC;AACtC,uBAAmC;AACnC,oCAAyC;AAWlC,MAAM,kBAAkB,MAAM;AACnC,QAAM,yBAAyB,aAAAA,QAAM,OAAO,KAAK;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-console */\n/* eslint-disable max-lines */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable prettier/prettier */\nimport { throttle } from 'lodash-es';\nimport React from 'react';\nimport type { DSMenuButtonT } from '../../../react-desc-prop-types.js';\nimport {\n isFocusableNode,\n isGroup,\n isMenuNodeAllowedToHaveChildren,\n isRootNode,\n} from '../../../utils/nodesTypeguardsAndGetters.js';\nimport { TREE_STRUCTURE_ERRORS } from '../constants/Errors.js';\nimport { MENU_FOCUS_REGIONS } from '../constants/index.js';\nimport { getFocusableSiblingsList } from '../utils/nodeGettersByCriterias.js';\n\ntype MenuFocusRegionsValues = (typeof MENU_FOCUS_REGIONS)[keyof typeof MENU_FOCUS_REGIONS];\n// if MenuFocusRegionsValues may be a string or a function that returns a string, we want only the resolved strings\ntype ValidRegionsValues<T extends MenuFocusRegionsValues = MenuFocusRegionsValues> = T extends string\n ? T\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends (...args: any) => any\n ? ReturnType<T>\n : never;\n\nexport const useFocusTracker = () => {\n const shouldFocusImmediately = React.useRef(false);\n /*\n * Separates \"recording that focus is on the trigger\" from \"requesting focus return\n * to the trigger\": the trigger's own focus event tracks the region passively, while\n * menu-driven intents (close, keyboard nav) actively refocus. Without the split, the\n * deferred refocus can land after focus already legitimately moved on (e.g. the user\n * Tabbed away) and steal it back.\n */\n const shouldRefocusTrigger = React.useRef(true);\n /*\n * Identity of the latest request to return focus to the trigger. The trigger keys its ref callback on it, so each\n * request re-invokes the callback exactly once (React calls a ref callback again only when its reference changes).\n * It is deliberately NOT derived by comparing the focus region against a value stored during render: that\n * comparison is not idempotent, so React's StrictMode double render consumed it and the refocus never happened.\n */\n const [triggerFocusRequestId, setTriggerFocusRequestId] = React.useState(0);\n const [focusRegion, setFocusRegion] = React.useState<ValidRegionsValues>('');\n // we want to keep the focus region trackers as stable as possible to avoid unnecessary re-renders\n // there is no need to change the trackers reference when the focus region changes,\n // since changing the focus region is always triggered by a final user interaction (so after reacts reconciliation)\n const focusedRegionPerformanceHelper = React.useRef('') as React.MutableRefObject<ValidRegionsValues>;\n const preventBlurReset = React.useRef(false);\n\n const focusedElementItemNode = React.useRef(\n null,\n ) as React.MutableRefObject<DSMenuButtonT.PseudoFocusableMenuNodes | null>;\n\n // typescript with debounce doesn't work well, so we need to disable the exhaustive deps rule here\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const racingConditionDebounceTrackFocus = React.useCallback(\n throttle(\n (\n newFocusRegion: ValidRegionsValues,\n focusNode: DSMenuButtonT.PseudoFocusableMenuNodes | null,\n flags?: { shouldFocusImmediately?: boolean; refocusTrigger?: boolean },\n ) => {\n setFocusRegion(newFocusRegion);\n focusedRegionPerformanceHelper.current = newFocusRegion;\n focusedElementItemNode.current = focusNode;\n\n shouldFocusImmediately.current = flags?.shouldFocusImmediately ?? false;\n shouldRefocusTrigger.current = flags?.refocusTrigger ?? true;\n if (newFocusRegion === MENU_FOCUS_REGIONS.TRIGGER && shouldRefocusTrigger.current) {\n setTriggerFocusRequestId((previousRequestId) => previousRequestId + 1);\n }\n\n return focusNode;\n },\n 50,\n { leading: true, trailing: true },\n ),\n [],\n );\n\n const trackFocusTrigger = React.useCallback(\n (options: { shouldFocusImmediately?: boolean; refocusTrigger?: boolean } = {}) =>\n racingConditionDebounceTrackFocus(MENU_FOCUS_REGIONS.TRIGGER, null, options),\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusNode = React.useCallback(\n (nodeToFocus: DSMenuButtonT.PseudoFocusableMenuNodes) => {\n const newFocusRegion = MENU_FOCUS_REGIONS.ITEM_BY_DSID(nodeToFocus.dsId);\n racingConditionDebounceTrackFocus(newFocusRegion, nodeToFocus);\n },\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusRegionReset = React.useCallback(\n () => racingConditionDebounceTrackFocus(MENU_FOCUS_REGIONS.RESET, null),\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusFirstChildItem = React.useCallback(\n (itemNode: DSMenuButtonT.PseudoFocusableMenuNodes) => {\n if (!isMenuNodeAllowedToHaveChildren(itemNode)) {\n console.log('focus first child item > itemNode', itemNode);\n throw TREE_STRUCTURE_ERRORS.NODE_CANNOT_HAVE_CHILDREN;\n }\n if (itemNode.children.length === 0) {\n console.log(itemNode);\n throw new Error('No children found in the item node');\n }\n const focusableChildrenNodes = getFocusableSiblingsList(itemNode.children[0]);\n if (focusableChildrenNodes.length === 0) {\n console.log('focus first child item > itemNode', itemNode);\n throw new Error('No focusable nodes found in the children of the item node');\n }\n\n const newFocusedNode = focusableChildrenNodes[0];\n return racingConditionDebounceTrackFocus(MENU_FOCUS_REGIONS.ITEM_BY_DSID(newFocusedNode.dsId), newFocusedNode);\n },\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusLastChildItem = React.useCallback(\n (itemNode: DSMenuButtonT.PseudoFocusableMenuNodes) => {\n if (!isMenuNodeAllowedToHaveChildren(itemNode)) {\n console.log('focus last child item > itemNode', itemNode);\n throw new Error('Item node is not allowed to have children');\n }\n if (itemNode.children.length === 0) {\n console.log(itemNode);\n throw new Error('No children found in the item node');\n }\n const focusableChildrenNodes = getFocusableSiblingsList(itemNode.children[0]);\n if (focusableChildrenNodes.length === 0) {\n console.log('focus last child item > itemNode', itemNode);\n throw new Error('No focusable nodes found in the children of the item node');\n }\n return racingConditionDebounceTrackFocus(\n MENU_FOCUS_REGIONS.ITEM_BY_DSID(focusableChildrenNodes[focusableChildrenNodes.length - 1].dsId),\n focusableChildrenNodes[focusableChildrenNodes.length - 1],\n );\n },\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusNextItem = React.useCallback(\n (itemNode: DSMenuButtonT.PseudoFocusableMenuNodes) => {\n const focusableSiblingsNodes = getFocusableSiblingsList(itemNode);\n // we find the current item node index in the focusableSiblingsNodes array\n const currIndex = focusableSiblingsNodes.findIndex((node) => node.dsId === itemNode.dsId);\n\n const nextIndex = currIndex + 1 < focusableSiblingsNodes.length ? currIndex + 1 : 0;\n const newFocusedNode = focusableSiblingsNodes[nextIndex];\n return racingConditionDebounceTrackFocus(MENU_FOCUS_REGIONS.ITEM_BY_DSID(newFocusedNode.dsId), newFocusedNode);\n },\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusPreviousItem = React.useCallback(\n (itemNode: DSMenuButtonT.PseudoFocusableMenuNodes) => {\n const focusableSiblingsNodes = getFocusableSiblingsList(itemNode);\n // we find the current item node index in the focusableSiblingsNodes array\n const currIndex = focusableSiblingsNodes.findIndex((node) => node.dsId === itemNode.dsId);\n\n const previousIndex = currIndex - 1 >= 0 ? currIndex - 1 : focusableSiblingsNodes.length - 1;\n const newFocusNode = focusableSiblingsNodes[previousIndex];\n return racingConditionDebounceTrackFocus(MENU_FOCUS_REGIONS.ITEM_BY_DSID(newFocusNode.dsId), newFocusNode);\n },\n [racingConditionDebounceTrackFocus],\n );\n\n const trackFocusParentItem = React.useCallback(\n (itemNode: DSMenuButtonT.PseudoFocusableMenuNodes) => {\n const { parent } = itemNode;\n // this typecast is required because we are reading the parent property from the itemNode\n // while this function can receive any PseudoFocusableMenuNodes,\n // the parent property may be a non-pseudo focusable node (specifically when the parent property is group node)\n const parentNode = parent;\n if (!parentNode) {\n console.log('focus parent item', { itemNode, parentNode });\n throw new Error(`No parent node found for the item node`);\n }\n\n let nodeToFocus: DSMenuButtonT.PseudoFocusableMenuNodes | null = parentNode;\n // if parent is SingleSelectGroupNode then we can't focus it\n if (isGroup(parentNode)) {\n const groupParent = parentNode.parent;\n if (!isFocusableNode(groupParent) && !isRootNode(groupParent)) {\n console.log('focus parent item', { itemNode, parentNode, groupParent });\n throw new Error('No focusable parent node found for the item node');\n }\n nodeToFocus = groupParent;\n }\n\n const focusableNode = isRootNode(nodeToFocus) ? null : nodeToFocus;\n const newFocusNode = focusableNode;\n if (!newFocusNode) trackFocusTrigger();\n else trackFocusNode(newFocusNode);\n\n return focusableNode;\n },\n [trackFocusNode, trackFocusTrigger],\n );\n\n return React.useMemo(\n () => ({\n preventBlurReset,\n focusRegion,\n triggerFocusRequestId,\n focusedElementItemNode,\n shouldFocusImmediately,\n shouldRefocusTrigger,\n trackFocusTrigger,\n trackFocusNode,\n trackFocusRegionReset,\n trackFocusFirstChildItem,\n trackFocusLastChildItem,\n trackFocusNextItem,\n trackFocusPreviousItem,\n trackFocusParentItem,\n }),\n [\n focusRegion,\n triggerFocusRequestId,\n trackFocusFirstChildItem,\n trackFocusLastChildItem,\n trackFocusNextItem,\n trackFocusNode,\n trackFocusParentItem,\n trackFocusPreviousItem,\n trackFocusRegionReset,\n trackFocusTrigger,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,uBAAyB;AACzB,mBAAkB;AAEl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BAAqB,EAAE,UAAU,YAAY,YAAY,CAAC;AACtE,gBAAM,IAAI,MAAM,kDAAkD;AAAA,QACpE;AACA,sBAAc;AAAA,MAChB;AAEA,YAAM,oBAAgB,6CAAW,WAAW,IAAI,OAAO;AACvD,YAAM,eAAe;AACrB,UAAI,CAAC,aAAc,mBAAkB;AAAA,UAChC,gBAAe,YAAY;AAEhC,aAAO;AAAA,IACT;AAAA,IACA,CAAC,gBAAgB,iBAAiB;AAAA,EACpC;AAEA,SAAO,aAAAA,QAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -54,19 +54,20 @@ const useGlobalEvents = ({
|
|
|
54
54
|
);
|
|
55
55
|
import_react.default.useEffect(() => {
|
|
56
56
|
const closeMenuAndSubmenus = (e) => {
|
|
57
|
+
if (!isMenuOpen) return;
|
|
57
58
|
handleChangeOpenedSubItems([], { itemNode: null, event: e });
|
|
58
|
-
onOpinionatedClose({ skipFocus: true });
|
|
59
|
+
onOpinionatedClose({ skipFocus: true, reason: "window-blur", event: e });
|
|
59
60
|
};
|
|
60
61
|
const detectIfClickIsOutsideMenuAndCloseIfSo = (e) => {
|
|
61
62
|
if (!isMenuOpen) return;
|
|
62
|
-
if (buttonDOMNodeRef.current
|
|
63
|
+
if (buttonDOMNodeRef.current?.contains(e.target)) return;
|
|
63
64
|
const isClickInsideMainMenu = mainMenuRef.current?.contains(e.target);
|
|
64
65
|
if (isClickInsideMainMenu) return;
|
|
65
66
|
const submenuNodesToCheck = Object.values(submenusRefs.current).filter(Boolean);
|
|
66
67
|
const isClickInsideAnySubmenu = submenuNodesToCheck.some((node) => node.contains(e.target));
|
|
67
68
|
if (isClickInsideAnySubmenu) return;
|
|
68
69
|
handleChangeOpenedSubItems([], { itemNode: null, event: e });
|
|
69
|
-
onOpinionatedClose({ skipFocus: true });
|
|
70
|
+
onOpinionatedClose({ skipFocus: true, reason: "outside-click", event: e });
|
|
70
71
|
};
|
|
71
72
|
window.addEventListener("blur", closeMenuAndSubmenus);
|
|
72
73
|
document.addEventListener("mousedown", detectIfClickIsOutsideMenuAndCloseIfSo);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/parts/DSMenuBehaviouralContextProvider/config/useGlobalEvents.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport type { DSMenuButtonT } from '../../../react-desc-prop-types.js';\nimport type { useMenuOpenStatus } from './useMenuOpenStatus.js';\nimport type { DSMenuBehaviouralContextProviderT } from '../react-desc-prop-types.js';\n\ntype UseGlobalEventsConfig = {\n menuOpenStatus: ReturnType<typeof useMenuOpenStatus>;\n handleChangeOpenedSubItems: Required<DSMenuButtonT.MenuBehaviouralLayerOptionalProps>['onDisplayedSubmenuChange'];\n propsWithDefault: DSMenuBehaviouralContextProviderT.InternalProps;\n};\n\nexport const useGlobalEvents = ({\n menuOpenStatus,\n handleChangeOpenedSubItems,\n propsWithDefault,\n}: UseGlobalEventsConfig) => {\n const { onOpinionatedClose, isMenuOpen } = menuOpenStatus;\n const { buttonDOMNodeRef } = propsWithDefault;\n const mainMenuRef = React.useRef<HTMLDivElement | null>(null);\n // we are using \"portal\" but then we check the native evenet to check if \"on click outside\" the menu\n // for such reason, we need to track the current HTML NODES of the submenus (topmost parent)\n // this will allow us to check if the click event is outside the menu or any of it's submenus\n const submenusRefs = React.useRef<Record<DSMenuButtonT.WithSubmenuMenuNodes['dsId'], HTMLElement>>({});\n const handleSubmenusRefChange = React.useCallback(\n (htmlNode: HTMLElement | null, dsId: DSMenuButtonT.WithSubmenuMenuNodes['dsId']) => {\n if (htmlNode) {\n submenusRefs.current[dsId] = htmlNode;\n } else {\n delete submenusRefs.current[dsId];\n }\n },\n [],\n );\n React.useEffect(() => {\n // when the window loses focus, close all the menus and submenus\n const closeMenuAndSubmenus = (e: FocusEvent) => {\n handleChangeOpenedSubItems([], { itemNode: null, event: e });\n onOpinionatedClose({ skipFocus: true });\n };\n // when the user clicks \"outside\" the menu and submenus, close all the menus and submenus\n const detectIfClickIsOutsideMenuAndCloseIfSo = (e: MouseEvent | TouchEvent) => {\n // we are running this on literally ALL the clicks that happen on the window\n // we don't want to be consuming resources that are not strictly necessary\n // if the main menu is not open, we don't need to check if the click is outside the menu ofc\n if (!isMenuOpen) return;\n // we discard the fastest to check \"trigger\" click first\n if (buttonDOMNodeRef.current
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAWX,MAAM,kBAAkB,CAAC;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACF,MAA6B;AAC3B,QAAM,EAAE,oBAAoB,WAAW,IAAI;AAC3C,QAAM,EAAE,iBAAiB,IAAI;AAC7B,QAAM,cAAc,aAAAA,QAAM,OAA8B,IAAI;AAI5D,QAAM,eAAe,aAAAA,QAAM,OAAwE,CAAC,CAAC;AACrG,QAAM,0BAA0B,aAAAA,QAAM;AAAA,IACpC,CAAC,UAA8B,SAAqD;AAClF,UAAI,UAAU;AACZ,qBAAa,QAAQ,IAAI,IAAI;AAAA,MAC/B,OAAO;AACL,eAAO,aAAa,QAAQ,IAAI;AAAA,MAClC;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AACA,eAAAA,QAAM,UAAU,MAAM;AAEpB,UAAM,uBAAuB,CAAC,MAAkB;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport type { DSMenuButtonT } from '../../../react-desc-prop-types.js';\nimport type { useMenuOpenStatus } from './useMenuOpenStatus.js';\nimport type { DSMenuBehaviouralContextProviderT } from '../react-desc-prop-types.js';\n\ntype UseGlobalEventsConfig = {\n menuOpenStatus: ReturnType<typeof useMenuOpenStatus>;\n handleChangeOpenedSubItems: Required<DSMenuButtonT.MenuBehaviouralLayerOptionalProps>['onDisplayedSubmenuChange'];\n propsWithDefault: DSMenuBehaviouralContextProviderT.InternalProps;\n};\n\nexport const useGlobalEvents = ({\n menuOpenStatus,\n handleChangeOpenedSubItems,\n propsWithDefault,\n}: UseGlobalEventsConfig) => {\n const { onOpinionatedClose, isMenuOpen } = menuOpenStatus;\n const { buttonDOMNodeRef } = propsWithDefault;\n const mainMenuRef = React.useRef<HTMLDivElement | null>(null);\n // we are using \"portal\" but then we check the native evenet to check if \"on click outside\" the menu\n // for such reason, we need to track the current HTML NODES of the submenus (topmost parent)\n // this will allow us to check if the click event is outside the menu or any of it's submenus\n const submenusRefs = React.useRef<Record<DSMenuButtonT.WithSubmenuMenuNodes['dsId'], HTMLElement>>({});\n const handleSubmenusRefChange = React.useCallback(\n (htmlNode: HTMLElement | null, dsId: DSMenuButtonT.WithSubmenuMenuNodes['dsId']) => {\n if (htmlNode) {\n submenusRefs.current[dsId] = htmlNode;\n } else {\n delete submenusRefs.current[dsId];\n }\n },\n [],\n );\n React.useEffect(() => {\n // when the window loses focus, close all the menus and submenus\n const closeMenuAndSubmenus = (e: FocusEvent) => {\n // same guard as the click-outside handler: every instance listens to window blur,\n // a closed menu has nothing to close (and must not report `onDisplayedSubmenuChange`/`onClose`)\n if (!isMenuOpen) return;\n handleChangeOpenedSubItems([], { itemNode: null, event: e });\n onOpinionatedClose({ skipFocus: true, reason: 'window-blur', event: e });\n };\n // when the user clicks \"outside\" the menu and submenus, close all the menus and submenus\n const detectIfClickIsOutsideMenuAndCloseIfSo = (e: MouseEvent | TouchEvent) => {\n // we are running this on literally ALL the clicks that happen on the window\n // we don't want to be consuming resources that are not strictly necessary\n // if the main menu is not open, we don't need to check if the click is outside the menu ofc\n if (!isMenuOpen) return;\n // we discard the fastest to check \"trigger\" click first \u2014 the trigger CONTAINS its content (icons, text...),\n // a pointer going down on any of it is a trigger interaction (the click that follows toggles the menu),\n // not an outside one: closing here would make the click re-open the menu we just closed\n if (buttonDOMNodeRef.current?.contains(e.target as Node)) return;\n // fastest check is the mainmenu, cuz we don't loop through all the submenus\n const isClickInsideMainMenu = mainMenuRef.current?.contains(e.target as Node);\n if (isClickInsideMainMenu) return;\n const submenuNodesToCheck = Object.values(submenusRefs.current).filter(Boolean);\n // we check if the event.target is a child of any of our known HTML nodes (via native .contains)\n const isClickInsideAnySubmenu = submenuNodesToCheck.some((node) => node.contains(e.target as Node));\n if (isClickInsideAnySubmenu) return;\n handleChangeOpenedSubItems([], { itemNode: null, event: e });\n onOpinionatedClose({ skipFocus: true, reason: 'outside-click', event: e });\n };\n\n window.addEventListener('blur', closeMenuAndSubmenus);\n document.addEventListener('mousedown', detectIfClickIsOutsideMenuAndCloseIfSo);\n document.addEventListener('touchstart', detectIfClickIsOutsideMenuAndCloseIfSo);\n return () => {\n window.removeEventListener('blur', closeMenuAndSubmenus);\n document.removeEventListener('mousedown', detectIfClickIsOutsideMenuAndCloseIfSo);\n document.removeEventListener('touchstart', detectIfClickIsOutsideMenuAndCloseIfSo);\n };\n }, [buttonDOMNodeRef, handleChangeOpenedSubItems, isMenuOpen, onOpinionatedClose]);\n\n return React.useMemo(\n () => ({\n mainMenuRef,\n submenusRefs,\n handleSubmenusRefChange,\n }),\n [handleSubmenusRefChange],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAWX,MAAM,kBAAkB,CAAC;AAAA,E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