@elliemae/ds-menu 2.2.0-alpha.4 → 3.0.0-next.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.
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
package/cjs/index.js CHANGED
@@ -1,63 +1,36 @@
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 src_exports = {};
29
- __export(src_exports, {
30
- DSMenuCheckboxGroupWithSchema: () => import_CheckboxGroup.DSMenuCheckboxGroupWithSchema,
31
- DSMenuItemCheckeableWithSchema: () => import_MenuItemCheckable.DSMenuItemCheckeableWithSchema,
32
- DSMenuItemRadioWithSchema: () => import_MenuItemRadio.DSMenuItemRadioWithSchema,
33
- DSMenuItemWithSchema: () => import_MenuItem.DSMenuItemWithSchema,
34
- DSMenuRadioGroupWithSchema: () => import_RadioGroup.DSMenuRadioGroupWithSchema,
35
- DSMenuSearchableGroupWithSchema: () => import_SearchableGroup.DSMenuSearchableGroupWithSchema,
36
- DSMenuSearchableListWithSchema: () => import_SearchableList.DSMenuSearchableListWithSchema,
37
- DSMenuSelectionGroupWithSchema: () => import_SelectionGroup.DSMenuSelectionGroupWithSchema,
38
- DSMenuSeparatorWithSchema: () => import_Separator.DSMenuSeparatorWithSchema,
39
- DSMenuWithSchema: () => import_Menu.DSMenuWithSchema,
40
- DSSubMenuWithSchema: () => import_SubMenu.DSSubMenuWithSchema,
41
- Menu: () => import_Menu.Menu,
42
- MenuCombobox: () => import_MenuCombobox.default,
43
- default: () => import_Menu.Menu,
44
- menuItemFactory: () => import_menuItemFactory.menuItemFactory,
45
- renderMenuItems: () => import_renderMenuItems.renderMenuItems
46
- });
47
- var React = __toESM(require("react"));
48
- var import_MenuItem = require("./MenuItems/MenuItem");
49
- var import_SubMenu = require("./MenuItems/SubMenu");
50
- var import_CheckboxGroup = require("./MenuItems/CheckboxGroup");
51
- var import_MenuItemCheckable = require("./MenuItems/MenuItemCheckable");
52
- var import_MenuItemRadio = require("./MenuItems/MenuItemRadio");
53
- var import_RadioGroup = require("./MenuItems/RadioGroup");
54
- var import_SearchableGroup = require("./MenuItems/SearchableGroup");
55
- var import_SearchableList = require("./MenuItems/SearchableList");
56
- var import_Separator = require("./MenuItems/Separator");
57
- var import_SelectionGroup = require("./MenuItems/SelectionGroup");
58
- var import_MenuCombobox = require("./MenuCombobox");
59
- var import_menuItemFactory = require("./MenuItems/menuItemFactory");
60
- var import_renderMenuItems = require("./MenuItems/renderMenuItems");
61
- var import_Menu = require("./Menu");
62
- module.exports = __toCommonJS(src_exports);
63
- //# sourceMappingURL=index.js.map
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Menu = require('./Menu.js');
6
+ var MenuItem = require('./MenuItems/MenuItem.js');
7
+ var SubMenu = require('./MenuItems/SubMenu.js');
8
+ var CheckboxGroup = require('./MenuItems/CheckboxGroup.js');
9
+ var MenuItemCheckable = require('./MenuItems/MenuItemCheckable.js');
10
+ var MenuItemRadio = require('./MenuItems/MenuItemRadio.js');
11
+ var RadioGroup = require('./MenuItems/RadioGroup.js');
12
+ var SearchableGroup = require('./MenuItems/SearchableGroup.js');
13
+ var SearchableList = require('./MenuItems/SearchableList.js');
14
+ var Separator = require('./MenuItems/Separator.js');
15
+ var SelectionGroup = require('./MenuItems/SelectionGroup.js');
16
+ var MenuCombobox = require('./MenuCombobox.js');
17
+ var menuItemFactory = require('./MenuItems/menuItemFactory.js');
18
+
19
+
20
+
21
+ exports.DSMenuWithSchema = Menu.DSMenuWithSchema;
22
+ exports.Menu = Menu.Menu;
23
+ exports["default"] = Menu.Menu;
24
+ exports.DSMenuItemWithSchema = MenuItem.DSMenuItemWithSchema;
25
+ exports.DSSubMenuWithSchema = SubMenu.DSSubMenuWithSchema;
26
+ exports.DSMenuCheckboxGroupWithSchema = CheckboxGroup.DSMenuCheckboxGroupWithSchema;
27
+ exports.DSMenuItemCheckeableWithSchema = MenuItemCheckable.DSMenuItemCheckeableWithSchema;
28
+ exports.DSMenuItemRadioWithSchema = MenuItemRadio.DSMenuItemRadioWithSchema;
29
+ exports.DSMenuRadioGroupWithSchema = RadioGroup.DSMenuRadioGroupWithSchema;
30
+ exports.DSMenuSearchableGroupWithSchema = SearchableGroup.DSMenuSearchableGroupWithSchema;
31
+ exports.DSMenuSearchableListWithSchema = SearchableList.DSMenuSearchableListWithSchema;
32
+ exports.DSMenuSeparatorWithSchema = Separator.DSMenuSeparatorWithSchema;
33
+ exports.DSMenuSelectionGroupWithSchema = SelectionGroup.DSMenuSelectionGroupWithSchema;
34
+ exports.MenuCombobox = MenuCombobox;
35
+ exports.menuItemFactory = menuItemFactory.menuItemFactory;
36
+ exports.renderMenuItems = menuItemFactory.renderMenuItems;
@@ -1,49 +1,20 @@
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 useHeightByAmountOfItems_exports = {};
29
- __export(useHeightByAmountOfItems_exports, {
30
- default: () => useHeightByAmountOfItems_default,
31
- useHeightByAmountOfItems: () => useHeightByAmountOfItems
32
- });
33
- var React = __toESM(require("react"));
34
- var import_react = require("react");
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
35
5
  const calculateHeight = (itemHeight, amountItemsInWindow, itemsLength) => {
36
6
  const realAmountItemsInWindow = itemsLength < amountItemsInWindow ? itemsLength : amountItemsInWindow;
37
7
  return itemHeight * realAmountItemsInWindow;
38
8
  };
