@elliemae/ds-menu 2.2.0-alpha.3 → 3.0.0-next.0

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.
Files changed (100) hide show
  1. package/cjs/Menu.js +181 -137
  2. package/cjs/MenuCombobox.js +53 -67
  3. package/cjs/MenuContext.js +11 -38
  4. package/cjs/MenuItems/CheckboxGroup.js +42 -49
  5. package/cjs/MenuItems/MenuItem.js +163 -116
  6. package/cjs/MenuItems/MenuItemCheckable.js +108 -77
  7. package/cjs/MenuItems/MenuItemCheckbox.js +41 -47
  8. package/cjs/MenuItems/MenuItemRadio.js +38 -50
  9. package/cjs/MenuItems/RadioGroup.js +39 -48
  10. package/cjs/MenuItems/SearchableGroup.js +92 -88
  11. package/cjs/MenuItems/SearchableList.js +95 -92
  12. package/cjs/MenuItems/SelectionGroup.js +90 -85
  13. package/cjs/MenuItems/Separator.js +40 -55
  14. package/cjs/MenuItems/SubMenu.js +160 -143
  15. package/cjs/MenuItems/menuItemFactory.js +68 -38
  16. package/cjs/VirtualMenuList.js +39 -69
  17. package/cjs/index.js +36 -63
  18. package/cjs/utils/useHeightByAmountOfItems.js +14 -43
  19. package/esm/Menu.js +149 -91
  20. package/esm/MenuCombobox.js +45 -38
  21. package/esm/MenuContext.js +5 -9
  22. package/esm/MenuItems/CheckboxGroup.js +31 -19
  23. package/esm/MenuItems/MenuItem.js +148 -84
  24. package/esm/MenuItems/MenuItemCheckable.js +96 -47
  25. package/esm/MenuItems/MenuItemCheckbox.js +33 -18
  26. package/esm/MenuItems/MenuItemRadio.js +28 -20
  27. package/esm/MenuItems/RadioGroup.js +28 -18
  28. package/esm/MenuItems/SearchableGroup.js +76 -53
  29. package/esm/MenuItems/SearchableList.js +82 -59
  30. package/esm/MenuItems/SelectionGroup.js +78 -54
  31. package/esm/MenuItems/Separator.js +29 -26
  32. package/esm/MenuItems/SubMenu.js +140 -107
  33. package/esm/MenuItems/menuItemFactory.js +60 -10
  34. package/esm/VirtualMenuList.js +32 -39
  35. package/esm/index.js +13 -34
  36. package/esm/utils/useHeightByAmountOfItems.js +11 -13
  37. package/package.json +11 -19
  38. package/types/Menu.d.ts +2 -3
  39. package/types/MenuContext.d.ts +2 -3
  40. package/types/MenuItems/CheckboxGroup.d.ts +5 -5
  41. package/types/MenuItems/MenuItem.d.ts +5 -5
  42. package/types/MenuItems/MenuItemCheckable.d.ts +15 -15
  43. package/types/MenuItems/MenuItemCheckbox.d.ts +2 -3
  44. package/types/MenuItems/MenuItemRadio.d.ts +5 -5
  45. package/types/MenuItems/RadioGroup.d.ts +5 -5
  46. package/types/MenuItems/SearchableGroup.d.ts +3 -3
  47. package/types/MenuItems/SearchableList.d.ts +16 -16
  48. package/types/MenuItems/SelectionGroup.d.ts +16 -16
  49. package/types/MenuItems/Separator.d.ts +1 -2
  50. package/types/MenuItems/SubMenu.d.ts +18 -18
  51. package/types/MenuItems/menuItemFactory.d.ts +3 -2
  52. package/types/VirtualMenuList.d.ts +1 -3
  53. package/types/index.d.ts +2 -3
  54. package/types/utils/useHeightByAmountOfItems.d.ts +1 -3
  55. package/cjs/Menu.js.map +0 -7
  56. package/cjs/MenuCombobox.js.map +0 -7
  57. package/cjs/MenuContext.js.map +0 -7
  58. package/cjs/MenuExports.js +0 -28
  59. package/cjs/MenuExports.js.map +0 -7
  60. package/cjs/MenuItems/CheckboxGroup.js.map +0 -7
  61. package/cjs/MenuItems/MenuItem.js.map +0 -7
  62. package/cjs/MenuItems/MenuItemCheckable.js.map +0 -7
  63. package/cjs/MenuItems/MenuItemCheckbox.js.map +0 -7
  64. package/cjs/MenuItems/MenuItemRadio.js.map +0 -7
  65. package/cjs/MenuItems/RadioGroup.js.map +0 -7
  66. package/cjs/MenuItems/SearchableGroup.js.map +0 -7
  67. package/cjs/MenuItems/SearchableList.js.map +0 -7
  68. package/cjs/MenuItems/SelectionGroup.js.map +0 -7
  69. package/cjs/MenuItems/Separator.js.map +0 -7
  70. package/cjs/MenuItems/SubMenu.js.map +0 -7
  71. package/cjs/MenuItems/menuItemFactory.js.map +0 -7
  72. package/cjs/MenuItems/renderMenuItems.js +0 -53
  73. package/cjs/MenuItems/renderMenuItems.js.map +0 -7
  74. package/cjs/VirtualMenuList.js.map +0 -7
  75. package/cjs/index.js.map +0 -7
  76. package/cjs/utils/useHeightByAmountOfItems.js.map +0 -7
  77. package/esm/Menu.js.map +0 -7
  78. package/esm/MenuCombobox.js.map +0 -7
  79. package/esm/MenuContext.js.map +0 -7
  80. package/esm/MenuExports.js +0 -3
  81. package/esm/MenuExports.js.map +0 -7
  82. package/esm/MenuItems/CheckboxGroup.js.map +0 -7
  83. package/esm/MenuItems/MenuItem.js.map +0 -7
  84. package/esm/MenuItems/MenuItemCheckable.js.map +0 -7
  85. package/esm/MenuItems/MenuItemCheckbox.js.map +0 -7
  86. package/esm/MenuItems/MenuItemRadio.js.map +0 -7
  87. package/esm/MenuItems/RadioGroup.js.map +0 -7
  88. package/esm/MenuItems/SearchableGroup.js.map +0 -7
  89. package/esm/MenuItems/SearchableList.js.map +0 -7
  90. package/esm/MenuItems/SelectionGroup.js.map +0 -7
  91. package/esm/MenuItems/Separator.js.map +0 -7
  92. package/esm/MenuItems/SubMenu.js.map +0 -7
  93. package/esm/MenuItems/menuItemFactory.js.map +0 -7
  94. package/esm/MenuItems/renderMenuItems.js +0 -24
  95. package/esm/MenuItems/renderMenuItems.js.map +0 -7
  96. package/esm/VirtualMenuList.js.map +0 -7
  97. package/esm/index.js.map +0 -7
  98. package/esm/utils/useHeightByAmountOfItems.js.map +0 -7
  99. package/types/MenuExports.d.ts +0 -1
  100. package/types/MenuItems/renderMenuItems.d.ts +0 -1
