@elliemae/ds-menu 2.3.0-alpha.9 → 2.3.0-next.3
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/cjs/Menu.js +195 -0
- package/cjs/MenuCombobox.js +56 -0
- package/cjs/MenuContext.js +11 -0
- package/cjs/MenuItems/CheckboxGroup.js +45 -0
- package/cjs/MenuItems/MenuItem.js +203 -0
- package/cjs/MenuItems/MenuItemCheckable.js +119 -0
- package/cjs/MenuItems/MenuItemCheckbox.js +42 -0
- package/cjs/MenuItems/MenuItemRadio.js +41 -0
- package/cjs/MenuItems/RadioGroup.js +42 -0
- package/cjs/MenuItems/SearchableGroup.js +101 -0
- package/cjs/MenuItems/SearchableList.js +117 -0
- package/cjs/MenuItems/SelectionGroup.js +107 -0
- package/cjs/MenuItems/Separator.js +44 -0
- package/cjs/MenuItems/SubMenu.js +203 -0
- package/cjs/MenuItems/menuItemFactory.js +73 -0
- package/cjs/VirtualMenuList.js +48 -0
- package/cjs/index.js +36 -0
- package/cjs/utils/useHeightByAmountOfItems.js +20 -0
- package/esm/Menu.js +180 -0
- package/esm/MenuCombobox.js +48 -0
- package/esm/MenuContext.js +5 -0
- package/esm/MenuItems/CheckboxGroup.js +35 -0
- package/esm/MenuItems/MenuItem.js +191 -0
- package/esm/MenuItems/MenuItemCheckable.js +108 -0
- package/esm/MenuItems/MenuItemCheckbox.js +34 -0
- package/esm/MenuItems/MenuItemRadio.js +32 -0
- package/esm/MenuItems/RadioGroup.js +32 -0
- package/esm/MenuItems/SearchableGroup.js +91 -0
- package/esm/MenuItems/SearchableList.js +108 -0
- package/esm/MenuItems/SelectionGroup.js +97 -0
- package/esm/MenuItems/Separator.js +33 -0
- package/esm/MenuItems/SubMenu.js +190 -0
- package/esm/MenuItems/menuItemFactory.js +64 -0
- package/esm/VirtualMenuList.js +42 -0
- package/esm/index.js +13 -0
- package/{dist/esm → esm}/utils/useHeightByAmountOfItems.js +11 -13
- package/package.json +62 -72
- package/{dist/types → types}/Menu.d.ts +2 -4
- package/{dist/types → types}/MenuCombobox.d.ts +0 -0
- package/types/MenuContext.d.ts +3 -0
- package/{dist/types → types}/MenuItems/CheckboxGroup.d.ts +5 -5
- package/{dist/types → types}/MenuItems/MenuItem.d.ts +5 -5
- package/{dist/types → types}/MenuItems/MenuItemCheckable.d.ts +14 -15
- package/{dist/types → types}/MenuItems/MenuItemCheckbox.d.ts +2 -3
- package/{dist/types → types}/MenuItems/MenuItemRadio.d.ts +5 -5
- package/{dist/types → types}/MenuItems/RadioGroup.d.ts +5 -5
- package/{dist/types → types}/MenuItems/SearchableGroup.d.ts +3 -3
- package/{dist/types → types}/MenuItems/SearchableList.d.ts +16 -16
- package/{dist/types → types}/MenuItems/SelectionGroup.d.ts +16 -16
- package/{dist/types → types}/MenuItems/Separator.d.ts +1 -2
- package/{dist/types → types}/MenuItems/SubMenu.d.ts +18 -18
- package/types/MenuItems/menuItemFactory.d.ts +3 -0
- package/{dist/types → types}/VirtualMenuList.d.ts +1 -3
- package/{dist/types → types}/index.d.ts +2 -3
- package/{dist/types → types}/tests/Menu.test.d.ts +0 -0
- package/{dist/types → types}/tests/MenuItem.test.d.ts +0 -0
- package/types/utils/useHeightByAmountOfItems.d.ts +5 -0
- package/dist/cjs/Menu.js +0 -151
- package/dist/cjs/Menu.js.map +0 -7
- package/dist/cjs/MenuCombobox.js +0 -70
- package/dist/cjs/MenuCombobox.js.map +0 -7
- package/dist/cjs/MenuContext.js +0 -38
- package/dist/cjs/MenuContext.js.map +0 -7
- package/dist/cjs/MenuExports.js +0 -36
- package/dist/cjs/MenuExports.js.map +0 -7
- package/dist/cjs/MenuItems/CheckboxGroup.js +0 -52
- package/dist/cjs/MenuItems/CheckboxGroup.js.map +0 -7
- package/dist/cjs/MenuItems/MenuItem.js +0 -157
- package/dist/cjs/MenuItems/MenuItem.js.map +0 -7
- package/dist/cjs/MenuItems/MenuItemCheckable.js +0 -88
- package/dist/cjs/MenuItems/MenuItemCheckable.js.map +0 -7
- package/dist/cjs/MenuItems/MenuItemCheckbox.js +0 -48
- package/dist/cjs/MenuItems/MenuItemCheckbox.js.map +0 -7
- package/dist/cjs/MenuItems/MenuItemRadio.js +0 -53
- package/dist/cjs/MenuItems/MenuItemRadio.js.map +0 -7
- package/dist/cjs/MenuItems/RadioGroup.js +0 -51
- package/dist/cjs/MenuItems/RadioGroup.js.map +0 -7
- package/dist/cjs/MenuItems/SearchableGroup.js +0 -97
- package/dist/cjs/MenuItems/SearchableGroup.js.map +0 -7
- package/dist/cjs/MenuItems/SearchableList.js +0 -114
- package/dist/cjs/MenuItems/SearchableList.js.map +0 -7
- package/dist/cjs/MenuItems/SelectionGroup.js +0 -102
- package/dist/cjs/MenuItems/SelectionGroup.js.map +0 -7
- package/dist/cjs/MenuItems/Separator.js +0 -59
- package/dist/cjs/MenuItems/Separator.js.map +0 -7
- package/dist/cjs/MenuItems/SubMenu.js +0 -187
- package/dist/cjs/MenuItems/SubMenu.js.map +0 -7
- package/dist/cjs/MenuItems/menuItemFactory.js +0 -41
- package/dist/cjs/MenuItems/menuItemFactory.js.map +0 -7
- package/dist/cjs/MenuItems/renderMenuItems.js +0 -54
- package/dist/cjs/MenuItems/renderMenuItems.js.map +0 -7
- package/dist/cjs/VirtualMenuList.js +0 -78
- package/dist/cjs/VirtualMenuList.js.map +0 -7
- package/dist/cjs/index.js +0 -63
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/utils/useHeightByAmountOfItems.js +0 -49
- package/dist/cjs/utils/useHeightByAmountOfItems.js.map +0 -7
- package/dist/esm/Menu.js +0 -122
- package/dist/esm/Menu.js.map +0 -7
- package/dist/esm/MenuCombobox.js +0 -41
- package/dist/esm/MenuCombobox.js.map +0 -7
- package/dist/esm/MenuContext.js +0 -9
- package/dist/esm/MenuContext.js.map +0 -7
- package/dist/esm/MenuExports.js +0 -7
- package/dist/esm/MenuExports.js.map +0 -7
- package/dist/esm/MenuItems/CheckboxGroup.js +0 -23
- package/dist/esm/MenuItems/CheckboxGroup.js.map +0 -7
- package/dist/esm/MenuItems/MenuItem.js +0 -128
- package/dist/esm/MenuItems/MenuItem.js.map +0 -7
- package/dist/esm/MenuItems/MenuItemCheckable.js +0 -59
- package/dist/esm/MenuItems/MenuItemCheckable.js.map +0 -7
- package/dist/esm/MenuItems/MenuItemCheckbox.js +0 -19
- package/dist/esm/MenuItems/MenuItemCheckbox.js.map +0 -7
- package/dist/esm/MenuItems/MenuItemRadio.js +0 -24
- package/dist/esm/MenuItems/MenuItemRadio.js.map +0 -7
- package/dist/esm/MenuItems/RadioGroup.js +0 -22
- package/dist/esm/MenuItems/RadioGroup.js.map +0 -7
- package/dist/esm/MenuItems/SearchableGroup.js +0 -68
- package/dist/esm/MenuItems/SearchableGroup.js.map +0 -7
- package/dist/esm/MenuItems/SearchableList.js +0 -85
- package/dist/esm/MenuItems/SearchableList.js.map +0 -7
- package/dist/esm/MenuItems/SelectionGroup.js +0 -73
- package/dist/esm/MenuItems/SelectionGroup.js.map +0 -7
- package/dist/esm/MenuItems/Separator.js +0 -30
- package/dist/esm/MenuItems/Separator.js.map +0 -7
- package/dist/esm/MenuItems/SubMenu.js +0 -158
- package/dist/esm/MenuItems/SubMenu.js.map +0 -7
- package/dist/esm/MenuItems/menuItemFactory.js +0 -12
- package/dist/esm/MenuItems/menuItemFactory.js.map +0 -7
- package/dist/esm/MenuItems/renderMenuItems.js +0 -25
- package/dist/esm/MenuItems/renderMenuItems.js.map +0 -7
- package/dist/esm/VirtualMenuList.js +0 -49
- package/dist/esm/VirtualMenuList.js.map +0 -7
- package/dist/esm/index.js +0 -34
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/utils/useHeightByAmountOfItems.js.map +0 -7
- package/dist/types/MenuContext.d.ts +0 -4
- package/dist/types/MenuExports.d.ts +0 -1
- package/dist/types/MenuItems/menuItemFactory.d.ts +0 -2
- package/dist/types/MenuItems/renderMenuItems.d.ts +0 -1
- package/dist/types/utils/useHeightByAmountOfItems.d.ts +0 -7
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/MenuItems/CheckboxGroup.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { CheckableGroup } from '@elliemae/ds-shared/CheckableGroup';\n\nconst CheckboxGroup = (props) => <CheckableGroup {...props} multi />;\n\nconst props = {\n /* The item (if multi false) or items (if multi true) selected */\n active: PropTypes.arrayOf(PropTypes.string).description(\n 'The item (if multi false) or items (if multi true) selected',\n ),\n /* Whether is multi select or not */\n multi: PropTypes.bool.description('Whether is multi select or not'),\n /* Handler when a user checks an item */\n onCheck: PropTypes.func.description('Handler when a user checks an item'),\n};\n\nCheckboxGroup.propTypes = props;\n\nconst DSMenuCheckboxGroupWithSchema = describe(CheckboxGroup);\nDSMenuCheckboxGroupWithSchema.propTypes = props;\n\nexport { DSMenuCheckboxGroupWithSchema, CheckboxGroup };\nexport default CheckboxGroup;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AAEA,MAAM,gBAAgB,CAAC,WAAU,qCAAC,gBAAD;AAAA,KAAoB;AAAA,EAAO,OAAK;AAAA;AAEjE,MAAM,QAAQ;AAAA,EAEZ,QAAQ,UAAU,QAAQ,UAAU,QAAQ,YAC1C;AAAA,EAGF,OAAO,UAAU,KAAK,YAAY;AAAA,EAElC,SAAS,UAAU,KAAK,YAAY;AAAA;AAGtC,cAAc,YAAY;AAE1B,MAAM,gCAAgC,SAAS;AAC/C,8BAA8B,YAAY;AAG1C,IAAO,wBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2, { useRef, useMemo, useContext } from "react";
|
|
3
|
-
import { PropTypes, describe } from "react-desc";
|
|
4
|
-
import { omit } from "lodash";
|
|
5
|
-
import { aggregatedClasses } from "@elliemae/ds-classnames";
|
|
6
|
-
import { mergeRefs, runAll } from "@elliemae/ds-utilities";
|
|
7
|
-
import { useFocusGroupItem } from "@elliemae/ds-shared/FocusGroup";
|
|
8
|
-
import { DSTruncatedTooltipText } from "@elliemae/ds-truncated-tooltip-text";
|
|
9
|
-
import { MenuContext } from "../MenuContext";
|
|
10
|
-
import { registerMenuItem, menuItemFactory } from "./menuItemFactory";
|
|
11
|
-
import { renderMenuItems } from "./renderMenuItems";
|
|
12
|
-
const noop = () => null;
|
|
13
|
-
const blockName = "menu-item";
|
|
14
|
-
const Content = aggregatedClasses("div")(blockName, "content");
|
|
15
|
-
const Addon = aggregatedClasses("div")(blockName, "addon", ({ empty, fixedItem }) => ({ empty, fixedItem }));
|
|
16
|
-
const renderAddon = (addon, fixedItem, addonId) => /* @__PURE__ */ React2.createElement(Addon, {
|
|
17
|
-
key: addonId,
|
|
18
|
-
classProps: { fixedItem }
|
|
19
|
-
}, addon);
|
|
20
|
-
const renderAddons = (addons, fixedItem) => Array.isArray(addons) ? addons.map(renderAddon) : renderAddon(addons, fixedItem);
|
|
21
|
-
const Wrapper = aggregatedClasses("li")(blockName, null, ({ disabled, disabledAddonInactive, customRenderer, fixedItem, type }) => ({
|
|
22
|
-
disabled,
|
|
23
|
-
disabledAddonInactive,
|
|
24
|
-
customRenderer,
|
|
25
|
-
fixedItem,
|
|
26
|
-
[`menu-type-${type}`]: type
|
|
27
|
-
}));
|
|
28
|
-
const calculateSize = (length = 0) => {
|
|
29
|
-
if (length > 45)
|
|
30
|
-
return 45 * 7;
|
|
31
|
-
return length * 7;
|
|
32
|
-
};
|
|
33
|
-
const MenuItem = (props2) => {
|
|
34
|
-
const {
|
|
35
|
-
innerRef,
|
|
36
|
-
as = "li",
|
|
37
|
-
role = "menuitem",
|
|
38
|
-
leftAddon = null,
|
|
39
|
-
rightAddon = void 0,
|
|
40
|
-
disabledAddonInactive = void 0,
|
|
41
|
-
label = void 0,
|
|
42
|
-
children,
|
|
43
|
-
tabIndex = -1,
|
|
44
|
-
onKeyDown = noop,
|
|
45
|
-
fixedItem = false,
|
|
46
|
-
noAddon,
|
|
47
|
-
disabled = false,
|
|
48
|
-
customRenderer,
|
|
49
|
-
maxOption,
|
|
50
|
-
closeMenu,
|
|
51
|
-
style,
|
|
52
|
-
...otherProps
|
|
53
|
-
} = props2;
|
|
54
|
-
const menuCxt = useContext(MenuContext);
|
|
55
|
-
const ref = useRef(null);
|
|
56
|
-
useFocusGroupItem(ref);
|
|
57
|
-
if (otherProps.subItems) {
|
|
58
|
-
const SubMenu = menuItemFactory("submenu");
|
|
59
|
-
return /* @__PURE__ */ React2.createElement(SubMenu, {
|
|
60
|
-
...props2,
|
|
61
|
-
closeMenu: menuCxt.closeMenu
|
|
62
|
-
}, renderMenuItems(otherProps.subItems));
|
|
63
|
-
}
|
|
64
|
-
const wrapperProps = useMemo(() => omit(otherProps, ["icon"]), [otherProps]);
|
|
65
|
-
const onClick = (...args) => {
|
|
66
|
-
if (wrapperProps.onClick)
|
|
67
|
-
wrapperProps.onClick(...args);
|
|
68
|
-
if (wrapperProps.closeOnClick && menuCxt.closeMenu) {
|
|
69
|
-
menuCxt.closeMenu(...args);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
return /* @__PURE__ */ React2.createElement(Wrapper, {
|
|
73
|
-
as,
|
|
74
|
-
classProps: {
|
|
75
|
-
disabled,
|
|
76
|
-
disabledAddonInactive,
|
|
77
|
-
customRenderer,
|
|
78
|
-
fixedItem,
|
|
79
|
-
type: otherProps.type
|
|
80
|
-
},
|
|
81
|
-
id: otherProps.id,
|
|
82
|
-
innerRef: otherProps.type !== "disabled" ? mergeRefs(innerRef, ref) : innerRef,
|
|
83
|
-
onKeyDown: !fixedItem && runAll((e) => {
|
|
84
|
-
if (e.key === " " || e.key === "Enter") {
|
|
85
|
-
e.preventDefault();
|
|
86
|
-
e.target.dispatchEvent(new MouseEvent("click", {
|
|
87
|
-
view: window,
|
|
88
|
-
bubbles: true,
|
|
89
|
-
cancelable: false
|
|
90
|
-
}));
|
|
91
|
-
}
|
|
92
|
-
}, onKeyDown),
|
|
93
|
-
role,
|
|
94
|
-
style,
|
|
95
|
-
tabIndex,
|
|
96
|
-
...wrapperProps,
|
|
97
|
-
onClick
|
|
98
|
-
}, !noAddon && renderAddons(leftAddon, fixedItem), label && /* @__PURE__ */ React2.createElement(Content, {
|
|
99
|
-
style: maxOption > 0 ? {
|
|
100
|
-
width: `${calculateSize(maxOption)}px`,
|
|
101
|
-
maxWidth: `${calculateSize(maxOption)}px`
|
|
102
|
-
} : void 0
|
|
103
|
-
}, /* @__PURE__ */ React2.createElement(DSTruncatedTooltipText, {
|
|
104
|
-
value: label
|
|
105
|
-
})), customRenderer, rightAddon && renderAddons(rightAddon), children);
|
|
106
|
-
};
|
|
107
|
-
const props = {
|
|
108
|
-
as: PropTypes.element.description("Renders the MenuItem with a specific html element"),
|
|
109
|
-
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description("reference to the component"),
|
|
110
|
-
leftAddon: PropTypes.element.description("Renders the passed element to the left"),
|
|
111
|
-
rightAddon: PropTypes.element.description("Renders the passed element to the right"),
|
|
112
|
-
label: PropTypes.string.description("Label for the menu item"),
|
|
113
|
-
style: PropTypes.object.description("style object for menu item wrapper"),
|
|
114
|
-
disabled: PropTypes.bool.description("disable menu item"),
|
|
115
|
-
tabindex: PropTypes.number.description("HTML tabindex to manage focus order"),
|
|
116
|
-
role: PropTypes.string.description("a11y role")
|
|
117
|
-
};
|
|
118
|
-
MenuItem.propTypes = props;
|
|
119
|
-
registerMenuItem("menuitem", MenuItem);
|
|
120
|
-
const DSMenuItemWithSchema = describe(MenuItem);
|
|
121
|
-
DSMenuItemWithSchema.propTypes = props;
|
|
122
|
-
var MenuItem_default = MenuItem;
|
|
123
|
-
export {
|
|
124
|
-
DSMenuItemWithSchema,
|
|
125
|
-
MenuItem,
|
|
126
|
-
MenuItem_default as default
|
|
127
|
-
};
|
|
128
|
-
//# sourceMappingURL=MenuItem.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 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, 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,IACA;AAAA,IACA;AAAA,IACA;AAAA,OACG;AAAA,MACD;AAEJ,QAAM,UAAU,WAAW;AAC3B,QAAM,MAAM,OAAO;AACnB,oBAAkB;AAClB,MAAI,WAAW,UAAU;AACvB,UAAM,UAAU,gBAAgB;AAChC,WACE,qCAAC,SAAD;AAAA,SAAa;AAAA,MAAO,WAAW,QAAQ;AAAA,OACpC,gBAAgB,WAAW;AAAA;AAKlC,QAAM,eAAe,QAAQ,MAAM,KAAK,YAAY,CAAC,UAAU,CAAC;AAEhE,QAAM,UAAU,IAAI,SAAS;AAC3B,QAAI,aAAa;AAAS,mBAAa,QAAQ,GAAG;AAClD,QAAI,aAAa,gBAAgB,QAAQ,WAAW;AAClD,cAAQ,UAAU,GAAG;AAAA;AAAA;AAIzB,SACE,qCAAC,SAAD;AAAA,IACE;AAAA,IACA,YAAY;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,WAAW;AAAA;AAAA,IAEnB,IAAI,WAAW;AAAA,IACf,UAAU,WAAW,SAAS,aAAa,UAAU,UAAU,OAAO;AAAA,IACtE,WACE,CAAC,aACD,OAAO,CAAC,MAAM;AACZ,UAAI,EAAE,QAAQ,OAAO,EAAE,QAAQ,SAAS;AACtC,UAAE;AACF,UAAE,OAAO,cACP,IAAI,WAAW,SAAS;AAAA,UACtB,MAAM;AAAA,UACN,SAAS;AAAA,UACT,YAAY;AAAA;AAAA;AAAA,OAIjB;AAAA,IAEL;AAAA,IACA;AAAA,IACA;AAAA,OACI;AAAA,IACJ;AAAA,KAEC,CAAC,WAAW,aAAa,WAAW,YACpC,SACC,qCAAC,SAAD;AAAA,IACE,OACE,YAAY,IACR;AAAA,MACE,OAAO,GAAG,cAAc;AAAA,MACxB,UAAU,GAAG,cAAc;AAAA,QAE7B;AAAA,KAGN,qCAAC,wBAAD;AAAA,IAAwB,OAAO;AAAA,OAGlC,gBACA,cAAc,aAAa,aAC3B;AAAA;AAKP,MAAM,QAAQ;AAAA,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
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2 from "react";
|
|
3
|
-
import { PropTypes, describe } from "react-desc";
|
|
4
|
-
import { Checkmark } from "@elliemae/ds-icons";
|
|
5
|
-
import { runAll } from "@elliemae/ds-utilities";
|
|
6
|
-
import { MenuItem } from "./MenuItem";
|
|
7
|
-
function useCheckable({ checked }) {
|
|
8
|
-
return {
|
|
9
|
-
checked,
|
|
10
|
-
"aria-checked": checked
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
const MenuItemCheckable = ({
|
|
14
|
-
role = "menuitemcheckbox",
|
|
15
|
-
checked = false,
|
|
16
|
-
name = "",
|
|
17
|
-
checkIcon = /* @__PURE__ */ React2.createElement(Checkmark, {
|
|
18
|
-
color: ["brand-primary", 600]
|
|
19
|
-
}),
|
|
20
|
-
children,
|
|
21
|
-
leftAddon,
|
|
22
|
-
item = void 0,
|
|
23
|
-
...otherProps
|
|
24
|
-
}) => {
|
|
25
|
-
const checkableProps = useCheckable({ checked, name });
|
|
26
|
-
const handleClick = () => runAll(otherProps.onClick, checkableProps.onClick)({ target: { value: name, checked } }, item);
|
|
27
|
-
const checkAddon = leftAddon || (checkableProps.checked ? /* @__PURE__ */ React2.createElement("div", {
|
|
28
|
-
className: "checkable-mark"
|
|
29
|
-
}, checkIcon) : /* @__PURE__ */ React2.createElement("div", null));
|
|
30
|
-
return /* @__PURE__ */ React2.createElement(MenuItem, {
|
|
31
|
-
...item,
|
|
32
|
-
...otherProps,
|
|
33
|
-
...checkableProps,
|
|
34
|
-
customRenderer: item && item.customRenderer ? item.customRenderer : () => {
|
|
35
|
-
},
|
|
36
|
-
items: otherProps.subItems,
|
|
37
|
-
leftAddon: checkAddon,
|
|
38
|
-
onClick: handleClick,
|
|
39
|
-
role
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
const props = {
|
|
43
|
-
checked: PropTypes.bool.description("Whether the item is checked or not"),
|
|
44
|
-
checkIcon: PropTypes.element.description("A custom item when the item is checked"),
|
|
45
|
-
name: PropTypes.string.description("form field name"),
|
|
46
|
-
item: PropTypes.object.description("menu item object props"),
|
|
47
|
-
role: PropTypes.string.description("a11y role"),
|
|
48
|
-
leftAddon: PropTypes.node.description("left addon component")
|
|
49
|
-
};
|
|
50
|
-
MenuItemCheckable.propTypes = props;
|
|
51
|
-
const DSMenuItemCheckeableWithSchema = describe(MenuItemCheckable);
|
|
52
|
-
DSMenuItemCheckeableWithSchema.propTypes = props;
|
|
53
|
-
var MenuItemCheckable_default = MenuItemCheckable;
|
|
54
|
-
export {
|
|
55
|
-
DSMenuItemCheckeableWithSchema,
|
|
56
|
-
MenuItemCheckable,
|
|
57
|
-
MenuItemCheckable_default as default
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=MenuItemCheckable.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/MenuItems/MenuItemCheckable.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable import/no-cycle */\nimport React from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { Checkmark } from '@elliemae/ds-icons';\nimport { runAll } from '@elliemae/ds-utilities';\nimport { MenuItem } from './MenuItem';\n\n// TODO: where to move this?\nfunction useCheckable({ checked }) {\n return {\n checked,\n 'aria-checked': checked,\n };\n}\n\n/**\n * Reuses the same props as the MenuItem\n *\n * @param root0\n * @param root0.role\n * @param root0.checked\n * @param root0.name\n * @param root0.checkIcon\n * @param root0.children\n * @param root0.leftAddon\n * @param root0.item\n */\nconst MenuItemCheckable = ({\n role = 'menuitemcheckbox',\n checked = false,\n name = '',\n checkIcon = <Checkmark color={['brand-primary', 600]} />,\n // eslint-disable-next-line react/prop-types\n children,\n leftAddon,\n item = undefined,\n ...otherProps\n}) => {\n const checkableProps = useCheckable({ checked, name });\n const handleClick = () =>\n runAll(otherProps.onClick, checkableProps.onClick)({ target: { value: name, checked } }, item);\n\n const checkAddon =\n leftAddon || (checkableProps.checked ? <div className=\"checkable-mark\">{checkIcon}</div> : <div />);\n return (\n <MenuItem\n {...item}\n {...otherProps}\n {...checkableProps}\n customRenderer={item && item.customRenderer ? item.customRenderer : () => {}}\n items={otherProps.subItems}\n leftAddon={checkAddon}\n onClick={handleClick}\n role={role}\n />\n );\n};\n\nconst props = {\n /** Whether the item is checked or not */\n checked: PropTypes.bool.description('Whether the item is checked or not'),\n /** A custom item when the item is checked */\n checkIcon: PropTypes.element.description('A custom item when the item is checked'),\n /** form field name */\n name: PropTypes.string.description('form field name'),\n /** menu item object props */\n item: PropTypes.object.description('menu item object props'),\n /** a11y role */\n role: PropTypes.string.description('a11y role'),\n /** left addon component */\n leftAddon: PropTypes.node.description('left addon component'),\n};\n\nMenuItemCheckable.propTypes = props;\n\nconst DSMenuItemCheckeableWithSchema = describe(MenuItemCheckable);\nDSMenuItemCheckeableWithSchema.propTypes = props;\n\nexport { DSMenuItemCheckeableWithSchema, MenuItemCheckable };\nexport default MenuItemCheckable;\n"],
|
|
5
|
-
"mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AAGA,sBAAsB,EAAE,WAAW;AACjC,SAAO;AAAA,IACL;AAAA,IACA,gBAAgB;AAAA;AAAA;AAgBpB,MAAM,oBAAoB,CAAC;AAAA,EACzB,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AAAA,EACP,YAAY,qCAAC,WAAD;AAAA,IAAW,OAAO,CAAC,iBAAiB;AAAA;AAAA,EAEhD;AAAA,EACA;AAAA,EACA,OAAO;AAAA,KACJ;AAAA,MACC;AACJ,QAAM,iBAAiB,aAAa,EAAE,SAAS;AAC/C,QAAM,cAAc,MAClB,OAAO,WAAW,SAAS,eAAe,SAAS,EAAE,QAAQ,EAAE,OAAO,MAAM,aAAa;AAE3F,QAAM,aACJ,aAAc,gBAAe,UAAU,qCAAC,OAAD;AAAA,IAAK,WAAU;AAAA,KAAkB,aAAmB,qCAAC,OAAD;AAC7F,SACE,qCAAC,UAAD;AAAA,OACM;AAAA,OACA;AAAA,OACA;AAAA,IACJ,gBAAgB,QAAQ,KAAK,iBAAiB,KAAK,iBAAiB,MAAM;AAAA;AAAA,IAC1E,OAAO,WAAW;AAAA,IAClB,WAAW;AAAA,IACX,SAAS;AAAA,IACT;AAAA;AAAA;AAKN,MAAM,QAAQ;AAAA,EAEZ,SAAS,UAAU,KAAK,YAAY;AAAA,EAEpC,WAAW,UAAU,QAAQ,YAAY;AAAA,EAEzC,MAAM,UAAU,OAAO,YAAY;AAAA,EAEnC,MAAM,UAAU,OAAO,YAAY;AAAA,EAEnC,MAAM,UAAU,OAAO,YAAY;AAAA,EAEnC,WAAW,UAAU,KAAK,YAAY;AAAA;AAGxC,kBAAkB,YAAY;AAE9B,MAAM,iCAAiC,SAAS;AAChD,+BAA+B,YAAY;AAG3C,IAAO,4BAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2 from "react";
|
|
3
|
-
import { DSCheckbox } from "@elliemae/ds-form/Checkbox";
|
|
4
|
-
import { MenuItemCheckable } from "./MenuItemCheckable";
|
|
5
|
-
import { registerMenuItem } from "./menuItemFactory";
|
|
6
|
-
const MenuItemCheckbox = ({ checked, ...rest }) => /* @__PURE__ */ React2.createElement(MenuItemCheckable, {
|
|
7
|
-
...rest,
|
|
8
|
-
leftAddon: /* @__PURE__ */ React2.createElement(DSCheckbox, {
|
|
9
|
-
checked
|
|
10
|
-
}),
|
|
11
|
-
role: "menuitemcheckbox"
|
|
12
|
-
});
|
|
13
|
-
registerMenuItem("checkbox", MenuItemCheckbox);
|
|
14
|
-
var MenuItemCheckbox_default = MenuItemCheckbox;
|
|
15
|
-
export {
|
|
16
|
-
MenuItemCheckbox,
|
|
17
|
-
MenuItemCheckbox_default as default
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=MenuItemCheckbox.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/MenuItems/MenuItemCheckbox.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { DSCheckbox } from '@elliemae/ds-form/Checkbox';\nimport { MenuItemCheckable } from './MenuItemCheckable';\nimport { registerMenuItem } from './menuItemFactory';\n\nconst MenuItemCheckbox = ({ checked, ...rest }) => (\n <MenuItemCheckable {...rest} leftAddon={<DSCheckbox checked={checked} />} role=\"menuitemcheckbox\" />\n);\n\nregisterMenuItem('checkbox', MenuItemCheckbox);\nexport { MenuItemCheckbox };\nexport default MenuItemCheckbox;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AAEA,MAAM,mBAAmB,CAAC,EAAE,YAAY,WACtC,qCAAC,mBAAD;AAAA,KAAuB;AAAA,EAAM,WAAW,qCAAC,YAAD;AAAA,IAAY;AAAA;AAAA,EAAsB,MAAK;AAAA;AAGjF,iBAAiB,YAAY;AAE7B,IAAO,2BAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2 from "react";
|
|
3
|
-
import { describe, PropTypes } from "react-desc";
|
|
4
|
-
import { MenuItemCheckable } from "./MenuItemCheckable";
|
|
5
|
-
import { registerMenuItem } from "./menuItemFactory";
|
|
6
|
-
const MenuItemRadio = (props2) => /* @__PURE__ */ React2.createElement(MenuItemCheckable, {
|
|
7
|
-
...props2,
|
|
8
|
-
role: "menuitemradio"
|
|
9
|
-
});
|
|
10
|
-
const props = {
|
|
11
|
-
checked: PropTypes.bool.description("Whether the item is checked or not"),
|
|
12
|
-
checkIcon: PropTypes.element.description("A custom item when the item is checked")
|
|
13
|
-
};
|
|
14
|
-
MenuItemRadio.propTypes = props;
|
|
15
|
-
registerMenuItem("radio", MenuItemRadio);
|
|
16
|
-
const DSMenuItemRadioWithSchema = describe(MenuItemCheckable);
|
|
17
|
-
DSMenuItemRadioWithSchema.propTypes = props;
|
|
18
|
-
var MenuItemRadio_default = MenuItemRadio;
|
|
19
|
-
export {
|
|
20
|
-
DSMenuItemRadioWithSchema,
|
|
21
|
-
MenuItemRadio,
|
|
22
|
-
MenuItemRadio_default as default
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=MenuItemRadio.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/MenuItems/MenuItemRadio.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport { MenuItemCheckable } from './MenuItemCheckable';\nimport { registerMenuItem } from './menuItemFactory';\n\nconst MenuItemRadio = (props) => <MenuItemCheckable {...props} role=\"menuitemradio\" />;\n\nconst props = {\n /** Whether the item is checked or not */\n checked: PropTypes.bool.description('Whether the item is checked or not'),\n /** A custom item when the item is checked */\n checkIcon: PropTypes.element.description('A custom item when the item is checked'),\n};\n\nMenuItemRadio.propTypes = props;\nregisterMenuItem('radio', MenuItemRadio);\n\nconst DSMenuItemRadioWithSchema = describe(MenuItemCheckable);\nDSMenuItemRadioWithSchema.propTypes = props;\n\nexport { DSMenuItemRadioWithSchema, MenuItemRadio };\nexport default MenuItemRadio;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AAEA,MAAM,gBAAgB,CAAC,WAAU,qCAAC,mBAAD;AAAA,KAAuB;AAAA,EAAO,MAAK;AAAA;AAEpE,MAAM,QAAQ;AAAA,EAEZ,SAAS,UAAU,KAAK,YAAY;AAAA,EAEpC,WAAW,UAAU,QAAQ,YAAY;AAAA;AAG3C,cAAc,YAAY;AAC1B,iBAAiB,SAAS;AAE1B,MAAM,4BAA4B,SAAS;AAC3C,0BAA0B,YAAY;AAGtC,IAAO,wBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2 from "react";
|
|
3
|
-
import { describe, PropTypes } from "react-desc";
|
|
4
|
-
import { CheckableGroup } from "@elliemae/ds-shared/CheckableGroup";
|
|
5
|
-
const RadioGroup = (props2) => /* @__PURE__ */ React2.createElement(CheckableGroup, {
|
|
6
|
-
...props2,
|
|
7
|
-
multi: false
|
|
8
|
-
});
|
|
9
|
-
const props = {
|
|
10
|
-
active: PropTypes.arrayOf(PropTypes.string).description("the item selected"),
|
|
11
|
-
onCheck: PropTypes.func.description("Handler when a user checks an item")
|
|
12
|
-
};
|
|
13
|
-
RadioGroup.propTypes = props;
|
|
14
|
-
const DSMenuRadioGroupWithSchema = describe(RadioGroup);
|
|
15
|
-
DSMenuRadioGroupWithSchema.propTypes = props;
|
|
16
|
-
var RadioGroup_default = RadioGroup;
|
|
17
|
-
export {
|
|
18
|
-
DSMenuRadioGroupWithSchema,
|
|
19
|
-
RadioGroup,
|
|
20
|
-
RadioGroup_default as default
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=RadioGroup.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/MenuItems/RadioGroup.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport { CheckableGroup } from '@elliemae/ds-shared/CheckableGroup';\n\nconst RadioGroup = (props) => <CheckableGroup {...props} multi={false} />;\n\nconst props = {\n /* The item selected */\n active: PropTypes.arrayOf(PropTypes.string).description('the item selected'),\n /* Handler when a user checks an item */\n onCheck: PropTypes.func.description('Handler when a user checks an item'),\n};\n\nRadioGroup.propTypes = props;\n\nconst DSMenuRadioGroupWithSchema = describe(RadioGroup);\n\nDSMenuRadioGroupWithSchema.propTypes = props;\n\nexport { DSMenuRadioGroupWithSchema, RadioGroup };\nexport default RadioGroup;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AAEA,MAAM,aAAa,CAAC,WAAU,qCAAC,gBAAD;AAAA,KAAoB;AAAA,EAAO,OAAO;AAAA;AAEhE,MAAM,QAAQ;AAAA,EAEZ,QAAQ,UAAU,QAAQ,UAAU,QAAQ,YAAY;AAAA,EAExD,SAAS,UAAU,KAAK,YAAY;AAAA;AAGtC,WAAW,YAAY;AAEvB,MAAM,6BAA6B,SAAS;AAE5C,2BAA2B,YAAY;AAGvC,IAAO,qBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2, { useEffect, useMemo, useState, useRef, useContext } from "react";
|
|
3
|
-
import { aggregatedClasses } from "@elliemae/ds-classnames";
|
|
4
|
-
import { focusGroupManagerHoc } from "@elliemae/ds-shared/FocusGroup";
|
|
5
|
-
import { DSSearchBox } from "@elliemae/ds-form/SearchBox";
|
|
6
|
-
import { PropTypes, describe } from "react-desc";
|
|
7
|
-
import { VirtualMenuList } from "../VirtualMenuList";
|
|
8
|
-
import { MenuContext } from "../MenuContext";
|
|
9
|
-
const SearchBoxWrapper = aggregatedClasses("div")("menu-search-group", "search-wrapper");
|
|
10
|
-
const NoOptionsWrapper = aggregatedClasses("div")("menu-search-group", "no-options");
|
|
11
|
-
const SearchableGroup = ({
|
|
12
|
-
children,
|
|
13
|
-
amountItemsInWindow = 5,
|
|
14
|
-
searchTerm: searchTermProp = "",
|
|
15
|
-
noOptionsText = "No options",
|
|
16
|
-
height,
|
|
17
|
-
width,
|
|
18
|
-
focusOnOpen = false
|
|
19
|
-
}) => {
|
|
20
|
-
const searchRef = useRef(null);
|
|
21
|
-
const [searchTerm, setSearchTerm] = useState(searchTermProp);
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (searchRef.current)
|
|
24
|
-
searchRef.current.focus();
|
|
25
|
-
}, []);
|
|
26
|
-
const { visible } = useContext(MenuContext) || {};
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (focusOnOpen && visible) {
|
|
29
|
-
setTimeout(() => {
|
|
30
|
-
if (searchRef.current)
|
|
31
|
-
searchRef.current.focus();
|
|
32
|
-
}, 0);
|
|
33
|
-
}
|
|
34
|
-
}, [focusOnOpen, visible]);
|
|
35
|
-
const filteredChildren = useMemo(() => children.filter((child) => !searchTerm || child.props.label.toLowerCase().startsWith(searchTerm.toLowerCase())), [children, searchTerm]);
|
|
36
|
-
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(SearchBoxWrapper, null, /* @__PURE__ */ React2.createElement(DSSearchBox, {
|
|
37
|
-
innerRef: searchRef,
|
|
38
|
-
onSearch: ({ value }) => setSearchTerm(value),
|
|
39
|
-
searchOnEnter: false,
|
|
40
|
-
showIcon: false,
|
|
41
|
-
value: searchTerm
|
|
42
|
-
})), !filteredChildren.length && /* @__PURE__ */ React2.createElement(NoOptionsWrapper, null, noOptionsText), /* @__PURE__ */ React2.createElement(VirtualMenuList, {
|
|
43
|
-
amountItemsInWindow,
|
|
44
|
-
height,
|
|
45
|
-
items: filteredChildren,
|
|
46
|
-
width
|
|
47
|
-
}));
|
|
48
|
-
};
|
|
49
|
-
const props = {
|
|
50
|
-
amountItemsInWindow: PropTypes.number.description("The amount of items that are going to be rendered in the group"),
|
|
51
|
-
searchTerm: PropTypes.string.description("A search term"),
|
|
52
|
-
noOptionsText: PropTypes.string.description("Text to show when there's no options to show"),
|
|
53
|
-
children: PropTypes.array.description("array of children for search list"),
|
|
54
|
-
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description("height for virtual list wrapper"),
|
|
55
|
-
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description("width for virtual list wrapper"),
|
|
56
|
-
focusOnOpen: PropTypes.bool.description("weather to focus on searchable group on open")
|
|
57
|
-
};
|
|
58
|
-
SearchableGroup.propTypes = props;
|
|
59
|
-
const DSMenuSearchableGroupWithSchema = describe(SearchableGroup);
|
|
60
|
-
DSMenuSearchableGroupWithSchema.propTypes = props;
|
|
61
|
-
const SearchableGroupHOC = focusGroupManagerHoc(SearchableGroup);
|
|
62
|
-
var SearchableGroup_default = SearchableGroupHOC;
|
|
63
|
-
export {
|
|
64
|
-
DSMenuSearchableGroupWithSchema,
|
|
65
|
-
SearchableGroupHOC as SearchableGroup,
|
|
66
|
-
SearchableGroup_default as default
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=SearchableGroup.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/MenuItems/SearchableGroup.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useEffect, useMemo, useState, useRef, useContext } from 'react';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { focusGroupManagerHoc } from '@elliemae/ds-shared/FocusGroup';\nimport { DSSearchBox } from '@elliemae/ds-form/SearchBox';\nimport { PropTypes, describe } from 'react-desc';\nimport { VirtualMenuList } from '../VirtualMenuList';\nimport { MenuContext } from '../MenuContext';\n\nconst SearchBoxWrapper = aggregatedClasses('div')(\n 'menu-search-group',\n 'search-wrapper',\n);\nconst NoOptionsWrapper = aggregatedClasses('div')(\n 'menu-search-group',\n 'no-options',\n);\n\nconst SearchableGroup = ({\n children,\n amountItemsInWindow = 5,\n searchTerm: searchTermProp = '',\n noOptionsText = 'No options',\n height,\n width,\n focusOnOpen = false,\n}) => {\n const searchRef = useRef(null);\n const [searchTerm, setSearchTerm] = useState(searchTermProp);\n\n useEffect(() => {\n if (searchRef.current) searchRef.current.focus();\n }, []);\n\n const { visible } = useContext(MenuContext) || {};\n\n useEffect(() => {\n if (focusOnOpen && visible) {\n setTimeout(() => {\n if (searchRef.current) searchRef.current.focus();\n }, 0);\n }\n }, [focusOnOpen, visible]);\n\n const filteredChildren = useMemo(\n () =>\n children.filter(\n (child) =>\n !searchTerm ||\n child.props.label.toLowerCase().startsWith(searchTerm.toLowerCase()),\n ),\n [children, searchTerm],\n );\n\n return (\n <>\n <SearchBoxWrapper>\n <DSSearchBox\n innerRef={searchRef}\n onSearch={({ value }) => setSearchTerm(value)}\n searchOnEnter={false}\n showIcon={false}\n value={searchTerm}\n />\n </SearchBoxWrapper>\n {!filteredChildren.length && (\n <NoOptionsWrapper>{noOptionsText}</NoOptionsWrapper>\n )}\n <VirtualMenuList\n amountItemsInWindow={amountItemsInWindow}\n height={height}\n items={filteredChildren}\n width={width}\n />\n </>\n );\n};\n\nconst props = {\n /** The amount of items that are going to be rendered in the group */\n amountItemsInWindow: PropTypes.number.description(\n 'The amount of items that are going to be rendered in the group',\n ),\n /** A search term */\n searchTerm: PropTypes.string.description('A search term'),\n /** Text to show when there's no options to show */\n noOptionsText: PropTypes.string.description(\n \"Text to show when there's no options to show\",\n ),\n /** array of children for search list */\n children: PropTypes.array.description('array of children for search list'),\n /** height for virtual list wrapper */\n height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(\n 'height for virtual list wrapper',\n ),\n /** width for virtual list wrapper */\n width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(\n 'width for virtual list wrapper',\n ),\n /** weather to focus on searchable group on open */\n focusOnOpen: PropTypes.bool.description(\n 'weather to focus on searchable group on open',\n ),\n};\n\nSearchableGroup.propTypes = props;\n\nconst DSMenuSearchableGroupWithSchema = describe(SearchableGroup);\nDSMenuSearchableGroupWithSchema.propTypes = props;\n\nconst SearchableGroupHOC = focusGroupManagerHoc(SearchableGroup);\n\nexport { DSMenuSearchableGroupWithSchema, SearchableGroupHOC as SearchableGroup };\nexport default SearchableGroupHOC;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,mBAAmB,kBAAkB,OACzC,qBACA;AAEF,MAAM,mBAAmB,kBAAkB,OACzC,qBACA;AAGF,MAAM,kBAAkB,CAAC;AAAA,EACvB;AAAA,EACA,sBAAsB;AAAA,EACtB,YAAY,iBAAiB;AAAA,EAC7B,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA,cAAc;AAAA,MACV;AACJ,QAAM,YAAY,OAAO;AACzB,QAAM,CAAC,YAAY,iBAAiB,SAAS;AAE7C,YAAU,MAAM;AACd,QAAI,UAAU;AAAS,gBAAU,QAAQ;AAAA,KACxC;AAEH,QAAM,EAAE,YAAY,WAAW,gBAAgB;AAE/C,YAAU,MAAM;AACd,QAAI,eAAe,SAAS;AAC1B,iBAAW,MAAM;AACf,YAAI,UAAU;AAAS,oBAAU,QAAQ;AAAA,SACxC;AAAA;AAAA,KAEJ,CAAC,aAAa;AAEjB,QAAM,mBAAmB,QACvB,MACE,SAAS,OACP,CAAC,UACC,CAAC,cACD,MAAM,MAAM,MAAM,cAAc,WAAW,WAAW,iBAE5D,CAAC,UAAU;AAGb,SACE,4DACE,qCAAC,kBAAD,MACE,qCAAC,aAAD;AAAA,IACE,UAAU;AAAA,IACV,UAAU,CAAC,EAAE,YAAY,cAAc;AAAA,IACvC,eAAe;AAAA,IACf,UAAU;AAAA,IACV,OAAO;AAAA,OAGV,CAAC,iBAAiB,UACjB,qCAAC,kBAAD,MAAmB,gBAErB,qCAAC,iBAAD;AAAA,IACE;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA;AAAA;AAMR,MAAM,QAAQ;AAAA,EAEZ,qBAAqB,UAAU,OAAO,YACpC;AAAA,EAGF,YAAY,UAAU,OAAO,YAAY;AAAA,EAEzC,eAAe,UAAU,OAAO,YAC9B;AAAA,EAGF,UAAU,UAAU,MAAM,YAAY;AAAA,EAEtC,QAAQ,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,SAAS,YAChE;AAAA,EAGF,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,SAAS,YAC/D;AAAA,EAGF,aAAa,UAAU,KAAK,YAC1B;AAAA;AAIJ,gBAAgB,YAAY;AAE5B,MAAM,kCAAkC,SAAS;AACjD,gCAAgC,YAAY;AAE5C,MAAM,qBAAqB,qBAAqB;AAGhD,IAAO,0BAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2, { useCallback, useMemo, useState } from "react";
|
|
3
|
-
import { PropTypes, describe } from "react-desc";
|
|
4
|
-
import { uniqBy } from "@elliemae/ds-utilities";
|
|
5
|
-
import { DSComboBox2 as DSComboBox } from "@elliemae/ds-form/ComboBox/v2/Combobox";
|
|
6
|
-
const noop = () => {
|
|
7
|
-
};
|
|
8
|
-
const SearchableList = ({
|
|
9
|
-
onSelectMenuItem = noop,
|
|
10
|
-
components = {},
|
|
11
|
-
searchTerm: searchTermProp = "",
|
|
12
|
-
items = [],
|
|
13
|
-
dropdownFilterOptions = {},
|
|
14
|
-
returnValue,
|
|
15
|
-
extraListProps = {},
|
|
16
|
-
appendTermInList = false,
|
|
17
|
-
maxOptions = 10,
|
|
18
|
-
loading = false
|
|
19
|
-
}) => {
|
|
20
|
-
const [searchTerm, setInputValue] = useState(searchTermProp);
|
|
21
|
-
const handleInputChange = useCallback((value, args) => {
|
|
22
|
-
const action = args ? args.action : null;
|
|
23
|
-
if (action === "input-blur" || action === "menu-close")
|
|
24
|
-
return;
|
|
25
|
-
setInputValue(value);
|
|
26
|
-
}, [searchTerm]);
|
|
27
|
-
const handleFilterByText = useCallback(() => {
|
|
28
|
-
if (searchTerm)
|
|
29
|
-
onSelectMenuItem(searchTerm);
|
|
30
|
-
}, [searchTerm]);
|
|
31
|
-
const handleKeyDown = useCallback((e) => {
|
|
32
|
-
if (e.key === "ArrowRight") {
|
|
33
|
-
handleFilterByText();
|
|
34
|
-
}
|
|
35
|
-
}, [searchTerm]);
|
|
36
|
-
const options = useMemo(() => searchTerm && appendTermInList ? uniqBy([
|
|
37
|
-
{
|
|
38
|
-
id: searchTerm,
|
|
39
|
-
label: searchTerm
|
|
40
|
-
}
|
|
41
|
-
].concat(items), (item) => item.label) : items, [searchTerm, appendTermInList]);
|
|
42
|
-
return /* @__PURE__ */ React2.createElement(DSComboBox, {
|
|
43
|
-
autoFocus: true,
|
|
44
|
-
components: { DropdownIndicator: null, ...components },
|
|
45
|
-
customMenuItemOptions: {
|
|
46
|
-
useTruncatedText: true
|
|
47
|
-
},
|
|
48
|
-
inlineMenu: true,
|
|
49
|
-
inputValue: searchTerm,
|
|
50
|
-
menuIsOpen: true,
|
|
51
|
-
onChange: onSelectMenuItem,
|
|
52
|
-
onFilterByInputText: handleFilterByText,
|
|
53
|
-
onInputChange: handleInputChange,
|
|
54
|
-
onKeyDown: handleKeyDown,
|
|
55
|
-
options,
|
|
56
|
-
returnValue,
|
|
57
|
-
valueProperty: "id",
|
|
58
|
-
maxOptions,
|
|
59
|
-
loading,
|
|
60
|
-
...extraListProps,
|
|
61
|
-
...dropdownFilterOptions
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
const props = {
|
|
65
|
-
onSelectMenuItem: PropTypes.func.description("callback after item gets selected"),
|
|
66
|
-
components: PropTypes.shape({}).description("Object with custom components for react-select"),
|
|
67
|
-
searchTerm: PropTypes.string.description("search term to filter for"),
|
|
68
|
-
items: PropTypes.array.description("item options"),
|
|
69
|
-
dropdownFilterOptions: PropTypes.shape({}).description("options"),
|
|
70
|
-
returnValue: PropTypes.bool.description("Whether the combo box is has value to return or not"),
|
|
71
|
-
extraListProps: PropTypes.shape({}).description("extra props to pass down to combo"),
|
|
72
|
-
appendTermInList: PropTypes.bool.description("append search term as item on the list"),
|
|
73
|
-
maxOptions: PropTypes.number.description("maxoptions for combobox"),
|
|
74
|
-
loading: PropTypes.bool.description("loading flag")
|
|
75
|
-
};
|
|
76
|
-
SearchableList.propTypes = props;
|
|
77
|
-
const DSMenuSearchableListWithSchema = describe(SearchableList);
|
|
78
|
-
DSMenuSearchableListWithSchema.propTypes = props;
|
|
79
|
-
var SearchableList_default = SearchableList;
|
|
80
|
-
export {
|
|
81
|
-
DSMenuSearchableListWithSchema,
|
|
82
|
-
SearchableList,
|
|
83
|
-
SearchableList_default as default
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=SearchableList.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/MenuItems/SearchableList.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useMemo, useState } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { uniqBy } from '@elliemae/ds-utilities';\nimport { DSComboBox2 as DSComboBox } from '@elliemae/ds-form/ComboBox/v2/Combobox';\n\nconst noop = () => {};\n\nconst SearchableList = ({\n onSelectMenuItem = noop,\n components = {},\n searchTerm: searchTermProp = '',\n items = [],\n dropdownFilterOptions = {},\n returnValue,\n extraListProps = {},\n appendTermInList = false,\n maxOptions = 10,\n loading = false,\n}) => {\n const [searchTerm, setInputValue] = useState(searchTermProp);\n\n const handleInputChange = useCallback(\n (value, args) => {\n const action = args ? args.action : null;\n if (action === 'input-blur' || action === 'menu-close') return;\n setInputValue(value);\n },\n [searchTerm],\n );\n\n const handleFilterByText = useCallback(() => {\n if (searchTerm) onSelectMenuItem(searchTerm);\n }, [searchTerm]);\n\n const handleKeyDown = useCallback(\n (e) => {\n if (e.key === 'ArrowRight') {\n handleFilterByText();\n }\n },\n [searchTerm],\n );\n\n const options = useMemo(\n () =>\n searchTerm && appendTermInList\n ? uniqBy(\n [\n {\n id: searchTerm,\n label: searchTerm,\n },\n ].concat(items),\n (item) => item.label,\n )\n : items,\n [searchTerm, appendTermInList],\n );\n\n return (\n <DSComboBox\n autoFocus\n components={{ DropdownIndicator: null, ...components }}\n customMenuItemOptions={{\n useTruncatedText: true,\n }}\n inlineMenu\n inputValue={searchTerm}\n menuIsOpen\n onChange={onSelectMenuItem}\n onFilterByInputText={handleFilterByText}\n onInputChange={handleInputChange}\n onKeyDown={handleKeyDown}\n options={options}\n returnValue={returnValue}\n valueProperty=\"id\"\n maxOptions={maxOptions}\n loading={loading}\n {...extraListProps}\n {...dropdownFilterOptions}\n />\n );\n};\n\nconst props = {\n /** callback after item gets selected */\n onSelectMenuItem: PropTypes.func.description('callback after item gets selected'),\n /** Object with custom components for react-select */\n components: PropTypes.shape({}).description('Object with custom components for react-select'),\n /** search term to filter for */\n searchTerm: PropTypes.string.description('search term to filter for'),\n /** item options */\n items: PropTypes.array.description('item options'),\n /** options */\n dropdownFilterOptions: PropTypes.shape({}).description('options'),\n /** Whether the combo box is has value to return or not */\n returnValue: PropTypes.bool.description('Whether the combo box is has value to return or not'),\n /** extra props to pass down to combo */\n extraListProps: PropTypes.shape({}).description('extra props to pass down to combo'),\n /** append search term as item on the list */\n appendTermInList: PropTypes.bool.description('append search term as item on the list'),\n /** maxoptions for combobox */\n maxOptions: PropTypes.number.description('maxoptions for combobox'),\n /** loading flag */\n loading: PropTypes.bool.description('loading flag'),\n};\n\nSearchableList.propTypes = props;\n\nconst DSMenuSearchableListWithSchema = describe(SearchableList);\n\nDSMenuSearchableListWithSchema.propTypes = props;\n\nexport { DSMenuSearchableListWithSchema, SearchableList };\nexport default SearchableList;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AAEA,MAAM,OAAO,MAAM;AAAA;AAEnB,MAAM,iBAAiB,CAAC;AAAA,EACtB,mBAAmB;AAAA,EACnB,aAAa;AAAA,EACb,YAAY,iBAAiB;AAAA,EAC7B,QAAQ;AAAA,EACR,wBAAwB;AAAA,EACxB;AAAA,EACA,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,aAAa;AAAA,EACb,UAAU;AAAA,MACN;AACJ,QAAM,CAAC,YAAY,iBAAiB,SAAS;AAE7C,QAAM,oBAAoB,YACxB,CAAC,OAAO,SAAS;AACf,UAAM,SAAS,OAAO,KAAK,SAAS;AACpC,QAAI,WAAW,gBAAgB,WAAW;AAAc;AACxD,kBAAc;AAAA,KAEhB,CAAC;AAGH,QAAM,qBAAqB,YAAY,MAAM;AAC3C,QAAI;AAAY,uBAAiB;AAAA,KAChC,CAAC;AAEJ,QAAM,gBAAgB,YACpB,CAAC,MAAM;AACL,QAAI,EAAE,QAAQ,cAAc;AAC1B;AAAA;AAAA,KAGJ,CAAC;AAGH,QAAM,UAAU,QACd,MACE,cAAc,mBACV,OACE;AAAA,IACE;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA;AAAA,IAET,OAAO,QACT,CAAC,SAAS,KAAK,SAEjB,OACN,CAAC,YAAY;AAGf,SACE,qCAAC,YAAD;AAAA,IACE,WAAS;AAAA,IACT,YAAY,EAAE,mBAAmB,SAAS;AAAA,IAC1C,uBAAuB;AAAA,MACrB,kBAAkB;AAAA;AAAA,IAEpB,YAAU;AAAA,IACV,YAAY;AAAA,IACZ,YAAU;AAAA,IACV,UAAU;AAAA,IACV,qBAAqB;AAAA,IACrB,eAAe;AAAA,IACf,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,eAAc;AAAA,IACd;AAAA,IACA;AAAA,OACI;AAAA,OACA;AAAA;AAAA;AAKV,MAAM,QAAQ;AAAA,EAEZ,kBAAkB,UAAU,KAAK,YAAY;AAAA,EAE7C,YAAY,UAAU,MAAM,IAAI,YAAY;AAAA,EAE5C,YAAY,UAAU,OAAO,YAAY;AAAA,EAEzC,OAAO,UAAU,MAAM,YAAY;AAAA,EAEnC,uBAAuB,UAAU,MAAM,IAAI,YAAY;AAAA,EAEvD,aAAa,UAAU,KAAK,YAAY;AAAA,EAExC,gBAAgB,UAAU,MAAM,IAAI,YAAY;AAAA,EAEhD,kBAAkB,UAAU,KAAK,YAAY;AAAA,EAE7C,YAAY,UAAU,OAAO,YAAY;AAAA,EAEzC,SAAS,UAAU,KAAK,YAAY;AAAA;AAGtC,eAAe,YAAY;AAE3B,MAAM,iCAAiC,SAAS;AAEhD,+BAA+B,YAAY;AAG3C,IAAO,yBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2, { useMemo } from "react";
|
|
3
|
-
import { PropTypes, describe } from "react-desc";
|
|
4
|
-
import { useCheckableGroup } from "@elliemae/ds-shared/CheckableGroup";
|
|
5
|
-
import { SearchableGroup } from "./SearchableGroup";
|
|
6
|
-
import { registerMenuItem, menuItemFactory } from "./menuItemFactory";
|
|
7
|
-
import { VirtualMenuList } from "../VirtualMenuList";
|
|
8
|
-
const noop = () => null;
|
|
9
|
-
const SelectionGroup = ({
|
|
10
|
-
multi = false,
|
|
11
|
-
searchable = false,
|
|
12
|
-
focusOnOpen = false,
|
|
13
|
-
onSelect = noop,
|
|
14
|
-
children,
|
|
15
|
-
items = void 0,
|
|
16
|
-
active = multi ? [] : "",
|
|
17
|
-
width,
|
|
18
|
-
height,
|
|
19
|
-
maxOptions = 5
|
|
20
|
-
}) => {
|
|
21
|
-
const renderedItems = useMemo(() => items && items.map((item) => {
|
|
22
|
-
const Component = menuItemFactory(multi ? "checkbox" : "radio");
|
|
23
|
-
return /* @__PURE__ */ React2.createElement(Component, {
|
|
24
|
-
...item,
|
|
25
|
-
key: item.name || item.id || item.key,
|
|
26
|
-
item,
|
|
27
|
-
name: item.id || item.name
|
|
28
|
-
});
|
|
29
|
-
}), [items]);
|
|
30
|
-
const decoratedGroupChildren = useCheckableGroup({
|
|
31
|
-
children: renderedItems || children,
|
|
32
|
-
multi,
|
|
33
|
-
active,
|
|
34
|
-
onCheck: onSelect
|
|
35
|
-
});
|
|
36
|
-
if (searchable) {
|
|
37
|
-
return /* @__PURE__ */ React2.createElement(SearchableGroup, {
|
|
38
|
-
focusOnOpen,
|
|
39
|
-
height,
|
|
40
|
-
items,
|
|
41
|
-
width
|
|
42
|
-
}, decoratedGroupChildren);
|
|
43
|
-
}
|
|
44
|
-
return /* @__PURE__ */ React2.createElement(VirtualMenuList, {
|
|
45
|
-
height,
|
|
46
|
-
items: decoratedGroupChildren,
|
|
47
|
-
width,
|
|
48
|
-
amountItemsInWindow: maxOptions
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
const props = {
|
|
52
|
-
multi: PropTypes.bool.description("toggle on multi select"),
|
|
53
|
-
searchable: PropTypes.bool.description("toggle on searchable behavior"),
|
|
54
|
-
focusOnOpen: PropTypes.bool.description("toggle to focus component on open"),
|
|
55
|
-
onSelect: PropTypes.func.description("callback that triggers when select happens"),
|
|
56
|
-
children: PropTypes.node.description(""),
|
|
57
|
-
items: PropTypes.array.description("selection group items"),
|
|
58
|
-
active: PropTypes.oneOfType([PropTypes.string, PropTypes.array]).description("array of values for multi and string for single selection"),
|
|
59
|
-
width: PropTypes.number.description("selection group width"),
|
|
60
|
-
height: PropTypes.number.description("selection group height")
|
|
61
|
-
};
|
|
62
|
-
SelectionGroup.propTypes = props;
|
|
63
|
-
registerMenuItem("selectiongroup", SelectionGroup);
|
|
64
|
-
registerMenuItem("SelectionGroup", SelectionGroup);
|
|
65
|
-
const DSMenuSelectionGroupWithSchema = describe(SelectionGroup);
|
|
66
|
-
DSMenuSelectionGroupWithSchema.propTypes = props;
|
|
67
|
-
var SelectionGroup_default = SelectionGroup;
|
|
68
|
-
export {
|
|
69
|
-
DSMenuSelectionGroupWithSchema,
|
|
70
|
-
SelectionGroup,
|
|
71
|
-
SelectionGroup_default as default
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=SelectionGroup.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/MenuItems/SelectionGroup.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useMemo } from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { useCheckableGroup } from '@elliemae/ds-shared/CheckableGroup';\nimport { SearchableGroup } from './SearchableGroup';\nimport { registerMenuItem, menuItemFactory } from './menuItemFactory';\nimport { VirtualMenuList } from '../VirtualMenuList';\n\nconst noop = () => null;\n\nconst SelectionGroup = ({\n multi = false,\n searchable = false,\n focusOnOpen = false,\n onSelect = noop,\n children,\n items = undefined,\n active = multi ? [] : '',\n width,\n height,\n maxOptions = 5,\n}) => {\n const renderedItems = useMemo(\n () =>\n items &&\n items.map((item) => {\n const Component = menuItemFactory(multi ? 'checkbox' : 'radio');\n return <Component {...item} key={item.name || item.id || item.key} item={item} name={item.id || item.name} />;\n }),\n [items],\n );\n const decoratedGroupChildren = useCheckableGroup({\n children: renderedItems || children,\n multi,\n active,\n onCheck: onSelect,\n });\n\n if (searchable) {\n return (\n <SearchableGroup focusOnOpen={focusOnOpen} height={height} items={items} width={width}>\n {decoratedGroupChildren}\n </SearchableGroup>\n );\n }\n return (\n <VirtualMenuList height={height} items={decoratedGroupChildren} width={width} amountItemsInWindow={maxOptions} />\n );\n};\n\nconst props = {\n /** toggle on multi select */\n multi: PropTypes.bool.description('toggle on multi select'),\n /** toggle on searchable behavior */\n searchable: PropTypes.bool.description('toggle on searchable behavior'),\n /** toggle to focus component on open */\n focusOnOpen: PropTypes.bool.description('toggle to focus component on open'),\n /** callback that triggers when select happens */\n onSelect: PropTypes.func.description('callback that triggers when select happens'),\n children: PropTypes.node.description(''),\n /** selection group items */\n items: PropTypes.array.description('selection group items'),\n /** array of values for multi and string for single selection */\n active: PropTypes.oneOfType([PropTypes.string, PropTypes.array]).description(\n 'array of values for multi and string for single selection',\n ),\n /** selection group width */\n width: PropTypes.number.description('selection group width'),\n /** selection group height */\n height: PropTypes.number.description('selection group height'),\n};\n\nSelectionGroup.propTypes = props;\nregisterMenuItem('selectiongroup', SelectionGroup);\nregisterMenuItem('SelectionGroup', SelectionGroup);\n\nconst DSMenuSelectionGroupWithSchema = describe(SelectionGroup);\nDSMenuSelectionGroupWithSchema.propTypes = props;\n\nexport { DSMenuSelectionGroupWithSchema, SelectionGroup };\nexport default SelectionGroup;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,OAAO,MAAM;AAEnB,MAAM,iBAAiB,CAAC;AAAA,EACtB,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,cAAc;AAAA,EACd,WAAW;AAAA,EACX;AAAA,EACA,QAAQ;AAAA,EACR,SAAS,QAAQ,KAAK;AAAA,EACtB;AAAA,EACA;AAAA,EACA,aAAa;AAAA,MACT;AACJ,QAAM,gBAAgB,QACpB,MACE,SACA,MAAM,IAAI,CAAC,SAAS;AAClB,UAAM,YAAY,gBAAgB,QAAQ,aAAa;AACvD,WAAO,qCAAC,WAAD;AAAA,SAAe;AAAA,MAAM,KAAK,KAAK,QAAQ,KAAK,MAAM,KAAK;AAAA,MAAK;AAAA,MAAY,MAAM,KAAK,MAAM,KAAK;AAAA;AAAA,MAEzG,CAAC;AAEH,QAAM,yBAAyB,kBAAkB;AAAA,IAC/C,UAAU,iBAAiB;AAAA,IAC3B;AAAA,IACA;AAAA,IACA,SAAS;AAAA;AAGX,MAAI,YAAY;AACd,WACE,qCAAC,iBAAD;AAAA,MAAiB;AAAA,MAA0B;AAAA,MAAgB;AAAA,MAAc;AAAA,OACtE;AAAA;AAIP,SACE,qCAAC,iBAAD;AAAA,IAAiB;AAAA,IAAgB,OAAO;AAAA,IAAwB;AAAA,IAAc,qBAAqB;AAAA;AAAA;AAIvG,MAAM,QAAQ;AAAA,EAEZ,OAAO,UAAU,KAAK,YAAY;AAAA,EAElC,YAAY,UAAU,KAAK,YAAY;AAAA,EAEvC,aAAa,UAAU,KAAK,YAAY;AAAA,EAExC,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,UAAU,UAAU,KAAK,YAAY;AAAA,EAErC,OAAO,UAAU,MAAM,YAAY;AAAA,EAEnC,QAAQ,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,QAAQ,YAC/D;AAAA,EAGF,OAAO,UAAU,OAAO,YAAY;AAAA,EAEpC,QAAQ,UAAU,OAAO,YAAY;AAAA;AAGvC,eAAe,YAAY;AAC3B,iBAAiB,kBAAkB;AACnC,iBAAiB,kBAAkB;AAEnC,MAAM,iCAAiC,SAAS;AAChD,+BAA+B,YAAY;AAG3C,IAAO,yBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|