@elliemae/ds-menu 2.2.0-next.3 → 2.3.0-alpha.1

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 +137 -181
  2. package/cjs/Menu.js.map +7 -0
  3. package/cjs/MenuCombobox.js +67 -53
  4. package/cjs/MenuCombobox.js.map +7 -0
  5. package/cjs/MenuContext.js +38 -11
  6. package/cjs/MenuContext.js.map +7 -0
  7. package/cjs/MenuExports.js +28 -0
  8. package/cjs/MenuExports.js.map +7 -0
  9. package/cjs/MenuItems/CheckboxGroup.js +49 -42
  10. package/cjs/MenuItems/CheckboxGroup.js.map +7 -0
  11. package/cjs/MenuItems/MenuItem.js +116 -163
  12. package/cjs/MenuItems/MenuItem.js.map +7 -0
  13. package/cjs/MenuItems/MenuItemCheckable.js +77 -108
  14. package/cjs/MenuItems/MenuItemCheckable.js.map +7 -0
  15. package/cjs/MenuItems/MenuItemCheckbox.js +47 -41
  16. package/cjs/MenuItems/MenuItemCheckbox.js.map +7 -0
  17. package/cjs/MenuItems/MenuItemRadio.js +50 -38
  18. package/cjs/MenuItems/MenuItemRadio.js.map +7 -0
  19. package/cjs/MenuItems/RadioGroup.js +48 -39
  20. package/cjs/MenuItems/RadioGroup.js.map +7 -0
  21. package/cjs/MenuItems/SearchableGroup.js +88 -92
  22. package/cjs/MenuItems/SearchableGroup.js.map +7 -0
  23. package/cjs/MenuItems/SearchableList.js +92 -95
  24. package/cjs/MenuItems/SearchableList.js.map +7 -0
  25. package/cjs/MenuItems/SelectionGroup.js +85 -90
  26. package/cjs/MenuItems/SelectionGroup.js.map +7 -0
  27. package/cjs/MenuItems/Separator.js +55 -40
  28. package/cjs/MenuItems/Separator.js.map +7 -0
  29. package/cjs/MenuItems/SubMenu.js +143 -160
  30. package/cjs/MenuItems/SubMenu.js.map +7 -0
  31. package/cjs/MenuItems/menuItemFactory.js +38 -68
  32. package/cjs/MenuItems/menuItemFactory.js.map +7 -0
  33. package/cjs/MenuItems/renderMenuItems.js +53 -0
  34. package/cjs/MenuItems/renderMenuItems.js.map +7 -0
  35. package/cjs/VirtualMenuList.js +69 -39
  36. package/cjs/VirtualMenuList.js.map +7 -0
  37. package/cjs/index.js +63 -36
  38. package/cjs/index.js.map +7 -0
  39. package/cjs/utils/useHeightByAmountOfItems.js +43 -14
  40. package/cjs/utils/useHeightByAmountOfItems.js.map +7 -0
  41. package/esm/Menu.js +91 -149
  42. package/esm/Menu.js.map +7 -0
  43. package/esm/MenuCombobox.js +38 -45
  44. package/esm/MenuCombobox.js.map +7 -0
  45. package/esm/MenuContext.js +9 -5
  46. package/esm/MenuContext.js.map +7 -0
  47. package/esm/MenuExports.js +3 -0
  48. package/esm/MenuExports.js.map +7 -0
  49. package/esm/MenuItems/CheckboxGroup.js +19 -31
  50. package/esm/MenuItems/CheckboxGroup.js.map +7 -0
  51. package/esm/MenuItems/MenuItem.js +84 -148
  52. package/esm/MenuItems/MenuItem.js.map +7 -0
  53. package/esm/MenuItems/MenuItemCheckable.js +47 -96
  54. package/esm/MenuItems/MenuItemCheckable.js.map +7 -0
  55. package/esm/MenuItems/MenuItemCheckbox.js +18 -33
  56. package/esm/MenuItems/MenuItemCheckbox.js.map +7 -0
  57. package/esm/MenuItems/MenuItemRadio.js +20 -28
  58. package/esm/MenuItems/MenuItemRadio.js.map +7 -0
  59. package/esm/MenuItems/RadioGroup.js +18 -28
  60. package/esm/MenuItems/RadioGroup.js.map +7 -0
  61. package/esm/MenuItems/SearchableGroup.js +53 -76
  62. package/esm/MenuItems/SearchableGroup.js.map +7 -0
  63. package/esm/MenuItems/SearchableList.js +59 -82
  64. package/esm/MenuItems/SearchableList.js.map +7 -0
  65. package/esm/MenuItems/SelectionGroup.js +54 -78
  66. package/esm/MenuItems/SelectionGroup.js.map +7 -0
  67. package/esm/MenuItems/Separator.js +26 -29
  68. package/esm/MenuItems/Separator.js.map +7 -0
  69. package/esm/MenuItems/SubMenu.js +107 -140
  70. package/esm/MenuItems/SubMenu.js.map +7 -0
  71. package/esm/MenuItems/menuItemFactory.js +10 -60
  72. package/esm/MenuItems/menuItemFactory.js.map +7 -0
  73. package/esm/MenuItems/renderMenuItems.js +24 -0
  74. package/esm/MenuItems/renderMenuItems.js.map +7 -0
  75. package/esm/VirtualMenuList.js +39 -32
  76. package/esm/VirtualMenuList.js.map +7 -0
  77. package/esm/index.js +34 -13
  78. package/esm/index.js.map +7 -0
  79. package/esm/utils/useHeightByAmountOfItems.js +13 -11
  80. package/esm/utils/useHeightByAmountOfItems.js.map +7 -0
  81. package/package.json +19 -11
  82. package/types/Menu.d.ts +5 -21
  83. package/types/MenuContext.d.ts +3 -2
  84. package/types/MenuExports.d.ts +1 -0
  85. package/types/MenuItems/CheckboxGroup.d.ts +6 -6
  86. package/types/MenuItems/MenuItem.d.ts +6 -6
  87. package/types/MenuItems/MenuItemCheckable.d.ts +17 -25
  88. package/types/MenuItems/MenuItemCheckbox.d.ts +3 -2
  89. package/types/MenuItems/MenuItemRadio.d.ts +6 -15
  90. package/types/MenuItems/RadioGroup.d.ts +6 -6
  91. package/types/MenuItems/SearchableGroup.d.ts +4 -12
  92. package/types/MenuItems/SearchableList.d.ts +17 -28
  93. package/types/MenuItems/SelectionGroup.d.ts +17 -28
  94. package/types/MenuItems/Separator.d.ts +3 -5
  95. package/types/MenuItems/SubMenu.d.ts +19 -32
  96. package/types/MenuItems/menuItemFactory.d.ts +2 -3
  97. package/types/MenuItems/renderMenuItems.d.ts +1 -0
  98. package/types/VirtualMenuList.d.ts +3 -1
  99. package/types/index.d.ts +3 -2
  100. package/types/utils/useHeightByAmountOfItems.d.ts +3 -1