39
- function useHeightByAmountOfItems({
40
- itemHeight,
41
- amountItems,
42
- items
43
- }) {
44
- const calculatedHeight = (0, import_react.useMemo)(() => calculateHeight(itemHeight, amountItems, items.length), [amountItems, items]);
9
+
10
+ function useHeightByAmountOfItems(_ref) {
11
+ let {
12
+ itemHeight,
13
+ amountItems,
14
+ items
15
+ } = _ref;
16
+ const calculatedHeight = React.useMemo(() => calculateHeight(itemHeight, amountItems, items.length), [amountItems, items]);
45
17
  return calculatedHeight;
46
18
  }
47
- var useHeightByAmountOfItems_default = useHeightByAmountOfItems;
48
- module.exports = __toCommonJS(useHeightByAmountOfItems_exports);
49
- //# sourceMappingURL=useHeightByAmountOfItems.js.map
19
+
20
+ module.exports = useHeightByAmountOfItems;
package/esm/Menu.js CHANGED
@@ -1,61 +1,106 @@
1
- import * as React from "react";
2
- import React2, { useContext, useEffect, useMemo, useRef } from "react";
3
- import { PropTypes, describe } from "react-desc";
4
- import { omit } from "lodash";
5
- import { aggregatedClasses } from "@elliemae/ds-classnames";
6
- import { animated } from "react-spring/web";
7
- import { useOnClickOutside } from "@elliemae/ds-utilities/hooks";
8
- import { mergeRefs } from "@elliemae/ds-utilities/system";
9
- import { focusGroupManagerHoc, FocusGroupContext } from "@elliemae/ds-shared/FocusGroup";
10
- import { useHiddenTransition } from "@elliemae/ds-hidden";
11
- import { MenuItemRadio } from "./MenuItems/MenuItemRadio";
12
- import { MenuItemCheckbox } from "./MenuItems/MenuItemCheckbox";
13
- import { CheckboxGroup } from "./MenuItems/CheckboxGroup";
14
- import { RadioGroup } from "./MenuItems/RadioGroup";
15
- import { MenuSeparator } from "./MenuItems/Separator";
16
- import { MenuItem } from "./MenuItems/MenuItem";
17
- import { SubMenu } from "./MenuItems/SubMenu";
18
- import { SearchableGroup } from "./MenuItems/SearchableGroup";
19
- import { SelectionGroup } from "./MenuItems/SelectionGroup";
20
- import { menuItemFactory } from "./MenuItems/menuItemFactory";
21
- import { renderMenuItems } from "./MenuItems/renderMenuItems";
22
- import { MenuContext } from "./MenuContext";
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
4
+ import 'core-js/modules/esnext.async-iterator.some.js';
5
+ import 'core-js/modules/esnext.iterator.constructor.js';
6
+ import 'core-js/modules/esnext.iterator.some.js';
7
+ import 'core-js/modules/esnext.async-iterator.constructor.js';
8
+ import 'core-js/modules/esnext.async-iterator.to-array.js';
9
+ import 'core-js/modules/esnext.iterator.to-array.js';
10
+ import 'core-js/modules/esnext.async-iterator.map.js';
11
+ import 'core-js/modules/esnext.iterator.map.js';
12
+ import 'core-js/modules/esnext.async-iterator.filter.js';
13
+ import 'core-js/modules/esnext.iterator.filter.js';
14
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
15
+ import 'core-js/modules/esnext.iterator.for-each.js';
16
+ import React, { useRef, useContext, useMemo, useEffect } from 'react';
17
+ import { PropTypes, describe } from 'react-desc';
18
+ import { omit } from 'lodash';
19
+ import { aggregatedClasses } from '@elliemae/ds-classnames';
20
+ import { animated } from 'react-spring/web';
21
+ import { useOnClickOutside } from '@elliemae/ds-utilities/hooks';
22
+ import { mergeRefs } from '@elliemae/ds-utilities/system';
23
+ import { focusGroupManagerHoc, FocusGroupContext } from '@elliemae/ds-shared/FocusGroup';
24
+ import { useHiddenTransition } from '@elliemae/ds-hidden';
25
+ import MenuItemRadio from './MenuItems/MenuItemRadio.js';
26
+ import MenuItemCheckbox from './MenuItems/MenuItemCheckbox.js';
27
+ import CheckboxGroup from './MenuItems/CheckboxGroup.js';
28
+ import RadioGroup from './MenuItems/RadioGroup.js';
29
+ import MenuSeparator from './MenuItems/Separator.js';
30
+ import MenuItem from './MenuItems/MenuItem.js';
31
+ import SubMenu from './MenuItems/SubMenu.js';
32
+ import SearchableGroup from './MenuItems/SearchableGroup.js';
33
+ import SelectionGroup from './MenuItems/SelectionGroup.js';
34
+ export { menuItemFactory, renderMenuItems } from './MenuItems/menuItemFactory.js';
35
+ import MenuContext from './MenuContext.js';
36
+ import { jsx } from 'react/jsx-runtime';
37
+
38
+ const _excluded = ["containerProps", "innerRef", "as", "children", "onClickOutside", "visible", "focusOnOpen", "maxOption", "style", "minWidth", "maxWidth", "closeMenu", "responsiveHeight"],
39
+ _excluded2 = ["destroyed"];
40
+
41
+ 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; }
42
+
43
+ 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; }
23
44
  const RESPONSIVE_HEIHGT_MARGIN = 120;
