@panneau/element-menu 4.0.2 → 4.0.5

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 (2) hide show
  1. package/es/index.js +78 -70
  2. 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 { useState } from 'react';
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__*/React.createElement(ListComponent, {
55
- className: className
56
- }, children !== null ? children : items.map(function (it, index) {
57
- var id = it.id,
58
- _it$className = it.className,
59
- customClassName = _it$className === void 0 ? null : _it$className,
60
- _it$linkClassName = it.linkClassName,
61
- customLinkClassName = _it$linkClassName === void 0 ? null : _it$linkClassName,
62
- _it$href = it.href,
63
- href = _it$href === void 0 ? null : _it$href,
64
- label = it.label,
65
- _it$external = it.external,
66
- external = _it$external === void 0 ? false : _it$external,
67
- _it$items = it.items,
68
- subItems = _it$items === void 0 ? null : _it$items,
69
- _it$dropdown = it.dropdown,
70
- dropdown = _it$dropdown === void 0 ? null : _it$dropdown,
71
- _it$active = it.active,
72
- active = _it$active === void 0 ? false : _it$active,
73
- _it$onClick = it.onClick,
74
- customOnClick = _it$onClick === void 0 ? null : _it$onClick,
75
- itemProps = _objectWithoutProperties(it, _excluded);
76
- var onClickItem = dropdown !== null ? function (e) {
77
- e.preventDefault();
78
- e.stopPropagation();
79
- setDropdownsVisible([].concat(_toConsumableArray(dropdownsVisible.slice(0, index)), [!(dropdownsVisible[index] || false)], _toConsumableArray(dropdownsVisible.slice(index + 1))));
80
- if (customOnClick !== null) {
81
- customOnClick(e);
82
- }
83
- } : customOnClick;
84
- var closeDropdown = dropdown !== null ? function () {
85
- setDropdownsVisible([].concat(_toConsumableArray(dropdownsVisible.slice(0, index)), [false], _toConsumableArray(dropdownsVisible.slice(index + 1))));
86
- } : null;
87
- var ItemComponent = itemTagName;
88
- var dropdownVisible = dropdownsVisible[index] || false;
89
- return linkAsItem ? /*#__PURE__*/React.createElement(Link, Object.assign({}, itemProps, {
90
- key: "item-".concat(id || index),
91
- onClick: onClickItem,
92
- href: href,
93
- external: external,
94
- className: classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
95
- active: active
96
- }, itemClassName, itemClassName !== null), customClassName, customClassName !== null), linkClassName, linkClassName !== null), customLinkClassName, customLinkClassName !== null))
97
- }), /*#__PURE__*/React.createElement(Label, itemProps, label)) : /*#__PURE__*/React.createElement(ItemComponent, {
98
- key: "item-".concat(id || index),
99
- className: classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
100
- dropdown: dropdown !== null,
101
- active: active
102
- }, itemClassName, itemClassName !== null), customClassName, customClassName !== null), hasSubMenuClassName, subItems !== null && hasSubMenuClassName !== null), hasDropdownClassName, subItems !== null && hasDropdownClassName !== null))
103
- }, href !== null || dropdown !== null ? /*#__PURE__*/React.createElement(Link, Object.assign({}, itemProps, {
104
- onClick: onClickItem,
105
- href: href || '#',
106
- external: external,
107
- className: classNames(_defineProperty(_defineProperty(_defineProperty({}, linkClassName, linkClassName !== null), 'dropdown-toggle', dropdown !== null), customLinkClassName, customLinkClassName !== null))
108
- }), label) : /*#__PURE__*/React.createElement(Label, itemProps, label), subItems !== null ? /*#__PURE__*/React.createElement(Menu, {
109
- items: subItems,
110
- className: subMenuClassName,
111
- itemClassName: classNames(_defineProperty(_defineProperty({}, subMenuItemClassName, subMenuItemClassName !== null), itemClassName, subMenuItemClassName === null && itemClassName !== null)),
112
- linkClassName: classNames(_defineProperty(_defineProperty({}, subMenuLinkClassName, subMenuLinkClassName !== null), linkClassName, subMenuLinkClassName === null && linkClassName !== null))
113
- }) : null, dropdown !== null ? /*#__PURE__*/React.createElement(Dropdown, {
114
- items: dropdown,
115
- visible: dropdownVisible,
116
- className: dropdownClassName,
117
- itemClassName: classNames(_defineProperty(_defineProperty({}, dropdownItemClassName, dropdownItemClassName !== null), itemClassName, dropdownItemClassName === null && itemClassName !== null)),
118
- align: dropdownAlign,
119
- onClickItem: closeDropdown,
120
- onClickOutside: closeDropdown
121
- }) : null);
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.2",
3
+ "version": "4.0.5",
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.2",
61
- "@panneau/element-dropdown": "^4.0.2",
62
- "@panneau/element-label": "^4.0.2",
63
- "@panneau/element-link": "^4.0.2",
60
+ "@panneau/core": "^4.0.5",
61
+ "@panneau/element-dropdown": "^4.0.5",
62
+ "@panneau/element-label": "^4.0.5",
63
+ "@panneau/element-link": "^4.0.5",
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": "53ad0f27e467992c23158732e0f7d39d8615780b"
71
+ "gitHead": "ac8b065e8c7ada1d176d15eff1c0fa53599ad31f"
72
72
  }