120 lines
2.9 KiB
JavaScript
120 lines
2.9 KiB
JavaScript
import n, { useRef as p, useEffect as d } from "react";
|
|
import { R as E, D as b } from "./chunks/constants-CRZ9QfxV.js";
|
|
import { createRoot as y } from "react-dom/client";
|
|
const a = /* @__PURE__ */ new Map();
|
|
function A() {
|
|
if (typeof window > "u") return;
|
|
const e = window[E] || {};
|
|
window[E] = {
|
|
...e,
|
|
React: e.React || n,
|
|
createRoot: e.createRoot || y
|
|
};
|
|
}
|
|
function S(e, t) {
|
|
const r = `${e}:${t}`;
|
|
return a.has(r) || a.set(
|
|
r,
|
|
import(
|
|
/* webpackIgnore: true */
|
|
/* @vite-ignore */
|
|
t
|
|
).catch((o) => {
|
|
throw a.delete(r), o;
|
|
})
|
|
), a.get(r);
|
|
}
|
|
function x({
|
|
componentName: e,
|
|
tagName: t,
|
|
defaultRemoteUrl: r,
|
|
normalizeProps: o
|
|
}) {
|
|
return function(l) {
|
|
const c = p(null), i = p(null), s = p(null);
|
|
return s.current = o ? o(l) : l, d(() => {
|
|
let m = !0;
|
|
return A(), S(e, r).then(() => {
|
|
if (!m || !c.current) return;
|
|
const u = document.createElement(t);
|
|
u.componentProps = s.current, c.current.appendChild(u), i.current = u;
|
|
}).catch((u) => {
|
|
console.error(
|
|
`[uikit/remote/ui] Failed to load ${e}:`,
|
|
u
|
|
);
|
|
}), () => {
|
|
m = !1, i.current && (i.current.remove(), i.current = null);
|
|
};
|
|
}, [e, r, t]), d(() => {
|
|
i.current && (i.current.componentProps = s.current);
|
|
}), n.createElement("span", {
|
|
ref: c,
|
|
style: { display: "contents" }
|
|
});
|
|
};
|
|
}
|
|
const R = Symbol.for("uikit.remote.app-sidebar.slot");
|
|
function w(e) {
|
|
function t() {
|
|
return null;
|
|
}
|
|
return t[R] = e, t;
|
|
}
|
|
const P = w("exit");
|
|
function f(e) {
|
|
var t;
|
|
if (!(e == null || typeof e == "boolean")) {
|
|
if (typeof e == "string" || typeof e == "number")
|
|
return String(e);
|
|
if (Array.isArray(e))
|
|
return e.map(f).filter(Boolean).join("");
|
|
if (n.isValidElement(e))
|
|
return f((t = e.props) == null ? void 0 : t.children);
|
|
}
|
|
}
|
|
function _(e) {
|
|
const t = { showExit: !1 };
|
|
return n.Children.forEach(e, (r) => {
|
|
var o;
|
|
n.isValidElement(r) && ((o = r.type) == null ? void 0 : o[R]) === "exit" && (t.showExit = !0, t.exitLabel = r.props.label || f(r.props.children) || "خروج", t.onExit = r.props.onClick, t.exitDisabled = !!r.props.disabled);
|
|
}), t;
|
|
}
|
|
function h(e) {
|
|
if (!e || n.isValidElement(e)) return e;
|
|
if (typeof e == "function")
|
|
return n.createElement(e);
|
|
if (typeof e == "object" && (e != null && e.$$typeof))
|
|
try {
|
|
return n.createElement(e);
|
|
} catch {
|
|
return e;
|
|
}
|
|
return e;
|
|
}
|
|
function C(e) {
|
|
return Array.isArray(e) ? e.map((t) => ({
|
|
...t,
|
|
icon: h(t == null ? void 0 : t.icon)
|
|
})) : [];
|
|
}
|
|
const D = x({
|
|
componentName: "AppSidebar",
|
|
tagName: "uikit-app-sidebar",
|
|
defaultRemoteUrl: b.AppSidebar,
|
|
normalizeProps: ({ children: e, items: t, ...r }) => ({
|
|
...r,
|
|
items: C(t),
|
|
...e != null ? _(e) : {}
|
|
})
|
|
});
|
|
function T(e) {
|
|
return n.createElement(D, e);
|
|
}
|
|
const O = Object.assign(T, {
|
|
Exit: P
|
|
});
|
|
export {
|
|
O as AppSidebar
|
|
};
|