24
- const blockName = "menu";
25
- const noop = () => {
26
- };
27
- const MenuComponent = aggregatedClasses("div")(blockName, "", ({ menuComboBox, type }) => ({
28
- "menu-combo-box": menuComboBox,
29
- [`type-${type}`]: type
30
- }));
45
+ const blockName = 'menu';
46
+
47
+ const noop = () => {};
48
+
49
+ const MenuComponent = aggregatedClasses('div')(blockName, '', _ref => {
50
+ let {
51
+ menuComboBox,
52
+ type
53
+ } = _ref;
54
+ return {
55
+ 'menu-combo-box': menuComboBox,
56
+ ["type-".concat(type)]: type
57
+ };
58
+ });
59
+ /**
60
+ * todo: -- IDEA -- each menu could have an overlay based on an overlay stack context so we can
61
+ * capture the context of the clicks on very nested components
62
+ */
63
+
31
64
  const isChildOfType = (child, type) => child.type.name === type;
32
- const DSMenu = ({
33
- containerProps = {},
34
- innerRef,
35
- as: MenuTag = animated.ul,
36
- children = void 0,
37
- onClickOutside = noop,
38
- visible = void 0,
39
- focusOnOpen = false,
40
- maxOption = 0,
41
- style = {},
42
- minWidth = void 0,
43
- maxWidth = void 0,
44
- closeMenu,
45
- responsiveHeight = false,
46
- ...otherProps
47
- }) => {
65
+
66
+ function DSMenu(_ref2) {
67
+ let {
68
+ containerProps = {},
69
+ innerRef,
70
+ as: MenuTag = animated.ul,
71
+ children = undefined,
72
+ onClickOutside = noop,
73
+ // handlers from hidden
74
+ visible = undefined,
75
+ focusOnOpen = false,
76
+ maxOption = 0,
77
+ style = {},
78
+ minWidth = undefined,
79
+ maxWidth = undefined,
80
+ closeMenu,
81
+ responsiveHeight = false
82
+ } = _ref2,
83
+ otherProps = _objectWithoutProperties(_ref2, _excluded);
84
+
48
85
  const menuRef = useRef(null);
49
- const { focusFirst } = useContext(FocusGroupContext);
50
- const { destroyed, ...hiddenProps } = useHiddenTransition({ visible, style });
86
+ const {
87
+ focusFirst
88
+ } = useContext(FocusGroupContext);
89
+
90
+ const _useHiddenTransition = useHiddenTransition({
91
+ visible,
92
+ style
93
+ }),
94
+ hiddenProps = _objectWithoutProperties(_useHiddenTransition, _excluded2); // force no addon to the children if the menu doesn't have any item with leftAddon like SelectionGroup
95
+
96
+
51
97
  const nextChildren = useMemo(() => {
52
- const forceLeftAddon = React2.Children.toArray(children).some((child) => isChildOfType(child, "SelectionGroup") || isChildOfType(child, "MenuItemCheckbox") || isChildOfType(child, "MenuItemRadio") || child.props.leftAddon);
53
- return React2.Children.map(children, (child) => child && React2.cloneElement(child, {
54
- ...child.props,
55
- noAddon: !forceLeftAddon ? true : void 0,
98
+ const forceLeftAddon = React.Children.toArray(children).some(child => isChildOfType(child, 'SelectionGroup') || isChildOfType(child, 'MenuItemCheckbox') || isChildOfType(child, 'MenuItemRadio') || child.props.leftAddon);
99
+ return React.Children.map(children, child => child && /*#__PURE__*/React.cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
100
+ noAddon: !forceLeftAddon ? true : undefined,
56
101
  maxOption,
57
102
  closeMenu
58
- }));
103
+ })));
59
104
  }, [children]);