@@ -1,48 +1,41 @@
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,
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 },
25
18
  innerRef,
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
- })
19
+ visible: true
20
+ }, /* @__PURE__ */ React2.createElement(SearchableList, {
21
+ appendTermInList: true,
22
+ extraListProps: dropdownFilterOptions,
23
+ items: options,
24
+ onSelectMenuItem,
25
+ maxOptions,
26
+ loading
45
27
  }));
46
28
  }
47
-
48
- export { MenuCombobox as default };
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
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/MenuCombobox.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport PropTypes from 'prop-types';\nimport { SearchableList } from './MenuItems/SearchableList';\nimport { Menu } from './Menu';\n\nfunction MenuCombobox({\n dropdownFilterOptions = {},\n options = [],\n onSelectMenuItem = () => null,\n innerRef,\n maxOptions = 10,\n loading = false,\n ...rest\n}) {\n return (\n <Menu\n {...rest}\n classProps={{ menuComboBox: true }}\n innerRef={innerRef}\n visible\n >\n <SearchableList\n appendTermInList\n extraListProps={dropdownFilterOptions}\n items={options}\n onSelectMenuItem={onSelectMenuItem}\n maxOptions={maxOptions}\n loading={loading}\n />\n </Menu>\n );\n}\n\nMenuCombobox.propTypes = {\n /** Options */\n dropdownFilterOptions: PropTypes.shape({}),\n /** The option or menu items to render */\n options: PropTypes.arrayOf(PropTypes.object),\n /** Handler when a menu item is selected */\n onSelectMenuItem: PropTypes.func,\n /** Internal ref */\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),\n /** Max options to display in the list */\n maxOptions: PropTypes.number,\n /** Is loading */\n loading: PropTypes.bool,\n};\n\nexport default MenuCombobox;\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;AACA;AAEA,sBAAsB;AAAA,EACpB,wBAAwB;AAAA,EACxB,UAAU;AAAA,EACV,mBAAmB,MAAM;AAAA,EACzB;AAAA,EACA,aAAa;AAAA,EACb,UAAU;AAAA,KACP;AAAA,GACF;AACD,SACE,qCAAC,MAAD;AAAA,OACM;AAAA,IACJ,YAAY,EAAE,cAAc;AAAA,IAC5B;AAAA,IACA,SAAO;AAAA,KAEP,qCAAC,gBAAD;AAAA,IACE,kBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAMR,aAAa,YAAY;AAAA,EAEvB,uBAAuB,UAAU,MAAM;AAAA,EAEvC,SAAS,UAAU,QAAQ,UAAU;AAAA,EAErC,kBAAkB,UAAU;AAAA,EAE5B,UAAU,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU;AAAA,EAEzD,YAAY,UAAU;AAAA,EAEtB,SAAS,UAAU;AAAA;AAGrB,IAAO,uBAAQ;",
6
+ "names": []
7
+ }
@@ -1,5 +1,9 @@
1
- import React from 'react';
2
-
3
- var MenuContext = /*#__PURE__*/React.createContext();
4
-
5
- export { MenuContext as default };
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
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/MenuContext.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\n\nconst MenuContext = React.createContext();\nexport { MenuContext };\nexport default MenuContext;\n"],
5
+ "mappings": "AAAA;ACAA;AAEA,MAAM,cAAc,OAAM;AAE1B,IAAO,sBAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ export * from "./Menu";
3
+ //# sourceMappingURL=MenuExports.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/MenuExports.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './Menu';"],
5
+ "mappings": "AAAA;ACAA;",
6
+ "names": []
7
+ }
@@ -1,35 +1,23 @@
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
-
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
+ });
22
9
  const props = {
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')
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")
31
13
  };
