uikit/dist/remote-ui.js
Mohamadzadeh c8ec2e3759
All checks were successful
Build and Deploy Next.js + Nginx Docker Image / build-and-deploy (push) Successful in 1m52s
Build and Deploy Next.js + Nginx Docker Image / deploy (push) Successful in 7s
add remote Pagination
2026-07-14 10:39:25 +03:30

139 lines
3.7 KiB
JavaScript

import { jsx as E } from "react/jsx-runtime";
import p, { useRef as s, useEffect as R } from "react";
import { createRoot as k } from "react-dom/client";
import { Text as U, Input as _, IconButton as I, HStack as v, Button as G, Badge as C, ChakraProvider as T } from "@chakra-ui/react";
const h = {
GBadge: "https://uikit.d.aiengines.ir/GBadge.js",
Pagination: "https://uikit.d.aiengines.ir/Pagination.js"
}, l = "__UIKIT_REMOTE_DEPS__", g = "__UIKIT_REMOTE_CONFIG__", u = /* @__PURE__ */ new Map(), y = {
GBadge: ["React", "createRoot", "ChakraProvider", "Badge"],
Pagination: [
"React",
"createRoot",
"ChakraProvider",
"Button",
"HStack",
"IconButton",
"Input",
"Text"
]
};
function D(e = {}) {
if (typeof window > "u") return;
const t = window[l] || {}, r = window[g] || {};
window[l] = {
...t,
React: e.React || t.React || p,
createRoot: e.createRoot || t.createRoot || k,
ChakraProvider: e.ChakraProvider || t.ChakraProvider || T,
Badge: e.Badge || t.Badge || C,
Button: e.Button || t.Button || G,
HStack: e.HStack || t.HStack || v,
IconButton: e.IconButton || t.IconButton || I,
Input: e.Input || t.Input || _,
Text: e.Text || t.Text || U,
theme: Object.prototype.hasOwnProperty.call(e, "theme") ? e.theme : t.theme,
chakraProviderProps: {
...t.chakraProviderProps || {},
...e.chakraProviderProps || {}
}
};
const n = e.remoteUrls || {};
window[g] = {
...r,
...e.remoteUrl ? { GBadgeUrl: e.remoteUrl } : {},
...e.GBadgeUrl ? { GBadgeUrl: e.GBadgeUrl } : {},
...e.PaginationUrl ? { PaginationUrl: e.PaginationUrl } : {},
...n.GBadge ? { GBadgeUrl: n.GBadge } : {},
...n.Pagination ? { PaginationUrl: n.Pagination } : {}
};
}
function O(e) {
if (typeof window > "u") return;
const t = window[l];
(y[e] || []).some((o) => !(t != null && t[o])) && D();
}
function S(e, t) {
var r;
return t || (typeof window > "u" ? h[e] : ((r = window[g]) == null ? void 0 : r[`${e}Url`]) || h[e]);
}
function M(e, t) {
const r = S(e, t), n = `${e}:${r}`;
return u.has(n) || u.set(
n,
import(
/* webpackIgnore: true */
/* @vite-ignore */
r
).catch((o) => {
throw u.delete(n), o;
})
), u.get(n);
}
function x(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."
);
}
function w({
componentName: e,
tagName: t,
normalizeProps: r
}) {
return function({
remoteUrl: o,
theme: f,
chakraProviderProps: m,
...B
}) {
const c = s(null), a = s(null), d = s(null);
return d.current = {
...r ? r(B) : B,
...f !== void 0 ? { theme: f } : {},
...m ? { chakraProviderProps: m } : {}
}, R(() => {
let P = !0;
return O(e), M(e, o).then(() => {
if (!P || !c.current) return;
const i = document.createElement(t);
i.componentProps = d.current, c.current.appendChild(i), a.current = i;
}).catch((i) => {
console.error(
`[uikit/remote/ui] Failed to load ${e}:`,
i
);
}), () => {
P = !1, a.current && (a.current.remove(), a.current = null);
};
}, [e, o, t]), R(() => {
a.current && (a.current.componentProps = d.current);
}), /* @__PURE__ */ E(
"span",
{
ref: c,
style: {
display: "contents"
}
}
);
};
}
const F = w({
componentName: "GBadge",
tagName: "uikit-g-badge",
normalizeProps: ({ children: e, ...t }) => ({
...t,
children: x(e)
})
}), $ = w({
componentName: "Pagination",
tagName: "uikit-pagination"
});
export {
F as GBadge,
$ as Pagination,
D as setupUikitRemoteDeps
};