111 lines
3.0 KiB
JavaScript
111 lines
3.0 KiB
JavaScript
import { jsx as E } from "react/jsx-runtime";
|
|
import d, { useRef as m, useEffect as A } from "react";
|
|
import { D as S } from "./chunks/constants-CRZ9QfxV.js";
|
|
const l = /* @__PURE__ */ new Map();
|
|
function R(t, e) {
|
|
const o = `${t}:${e}`;
|
|
return l.has(o) || l.set(
|
|
o,
|
|
import(
|
|
/* webpackIgnore: true */
|
|
/* @vite-ignore */
|
|
e
|
|
).catch((i) => {
|
|
throw l.delete(o), i;
|
|
})
|
|
), l.get(o);
|
|
}
|
|
function b({
|
|
componentName: t,
|
|
tagName: e,
|
|
defaultRemoteUrl: o,
|
|
normalizeProps: i
|
|
}) {
|
|
return function(s) {
|
|
const c = m(null), n = m(null), f = m(null);
|
|
return f.current = i ? i(s) : s, A(() => {
|
|
let x = !0;
|
|
return R(t, o).then(() => {
|
|
if (!x || !c.current) return;
|
|
const a = document.createElement(e);
|
|
a.componentProps = f.current, c.current.appendChild(a), n.current = a;
|
|
}).catch((a) => {
|
|
console.error(
|
|
`[uikit/remote/ui] Failed to load ${t}:`,
|
|
a
|
|
);
|
|
}), () => {
|
|
x = !1, n.current && (n.current.remove(), n.current = null);
|
|
};
|
|
}, [t, o, e]), A(() => {
|
|
n.current && (n.current.componentProps = f.current);
|
|
}), /* @__PURE__ */ E(
|
|
"span",
|
|
{
|
|
ref: c,
|
|
style: {
|
|
display: "contents"
|
|
}
|
|
}
|
|
);
|
|
};
|
|
}
|
|
const g = Symbol.for("uikit.remote.app-header.slot");
|
|
function p(t) {
|
|
function e() {
|
|
return null;
|
|
}
|
|
return e[g] = t, e;
|
|
}
|
|
const y = p("brandSection"), H = p("logo"), L = p("brand"), C = p("title"), P = p("description"), T = p("bi"), w = p("extra");
|
|
function u(t) {
|
|
var e;
|
|
if (!(t == null || typeof t == "boolean")) {
|
|
if (typeof t == "string" || typeof t == "number")
|
|
return String(t);
|
|
if (Array.isArray(t))
|
|
return t.map(u).filter(Boolean).join("");
|
|
if (d.isValidElement(t))
|
|
return u((e = t.props) == null ? void 0 : e.children);
|
|
}
|
|
}
|
|
function B(t) {
|
|
const e = {
|
|
showBi: !1,
|
|
showExtra: !1
|
|
};
|
|
function o(i) {
|
|
d.Children.forEach(i, (r) => {
|
|
var c, n;
|
|
if (!d.isValidElement(r)) return;
|
|
const s = (c = r.type) == null ? void 0 : c[g];
|
|
s === "logo" ? (e.logoSrc = r.props.src, e.logoAlt = r.props.alt) : s === "title" ? e.title = u(r.props.children) : s === "description" ? e.description = u(r.props.children) : s === "bi" ? (e.showBi = !0, e.biLogoSrc = r.props.logoSrc || r.props.src, e.biLogoAlt = r.props.alt, e.biText = r.props.text) : s === "extra" && (e.showExtra = !0, e.extraLogoSrc = r.props.logoSrc || r.props.src, e.extraLogoAlt = r.props.alt, e.extraText = r.props.text ?? u(r.props.children)), (n = r.props) != null && n.children && o(r.props.children);
|
|
});
|
|
}
|
|
return o(t), e;
|
|
}
|
|
const D = b({
|
|
componentName: "AppHeader",
|
|
tagName: "uikit-app-header",
|
|
defaultRemoteUrl: S.AppHeader,
|
|
normalizeProps: ({ children: t, ...e }) => t == null ? e : {
|
|
...e,
|
|
...B(t)
|
|
}
|
|
});
|
|
function _(t) {
|
|
return /* @__PURE__ */ E(D, { ...t });
|
|
}
|
|
const O = Object.assign(_, {
|
|
BrandSection: y,
|
|
Logo: H,
|
|
Brand: L,
|
|
Title: C,
|
|
Description: P,
|
|
Extra: w,
|
|
Bi: T
|
|
});
|
|
export {
|
|
O as AppHeader
|
|
};
|