14
+ CheckboxGroup.propTypes = props;
32
15
  const DSMenuCheckboxGroupWithSchema = describe(CheckboxGroup);
33
16
  DSMenuCheckboxGroupWithSchema.propTypes = props;
34
-
35
- export { DSMenuCheckboxGroupWithSchema, CheckboxGroup as default };
17
+ var CheckboxGroup_default = CheckboxGroup;
18
+ export {
19
+ CheckboxGroup,
20
+ DSMenuCheckboxGroupWithSchema,
21
+ CheckboxGroup_default as default
22
+ };
23
+ //# sourceMappingURL=CheckboxGroup.js.map
@@ -0,0 +1,7 @@
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,87 +1,44 @@
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 _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
8
- import _jsx from '@babel/runtime/helpers/esm/jsx';
9
- import 'core-js/modules/esnext.async-iterator.map.js';
10
- import 'core-js/modules/esnext.iterator.map.js';
11
- import 'core-js/modules/web.dom-collections.iterator.js';
12
- import { useContext, useRef, useMemo } from 'react';
13
- import { PropTypes, describe } from 'react-desc';
14
- import { omit } from 'lodash';
15
- import { aggregatedClasses } from '@elliemae/ds-classnames';
16
- import { mergeRefs, runAll } from '@elliemae/ds-utilities';
17
- import { useFocusGroupItem } from '@elliemae/ds-shared/FocusGroup';
18
- import DSTruncatedTooltipText from '@elliemae/ds-truncated-tooltip-text';
19
- import { renderMenuItems } from './menuItemFactory.js';
20
- import SubMenu from './SubMenu.js';
21
- import MenuContext from '../MenuContext.js';
22
- import { jsx, jsxs } from 'react/jsx-runtime';
23
-
24
- const _excluded = ["innerRef", "as", "role", "leftAddon", "rightAddon", "disabledAddonInactive", "label", "children", "tabIndex", "onKeyDown", "fixedItem", "noAddon", "disabled", "customRenderer", "maxOption", "closeMenu", "style"];
25
-
26
- 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; }
27
-
28
- 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; }
29
-
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 } from "./menuItemFactory";
11
+ import { renderMenuItems } from "./renderMenuItems";
30
12
  const noop = () => null;
