@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.
- package/cjs/Menu.js +181 -137
- package/cjs/MenuCombobox.js +53 -67
- package/cjs/MenuContext.js +11 -38
- package/cjs/MenuItems/CheckboxGroup.js +42 -49
- package/cjs/MenuItems/MenuItem.js +163 -116
- package/cjs/MenuItems/MenuItemCheckable.js +108 -77
- package/cjs/MenuItems/MenuItemCheckbox.js +41 -47
- package/cjs/MenuItems/MenuItemRadio.js +38 -50
- package/cjs/MenuItems/RadioGroup.js +39 -48
- package/cjs/MenuItems/SearchableGroup.js +92 -88
- package/cjs/MenuItems/SearchableList.js +95 -92
- package/cjs/MenuItems/SelectionGroup.js +90 -85
- package/cjs/MenuItems/Separator.js +40 -55
- package/cjs/MenuItems/SubMenu.js +160 -143
- package/cjs/MenuItems/menuItemFactory.js +68 -38
- package/cjs/VirtualMenuList.js +39 -69
- package/cjs/index.js +36 -63
- package/cjs/utils/useHeightByAmountOfItems.js +14 -43
- package/esm/Menu.js +149 -91
- package/esm/MenuCombobox.js +45 -38
- package/esm/MenuContext.js +5 -9
- package/esm/MenuItems/CheckboxGroup.js +31 -19
- package/esm/MenuItems/MenuItem.js +148 -84
- package/esm/MenuItems/MenuItemCheckable.js +96 -47
- package/esm/MenuItems/MenuItemCheckbox.js +33 -18
- package/esm/MenuItems/MenuItemRadio.js +28 -20
- package/esm/MenuItems/RadioGroup.js +28 -18
- package/esm/MenuItems/SearchableGroup.js +76 -53
- package/esm/MenuItems/SearchableList.js +82 -59
- package/esm/MenuItems/SelectionGroup.js +78 -54
- package/esm/MenuItems/Separator.js +29 -26
- package/esm/MenuItems/SubMenu.js +140 -107
- package/esm/MenuItems/menuItemFactory.js +60 -10
- package/esm/VirtualMenuList.js +32 -39
- package/esm/index.js +13 -34
- package/esm/utils/useHeightByAmountOfItems.js +11 -13
- package/package.json +11 -19
- package/types/Menu.d.ts +2 -3
- package/types/MenuContext.d.ts +2 -3
- package/types/MenuItems/CheckboxGroup.d.ts +5 -5
- package/types/MenuItems/MenuItem.d.ts +5 -5
- package/types/MenuItems/MenuItemCheckable.d.ts +15 -15
- package/types/MenuItems/MenuItemCheckbox.d.ts +2 -3
- package/types/MenuItems/MenuItemRadio.d.ts +5 -5
- package/types/MenuItems/RadioGroup.d.ts +5 -5
- package/types/MenuItems/SearchableGroup.d.ts +3 -3
- package/types/MenuItems/SearchableList.d.ts +16 -16
- package/types/MenuItems/SelectionGroup.d.ts +16 -16
- package/types/MenuItems/Separator.d.ts +1 -2
- package/types/MenuItems/SubMenu.d.ts +18 -18
- package/types/MenuItems/menuItemFactory.d.ts +3 -2
- package/types/VirtualMenuList.d.ts +1 -3
- package/types/index.d.ts +2 -3
- package/types/utils/useHeightByAmountOfItems.d.ts +1 -3
- package/cjs/Menu.js.map +0 -7
- package/cjs/MenuCombobox.js.map +0 -7
- package/cjs/MenuContext.js.map +0 -7
- package/cjs/MenuExports.js +0 -28
- package/cjs/MenuExports.js.map +0 -7
- package/cjs/MenuItems/CheckboxGroup.js.map +0 -7
- package/cjs/MenuItems/MenuItem.js.map +0 -7
- package/cjs/MenuItems/MenuItemCheckable.js.map +0 -7
- package/cjs/MenuItems/MenuItemCheckbox.js.map +0 -7
- package/cjs/MenuItems/MenuItemRadio.js.map +0 -7
- package/cjs/MenuItems/RadioGroup.js.map +0 -7
- package/cjs/MenuItems/SearchableGroup.js.map +0 -7
- package/cjs/MenuItems/SearchableList.js.map +0 -7
- package/cjs/MenuItems/SelectionGroup.js.map +0 -7
- package/cjs/MenuItems/Separator.js.map +0 -7
- package/cjs/MenuItems/SubMenu.js.map +0 -7
- package/cjs/MenuItems/menuItemFactory.js.map +0 -7
- package/cjs/MenuItems/renderMenuItems.js +0 -53
- package/cjs/MenuItems/renderMenuItems.js.map +0 -7
- package/cjs/VirtualMenuList.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/utils/useHeightByAmountOfItems.js.map +0 -7
- package/esm/Menu.js.map +0 -7
- package/esm/MenuCombobox.js.map +0 -7
- package/esm/MenuContext.js.map +0 -7
- package/esm/MenuExports.js +0 -3
- package/esm/MenuExports.js.map +0 -7
- package/esm/MenuItems/CheckboxGroup.js.map +0 -7
- package/esm/MenuItems/MenuItem.js.map +0 -7
- package/esm/MenuItems/MenuItemCheckable.js.map +0 -7
- package/esm/MenuItems/MenuItemCheckbox.js.map +0 -7
- package/esm/MenuItems/MenuItemRadio.js.map +0 -7
- package/esm/MenuItems/RadioGroup.js.map +0 -7
- package/esm/MenuItems/SearchableGroup.js.map +0 -7
- package/esm/MenuItems/SearchableList.js.map +0 -7
- package/esm/MenuItems/SelectionGroup.js.map +0 -7
- package/esm/MenuItems/Separator.js.map +0 -7
- package/esm/MenuItems/SubMenu.js.map +0 -7
- package/esm/MenuItems/menuItemFactory.js.map +0 -7
- package/esm/MenuItems/renderMenuItems.js +0 -24
- package/esm/MenuItems/renderMenuItems.js.map +0 -7
- package/esm/VirtualMenuList.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/utils/useHeightByAmountOfItems.js.map +0 -7
- package/types/MenuExports.d.ts +0 -1
- package/types/MenuItems/renderMenuItems.d.ts +0 -1
package/cjs/index.js
CHANGED
|
@@ -1,63 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
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
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
48
|
-
module.exports =
|
|
49
|
-
//# sourceMappingURL=useHeightByAmountOfItems.js.map
|
|
19
|
+
|
|
20
|
+
module.exports = useHeightByAmountOfItems;
|
package/esm/Menu.js
CHANGED
|
@@ -1,61 +1,106 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
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 =
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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 {
|
|
50
|
-
|
|
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 =
|
|
53
|
-
return
|
|
54
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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: {
|
|
123
|
+
classProps: _objectSpread(_objectSpread({}, otherProps.classProps || {}), {}, {
|
|
124
|
+
type: otherProps.type
|
|
125
|
+
}),
|
|
75
126
|
innerRef: mergeRefs(innerRef, menuRef),
|
|
76
|
-
role: "menu"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
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 };
|
package/esm/MenuCombobox.js
CHANGED
|
@@ -1,41 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
30
|
-
|
|
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 };
|
package/esm/MenuContext.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
18
|
-
export {
|
|
19
|
-
CheckboxGroup,
|
|
20
|
-
DSMenuCheckboxGroupWithSchema,
|
|
21
|
-
CheckboxGroup_default as default
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=CheckboxGroup.js.map
|
|
34
|
+
|
|
35
|
+
export { DSMenuCheckboxGroupWithSchema, CheckboxGroup as default };
|