60
105
  useOnClickOutside(menuRef, onClickOutside);
61
106
  useEffect(() => {
@@ -64,44 +109,64 @@ const DSMenu = ({
64
109
  focusFirst();
65
110
  }, 0);
66
111
  }
67
- }, [visible, focusOnOpen]);
68
- return !hiddenProps.destroyed ? /* @__PURE__ */ React2.createElement(MenuContext.Provider, {
69
- value: { visible, closeMenu }
70
- }, /* @__PURE__ */ React2.createElement(MenuComponent, {
71
- "data-testid": containerProps?.["data-testid"] ? containerProps["data-testid"] : "em-ds-menu",
72
- ...containerProps,
112
+ }, [visible, focusOnOpen]); // todo: find out a better approach to this
113
+
114
+ return !hiddenProps.destroyed ? /*#__PURE__*/_jsx(MenuContext.Provider, {
115
+ value: {
116
+ visible,
117
+ closeMenu
118
+ }
119
+ }, void 0, /*#__PURE__*/jsx(MenuComponent, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
120
+ "data-testid": containerProps !== null && containerProps !== void 0 && containerProps['data-testid'] ? containerProps['data-testid'] : "em-ds-menu"
121
+ }, containerProps), {}, {
73
122
  as: MenuTag,
74
- classProps: { ...otherProps.classProps || {}, type: otherProps.type },
123
+ classProps: _objectSpread(_objectSpread({}, otherProps.classProps || {}), {}, {
124
+ type: otherProps.type
125
+ }),
75
126
  innerRef: mergeRefs(innerRef, menuRef),
76
- role: "menu",
77
- ...omit(otherProps, ["scheduleUpdate"]),
78
- ...hiddenProps
79
- }, /* @__PURE__ */ React2.createElement("div", {
80
- className: "menu-component-internal-wrapper",
81
- style: {
82
- ...style,
83
- minWidth,
84
- maxWidth,
85
- ...responsiveHeight ? {
86
- overflowY: "scroll",
87
- maxHeight: responsiveHeight ? `${window.innerHeight - RESPONSIVE_HEIHGT_MARGIN}px` : void 0
88
- } : {}
89
- }
90
- }, nextChildren))) : null;
91
- };
92
- const Menu = focusGroupManagerHoc(DSMenu, { loop: true });
127
+ role: "menu"
128
+ }, omit(otherProps, ['scheduleUpdate'])), hiddenProps), {}, {
129
+ children: /*#__PURE__*/_jsx("div", {
130
+ className: "menu-component-internal-wrapper",
131
+ style: _objectSpread(_objectSpread({}, style), {}, {
132
+ minWidth,
133
+ maxWidth
134
+ }, responsiveHeight ? {
135
+ overflowY: 'scroll',
136
+ maxHeight: responsiveHeight ? "".concat(window.innerHeight - RESPONSIVE_HEIHGT_MARGIN, "px") : undefined
137
+ } : {})
138
+ }, void 0, nextChildren)
139
+ }))) : null;
140
+ }
141
+
142
+ const Menu = focusGroupManagerHoc(DSMenu, {
143
+ loop: true
144
+ });
93
145
  const props = {
94
- containerProps: PropTypes.object.description("Injected props to wrapper element of component"),
95
- as: PropTypes.element.description("Renders the menu with a specific html element"),
96
- onClickOutside: PropTypes.func.description("Handler when a user clicks outside the menu"),
97
- visible: PropTypes.bool.description("Whether the menu is visible or not"),
146
+ /** Injected props to wrapper element of component */
147
+ containerProps: PropTypes.object.description('Injected props to wrapper element of component'),
148
+
149
+ /** Renders the menu with a specific html element */
150
+ as: PropTypes.element.description('Renders the menu with a specific html element'),
151
+
152
+ /** Handler when a user clicks outside the menu */
153
+ onClickOutside: PropTypes.func.description('Handler when a user clicks outside the menu'),
154
+
155
+ /** Whether the menu is visible or not */
156
+ visible: PropTypes.bool.description('Whether the menu is visible or not'),
157
+
158
+ /** When set to true, it's going to focus the first item */
98
159
  focusOnOpen: PropTypes.bool.description("When set to true, it's going to focus the first item"),
160
+
161
+ /** Customize menu minWidth. Can be undefined or 'number' */
99
162
  minWidth: PropTypes.number.description("Customize menu minWidth. Can be undefined or 'number'"),
163
+
164
+ /** Customize menu maxWidth. Can be undefined or 'number' */
100
165
  maxWidth: PropTypes.number.description("Customize menu maxWidth. Can be undefined or 'number'")
101
166
  };