31
-
32
- const blockName = 'menu-item';
33
- const Content = aggregatedClasses('div')(blockName, 'content');
34
- const Addon = aggregatedClasses('div')(blockName, 'addon', _ref => {
35
- let {
36
- empty,
37
- fixedItem
38
- } = _ref;
39
- return {
40
- empty,
41
- fixedItem
42
- };
43
- });
44
-
45
- const renderAddon = (addon, fixedItem, addonId) => /*#__PURE__*/_jsx(Addon, {
46
- classProps: {
47
- fixedItem
48
- }
49
- }, addonId, addon);
50
-
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);
51
20
  const renderAddons = (addons, fixedItem) => Array.isArray(addons) ? addons.map(renderAddon) : renderAddon(addons, fixedItem);
52
-
53
- const Wrapper = aggregatedClasses('li')(blockName, null, _ref2 => {
54
- let {
55
- disabled,
56
- disabledAddonInactive,
57
- customRenderer,
58
- fixedItem,
59
- type
60
- } = _ref2;
61
- return {
62
- disabled,
63
- disabledAddonInactive,
64
- customRenderer,
65
- fixedItem,
66
- ["menu-type-".concat(type)]: type
67
- };
68
- });
69
-
70
- const calculateSize = function () {
71
- let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
72
- if (length > 45) return 45 * 7;
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;
73
31
  return length * 7;
74
32
  };
