144 lines
3.6 KiB
JavaScript
144 lines
3.6 KiB
JavaScript
import k, { useRef as d, useEffect as h } from "react";
|
|
import { createRoot as v } from "react-dom/client";
|
|
import { Text as w, Input as y, IconButton as E, HStack as x, Button as C, Badge as I, ChakraProvider as T, useTheme as D } from "@chakra-ui/react";
|
|
import { a as m, D as P } from "./chunks/constants-CRZ9QfxV.js";
|
|
import { jsx as g } from "react/jsx-runtime";
|
|
import { AppHeader as N } from "./remote-ui-app-header.js";
|
|
import { AppSidebar as J } from "./remote-ui-app-sidebar.js";
|
|
function S(e = {}) {
|
|
if (typeof window > "u") return;
|
|
const t = window[m] || {};
|
|
window[m] = {
|
|
...t,
|
|
React: e.React || t.React || k,
|
|
createRoot: e.createRoot || t.createRoot || v,
|
|
ChakraProvider: e.ChakraProvider || t.ChakraProvider || T,
|
|
Badge: e.Badge || t.Badge || I,
|
|
Button: e.Button || t.Button || C,
|
|
HStack: e.HStack || t.HStack || x,
|
|
IconButton: e.IconButton || t.IconButton || E,
|
|
Input: e.Input || t.Input || y,
|
|
Text: e.Text || t.Text || w,
|
|
...e.deps || {},
|
|
theme: Object.prototype.hasOwnProperty.call(e, "theme") ? e.theme : t.theme,
|
|
chakraProviderProps: {
|
|
...t.chakraProviderProps || {},
|
|
...e.chakraProviderProps || {}
|
|
}
|
|
};
|
|
}
|
|
const a = /* @__PURE__ */ new Map();
|
|
function b(e = []) {
|
|
if (typeof window > "u") return !1;
|
|
const t = window[m];
|
|
return e.every((r) => t == null ? void 0 : t[r]);
|
|
}
|
|
function H(e = []) {
|
|
typeof window > "u" || b(e) || S();
|
|
}
|
|
function G(e, t) {
|
|
const r = `${e}:${t}`;
|
|
return a.has(r) || a.set(
|
|
r,
|
|
import(
|
|
/* webpackIgnore: true */
|
|
/* @vite-ignore */
|
|
t
|
|
).catch((u) => {
|
|
throw a.delete(r), u;
|
|
})
|
|
), a.get(r);
|
|
}
|
|
function B({
|
|
componentName: e,
|
|
tagName: t,
|
|
defaultRemoteUrl: r,
|
|
requiredDeps: u,
|
|
normalizeProps: f
|
|
}) {
|
|
return function({
|
|
theme: s,
|
|
chakraProviderProps: p,
|
|
...l
|
|
}) {
|
|
const c = d(null), n = d(null), i = d(null);
|
|
return i.current = {
|
|
...f ? f(l) : l,
|
|
...s !== void 0 ? { theme: s } : {},
|
|
...p ? { chakraProviderProps: p } : {}
|
|
}, h(() => {
|
|
let R = !0;
|
|
return H(u), G(e, r).then(() => {
|
|
if (!R || !c.current) return;
|
|
const o = document.createElement(t);
|
|
o.componentProps = i.current, c.current.appendChild(o), n.current = o;
|
|
}).catch((o) => {
|
|
console.error(
|
|
`[uikit/remote/ui] Failed to load ${e}:`,
|
|
o
|
|
);
|
|
}), () => {
|
|
R = !1, n.current && (n.current.remove(), n.current = null);
|
|
};
|
|
}, [e, r, t]), h(() => {
|
|
n.current && (n.current.componentProps = i.current);
|
|
}), /* @__PURE__ */ g(
|
|
"span",
|
|
{
|
|
ref: c,
|
|
style: {
|
|
display: "contents"
|
|
}
|
|
}
|
|
);
|
|
};
|
|
}
|
|
function O(e) {
|
|
if (typeof e == "string" || typeof e == "number")
|
|
return e;
|
|
e != null && console.warn(
|
|
"[uikit/remote/ui] GBadge only accepts text/number children across the remote boundary."
|
|
);
|
|
}
|
|
const K = B({
|
|
componentName: "GBadge",
|
|
tagName: "uikit-g-badge",
|
|
defaultRemoteUrl: P.GBadge,
|
|
requiredDeps: ["React", "createRoot", "ChakraProvider", "Badge"],
|
|
normalizeProps: ({ children: e, ...t }) => ({
|
|
...t,
|
|
children: O(e)
|
|
})
|
|
}), _ = B({
|
|
componentName: "Pagination",
|
|
tagName: "uikit-pagination",
|
|
defaultRemoteUrl: P.Pagination,
|
|
requiredDeps: [
|
|
"React",
|
|
"createRoot",
|
|
"ChakraProvider",
|
|
"Button",
|
|
"HStack",
|
|
"IconButton",
|
|
"Input",
|
|
"Text"
|
|
]
|
|
});
|
|
function L({ theme: e, ...t }) {
|
|
const r = D();
|
|
return /* @__PURE__ */ g(
|
|
_,
|
|
{
|
|
...t,
|
|
theme: e ?? r
|
|
}
|
|
);
|
|
}
|
|
export {
|
|
N as AppHeader,
|
|
J as AppSidebar,
|
|
K as GBadge,
|
|
L as Pagination,
|
|
S as setupUikitRemoteDeps
|
|
};
|