@elliemae/ds-menu-button 3.39.0-rc.1
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/DSMenuButton.js +50 -0
- package/dist/cjs/DSMenuButton.js.map +7 -0
- package/dist/cjs/DSMenuButtonCTX.js +38 -0
- package/dist/cjs/DSMenuButtonCTX.js.map +7 -0
- package/dist/cjs/config/useMenuButton.js +55 -0
- package/dist/cjs/config/useMenuButton.js.map +7 -0
- package/dist/cjs/config/useValidateProps.js +40 -0
- package/dist/cjs/config/useValidateProps.js.map +7 -0
- package/dist/cjs/constants/index.js +43 -0
- package/dist/cjs/constants/index.js.map +7 -0
- package/dist/cjs/index.js +41 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +7 -0
- package/dist/cjs/parts/ItemFactory.js +66 -0
- package/dist/cjs/parts/ItemFactory.js.map +7 -0
- package/dist/cjs/parts/MenuButtonContent.js +157 -0
- package/dist/cjs/parts/MenuButtonContent.js.map +7 -0
- package/dist/cjs/parts/MenuItem.js +244 -0
- package/dist/cjs/parts/MenuItem.js.map +7 -0
- package/dist/cjs/parts/SubMenu.js +126 -0
- package/dist/cjs/parts/SubMenu.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +64 -0
- package/dist/cjs/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/styled.js +128 -0
- package/dist/cjs/styled.js.map +7 -0
- package/dist/esm/DSMenuButton.js +20 -0
- package/dist/esm/DSMenuButton.js.map +7 -0
- package/dist/esm/DSMenuButtonCTX.js +8 -0
- package/dist/esm/DSMenuButtonCTX.js.map +7 -0
- package/dist/esm/config/useMenuButton.js +25 -0
- package/dist/esm/config/useMenuButton.js.map +7 -0
- package/dist/esm/config/useValidateProps.js +10 -0
- package/dist/esm/config/useValidateProps.js.map +7 -0
- package/dist/esm/constants/index.js +13 -0
- package/dist/esm/constants/index.js.map +7 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +7 -0
- package/dist/esm/parts/ItemFactory.js +36 -0
- package/dist/esm/parts/ItemFactory.js.map +7 -0
- package/dist/esm/parts/MenuButtonContent.js +127 -0
- package/dist/esm/parts/MenuButtonContent.js.map +7 -0
- package/dist/esm/parts/MenuItem.js +227 -0
- package/dist/esm/parts/MenuItem.js.map +7 -0
- package/dist/esm/parts/SubMenu.js +96 -0
- package/dist/esm/parts/SubMenu.js.map +7 -0
- package/dist/esm/react-desc-prop-types.js +34 -0
- package/dist/esm/react-desc-prop-types.js.map +7 -0
- package/dist/esm/styled.js +98 -0
- package/dist/esm/styled.js.map +7 -0
- package/dist/types/DSMenuButton.d.ts +7 -0
- package/dist/types/DSMenuButtonCTX.d.ts +11 -0
- package/dist/types/config/useMenuButton.d.ts +9 -0
- package/dist/types/config/useValidateProps.d.ts +3 -0
- package/dist/types/constants/index.d.ts +5 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/parts/ItemFactory.d.ts +14 -0
- package/dist/types/parts/MenuButtonContent.d.ts +1 -0
- package/dist/types/parts/MenuItem.d.ts +21 -0
- package/dist/types/parts/SubMenu.d.ts +14 -0
- package/dist/types/react-desc-prop-types.d.ts +51 -0
- package/dist/types/styled.d.ts +15 -0
- package/package.json +76 -0
@@ -0,0 +1,50 @@
|
|
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 DSMenuButton_exports = {};
|
30
|
+
__export(DSMenuButton_exports, {
|
31
|
+
DSMenuButton: () => DSMenuButton,
|
32
|
+
DSMenuButtonWithSchema: () => DSMenuButtonWithSchema
|
33
|
+
});
|
34
|
+
module.exports = __toCommonJS(DSMenuButton_exports);
|
35
|
+
var React = __toESM(require("react"));
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
37
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
38
|
+
var import_react_desc_prop_types = require("./react-desc-prop-types.js");
|
39
|
+
var import_useMenuButton = require("./config/useMenuButton.js");
|
40
|
+
var import_constants = require("./constants/index.js");
|
41
|
+
var import_DSMenuButtonCTX = require("./DSMenuButtonCTX.js");
|
42
|
+
var import_MenuButtonContent = require("./parts/MenuButtonContent.js");
|
43
|
+
const DSMenuButton = (props) => {
|
44
|
+
const ctx = (0, import_useMenuButton.useDSMenuButton)(props);
|
45
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DSMenuButtonCTX.MenuButtonContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MenuButtonContent.MenuButtonContent, {}) });
|
46
|
+
};
|
47
|
+
DSMenuButton.displayName = import_constants.DSMenuButtonName;
|
48
|
+
const DSMenuButtonWithSchema = (0, import_ds_props_helpers.describe)(DSMenuButton);
|
49
|
+
DSMenuButtonWithSchema.propTypes = import_react_desc_prop_types.DSDMenuButtonPropTypesSchema;
|
50
|
+
//# sourceMappingURL=DSMenuButton.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/DSMenuButton.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { type MenuButtonT, DSDMenuButtonPropTypesSchema } from './react-desc-prop-types.js';\nimport { useDSMenuButton } from './config/useMenuButton.js';\nimport { DSMenuButtonName } from './constants/index.js';\nimport { MenuButtonContext } from './DSMenuButtonCTX.js';\nimport { MenuButtonContent } from './parts/MenuButtonContent.js';\n\nconst DSMenuButton = <T extends object = object>(props: MenuButtonT.Props<T>) => {\n const ctx = useDSMenuButton(props);\n\n return (\n <MenuButtonContext.Provider value={ctx}>\n <MenuButtonContent />\n </MenuButtonContext.Provider>\n );\n};\n\nDSMenuButton.displayName = DSMenuButtonName;\nconst DSMenuButtonWithSchema = describe(DSMenuButton);\nDSMenuButtonWithSchema.propTypes = DSDMenuButtonPropTypesSchema;\n\nexport { DSMenuButton, DSMenuButtonWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADajB;AAZN,8BAAyB;AACzB,mCAA+D;AAC/D,2BAAgC;AAChC,uBAAiC;AACjC,6BAAkC;AAClC,+BAAkC;AAElC,MAAM,eAAe,CAA4B,UAAgC;AAC/E,QAAM,UAAM,sCAAgB,KAAK;AAEjC,SACE,4CAAC,yCAAkB,UAAlB,EAA2B,OAAO,KACjC,sDAAC,8CAAkB,GACrB;AAEJ;AAEA,aAAa,cAAc;AAC3B,MAAM,6BAAyB,kCAAS,YAAY;AACpD,uBAAuB,YAAY;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,38 @@
|
|
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 DSMenuButtonCTX_exports = {};
|
30
|
+
__export(DSMenuButtonCTX_exports, {
|
31
|
+
MenuButtonContext: () => MenuButtonContext
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(DSMenuButtonCTX_exports);
|
34
|
+
var React = __toESM(require("react"));
|
35
|
+
var import_react = __toESM(require("react"));
|
36
|
+
const defaultContext = {};
|
37
|
+
const MenuButtonContext = import_react.default.createContext(defaultContext);
|
38
|
+
//# sourceMappingURL=DSMenuButtonCTX.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/DSMenuButtonCTX.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport type { MenuButtonT } from './react-desc-prop-types.js';\ninterface MenuButtonContextProps<T extends object = object> {\n focusedOption: string | null;\n setFocusedOption: React.Dispatch<React.SetStateAction<string | null>>;\n selectedKeys: string[];\n onSelectionChange: (selectedKeys: string[], parentId: string, item: MenuButtonT.Item) => void;\n propsWithDefault: MenuButtonT.InternalProps<T>;\n}\n\nconst defaultContext = {} as MenuButtonContextProps<object>;\n\nexport const MenuButtonContext = React.createContext(defaultContext);\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAUlB,MAAM,iBAAiB,CAAC;AAEjB,MAAM,oBAAoB,aAAAA,QAAM,cAAc,cAAc;",
|
6
|
+
"names": ["React"]
|
7
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var useMenuButton_exports = {};
|
30
|
+
__export(useMenuButton_exports, {
|
31
|
+
useDSMenuButton: () => useDSMenuButton
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(useMenuButton_exports);
|
34
|
+
var React = __toESM(require("react"));
|
35
|
+
var import_react = require("react");
|
36
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
37
|
+
var import_react_desc_prop_types = require("../react-desc-prop-types.js");
|
38
|
+
var import_useValidateProps = require("./useValidateProps.js");
|
39
|
+
const useDSMenuButton = (propsFromUser) => {
|
40
|
+
const propsWithDefault = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(propsFromUser, import_react_desc_prop_types.defaultProps);
|
41
|
+
(0, import_useValidateProps.useValidateProps)(propsWithDefault, import_react_desc_prop_types.DSDMenuButtonPropTypes);
|
42
|
+
const { selectedKeys, onSelectionChange } = propsWithDefault;
|
43
|
+
const [focusedOption, setFocusedOption] = (0, import_react.useState)(null);
|
44
|
+
return (0, import_react.useMemo)(
|
45
|
+
() => ({
|
46
|
+
propsWithDefault,
|
47
|
+
focusedOption,
|
48
|
+
setFocusedOption,
|
49
|
+
selectedKeys,
|
50
|
+
onSelectionChange
|
51
|
+
}),
|
52
|
+
[focusedOption, propsWithDefault, selectedKeys, onSelectionChange]
|
53
|
+
);
|
54
|
+
};
|
55
|
+
//# sourceMappingURL=useMenuButton.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/config/useMenuButton.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["import { useMemo, useState } from 'react';\nimport { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport { type MenuButtonT, DSDMenuButtonPropTypes, defaultProps } from '../react-desc-prop-types.js';\nimport { useValidateProps } from './useValidateProps.js';\n\nexport const useDSMenuButton = <T extends object = object>(propsFromUser: MenuButtonT.Props<T>) => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<MenuButtonT.InternalProps<T>>(propsFromUser, defaultProps);\n useValidateProps(propsWithDefault, DSDMenuButtonPropTypes);\n\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n\n const { selectedKeys, onSelectionChange } = propsWithDefault;\n const [focusedOption, setFocusedOption] = useState<string | null>(null);\n\n return useMemo(\n () => ({\n propsWithDefault,\n focusedOption,\n setFocusedOption,\n selectedKeys,\n onSelectionChange,\n }),\n [focusedOption, propsWithDefault, selectedKeys, onSelectionChange],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkC;AAClC,8BAA6C;AAC7C,mCAAuE;AACvE,8BAAiC;AAE1B,MAAM,kBAAkB,CAA4B,kBAAwC;AAIjG,QAAM,uBAAmB,sDAA2D,eAAe,yCAAY;AAC/G,gDAAiB,kBAAkB,mDAAsB;AAMzD,QAAM,EAAE,cAAc,kBAAkB,IAAI;AAC5C,QAAM,CAAC,eAAe,gBAAgB,QAAI,uBAAwB,IAAI;AAEtE,aAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,eAAe,kBAAkB,cAAc,iBAAiB;AAAA,EACnE;AACF;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,40 @@
|
|
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 useValidateProps_exports = {};
|
30
|
+
__export(useValidateProps_exports, {
|
31
|
+
useValidateProps: () => useValidateProps
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(useValidateProps_exports);
|
34
|
+
var React = __toESM(require("react"));
|
35
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
36
|
+
var import_constants = require("../constants/index.js");
|
37
|
+
const useValidateProps = (props, propTypes) => {
|
38
|
+
(0, import_ds_props_helpers.useValidateTypescriptPropTypes)(props, propTypes, import_constants.DSMenuButtonName);
|
39
|
+
};
|
40
|
+
//# sourceMappingURL=useValidateProps.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/config/useValidateProps.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["import { useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport type { WeakValidationMap } from 'react';\nimport { type MenuButtonT } from '../react-desc-prop-types.js';\nimport { DSMenuButtonName } from '../constants/index.js';\n\nexport const useValidateProps = <T extends object = object>(\n props: MenuButtonT.InternalProps<T>,\n propTypes: WeakValidationMap<unknown>,\n): void => {\n // we validate the \"required if\" via 'isRequiredIf from our custom PropTypes\n useValidateTypescriptPropTypes(props, propTypes, DSMenuButtonName);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,8BAA+C;AAG/C,uBAAiC;AAE1B,MAAM,mBAAmB,CAC9B,OACA,cACS;AAET,8DAA+B,OAAO,WAAW,iCAAgB;AACnE;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -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 constants_exports = {};
|
30
|
+
__export(constants_exports, {
|
31
|
+
DSMenuButtonName: () => DSMenuButtonName,
|
32
|
+
MENU_BUTTON_DATATEST_ID: () => MENU_BUTTON_DATATEST_ID,
|
33
|
+
MENU_BUTTON_SLOTS: () => MENU_BUTTON_SLOTS
|
34
|
+
});
|
35
|
+
module.exports = __toCommonJS(constants_exports);
|
36
|
+
var React = __toESM(require("react"));
|
37
|
+
var import_ds_system = require("@elliemae/ds-system");
|
38
|
+
const DSMenuButtonName = "DSMenuButton";
|
39
|
+
const MENU_BUTTON_SLOTS = {
|
40
|
+
root: "root"
|
41
|
+
};
|
42
|
+
const MENU_BUTTON_DATATEST_ID = (0, import_ds_system.slotObjectToDataTestIds)(DSMenuButtonName, MENU_BUTTON_SLOTS);
|
43
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/constants/index.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["import { slotObjectToDataTestIds } from '@elliemae/ds-system';\n\nexport const DSMenuButtonName = 'DSMenuButton';\n\n// we are giving \"component_name_slots\" to avoid errors on duplicate exports variables in aggregators\nexport const MENU_BUTTON_SLOTS = {\n root: 'root',\n} as const;\n\n// we are giving \"component_name_data_testid\" to avoid errors on duplicate exports variables in aggregators\nexport const MENU_BUTTON_DATATEST_ID = slotObjectToDataTestIds(DSMenuButtonName, MENU_BUTTON_SLOTS);\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAwC;AAEjC,MAAM,mBAAmB;AAGzB,MAAM,oBAAoB;AAAA,EAC/B,MAAM;AACR;AAGO,MAAM,8BAA0B,0CAAwB,kBAAkB,iBAAiB;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,41 @@
|
|
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 src_exports = {};
|
30
|
+
__export(src_exports, {
|
31
|
+
DSMenuButton: () => import_DSMenuButton.DSMenuButton,
|
32
|
+
DSMenuButtonName: () => import_constants.DSMenuButtonName,
|
33
|
+
DSMenuButtonWithSchema: () => import_DSMenuButton.DSMenuButtonWithSchema,
|
34
|
+
MENU_BUTTON_DATATEST_ID: () => import_constants.MENU_BUTTON_DATATEST_ID,
|
35
|
+
MENU_BUTTON_SLOTS: () => import_constants.MENU_BUTTON_SLOTS
|
36
|
+
});
|
37
|
+
module.exports = __toCommonJS(src_exports);
|
38
|
+
var React = __toESM(require("react"));
|
39
|
+
var import_DSMenuButton = require("./DSMenuButton.js");
|
40
|
+
var import_constants = require("./constants/index.js");
|
41
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/index.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["export { DSMenuButton, DSMenuButtonWithSchema } from './DSMenuButton.js';\nexport { type MenuButtonT } from './react-desc-prop-types.js';\nexport { DSMenuButtonName, MENU_BUTTON_DATATEST_ID, MENU_BUTTON_SLOTS } from './constants/index.js';\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,0BAAqD;AAErD,uBAA6E;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,66 @@
|
|
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 ItemFactory_exports = {};
|
30
|
+
__export(ItemFactory_exports, {
|
31
|
+
ItemFactory: () => ItemFactory
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(ItemFactory_exports);
|
34
|
+
var React = __toESM(require("react"));
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
36
|
+
var import_MenuItem = require("./MenuItem.js");
|
37
|
+
const ItemFactory = ({
|
38
|
+
item,
|
39
|
+
innerRef,
|
40
|
+
onFocus,
|
41
|
+
tabIndex,
|
42
|
+
level,
|
43
|
+
selectionMode,
|
44
|
+
parentId
|
45
|
+
}) => {
|
46
|
+
if (item.type === "separator") {
|
47
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MenuItem.Separator, {});
|
48
|
+
}
|
49
|
+
if (item.type === "section") {
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MenuItem.Section, { item });
|
51
|
+
}
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
53
|
+
import_MenuItem.MenuItem,
|
54
|
+
{
|
55
|
+
item,
|
56
|
+
innerRef,
|
57
|
+
onFocus,
|
58
|
+
tabIndex,
|
59
|
+
level,
|
60
|
+
parentId,
|
61
|
+
selectionMode
|
62
|
+
},
|
63
|
+
item.dsId
|
64
|
+
);
|
65
|
+
};
|
66
|
+
//# sourceMappingURL=ItemFactory.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/parts/ItemFactory.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["/* eslint-disable import/no-cycle */\n/* eslint-disable arrow-body-style */\nimport React from 'react';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { MenuItem, Section, Separator } from './MenuItem.js';\n\nimport type { MenuButtonT } from '../react-desc-prop-types.js';\ninterface ItemFactoryProps {\n item: MenuButtonT.Item;\n level: number;\n selectionMode?: 'single' | 'multiple';\n parentId?: string;\n tabIndex: TypescriptHelpersT.WCAGTabIndex;\n onFocus: React.FocusEventHandler;\n innerRef: TypescriptHelpersT.AnyRef<HTMLElement>;\n}\n\nexport const ItemFactory: React.FC<ItemFactoryProps> = ({\n item,\n innerRef,\n onFocus,\n tabIndex,\n level,\n selectionMode,\n parentId,\n}) => {\n if (item.type === 'separator') {\n return <Separator />;\n }\n if (item.type === 'section') {\n return <Section item={item} />;\n }\n return (\n <MenuItem\n key={item.dsId}\n item={item}\n innerRef={innerRef}\n onFocus={onFocus}\n tabIndex={tabIndex}\n level={level}\n parentId={parentId}\n selectionMode={selectionMode}\n />\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD2BZ;AAvBX,sBAA6C;AAatC,MAAM,cAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,MAAI,KAAK,SAAS,aAAa;AAC7B,WAAO,4CAAC,6BAAU;AAAA,EACpB;AACA,MAAI,KAAK,SAAS,WAAW;AAC3B,WAAO,4CAAC,2BAAQ,MAAY;AAAA,EAC9B;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MAEC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAPK,KAAK;AAAA,EAQZ;AAEJ;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,157 @@
|
|
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 MenuButtonContent_exports = {};
|
30
|
+
__export(MenuButtonContent_exports, {
|
31
|
+
MenuButtonContent: () => MenuButtonContent
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(MenuButtonContent_exports);
|
34
|
+
var React = __toESM(require("react"));
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
36
|
+
var import_react = __toESM(require("react"));
|
37
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
38
|
+
var import_SubMenu = require("./SubMenu.js");
|
39
|
+
var import_DSMenuButtonCTX = require("../DSMenuButtonCTX.js");
|
40
|
+
var import_styled = require("../styled.js");
|
41
|
+
function useOnClickOutside(ref, cb) {
|
42
|
+
import_react.default.useEffect(() => {
|
43
|
+
const listener = (event) => {
|
44
|
+
if (!ref?.current || ref?.current?.contains?.(event.target)) {
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
cb(event);
|
48
|
+
};
|
49
|
+
document.addEventListener("mousedown", listener);
|
50
|
+
document.addEventListener("touchstart", listener);
|
51
|
+
return () => {
|
52
|
+
document.removeEventListener("mousedown", listener);
|
53
|
+
document.removeEventListener("touchstart", listener);
|
54
|
+
};
|
55
|
+
}, [ref, cb]);
|
56
|
+
}
|
57
|
+
const MenuButtonContent = () => {
|
58
|
+
const [referenceElement, setReferenceElement] = (0, import_react.useState)(null);
|
59
|
+
const [isOpen, setIsOpen] = (0, import_react.useState)(false);
|
60
|
+
const { setFocusedOption, propsWithDefault } = (0, import_react.useContext)(import_DSMenuButtonCTX.MenuButtonContext);
|
61
|
+
const { items, TriggerElement, selectionMode, triggerElementProps, menuMinWidth } = propsWithDefault;
|
62
|
+
const globalProps = (0, import_ds_props_helpers.useGetGlobalAttributes)(propsWithDefault);
|
63
|
+
const xstyledProps = (0, import_ds_props_helpers.useGetXstyledProps)(propsWithDefault);
|
64
|
+
const firstItem = (0, import_react.useMemo)(() => {
|
65
|
+
const first = items.find((item) => item.type !== "separator");
|
66
|
+
if (first && first.type === "section") {
|
67
|
+
return first.childrens?.find((item) => item.type !== "separator");
|
68
|
+
}
|
69
|
+
return first;
|
70
|
+
}, [items]);
|
71
|
+
const handleOnKeyDown = (0, import_react.useCallback)(
|
72
|
+
(event) => {
|
73
|
+
if (event.key === "Escape") {
|
74
|
+
referenceElement?.focus();
|
75
|
+
}
|
76
|
+
if (event.key === "ArrowDown" && isOpen) {
|
77
|
+
event.preventDefault();
|
78
|
+
setFocusedOption(firstItem?.dsId || "");
|
79
|
+
}
|
80
|
+
if (event.key === "ArrowUp" && isOpen) {
|
81
|
+
event.preventDefault();
|
82
|
+
setFocusedOption(items[items.length - 1].dsId);
|
83
|
+
}
|
84
|
+
if (event.key === "Enter" && isOpen) {
|
85
|
+
event.preventDefault();
|
86
|
+
setIsOpen(false);
|
87
|
+
referenceElement?.focus();
|
88
|
+
} else if ((event.key === "Enter" || event.key === " ") && !isOpen && firstItem) {
|
89
|
+
setFocusedOption(firstItem?.dsId);
|
90
|
+
}
|
91
|
+
},
|
92
|
+
[firstItem, items, isOpen, referenceElement, setFocusedOption]
|
93
|
+
);
|
94
|
+
const handleOnTriggerOnKeyDown = (0, import_react.useCallback)(
|
95
|
+
(e) => {
|
96
|
+
if (e.key === "Enter" || e.key === " ") {
|
97
|
+
e.preventDefault();
|
98
|
+
setFocusedOption(items[0]?.dsId);
|
99
|
+
}
|
100
|
+
},
|
101
|
+
[items, setFocusedOption]
|
102
|
+
);
|
103
|
+
const handleOnClick = (0, import_react.useCallback)(() => {
|
104
|
+
setIsOpen(!isOpen);
|
105
|
+
}, [isOpen]);
|
106
|
+
const attributes = (0, import_react.useMemo)(
|
107
|
+
() => ({
|
108
|
+
"aria-haspopup": "true",
|
109
|
+
"aria-expanded": isOpen
|
110
|
+
}),
|
111
|
+
[isOpen]
|
112
|
+
);
|
113
|
+
const listeners = (0, import_react.useMemo)(
|
114
|
+
() => ({
|
115
|
+
onKeyDown: handleOnTriggerOnKeyDown
|
116
|
+
}),
|
117
|
+
[handleOnTriggerOnKeyDown]
|
118
|
+
);
|
119
|
+
const containerRef = (0, import_react.useRef)(null);
|
120
|
+
useOnClickOutside(containerRef, () => setIsOpen(false));
|
121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
122
|
+
import_styled.StyledMenuButtonWrapper,
|
123
|
+
{
|
124
|
+
onClick: handleOnClick,
|
125
|
+
onKeyDown: handleOnKeyDown,
|
126
|
+
innerRef: containerRef,
|
127
|
+
...globalProps,
|
128
|
+
...xstyledProps,
|
129
|
+
children: [
|
130
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
131
|
+
TriggerElement,
|
132
|
+
{
|
133
|
+
isOpen,
|
134
|
+
innerRef: setReferenceElement,
|
135
|
+
setIsOpen,
|
136
|
+
attributes,
|
137
|
+
listeners,
|
138
|
+
triggerElementProps
|
139
|
+
}
|
140
|
+
),
|
141
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
142
|
+
import_SubMenu.SubMenu,
|
143
|
+
{
|
144
|
+
level: 1,
|
145
|
+
items,
|
146
|
+
showSubMenu: isOpen,
|
147
|
+
setShowSubMenu: setIsOpen,
|
148
|
+
referenceElement,
|
149
|
+
selectionMode,
|
150
|
+
minWidth: menuMinWidth
|
151
|
+
}
|
152
|
+
)
|
153
|
+
]
|
154
|
+
}
|
155
|
+
);
|
156
|
+
};
|
157
|
+
//# sourceMappingURL=MenuButtonContent.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/parts/MenuButtonContent.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\nimport React, { useState, useMemo, useCallback, useContext, useRef } from 'react';\nimport { useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\nimport { SubMenu } from './SubMenu.js';\nimport { MenuButtonContext } from '../DSMenuButtonCTX.js';\n\nimport { StyledMenuButtonWrapper } from '../styled.js';\nfunction useOnClickOutside(ref: React.RefObject<HTMLElement>, cb: (event: MouseEvent | TouchEvent) => void) {\n React.useEffect(() => {\n const listener = (event: MouseEvent | TouchEvent) => {\n // Do nothing if clicking ref's element or descendent elements\n if (!ref?.current || ref?.current?.contains?.(event.target as Node)) {\n return;\n }\n cb(event);\n };\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [ref, cb]);\n}\n\nexport const MenuButtonContent = () => {\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n const [isOpen, setIsOpen] = useState(false);\n const { setFocusedOption, propsWithDefault } = useContext(MenuButtonContext);\n\n const { items, TriggerElement, selectionMode, triggerElementProps, menuMinWidth } = propsWithDefault;\n const globalProps = useGetGlobalAttributes(propsWithDefault);\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n\n const firstItem = useMemo(() => {\n const first = items.find((item) => item.type !== 'separator');\n if (first && first.type === 'section') {\n return first.childrens?.find((item) => item.type !== 'separator');\n }\n return first;\n }, [items]);\n\n const handleOnKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'Escape') {\n referenceElement?.focus();\n }\n if (event.key === 'ArrowDown' && isOpen) {\n event.preventDefault();\n setFocusedOption(firstItem?.dsId || '');\n }\n if (event.key === 'ArrowUp' && isOpen) {\n event.preventDefault();\n setFocusedOption(items[items.length - 1].dsId);\n }\n\n // Enter to close the menu and focus the trigger element\n if (event.key === 'Enter' && isOpen) {\n event.preventDefault();\n setIsOpen(false);\n referenceElement?.focus();\n } else if ((event.key === 'Enter' || event.key === ' ') && !isOpen && firstItem) {\n setFocusedOption(firstItem?.dsId);\n }\n },\n [firstItem, items, isOpen, referenceElement, setFocusedOption],\n );\n\n const handleOnTriggerOnKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n setFocusedOption(items[0]?.dsId);\n }\n },\n [items, setFocusedOption],\n );\n\n const handleOnClick = useCallback(() => {\n setIsOpen(!isOpen);\n }, [isOpen]);\n\n const attributes = useMemo(\n () => ({\n 'aria-haspopup': 'true',\n 'aria-expanded': isOpen,\n }),\n [isOpen],\n );\n\n const listeners = useMemo(\n () => ({\n onKeyDown: handleOnTriggerOnKeyDown,\n }),\n [handleOnTriggerOnKeyDown],\n );\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n useOnClickOutside(containerRef, () => setIsOpen(false));\n\n return (\n <StyledMenuButtonWrapper\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n innerRef={containerRef}\n {...globalProps}\n {...xstyledProps}\n >\n <TriggerElement\n isOpen={isOpen}\n innerRef={setReferenceElement}\n setIsOpen={setIsOpen}\n attributes={attributes}\n listeners={listeners}\n triggerElementProps={triggerElementProps}\n />\n {isOpen && (\n <SubMenu\n level={1}\n items={items}\n showSubMenu={isOpen}\n setShowSubMenu={setIsOpen}\n referenceElement={referenceElement}\n selectionMode={selectionMode}\n minWidth={menuMinWidth}\n />\n )}\n </StyledMenuButtonWrapper>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": "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",
|
6
|
+
"names": ["React"]
|
7
|
+
}
|