@elliemae/ds-menu 2.2.0-next.4 → 2.3.0-alpha.2
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 +137 -181
- package/cjs/Menu.js.map +7 -0
- package/cjs/MenuCombobox.js +67 -53
- package/cjs/MenuCombobox.js.map +7 -0
- package/cjs/MenuContext.js +38 -11
- package/cjs/MenuContext.js.map +7 -0
- package/cjs/MenuExports.js +28 -0
- package/cjs/MenuExports.js.map +7 -0
- package/cjs/MenuItems/CheckboxGroup.js +49 -42
- package/cjs/MenuItems/CheckboxGroup.js.map +7 -0
- package/cjs/MenuItems/MenuItem.js +116 -163
- package/cjs/MenuItems/MenuItem.js.map +7 -0
- package/cjs/MenuItems/MenuItemCheckable.js +77 -108
- package/cjs/MenuItems/MenuItemCheckable.js.map +7 -0
- package/cjs/MenuItems/MenuItemCheckbox.js +47 -41
- package/cjs/MenuItems/MenuItemCheckbox.js.map +7 -0
- package/cjs/MenuItems/MenuItemRadio.js +50 -38
- package/cjs/MenuItems/MenuItemRadio.js.map +7 -0
- package/cjs/MenuItems/RadioGroup.js +48 -39
- package/cjs/MenuItems/RadioGroup.js.map +7 -0
- package/cjs/MenuItems/SearchableGroup.js +88 -92
- package/cjs/MenuItems/SearchableGroup.js.map +7 -0
- package/cjs/MenuItems/SearchableList.js +92 -95
- package/cjs/MenuItems/SearchableList.js.map +7 -0
- package/cjs/MenuItems/SelectionGroup.js +85 -90
- package/cjs/MenuItems/SelectionGroup.js.map +7 -0
- package/cjs/MenuItems/Separator.js +55 -40
- package/cjs/MenuItems/Separator.js.map +7 -0
- package/cjs/MenuItems/SubMenu.js +143 -160
- package/cjs/MenuItems/SubMenu.js.map +7 -0
- package/cjs/MenuItems/menuItemFactory.js +38 -68
- package/cjs/MenuItems/menuItemFactory.js.map +7 -0
- package/cjs/MenuItems/renderMenuItems.js +53 -0
- package/cjs/MenuItems/renderMenuItems.js.map +7 -0
- package/cjs/VirtualMenuList.js +69 -39
- package/cjs/VirtualMenuList.js.map +7 -0
- package/cjs/index.js +63 -36
- package/cjs/index.js.map +7 -0
- package/cjs/utils/useHeightByAmountOfItems.js +43 -14
- package/cjs/utils/useHeightByAmountOfItems.js.map +7 -0
- package/esm/Menu.js +91 -149
- package/esm/Menu.js.map +7 -0
- package/esm/MenuCombobox.js +38 -45
- package/esm/MenuCombobox.js.map +7 -0
- package/esm/MenuContext.js +9 -5
- package/esm/MenuContext.js.map +7 -0
- package/esm/MenuExports.js +3 -0
- package/esm/MenuExports.js.map +7 -0
- package/esm/MenuItems/CheckboxGroup.js +19 -31
- package/esm/MenuItems/CheckboxGroup.js.map +7 -0
- package/esm/MenuItems/MenuItem.js +84 -148
- package/esm/MenuItems/MenuItem.js.map +7 -0
- package/esm/MenuItems/MenuItemCheckable.js +47 -96
- package/esm/MenuItems/MenuItemCheckable.js.map +7 -0
- package/esm/MenuItems/MenuItemCheckbox.js +18 -33
- package/esm/MenuItems/MenuItemCheckbox.js.map +7 -0
- package/esm/MenuItems/MenuItemRadio.js +20 -28
- package/esm/MenuItems/MenuItemRadio.js.map +7 -0
- package/esm/MenuItems/RadioGroup.js +18 -28
- package/esm/MenuItems/RadioGroup.js.map +7 -0
- package/esm/MenuItems/SearchableGroup.js +53 -76
- package/esm/MenuItems/SearchableGroup.js.map +7 -0
- package/esm/MenuItems/SearchableList.js +59 -82
- package/esm/MenuItems/SearchableList.js.map +7 -0
- package/esm/MenuItems/SelectionGroup.js +54 -78
- package/esm/MenuItems/SelectionGroup.js.map +7 -0
- package/esm/MenuItems/Separator.js +26 -29
- package/esm/MenuItems/Separator.js.map +7 -0
- package/esm/MenuItems/SubMenu.js +107 -140
- package/esm/MenuItems/SubMenu.js.map +7 -0
- package/esm/MenuItems/menuItemFactory.js +10 -60
- package/esm/MenuItems/menuItemFactory.js.map +7 -0
- package/esm/MenuItems/renderMenuItems.js +24 -0
- package/esm/MenuItems/renderMenuItems.js.map +7 -0
- package/esm/VirtualMenuList.js +39 -32
- package/esm/VirtualMenuList.js.map +7 -0
- package/esm/index.js +34 -13
- package/esm/index.js.map +7 -0
- package/esm/utils/useHeightByAmountOfItems.js +13 -11
- package/esm/utils/useHeightByAmountOfItems.js.map +7 -0
- package/package.json +19 -11
- package/types/Menu.d.ts +5 -21
- package/types/MenuContext.d.ts +3 -2
- package/types/MenuExports.d.ts +1 -0
- package/types/MenuItems/CheckboxGroup.d.ts +6 -6
- package/types/MenuItems/MenuItem.d.ts +6 -6
- package/types/MenuItems/MenuItemCheckable.d.ts +17 -25
- package/types/MenuItems/MenuItemCheckbox.d.ts +3 -2
- package/types/MenuItems/MenuItemRadio.d.ts +6 -15
- package/types/MenuItems/RadioGroup.d.ts +6 -6
- package/types/MenuItems/SearchableGroup.d.ts +4 -12
- package/types/MenuItems/SearchableList.d.ts +17 -28
- package/types/MenuItems/SelectionGroup.d.ts +17 -28
- package/types/MenuItems/Separator.d.ts +3 -5
- package/types/MenuItems/SubMenu.d.ts +19 -32
- package/types/MenuItems/menuItemFactory.d.ts +2 -3
- package/types/MenuItems/renderMenuItems.d.ts +1 -0
- package/types/VirtualMenuList.d.ts +3 -1
- package/types/index.d.ts +3 -2
- package/types/utils/useHeightByAmountOfItems.d.ts +3 -1
|
@@ -1,101 +1,97 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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 SearchableGroup_exports = {};
|
|
29
|
+
__export(SearchableGroup_exports, {
|
|
30
|
+
DSMenuSearchableGroupWithSchema: () => DSMenuSearchableGroupWithSchema,
|
|
31
|
+
SearchableGroup: () => SearchableGroupHOC,
|
|
32
|
+
default: () => SearchableGroup_default
|
|
33
|
+
});
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_ds_classnames = require("@elliemae/ds-classnames");
|
|
37
|
+
var import_FocusGroup = require("@elliemae/ds-shared/FocusGroup");
|
|
38
|
+
var import_ds_form = require("@elliemae/ds-form");
|
|
39
|
+
var import_react_desc = require("react-desc");
|
|
40
|
+
var import_VirtualMenuList = require("../VirtualMenuList");
|
|
41
|
+
var import_MenuContext = require("../MenuContext");
|
|
42
|
+
const SearchBoxWrapper = (0, import_ds_classnames.aggregatedClasses)("div")("menu-search-group", "search-wrapper");
|
|
43
|
+
const NoOptionsWrapper = (0, import_ds_classnames.aggregatedClasses)("div")("menu-search-group", "no-options");
|
|
44
|
+
const SearchableGroup = ({
|
|
45
|
+
children,
|
|
46
|
+
amountItemsInWindow = 5,
|
|
47
|
+
searchTerm: searchTermProp = "",
|
|
48
|
+
noOptionsText = "No options",
|
|
49
|
+
height,
|
|
50
|
+
width,
|
|
51
|
+
focusOnOpen = false
|
|
52
|
+
}) => {
|
|
53
|
+
const searchRef = (0, import_react.useRef)(null);
|
|
54
|
+
const [searchTerm, setSearchTerm] = (0, import_react.useState)(searchTermProp);
|
|
55
|
+
(0, import_react.useEffect)(() => {
|
|
56
|
+
if (searchRef.current)
|
|
57
|
+
searchRef.current.focus();
|
|
41
58
|
}, []);
|
|
42
|
-
const {
|
|
43
|
-
|
|
44
|
-
} = React.useContext(MenuContext) || {};
|
|
45
|
-
React.useEffect(() => {
|
|
59
|
+
const { visible } = (0, import_react.useContext)(import_MenuContext.MenuContext) || {};
|
|
60
|
+
(0, import_react.useEffect)(() => {
|
|
46
61
|
if (focusOnOpen && visible) {
|
|
47
62
|
setTimeout(() => {
|
|
48
|
-
if (searchRef.current)
|
|
63
|
+
if (searchRef.current)
|
|
64
|
+
searchRef.current.focus();
|
|
49
65
|
}, 0);
|
|
50
66
|
}
|
|
51
67
|
}, [focusOnOpen, visible]);
|
|
52
|
-
const filteredChildren =
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
amountItemsInWindow: amountItemsInWindow,
|
|
67
|
-
height: height,
|
|
68
|
-
items: filteredChildren,
|
|
69
|
-
width: width
|
|
70
|
-
})]
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
68
|
+
const filteredChildren = (0, import_react.useMemo)(() => children.filter((child) => !searchTerm || child.props.label.toLowerCase().startsWith(searchTerm.toLowerCase())), [children, searchTerm]);
|
|
69
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(SearchBoxWrapper, null, /* @__PURE__ */ import_react.default.createElement(import_ds_form.DSSearchBox, {
|
|
70
|
+
innerRef: searchRef,
|
|
71
|
+
onSearch: ({ value }) => setSearchTerm(value),
|
|
72
|
+
searchOnEnter: false,
|
|
73
|
+
showIcon: false,
|
|
74
|
+
value: searchTerm
|
|
75
|
+
})), !filteredChildren.length && /* @__PURE__ */ import_react.default.createElement(NoOptionsWrapper, null, noOptionsText), /* @__PURE__ */ import_react.default.createElement(import_VirtualMenuList.VirtualMenuList, {
|
|
76
|
+
amountItemsInWindow,
|
|
77
|
+
height,
|
|
78
|
+
items: filteredChildren,
|
|
79
|
+
width
|
|
80
|
+
}));
|
|
81
|
+
};
|
|
74
82
|
const props = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
noOptionsText: reactDesc.PropTypes.string.description("Text to show when there's no options to show"),
|
|
83
|
-
|
|
84
|
-
/** array of children for search list */
|
|
85
|
-
children: reactDesc.PropTypes.array.description('array of children for search list'),
|
|
86
|
-
|
|
87
|
-
/** height for virtual list wrapper */
|
|
88
|
-
height: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.number]).description('height for virtual list wrapper'),
|
|
89
|
-
|
|
90
|
-
/** width for virtual list wrapper */
|
|
91
|
-
width: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.number]).description('width for virtual list wrapper'),
|
|
92
|
-
|
|
93
|
-
/** weather to focus on searchable group on open */
|
|
94
|
-
focusOnOpen: reactDesc.PropTypes.bool.description('weather to focus on searchable group on open')
|
|
83
|
+
amountItemsInWindow: import_react_desc.PropTypes.number.description("The amount of items that are going to be rendered in the group"),
|
|
84
|
+
searchTerm: import_react_desc.PropTypes.string.description("A search term"),
|
|
85
|
+
noOptionsText: import_react_desc.PropTypes.string.description("Text to show when there's no options to show"),
|
|
86
|
+
children: import_react_desc.PropTypes.array.description("array of children for search list"),
|
|
87
|
+
height: import_react_desc.PropTypes.oneOfType([import_react_desc.PropTypes.string, import_react_desc.PropTypes.number]).description("height for virtual list wrapper"),
|
|
88
|
+
width: import_react_desc.PropTypes.oneOfType([import_react_desc.PropTypes.string, import_react_desc.PropTypes.number]).description("width for virtual list wrapper"),
|
|
89
|
+
focusOnOpen: import_react_desc.PropTypes.bool.description("weather to focus on searchable group on open")
|
|
95
90
|
};
|
|
96
|
-
|
|
91
|
+
SearchableGroup.propTypes = props;
|
|
92
|
+
const DSMenuSearchableGroupWithSchema = (0, import_react_desc.describe)(SearchableGroup);
|
|
97
93
|
DSMenuSearchableGroupWithSchema.propTypes = props;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
exports
|
|
101
|
-
|
|
94
|
+
const SearchableGroupHOC = (0, import_FocusGroup.focusGroupManagerHoc)(SearchableGroup);
|
|
95
|
+
var SearchableGroup_default = SearchableGroupHOC;
|
|
96
|
+
module.exports = __toCommonJS(SearchableGroup_exports);
|
|
97
|
+
//# sourceMappingURL=SearchableGroup.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/MenuItems/SearchableGroup.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["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';\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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwE;AACxE,2BAAkC;AAClC,wBAAqC;AACrC,qBAA4B;AAC5B,wBAAoC;AACpC,6BAAgC;AAChC,yBAA4B;AAE5B,MAAM,mBAAmB,4CAAkB,OACzC,qBACA;AAEF,MAAM,mBAAmB,4CAAkB,OACzC,qBACA;AAGF,MAAM,kBAAkB,CAAC;AAAA,EACvB;AAAA,EACA,sBAAsB;AAAA,EACtB,YAAY,iBAAiB;AAAA,EAC7B,gBAAgB;AAAA,EAChB;AAAA,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AqB;AAGhD,IAAO,0BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,66 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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 SearchableList_exports = {};
|
|
29
|
+
__export(SearchableList_exports, {
|
|
30
|
+
DSMenuSearchableListWithSchema: () => DSMenuSearchableListWithSchema,
|
|
31
|
+
SearchableList: () => SearchableList,
|
|
32
|
+
default: () => SearchableList_default
|
|
33
|
+
});
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_react_desc = require("react-desc");
|
|
37
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
38
|
+
var import_Combobox = require("@elliemae/ds-form/ComboBox/v2/Combobox");
|
|
39
|
+
const noop = () => {
|
|
40
|
+
};
|
|
41
|
+
const SearchableList = ({
|
|
42
|
+
onSelectMenuItem = noop,
|
|
43
|
+
components = {},
|
|
44
|
+
searchTerm: searchTermProp = "",
|
|
45
|
+
items = [],
|
|
46
|
+
dropdownFilterOptions = {},
|
|
47
|
+
returnValue,
|
|
48
|
+
extraListProps = {},
|
|
49
|
+
appendTermInList = false,
|
|
50
|
+
maxOptions = 10,
|
|
51
|
+
loading = false
|
|
52
|
+
}) => {
|
|
53
|
+
const [searchTerm, setInputValue] = (0, import_react.useState)(searchTermProp);
|
|
54
|
+
const handleInputChange = (0, import_react.useCallback)((value, args) => {
|
|
43
55
|
const action = args ? args.action : null;
|
|
44
|
-
if (action ===
|
|
56
|
+
if (action === "input-blur" || action === "menu-close")
|
|
57
|
+
return;
|
|
45
58
|
setInputValue(value);
|
|
46
59
|
}, [searchTerm]);
|
|
47
|
-
const handleFilterByText =
|
|
48
|
-
if (searchTerm)
|
|
60
|
+
const handleFilterByText = (0, import_react.useCallback)(() => {
|
|
61
|
+
if (searchTerm)
|
|
62
|
+
onSelectMenuItem(searchTerm);
|
|
49
63
|
}, [searchTerm]);
|
|
50
|
-
const handleKeyDown =
|
|
51
|
-
if (e.key ===
|
|
64
|
+
const handleKeyDown = (0, import_react.useCallback)((e) => {
|
|
65
|
+
if (e.key === "ArrowRight") {
|
|
52
66
|
handleFilterByText();
|
|
53
67
|
}
|
|
54
68
|
}, [searchTerm]);
|
|
55
|
-
const options =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
69
|
+
const options = (0, import_react.useMemo)(() => searchTerm && appendTermInList ? (0, import_ds_utilities.uniqBy)([
|
|
70
|
+
{
|
|
71
|
+
id: searchTerm,
|
|
72
|
+
label: searchTerm
|
|
73
|
+
}
|
|
74
|
+
].concat(items), (item) => item.label) : items, [searchTerm, appendTermInList]);
|
|
75
|
+
return /* @__PURE__ */ import_react.default.createElement(import_Combobox.DSComboBox2, {
|
|
60
76
|
autoFocus: true,
|
|
61
|
-
components:
|
|
62
|
-
DropdownIndicator: null
|
|
63
|
-
}, components),
|
|
77
|
+
components: { DropdownIndicator: null, ...components },
|
|
64
78
|
customMenuItemOptions: {
|
|
65
79
|
useTruncatedText: true
|
|
66
80
|
},
|
|
@@ -71,47 +85,30 @@ function SearchableList(_ref) {
|
|
|
71
85
|
onFilterByInputText: handleFilterByText,
|
|
72
86
|
onInputChange: handleInputChange,
|
|
73
87
|
onKeyDown: handleKeyDown,
|
|
74
|
-
options
|
|
75
|
-
returnValue
|
|
88
|
+
options,
|
|
89
|
+
returnValue,
|
|
76
90
|
valueProperty: "id",
|
|
77
|
-
maxOptions
|
|
78
|
-
loading
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
maxOptions,
|
|
92
|
+
loading,
|
|
93
|
+
...extraListProps,
|
|
94
|
+
...dropdownFilterOptions
|
|
95
|
+
});
|
|
96
|
+
};
|
|
82
97
|
const props = {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
items: reactDesc.PropTypes.array.description('item options'),
|
|
94
|
-
|
|
95
|
-
/** options */
|
|
96
|
-
dropdownFilterOptions: reactDesc.PropTypes.shape({}).description('options'),
|
|
97
|
-
|
|
98
|
-
/** Whether the combo box is has value to return or not */
|
|
99
|
-
returnValue: reactDesc.PropTypes.bool.description('Whether the combo box is has value to return or not'),
|
|
100
|
-
|
|
101
|
-
/** extra props to pass down to combo */
|
|
102
|
-
extraListProps: reactDesc.PropTypes.shape({}).description('extra props to pass down to combo'),
|
|
103
|
-
|
|
104
|
-
/** append search term as item on the list */
|
|
105
|
-
appendTermInList: reactDesc.PropTypes.bool.description('append search term as item on the list'),
|
|
106
|
-
|
|
107
|
-
/** maxoptions for combobox */
|
|
108
|
-
maxOptions: reactDesc.PropTypes.number.description('maxoptions for combobox'),
|
|
109
|
-
|
|
110
|
-
/** loading flag */
|
|
111
|
-
loading: reactDesc.PropTypes.bool.description('loading flag')
|
|
98
|
+
onSelectMenuItem: import_react_desc.PropTypes.func.description("callback after item gets selected"),
|
|
99
|
+
components: import_react_desc.PropTypes.shape({}).description("Object with custom components for react-select"),
|
|
100
|
+
searchTerm: import_react_desc.PropTypes.string.description("search term to filter for"),
|
|
101
|
+
items: import_react_desc.PropTypes.array.description("item options"),
|
|
102
|
+
dropdownFilterOptions: import_react_desc.PropTypes.shape({}).description("options"),
|
|
103
|
+
returnValue: import_react_desc.PropTypes.bool.description("Whether the combo box is has value to return or not"),
|
|
104
|
+
extraListProps: import_react_desc.PropTypes.shape({}).description("extra props to pass down to combo"),
|
|
105
|
+
appendTermInList: import_react_desc.PropTypes.bool.description("append search term as item on the list"),
|
|
106
|
+
maxOptions: import_react_desc.PropTypes.number.description("maxoptions for combobox"),
|
|
107
|
+
loading: import_react_desc.PropTypes.bool.description("loading flag")
|
|
112
108
|
};
|
|
113
|
-
|
|
109
|
+
SearchableList.propTypes = props;
|
|
110
|
+
const DSMenuSearchableListWithSchema = (0, import_react_desc.describe)(SearchableList);
|
|
114
111
|
DSMenuSearchableListWithSchema.propTypes = props;
|
|
115
|
-
|
|
116
|
-
exports
|
|
117
|
-
|
|
112
|
+
var SearchableList_default = SearchableList;
|
|
113
|
+
module.exports = __toCommonJS(SearchableList_exports);
|
|
114
|
+
//# sourceMappingURL=SearchableList.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/MenuItems/SearchableList.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;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