@panneau/element-menu 3.0.118 → 3.0.126
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/lib/index.js +33 -46
- package/package.json +8 -7
package/lib/index.js
CHANGED
|
@@ -14,37 +14,24 @@ var Dropdown = require('@panneau/element-dropdown');
|
|
|
14
14
|
var Label = require('@panneau/element-label');
|
|
15
15
|
var Link = require('@panneau/element-link');
|
|
16
16
|
|
|
17
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
-
|
|
19
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
20
|
-
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
21
|
-
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
22
|
-
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
23
|
-
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
24
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
25
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
26
|
-
var Dropdown__default = /*#__PURE__*/_interopDefaultLegacy(Dropdown);
|
|
27
|
-
var Label__default = /*#__PURE__*/_interopDefaultLegacy(Label);
|
|
28
|
-
var Link__default = /*#__PURE__*/_interopDefaultLegacy(Link);
|
|
29
|
-
|
|
30
17
|
var _excluded = ["id", "className", "linkClassName", "href", "label", "external", "items", "dropdown", "active", "onClick"];
|
|
31
18
|
var propTypes = {
|
|
32
19
|
items: core.PropTypes.menuItems,
|
|
33
|
-
tagName:
|
|
34
|
-
itemTagName:
|
|
35
|
-
children:
|
|
36
|
-
linkAsItem:
|
|
37
|
-
className:
|
|
38
|
-
itemClassName:
|
|
39
|
-
linkClassName:
|
|
40
|
-
hasSubMenuClassName:
|
|
41
|
-
subMenuClassName:
|
|
42
|
-
subMenuItemClassName:
|
|
43
|
-
subMenuLinkClassName:
|
|
44
|
-
hasDropdownClassName:
|
|
45
|
-
dropdownClassName:
|
|
46
|
-
dropdownItemClassName:
|
|
47
|
-
dropdownLinkClassName:
|
|
20
|
+
tagName: PropTypes.string,
|
|
21
|
+
itemTagName: PropTypes.string,
|
|
22
|
+
children: PropTypes.node,
|
|
23
|
+
linkAsItem: PropTypes.bool,
|
|
24
|
+
className: PropTypes.string,
|
|
25
|
+
itemClassName: PropTypes.string,
|
|
26
|
+
linkClassName: PropTypes.string,
|
|
27
|
+
hasSubMenuClassName: PropTypes.string,
|
|
28
|
+
subMenuClassName: PropTypes.string,
|
|
29
|
+
subMenuItemClassName: PropTypes.string,
|
|
30
|
+
subMenuLinkClassName: PropTypes.string,
|
|
31
|
+
hasDropdownClassName: PropTypes.string,
|
|
32
|
+
dropdownClassName: PropTypes.string,
|
|
33
|
+
dropdownItemClassName: PropTypes.string,
|
|
34
|
+
dropdownLinkClassName: PropTypes.string,
|
|
48
35
|
dropdownAlign: core.PropTypes.dropdownAlign
|
|
49
36
|
};
|
|
50
37
|
var defaultProps = {
|
|
@@ -87,11 +74,11 @@ var Menu = function Menu(_ref) {
|
|
|
87
74
|
var _useState = React.useState(items.map(function () {
|
|
88
75
|
return false;
|
|
89
76
|
})),
|
|
90
|
-
_useState2 =
|
|
77
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
91
78
|
dropdownsVisible = _useState2[0],
|
|
92
79
|
setDropdownsVisible = _useState2[1];
|
|
93
80
|
var ListComponent = linkAsItem ? 'div' : tagName;
|
|
94
|
-
return /*#__PURE__*/
|
|
81
|
+
return /*#__PURE__*/React.createElement(ListComponent, {
|
|
95
82
|
className: className
|
|
96
83
|
}, children !== null ? children : items.map(function (it, index) {
|
|
97
84
|
var id = it.id,
|
|
@@ -112,50 +99,50 @@ var Menu = function Menu(_ref) {
|
|
|
112
99
|
active = _it$active === void 0 ? false : _it$active,
|
|
113
100
|
_it$onClick = it.onClick,
|
|
114
101
|
customOnClick = _it$onClick === void 0 ? null : _it$onClick,
|
|
115
|
-
itemProps =
|
|
102
|
+
itemProps = _objectWithoutProperties(it, _excluded);
|
|
116
103
|
var onClickItem = dropdown !== null ? function (e) {
|
|
117
104
|
e.preventDefault();
|
|
118
105
|
e.stopPropagation();
|
|
119
|
-
setDropdownsVisible([].concat(
|
|
106
|
+
setDropdownsVisible([].concat(_toConsumableArray(dropdownsVisible.slice(0, index)), [!(dropdownsVisible[index] || false)], _toConsumableArray(dropdownsVisible.slice(index + 1))));
|
|
120
107
|
if (customOnClick !== null) {
|
|
121
108
|
customOnClick(e);
|
|
122
109
|
}
|
|
123
110
|
} : customOnClick;
|
|
124
111
|
var closeDropdown = dropdown !== null ? function () {
|
|
125
|
-
setDropdownsVisible([].concat(
|
|
112
|
+
setDropdownsVisible([].concat(_toConsumableArray(dropdownsVisible.slice(0, index)), [false], _toConsumableArray(dropdownsVisible.slice(index + 1))));
|
|
126
113
|
} : null;
|
|
127
114
|
var ItemComponent = itemTagName;
|
|
128
115
|
var dropdownVisible = dropdownsVisible[index] || false;
|
|
129
|
-
return linkAsItem ? /*#__PURE__*/
|
|
116
|
+
return linkAsItem ? /*#__PURE__*/React.createElement(Link, Object.assign({}, itemProps, {
|
|
130
117
|
key: "item-".concat(id || index),
|
|
131
118
|
onClick: onClickItem,
|
|
132
119
|
href: href,
|
|
133
120
|
external: external,
|
|
134
|
-
className:
|
|
121
|
+
className: classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
|
|
135
122
|
active: active
|
|
136
123
|
}, itemClassName, itemClassName !== null), customClassName, customClassName !== null), linkClassName, linkClassName !== null), customLinkClassName, customLinkClassName !== null))
|
|
137
|
-
}), /*#__PURE__*/
|
|
124
|
+
}), /*#__PURE__*/React.createElement(Label, itemProps, label)) : /*#__PURE__*/React.createElement(ItemComponent, {
|
|
138
125
|
key: "item-".concat(id || index),
|
|
139
|
-
className:
|
|
126
|
+
className: classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
|
|
140
127
|
dropdown: dropdown !== null,
|
|
141
128
|
active: active
|
|
142
129
|
}, itemClassName, itemClassName !== null), customClassName, customClassName !== null), hasSubMenuClassName, subItems !== null && hasSubMenuClassName !== null), hasDropdownClassName, subItems !== null && hasDropdownClassName !== null))
|
|
143
|
-
}, href !== null || dropdown !== null ? /*#__PURE__*/
|
|
130
|
+
}, href !== null || dropdown !== null ? /*#__PURE__*/React.createElement(Link, Object.assign({}, itemProps, {
|
|
144
131
|
onClick: onClickItem,
|
|
145
132
|
href: href || '#',
|
|
146
133
|
external: external,
|
|
147
|
-
className:
|
|
148
|
-
}), label) : /*#__PURE__*/
|
|
134
|
+
className: classNames(_defineProperty(_defineProperty(_defineProperty({}, linkClassName, linkClassName !== null), 'dropdown-toggle', dropdown !== null), customLinkClassName, customLinkClassName !== null))
|
|
135
|
+
}), label) : /*#__PURE__*/React.createElement(Label, itemProps, label), subItems !== null ? /*#__PURE__*/React.createElement(Menu, {
|
|
149
136
|
items: subItems,
|
|
150
137
|
className: subMenuClassName,
|
|
151
|
-
itemClassName:
|
|
152
|
-
linkClassName:
|
|
153
|
-
}) : null, dropdown !== null ? /*#__PURE__*/
|
|
138
|
+
itemClassName: classNames(_defineProperty(_defineProperty({}, subMenuItemClassName, subMenuItemClassName !== null), itemClassName, subMenuItemClassName === null && itemClassName !== null)),
|
|
139
|
+
linkClassName: classNames(_defineProperty(_defineProperty({}, subMenuLinkClassName, subMenuLinkClassName !== null), linkClassName, subMenuLinkClassName === null && linkClassName !== null))
|
|
140
|
+
}) : null, dropdown !== null ? /*#__PURE__*/React.createElement(Dropdown, {
|
|
154
141
|
items: dropdown,
|
|
155
142
|
visible: dropdownVisible,
|
|
156
143
|
className: dropdownClassName,
|
|
157
|
-
itemClassName:
|
|
158
|
-
linkClassName:
|
|
144
|
+
itemClassName: classNames(_defineProperty(_defineProperty({}, dropdownItemClassName, dropdownItemClassName !== null), itemClassName, dropdownItemClassName === null && itemClassName !== null)),
|
|
145
|
+
linkClassName: classNames(_defineProperty(_defineProperty({}, dropdownLinkClassName, dropdownLinkClassName !== null), linkClassName, dropdownLinkClassName === null && linkClassName !== null)),
|
|
159
146
|
align: dropdownAlign,
|
|
160
147
|
onClickItem: closeDropdown,
|
|
161
148
|
onClickOutside: closeDropdown
|
|
@@ -166,4 +153,4 @@ Menu.propTypes = propTypes;
|
|
|
166
153
|
Menu.defaultProps = defaultProps;
|
|
167
154
|
var Menu$1 = Menu;
|
|
168
155
|
|
|
169
|
-
exports
|
|
156
|
+
exports.default = Menu$1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/element-menu",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.126",
|
|
4
4
|
"description": "Menu element",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -41,7 +41,8 @@
|
|
|
41
41
|
"assets"
|
|
42
42
|
],
|
|
43
43
|
"scripts": {
|
|
44
|
-
"
|
|
44
|
+
"prepublishOnly": "npm run build",
|
|
45
|
+
"build": "../../scripts/prepare-package.sh"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
@@ -53,10 +54,10 @@
|
|
|
53
54
|
},
|
|
54
55
|
"dependencies": {
|
|
55
56
|
"@babel/runtime": "^7.12.5",
|
|
56
|
-
"@panneau/core": "^3.0.
|
|
57
|
-
"@panneau/element-dropdown": "^3.0.
|
|
58
|
-
"@panneau/element-label": "^3.0.
|
|
59
|
-
"@panneau/element-link": "^3.0.
|
|
57
|
+
"@panneau/core": "^3.0.126",
|
|
58
|
+
"@panneau/element-dropdown": "^3.0.126",
|
|
59
|
+
"@panneau/element-label": "^3.0.126",
|
|
60
|
+
"@panneau/element-link": "^3.0.126",
|
|
60
61
|
"classnames": "^2.2.6",
|
|
61
62
|
"prop-types": "^15.7.2",
|
|
62
63
|
"react-intl": "^5.15.8||^6.0.0"
|
|
@@ -64,5 +65,5 @@
|
|
|
64
65
|
"publishConfig": {
|
|
65
66
|
"access": "public"
|
|
66
67
|
},
|
|
67
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "fa69ddff3f8cf22b00504093087608d5701e6f6a"
|
|
68
69
|
}
|