uikit/dist/remote-ui.js
Mohamadzadeh c75420a91c
All checks were successful
Build and Deploy Next.js + Nginx Docker Image / build-and-deploy (push) Successful in 50s
Build and Deploy Next.js + Nginx Docker Image / deploy (push) Successful in 7s
important changes
2026-07-14 16:33:32 +03:30

133 lines
3.4 KiB
JavaScript

import B, { useRef as d, useEffect as g } from "react";
import { createRoot as k } from "react-dom/client";
import { Text as v, Input as w, IconButton as E, HStack as y, Button as I, Badge as C, ChakraProvider as T } from "@chakra-ui/react";
import { jsx as _ } from "react/jsx-runtime";
const h = {
GBadge: "https://uikit.d.aiengines.ir/GBadge.js",
Pagination: "https://uikit.d.aiengines.ir/Pagination.js"
}, s = "__UIKIT_REMOTE_DEPS__";
function D(e = {}) {
if (typeof window > "u") return;
const t = window[s] || {};
window[s] = {
...t,
React: e.React || t.React || B,
createRoot: e.createRoot || t.createRoot || k,
ChakraProvider: e.ChakraProvider || t.ChakraProvider || T,
Badge: e.Badge || t.Badge || C,
Button: e.Button || t.Button || I,
HStack: e.HStack || t.HStack || y,
IconButton: e.IconButton || t.IconButton || E,
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 x(e = []) {
if (typeof window > "u") return !1;
const t = window[s];
return e.every((r) => t == null ? void 0 : t[r]);
}
function S(e = []) {
typeof window > "u" || x(e) || D();
}
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 P({
componentName: e,
tagName: t,
defaultRemoteUrl: r,
requiredDeps: u,
normalizeProps: f
}) {
return function({
theme: m,
chakraProviderProps: l,
...p
}) {
const i = d(null), n = d(null), c = d(null);
return c.current = {
...f ? f(p) : p,
...m !== void 0 ? { theme: m } : {},
...l ? { chakraProviderProps: l } : {}
}, g(() => {
let R = !0;
return S(u), G(e, r).then(() => {
if (!R || !i.current) return;
const o = document.createElement(t);
o.componentProps = c.current, i.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]), g(() => {
n.current && (n.current.componentProps = c.current);
}), /* @__PURE__ */ _(
"span",
{
ref: i,
style: {
display: "contents"
}
}
);
};
}
function b(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 q = P({
componentName: "GBadge",
tagName: "uikit-g-badge",
defaultRemoteUrl: h.GBadge,
requiredDeps: ["React", "createRoot", "ChakraProvider", "Badge"],
normalizeProps: ({ children: e, ...t }) => ({
...t,
children: b(e)
})
}), K = P({
componentName: "Pagination",
tagName: "uikit-pagination",
defaultRemoteUrl: h.Pagination,
requiredDeps: [
"React",
"createRoot",
"ChakraProvider",
"Button",
"HStack",
"IconButton",
"Input",
"Text"
]
});
export {
q as GBadge,
K as Pagination,
D as setupUikitRemoteDeps
};