mui-nested-menu
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -16,8 +16,6 @@ "use strict"; | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
/** | ||
* Create a JSX element with nested elements creating a nested menu. | ||
* Every menu item should have a uid provided | ||
*/ | ||
function nestedMenuItemsFromObject(_ref) { | ||
@@ -27,44 +25,37 @@ var items = _ref.items, | ||
handleClose = _ref.handleClose; | ||
var menuItems = []; | ||
var i = 0; | ||
return items.map(function (item) { | ||
var leftIcon = item.leftIcon, | ||
rightIcon = item.rightIcon, | ||
label = item.label, | ||
items = item.items, | ||
callback = item.callback, | ||
uid = item.uid; | ||
var _iterator = _createForOfIteratorHelper(items), | ||
_step; | ||
try { | ||
var _loop = function _loop() { | ||
var item = _step.value; | ||
i++; | ||
menuItems.push(item.items ? /*#__PURE__*/_react["default"].createElement(_NestedMenuItem.NestedMenuItem, { | ||
key: i, | ||
leftIcon: item.leftIcon, | ||
rightIcon: item.rightIcon, | ||
label: item.label, | ||
if (items) { | ||
// Recurse deeper | ||
return /*#__PURE__*/_react["default"].createElement(_NestedMenuItem.NestedMenuItem, { | ||
key: uid, | ||
leftIcon: leftIcon, | ||
rightIcon: rightIcon, | ||
label: label, | ||
parentMenuOpen: isOpen | ||
}, item.items ? nestedMenuItemsFromObject({ | ||
items: item.items, | ||
}, nestedMenuItemsFromObject({ | ||
items: items, | ||
isOpen: isOpen, | ||
handleClose: handleClose | ||
}) : null) : /*#__PURE__*/_react["default"].createElement(_IconMenuItem.IconMenuItem, { | ||
key: i, | ||
})); | ||
} else { | ||
// No children elements, return MenuItem | ||
return /*#__PURE__*/_react["default"].createElement(_IconMenuItem.IconMenuItem, { | ||
key: uid, | ||
leftIcon: leftIcon, | ||
rightIcon: rightIcon, | ||
label: label, | ||
onClick: function onClick() { | ||
handleClose(); | ||
item.callback(); | ||
}, | ||
leftIcon: item.leftIcon, | ||
rightIcon: item.rightIcon, | ||
label: item.label | ||
})); | ||
}; | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
_loop(); | ||
callback(); | ||
} | ||
}); | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} | ||
return menuItems; | ||
}); | ||
} |
{ | ||
"name": "mui-nested-menu", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Nested Menu Items for Material UI version 5.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27268
9
452