@elliemae/ds-menu 2.3.0-alpha.6 → 2.3.0-alpha.7
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/Menu.js +106 -15
- package/dist/cjs/Menu.js.map +2 -2
- package/dist/cjs/MenuCombobox.js +2 -2
- package/dist/cjs/MenuCombobox.js.map +2 -2
- package/dist/cjs/MenuItems/MenuItem.js +1 -0
- package/dist/cjs/MenuItems/MenuItem.js.map +2 -2
- package/dist/cjs/MenuItems/SubMenu.js +4 -3
- package/dist/cjs/MenuItems/SubMenu.js.map +2 -2
- package/dist/cjs/MenuItems/renderMenuItems.js +2 -1
- package/dist/cjs/MenuItems/renderMenuItems.js.map +2 -2
- package/dist/esm/Menu.js +95 -4
- package/dist/esm/Menu.js.map +2 -2
- package/dist/esm/MenuCombobox.js +1 -1
- package/dist/esm/MenuCombobox.js.map +1 -1
- package/dist/esm/MenuItems/MenuItem.js +2 -1
- package/dist/esm/MenuItems/MenuItem.js.map +2 -2
- package/dist/esm/MenuItems/SubMenu.js +3 -2
- package/dist/esm/MenuItems/SubMenu.js.map +2 -2
- package/dist/esm/MenuItems/renderMenuItems.js +2 -1
- package/dist/esm/MenuItems/renderMenuItems.js.map +2 -2
- package/package.json +11 -15
- package/dist/cjs/DSMenu.js +0 -127
- package/dist/cjs/DSMenu.js.map +0 -7
- package/dist/esm/DSMenu.js +0 -98
- package/dist/esm/DSMenu.js.map +0 -7
package/dist/cjs/Menu.js
CHANGED
|
@@ -27,34 +27,125 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
27
27
|
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
28
|
var Menu_exports = {};
|
|
29
29
|
__export(Menu_exports, {
|
|
30
|
-
DSMenuWithSchema: () =>
|
|
31
|
-
Menu: () =>
|
|
30
|
+
DSMenuWithSchema: () => DSMenuWithSchema,
|
|
31
|
+
Menu: () => Menu,
|
|
32
32
|
default: () => Menu_default,
|
|
33
33
|
menuItemFactory: () => import_menuItemFactory.menuItemFactory,
|
|
34
|
-
renderMenuItems: () => import_renderMenuItems.renderMenuItems
|
|
34
|
+
renderMenuItems: () => import_renderMenuItems.renderMenuItems,
|
|
35
|
+
setSubMenu: () => setSubMenu
|
|
35
36
|
});
|
|
36
37
|
var React = __toESM(require("react"));
|
|
38
|
+
var import_react = __toESM(require("react"));
|
|
39
|
+
var import_react_desc = require("react-desc");
|
|
40
|
+
var import_lodash = require("lodash");
|
|
41
|
+
var import_ds_classnames = require("@elliemae/ds-classnames");
|
|
42
|
+
var import_web = require("react-spring/web");
|
|
43
|
+
var import_hooks = require("@elliemae/ds-utilities/hooks");
|
|
44
|
+
var import_system = require("@elliemae/ds-utilities/system");
|
|
45
|
+
var import_FocusGroup = require("@elliemae/ds-shared/FocusGroup");
|
|
46
|
+
var import_ds_hidden = require("@elliemae/ds-hidden");
|
|
47
|
+
var import_MenuContext = require("./MenuContext");
|
|
37
48
|
var import_MenuItemRadio = require("./MenuItems/MenuItemRadio");
|
|
38
49
|
var import_MenuItemCheckbox = require("./MenuItems/MenuItemCheckbox");
|
|
39
50
|
var import_CheckboxGroup = require("./MenuItems/CheckboxGroup");
|
|
40
51
|
var import_RadioGroup = require("./MenuItems/RadioGroup");
|
|
41
52
|
var import_Separator = require("./MenuItems/Separator");
|
|
42
53
|
var import_MenuItem = require("./MenuItems/MenuItem");
|
|
43
|
-
var import_SubMenu = require("./MenuItems/SubMenu");
|
|
44
54
|
var import_SearchableGroup = require("./MenuItems/SearchableGroup");
|
|
45
55
|
var import_SelectionGroup = require("./MenuItems/SelectionGroup");
|
|
46
56
|
var import_menuItemFactory = require("./MenuItems/menuItemFactory");
|
|
47
57
|
var import_renderMenuItems = require("./MenuItems/renderMenuItems");
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
const RESPONSIVE_HEIHGT_MARGIN = 120;
|
|
59
|
+
const blockName = "menu";
|
|
60
|
+
const noop = () => {
|
|
61
|
+
};
|
|
62
|
+
const MenuComponent = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, "", ({ menuComboBox, type }) => ({
|
|
63
|
+
"menu-combo-box": menuComboBox,
|
|
64
|
+
[`type-${type}`]: type
|
|
65
|
+
}));
|
|
66
|
+
const isChildOfType = (child, type) => child.type === type || child.type?.name === type;
|
|
67
|
+
const DSMenu = ({
|
|
68
|
+
containerProps = {},
|
|
69
|
+
innerRef,
|
|
70
|
+
as: MenuTag = import_web.animated.ul,
|
|
71
|
+
children = void 0,
|
|
72
|
+
onClickOutside = noop,
|
|
73
|
+
visible = void 0,
|
|
74
|
+
focusOnOpen = false,
|
|
75
|
+
maxOption = 0,
|
|
76
|
+
style = {},
|
|
77
|
+
minWidth = void 0,
|
|
78
|
+
maxWidth = void 0,
|
|
79
|
+
closeMenu,
|
|
80
|
+
responsiveHeight = false,
|
|
81
|
+
...otherProps
|
|
82
|
+
}) => {
|
|
83
|
+
const menuRef = (0, import_react.useRef)(null);
|
|
84
|
+
const { focusFirst } = (0, import_react.useContext)(import_FocusGroup.FocusGroupContext);
|
|
85
|
+
const { destroyed, ...hiddenProps } = (0, import_ds_hidden.useHiddenTransition)({ visible, style });
|
|
86
|
+
const nextChildren = (0, import_react.useMemo)(() => {
|
|
87
|
+
const forceLeftAddon = import_react.default.Children.toArray(children).some((child) => isChildOfType(child, "SelectionGroup") || isChildOfType(child, "MenuItemCheckbox") || isChildOfType(child, "MenuItemRadio") || child.props.leftAddon);
|
|
88
|
+
return import_react.default.Children.map(children, (child) => child && import_react.default.cloneElement(child, {
|
|
89
|
+
...child.props,
|
|
90
|
+
noAddon: !forceLeftAddon ? true : void 0,
|
|
91
|
+
maxOption,
|
|
92
|
+
closeMenu
|
|
93
|
+
}));
|
|
94
|
+
}, [children]);
|
|
95
|
+
(0, import_hooks.useOnClickOutside)(menuRef, onClickOutside);
|
|
96
|
+
(0, import_react.useEffect)(() => {
|
|
97
|
+
if (focusOnOpen && visible) {
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
focusFirst();
|
|
100
|
+
}, 0);
|
|
101
|
+
}
|
|
102
|
+
}, [visible, focusOnOpen]);
|
|
103
|
+
return !hiddenProps.destroyed ? /* @__PURE__ */ import_react.default.createElement(import_MenuContext.MenuContext.Provider, {
|
|
104
|
+
value: { visible, closeMenu }
|
|
105
|
+
}, /* @__PURE__ */ import_react.default.createElement(MenuComponent, {
|
|
106
|
+
"data-testid": containerProps?.["data-testid"] ? containerProps["data-testid"] : "em-ds-menu",
|
|
107
|
+
...containerProps,
|
|
108
|
+
as: MenuTag,
|
|
109
|
+
classProps: { ...otherProps.classProps || {}, type: otherProps.type },
|
|
110
|
+
innerRef: (0, import_system.mergeRefs)(innerRef, menuRef),
|
|
111
|
+
role: "menu",
|
|
112
|
+
...(0, import_lodash.omit)(otherProps, ["scheduleUpdate"]),
|
|
113
|
+
...hiddenProps
|
|
114
|
+
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
115
|
+
className: "menu-component-internal-wrapper",
|
|
116
|
+
style: {
|
|
117
|
+
...style,
|
|
118
|
+
minWidth,
|
|
119
|
+
maxWidth,
|
|
120
|
+
...responsiveHeight ? {
|
|
121
|
+
overflowY: "scroll",
|
|
122
|
+
maxHeight: responsiveHeight ? `${window.innerHeight - RESPONSIVE_HEIHGT_MARGIN}px` : void 0
|
|
123
|
+
} : {}
|
|
124
|
+
}
|
|
125
|
+
}, nextChildren))) : null;
|
|
126
|
+
};
|
|
127
|
+
const Menu = (0, import_FocusGroup.focusGroupManagerHoc)(DSMenu, { loop: true });
|
|
128
|
+
const props = {
|
|
129
|
+
containerProps: import_react_desc.PropTypes.object.description("Injected props to wrapper element of component"),
|
|
130
|
+
as: import_react_desc.PropTypes.element.description("Renders the menu with a specific html element"),
|
|
131
|
+
onClickOutside: import_react_desc.PropTypes.func.description("Handler when a user clicks outside the menu"),
|
|
132
|
+
visible: import_react_desc.PropTypes.bool.description("Whether the menu is visible or not"),
|
|
133
|
+
focusOnOpen: import_react_desc.PropTypes.bool.description("When set to true, it's going to focus the first item"),
|
|
134
|
+
minWidth: import_react_desc.PropTypes.number.description("Customize menu minWidth. Can be undefined or 'number'"),
|
|
135
|
+
maxWidth: import_react_desc.PropTypes.number.description("Customize menu maxWidth. Can be undefined or 'number'")
|
|
136
|
+
};
|
|
137
|
+
DSMenu.propTypes = props;
|
|
138
|
+
const DSMenuWithSchema = (0, import_react_desc.describe)(DSMenu);
|
|
139
|
+
DSMenuWithSchema.propTypes = props;
|
|
140
|
+
Menu.Item = import_MenuItem.MenuItem;
|
|
141
|
+
Menu.ItemCheckbox = import_MenuItemCheckbox.MenuItemCheckbox;
|
|
142
|
+
Menu.ItemRadio = import_MenuItemRadio.MenuItemRadio;
|
|
143
|
+
Menu.Separator = import_Separator.MenuSeparator;
|
|
144
|
+
Menu.CheckboxGroup = import_CheckboxGroup.CheckboxGroup;
|
|
145
|
+
Menu.RadioGroup = import_RadioGroup.RadioGroup;
|
|
146
|
+
Menu.SearchableGroup = import_SearchableGroup.SearchableGroup;
|
|
147
|
+
Menu.SelectionGroup = import_SelectionGroup.SelectionGroup;
|
|
148
|
+
const setSubMenu = (SubMenu) => Menu.SubMenu = SubMenu;
|
|
149
|
+
var Menu_default = Menu;
|
|
59
150
|
module.exports = __toCommonJS(Menu_exports);
|
|
60
151
|
//# sourceMappingURL=Menu.js.map
|
package/dist/cjs/Menu.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Menu.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { MenuItemRadio } from './MenuItems/MenuItemRadio';\nimport { MenuItemCheckbox } from './MenuItems/MenuItemCheckbox';\nimport { CheckboxGroup } from './MenuItems/CheckboxGroup';\nimport { RadioGroup } from './MenuItems/RadioGroup';\nimport { MenuSeparator } from './MenuItems/Separator';\nimport { MenuItem } from './MenuItems/MenuItem';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useEffect, useMemo, useRef } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { omit } from 'lodash';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { animated } from 'react-spring/web';\nimport { useOnClickOutside } from '@elliemae/ds-utilities/hooks';\nimport { mergeRefs } from '@elliemae/ds-utilities/system';\nimport { focusGroupManagerHoc, FocusGroupContext } from '@elliemae/ds-shared/FocusGroup';\nimport { useHiddenTransition } from '@elliemae/ds-hidden';\nimport { MenuContext } from './MenuContext';\nimport { MenuItemRadio } from './MenuItems/MenuItemRadio';\nimport { MenuItemCheckbox } from './MenuItems/MenuItemCheckbox';\nimport { CheckboxGroup } from './MenuItems/CheckboxGroup';\nimport { RadioGroup } from './MenuItems/RadioGroup';\nimport { MenuSeparator } from './MenuItems/Separator';\nimport { MenuItem } from './MenuItems/MenuItem';\nimport { SearchableGroup } from './MenuItems/SearchableGroup';\nimport { SelectionGroup } from './MenuItems/SelectionGroup';\nimport { menuItemFactory } from './MenuItems/menuItemFactory';\nimport { renderMenuItems } from './MenuItems/renderMenuItems';\n\nconst RESPONSIVE_HEIHGT_MARGIN = 120;\n\nconst blockName = 'menu';\n\nconst noop = () => {};\n\nconst MenuComponent = aggregatedClasses('div')(blockName, '', ({ menuComboBox, type }) => ({\n 'menu-combo-box': menuComboBox,\n [`type-${type}`]: type,\n}));\n\n/**\n * todo: -- IDEA -- each menu could have an overlay based on an overlay stack context so we can\n * capture the context of the clicks on very nested components\n */\n\nconst isChildOfType = (child, type) => (child.type === type || child.type?.name === type);\n\nconst DSMenu = ({\n containerProps = {},\n innerRef,\n as: MenuTag = animated.ul,\n children = undefined,\n onClickOutside = noop,\n // handlers from hidden\n visible = undefined,\n focusOnOpen = false,\n maxOption = 0,\n style = {},\n minWidth = undefined,\n maxWidth = undefined,\n closeMenu,\n responsiveHeight = false,\n ...otherProps\n}) => {\n const menuRef = useRef(null);\n const { focusFirst } = useContext(FocusGroupContext);\n const { destroyed, ...hiddenProps } = useHiddenTransition({ visible, style });\n\n // force no addon to the children if the menu doesn't have any item with leftAddon like SelectionGroup\n const nextChildren = useMemo(() => {\n const forceLeftAddon = React.Children.toArray(children).some(\n (child) =>\n isChildOfType(child, 'SelectionGroup') ||\n isChildOfType(child, 'MenuItemCheckbox') ||\n isChildOfType(child, 'MenuItemRadio') ||\n child.props.leftAddon,\n );\n\n return React.Children.map(\n children,\n (child) =>\n child &&\n React.cloneElement(child, {\n ...child.props,\n noAddon: !forceLeftAddon ? true : undefined,\n maxOption,\n closeMenu,\n }),\n );\n }, [children]);\n\n useOnClickOutside(menuRef, onClickOutside);\n\n useEffect(() => {\n if (focusOnOpen && visible) {\n setTimeout(() => {\n focusFirst();\n }, 0);\n }\n }, [visible, focusOnOpen]);\n // todo: find out a better approach to this\n return !hiddenProps.destroyed ? (\n <MenuContext.Provider value={{ visible, closeMenu }}>\n <MenuComponent\n data-testid={containerProps?.['data-testid'] ? containerProps['data-testid'] : 'em-ds-menu'}\n {...containerProps}\n as={MenuTag}\n classProps={{ ...(otherProps.classProps || {}), type: otherProps.type }}\n innerRef={mergeRefs(innerRef, menuRef)}\n role=\"menu\"\n {...omit(otherProps, ['scheduleUpdate'])}\n {...hiddenProps}\n >\n {/* eslint-disable indent */}\n <div\n className=\"menu-component-internal-wrapper\"\n style={{\n ...style,\n minWidth,\n maxWidth,\n ...(responsiveHeight\n ? {\n overflowY: 'scroll',\n maxHeight: responsiveHeight ? `${window.innerHeight - RESPONSIVE_HEIHGT_MARGIN}px` : undefined,\n }\n : {}),\n }}\n >\n {/* eslint-enable indent */}\n {nextChildren}\n </div>\n </MenuComponent>\n </MenuContext.Provider>\n ) : null;\n};\n\nconst Menu = focusGroupManagerHoc(DSMenu, { loop: true });\n\nconst props = {\n /** Injected props to wrapper element of component */\n containerProps: PropTypes.object.description('Injected props to wrapper element of component'),\n /** Renders the menu with a specific html element */\n as: PropTypes.element.description('Renders the menu with a specific html element'),\n /** Handler when a user clicks outside the menu */\n onClickOutside: PropTypes.func.description('Handler when a user clicks outside the menu'),\n /** Whether the menu is visible or not */\n visible: PropTypes.bool.description('Whether the menu is visible or not'),\n /** When set to true, it's going to focus the first item */\n focusOnOpen: PropTypes.bool.description(\"When set to true, it's going to focus the first item\"),\n /** Customize menu minWidth. Can be undefined or 'number' */\n minWidth: PropTypes.number.description(\"Customize menu minWidth. Can be undefined or 'number'\"),\n /** Customize menu maxWidth. Can be undefined or 'number' */\n maxWidth: PropTypes.number.description(\"Customize menu maxWidth. Can be undefined or 'number'\"),\n};\n\nDSMenu.propTypes = props;\n\nconst DSMenuWithSchema = describe(DSMenu);\n\nDSMenuWithSchema.propTypes = props;\n\nMenu.Item = MenuItem;\nMenu.ItemCheckbox = MenuItemCheckbox;\nMenu.ItemRadio = MenuItemRadio;\nMenu.Separator = MenuSeparator;\nMenu.CheckboxGroup = CheckboxGroup;\nMenu.RadioGroup = RadioGroup;\nMenu.SearchableGroup = SearchableGroup;\nMenu.SelectionGroup = SelectionGroup;\n\nconst setSubMenu = (SubMenu) => Menu.SubMenu = SubMenu;\n\nexport { menuItemFactory, renderMenuItems, DSMenuWithSchema, Menu, setSubMenu };\nexport default Menu;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA8D;AAC9D,wBAAoC;AACpC,oBAAqB;AACrB,2BAAkC;AAClC,iBAAyB;AACzB,mBAAkC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BAAiB;AAEtB,MAAM,aAAa,CAAC,YAAY,KAAK,UAAU;AAG/C,IAAO,eAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/MenuCombobox.js
CHANGED
|
@@ -33,7 +33,7 @@ var React = __toESM(require("react"));
|
|
|
33
33
|
var import_react = __toESM(require("react"));
|
|
34
34
|
var import_prop_types = __toESM(require("prop-types"));
|
|
35
35
|
var import_SearchableList = require("./MenuItems/SearchableList");
|
|
36
|
-
var
|
|
36
|
+
var import_Menu = require("./Menu");
|
|
37
37
|
function MenuCombobox({
|
|
38
38
|
dropdownFilterOptions = {},
|
|
39
39
|
options = [],
|
|
@@ -43,7 +43,7 @@ function MenuCombobox({
|
|
|
43
43
|
loading = false,
|
|
44
44
|
...rest
|
|
45
45
|
}) {
|
|
46
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
46
|
+
return /* @__PURE__ */ import_react.default.createElement(import_Menu.Menu, {
|
|
47
47
|
...rest,
|
|
48
48
|
classProps: { menuComboBox: true },
|
|
49
49
|
innerRef,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/MenuCombobox.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { SearchableList } from './MenuItems/SearchableList';\nimport { Menu } from './
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,wBAAsB;AACtB,4BAA+B;AAC/B,
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { SearchableList } from './MenuItems/SearchableList';\nimport { Menu } from './Menu';\n\nfunction MenuCombobox({\n dropdownFilterOptions = {},\n options = [],\n onSelectMenuItem = () => null,\n innerRef,\n maxOptions = 10,\n loading = false,\n ...rest\n}) {\n return (\n <Menu\n {...rest}\n classProps={{ menuComboBox: true }}\n innerRef={innerRef}\n visible\n >\n <SearchableList\n appendTermInList\n extraListProps={dropdownFilterOptions}\n items={options}\n onSelectMenuItem={onSelectMenuItem}\n maxOptions={maxOptions}\n loading={loading}\n />\n </Menu>\n );\n}\n\nMenuCombobox.propTypes = {\n /** Options */\n dropdownFilterOptions: PropTypes.shape({}),\n /** The option or menu items to render */\n options: PropTypes.arrayOf(PropTypes.object),\n /** Handler when a menu item is selected */\n onSelectMenuItem: PropTypes.func,\n /** Internal ref */\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),\n /** Max options to display in the list */\n maxOptions: PropTypes.number,\n /** Is loading */\n loading: PropTypes.bool,\n};\n\nexport default MenuCombobox;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,wBAAsB;AACtB,4BAA+B;AAC/B,kBAAqB;AAErB,sBAAsB;AAAA,EACpB,wBAAwB;AAAA,EACxB,UAAU;AAAA,EACV,mBAAmB,MAAM;AAAA,EACzB;AAAA,EACA,aAAa;AAAA,EACb,UAAU;AAAA,KACP;AAAA,GACF;AACD,SACE,mDAAC,kBAAD;AAAA,OACM;AAAA,IACJ,YAAY,EAAE,cAAc;AAAA,IAC5B;AAAA,IACA,SAAO;AAAA,KAEP,mDAAC,sCAAD;AAAA,IACE,kBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAMR,aAAa,YAAY;AAAA,EAEvB,uBAAuB,0BAAU,MAAM;AAAA,EAEvC,SAAS,0BAAU,QAAQ,0BAAU;AAAA,EAErC,kBAAkB,0BAAU;AAAA,EAE5B,UAAU,0BAAU,UAAU,CAAC,0BAAU,MAAM,0BAAU;AAAA,EAEzD,YAAY,0BAAU;AAAA,EAEtB,SAAS,0BAAU;AAAA;AAGrB,IAAO,uBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -88,6 +88,7 @@ const MenuItem = (props2) => {
|
|
|
88
88
|
const ref = (0, import_react.useRef)(null);
|
|
89
89
|
(0, import_FocusGroup.useFocusGroupItem)(ref);
|
|
90
90
|
if (otherProps.subItems) {
|
|
91
|
+
const SubMenu = (0, import_menuItemFactory.menuItemFactory)("submenu");
|
|
91
92
|
return /* @__PURE__ */ import_react.default.createElement(SubMenu, {
|
|
92
93
|
...props2,
|
|
93
94
|
closeMenu: menuCxt.closeMenu
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/MenuItems/MenuItem.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable import/no-cycle */\nimport React, { useRef, useMemo, useContext } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { omit } from 'lodash';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { mergeRefs, runAll } from '@elliemae/ds-utilities';\nimport { useFocusGroupItem } from '@elliemae/ds-shared/FocusGroup';\nimport { DSTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport { MenuContext } from '../MenuContext';\nimport { registerMenuItem } from './menuItemFactory';\nimport { renderMenuItems } from './renderMenuItems';\n\nconst noop = () => null;\n\nconst blockName = 'menu-item';\n\nconst Content = aggregatedClasses('div')(blockName, 'content');\nconst Addon = aggregatedClasses('div')(blockName, 'addon', ({ empty, fixedItem }) => ({ empty, fixedItem }));\n\nconst renderAddon = (addon, fixedItem, addonId) => (\n <Addon key={addonId} classProps={{ fixedItem }}>\n {addon}\n </Addon>\n);\n\nconst renderAddons = (addons, fixedItem) =>\n Array.isArray(addons) ? addons.map(renderAddon) : renderAddon(addons, fixedItem);\n\nconst Wrapper = aggregatedClasses('li')(\n blockName,\n null,\n ({ disabled, disabledAddonInactive, customRenderer, fixedItem, type }) => ({\n disabled,\n disabledAddonInactive,\n customRenderer,\n fixedItem,\n [`menu-type-${type}`]: type,\n }),\n);\nconst calculateSize = (length = 0) => {\n if (length > 45) return 45 * 7;\n return length * 7;\n};\n\nconst MenuItem = (props) => {\n const {\n innerRef,\n as = 'li',\n role = 'menuitem',\n leftAddon = null,\n rightAddon = undefined,\n disabledAddonInactive = undefined,\n label = undefined,\n children,\n tabIndex = -1,\n onKeyDown = noop,\n fixedItem = false,\n noAddon,\n disabled = false,\n customRenderer,\n maxOption,\n closeMenu,\n style,\n ...otherProps\n } = props;\n\n const menuCxt = useContext(MenuContext);\n const ref = useRef(null);\n useFocusGroupItem(ref);\n if (otherProps.subItems) {\n return (\n <SubMenu {...props} closeMenu={menuCxt.closeMenu}>\n {renderMenuItems(otherProps.subItems)}\n </SubMenu>\n );\n }\n\n const wrapperProps = useMemo(() => omit(otherProps, ['icon']), [otherProps]);\n\n const onClick = (...args) => {\n if (wrapperProps.onClick) wrapperProps.onClick(...args);\n if (wrapperProps.closeOnClick && menuCxt.closeMenu) {\n menuCxt.closeMenu(...args);\n }\n };\n\n return (\n <Wrapper\n as={as}\n classProps={{\n disabled,\n disabledAddonInactive,\n customRenderer,\n fixedItem,\n type: otherProps.type,\n }}\n id={otherProps.id}\n innerRef={otherProps.type !== 'disabled' ? mergeRefs(innerRef, ref) : innerRef}\n onKeyDown={\n !fixedItem &&\n runAll((e) => {\n if (e.key === ' ' || e.key === 'Enter') {\n e.preventDefault();\n e.target.dispatchEvent(\n new MouseEvent('click', {\n view: window,\n bubbles: true,\n cancelable: false,\n }),\n );\n }\n }, onKeyDown)\n }\n role={role}\n style={style}\n tabIndex={tabIndex}\n {...wrapperProps}\n onClick={onClick}\n >\n {!noAddon && renderAddons(leftAddon, fixedItem)}\n {label && (\n <Content\n style={\n maxOption > 0\n ? {\n width: `${calculateSize(maxOption)}px`,\n maxWidth: `${calculateSize(maxOption)}px`,\n }\n : undefined\n }\n >\n <DSTruncatedTooltipText value={label} />\n </Content>\n )}\n {customRenderer}\n {rightAddon && renderAddons(rightAddon)}\n {children}\n </Wrapper>\n );\n};\n\nconst props = {\n /** Renders the MenuItem with a specific html element */\n as: PropTypes.element.description('Renders the MenuItem with a specific html element'),\n /**\n * reference to the component\n */\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description(\n 'reference to the component',\n ),\n /** Renders the passed element to the left */\n leftAddon: PropTypes.element.description('Renders the passed element to the left'),\n /** Renders the passed element to the right */\n rightAddon: PropTypes.element.description('Renders the passed element to the right'),\n /** Label for the menu item */\n label: PropTypes.string.description('Label for the menu item'),\n /** style object for menu item wrapper */\n style: PropTypes.object.description('style object for menu item wrapper'),\n /** disable menu item */\n disabled: PropTypes.bool.description('disable menu item'),\n /** HTML tabindex to manage focus order */\n tabindex: PropTypes.number.description('HTML tabindex to manage focus order'),\n /** a11y role */\n role: PropTypes.string.description('a11y role'),\n};\n\nMenuItem.propTypes = props;\nregisterMenuItem('menuitem', MenuItem);\n\nconst DSMenuItemWithSchema = describe(MenuItem);\nDSMenuItemWithSchema.propTypes = props;\n\nexport { DSMenuItemWithSchema, MenuItem };\nexport default MenuItem;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAmD;AACnD,wBAAoC;AACpC,oBAAqB;AACrB,2BAAkC;AAClC,0BAAkC;AAClC,wBAAkC;AAClC,uCAAuC;AACvC,yBAA4B;AAC5B,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable import/no-cycle */\nimport React, { useRef, useMemo, useContext } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { omit } from 'lodash';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { mergeRefs, runAll } from '@elliemae/ds-utilities';\nimport { useFocusGroupItem } from '@elliemae/ds-shared/FocusGroup';\nimport { DSTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport { MenuContext } from '../MenuContext';\nimport { registerMenuItem, menuItemFactory } from './menuItemFactory';\nimport { renderMenuItems } from './renderMenuItems';\n\nconst noop = () => null;\n\nconst blockName = 'menu-item';\n\nconst Content = aggregatedClasses('div')(blockName, 'content');\nconst Addon = aggregatedClasses('div')(blockName, 'addon', ({ empty, fixedItem }) => ({ empty, fixedItem }));\n\nconst renderAddon = (addon, fixedItem, addonId) => (\n <Addon key={addonId} classProps={{ fixedItem }}>\n {addon}\n </Addon>\n);\n\nconst renderAddons = (addons, fixedItem) =>\n Array.isArray(addons) ? addons.map(renderAddon) : renderAddon(addons, fixedItem);\n\nconst Wrapper = aggregatedClasses('li')(\n blockName,\n null,\n ({ disabled, disabledAddonInactive, customRenderer, fixedItem, type }) => ({\n disabled,\n disabledAddonInactive,\n customRenderer,\n fixedItem,\n [`menu-type-${type}`]: type,\n }),\n);\nconst calculateSize = (length = 0) => {\n if (length > 45) return 45 * 7;\n return length * 7;\n};\n\nconst MenuItem = (props) => {\n const {\n innerRef,\n as = 'li',\n role = 'menuitem',\n leftAddon = null,\n rightAddon = undefined,\n disabledAddonInactive = undefined,\n label = undefined,\n children,\n tabIndex = -1,\n onKeyDown = noop,\n fixedItem = false,\n noAddon,\n disabled = false,\n customRenderer,\n maxOption,\n closeMenu,\n style,\n ...otherProps\n } = props;\n\n const menuCxt = useContext(MenuContext);\n const ref = useRef(null);\n useFocusGroupItem(ref);\n if (otherProps.subItems) {\n const SubMenu = menuItemFactory('submenu');\n return (\n <SubMenu {...props} closeMenu={menuCxt.closeMenu}>\n {renderMenuItems(otherProps.subItems)}\n </SubMenu>\n );\n }\n\n const wrapperProps = useMemo(() => omit(otherProps, ['icon']), [otherProps]);\n\n const onClick = (...args) => {\n if (wrapperProps.onClick) wrapperProps.onClick(...args);\n if (wrapperProps.closeOnClick && menuCxt.closeMenu) {\n menuCxt.closeMenu(...args);\n }\n };\n\n return (\n <Wrapper\n as={as}\n classProps={{\n disabled,\n disabledAddonInactive,\n customRenderer,\n fixedItem,\n type: otherProps.type,\n }}\n id={otherProps.id}\n innerRef={otherProps.type !== 'disabled' ? mergeRefs(innerRef, ref) : innerRef}\n onKeyDown={\n !fixedItem &&\n runAll((e) => {\n if (e.key === ' ' || e.key === 'Enter') {\n e.preventDefault();\n e.target.dispatchEvent(\n new MouseEvent('click', {\n view: window,\n bubbles: true,\n cancelable: false,\n }),\n );\n }\n }, onKeyDown)\n }\n role={role}\n style={style}\n tabIndex={tabIndex}\n {...wrapperProps}\n onClick={onClick}\n >\n {!noAddon && renderAddons(leftAddon, fixedItem)}\n {label && (\n <Content\n style={\n maxOption > 0\n ? {\n width: `${calculateSize(maxOption)}px`,\n maxWidth: `${calculateSize(maxOption)}px`,\n }\n : undefined\n }\n >\n <DSTruncatedTooltipText value={label} />\n </Content>\n )}\n {customRenderer}\n {rightAddon && renderAddons(rightAddon)}\n {children}\n </Wrapper>\n );\n};\n\nconst props = {\n /** Renders the MenuItem with a specific html element */\n as: PropTypes.element.description('Renders the MenuItem with a specific html element'),\n /**\n * reference to the component\n */\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description(\n 'reference to the component',\n ),\n /** Renders the passed element to the left */\n leftAddon: PropTypes.element.description('Renders the passed element to the left'),\n /** Renders the passed element to the right */\n rightAddon: PropTypes.element.description('Renders the passed element to the right'),\n /** Label for the menu item */\n label: PropTypes.string.description('Label for the menu item'),\n /** style object for menu item wrapper */\n style: PropTypes.object.description('style object for menu item wrapper'),\n /** disable menu item */\n disabled: PropTypes.bool.description('disable menu item'),\n /** HTML tabindex to manage focus order */\n tabindex: PropTypes.number.description('HTML tabindex to manage focus order'),\n /** a11y role */\n role: PropTypes.string.description('a11y role'),\n};\n\nMenuItem.propTypes = props;\nregisterMenuItem('menuitem', MenuItem);\n\nconst DSMenuItemWithSchema = describe(MenuItem);\nDSMenuItemWithSchema.propTypes = props;\n\nexport { DSMenuItemWithSchema, MenuItem };\nexport default MenuItem;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAmD;AACnD,wBAAoC;AACpC,oBAAqB;AACrB,2BAAkC;AAClC,0BAAkC;AAClC,wBAAkC;AAClC,uCAAuC;AACvC,yBAA4B;AAC5B,6BAAkD;AAClD,6BAAgC;AAEhC,MAAM,OAAO,MAAM;AAEnB,MAAM,YAAY;AAElB,MAAM,UAAU,4CAAkB,OAAO,WAAW;AACpD,MAAM,QAAQ,4CAAkB,OAAO,WAAW,SAAS,CAAC,EAAE,OAAO,gBAAiB,GAAE,OAAO;AAE/F,MAAM,cAAc,CAAC,OAAO,WAAW,YACrC,mDAAC,OAAD;AAAA,EAAO,KAAK;AAAA,EAAS,YAAY,EAAE;AAAA,GAChC;AAIL,MAAM,eAAe,CAAC,QAAQ,cAC5B,MAAM,QAAQ,UAAU,OAAO,IAAI,eAAe,YAAY,QAAQ;AAExE,MAAM,UAAU,4CAAkB,MAChC,WACA,MACA,CAAC,EAAE,UAAU,uBAAuB,gBAAgB,WAAW,WAAY;AAAA,EACzE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GACC,aAAa,SAAS;AAAA;AAG3B,MAAM,gBAAgB,CAAC,SAAS,MAAM;AACpC,MAAI,SAAS;AAAI,WAAO,KAAK;AAC7B,SAAO,SAAS;AAAA;AAGlB,MAAM,WAAW,CAAC,WAAU;AAC1B,QAAM;AAAA,IACJ;AAAA,IACA,KAAK;AAAA,IACL,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,wBAAwB;AAAA,IACxB,QAAQ;AAAA,IACR;AAAA,IACA,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,Y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C,gBACA,cAAc,aAAa,aAC3B;AAAA;AAKP,MAAM,QAAQ;AAAA,EAEZ,IAAI,4BAAU,QAAQ,YAAY;AAAA,EAIlC,UAAU,4BAAU,UAAU,CAAC,4BAAU,MAAM,4BAAU,MAAM,EAAE,SAAS,4BAAU,SAAS,YAC3F;AAAA,EAGF,WAAW,4BAAU,QAAQ,YAAY;AAAA,EAEzC,YAAY,4BAAU,QAAQ,YAAY;AAAA,EAE1C,OAAO,4BAAU,OAAO,YAAY;AAAA,EAEpC,OAAO,4BAAU,OAAO,YAAY;AAAA,EAEpC,UAAU,4BAAU,KAAK,YAAY;AAAA,EAErC,UAAU,4BAAU,OAAO,YAAY;AAAA,EAEvC,MAAM,4BAAU,OAAO,YAAY;AAAA;AAGrC,SAAS,YAAY;AACrB,6CAAiB,YAAY;AAE7B,MAAM,uBAAuB,gCAAS;AACtC,qBAAqB,YAAY;AAGjC,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,13 +34,13 @@ __export(SubMenu_exports, {
|
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
36
|
var import_react_desc = require("react-desc");
|
|
37
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
37
38
|
var import_ds_icons = require("@elliemae/ds-icons");
|
|
38
39
|
var import_FocusGroup = require("@elliemae/ds-shared/FocusGroup");
|
|
39
40
|
var import_ds_hidden = require("@elliemae/ds-hidden");
|
|
40
41
|
var import_ds_button = require("@elliemae/ds-button");
|
|
41
42
|
var import_ds_popper = require("@elliemae/ds-popper");
|
|
42
|
-
var
|
|
43
|
-
var import_DSMenu = require("../DSMenu");
|
|
43
|
+
var import_Menu = require("../Menu");
|
|
44
44
|
var import_MenuItem = require("./MenuItem");
|
|
45
45
|
var import_menuItemFactory = require("./menuItemFactory");
|
|
46
46
|
const ChevronRightComp = import_styled_components.default.div`
|
|
@@ -125,7 +125,7 @@ const SubMenu = ({
|
|
|
125
125
|
size: "sm"
|
|
126
126
|
}));
|
|
127
127
|
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_ds_popper.DSPopper, {
|
|
128
|
-
contentComponent: /* @__PURE__ */ import_react.default.createElement(
|
|
128
|
+
contentComponent: /* @__PURE__ */ import_react.default.createElement(import_Menu.Menu, {
|
|
129
129
|
focusKeyBindings: {
|
|
130
130
|
ArrowLeft: [() => focusItemByNode(itemRef.current), "exit"]
|
|
131
131
|
},
|
|
@@ -179,6 +179,7 @@ const props = {
|
|
|
179
179
|
};
|
|
180
180
|
SubMenu.propTypes = props;
|
|
181
181
|
(0, import_menuItemFactory.registerMenuItem)("submenu", SubMenu);
|
|
182
|
+
(0, import_Menu.setSubMenu)(SubMenu);
|
|
182
183
|
const DSSubMenuWithSchema = (0, import_react_desc.describe)(SubMenu);
|
|
183
184
|
DSSubMenuWithSchema.propTypes = props;
|
|
184
185
|
var SubMenu_default = SubMenu;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/MenuItems/SubMenu.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable indent */\n/* eslint-disable max-lines */\nimport React, { useCallback, useRef, useState } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { ChevronSmallRight, MoreOptionsVert } from '@elliemae/ds-icons';\nimport { useFocusGroupItem } from '@elliemae/ds-shared/FocusGroup';\nimport { useHiddenController } from '@elliemae/ds-hidden';\nimport { DSButton, BUTTON_VARIANT } from '@elliemae/ds-button';\nimport { DSPopper, interactions } from '@elliemae/ds-popper';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAqD;AACrD,wBAAoC;AACpC,sBAAmD;AACnD,wBAAkC;AAClC,uBAAoC;AACpC,uBAAyC;AACzC,uBAAuC;AACvC
|
|
4
|
+
"sourcesContent": ["/* eslint-disable indent */\n/* eslint-disable max-lines */\nimport React, { useCallback, useRef, useState } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport styled from 'styled-components';\nimport { ChevronSmallRight, MoreOptionsVert } from '@elliemae/ds-icons';\nimport { useFocusGroupItem } from '@elliemae/ds-shared/FocusGroup';\nimport { useHiddenController } from '@elliemae/ds-hidden';\nimport { DSButton, BUTTON_VARIANT } from '@elliemae/ds-button';\nimport { DSPopper, interactions } from '@elliemae/ds-popper';\nimport { Menu, setSubMenu } from '../Menu';\nimport { MenuItem } from './MenuItem';\nimport { registerMenuItem } from './menuItemFactory';\n\nconst ChevronRightComp = styled.div`\n display: flex;\n justify-content: center;\n align-items: center;\n width: 28px; // same width as the ellipsis button\n`;\n\nconst SubMenu = ({\n noAddon,\n leftAddon = undefined,\n label = undefined,\n interactionType = 'hover',\n children: subitems,\n rightAddonType,\n disabledAddonInactive,\n checkableProps = {},\n customRenderer,\n onClick,\n closeMenu,\n id,\n}) => {\n const itemRef = useRef(null);\n const focusOnOpen = useRef(false);\n const [isAddonHovered, setIsAddonHovered] = useState<boolean>(false);\n const {\n visible = false,\n onShow,\n onHide,\n } = useHiddenController(undefined, {\n interaction: 'click',\n });\n\n const interaction = rightAddonType === 'elipsis' ? 'click' : 'hover';\n\n const { focusItemByNode } = useFocusGroupItem();\n // todo: create a menu state to handle all related menu things\n const handleShowSubItemsWithMouse = (e) => {\n e.stopPropagation();\n onShow();\n focusOnOpen.current = true;\n };\n const handleShowWithMouse = (e) => {\n if (onClick) onClick(e);\n };\n const handleShowWithMouseHover = () => {\n setIsAddonHovered(true);\n onShow();\n focusOnOpen.current = false;\n };\n\n const handleShowWithKeyboard = () => {\n onShow();\n focusOnOpen.current = true;\n };\n\n const handleOnMouseEnter = useCallback(() => {\n setIsAddonHovered(true);\n }, []);\n\n const handleOnMouseLeave = useCallback(() => {\n setIsAddonHovered(false);\n }, []);\n\n const hoverHandlers =\n interaction === 'hover'\n ? {\n onMouseEnter: handleShowWithMouseHover,\n onMouseLeave: () => {\n onHide();\n setIsAddonHovered(false);\n },\n }\n : { onClick: handleShowWithMouse };\n\n const rightAddon =\n rightAddonType === 'elipsis' ? (\n <DSButton\n aria-label=\"vertical-elipsis\"\n data-testid=\"vertical-elipsis\"\n buttonType=\"text\"\n leftIcon={\n <MoreOptionsVert\n className=\"submenu-arrow\"\n color={visible || isAddonHovered ? ['brand-primary', 800] : ['neutral', 500]}\n size=\"s\"\n />\n }\n onClick={(e) => handleShowSubItemsWithMouse(e)}\n size=\"m\"\n variant={BUTTON_VARIANT.DEFAULT}\n />\n ) : (\n <ChevronRightComp>\n <ChevronSmallRight\n data-testid=\"chevron-right\"\n className=\"submenu-arrow\"\n color={visible || isAddonHovered ? ['brand-primary', 800] : ['neutral', 500]}\n size=\"sm\"\n />\n </ChevronRightComp>\n );\n\n return (\n <>\n <DSPopper\n contentComponent={\n <Menu\n focusKeyBindings={{\n ArrowLeft: [() => focusItemByNode(itemRef.current), 'exit'],\n }}\n focusOnOpen={focusOnOpen.current}\n onExitFocusGroup={onHide}\n {...hoverHandlers}\n closeMenu={closeMenu}\n visible={visible}\n >\n {subitems}\n </Menu>\n }\n interactionType={interactionType}\n isOpen={visible}\n onOpen={(opening) => (opening ? onShow() : onHide())}\n placement=\"right-start\"\n showArrow={false}\n triggerComponent={\n <MenuItem\n customRenderer={customRenderer}\n disabledAddonInactive={disabledAddonInactive}\n id={id}\n innerRef={itemRef}\n label={label}\n leftAddon={leftAddon}\n noAddon={noAddon}\n onFocus={handleOnMouseEnter}\n onBlur={handleOnMouseLeave}\n onMouseEnter={handleOnMouseEnter}\n onMouseLeave={handleOnMouseLeave}\n {...hoverHandlers}\n onKeyDown={(e) => {\n if (e.key === 'ArrowRight' || e.key === 'Enter' || e.keyCode === 32) {\n handleShowWithKeyboard();\n }\n }}\n rightAddon={rightAddon}\n {...checkableProps}\n />\n }\n />\n </>\n );\n};\n\nconst props = {\n /** dont show addon for submenu */\n noAddon: PropTypes.bool.description('dont show addon for submenu'),\n /** left addon */\n leftAddon: PropTypes.node.description('left addon'),\n /** submenu label */\n label: PropTypes.string.description('submenu label'),\n /** A type indicating how to open/close the tooltip */\n interactionType: PropTypes.oneOf(interactions).description('A type indicating how to open/close the tooltip'),\n /** sub menu items */\n children: PropTypes.oneOfType([PropTypes.array, PropTypes.node]).description('sub menu items'),\n /** right addon, ellipsis or undefined */\n rightAddonType: PropTypes.oneOf(['ellipsis']).description('right addon, ellipsis or undefined'),\n disabledAddonInactive: PropTypes.bool.description(''),\n /** props passed to MenuItem component */\n checkableProps: PropTypes.object.description('props passed to MenuItem component'),\n /** custom renderer for menu item */\n customRenderer: PropTypes.func.description('custom renderer for menu item'),\n /** on click handler */\n onClick: PropTypes.func.description('on click handler'),\n closeMenu: PropTypes.any.description(''),\n /** component id */\n id: PropTypes.string.description('component id'),\n};\n\nSubMenu.propTypes = props;\nregisterMenuItem('submenu', SubMenu);\nsetSubMenu(SubMenu);\nconst DSSubMenuWithSchema = describe(SubMenu);\n\nDSSubMenuWithSchema.propTypes = props;\n\nexport { DSSubMenuWithSchema, SubMenu };\nexport default SubMenu;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAqD;AACrD,wBAAoC;AACpC,+BAAmB;AACnB,sBAAmD;AACnD,wBAAkC;AAClC,uBAAoC;AACpC,uBAAyC;AACzC,uBAAuC;AACvC,kBAAiC;AACjC,sBAAyB;AACzB,6BAAiC;AAEjC,MAAM,mBAAmB,iCAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAOhC,MAAM,UAAU,CAAC;AAAA,EACf;AAAA,EACA,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,kBAAkB;AAAA,EAClB,UAAU;A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4BAAU,KAAK,YAAY;AAAA,EAE3C,SAAS,4BAAU,KAAK,YAAY;AAAA,EACpC,WAAW,4BAAU,IAAI,YAAY;AAAA,EAErC,IAAI,4BAAU,OAAO,YAAY;AAAA;AAGnC,QAAQ,YAAY;AACpB,6CAAiB,WAAW;AAC5B,4BAAW;AACX,MAAM,sBAAsB,gCAAS;AAErC,oBAAoB,YAAY;AAGhC,IAAO,kBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,7 +32,8 @@ __export(renderMenuItems_exports, {
|
|
|
32
32
|
var React = __toESM(require("react"));
|
|
33
33
|
var import_react = __toESM(require("react"));
|
|
34
34
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
35
|
-
|
|
35
|
+
var import_menuItemFactory = require("./menuItemFactory");
|
|
36
|
+
const renderMenuItems = (options, factory = import_menuItemFactory.menuItemFactory) => options.map((option, index) => {
|
|
36
37
|
if ((0, import_ds_utilities.isFunction)(option.renderer)) {
|
|
37
38
|
return option.renderer({
|
|
38
39
|
key: option.id,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/MenuItems/renderMenuItems.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable import/no-cycle */\nimport React from 'react';\nimport { isFunction } from '@elliemae/ds-utilities';\n\nexport const renderMenuItems = (options, factory) =>\n options.map((option, index) => {\n if (isFunction(option.renderer)) {\n return option.renderer({\n key: option.id,\n item: option,\n });\n }\n const ItemComponent = factory(option.type);\n const children = option.subItems && renderMenuItems(option.subItems, factory);\n return (\n <ItemComponent\n {...option}\n key={option.id || index}\n item={option}\n onClick={null}\n onMouseDown={option.onClick}\n // onClick callback called in onMouseDown due to events order issue\n >\n {children}\n </ItemComponent>\n );\n });\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkB;AAClB,0BAA2B;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable import/no-cycle */\nimport React from 'react';\nimport { isFunction } from '@elliemae/ds-utilities';\nimport { menuItemFactory } from './menuItemFactory';\n\nexport const renderMenuItems = (options, factory = menuItemFactory) =>\n options.map((option, index) => {\n if (isFunction(option.renderer)) {\n return option.renderer({\n key: option.id,\n item: option,\n });\n }\n const ItemComponent = factory(option.type);\n const children = option.subItems && renderMenuItems(option.subItems, factory);\n return (\n <ItemComponent\n {...option}\n key={option.id || index}\n item={option}\n onClick={null}\n onMouseDown={option.onClick}\n // onClick callback called in onMouseDown due to events order issue\n >\n {children}\n </ItemComponent>\n );\n });\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkB;AAClB,0BAA2B;AAC3B,6BAAgC;AAEzB,MAAM,kBAAkB,CAAC,SAAS,UAAU,2CACjD,QAAQ,IAAI,CAAC,QAAQ,UAAU;AAC7B,MAAI,oCAAW,OAAO,WAAW;AAC/B,WAAO,OAAO,SAAS;AAAA,MACrB,KAAK,OAAO;AAAA,MACZ,MAAM;AAAA;AAAA;AAGV,QAAM,gBAAgB,QAAQ,OAAO;AACrC,QAAM,WAAW,OAAO,YAAY,gBAAgB,OAAO,UAAU;AACrE,SACE,mDAAC,eAAD;AAAA,OACM;AAAA,IACJ,KAAK,OAAO,MAAM;AAAA,IAClB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa,OAAO;AAAA,KAGnB;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/Menu.js
CHANGED
|
@@ -1,31 +1,122 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import React2, { useContext, useEffect, useMemo, useRef } from "react";
|
|
3
|
+
import { PropTypes, describe } from "react-desc";
|
|
4
|
+
import { omit } from "lodash";
|
|
5
|
+
import { aggregatedClasses } from "@elliemae/ds-classnames";
|
|
6
|
+
import { animated } from "react-spring/web";
|
|
7
|
+
import { useOnClickOutside } from "@elliemae/ds-utilities/hooks";
|
|
8
|
+
import { mergeRefs } from "@elliemae/ds-utilities/system";
|
|
9
|
+
import { focusGroupManagerHoc, FocusGroupContext } from "@elliemae/ds-shared/FocusGroup";
|
|
10
|
+
import { useHiddenTransition } from "@elliemae/ds-hidden";
|
|
11
|
+
import { MenuContext } from "./MenuContext";
|
|
2
12
|
import { MenuItemRadio } from "./MenuItems/MenuItemRadio";
|
|
3
13
|
import { MenuItemCheckbox } from "./MenuItems/MenuItemCheckbox";
|
|
4
14
|
import { CheckboxGroup } from "./MenuItems/CheckboxGroup";
|
|
5
15
|
import { RadioGroup } from "./MenuItems/RadioGroup";
|
|
6
16
|
import { MenuSeparator } from "./MenuItems/Separator";
|
|
7
17
|
import { MenuItem } from "./MenuItems/MenuItem";
|
|
8
|
-
import { SubMenu } from "./MenuItems/SubMenu";
|
|
9
18
|
import { SearchableGroup } from "./MenuItems/SearchableGroup";
|
|
10
19
|
import { SelectionGroup } from "./MenuItems/SelectionGroup";
|
|
11
20
|
import { menuItemFactory } from "./MenuItems/menuItemFactory";
|
|
12
21
|
import { renderMenuItems } from "./MenuItems/renderMenuItems";
|
|
13
|
-
|
|
22
|
+
const RESPONSIVE_HEIHGT_MARGIN = 120;
|
|
23
|
+
const blockName = "menu";
|
|
24
|
+
const noop = () => {
|
|
25
|
+
};
|
|
26
|
+
const MenuComponent = aggregatedClasses("div")(blockName, "", ({ menuComboBox, type }) => ({
|
|
27
|
+
"menu-combo-box": menuComboBox,
|
|
28
|
+
[`type-${type}`]: type
|
|
29
|
+
}));
|
|
30
|
+
const isChildOfType = (child, type) => child.type === type || child.type?.name === type;
|
|
31
|
+
const DSMenu = ({
|
|
32
|
+
containerProps = {},
|
|
33
|
+
innerRef,
|
|
34
|
+
as: MenuTag = animated.ul,
|
|
35
|
+
children = void 0,
|
|
36
|
+
onClickOutside = noop,
|
|
37
|
+
visible = void 0,
|
|
38
|
+
focusOnOpen = false,
|
|
39
|
+
maxOption = 0,
|
|
40
|
+
style = {},
|
|
41
|
+
minWidth = void 0,
|
|
42
|
+
maxWidth = void 0,
|
|
43
|
+
closeMenu,
|
|
44
|
+
responsiveHeight = false,
|
|
45
|
+
...otherProps
|
|
46
|
+
}) => {
|
|
47
|
+
const menuRef = useRef(null);
|
|
48
|
+
const { focusFirst } = useContext(FocusGroupContext);
|
|
49
|
+
const { destroyed, ...hiddenProps } = useHiddenTransition({ visible, style });
|
|
50
|
+
const nextChildren = useMemo(() => {
|
|
51
|
+
const forceLeftAddon = React2.Children.toArray(children).some((child) => isChildOfType(child, "SelectionGroup") || isChildOfType(child, "MenuItemCheckbox") || isChildOfType(child, "MenuItemRadio") || child.props.leftAddon);
|
|
52
|
+
return React2.Children.map(children, (child) => child && React2.cloneElement(child, {
|
|
53
|
+
...child.props,
|
|
54
|
+
noAddon: !forceLeftAddon ? true : void 0,
|
|
55
|
+
maxOption,
|
|
56
|
+
closeMenu
|
|
57
|
+
}));
|
|
58
|
+
}, [children]);
|
|
59
|
+
useOnClickOutside(menuRef, onClickOutside);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (focusOnOpen && visible) {
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
focusFirst();
|
|
64
|
+
}, 0);
|
|
65
|
+
}
|
|
66
|
+
}, [visible, focusOnOpen]);
|
|
67
|
+
return !hiddenProps.destroyed ? /* @__PURE__ */ React2.createElement(MenuContext.Provider, {
|
|
68
|
+
value: { visible, closeMenu }
|
|
69
|
+
}, /* @__PURE__ */ React2.createElement(MenuComponent, {
|
|
70
|
+
"data-testid": containerProps?.["data-testid"] ? containerProps["data-testid"] : "em-ds-menu",
|
|
71
|
+
...containerProps,
|
|
72
|
+
as: MenuTag,
|
|
73
|
+
classProps: { ...otherProps.classProps || {}, type: otherProps.type },
|
|
74
|
+
innerRef: mergeRefs(innerRef, menuRef),
|
|
75
|
+
role: "menu",
|
|
76
|
+
...omit(otherProps, ["scheduleUpdate"]),
|
|
77
|
+
...hiddenProps
|
|
78
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
79
|
+
className: "menu-component-internal-wrapper",
|
|
80
|
+
style: {
|
|
81
|
+
...style,
|
|
82
|
+
minWidth,
|
|
83
|
+
maxWidth,
|
|
84
|
+
...responsiveHeight ? {
|
|
85
|
+
overflowY: "scroll",
|
|
86
|
+
maxHeight: responsiveHeight ? `${window.innerHeight - RESPONSIVE_HEIHGT_MARGIN}px` : void 0
|
|
87
|
+
} : {}
|
|
88
|
+
}
|
|
89
|
+
}, nextChildren))) : null;
|
|
90
|
+
};
|
|
91
|
+
const Menu = focusGroupManagerHoc(DSMenu, { loop: true });
|
|
92
|
+
const props = {
|
|
93
|
+
containerProps: PropTypes.object.description("Injected props to wrapper element of component"),
|
|
94
|
+
as: PropTypes.element.description("Renders the menu with a specific html element"),
|
|
95
|
+
onClickOutside: PropTypes.func.description("Handler when a user clicks outside the menu"),
|
|
96
|
+
visible: PropTypes.bool.description("Whether the menu is visible or not"),
|
|
97
|
+
focusOnOpen: PropTypes.bool.description("When set to true, it's going to focus the first item"),
|
|
98
|
+
minWidth: PropTypes.number.description("Customize menu minWidth. Can be undefined or 'number'"),
|
|
99
|
+
maxWidth: PropTypes.number.description("Customize menu maxWidth. Can be undefined or 'number'")
|
|
100
|
+
};
|
|
101
|
+
DSMenu.propTypes = props;
|
|
102
|
+
const DSMenuWithSchema = describe(DSMenu);
|
|
103
|
+
DSMenuWithSchema.propTypes = props;
|
|
14
104
|
Menu.Item = MenuItem;
|
|
15
105
|
Menu.ItemCheckbox = MenuItemCheckbox;
|
|
16
106
|
Menu.ItemRadio = MenuItemRadio;
|
|
17
|
-
Menu.SubMenu = SubMenu;
|
|
18
107
|
Menu.Separator = MenuSeparator;
|
|
19
108
|
Menu.CheckboxGroup = CheckboxGroup;
|
|
20
109
|
Menu.RadioGroup = RadioGroup;
|
|
21
110
|
Menu.SearchableGroup = SearchableGroup;
|
|
22
111
|
Menu.SelectionGroup = SelectionGroup;
|
|
112
|
+
const setSubMenu = (SubMenu) => Menu.SubMenu = SubMenu;
|
|
23
113
|
var Menu_default = Menu;
|
|
24
114
|
export {
|
|
25
115
|
DSMenuWithSchema,
|
|
26
116
|
Menu,
|
|
27
117
|
Menu_default as default,
|
|
28
118
|
menuItemFactory,
|
|
29
|
-
renderMenuItems
|
|
119
|
+
renderMenuItems,
|
|
120
|
+
setSubMenu
|
|
30
121
|
};
|
|
31
122
|
//# sourceMappingURL=Menu.js.map
|
package/dist/esm/Menu.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/Menu.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { MenuItemRadio } from './MenuItems/MenuItemRadio';\nimport { MenuItemCheckbox } from './MenuItems/MenuItemCheckbox';\nimport { CheckboxGroup } from './MenuItems/CheckboxGroup';\nimport { RadioGroup } from './MenuItems/RadioGroup';\nimport { MenuSeparator } from './MenuItems/Separator';\nimport { MenuItem } from './MenuItems/MenuItem';\nimport {
|
|
5
|
-
"mappings": "AAAA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useEffect, useMemo, useRef } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { omit } from 'lodash';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { animated } from 'react-spring/web';\nimport { useOnClickOutside } from '@elliemae/ds-utilities/hooks';\nimport { mergeRefs } from '@elliemae/ds-utilities/system';\nimport { focusGroupManagerHoc, FocusGroupContext } from '@elliemae/ds-shared/FocusGroup';\nimport { useHiddenTransition } from '@elliemae/ds-hidden';\nimport { MenuContext } from './MenuContext';\nimport { MenuItemRadio } from './MenuItems/MenuItemRadio';\nimport { MenuItemCheckbox } from './MenuItems/MenuItemCheckbox';\nimport { CheckboxGroup } from './MenuItems/CheckboxGroup';\nimport { RadioGroup } from './MenuItems/RadioGroup';\nimport { MenuSeparator } from './MenuItems/Separator';\nimport { MenuItem } from './MenuItems/MenuItem';\nimport { SearchableGroup } from './MenuItems/SearchableGroup';\nimport { SelectionGroup } from './MenuItems/SelectionGroup';\nimport { menuItemFactory } from './MenuItems/menuItemFactory';\nimport { renderMenuItems } from './MenuItems/renderMenuItems';\n\nconst RESPONSIVE_HEIHGT_MARGIN = 120;\n\nconst blockName = 'menu';\n\nconst noop = () => {};\n\nconst MenuComponent = aggregatedClasses('div')(blockName, '', ({ menuComboBox, type }) => ({\n 'menu-combo-box': menuComboBox,\n [`type-${type}`]: type,\n}));\n\n/**\n * todo: -- IDEA -- each menu could have an overlay based on an overlay stack context so we can\n * capture the context of the clicks on very nested components\n */\n\nconst isChildOfType = (child, type) => (child.type === type || child.type?.name === type);\n\nconst DSMenu = ({\n containerProps = {},\n innerRef,\n as: MenuTag = animated.ul,\n children = undefined,\n onClickOutside = noop,\n // handlers from hidden\n visible = undefined,\n focusOnOpen = false,\n maxOption = 0,\n style = {},\n minWidth = undefined,\n maxWidth = undefined,\n closeMenu,\n responsiveHeight = false,\n ...otherProps\n}) => {\n const menuRef = useRef(null);\n const { focusFirst } = useContext(FocusGroupContext);\n const { destroyed, ...hiddenProps } = useHiddenTransition({ visible, style });\n\n // force no addon to the children if the menu doesn't have any item with leftAddon like SelectionGroup\n const nextChildren = useMemo(() => {\n const forceLeftAddon = React.Children.toArray(children).some(\n (child) =>\n isChildOfType(child, 'SelectionGroup') ||\n isChildOfType(child, 'MenuItemCheckbox') ||\n isChildOfType(child, 'MenuItemRadio') ||\n child.props.leftAddon,\n );\n\n return React.Children.map(\n children,\n (child) =>\n child &&\n React.cloneElement(child, {\n ...child.props,\n noAddon: !forceLeftAddon ? true : undefined,\n maxOption,\n closeMenu,\n }),\n );\n }, [children]);\n\n useOnClickOutside(menuRef, onClickOutside);\n\n useEffect(() => {\n if (focusOnOpen && visible) {\n setTimeout(() => {\n focusFirst();\n }, 0);\n }\n }, [visible, focusOnOpen]);\n // todo: find out a better approach to this\n return !hiddenProps.destroyed ? (\n <MenuContext.Provider value={{ visible, closeMenu }}>\n <MenuComponent\n data-testid={containerProps?.['data-testid'] ? containerProps['data-testid'] : 'em-ds-menu'}\n {...containerProps}\n as={MenuTag}\n classProps={{ ...(otherProps.classProps || {}), type: otherProps.type }}\n innerRef={mergeRefs(innerRef, menuRef)}\n role=\"menu\"\n {...omit(otherProps, ['scheduleUpdate'])}\n {...hiddenProps}\n >\n {/* eslint-disable indent */}\n <div\n className=\"menu-component-internal-wrapper\"\n style={{\n ...style,\n minWidth,\n maxWidth,\n ...(responsiveHeight\n ? {\n overflowY: 'scroll',\n maxHeight: responsiveHeight ? `${window.innerHeight - RESPONSIVE_HEIHGT_MARGIN}px` : undefined,\n }\n : {}),\n }}\n >\n {/* eslint-enable indent */}\n {nextChildren}\n </div>\n </MenuComponent>\n </MenuContext.Provider>\n ) : null;\n};\n\nconst Menu = focusGroupManagerHoc(DSMenu, { loop: true });\n\nconst props = {\n /** Injected props to wrapper element of component */\n containerProps: PropTypes.object.description('Injected props to wrapper element of component'),\n /** Renders the menu with a specific html element */\n as: PropTypes.element.description('Renders the menu with a specific html element'),\n /** Handler when a user clicks outside the menu */\n onClickOutside: PropTypes.func.description('Handler when a user clicks outside the menu'),\n /** Whether the menu is visible or not */\n visible: PropTypes.bool.description('Whether the menu is visible or not'),\n /** When set to true, it's going to focus the first item */\n focusOnOpen: PropTypes.bool.description(\"When set to true, it's going to focus the first item\"),\n /** Customize menu minWidth. Can be undefined or 'number' */\n minWidth: PropTypes.number.description(\"Customize menu minWidth. Can be undefined or 'number'\"),\n /** Customize menu maxWidth. Can be undefined or 'number' */\n maxWidth: PropTypes.number.description(\"Customize menu maxWidth. Can be undefined or 'number'\"),\n};\n\nDSMenu.propTypes = props;\n\nconst DSMenuWithSchema = describe(DSMenu);\n\nDSMenuWithSchema.propTypes = props;\n\nMenu.Item = MenuItem;\nMenu.ItemCheckbox = MenuItemCheckbox;\nMenu.ItemRadio = MenuItemRadio;\nMenu.Separator = MenuSeparator;\nMenu.CheckboxGroup = CheckboxGroup;\nMenu.RadioGroup = RadioGroup;\nMenu.SearchableGroup = SearchableGroup;\nMenu.SelectionGroup = SelectionGroup;\n\nconst setSubMenu = (SubMenu) => Menu.SubMenu = SubMenu;\n\nexport { menuItemFactory, renderMenuItems, DSMenuWithSchema, Menu, setSubMenu };\nexport default Menu;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,2BAA2B;AAEjC,MAAM,YAAY;AAElB,MAAM,OAAO,MAAM;AAAA;AAEnB,MAAM,gBAAgB,kBAAkB,OAAO,WAAW,IAAI,CAAC,EAAE,cAAc,WAAY;AAAA,EACzF,kBAAkB;AAAA,GACjB,QAAQ,SAAS;AAAA;AAQpB,MAAM,gBAAgB,CAAC,OAAO,SAAU,MAAM,SAAS,QAAQ,MAAM,MAAM,SAAS;AAEpF,MAAM,SAAS,CAAC;AAAA,EACd,iBAAiB;AAAA,EACjB;AAAA,EACA,IAAI,UAAU,SAAS;AAAA,EACvB,WAAW;AAAA,EACX,iBAAiB;AAAA,EAEjB,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AAAA,EACX;AAAA,EACA,mBAAmB;AAAA,KAChB;AAAA,MACC;AACJ,QAAM,UAAU,OAAO;AACvB,QAAM,EAAE,eAAe,WAAW;AAClC,QAAM,EAAE,cAAc,gBAAgB,oBAAoB,EAAE,SAAS;AAGrE,QAAM,eAAe,QAAQ,MAAM;AACjC,U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AAY;AAAA,EAExC,UAAU,UAAU,OAAO,YAAY;AAAA,EAEvC,UAAU,UAAU,OAAO,YAAY;AAAA;AAGzC,OAAO,YAAY;AAEnB,MAAM,mBAAmB,SAAS;AAElC,iBAAiB,YAAY;AAE7B,KAAK,OAAO;AACZ,KAAK,eAAe;AACpB,KAAK,YAAY;AACjB,KAAK,YAAY;AACjB,KAAK,gBAAgB;AACrB,KAAK,aAAa;AAClB,KAAK,kBAAkB;AACvB,KAAK,iBAAiB;AAEtB,MAAM,aAAa,CAAC,YAAY,KAAK,UAAU;AAG/C,IAAO,eAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/MenuCombobox.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import React2 from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { SearchableList } from "./MenuItems/SearchableList";
|
|
5
|
-
import { Menu } from "./
|
|
5
|
+
import { Menu } from "./Menu";
|
|
6
6
|
function MenuCombobox({
|
|
7
7
|
dropdownFilterOptions = {},
|
|
8
8
|
options = [],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/MenuCombobox.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport PropTypes from 'prop-types';\nimport { SearchableList } from './MenuItems/SearchableList';\nimport { Menu } from './
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport PropTypes from 'prop-types';\nimport { SearchableList } from './MenuItems/SearchableList';\nimport { Menu } from './Menu';\n\nfunction MenuCombobox({\n dropdownFilterOptions = {},\n options = [],\n onSelectMenuItem = () => null,\n innerRef,\n maxOptions = 10,\n loading = false,\n ...rest\n}) {\n return (\n <Menu\n {...rest}\n classProps={{ menuComboBox: true }}\n innerRef={innerRef}\n visible\n >\n <SearchableList\n appendTermInList\n extraListProps={dropdownFilterOptions}\n items={options}\n onSelectMenuItem={onSelectMenuItem}\n maxOptions={maxOptions}\n loading={loading}\n />\n </Menu>\n );\n}\n\nMenuCombobox.propTypes = {\n /** Options */\n dropdownFilterOptions: PropTypes.shape({}),\n /** The option or menu items to render */\n options: PropTypes.arrayOf(PropTypes.object),\n /** Handler when a menu item is selected */\n onSelectMenuItem: PropTypes.func,\n /** Internal ref */\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),\n /** Max options to display in the list */\n maxOptions: PropTypes.number,\n /** Is loading */\n loading: PropTypes.bool,\n};\n\nexport default MenuCombobox;\n"],
|
|
5
5
|
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AAEA,sBAAsB;AAAA,EACpB,wBAAwB;AAAA,EACxB,UAAU;AAAA,EACV,mBAAmB,MAAM;AAAA,EACzB;AAAA,EACA,aAAa;AAAA,EACb,UAAU;AAAA,KACP;AAAA,GACF;AACD,SACE,qCAAC,MAAD;AAAA,OACM;AAAA,IACJ,YAAY,EAAE,cAAc;AAAA,IAC5B;AAAA,IACA,SAAO;AAAA,KAEP,qCAAC,gBAAD;AAAA,IACE,kBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAMR,aAAa,YAAY;AAAA,EAEvB,uBAAuB,UAAU,MAAM;AAAA,EAEvC,SAAS,UAAU,QAAQ,UAAU;AAAA,EAErC,kBAAkB,UAAU;AAAA,EAE5B,UAAU,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU;AAAA,EAEzD,YAAY,UAAU;AAAA,EAEtB,SAAS,UAAU;AAAA;AAGrB,IAAO,uBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,7 +7,7 @@ import { mergeRefs, runAll } from "@elliemae/ds-utilities";
|
|
|
7
7
|
import { useFocusGroupItem } from "@elliemae/ds-shared/FocusGroup";
|
|
8
8
|
import { DSTruncatedTooltipText } from "@elliemae/ds-truncated-tooltip-text";
|
|
9
9
|
import { MenuContext } from "../MenuContext";
|
|
10
|
-
import { registerMenuItem } from "./menuItemFactory";
|
|
10
|
+
import { registerMenuItem, menuItemFactory } from "./menuItemFactory";
|
|
11
11
|
import { renderMenuItems } from "./renderMenuItems";
|
|
12
12
|
const noop = () => null;
|
|
13
13
|
const blockName = "menu-item";
|
|
@@ -55,6 +55,7 @@ const MenuItem = (props2) => {
|
|
|
55
55
|
const ref = useRef(null);
|
|
56
56
|
useFocusGroupItem(ref);
|
|
57
57
|
if (otherProps.subItems) {
|
|
58
|
+
const SubMenu = menuItemFactory("submenu");
|
|
58
59
|
return /* @__PURE__ */ React2.createElement(SubMenu, {
|
|
59
60
|
...props2,
|
|
60
61
|
closeMenu: menuCxt.closeMenu
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/MenuItems/MenuItem.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable import/no-cycle */\nimport React, { useRef, useMemo, useContext } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { omit } from 'lodash';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { mergeRefs, runAll } from '@elliemae/ds-utilities';\nimport { useFocusGroupItem } from '@elliemae/ds-shared/FocusGroup';\nimport { DSTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport { MenuContext } from '../MenuContext';\nimport { registerMenuItem } from './menuItemFactory';\nimport { renderMenuItems } from './renderMenuItems';\n\nconst noop = () => null;\n\nconst blockName = 'menu-item';\n\nconst Content = aggregatedClasses('div')(blockName, 'content');\nconst Addon = aggregatedClasses('div')(blockName, 'addon', ({ empty, fixedItem }) => ({ empty, fixedItem }));\n\nconst renderAddon = (addon, fixedItem, addonId) => (\n <Addon key={addonId} classProps={{ fixedItem }}>\n {addon}\n </Addon>\n);\n\nconst renderAddons = (addons, fixedItem) =>\n Array.isArray(addons) ? addons.map(renderAddon) : renderAddon(addons, fixedItem);\n\nconst Wrapper = aggregatedClasses('li')(\n blockName,\n null,\n ({ disabled, disabledAddonInactive, customRenderer, fixedItem, type }) => ({\n disabled,\n disabledAddonInactive,\n customRenderer,\n fixedItem,\n [`menu-type-${type}`]: type,\n }),\n);\nconst calculateSize = (length = 0) => {\n if (length > 45) return 45 * 7;\n return length * 7;\n};\n\nconst MenuItem = (props) => {\n const {\n innerRef,\n as = 'li',\n role = 'menuitem',\n leftAddon = null,\n rightAddon = undefined,\n disabledAddonInactive = undefined,\n label = undefined,\n children,\n tabIndex = -1,\n onKeyDown = noop,\n fixedItem = false,\n noAddon,\n disabled = false,\n customRenderer,\n maxOption,\n closeMenu,\n style,\n ...otherProps\n } = props;\n\n const menuCxt = useContext(MenuContext);\n const ref = useRef(null);\n useFocusGroupItem(ref);\n if (otherProps.subItems) {\n return (\n <SubMenu {...props} closeMenu={menuCxt.closeMenu}>\n {renderMenuItems(otherProps.subItems)}\n </SubMenu>\n );\n }\n\n const wrapperProps = useMemo(() => omit(otherProps, ['icon']), [otherProps]);\n\n const onClick = (...args) => {\n if (wrapperProps.onClick) wrapperProps.onClick(...args);\n if (wrapperProps.closeOnClick && menuCxt.closeMenu) {\n menuCxt.closeMenu(...args);\n }\n };\n\n return (\n <Wrapper\n as={as}\n classProps={{\n disabled,\n disabledAddonInactive,\n customRenderer,\n fixedItem,\n type: otherProps.type,\n }}\n id={otherProps.id}\n innerRef={otherProps.type !== 'disabled' ? mergeRefs(innerRef, ref) : innerRef}\n onKeyDown={\n !fixedItem &&\n runAll((e) => {\n if (e.key === ' ' || e.key === 'Enter') {\n e.preventDefault();\n e.target.dispatchEvent(\n new MouseEvent('click', {\n view: window,\n bubbles: true,\n cancelable: false,\n }),\n );\n }\n }, onKeyDown)\n }\n role={role}\n style={style}\n tabIndex={tabIndex}\n {...wrapperProps}\n onClick={onClick}\n >\n {!noAddon && renderAddons(leftAddon, fixedItem)}\n {label && (\n <Content\n style={\n maxOption > 0\n ? {\n width: `${calculateSize(maxOption)}px`,\n maxWidth: `${calculateSize(maxOption)}px`,\n }\n : undefined\n }\n >\n <DSTruncatedTooltipText value={label} />\n </Content>\n )}\n {customRenderer}\n {rightAddon && renderAddons(rightAddon)}\n {children}\n </Wrapper>\n );\n};\n\nconst props = {\n /** Renders the MenuItem with a specific html element */\n as: PropTypes.element.description('Renders the MenuItem with a specific html element'),\n /**\n * reference to the component\n */\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description(\n 'reference to the component',\n ),\n /** Renders the passed element to the left */\n leftAddon: PropTypes.element.description('Renders the passed element to the left'),\n /** Renders the passed element to the right */\n rightAddon: PropTypes.element.description('Renders the passed element to the right'),\n /** Label for the menu item */\n label: PropTypes.string.description('Label for the menu item'),\n /** style object for menu item wrapper */\n style: PropTypes.object.description('style object for menu item wrapper'),\n /** disable menu item */\n disabled: PropTypes.bool.description('disable menu item'),\n /** HTML tabindex to manage focus order */\n tabindex: PropTypes.number.description('HTML tabindex to manage focus order'),\n /** a11y role */\n role: PropTypes.string.description('a11y role'),\n};\n\nMenuItem.propTypes = props;\nregisterMenuItem('menuitem', MenuItem);\n\nconst DSMenuItemWithSchema = describe(MenuItem);\nDSMenuItemWithSchema.propTypes = props;\n\nexport { DSMenuItemWithSchema, MenuItem };\nexport default MenuItem;\n"],
|
|
5
|
-
"mappings": "AAAA;ACEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,OAAO,MAAM;AAEnB,MAAM,YAAY;AAElB,MAAM,UAAU,kBAAkB,OAAO,WAAW;AACpD,MAAM,QAAQ,kBAAkB,OAAO,WAAW,SAAS,CAAC,EAAE,OAAO,gBAAiB,GAAE,OAAO;AAE/F,MAAM,cAAc,CAAC,OAAO,WAAW,YACrC,qCAA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/* eslint-disable import/no-cycle */\nimport React, { useRef, useMemo, useContext } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { omit } from 'lodash';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { mergeRefs, runAll } from '@elliemae/ds-utilities';\nimport { useFocusGroupItem } from '@elliemae/ds-shared/FocusGroup';\nimport { DSTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport { MenuContext } from '../MenuContext';\nimport { registerMenuItem, menuItemFactory } from './menuItemFactory';\nimport { renderMenuItems } from './renderMenuItems';\n\nconst noop = () => null;\n\nconst blockName = 'menu-item';\n\nconst Content = aggregatedClasses('div')(blockName, 'content');\nconst Addon = aggregatedClasses('div')(blockName, 'addon', ({ empty, fixedItem }) => ({ empty, fixedItem }));\n\nconst renderAddon = (addon, fixedItem, addonId) => (\n <Addon key={addonId} classProps={{ fixedItem }}>\n {addon}\n </Addon>\n);\n\nconst renderAddons = (addons, fixedItem) =>\n Array.isArray(addons) ? addons.map(renderAddon) : renderAddon(addons, fixedItem);\n\nconst Wrapper = aggregatedClasses('li')(\n blockName,\n null,\n ({ disabled, disabledAddonInactive, customRenderer, fixedItem, type }) => ({\n disabled,\n disabledAddonInactive,\n customRenderer,\n fixedItem,\n [`menu-type-${type}`]: type,\n }),\n);\nconst calculateSize = (length = 0) => {\n if (length > 45) return 45 * 7;\n return length * 7;\n};\n\nconst MenuItem = (props) => {\n const {\n innerRef,\n as = 'li',\n role = 'menuitem',\n leftAddon = null,\n rightAddon = undefined,\n disabledAddonInactive = undefined,\n label = undefined,\n children,\n tabIndex = -1,\n onKeyDown = noop,\n fixedItem = false,\n noAddon,\n disabled = false,\n customRenderer,\n maxOption,\n closeMenu,\n style,\n ...otherProps\n } = props;\n\n const menuCxt = useContext(MenuContext);\n const ref = useRef(null);\n useFocusGroupItem(ref);\n if (otherProps.subItems) {\n const SubMenu = menuItemFactory('submenu');\n return (\n <SubMenu {...props} closeMenu={menuCxt.closeMenu}>\n {renderMenuItems(otherProps.subItems)}\n </SubMenu>\n );\n }\n\n const wrapperProps = useMemo(() => omit(otherProps, ['icon']), [otherProps]);\n\n const onClick = (...args) => {\n if (wrapperProps.onClick) wrapperProps.onClick(...args);\n if (wrapperProps.closeOnClick && menuCxt.closeMenu) {\n menuCxt.closeMenu(...args);\n }\n };\n\n return (\n <Wrapper\n as={as}\n classProps={{\n disabled,\n disabledAddonInactive,\n customRenderer,\n fixedItem,\n type: otherProps.type,\n }}\n id={otherProps.id}\n innerRef={otherProps.type !== 'disabled' ? mergeRefs(innerRef, ref) : innerRef}\n onKeyDown={\n !fixedItem &&\n runAll((e) => {\n if (e.key === ' ' || e.key === 'Enter') {\n e.preventDefault();\n e.target.dispatchEvent(\n new MouseEvent('click', {\n view: window,\n bubbles: true,\n cancelable: false,\n }),\n );\n }\n }, onKeyDown)\n }\n role={role}\n style={style}\n tabIndex={tabIndex}\n {...wrapperProps}\n onClick={onClick}\n >\n {!noAddon && renderAddons(leftAddon, fixedItem)}\n {label && (\n <Content\n style={\n maxOption > 0\n ? {\n width: `${calculateSize(maxOption)}px`,\n maxWidth: `${calculateSize(maxOption)}px`,\n }\n : undefined\n }\n >\n <DSTruncatedTooltipText value={label} />\n </Content>\n )}\n {customRenderer}\n {rightAddon && renderAddons(rightAddon)}\n {children}\n </Wrapper>\n );\n};\n\nconst props = {\n /** Renders the MenuItem with a specific html element */\n as: PropTypes.element.description('Renders the MenuItem with a specific html element'),\n /**\n * reference to the component\n */\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description(\n 'reference to the component',\n ),\n /** Renders the passed element to the left */\n leftAddon: PropTypes.element.description('Renders the passed element to the left'),\n /** Renders the passed element to the right */\n rightAddon: PropTypes.element.description('Renders the passed element to the right'),\n /** Label for the menu item */\n label: PropTypes.string.description('Label for the menu item'),\n /** style object for menu item wrapper */\n style: PropTypes.object.description('style object for menu item wrapper'),\n /** disable menu item */\n disabled: PropTypes.bool.description('disable menu item'),\n /** HTML tabindex to manage focus order */\n tabindex: PropTypes.number.description('HTML tabindex to manage focus order'),\n /** a11y role */\n role: PropTypes.string.description('a11y role'),\n};\n\nMenuItem.propTypes = props;\nregisterMenuItem('menuitem', MenuItem);\n\nconst DSMenuItemWithSchema = describe(MenuItem);\nDSMenuItemWithSchema.propTypes = props;\n\nexport { DSMenuItemWithSchema, MenuItem };\nexport default MenuItem;\n"],
|
|
5
|
+
"mappings": "AAAA;ACEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,OAAO,MAAM;AAEnB,MAAM,YAAY;AAElB,MAAM,UAAU,kBAAkB,OAAO,WAAW;AACpD,MAAM,QAAQ,kBAAkB,OAAO,WAAW,SAAS,CAAC,EAAE,OAAO,gBAAiB,GAAE,OAAO;AAE/F,MAAM,cAAc,CAAC,OAAO,WAAW,YACrC,qCAAC,OAAD;AAAA,EAAO,KAAK;AAAA,EAAS,YAAY,EAAE;AAAA,GAChC;AAIL,MAAM,eAAe,CAAC,QAAQ,cAC5B,MAAM,QAAQ,UAAU,OAAO,IAAI,eAAe,YAAY,QAAQ;AAExE,MAAM,UAAU,kBAAkB,MAChC,WACA,MACA,CAAC,EAAE,UAAU,uBAAuB,gBAAgB,WAAW,WAAY;AAAA,EACzE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GACC,aAAa,SAAS;AAAA;AAG3B,MAAM,gBAAgB,CAAC,SAAS,MAAM;AACpC,MAAI,SAAS;AAAI,WAAO,KAAK;AAC7B,SAAO,SAAS;AAAA;AAGlB,MAAM,WAAW,CAAC,WAAU;AAC1B,QAAM;AAAA,IACJ;AAAA,IACA,KAAK;AAAA,IACL,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,wBAAwB;AAAA,IACxB,QAAQ;AAAA,IACR;AAAA,IACA,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,IACX;AAAA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A,EAEZ,IAAI,UAAU,QAAQ,YAAY;AAAA,EAIlC,UAAU,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU,MAAM,EAAE,SAAS,UAAU,SAAS,YAC3F;AAAA,EAGF,WAAW,UAAU,QAAQ,YAAY;AAAA,EAEzC,YAAY,UAAU,QAAQ,YAAY;AAAA,EAE1C,OAAO,UAAU,OAAO,YAAY;AAAA,EAEpC,OAAO,UAAU,OAAO,YAAY;AAAA,EAEpC,UAAU,UAAU,KAAK,YAAY;AAAA,EAErC,UAAU,UAAU,OAAO,YAAY;AAAA,EAEvC,MAAM,UAAU,OAAO,YAAY;AAAA;AAGrC,SAAS,YAAY;AACrB,iBAAiB,YAAY;AAE7B,MAAM,uBAAuB,SAAS;AACtC,qBAAqB,YAAY;AAGjC,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import React2, { useCallback, useRef, useState } from "react";
|
|
3
3
|
import { PropTypes, describe } from "react-desc";
|
|
4
|
+
import styled from "styled-components";
|
|
4
5
|
import { ChevronSmallRight, MoreOptionsVert } from "@elliemae/ds-icons";
|
|
5
6
|
import { useFocusGroupItem } from "@elliemae/ds-shared/FocusGroup";
|
|
6
7
|
import { useHiddenController } from "@elliemae/ds-hidden";
|
|
7
8
|
import { DSButton, BUTTON_VARIANT } from "@elliemae/ds-button";
|
|
8
9
|
import { DSPopper, interactions } from "@elliemae/ds-popper";
|
|
9
|
-
import
|
|
10
|
-
import { Menu } from "../DSMenu";
|
|
10
|
+
import { Menu, setSubMenu } from "../Menu";
|
|
11
11
|
import { MenuItem } from "./MenuItem";
|
|
12
12
|
import { registerMenuItem } from "./menuItemFactory";
|
|
13
13
|
const ChevronRightComp = styled.div`
|
|
@@ -146,6 +146,7 @@ const props = {
|
|
|
146
146
|
};
|
|
147
147
|
SubMenu.propTypes = props;
|
|
148
148
|
registerMenuItem("submenu", SubMenu);
|
|
149
|
+
setSubMenu(SubMenu);
|
|
149
150
|
const DSSubMenuWithSchema = describe(SubMenu);
|
|
150
151
|
DSSubMenuWithSchema.propTypes = props;
|
|
151
152
|
var SubMenu_default = SubMenu;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/MenuItems/SubMenu.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable indent */\n/* eslint-disable max-lines */\nimport React, { useCallback, useRef, useState } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { ChevronSmallRight, MoreOptionsVert } from '@elliemae/ds-icons';\nimport { useFocusGroupItem } from '@elliemae/ds-shared/FocusGroup';\nimport { useHiddenController } from '@elliemae/ds-hidden';\nimport { DSButton, BUTTON_VARIANT } from '@elliemae/ds-button';\nimport { DSPopper, interactions } from '@elliemae/ds-popper';\nimport
|
|
5
|
-
"mappings": "AAAA;ACEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,mBAAmB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAOhC,MAAM,UAAU,CAAC;AAAA,EACf;AAAA,EACA,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,QAAM,UAAU,OAAO;AACvB,QAAM,cAAc,OAAO;AAC3B,QAAM,CAAC,gBAAgB,qBAAqB,SAAkB;AAC9D,QAAM;AAAA,IACJ,UAAU;AAAA,IACV;AAAA,IACA;AAAA,MACE,oBAAoB,QAAW;AAAA,IACjC,aAAa;AAAA;AAGf,QAAM,cAAc,mBAAmB,YAAY,UAAU;AAE7D,QAAM,EAAE,oBAAoB;AAE5B,QAAM,8B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,QAAQ;AAAA,IACR,QAAQ,CAAC,YAAa,UAAU,WAAW;AAAA,IAC3C,WAAU;AAAA,IACV,WAAW;AAAA,IACX,kBACE,qCAAC,UAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,cAAc;AAAA,SACV;AAAA,MACJ,WAAW,CAAC,MAAM;AAChB,YAAI,EAAE,QAAQ,gBAAgB,EAAE,QAAQ,WAAW,EAAE,YAAY,IAAI;AACnE;AAAA;AAAA;AAAA,MAGJ;AAAA,SACI;AAAA;AAAA;AAAA;AAQhB,MAAM,QAAQ;AAAA,EAEZ,SAAS,UAAU,KAAK,YAAY;AAAA,EAEpC,WAAW,UAAU,KAAK,YAAY;AAAA,EAEtC,OAAO,UAAU,OAAO,YAAY;AAAA,EAEpC,iBAAiB,UAAU,MAAM,cAAc,YAAY;AAAA,EAE3D,UAAU,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,OAAO,YAAY;AAAA,EAE7E,gBAAgB,UAAU,MAAM,CAAC,aAAa,YAAY;AAAA,EAC1D,uBAAuB,UAAU,KAAK,YAAY;AAAA,EAElD,gBAAgB,UAAU,OAAO,YAAY;AAAA,EAE7C,gBAAgB,UAAU,KAAK,YAAY;AAAA,EAE3C,SAAS,UAAU,KAAK,YAAY;AAAA,EACpC,WAAW,UAAU,IAAI,YAAY;AAAA,EAErC,IAAI,UAAU,OAAO,YAAY;AAAA;AAGnC,QAAQ,YAAY;AACpB,iBAAiB,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable indent */\n/* eslint-disable max-lines */\nimport React, { useCallback, useRef, useState } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport styled from 'styled-components';\nimport { ChevronSmallRight, MoreOptionsVert } from '@elliemae/ds-icons';\nimport { useFocusGroupItem } from '@elliemae/ds-shared/FocusGroup';\nimport { useHiddenController } from '@elliemae/ds-hidden';\nimport { DSButton, BUTTON_VARIANT } from '@elliemae/ds-button';\nimport { DSPopper, interactions } from '@elliemae/ds-popper';\nimport { Menu, setSubMenu } from '../Menu';\nimport { MenuItem } from './MenuItem';\nimport { registerMenuItem } from './menuItemFactory';\n\nconst ChevronRightComp = styled.div`\n display: flex;\n justify-content: center;\n align-items: center;\n width: 28px; // same width as the ellipsis button\n`;\n\nconst SubMenu = ({\n noAddon,\n leftAddon = undefined,\n label = undefined,\n interactionType = 'hover',\n children: subitems,\n rightAddonType,\n disabledAddonInactive,\n checkableProps = {},\n customRenderer,\n onClick,\n closeMenu,\n id,\n}) => {\n const itemRef = useRef(null);\n const focusOnOpen = useRef(false);\n const [isAddonHovered, setIsAddonHovered] = useState<boolean>(false);\n const {\n visible = false,\n onShow,\n onHide,\n } = useHiddenController(undefined, {\n interaction: 'click',\n });\n\n const interaction = rightAddonType === 'elipsis' ? 'click' : 'hover';\n\n const { focusItemByNode } = useFocusGroupItem();\n // todo: create a menu state to handle all related menu things\n const handleShowSubItemsWithMouse = (e) => {\n e.stopPropagation();\n onShow();\n focusOnOpen.current = true;\n };\n const handleShowWithMouse = (e) => {\n if (onClick) onClick(e);\n };\n const handleShowWithMouseHover = () => {\n setIsAddonHovered(true);\n onShow();\n focusOnOpen.current = false;\n };\n\n const handleShowWithKeyboard = () => {\n onShow();\n focusOnOpen.current = true;\n };\n\n const handleOnMouseEnter = useCallback(() => {\n setIsAddonHovered(true);\n }, []);\n\n const handleOnMouseLeave = useCallback(() => {\n setIsAddonHovered(false);\n }, []);\n\n const hoverHandlers =\n interaction === 'hover'\n ? {\n onMouseEnter: handleShowWithMouseHover,\n onMouseLeave: () => {\n onHide();\n setIsAddonHovered(false);\n },\n }\n : { onClick: handleShowWithMouse };\n\n const rightAddon =\n rightAddonType === 'elipsis' ? (\n <DSButton\n aria-label=\"vertical-elipsis\"\n data-testid=\"vertical-elipsis\"\n buttonType=\"text\"\n leftIcon={\n <MoreOptionsVert\n className=\"submenu-arrow\"\n color={visible || isAddonHovered ? ['brand-primary', 800] : ['neutral', 500]}\n size=\"s\"\n />\n }\n onClick={(e) => handleShowSubItemsWithMouse(e)}\n size=\"m\"\n variant={BUTTON_VARIANT.DEFAULT}\n />\n ) : (\n <ChevronRightComp>\n <ChevronSmallRight\n data-testid=\"chevron-right\"\n className=\"submenu-arrow\"\n color={visible || isAddonHovered ? ['brand-primary', 800] : ['neutral', 500]}\n size=\"sm\"\n />\n </ChevronRightComp>\n );\n\n return (\n <>\n <DSPopper\n contentComponent={\n <Menu\n focusKeyBindings={{\n ArrowLeft: [() => focusItemByNode(itemRef.current), 'exit'],\n }}\n focusOnOpen={focusOnOpen.current}\n onExitFocusGroup={onHide}\n {...hoverHandlers}\n closeMenu={closeMenu}\n visible={visible}\n >\n {subitems}\n </Menu>\n }\n interactionType={interactionType}\n isOpen={visible}\n onOpen={(opening) => (opening ? onShow() : onHide())}\n placement=\"right-start\"\n showArrow={false}\n triggerComponent={\n <MenuItem\n customRenderer={customRenderer}\n disabledAddonInactive={disabledAddonInactive}\n id={id}\n innerRef={itemRef}\n label={label}\n leftAddon={leftAddon}\n noAddon={noAddon}\n onFocus={handleOnMouseEnter}\n onBlur={handleOnMouseLeave}\n onMouseEnter={handleOnMouseEnter}\n onMouseLeave={handleOnMouseLeave}\n {...hoverHandlers}\n onKeyDown={(e) => {\n if (e.key === 'ArrowRight' || e.key === 'Enter' || e.keyCode === 32) {\n handleShowWithKeyboard();\n }\n }}\n rightAddon={rightAddon}\n {...checkableProps}\n />\n }\n />\n </>\n );\n};\n\nconst props = {\n /** dont show addon for submenu */\n noAddon: PropTypes.bool.description('dont show addon for submenu'),\n /** left addon */\n leftAddon: PropTypes.node.description('left addon'),\n /** submenu label */\n label: PropTypes.string.description('submenu label'),\n /** A type indicating how to open/close the tooltip */\n interactionType: PropTypes.oneOf(interactions).description('A type indicating how to open/close the tooltip'),\n /** sub menu items */\n children: PropTypes.oneOfType([PropTypes.array, PropTypes.node]).description('sub menu items'),\n /** right addon, ellipsis or undefined */\n rightAddonType: PropTypes.oneOf(['ellipsis']).description('right addon, ellipsis or undefined'),\n disabledAddonInactive: PropTypes.bool.description(''),\n /** props passed to MenuItem component */\n checkableProps: PropTypes.object.description('props passed to MenuItem component'),\n /** custom renderer for menu item */\n customRenderer: PropTypes.func.description('custom renderer for menu item'),\n /** on click handler */\n onClick: PropTypes.func.description('on click handler'),\n closeMenu: PropTypes.any.description(''),\n /** component id */\n id: PropTypes.string.description('component id'),\n};\n\nSubMenu.propTypes = props;\nregisterMenuItem('submenu', SubMenu);\nsetSubMenu(SubMenu);\nconst DSSubMenuWithSchema = describe(SubMenu);\n\nDSSubMenuWithSchema.propTypes = props;\n\nexport { DSSubMenuWithSchema, SubMenu };\nexport default SubMenu;\n"],
|
|
5
|
+
"mappings": "AAAA;ACEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,mBAAmB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAOhC,MAAM,UAAU,CAAC;AAAA,EACf;AAAA,EACA,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,QAAM,UAAU,OAAO;AACvB,QAAM,cAAc,OAAO;AAC3B,QAAM,CAAC,gBAAgB,qBAAqB,SAAkB;AAC9D,QAAM;AAAA,IACJ,UAAU;AAAA,IACV;AAAA,IACA;AAAA,MACE,oBAAoB,QAAW;AAAA,IACjC,aAAa;AAAA;AAGf,QAAM,cAAc,mBAAmB,YAAY,UAAU;AAE7D,QAAM,EAAE,oBAAoB;AAE5B,QAAM,8BAA8B,CAAC,MAAM;AACzC,MAAE;AACF;AACA,gBAAY,UAAU;AAAA;AAExB,QAAM,sBAAsB,CA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AAW;AAAA,IACX,kBACE,qCAAC,UAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,cAAc;AAAA,SACV;AAAA,MACJ,WAAW,CAAC,MAAM;AAChB,YAAI,EAAE,QAAQ,gBAAgB,EAAE,QAAQ,WAAW,EAAE,YAAY,IAAI;AACnE;AAAA;AAAA;AAAA,MAGJ;AAAA,SACI;AAAA;AAAA;AAAA;AAQhB,MAAM,QAAQ;AAAA,EAEZ,SAAS,UAAU,KAAK,YAAY;AAAA,EAEpC,WAAW,UAAU,KAAK,YAAY;AAAA,EAEtC,OAAO,UAAU,OAAO,YAAY;AAAA,EAEpC,iBAAiB,UAAU,MAAM,cAAc,YAAY;AAAA,EAE3D,UAAU,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,OAAO,YAAY;AAAA,EAE7E,gBAAgB,UAAU,MAAM,CAAC,aAAa,YAAY;AAAA,EAC1D,uBAAuB,UAAU,KAAK,YAAY;AAAA,EAElD,gBAAgB,UAAU,OAAO,YAAY;AAAA,EAE7C,gBAAgB,UAAU,KAAK,YAAY;AAAA,EAE3C,SAAS,UAAU,KAAK,YAAY;AAAA,EACpC,WAAW,UAAU,IAAI,YAAY;AAAA,EAErC,IAAI,UAAU,OAAO,YAAY;AAAA;AAGnC,QAAQ,YAAY;AACpB,iBAAiB,WAAW;AAC5B,WAAW;AACX,MAAM,sBAAsB,SAAS;AAErC,oBAAoB,YAAY;AAGhC,IAAO,kBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import React2 from "react";
|
|
3
3
|
import { isFunction } from "@elliemae/ds-utilities";
|
|
4
|
-
|
|
4
|
+
import { menuItemFactory } from "./menuItemFactory";
|
|
5
|
+
const renderMenuItems = (options, factory = menuItemFactory) => options.map((option, index) => {
|
|
5
6
|
if (isFunction(option.renderer)) {
|
|
6
7
|
return option.renderer({
|
|
7
8
|
key: option.id,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/MenuItems/renderMenuItems.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable import/no-cycle */\nimport React from 'react';\nimport { isFunction } from '@elliemae/ds-utilities';\n\nexport const renderMenuItems = (options, factory) =>\n options.map((option, index) => {\n if (isFunction(option.renderer)) {\n return option.renderer({\n key: option.id,\n item: option,\n });\n }\n const ItemComponent = factory(option.type);\n const children = option.subItems && renderMenuItems(option.subItems, factory);\n return (\n <ItemComponent\n {...option}\n key={option.id || index}\n item={option}\n onClick={null}\n onMouseDown={option.onClick}\n // onClick callback called in onMouseDown due to events order issue\n >\n {children}\n </ItemComponent>\n );\n });\n"],
|
|
5
|
-
"mappings": "AAAA;ACCA;AACA;AAEO,MAAM,kBAAkB,CAAC,SAAS,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable import/no-cycle */\nimport React from 'react';\nimport { isFunction } from '@elliemae/ds-utilities';\nimport { menuItemFactory } from './menuItemFactory';\n\nexport const renderMenuItems = (options, factory = menuItemFactory) =>\n options.map((option, index) => {\n if (isFunction(option.renderer)) {\n return option.renderer({\n key: option.id,\n item: option,\n });\n }\n const ItemComponent = factory(option.type);\n const children = option.subItems && renderMenuItems(option.subItems, factory);\n return (\n <ItemComponent\n {...option}\n key={option.id || index}\n item={option}\n onClick={null}\n onMouseDown={option.onClick}\n // onClick callback called in onMouseDown due to events order issue\n >\n {children}\n </ItemComponent>\n );\n });\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AACA;AACA;AAEO,MAAM,kBAAkB,CAAC,SAAS,UAAU,oBACjD,QAAQ,IAAI,CAAC,QAAQ,UAAU;AAC7B,MAAI,WAAW,OAAO,WAAW;AAC/B,WAAO,OAAO,SAAS;AAAA,MACrB,KAAK,OAAO;AAAA,MACZ,MAAM;AAAA;AAAA;AAGV,QAAM,gBAAgB,QAAQ,OAAO;AACrC,QAAM,WAAW,OAAO,YAAY,gBAAgB,OAAO,UAAU;AACrE,SACE,qCAAC,eAAD;AAAA,OACM;AAAA,IACJ,KAAK,OAAO,MAAM;AAAA,IAClB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa,OAAO;AAAA,KAGnB;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-menu",
|
|
3
|
-
"version": "2.3.0-alpha.
|
|
3
|
+
"version": "2.3.0-alpha.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Menu",
|
|
6
6
|
"files": [
|
|
@@ -89,10 +89,6 @@
|
|
|
89
89
|
"./Menu": {
|
|
90
90
|
"import": "./dist/esm/Menu.js",
|
|
91
91
|
"require": "./dist/cjs/Menu.js"
|
|
92
|
-
},
|
|
93
|
-
"./DSMenu": {
|
|
94
|
-
"import": "./dist/esm/DSMenu.js",
|
|
95
|
-
"require": "./dist/cjs/DSMenu.js"
|
|
96
92
|
}
|
|
97
93
|
},
|
|
98
94
|
"sideEffects": [
|
|
@@ -109,16 +105,16 @@
|
|
|
109
105
|
},
|
|
110
106
|
"author": "ICE MT",
|
|
111
107
|
"dependencies": {
|
|
112
|
-
"@elliemae/ds-button": "2.3.0-alpha.
|
|
113
|
-
"@elliemae/ds-classnames": "2.3.0-alpha.
|
|
114
|
-
"@elliemae/ds-form": "2.3.0-alpha.
|
|
115
|
-
"@elliemae/ds-hidden": "2.3.0-alpha.
|
|
116
|
-
"@elliemae/ds-icons": "2.3.0-alpha.
|
|
117
|
-
"@elliemae/ds-popper": "2.3.0-alpha.
|
|
118
|
-
"@elliemae/ds-separator": "2.3.0-alpha.
|
|
119
|
-
"@elliemae/ds-shared": "2.3.0-alpha.
|
|
120
|
-
"@elliemae/ds-truncated-tooltip-text": "2.3.0-alpha.
|
|
121
|
-
"@elliemae/ds-utilities": "2.3.0-alpha.
|
|
108
|
+
"@elliemae/ds-button": "2.3.0-alpha.7",
|
|
109
|
+
"@elliemae/ds-classnames": "2.3.0-alpha.7",
|
|
110
|
+
"@elliemae/ds-form": "2.3.0-alpha.7",
|
|
111
|
+
"@elliemae/ds-hidden": "2.3.0-alpha.7",
|
|
112
|
+
"@elliemae/ds-icons": "2.3.0-alpha.7",
|
|
113
|
+
"@elliemae/ds-popper": "2.3.0-alpha.7",
|
|
114
|
+
"@elliemae/ds-separator": "2.3.0-alpha.7",
|
|
115
|
+
"@elliemae/ds-shared": "2.3.0-alpha.7",
|
|
116
|
+
"@elliemae/ds-truncated-tooltip-text": "2.3.0-alpha.7",
|
|
117
|
+
"@elliemae/ds-utilities": "2.3.0-alpha.7",
|
|
122
118
|
"prop-types": "~15.7.2",
|
|
123
119
|
"react-desc": "~4.1.3",
|
|
124
120
|
"react-spring": "~8.0.27",
|
package/dist/cjs/DSMenu.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var DSMenu_exports = {};
|
|
29
|
-
__export(DSMenu_exports, {
|
|
30
|
-
DSMenuWithSchema: () => DSMenuWithSchema,
|
|
31
|
-
Menu: () => Menu
|
|
32
|
-
});
|
|
33
|
-
var React = __toESM(require("react"));
|
|
34
|
-
var import_react = __toESM(require("react"));
|
|
35
|
-
var import_react_desc = require("react-desc");
|
|
36
|
-
var import_lodash = require("lodash");
|
|
37
|
-
var import_ds_classnames = require("@elliemae/ds-classnames");
|
|
38
|
-
var import_web = require("react-spring/web");
|
|
39
|
-
var import_hooks = require("@elliemae/ds-utilities/hooks");
|
|
40
|
-
var import_system = require("@elliemae/ds-utilities/system");
|
|
41
|
-
var import_FocusGroup = require("@elliemae/ds-shared/FocusGroup");
|
|
42
|
-
var import_ds_hidden = require("@elliemae/ds-hidden");
|
|
43
|
-
var import_MenuContext = require("./MenuContext");
|
|
44
|
-
const RESPONSIVE_HEIHGT_MARGIN = 120;
|
|
45
|
-
const blockName = "menu";
|
|
46
|
-
const noop = () => {
|
|
47
|
-
};
|
|
48
|
-
const MenuComponent = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, "", ({ menuComboBox, type }) => ({
|
|
49
|
-
"menu-combo-box": menuComboBox,
|
|
50
|
-
[`type-${type}`]: type
|
|
51
|
-
}));
|
|
52
|
-
const isChildOfType = (child, type) => child.type.name === type;
|
|
53
|
-
const DSMenu = ({
|
|
54
|
-
containerProps = {},
|
|
55
|
-
innerRef,
|
|
56
|
-
as: MenuTag = import_web.animated.ul,
|
|
57
|
-
children = void 0,
|
|
58
|
-
onClickOutside = noop,
|
|
59
|
-
visible = void 0,
|
|
60
|
-
focusOnOpen = false,
|
|
61
|
-
maxOption = 0,
|
|
62
|
-
style = {},
|
|
63
|
-
minWidth = void 0,
|
|
64
|
-
maxWidth = void 0,
|
|
65
|
-
closeMenu,
|
|
66
|
-
responsiveHeight = false,
|
|
67
|
-
...otherProps
|
|
68
|
-
}) => {
|
|
69
|
-
const menuRef = (0, import_react.useRef)(null);
|
|
70
|
-
const { focusFirst } = (0, import_react.useContext)(import_FocusGroup.FocusGroupContext);
|
|
71
|
-
const { destroyed, ...hiddenProps } = (0, import_ds_hidden.useHiddenTransition)({ visible, style });
|
|
72
|
-
const nextChildren = (0, import_react.useMemo)(() => {
|
|
73
|
-
const forceLeftAddon = import_react.default.Children.toArray(children).some((child) => isChildOfType(child, "SelectionGroup") || isChildOfType(child, "MenuItemCheckbox") || isChildOfType(child, "MenuItemRadio") || child.props.leftAddon);
|
|
74
|
-
return import_react.default.Children.map(children, (child) => child && import_react.default.cloneElement(child, {
|
|
75
|
-
...child.props,
|
|
76
|
-
noAddon: !forceLeftAddon ? true : void 0,
|
|
77
|
-
maxOption,
|
|
78
|
-
closeMenu
|
|
79
|
-
}));
|
|
80
|
-
}, [children]);
|
|
81
|
-
(0, import_hooks.useOnClickOutside)(menuRef, onClickOutside);
|
|
82
|
-
(0, import_react.useEffect)(() => {
|
|
83
|
-
if (focusOnOpen && visible) {
|
|
84
|
-
setTimeout(() => {
|
|
85
|
-
focusFirst();
|
|
86
|
-
}, 0);
|
|
87
|
-
}
|
|
88
|
-
}, [visible, focusOnOpen]);
|
|
89
|
-
return !hiddenProps.destroyed ? /* @__PURE__ */ import_react.default.createElement(import_MenuContext.MenuContext.Provider, {
|
|
90
|
-
value: { visible, closeMenu }
|
|
91
|
-
}, /* @__PURE__ */ import_react.default.createElement(MenuComponent, {
|
|
92
|
-
"data-testid": containerProps?.["data-testid"] ? containerProps["data-testid"] : "em-ds-menu",
|
|
93
|
-
...containerProps,
|
|
94
|
-
as: MenuTag,
|
|
95
|
-
classProps: { ...otherProps.classProps || {}, type: otherProps.type },
|
|
96
|
-
innerRef: (0, import_system.mergeRefs)(innerRef, menuRef),
|
|
97
|
-
role: "menu",
|
|
98
|
-
...(0, import_lodash.omit)(otherProps, ["scheduleUpdate"]),
|
|
99
|
-
...hiddenProps
|
|
100
|
-
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
101
|
-
className: "menu-component-internal-wrapper",
|
|
102
|
-
style: {
|
|
103
|
-
...style,
|
|
104
|
-
minWidth,
|
|
105
|
-
maxWidth,
|
|
106
|
-
...responsiveHeight ? {
|
|
107
|
-
overflowY: "scroll",
|
|
108
|
-
maxHeight: responsiveHeight ? `${window.innerHeight - RESPONSIVE_HEIHGT_MARGIN}px` : void 0
|
|
109
|
-
} : {}
|
|
110
|
-
}
|
|
111
|
-
}, nextChildren))) : null;
|
|
112
|
-
};
|
|
113
|
-
const Menu = (0, import_FocusGroup.focusGroupManagerHoc)(DSMenu, { loop: true });
|
|
114
|
-
const props = {
|
|
115
|
-
containerProps: import_react_desc.PropTypes.object.description("Injected props to wrapper element of component"),
|
|
116
|
-
as: import_react_desc.PropTypes.element.description("Renders the menu with a specific html element"),
|
|
117
|
-
onClickOutside: import_react_desc.PropTypes.func.description("Handler when a user clicks outside the menu"),
|
|
118
|
-
visible: import_react_desc.PropTypes.bool.description("Whether the menu is visible or not"),
|
|
119
|
-
focusOnOpen: import_react_desc.PropTypes.bool.description("When set to true, it's going to focus the first item"),
|
|
120
|
-
minWidth: import_react_desc.PropTypes.number.description("Customize menu minWidth. Can be undefined or 'number'"),
|
|
121
|
-
maxWidth: import_react_desc.PropTypes.number.description("Customize menu maxWidth. Can be undefined or 'number'")
|
|
122
|
-
};
|
|
123
|
-
DSMenu.propTypes = props;
|
|
124
|
-
const DSMenuWithSchema = (0, import_react_desc.describe)(DSMenu);
|
|
125
|
-
DSMenuWithSchema.propTypes = props;
|
|
126
|
-
module.exports = __toCommonJS(DSMenu_exports);
|
|
127
|
-
//# sourceMappingURL=DSMenu.js.map
|
package/dist/cjs/DSMenu.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/DSMenu.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable react/prop-types */\nimport React, { useContext, useEffect, useMemo, useRef } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { omit } from 'lodash';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { animated } from 'react-spring/web';\nimport { useOnClickOutside } from '@elliemae/ds-utilities/hooks';\nimport { mergeRefs } from '@elliemae/ds-utilities/system';\nimport { focusGroupManagerHoc, FocusGroupContext } from '@elliemae/ds-shared/FocusGroup';\nimport { useHiddenTransition } from '@elliemae/ds-hidden';\nimport { MenuContext } from './MenuContext';\n\nconst RESPONSIVE_HEIHGT_MARGIN = 120;\n\nconst blockName = 'menu';\n\nconst noop = () => {};\n\nconst MenuComponent = aggregatedClasses('div')(blockName, '', ({ menuComboBox, type }) => ({\n 'menu-combo-box': menuComboBox,\n [`type-${type}`]: type,\n}));\n\n/**\n * todo: -- IDEA -- each menu could have an overlay based on an overlay stack context so we can\n * capture the context of the clicks on very nested components\n */\n\nconst isChildOfType = (child, type) => child.type.name === type;\n\nconst DSMenu = ({\n containerProps = {},\n innerRef,\n as: MenuTag = animated.ul,\n children = undefined,\n onClickOutside = noop,\n // handlers from hidden\n visible = undefined,\n focusOnOpen = false,\n maxOption = 0,\n style = {},\n minWidth = undefined,\n maxWidth = undefined,\n closeMenu,\n responsiveHeight = false,\n ...otherProps\n}) => {\n const menuRef = useRef(null);\n const { focusFirst } = useContext(FocusGroupContext);\n const { destroyed, ...hiddenProps } = useHiddenTransition({ visible, style });\n\n // force no addon to the children if the menu doesn't have any item with leftAddon like SelectionGroup\n const nextChildren = useMemo(() => {\n const forceLeftAddon = React.Children.toArray(children).some(\n (child) =>\n isChildOfType(child, 'SelectionGroup') ||\n isChildOfType(child, 'MenuItemCheckbox') ||\n isChildOfType(child, 'MenuItemRadio') ||\n child.props.leftAddon,\n );\n\n return React.Children.map(\n children,\n (child) =>\n child &&\n React.cloneElement(child, {\n ...child.props,\n noAddon: !forceLeftAddon ? true : undefined,\n maxOption,\n closeMenu,\n }),\n );\n }, [children]);\n\n useOnClickOutside(menuRef, onClickOutside);\n\n useEffect(() => {\n if (focusOnOpen && visible) {\n setTimeout(() => {\n focusFirst();\n }, 0);\n }\n }, [visible, focusOnOpen]);\n // todo: find out a better approach to this\n return !hiddenProps.destroyed ? (\n <MenuContext.Provider value={{ visible, closeMenu }}>\n <MenuComponent\n data-testid={containerProps?.['data-testid'] ? containerProps['data-testid'] : 'em-ds-menu'}\n {...containerProps}\n as={MenuTag}\n classProps={{ ...(otherProps.classProps || {}), type: otherProps.type }}\n innerRef={mergeRefs(innerRef, menuRef)}\n role=\"menu\"\n {...omit(otherProps, ['scheduleUpdate'])}\n {...hiddenProps}\n >\n {/* eslint-disable indent */}\n <div\n className=\"menu-component-internal-wrapper\"\n style={{\n ...style,\n minWidth,\n maxWidth,\n ...(responsiveHeight\n ? {\n overflowY: 'scroll',\n maxHeight: responsiveHeight ? `${window.innerHeight - RESPONSIVE_HEIHGT_MARGIN}px` : undefined,\n }\n : {}),\n }}\n >\n {/* eslint-enable indent */}\n {nextChildren}\n </div>\n </MenuComponent>\n </MenuContext.Provider>\n ) : null;\n};\n\nconst Menu = focusGroupManagerHoc(DSMenu, { loop: true });\n\nconst props = {\n /** Injected props to wrapper element of component */\n containerProps: PropTypes.object.description('Injected props to wrapper element of component'),\n /** Renders the menu with a specific html element */\n as: PropTypes.element.description('Renders the menu with a specific html element'),\n /** Handler when a user clicks outside the menu */\n onClickOutside: PropTypes.func.description('Handler when a user clicks outside the menu'),\n /** Whether the menu is visible or not */\n visible: PropTypes.bool.description('Whether the menu is visible or not'),\n /** When set to true, it's going to focus the first item */\n focusOnOpen: PropTypes.bool.description(\"When set to true, it's going to focus the first item\"),\n /** Customize menu minWidth. Can be undefined or 'number' */\n minWidth: PropTypes.number.description(\"Customize menu minWidth. Can be undefined or 'number'\"),\n /** Customize menu maxWidth. Can be undefined or 'number' */\n maxWidth: PropTypes.number.description(\"Customize menu maxWidth. Can be undefined or 'number'\"),\n};\n\nDSMenu.propTypes = props;\n\nconst DSMenuWithSchema = describe(DSMenu);\n\nDSMenuWithSchema.propTypes = props;\n\nexport { DSMenuWithSchema, Menu };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAA8D;AAC9D,wBAAoC;AACpC,oBAAqB;AACrB,2BAAkC;AAClC,iBAAyB;AACzB,mBAAkC;AAClC,oBAA0B;AAC1B,wBAAwD;AACxD,uBAAoC;AACpC,yBAA4B;AAE5B,MAAM,2BAA2B;AAEjC,MAAM,YAAY;AAElB,MAAM,OAAO,MAAM;AAAA;AAEnB,MAAM,gBAAgB,4CAAkB,OAAO,WAAW,IAAI,CAAC,EAAE,cAAc,WAAY;AAAA,EACzF,kBAAkB;AAAA,GACjB,QAAQ,SAAS;AAAA;AAQpB,MAAM,gBAAgB,CAAC,OAAO,SAAS,MAAM,KAAK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;AAAA,IACE,WAAU;AAAA,IACV,OAAO;AAAA,SACF;AAAA,MACH;AAAA,MACA;AAAA,SACI,mBACA;AAAA,QACE,WAAW;AAAA,QACX,WAAW,mBAAmB,GAAG,OAAO,cAAc,+BAA+B;AAAA,UAEvF;AAAA;AAAA,KAIL,kBAIL;AAAA;AAGN,MAAM,OAAO,4CAAqB,QAAQ,EAAE,MAAM;AAElD,MAAM,QAAQ;AAAA,EAEZ,gBAAgB,4BAAU,OAAO,YAAY;AAAA,EAE7C,IAAI,4BAAU,QAAQ,YAAY;AAAA,EAElC,gBAAgB,4BAAU,KAAK,YAAY;AAAA,EAE3C,SAAS,4BAAU,KAAK,YAAY;AAAA,EAEpC,aAAa,4BAAU,KAAK,YAAY;AAAA,EAExC,UAAU,4BAAU,OAAO,YAAY;AAAA,EAEvC,UAAU,4BAAU,OAAO,YAAY;AAAA;AAGzC,OAAO,YAAY;AAEnB,MAAM,mBAAmB,gCAAS;AAElC,iBAAiB,YAAY;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/DSMenu.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2, { useContext, useEffect, useMemo, useRef } from "react";
|
|
3
|
-
import { PropTypes, describe } from "react-desc";
|
|
4
|
-
import { omit } from "lodash";
|
|
5
|
-
import { aggregatedClasses } from "@elliemae/ds-classnames";
|
|
6
|
-
import { animated } from "react-spring/web";
|
|
7
|
-
import { useOnClickOutside } from "@elliemae/ds-utilities/hooks";
|
|
8
|
-
import { mergeRefs } from "@elliemae/ds-utilities/system";
|
|
9
|
-
import { focusGroupManagerHoc, FocusGroupContext } from "@elliemae/ds-shared/FocusGroup";
|
|
10
|
-
import { useHiddenTransition } from "@elliemae/ds-hidden";
|
|
11
|
-
import { MenuContext } from "./MenuContext";
|
|
12
|
-
const RESPONSIVE_HEIHGT_MARGIN = 120;
|
|
13
|
-
const blockName = "menu";
|
|
14
|
-
const noop = () => {
|
|
15
|
-
};
|
|
16
|
-
const MenuComponent = aggregatedClasses("div")(blockName, "", ({ menuComboBox, type }) => ({
|
|
17
|
-
"menu-combo-box": menuComboBox,
|
|
18
|
-
[`type-${type}`]: type
|
|
19
|
-
}));
|
|
20
|
-
const isChildOfType = (child, type) => child.type.name === type;
|
|
21
|
-
const DSMenu = ({
|
|
22
|
-
containerProps = {},
|
|
23
|
-
innerRef,
|
|
24
|
-
as: MenuTag = animated.ul,
|
|
25
|
-
children = void 0,
|
|
26
|
-
onClickOutside = noop,
|
|
27
|
-
visible = void 0,
|
|
28
|
-
focusOnOpen = false,
|
|
29
|
-
maxOption = 0,
|
|
30
|
-
style = {},
|
|
31
|
-
minWidth = void 0,
|
|
32
|
-
maxWidth = void 0,
|
|
33
|
-
closeMenu,
|
|
34
|
-
responsiveHeight = false,
|
|
35
|
-
...otherProps
|
|
36
|
-
}) => {
|
|
37
|
-
const menuRef = useRef(null);
|
|
38
|
-
const { focusFirst } = useContext(FocusGroupContext);
|
|
39
|
-
const { destroyed, ...hiddenProps } = useHiddenTransition({ visible, style });
|
|
40
|
-
const nextChildren = useMemo(() => {
|
|
41
|
-
const forceLeftAddon = React2.Children.toArray(children).some((child) => isChildOfType(child, "SelectionGroup") || isChildOfType(child, "MenuItemCheckbox") || isChildOfType(child, "MenuItemRadio") || child.props.leftAddon);
|
|
42
|
-
return React2.Children.map(children, (child) => child && React2.cloneElement(child, {
|
|
43
|
-
...child.props,
|
|
44
|
-
noAddon: !forceLeftAddon ? true : void 0,
|
|
45
|
-
maxOption,
|
|
46
|
-
closeMenu
|
|
47
|
-
}));
|
|
48
|
-
}, [children]);
|
|
49
|
-
useOnClickOutside(menuRef, onClickOutside);
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (focusOnOpen && visible) {
|
|
52
|
-
setTimeout(() => {
|
|
53
|
-
focusFirst();
|
|
54
|
-
}, 0);
|
|
55
|
-
}
|
|
56
|
-
}, [visible, focusOnOpen]);
|
|
57
|
-
return !hiddenProps.destroyed ? /* @__PURE__ */ React2.createElement(MenuContext.Provider, {
|
|
58
|
-
value: { visible, closeMenu }
|
|
59
|
-
}, /* @__PURE__ */ React2.createElement(MenuComponent, {
|
|
60
|
-
"data-testid": containerProps?.["data-testid"] ? containerProps["data-testid"] : "em-ds-menu",
|
|
61
|
-
...containerProps,
|
|
62
|
-
as: MenuTag,
|
|
63
|
-
classProps: { ...otherProps.classProps || {}, type: otherProps.type },
|
|
64
|
-
innerRef: mergeRefs(innerRef, menuRef),
|
|
65
|
-
role: "menu",
|
|
66
|
-
...omit(otherProps, ["scheduleUpdate"]),
|
|
67
|
-
...hiddenProps
|
|
68
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
69
|
-
className: "menu-component-internal-wrapper",
|
|
70
|
-
style: {
|
|
71
|
-
...style,
|
|
72
|
-
minWidth,
|
|
73
|
-
maxWidth,
|
|
74
|
-
...responsiveHeight ? {
|
|
75
|
-
overflowY: "scroll",
|
|
76
|
-
maxHeight: responsiveHeight ? `${window.innerHeight - RESPONSIVE_HEIHGT_MARGIN}px` : void 0
|
|
77
|
-
} : {}
|
|
78
|
-
}
|
|
79
|
-
}, nextChildren))) : null;
|
|
80
|
-
};
|
|
81
|
-
const Menu = focusGroupManagerHoc(DSMenu, { loop: true });
|
|
82
|
-
const props = {
|
|
83
|
-
containerProps: PropTypes.object.description("Injected props to wrapper element of component"),
|
|
84
|
-
as: PropTypes.element.description("Renders the menu with a specific html element"),
|
|
85
|
-
onClickOutside: PropTypes.func.description("Handler when a user clicks outside the menu"),
|
|
86
|
-
visible: PropTypes.bool.description("Whether the menu is visible or not"),
|
|
87
|
-
focusOnOpen: PropTypes.bool.description("When set to true, it's going to focus the first item"),
|
|
88
|
-
minWidth: PropTypes.number.description("Customize menu minWidth. Can be undefined or 'number'"),
|
|
89
|
-
maxWidth: PropTypes.number.description("Customize menu maxWidth. Can be undefined or 'number'")
|
|
90
|
-
};
|
|
91
|
-
DSMenu.propTypes = props;
|
|
92
|
-
const DSMenuWithSchema = describe(DSMenu);
|
|
93
|
-
DSMenuWithSchema.propTypes = props;
|
|
94
|
-
export {
|
|
95
|
-
DSMenuWithSchema,
|
|
96
|
-
Menu
|
|
97
|
-
};
|
|
98
|
-
//# sourceMappingURL=DSMenu.js.map
|
package/dist/esm/DSMenu.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSMenu.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { useContext, useEffect, useMemo, useRef } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { omit } from 'lodash';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { animated } from 'react-spring/web';\nimport { useOnClickOutside } from '@elliemae/ds-utilities/hooks';\nimport { mergeRefs } from '@elliemae/ds-utilities/system';\nimport { focusGroupManagerHoc, FocusGroupContext } from '@elliemae/ds-shared/FocusGroup';\nimport { useHiddenTransition } from '@elliemae/ds-hidden';\nimport { MenuContext } from './MenuContext';\n\nconst RESPONSIVE_HEIHGT_MARGIN = 120;\n\nconst blockName = 'menu';\n\nconst noop = () => {};\n\nconst MenuComponent = aggregatedClasses('div')(blockName, '', ({ menuComboBox, type }) => ({\n 'menu-combo-box': menuComboBox,\n [`type-${type}`]: type,\n}));\n\n/**\n * todo: -- IDEA -- each menu could have an overlay based on an overlay stack context so we can\n * capture the context of the clicks on very nested components\n */\n\nconst isChildOfType = (child, type) => child.type.name === type;\n\nconst DSMenu = ({\n containerProps = {},\n innerRef,\n as: MenuTag = animated.ul,\n children = undefined,\n onClickOutside = noop,\n // handlers from hidden\n visible = undefined,\n focusOnOpen = false,\n maxOption = 0,\n style = {},\n minWidth = undefined,\n maxWidth = undefined,\n closeMenu,\n responsiveHeight = false,\n ...otherProps\n}) => {\n const menuRef = useRef(null);\n const { focusFirst } = useContext(FocusGroupContext);\n const { destroyed, ...hiddenProps } = useHiddenTransition({ visible, style });\n\n // force no addon to the children if the menu doesn't have any item with leftAddon like SelectionGroup\n const nextChildren = useMemo(() => {\n const forceLeftAddon = React.Children.toArray(children).some(\n (child) =>\n isChildOfType(child, 'SelectionGroup') ||\n isChildOfType(child, 'MenuItemCheckbox') ||\n isChildOfType(child, 'MenuItemRadio') ||\n child.props.leftAddon,\n );\n\n return React.Children.map(\n children,\n (child) =>\n child &&\n React.cloneElement(child, {\n ...child.props,\n noAddon: !forceLeftAddon ? true : undefined,\n maxOption,\n closeMenu,\n }),\n );\n }, [children]);\n\n useOnClickOutside(menuRef, onClickOutside);\n\n useEffect(() => {\n if (focusOnOpen && visible) {\n setTimeout(() => {\n focusFirst();\n }, 0);\n }\n }, [visible, focusOnOpen]);\n // todo: find out a better approach to this\n return !hiddenProps.destroyed ? (\n <MenuContext.Provider value={{ visible, closeMenu }}>\n <MenuComponent\n data-testid={containerProps?.['data-testid'] ? containerProps['data-testid'] : 'em-ds-menu'}\n {...containerProps}\n as={MenuTag}\n classProps={{ ...(otherProps.classProps || {}), type: otherProps.type }}\n innerRef={mergeRefs(innerRef, menuRef)}\n role=\"menu\"\n {...omit(otherProps, ['scheduleUpdate'])}\n {...hiddenProps}\n >\n {/* eslint-disable indent */}\n <div\n className=\"menu-component-internal-wrapper\"\n style={{\n ...style,\n minWidth,\n maxWidth,\n ...(responsiveHeight\n ? {\n overflowY: 'scroll',\n maxHeight: responsiveHeight ? `${window.innerHeight - RESPONSIVE_HEIHGT_MARGIN}px` : undefined,\n }\n : {}),\n }}\n >\n {/* eslint-enable indent */}\n {nextChildren}\n </div>\n </MenuComponent>\n </MenuContext.Provider>\n ) : null;\n};\n\nconst Menu = focusGroupManagerHoc(DSMenu, { loop: true });\n\nconst props = {\n /** Injected props to wrapper element of component */\n containerProps: PropTypes.object.description('Injected props to wrapper element of component'),\n /** Renders the menu with a specific html element */\n as: PropTypes.element.description('Renders the menu with a specific html element'),\n /** Handler when a user clicks outside the menu */\n onClickOutside: PropTypes.func.description('Handler when a user clicks outside the menu'),\n /** Whether the menu is visible or not */\n visible: PropTypes.bool.description('Whether the menu is visible or not'),\n /** When set to true, it's going to focus the first item */\n focusOnOpen: PropTypes.bool.description(\"When set to true, it's going to focus the first item\"),\n /** Customize menu minWidth. Can be undefined or 'number' */\n minWidth: PropTypes.number.description(\"Customize menu minWidth. Can be undefined or 'number'\"),\n /** Customize menu maxWidth. Can be undefined or 'number' */\n maxWidth: PropTypes.number.description(\"Customize menu maxWidth. Can be undefined or 'number'\"),\n};\n\nDSMenu.propTypes = props;\n\nconst DSMenuWithSchema = describe(DSMenu);\n\nDSMenuWithSchema.propTypes = props;\n\nexport { DSMenuWithSchema, Menu };\n"],
|
|
5
|
-
"mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,2BAA2B;AAEjC,MAAM,YAAY;AAElB,MAAM,OAAO,MAAM;AAAA;AAEnB,MAAM,gBAAgB,kBAAkB,OAAO,WAAW,IAAI,CAAC,EAAE,cAAc,WAAY;AAAA,EACzF,kBAAkB;AAAA,GACjB,QAAQ,SAAS;AAAA;AAQpB,MAAM,gBAAgB,CAAC,OAAO,SAAS,MAAM,KAAK,SAAS;AAE3D,MAAM,SAAS,CAAC;AAAA,EACd,iBAAiB;AAAA,EACjB;AAAA,EACA,IAAI,UAAU,SAAS;AAAA,EACvB,WAAW;AAAA,EACX,iBAAiB;AAAA,EAEjB,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AAAA,EACX;AAAA,EACA,mBAAmB;AAAA,KAChB;AAAA,MACC;AACJ,QAAM,UAAU,OAAO;AACvB,QAAM,EAAE,eAAe,WAAW;AAClC,QAAM,EAAE,cAAc,gBAAgB,oBAAoB,EAAE,SAAS;AAGrE,QAAM,eAAe,QAAQ,MAAM;AACj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