102
- DSMenu.propTypes = props;
103
167
  const DSMenuWithSchema = describe(DSMenu);
104
- DSMenuWithSchema.propTypes = props;
168
+ DSMenuWithSchema.propTypes = props; // todo: add a handler to get this kind of exports for documentation
169
+
105
170
  Menu.Item = MenuItem;
106
171
  Menu.ItemCheckbox = MenuItemCheckbox;
107
172
  Menu.ItemRadio = MenuItemRadio;
@@ -111,12 +176,5 @@ Menu.CheckboxGroup = CheckboxGroup;
111
176
  Menu.RadioGroup = RadioGroup;
112
177
  Menu.SearchableGroup = SearchableGroup;
113
178
  Menu.SelectionGroup = SelectionGroup;
114
- var Menu_default = Menu;
115
- export {
116
- DSMenuWithSchema,
117
- Menu,
118
- Menu_default as default,
119
- menuItemFactory,
120
- renderMenuItems
121
- };
122
- //# sourceMappingURL=Menu.js.map
179
+
180
+ export { DSMenuWithSchema, Menu, Menu as default };
@@ -1,41 +1,48 @@
1
- import * as React from "react";
2
- import React2 from "react";
3
- import PropTypes from "prop-types";
4
- import { SearchableList } from "./MenuItems/SearchableList";
5
- import { Menu } from "./Menu";
6
- function MenuCombobox({
7
- dropdownFilterOptions = {},
8
- options = [],
9
- onSelectMenuItem = () => null,
10
- innerRef,
11
- maxOptions = 10,
12
- loading = false,
13
- ...rest
14
- }) {
15
- return /* @__PURE__ */ React2.createElement(Menu, {
16
- ...rest,
17
- classProps: { menuComboBox: true },
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 _jsx from '@babel/runtime/helpers/esm/jsx';
8
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
9
+ import 'react';
10
+ import SearchableList from './MenuItems/SearchableList.js';
11
+ import { Menu } from './Menu.js';
12
+ import { jsx } from 'react/jsx-runtime';
13
+
14
+ const _excluded = ["dropdownFilterOptions", "options", "onSelectMenuItem", "innerRef", "maxOptions", "loading"];
15
+
16
+ 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; }
17
+
18
+ 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; }
19
+
20
+ function MenuCombobox(_ref) {
21
+ let {
22
+ dropdownFilterOptions = {},
23
+ options = [],
24
+ onSelectMenuItem = () => null,
18
25
  innerRef,
19
- visible: true
20
- }, /* @__PURE__ */ React2.createElement(SearchableList, {
21
- appendTermInList: true,
22
- extraListProps: dropdownFilterOptions,
23
- items: options,
24
- onSelectMenuItem,
25
- maxOptions,
26
- loading
26
+ maxOptions = 10,
27
+ loading = false
28
+ } = _ref,
29
+ rest = _objectWithoutProperties(_ref, _excluded);
30
+
31
+ return /*#__PURE__*/jsx(Menu, _objectSpread(_objectSpread({}, rest), {}, {
32
+ classProps: {
33
+ menuComboBox: true
34
+ },
35
+ innerRef: innerRef,
36
+ visible: true,
37
+ children: /*#__PURE__*/_jsx(SearchableList, {
38
+ appendTermInList: true,
39
+ extraListProps: dropdownFilterOptions,
40
+ items: options,
41
+ onSelectMenuItem: onSelectMenuItem,
42
+ maxOptions: maxOptions,
43
+ loading: loading
44
+ })
27
45
  }));
28
46
  }
29
- MenuCombobox.propTypes = {
30
- dropdownFilterOptions: PropTypes.shape({}),
31
- options: PropTypes.arrayOf(PropTypes.object),
32
- onSelectMenuItem: PropTypes.func,
33
- innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
34
- maxOptions: PropTypes.number,
35
- loading: PropTypes.bool
36
- };
37
- var MenuCombobox_default = MenuCombobox;
38
- export {
39
- MenuCombobox_default as default
40
- };
41
- //# sourceMappingURL=MenuCombobox.js.map
47
+
48
+ export { MenuCombobox as default };
@@ -1,9 +1,5 @@
1
- import * as React from "react";
2
- import React2 from "react";
3
- const MenuContext = React2.createContext();
4
- var MenuContext_default = MenuContext;
5
- export {
6
- MenuContext,
7
- MenuContext_default as default
8
- };
9
- //# sourceMappingURL=MenuContext.js.map
1
+ import React from 'react';
2
+
3
+ var MenuContext = /*#__PURE__*/React.createContext();
4
+
5
+ export { MenuContext as default };
@@ -1,23 +1,35 @@
1
- import * as React from "react";
2
- import React2 from "react";
3
- import { PropTypes, describe } from "react-desc";
4
- import { CheckableGroup } from "@elliemae/ds-shared/CheckableGroup";
5
- const CheckboxGroup = (props2) => /* @__PURE__ */ React2.createElement(CheckableGroup, {
6
- ...props2,
7
- multi: true
8
- });
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 'react';
8
+ import { PropTypes, describe } from 'react-desc';
9
+ import CheckableGroup from '@elliemae/ds-shared/CheckableGroup';
10
+ import { jsx } from 'react/jsx-runtime';
11
+
12
+ 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; }
13
+
14
+ 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; }
15
+
16
+ function CheckboxGroup(props) {
17
+ return /*#__PURE__*/jsx(CheckableGroup, _objectSpread(_objectSpread({}, props), {}, {
18
+ multi: true
19
+ }));
20
+ }
21
+
9
22
  const props = {
10
- active: PropTypes.arrayOf(PropTypes.string).description("The item (if multi false) or items (if multi true) selected"),
11
- multi: PropTypes.bool.description("Whether is multi select or not"),
12
- onCheck: PropTypes.func.description("Handler when a user checks an item")
23
+ /* The item (if multi false) or items (if multi true) selected */
24
+ active: PropTypes.arrayOf(PropTypes.string).description('The item (if multi false) or items (if multi true) selected'),
25
+
26
+ /* Whether is multi select or not */
27
+ multi: PropTypes.bool.description('Whether is multi select or not'),
28
+
29
+ /* Handler when a user checks an item */
30
+ onCheck: PropTypes.func.description('Handler when a user checks an item')
13
31
  };
14
- CheckboxGroup.propTypes = props;
15
32
  const DSMenuCheckboxGroupWithSchema = describe(CheckboxGroup);
16
33
  DSMenuCheckboxGroupWithSchema.propTypes = props;
17
- var CheckboxGroup_default = CheckboxGroup;
18
- export {
19
- CheckboxGroup,
20
- DSMenuCheckboxGroupWithSchema,
21
- CheckboxGroup_default as default
22
- };
23
- //# sourceMappingURL=CheckboxGroup.js.map
34
+
35
+ export { DSMenuCheckboxGroupWithSchema, CheckboxGroup as default };