134 lines
3.5 KiB
JavaScript
134 lines
3.5 KiB
JavaScript
import g, { useRef as d, useEffect as h } from "react";
|
|
import { createRoot as k } from "react-dom/client";
|
|
import { Text as v, Input as w, IconButton as y, HStack as E, Button as x, Badge as C, ChakraProvider as I } from "@chakra-ui/react";
|
|
import { a as f, D as B } from "./chunks/constants-CRZ9QfxV.js";
|
|
import { jsx as D } from "react/jsx-runtime";
|
|
import { AppHeader as z } from "./remote-ui-app-header.js";
|
|
import { AppSidebar as N } from "./remote-ui-app-sidebar.js";
|
|
function S(e = {}) {
|
|
if (typeof window > "u") return;
|
|
const t = window[f] || {};
|
|
window[f] = {
|
|
...t,
|
|
React: e.React || t.React || g,
|
|
createRoot: e.createRoot || t.createRoot || k,
|
|
ChakraProvider: e.ChakraProvider || t.ChakraProvider || I,
|
|
Badge: e.Badge || t.Badge || C,
|
|
Button: e.Button || t.Button || x,
|
|
HStack: e.HStack || t.HStack || E,
|
|
IconButton: e.IconButton || t.IconButton || y,
|
|
Input: e.Input || t.Input || w,
|
|
Text: e.Text || t.Text || v,
|
|
...e.deps || {},
|
|
theme: Object.prototype.hasOwnProperty.call(e, "theme") ? e.theme : t.theme,
|
|
chakraProviderProps: {
|
|
...t.chakraProviderProps || {},
|
|
...e.chakraProviderProps || {}
|
|
}
|
|
};
|
|
}
|
|
const a = /* @__PURE__ */ new Map();
|
|
function T(e = []) {
|
|
if (typeof window > "u") return !1;
|
|
const t = window[f];
|
|
return e.every((r) => t == null ? void 0 : t[r]);
|
|
}
|
|
function b(e = []) {
|
|
typeof window > "u" || T(e) || S();
|
|
}
|
|
function H(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 P({
|
|
componentName: e,
|
|
tagName: t,
|
|
defaultRemoteUrl: r,
|
|
requiredDeps: u,
|
|
normalizeProps: m
|
|
}) {
|
|
return function({
|
|
theme: p,
|
|
chakraProviderProps: s,
|
|
...l
|
|
}) {
|
|
const c = d(null), n = d(null), i = d(null);
|
|
return i.current = {
|
|
...m ? m(l) : l,
|
|
...p !== void 0 ? { theme: p } : {},
|
|
...s ? { chakraProviderProps: s } : {}
|
|
}, h(() => {
|
|
let R = !0;
|
|
return b(u), H(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__ */ D(
|
|
"span",
|
|
{
|
|
ref: c,
|
|
style: {
|
|
display: "contents"
|
|
}
|
|
}
|
|
);
|
|
};
|
|
}
|
|
function G(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 $ = P({
|
|
componentName: "GBadge",
|
|
tagName: "uikit-g-badge",
|
|
defaultRemoteUrl: B.GBadge,
|
|
requiredDeps: ["React", "createRoot", "ChakraProvider", "Badge"],
|
|
normalizeProps: ({ children: e, ...t }) => ({
|
|
...t,
|
|
children: G(e)
|
|
})
|
|
}), j = P({
|
|
componentName: "Pagination",
|
|
tagName: "uikit-pagination",
|
|
defaultRemoteUrl: B.Pagination,
|
|
requiredDeps: [
|
|
"React",
|
|
"createRoot",
|
|
"ChakraProvider",
|
|
"Button",
|
|
"HStack",
|
|
"IconButton",
|
|
"Input",
|
|
"Text"
|
|
]
|
|
});
|
|
export {
|
|
z as AppHeader,
|
|
N as AppSidebar,
|
|
$ as GBadge,
|
|
j as Pagination,
|
|
S as setupUikitRemoteDeps
|
|
};
|