@panneau/element-menu 4.0.1 → 4.0.4
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/es/index.js +78 -70
- package/package.json +6 -6
package/es/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
1
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
3
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
5
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
6
|
import classNames from 'classnames';
|
|
6
|
-
import
|
|
7
|
+
import { useState, createElement } from 'react';
|
|
7
8
|
import Dropdown from '@panneau/element-dropdown';
|
|
8
9
|
import Label from '@panneau/element-label';
|
|
9
10
|
import Link from '@panneau/element-link';
|
|
11
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
10
12
|
|
|
11
13
|
var _excluded = ["id", "className", "linkClassName", "href", "label", "external", "items", "dropdown", "active", "onClick"];
|
|
12
14
|
var DEFAULT_ITEMS = [];
|
|
@@ -51,75 +53,81 @@ function Menu(_ref) {
|
|
|
51
53
|
dropdownsVisible = _useState2[0],
|
|
52
54
|
setDropdownsVisible = _useState2[1];
|
|
53
55
|
var ListComponent = linkAsItem ? 'div' : tagName;
|
|
54
|
-
return /*#__PURE__*/
|
|
55
|
-
className: className
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
56
|
+
return /*#__PURE__*/jsx(ListComponent, {
|
|
57
|
+
className: className,
|
|
58
|
+
children: children !== null ? children : items.map(function (it, index) {
|
|
59
|
+
var id = it.id,
|
|
60
|
+
_it$className = it.className,
|
|
61
|
+
customClassName = _it$className === void 0 ? null : _it$className,
|
|
62
|
+
_it$linkClassName = it.linkClassName,
|
|
63
|
+
customLinkClassName = _it$linkClassName === void 0 ? null : _it$linkClassName,
|
|
64
|
+
_it$href = it.href,
|
|
65
|
+
href = _it$href === void 0 ? null : _it$href,
|
|
66
|
+
label = it.label,
|
|
67
|
+
_it$external = it.external,
|
|
68
|
+
external = _it$external === void 0 ? false : _it$external,
|
|
69
|
+
_it$items = it.items,
|
|
70
|
+
subItems = _it$items === void 0 ? null : _it$items,
|
|
71
|
+
_it$dropdown = it.dropdown,
|
|
72
|
+
dropdown = _it$dropdown === void 0 ? null : _it$dropdown,
|
|
73
|
+
_it$active = it.active,
|
|
74
|
+
active = _it$active === void 0 ? false : _it$active,
|
|
75
|
+
_it$onClick = it.onClick,
|
|
76
|
+
customOnClick = _it$onClick === void 0 ? null : _it$onClick,
|
|
77
|
+
itemProps = _objectWithoutProperties(it, _excluded);
|
|
78
|
+
var onClickItem = dropdown !== null ? function (e) {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
setDropdownsVisible([].concat(_toConsumableArray(dropdownsVisible.slice(0, index)), [!(dropdownsVisible[index] || false)], _toConsumableArray(dropdownsVisible.slice(index + 1))));
|
|
82
|
+
if (customOnClick !== null) {
|
|
83
|
+
customOnClick(e);
|
|
84
|
+
}
|
|
85
|
+
} : customOnClick;
|
|
86
|
+
var closeDropdown = dropdown !== null ? function () {
|
|
87
|
+
setDropdownsVisible([].concat(_toConsumableArray(dropdownsVisible.slice(0, index)), [false], _toConsumableArray(dropdownsVisible.slice(index + 1))));
|
|
88
|
+
} : null;
|
|
89
|
+
var ItemComponent = itemTagName;
|
|
90
|
+
var dropdownVisible = dropdownsVisible[index] || false;
|
|
91
|
+
return linkAsItem ? /*#__PURE__*/createElement(Link, _objectSpread(_objectSpread({}, itemProps), {}, {
|
|
92
|
+
key: "item-".concat(id || index),
|
|
93
|
+
onClick: onClickItem,
|
|
94
|
+
href: href,
|
|
95
|
+
external: external,
|
|
96
|
+
className: classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
|
|
97
|
+
active: active
|
|
98
|
+
}, itemClassName, itemClassName !== null), customClassName, customClassName !== null), linkClassName, linkClassName !== null), customLinkClassName, customLinkClassName !== null))
|
|
99
|
+
}), /*#__PURE__*/jsx(Label, _objectSpread(_objectSpread({}, itemProps), {}, {
|
|
100
|
+
children: label
|
|
101
|
+
}))) : /*#__PURE__*/jsxs(ItemComponent, {
|
|
102
|
+
className: classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
|
|
103
|
+
dropdown: dropdown !== null,
|
|
104
|
+
active: active
|
|
105
|
+
}, itemClassName, itemClassName !== null), customClassName, customClassName !== null), hasSubMenuClassName, subItems !== null && hasSubMenuClassName !== null), hasDropdownClassName, subItems !== null && hasDropdownClassName !== null)),
|
|
106
|
+
children: [href !== null || dropdown !== null ? /*#__PURE__*/jsx(Link, _objectSpread(_objectSpread({}, itemProps), {}, {
|
|
107
|
+
onClick: onClickItem,
|
|
108
|
+
href: href || '#',
|
|
109
|
+
external: external,
|
|
110
|
+
className: classNames(_defineProperty(_defineProperty(_defineProperty({}, linkClassName, linkClassName !== null), 'dropdown-toggle', dropdown !== null), customLinkClassName, customLinkClassName !== null)),
|
|
111
|
+
children: label
|
|
112
|
+
})) : /*#__PURE__*/jsx(Label, _objectSpread(_objectSpread({}, itemProps), {}, {
|
|
113
|
+
children: label
|
|
114
|
+
})), subItems !== null ? /*#__PURE__*/jsx(Menu, {
|
|
115
|
+
items: subItems,
|
|
116
|
+
className: subMenuClassName,
|
|
117
|
+
itemClassName: classNames(_defineProperty(_defineProperty({}, subMenuItemClassName, subMenuItemClassName !== null), itemClassName, subMenuItemClassName === null && itemClassName !== null)),
|
|
118
|
+
linkClassName: classNames(_defineProperty(_defineProperty({}, subMenuLinkClassName, subMenuLinkClassName !== null), linkClassName, subMenuLinkClassName === null && linkClassName !== null))
|
|
119
|
+
}) : null, dropdown !== null ? /*#__PURE__*/jsx(Dropdown, {
|
|
120
|
+
items: dropdown,
|
|
121
|
+
visible: dropdownVisible,
|
|
122
|
+
className: dropdownClassName,
|
|
123
|
+
itemClassName: classNames(_defineProperty(_defineProperty({}, dropdownItemClassName, dropdownItemClassName !== null), itemClassName, dropdownItemClassName === null && itemClassName !== null)),
|
|
124
|
+
align: dropdownAlign,
|
|
125
|
+
onClickItem: closeDropdown,
|
|
126
|
+
onClickOutside: closeDropdown
|
|
127
|
+
}) : null]
|
|
128
|
+
}, "item-".concat(id || index));
|
|
129
|
+
})
|
|
130
|
+
});
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
export { Menu as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/element-menu",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Menu element",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@babel/runtime": "^7.12.5",
|
|
60
|
-
"@panneau/core": "^4.0.
|
|
61
|
-
"@panneau/element-dropdown": "^4.0.
|
|
62
|
-
"@panneau/element-label": "^4.0.
|
|
63
|
-
"@panneau/element-link": "^4.0.
|
|
60
|
+
"@panneau/core": "^4.0.4",
|
|
61
|
+
"@panneau/element-dropdown": "^4.0.4",
|
|
62
|
+
"@panneau/element-label": "^4.0.4",
|
|
63
|
+
"@panneau/element-link": "^4.0.4",
|
|
64
64
|
"classnames": "^2.5.1",
|
|
65
65
|
"prop-types": "^15.7.2",
|
|
66
66
|
"react-intl": "^5.15.8 || ^6.0.0 || ^7.0.0"
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "e854451a718c6bc7dcde2b804c9913d8ac0297ff"
|
|
72
72
|
}
|