UNPKG

@wener/console

Version:
132 lines (131 loc) 5.26 kB
function _array_like_to_array(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; } function _array_without_holes(arr) { if (Array.isArray(arr)) return _array_like_to_array(arr); } function _iterable_to_array(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _non_iterable_spread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _object_without_properties(source, excluded) { if (source == null) return {}; var target = {}, sourceKeys, key, i; if (typeof Reflect !== "undefined" && Reflect.ownKeys) { sourceKeys = Reflect.ownKeys(source); for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } return target; } target = _object_without_properties_loose(source, excluded); if (Object.getOwnPropertySymbols) { sourceKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _object_without_properties_loose(source, excluded) { if (source == null) return {}; var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } return target; } function _to_consumable_array(arr) { return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread(); } function _unsupported_iterable_to_array(o, minLen) { if (!o) return; if (typeof o === "string") return _array_like_to_array(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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen); } import React from "react"; import { SiteLogo } from "@wener/console/console"; import { useContextStore } from "@wener/console/hooks"; import { IconSidebarLayout } from "../../../components/IconSidebarLayout/IconSidebarLayout.js"; import { DockLayout } from "../DockLayout/index.js"; var MenuBarItem = IconSidebarLayout.Item; var TitleDivider = function (param) { var children = param.children; return /*#__PURE__*/ React.createElement("div", { className: "w-full border-b pt-4 text-center text-[12px] font-bold opacity-40" }, children); }; function renderMenuItems(items) { return items.map(function (item, i) { if ("type" in item) { if (item.type === "group") { return [ item.title ? /*#__PURE__*/ React.createElement(TitleDivider, { key: item.name || item.title }, item.title) : null ].concat(_to_consumable_array(renderMenuItems(item.items))); } return null; } return [ /*#__PURE__*/ React.createElement(MenuBarItem, { key: "".concat(i, "-").concat(item.title), item: item }) ]; }); } var TopItems = [ { title: "\u9996\u9875", href: "/", icon: /*#__PURE__*/ React.createElement(SiteLogo, null) } ]; export var ConsoleLayoutLegacy = function (_0) { var children = _0.children, props = _object_without_properties(_0, [ "children" ]); var useWatch = useContextStore().useWatch; var _useWatch; var _ref = (_useWatch = useWatch("console.menu")) !== null && _useWatch !== void 0 ? _useWatch : {}, _ref_top = _ref.top, top = _ref_top === void 0 ? [] : _ref_top, _ref_center = _ref.center, center = _ref_center === void 0 ? [] : _ref_center, _ref_bottom = _ref.bottom, bottom = _ref_bottom === void 0 ? [] : _ref_bottom; return /*#__PURE__*/ React.createElement(IconSidebarLayout.Layout, { className: "min-h-screen flex-1", top: renderMenuItems(_to_consumable_array(TopItems).concat(_to_consumable_array(top)).concat(props.top || [])), center: renderMenuItems(center.concat(props.center || [])), bottom: renderMenuItems(bottom.concat(props.bottom || [])) }, /*#__PURE__*/ React.createElement(DockLayout, null, children)); };