@@ -1,68 +1,91 @@
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";
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
- }) => {
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'core-js/modules/web.dom-collections.iterator.js';
3
+ import 'core-js/modules/esnext.async-iterator.filter.js';
4
+ import 'core-js/modules/esnext.iterator.constructor.js';
5
+ import 'core-js/modules/esnext.iterator.filter.js';
6
+ import { useRef, useState, useEffect, useContext, useMemo } from 'react';
7
+ import { aggregatedClasses } from '@elliemae/ds-classnames';
8
+ import { focusGroupManagerHoc } from '@elliemae/ds-shared/FocusGroup';
9
+ import DSSearchBox from '@elliemae/ds-form/SearchBox';
10
+ import { PropTypes, describe } from 'react-desc';
11
+ import VirtualMenuList from '../VirtualMenuList.js';
12
+ import MenuContext from '../MenuContext.js';
13
+ import { jsxs, Fragment } from 'react/jsx-runtime';
14
+
15
+ const SearchBoxWrapper = aggregatedClasses('div')('menu-search-group', 'search-wrapper');
16
+ const NoOptionsWrapper = aggregatedClasses('div')('menu-search-group', 'no-options');
17
+
18
+ function SearchableGroup(_ref) {
19
+ let {
20
+ children,
21
+ amountItemsInWindow = 5,
22
+ searchTerm: searchTermProp = '',
23
+ noOptionsText = 'No options',
24
+ height,
25
+ width,
26
+ focusOnOpen = false
27
+ } = _ref;
20
28
  const searchRef = useRef(null);
21
29
  const [searchTerm, setSearchTerm] = useState(searchTermProp);
22
30
  useEffect(() => {
23
- if (searchRef.current)
24
- searchRef.current.focus();
31
+ if (searchRef.current) searchRef.current.focus();
25
32
  }, []);
26
- const { visible } = useContext(MenuContext) || {};
33
+ const {
34
+ visible
35
+ } = useContext(MenuContext) || {};
27
36
  useEffect(() => {
28
37
  if (focusOnOpen && visible) {
29
38
  setTimeout(() => {
30
- if (searchRef.current)
31
- searchRef.current.focus();
39
+ if (searchRef.current) searchRef.current.focus();
32
40
  }, 0);
33
41
  }
34
42
  }, [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
- };
43
+ const filteredChildren = useMemo(() => children.filter(child => !searchTerm || child.props.label.toLowerCase().startsWith(searchTerm.toLowerCase())), [children, searchTerm]);
44
+ return /*#__PURE__*/jsxs(Fragment, {
45
+ children: [/*#__PURE__*/_jsx(SearchBoxWrapper, {}, void 0, /*#__PURE__*/_jsx(DSSearchBox, {
46
+ innerRef: searchRef,
47
+ onSearch: _ref2 => {
48
+ let {
49
+ value
50
+ } = _ref2;
51
+ return setSearchTerm(value);
52
+ },
53
+ searchOnEnter: false,
54
+ showIcon: false,
55
+ value: searchTerm
56
+ })), !filteredChildren.length && /*#__PURE__*/_jsx(NoOptionsWrapper, {}, void 0, noOptionsText), /*#__PURE__*/_jsx(VirtualMenuList, {
57
+ amountItemsInWindow: amountItemsInWindow,
58
+ height: height,
59
+ items: filteredChildren,
60
+ width: width
61
+ })]
62
+ });
63
+ }
64
+
49
65
  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"),
66
+ /** The amount of items that are going to be rendered in the group */
67
+ amountItemsInWindow: PropTypes.number.description('The amount of items that are going to be rendered in the group'),
68
+
69
+ /** A search term */
70
+ searchTerm: PropTypes.string.description('A search term'),
71
+
72
+ /** Text to show when there's no options to show */
52
73
  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")
74
+
75
+ /** array of children for search list */
76
+ children: PropTypes.array.description('array of children for search list'),
77
+
78
+ /** height for virtual list wrapper */
79
+ height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('height for virtual list wrapper'),
80
+
81
+ /** width for virtual list wrapper */
82
+ width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('width for virtual list wrapper'),
83
+
84
+ /** weather to focus on searchable group on open */
85
+ focusOnOpen: PropTypes.bool.description('weather to focus on searchable group on open')
57
86
  };
58
- SearchableGroup.propTypes = props;
59
87
  const DSMenuSearchableGroupWithSchema = describe(SearchableGroup);
60
88
  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
89
+ var SearchableGroup$1 = focusGroupManagerHoc(SearchableGroup);
90
+
91
+ export { DSMenuSearchableGroupWithSchema, SearchableGroup$1 as default };
@@ -1,47 +1,58 @@
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
- }) => {
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import 'core-js/modules/web.dom-collections.iterator.js';
8
+ import { useState, useCallback, useMemo } from 'react';
9
+ import { PropTypes, describe } from 'react-desc';
10
+ import { uniqBy } from '@elliemae/ds-utilities';
11
+ import { DSComboBox } from '@elliemae/ds-form';
12
+ import { jsx } from 'react/jsx-runtime';
13
+
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
+
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
+
18
+ const noop = () => {};
19
+
20
+ function SearchableList(_ref) {
21
+ let {
22
+ onSelectMenuItem = noop,
23
+ components = {},
24
+ searchTerm: searchTermProp = '',
25
+ items = [],
26
+ dropdownFilterOptions = {},
27
+ returnValue,
28
+ extraListProps = {},
29
+ appendTermInList = false,
30
+ maxOptions = 10,
31
+ loading = false
32
+ } = _ref;
20
33
  const [searchTerm, setInputValue] = useState(searchTermProp);
21
34
  const handleInputChange = useCallback((value, args) => {
22
35
  const action = args ? args.action : null;
23
- if (action === "input-blur" || action === "menu-close")
24
- return;
36
+ if (action === 'input-blur' || action === 'menu-close') return;
25
37
  setInputValue(value);
26
38
  }, [searchTerm]);
27
39
  const handleFilterByText = useCallback(() => {
28
- if (searchTerm)
29
- onSelectMenuItem(searchTerm);
40
+ if (searchTerm) onSelectMenuItem(searchTerm);
30
41
  }, [searchTerm]);
31
- const handleKeyDown = useCallback((e) => {
32
- if (e.key === "ArrowRight") {
42
+ const handleKeyDown = useCallback(e => {
43
+ if (e.key === 'ArrowRight') {
33
44
  handleFilterByText();
34
45
  }
35
46
  }, [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, {
47
+ const options = useMemo(() => searchTerm && appendTermInList ? uniqBy([{
48
+ id: searchTerm,
49
+ label: searchTerm
50
+ }].concat(items), item => item.label) : items, [searchTerm, appendTermInList]);
51
+ return /*#__PURE__*/jsx(DSComboBox, _objectSpread(_objectSpread({
43
52
  autoFocus: true,
44
- components: { DropdownIndicator: null, ...components },
53
+ components: _objectSpread({
54
+ DropdownIndicator: null
55
+ }, components),
45
56
  customMenuItemOptions: {
46
57
  useTruncatedText: true
47
58
  },
@@ -52,34 +63,46 @@ const SearchableList = ({
52
63
  onFilterByInputText: handleFilterByText,
53
64
  onInputChange: handleInputChange,
54
65
  onKeyDown: handleKeyDown,
55
- options,
56
- returnValue,
66
+ options: options,
67
+ returnValue: returnValue,
57
68
  valueProperty: "id",
58
- maxOptions,
59
- loading,
60
- ...extraListProps,
61
- ...dropdownFilterOptions
62
- });
63
- };
69
+ maxOptions: maxOptions,
70
+ loading: loading
71
+ }, extraListProps), dropdownFilterOptions));
72
+ }
73
+
64
74
  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
+ /** callback after item gets selected */
76
+ onSelectMenuItem: PropTypes.func.description('callback after item gets selected'),
77
+
78
+ /** Object with custom components for react-select */
79
+ components: PropTypes.shape({}).description('Object with custom components for react-select'),
80
+
81
+ /** search term to filter for */
82
+ searchTerm: PropTypes.string.description('search term to filter for'),
83
+
84
+ /** item options */
85
+ items: PropTypes.array.description('item options'),
86
+
87
+ /** options */
88
+ dropdownFilterOptions: PropTypes.shape({}).description('options'),
89
+
90
+ /** Whether the combo box is has value to return or not */
91
+ returnValue: PropTypes.bool.description('Whether the combo box is has value to return or not'),
92
+
93
+ /** extra props to pass down to combo */
94
+ extraListProps: PropTypes.shape({}).description('extra props to pass down to combo'),
95
+
96
+ /** append search term as item on the list */
97
+ appendTermInList: PropTypes.bool.description('append search term as item on the list'),
98
+
99
+ /** maxoptions for combobox */
100
+ maxOptions: PropTypes.number.description('maxoptions for combobox'),
101
+
102
+ /** loading flag */
103
+ loading: PropTypes.bool.description('loading flag')
75
104
  };
76
- SearchableList.propTypes = props;
77
105
  const DSMenuSearchableListWithSchema = describe(SearchableList);
78
106
  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
107
+
108
+ export { DSMenuSearchableListWithSchema, SearchableList as default };
@@ -1,31 +1,45 @@
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";
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
+ import 'core-js/modules/esnext.async-iterator.map.js';
4
+ import 'core-js/modules/esnext.iterator.map.js';
5
+ import 'core-js/modules/esnext.async-iterator.filter.js';
6
+ import 'core-js/modules/esnext.iterator.constructor.js';
7
+ import 'core-js/modules/esnext.iterator.filter.js';
8
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
9
+ import 'core-js/modules/esnext.iterator.for-each.js';
10
+ import { useMemo, createElement } from 'react';
11
+ import { PropTypes, describe } from 'react-desc';
12
+ import { useCheckableGroup } from '@elliemae/ds-shared/CheckableGroup';
13
+ import SearchableGroup from './SearchableGroup.js';
14
+ import { menuItemFactory } from './menuItemFactory.js';
15
+ import VirtualMenuList from '../VirtualMenuList.js';
16
+
17
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
18
+
19
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
20
+
8
21
  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,
22
+
23
+ function SelectionGroup(_ref) {
24
+ let {
25
+ multi = false,
26
+ searchable = false,
27
+ focusOnOpen = false,
28
+ onSelect = noop,
29
+ children,
30
+ items = undefined,
31
+ active = multi ? [] : '',
32
+ width,
33
+ height,
34
+ maxOptions = 5
35
+ } = _ref;
36
+ const renderedItems = useMemo(() => items && items.map(item => {
37
+ const Component = menuItemFactory(multi ? 'checkbox' : 'radio');
38
+ return /*#__PURE__*/createElement(Component, _objectSpread(_objectSpread({}, item), {}, {
25
39
  key: item.name || item.id || item.key,
26
- item,
40
+ item: item,
27
41
  name: item.id || item.name
28
- });
42
+ }));
29
43
  }), [items]);
30
44
  const decoratedGroupChildren = useCheckableGroup({
31
45
  children: renderedItems || children,
@@ -33,41 +47,51 @@ const SelectionGroup = ({
33
47
  active,
34
48
  onCheck: onSelect
35
49
  });
50
+
36
51
  if (searchable) {
37
- return /* @__PURE__ */ React2.createElement(SearchableGroup, {
38
- focusOnOpen,
39
- height,
40
- items,
41
- width
42
- }, decoratedGroupChildren);
52
+ return /*#__PURE__*/_jsx(SearchableGroup, {
53
+ focusOnOpen: focusOnOpen,
54
+ height: height,
55
+ items: items,
56
+ width: width
57
+ }, void 0, decoratedGroupChildren);
43
58
  }
44
- return /* @__PURE__ */ React2.createElement(VirtualMenuList, {
45
- height,
59
+
60
+ return /*#__PURE__*/_jsx(VirtualMenuList, {
61
+ height: height,
46
62
  items: decoratedGroupChildren,
47
- width,
63
+ width: width,
48
64
  amountItemsInWindow: maxOptions
49
65
  });
50
- };
66
+ }
67
+
51
68
  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")
69
+ /** toggle on multi select */
70
+ multi: PropTypes.bool.description('toggle on multi select'),
71
+
72
+ /** toggle on searchable behavior */
73
+ searchable: PropTypes.bool.description('toggle on searchable behavior'),
74
+
75
+ /** toggle to focus component on open */
76
+ focusOnOpen: PropTypes.bool.description('toggle to focus component on open'),
77
+
78
+ /** callback that triggers when select happens */
79
+ onSelect: PropTypes.func.description('callback that triggers when select happens'),
80
+ children: PropTypes.node.description(''),
81
+
82
+ /** selection group items */
83
+ items: PropTypes.array.description('selection group items'),
84
+
85
+ /** array of values for multi and string for single selection */
86
+ active: PropTypes.oneOfType([PropTypes.string, PropTypes.array]).description('array of values for multi and string for single selection'),
87
+
88
+ /** selection group width */
89
+ width: PropTypes.number.description('selection group width'),
90
+
91
+ /** selection group height */
92
+ height: PropTypes.number.description('selection group height')
61
93
  };
62
- SelectionGroup.propTypes = props;
63
- registerMenuItem("selectiongroup", SelectionGroup);
64
- registerMenuItem("SelectionGroup", SelectionGroup);
65
94
  const DSMenuSelectionGroupWithSchema = describe(SelectionGroup);
66
95
  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
96
+
97
+ export { DSMenuSelectionGroupWithSchema, SelectionGroup as default };
@@ -1,30 +1,33 @@
1
- import * as React from "react";
2
- import React2 from "react";
3
- import { describe, PropTypes } from "react-desc";
4
- import { aggregatedClasses } from "@elliemae/ds-classnames";
5
- import { DSSeparator } from "@elliemae/ds-separator";
6
- import styled from "styled-components";
7
- import { registerMenuItem } from "./menuItemFactory";
8
- const blockName = "menu-separator";
9
- const Li = styled.li`
10
- display: flex;
11
- align-items: flex-start;
12
- flex-direction: column;
13
- `;
14
- const Title = aggregatedClasses("h5")(blockName, "title");
15
- const MenuSeparator = ({ title, showSeparator = true }) => /* @__PURE__ */ React2.createElement(Li, null, showSeparator && /* @__PURE__ */ React2.createElement(DSSeparator, null), title && /* @__PURE__ */ React2.createElement(Title, null, title));
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'react';
3
+ import { PropTypes, describe } from 'react-desc';
4
+ import { aggregatedClasses } from '@elliemae/ds-classnames';
5
+ import DSSeparator from '@elliemae/ds-separator';
6
+ import styled from 'styled-components';
7
+
8
+ var _DSSeparator;
9
+ const blockName = 'menu-separator';
10
+ const Li = /*#__PURE__*/styled.li.withConfig({
11
+ componentId: "sc-aysbq3-0"
12
+ })(["display:flex;align-items:flex-start;flex-direction:column;"]);
13
+ const Title = aggregatedClasses('h5')(blockName, 'title');
14
+
15
+ const MenuSeparator = _ref => {
16
+ let {
17
+ title,
18
+ showSeparator = true
19
+ } = _ref;
20
+ return /*#__PURE__*/_jsx(Li, {}, void 0, showSeparator && (_DSSeparator || (_DSSeparator = /*#__PURE__*/_jsx(DSSeparator, {}))), title && /*#__PURE__*/_jsx(Title, {}, void 0, title));
21
+ };
22
+
16
23
  const props = {
17
- title: PropTypes.string.description("menu separator h5 title"),
18
- showSeparator: PropTypes.bool.description("toggle separator on and off")
24
+ /** menu separator h5 title */
25
+ title: PropTypes.string.description('menu separator h5 title'),
26
+
27
+ /** toggle separator on and off */
28
+ showSeparator: PropTypes.bool.description('toggle separator on and off')
19
29
  };
20
- MenuSeparator.propTypes = props;
21
- registerMenuItem("separator", MenuSeparator);
22
30
  const DSMenuSeparatorWithSchema = describe(MenuSeparator);
23
31
  DSMenuSeparatorWithSchema.propTypes = props;
24
- var Separator_default = MenuSeparator;
25
- export {
26
- DSMenuSeparatorWithSchema,
27
- MenuSeparator,
28
- Separator_default as default
29
- };
30
- //# sourceMappingURL=Separator.js.map
32
+
33
+ export { DSMenuSeparatorWithSchema, MenuSeparator as default };