75
-
76
- function MenuItem(props) {
33
+ const MenuItem = (props2) => {
77
34
  const {
78
35
  innerRef,
79
- as = 'li',
80
- role = 'menuitem',
36
+ as = "li",
37
+ role = "menuitem",
81
38
  leftAddon = null,
82
- rightAddon = undefined,
83
- disabledAddonInactive = undefined,
84
- label = undefined,
39
+ rightAddon = void 0,
40
+ disabledAddonInactive = void 0,
41
+ label = void 0,
85
42
  children,
86
43
  tabIndex = -1,
87
44
  onKeyDown = noop,
@@ -91,33 +48,28 @@ function MenuItem(props) {
91
48
  customRenderer,
92
49
  maxOption,
93
50
  closeMenu,
94
- style
95
- } = props,
96
- otherProps = _objectWithoutProperties(props, _excluded);
97
-
51
+ style,
52
+ ...otherProps
53
+ } = props2;
98
54
  const menuCxt = useContext(MenuContext);
99
55
  const ref = useRef(null);
100
56
  useFocusGroupItem(ref);
101
-
102
57
  if (otherProps.subItems) {
103
- return /*#__PURE__*/jsx(SubMenu, _objectSpread(_objectSpread({}, props), {}, {
104
- closeMenu: menuCxt.closeMenu,
105
- children: renderMenuItems(otherProps.subItems)
106
- }));
58
+ return /* @__PURE__ */ React2.createElement(SubMenu, {
59
+ ...props2,
60
+ closeMenu: menuCxt.closeMenu
61
+ }, renderMenuItems(otherProps.subItems));
107
62
  }
108
-
109
- const wrapperProps = useMemo(() => omit(otherProps, ['icon']), [otherProps]);
110
-
111
- const onClick = function () {
112
- if (wrapperProps.onClick) wrapperProps.onClick(...arguments);
113
-
63
+ const wrapperProps = useMemo(() => omit(otherProps, ["icon"]), [otherProps]);
64
+ const onClick = (...args) => {
65
+ if (wrapperProps.onClick)
66
+ wrapperProps.onClick(...args);
114
67
  if (wrapperProps.closeOnClick && menuCxt.closeMenu) {
115
- menuCxt.closeMenu(...arguments);
68
+ menuCxt.closeMenu(...args);
116
69
  }
117
70
  };
118
-
119
- return /*#__PURE__*/jsxs(Wrapper, _objectSpread(_objectSpread({
120
- as: as,
71
+ return /* @__PURE__ */ React2.createElement(Wrapper, {
72
+ as,
121
73
  classProps: {
122
74
  disabled,
123
75
  disabledAddonInactive,
@@ -126,66 +78,50 @@ function MenuItem(props) {
126
78
  type: otherProps.type
127
79
  },
128
80
  id: otherProps.id,
129
- innerRef: otherProps.type !== 'disabled' ? mergeRefs(innerRef, ref) : innerRef,
130
- onKeyDown: !fixedItem && runAll(e => {
131
- if (e.key === ' ' || e.key === 'Enter') {
81
+ innerRef: otherProps.type !== "disabled" ? mergeRefs(innerRef, ref) : innerRef,
82
+ onKeyDown: !fixedItem && runAll((e) => {
83
+ if (e.key === " " || e.key === "Enter") {
132
84
  e.preventDefault();
133
- e.target.dispatchEvent(new MouseEvent('click', {
85
+ e.target.dispatchEvent(new MouseEvent("click", {
134
86
  view: window,
135
87
  bubbles: true,
136
88
  cancelable: false
137
89
  }));
138
90
  }
139
91
  }, onKeyDown),
140
- role: role,
141
- style: style,
142
- tabIndex: tabIndex
143
- }, wrapperProps), {}, {
144
- onClick: onClick,
145
- children: [!noAddon && renderAddons(leftAddon, fixedItem), label && /*#__PURE__*/_jsx(Content, {
146
- style: maxOption > 0 ? {
147
- width: "".concat(calculateSize(maxOption), "px"),
148
- maxWidth: "".concat(calculateSize(maxOption), "px")
149
- } : undefined
150
- }, void 0, /*#__PURE__*/_jsx(DSTruncatedTooltipText, {
151
- value: label
152
- })), customRenderer, rightAddon && renderAddons(rightAddon), children]
153
- }));
154
- }
155
-
92
+ role,
93
+ style,
94
+ tabIndex,
95
+ ...wrapperProps,
96
+ onClick
97
+ }, !noAddon && renderAddons(leftAddon, fixedItem), label && /* @__PURE__ */ React2.createElement(Content, {
98
+ style: maxOption > 0 ? {
99
+ width: `${calculateSize(maxOption)}px`,
100
+ maxWidth: `${calculateSize(maxOption)}px`
101
+ } : void 0
102
+ }, /* @__PURE__ */ React2.createElement(DSTruncatedTooltipText, {
103
+ value: label
104
+ })), customRenderer, rightAddon && renderAddons(rightAddon), children);
105
+ };
156
106
  const props = {
157
- /** Renders the MenuItem with a specific html element */
158
- as: PropTypes.element.description('Renders the MenuItem with a specific html element'),
159
-
160
- /**
161
- * reference to the component
162
- */
163
- innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
164
- current: PropTypes.any
165
- })]).description('reference to the component'),
166
-
167
- /** Renders the passed element to the left */
168
- leftAddon: PropTypes.element.description('Renders the passed element to the left'),
169
-
170
- /** Renders the passed element to the right */
171
- rightAddon: PropTypes.element.description('Renders the passed element to the right'),
172
-
173
- /** Label for the menu item */
174
- label: PropTypes.string.description('Label for the menu item'),
175
-
176
- /** style object for menu item wrapper */
177
- style: PropTypes.object.description('style object for menu item wrapper'),
178
-
179
- /** disable menu item */
180
- disabled: PropTypes.bool.description('disable menu item'),
181
-
182
- /** HTML tabindex to manage focus order */
183
- tabindex: PropTypes.number.description('HTML tabindex to manage focus order'),
184
-
185
- /** a11y role */
186
- role: PropTypes.string.description('a11y role')
107
+ as: PropTypes.element.description("Renders the MenuItem with a specific html element"),
108
+ innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description("reference to the component"),
109
+ leftAddon: PropTypes.element.description("Renders the passed element to the left"),
110
+ rightAddon: PropTypes.element.description("Renders the passed element to the right"),
111
+ label: PropTypes.string.description("Label for the menu item"),
112
+ style: PropTypes.object.description("style object for menu item wrapper"),
113
+ disabled: PropTypes.bool.description("disable menu item"),
114
+ tabindex: PropTypes.number.description("HTML tabindex to manage focus order"),
115
+ role: PropTypes.string.description("a11y role")
187
116
  };
117
+ MenuItem.propTypes = props;
118
+ registerMenuItem("menuitem", MenuItem);
188
119
  const DSMenuItemWithSchema = describe(MenuItem);
189
120
  DSMenuItemWithSchema.propTypes = props;
190
-
191
- export { DSMenuItemWithSchema, MenuItem as default };
121
+ var MenuItem_default = MenuItem;
122
+ export {
123
+ DSMenuItemWithSchema,
124
+ MenuItem,
125
+ MenuItem_default as default
126
+ };
127
+ //# sourceMappingURL=MenuItem.js.map
@@ -0,0 +1,7 @@
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 } from './menuItemFactory';\nimport { renderMenuItems } from './renderMenuItems';\n\nconst noop = () => null;\n\nconst blockName = 'menu-item';\n\nconst Content = aggregatedClasses('div')(blockName, 'content');\nconst Addon = aggregatedClasses('div')(blockName, 'addon', ({ empty, fixedItem }) => ({ empty, fixedItem }));\n\nconst renderAddon = (addon, fixedItem, addonId) => (\n <Addon key={addonId} classProps={{ fixedItem }}>\n {addon}\n </Addon>\n);\n\nconst renderAddons = (addons, fixedItem) =>\n Array.isArray(addons) ? addons.map(renderAddon) : renderAddon(addons, fixedItem);\n\nconst Wrapper = aggregatedClasses('li')(\n blockName,\n null,\n ({ disabled, disabledAddonInactive, customRenderer, fixedItem, type }) => ({\n disabled,\n disabledAddonInactive,\n customRenderer,\n fixedItem,\n [`menu-type-${type}`]: type,\n }),\n);\nconst calculateSize = (length = 0) => {\n if (length > 45) return 45 * 7;\n return length * 7;\n};\n\nconst MenuItem = (props) => {\n const {\n innerRef,\n as = 'li',\n role = 'menuitem',\n leftAddon = null,\n rightAddon = undefined,\n disabledAddonInactive = undefined,\n label = undefined,\n children,\n tabIndex = -1,\n onKeyDown = noop,\n fixedItem = false,\n noAddon,\n disabled = false,\n customRenderer,\n maxOption,\n closeMenu,\n style,\n ...otherProps\n } = props;\n\n const menuCxt = useContext(MenuContext);\n const ref = useRef(null);\n useFocusGroupItem(ref);\n if (otherProps.subItems) {\n return (\n <SubMenu {...props} closeMenu={menuCxt.closeMenu}>\n {renderMenuItems(otherProps.subItems)}\n </SubMenu>\n );\n }\n\n const wrapperProps = useMemo(() => omit(otherProps, ['icon']), [otherProps]);\n\n const onClick = (...args) => {\n if (wrapperProps.onClick) wrapperProps.onClick(...args);\n if (wrapperProps.closeOnClick && menuCxt.closeMenu) {\n menuCxt.closeMenu(...args);\n }\n };\n\n return (\n <Wrapper\n as={as}\n classProps={{\n disabled,\n disabledAddonInactive,\n customRenderer,\n fixedItem,\n type: otherProps.type,\n }}\n id={otherProps.id}\n innerRef={otherProps.type !== 'disabled' ? mergeRefs(innerRef, ref) : innerRef}\n onKeyDown={\n !fixedItem &&\n runAll((e) => {\n if (e.key === ' ' || e.key === 'Enter') {\n e.preventDefault();\n e.target.dispatchEvent(\n new MouseEvent('click', {\n view: window,\n bubbles: true,\n cancelable: false,\n }),\n );\n }\n }, onKeyDown)\n }\n role={role}\n style={style}\n tabIndex={tabIndex}\n {...wrapperProps}\n onClick={onClick}\n >\n {!noAddon && renderAddons(leftAddon, fixedItem)}\n {label && (\n <Content\n style={\n maxOption > 0\n ? {\n width: `${calculateSize(maxOption)}px`,\n maxWidth: `${calculateSize(maxOption)}px`,\n }\n : undefined\n }\n >\n <DSTruncatedTooltipText value={label} />\n </Content>\n )}\n {customRenderer}\n {rightAddon && renderAddons(rightAddon)}\n {children}\n </Wrapper>\n );\n};\n\nconst props = {\n /** Renders the MenuItem with a specific html element */\n as: PropTypes.element.description('Renders the MenuItem with a specific html element'),\n /**\n * reference to the component\n */\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description(\n 'reference to the component',\n ),\n /** Renders the passed element to the left */\n leftAddon: PropTypes.element.description('Renders the passed element to the left'),\n /** Renders the passed element to the right */\n rightAddon: PropTypes.element.description('Renders the passed element to the right'),\n /** Label for the menu item */\n label: PropTypes.string.description('Label for the menu item'),\n /** style object for menu item wrapper */\n style: PropTypes.object.description('style object for menu item wrapper'),\n /** disable menu item */\n disabled: PropTypes.bool.description('disable menu item'),\n /** HTML tabindex to manage focus order */\n tabindex: PropTypes.number.description('HTML tabindex to manage focus order'),\n /** a11y role */\n role: PropTypes.string.description('a11y role'),\n};\n\nMenuItem.propTypes = props;\nregisterMenuItem('menuitem', MenuItem);\n\nconst DSMenuItemWithSchema = describe(MenuItem);\nDSMenuItemWithSchema.propTypes = props;\n\nexport { DSMenuItemWithSchema, MenuItem };\nexport default MenuItem;\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }