update api.js

This commit is contained in:
Mohamadzadeh 2026-06-20 11:55:38 +03:30
parent e7316c0e7f
commit cd1128332f
5 changed files with 171 additions and 165 deletions

313
dist/core.js vendored
View File

@ -1,106 +1,107 @@
import J from "axios"; import J from "axios";
import { jsx as Z, jsxs as v } from "react/jsx-runtime"; import { jsx as Z, jsxs as v } from "react/jsx-runtime";
import H from "keycloak-js"; import H from "keycloak-js";
import { createContext as P, useState as y, useRef as C, useCallback as b, useEffect as K, useMemo as z, useContext as k } from "react"; import { createContext as P, useState as y, useRef as U, useCallback as b, useEffect as K, useMemo as z, useContext as k } from "react";
import { useQueryClient as Q, useMutation as j, useQuery as Y, QueryClient as $, QueryClientProvider as _ } from "@tanstack/react-query"; import { useQueryClient as Q, useMutation as j, useQuery as Y, QueryClient as $, QueryClientProvider as _ } from "@tanstack/react-query";
import { extendTheme as ee, withDefaultColorScheme as te, ChakraProvider as re, Spinner as ne } from "@chakra-ui/react"; import { extendTheme as ee, withDefaultColorScheme as te, ChakraProvider as re, Spinner as ne } from "@chakra-ui/react";
import { Global as oe } from "@emotion/react"; import { Global as oe } from "@emotion/react";
let w = null, o = null, B = null, W = !1; let w = null, n = null, B = null, W = !1;
const ie = P(null), se = ({ url: e, realm: t, clientId: r }) => (o || (o = new H({ const ie = P(null), se = ({ url: e, realm: t, clientId: r }) => (n || (n = new H({
url: e, url: e,
realm: t, realm: t,
clientId: r clientId: r
})), o), ue = (e) => (w = e, w), ae = () => W, U = () => !!(o != null && o.authenticated), X = () => (o == null ? void 0 : o.token) ?? null, M = async (e = 30) => o ? o.updateToken(e) : !1, L = (e) => o == null ? void 0 : o.logout(e), Ce = (e) => o == null ? void 0 : o.login(e), V = ({ config: e, initOptions: t = {} } = {}) => { })), n), ue = (e) => (w = e, w), ae = () => W, C = () => !!(n != null && n.authenticated), X = () => (n == null ? void 0 : n.token) ?? null, M = async (e = 30) => n ? n.updateToken(e) : !1, L = (e) => n == null ? void 0 : n.logout(e), Ue = (e) => n == null ? void 0 : n.login(e), V = ({ config: e, initOptions: t = {} } = {}) => {
const r = e ?? w; const r = e ?? w;
if (!(r != null && r.url) || !(r != null && r.realm) || !(r != null && r.clientId)) if (!(r != null && r.url) || !(r != null && r.realm) || !(r != null && r.clientId))
throw new Error("Keycloak config is required."); throw new Error("Keycloak config is required.");
ue(r); ue(r);
const i = se(r); const o = se(r);
return B || (B = i.init({ return B || (B = o.init({
onLoad: "login-required", onLoad: "login-required",
checkLoginIframe: !1, checkLoginIframe: !1,
flow: "implicit", flow: "implicit",
...t ...t
}).then((u) => (W = !0, u)).catch((u) => { }).then((d) => (W = !0, d)).catch((d) => {
throw W = !0, u; throw W = !0, d;
})), B; })), B;
}, de = ({ }, de = ({
children: e, children: e,
config: t, config: t,
initOptions: r, initOptions: r,
loading: i = null loading: o = null
}) => { }) => {
const [u, l] = y(!1), [n, s] = y(!1), [S, m] = y(null), a = C(!1), c = b(() => { const [d, h] = y(!1), [a, i] = y(!1), [s, m] = y(null), u = U(!1), l = b(() => {
o && (s(!!o.authenticated), m(o.token ?? null)); n && (i(!!n.authenticated), m(n.token ?? null));
}, []); }, []);
K(() => (a.current = !0, V({ config: t, initOptions: r }).then((d) => { K(() => (u.current = !0, V({ config: t, initOptions: r }).then((c) => {
a.current && (s(!!d), m((o == null ? void 0 : o.token) ?? null), l(!0)); u.current && (i(!!c), m((n == null ? void 0 : n.token) ?? null), h(!0));
}).catch(() => { }).catch(() => {
a.current && (s(!1), m(null), l(!0)); u.current && (i(!1), m(null), h(!0));
}), () => { }), () => {
a.current = !1; u.current = !1;
}), [t, r]); }), [t, r]);
const E = b(() => o == null ? void 0 : o.login(), []), h = b((d) => o == null ? void 0 : o.logout(d), []), F = b( const E = b(() => n == null ? void 0 : n.login(), []), F = b((c) => n == null ? void 0 : n.logout(c), []), S = b(
async (d = 30) => { async (c = 30) => {
if (!o) return !1; if (!n) return !1;
const p = await o.updateToken(d); const p = await n.updateToken(c);
return c(), p; return l(), p;
}, },
[c] [l]
), q = z( ), q = z(
() => ({ () => ({
initialized: u, initialized: d,
authenticated: n, authenticated: a,
token: S, token: s,
login: E, login: E,
logout: h, logout: F,
updateToken: F updateToken: S
}), }),
[u, n, S, E, h, F] [d, a, s, E, F, S]
); );
return u ? /* @__PURE__ */ Z(ie.Provider, { value: q, children: e }) : i; return d ? /* @__PURE__ */ Z(ie.Provider, { value: q, children: e }) : o;
}; };
let x = null; let x = null;
const ce = (e) => { const ce = (e) => {
const { api: t } = e, r = J.create({ const { api: t } = e, r = J.create({
baseURL: t.baseUrl baseURL: t.baseUrl
}), i = async () => { }), o = async () => {
(!ae() || !U()) && await V(); (!ae() || !C()) && await V();
}, u = async (n) => { }, d = !!e.keycloak, h = async (i) => {
await i(); if (!d) return i;
await o();
let s = X(); let s = X();
if (s) { if (s) {
try { try {
await M(5), s = X(); await M(5), s = X();
} catch { } catch {
} }
n.headers = { i.headers = {
...n.headers, ...i.headers,
Authorization: `Bearer ${s}` Authorization: `Bearer ${s}`
}; };
} }
return n; return i;
}, l = async (n) => { }, a = async (i) => {
var S; var m;
const s = n.config; const s = i.config;
if (((S = n == null ? void 0 : n.response) == null ? void 0 : S.status) === 401 && !(s != null && s._retry)) { if (((m = i == null ? void 0 : i.response) == null ? void 0 : m.status) === 401 && !(s != null && s._retry)) {
s._retry = !0; s._retry = !0;
try { try {
await M(30); await M(30);
const m = X(); const u = X();
return s.headers = { return s.headers = {
...s.headers, ...s.headers,
Authorization: `Bearer ${m}` Authorization: `Bearer ${u}`
}, r(s); }, r(s);
} catch { } catch {
L({ redirectUri: window.location.origin }); L({ redirectUri: window.location.origin });
} }
} }
return Promise.reject(n); return Promise.reject(i);
}; };
return r.interceptors.request.use(u), r.interceptors.response.use( return r.interceptors.request.use(h), r.interceptors.response.use(
(n) => n, (i) => i,
l a
), { ), {
api: r api: r
}; };
@ -116,23 +117,23 @@ const ce = (e) => {
} }
} }
), Fe = async (e) => (await N.get(e)).data; ), Fe = async (e) => (await N.get(e)).data;
function f(e) { function O(e) {
return Array.isArray(e) ? e : [e]; return Array.isArray(e) ? e : [e];
} }
function Se(e) { function Se(e) {
return [...f(e), "list"]; return [...O(e), "list"];
} }
function D(e, t) { function D(e, t) {
return [...f(e), t]; return [...O(e), t];
} }
function me(e, t) { function me(e, t) {
if (!t) return e; if (!t) return e;
const r = new URLSearchParams(); const r = new URLSearchParams();
Object.entries(t).forEach(([u, l]) => { Object.entries(t).forEach(([d, h]) => {
l != null && l !== "" && r.append(u, l); h != null && h !== "" && r.append(d, h);
}); });
const i = r.toString(); const o = r.toString();
return i ? `${e}?${i}` : e; return o ? `${e}?${o}` : e;
} }
function qe(e, t) { function qe(e, t) {
return typeof e == "function" ? e(t == null ? void 0 : t.id, t) : e; return typeof e == "function" ? e(t == null ? void 0 : t.id, t) : e;
@ -144,65 +145,65 @@ function pe(e = {}) {
function Ee(e, t) { function Ee(e, t) {
return `${e.replace(/\/$/, "")}/${t}`; return `${e.replace(/\/$/, "")}/${t}`;
} }
function Ue({ function Ce({
key: e, key: e,
url: t, url: t,
actions: r = {}, actions: r = {},
axiosInstance: i = N, axiosInstance: o = N,
fetcher: u = Fe fetcher: d = Fe
}) { }) {
const l = f(e), n = Se(e); const h = O(e), a = Se(e);
function s(a, c = {}) { function i(u, l = {}) {
return Y({ return Y({
queryKey: a ? [...n, a] : n, queryKey: u ? [...a, u] : a,
queryFn: () => u(me(t, a)), queryFn: () => d(me(t, u)),
...c ...l
}); });
} }
function S(a, c = {}) { function s(u, l = {}) {
return Y({ return Y({
queryKey: D(e, a), queryKey: D(e, u),
queryFn: () => u(Ee(t, a)), queryFn: () => d(Ee(t, u)),
enabled: !!a, enabled: !!u,
...c ...l
}); });
} }
function m(a, c = {}) { function m(u, l = {}) {
const E = Q(), h = r[a]; const E = Q(), F = r[u];
if (!h) if (!F)
throw new Error(`Action "${a}" is not defined.`); throw new Error(`Action "${u}" is not defined.`);
return j({ return j({
mutationKey: [...l, a], mutationKey: [...h, u],
mutationFn: async (F = {}) => { mutationFn: async (S = {}) => {
const q = h.method || "post", d = qe(h.url || t, F), p = h.body ? h.body(F) : h.sendRawPayload ? F : pe(F); const q = F.method || "post", c = qe(F.url || t, S), p = F.body ? F.body(S) : F.sendRawPayload ? S : pe(S);
return (q === "delete" ? await i.delete( return (q === "delete" ? await o.delete(
d, c,
p && Object.keys(p).length > 0 ? { data: p } : void 0 p && Object.keys(p).length > 0 ? { data: p } : void 0
) : await i[q](d, p)).data; ) : await o[q](c, p)).data;
}, },
onSuccess: (...F) => { onSuccess: (...S) => {
var A; var A;
const [q, d] = F; const [q, c] = S;
E.invalidateQueries({ E.invalidateQueries({
queryKey: n queryKey: a
}); });
const p = (d == null ? void 0 : d.id) ?? (q == null ? void 0 : q.id); const p = (c == null ? void 0 : c.id) ?? (q == null ? void 0 : q.id);
p && E.invalidateQueries({ p && E.invalidateQueries({
queryKey: D(e, p) queryKey: D(e, p)
}); });
const T = typeof h.invalidateKeys == "function" ? h.invalidateKeys(q, d) : h.invalidateKeys; const T = typeof F.invalidateKeys == "function" ? F.invalidateKeys(q, c) : F.invalidateKeys;
T == null || T.forEach((G) => { T == null || T.forEach((G) => {
E.invalidateQueries({ queryKey: G }); E.invalidateQueries({ queryKey: G });
}), (A = c.onSuccess) == null || A.call(c, ...F); }), (A = l.onSuccess) == null || A.call(l, ...S);
}, },
...c ...l
}); });
} }
return { return {
key: l, key: h,
listKey: n, listKey: a,
useGet: s, useGet: i,
useItem: S, useItem: s,
useAction: m useAction: m
}; };
} }
@ -210,33 +211,33 @@ const R = P(null), g = "permissions", Ze = (e) => (e == null ? void 0 : e.storag
user: e = null, user: e = null,
children: t, children: t,
config: r, config: r,
loading: i = /* @__PURE__ */ Z("div", { children: "Loading permissions..." }), loading: o = /* @__PURE__ */ Z("div", { children: "Loading permissions..." }),
errorFallback: u = /* @__PURE__ */ Z("div", { children: "Error loading permissions" }) errorFallback: d = /* @__PURE__ */ Z("div", { children: "Error loading permissions" })
}) => { }) => {
const l = Ze(r), [n, s] = y( const h = Ze(r), [a, i] = y(
() => ye(l) () => ye(h)
), { data: S, isLoading: m, error: a } = xe(r), c = S ?? n; ), { data: s, isLoading: m, error: u } = xe(r), l = s ?? a;
K(() => { K(() => {
S && (Ke(l, S), s(S)); s && (Ke(h, s), i(s));
}, [S, l]); }, [s, h]);
const E = z( const E = z(
() => Te(c), () => Te(l),
[c] [l]
), h = b( ), F = b(
(d = "") => Xe(E, d), (c = "") => Xe(E, c),
[E] [E]
), F = b((d = "") => !h(d), [h]), q = z( ), S = b((c = "") => !F(c), [F]), q = z(
() => ({ () => ({
user: e, user: e,
can: h, can: F,
cannot: F, cannot: S,
permissions: c, permissions: l,
isLoading: m, isLoading: m,
error: a error: u
}), }),
[e, h, F, c, m, a] [e, F, S, l, m, u]
); );
return a && !c ? u : m && !c ? i : /* @__PURE__ */ Z(R.Provider, { value: q, children: t }); return u && !l ? d : m && !l ? o : /* @__PURE__ */ Z(R.Provider, { value: q, children: t });
}, ye = (e = g) => { }, ye = (e = g) => {
if (!(typeof window > "u")) if (!(typeof window > "u"))
try { try {
@ -259,7 +260,7 @@ const R = P(null), g = "permissions", Ze = (e) => (e == null ? void 0 : e.storag
} }
}, Te = (e) => e ? new Set(e.map((t) => t.name)) : /* @__PURE__ */ new Set(), Xe = (e, t = "") => { }, Te = (e) => e ? new Set(e.map((t) => t.name)) : /* @__PURE__ */ new Set(), Xe = (e, t = "") => {
if (!t) return !1; if (!t) return !1;
if (e.has(t) || [...e].some((i) => i.startsWith(t))) return !0; if (e.has(t) || [...e].some((o) => o.startsWith(t))) return !0;
let r = t; let r = t;
for (; r.includes(":"); ) for (; r.includes(":"); )
if (r = r.slice(0, r.lastIndexOf(":")), e.has(`${r}:*`)) return !0; if (r = r.slice(0, r.lastIndexOf(":")), e.has(`${r}:*`)) return !0;
@ -272,16 +273,16 @@ const R = P(null), g = "permissions", Ze = (e) => (e == null ? void 0 : e.storag
throw new Error("Permission config requires url and clientId."); throw new Error("Permission config requires url and clientId.");
const t = X(), r = new URL(e.url); const t = X(), r = new URL(e.url);
r.searchParams.set("client_id", e.clientId); r.searchParams.set("client_id", e.clientId);
const i = await fetch(r.toString(), { const o = await fetch(r.toString(), {
method: "GET", method: "GET",
headers: { headers: {
...t ? { Authorization: `Bearer ${t}` } : {} ...t ? { Authorization: `Bearer ${t}` } : {}
} }
}); });
if (!i.ok) if (!o.ok)
throw new Error("Failed to load permissions"); throw new Error("Failed to load permissions");
return i.json(); return o.json();
}, O = () => { }, f = () => {
const e = k(R); const e = k(R);
if (!e) if (!e)
throw new Error("usePermission must be used within PermissionProvider"); throw new Error("usePermission must be used within PermissionProvider");
@ -289,7 +290,7 @@ const R = P(null), g = "permissions", Ze = (e) => (e == null ? void 0 : e.storag
}, xe = (e) => Y({ }, xe = (e) => Y({
queryKey: I.list(e == null ? void 0 : e.clientId), queryKey: I.list(e == null ? void 0 : e.clientId),
queryFn: () => ze(e), queryFn: () => ze(e),
enabled: !!(e != null && e.url) && !!(e != null && e.clientId) && U(), enabled: !!(e != null && e.url) && !!(e != null && e.clientId) && C(),
staleTime: 1 / 0, staleTime: 1 / 0,
refetchOnWindowFocus: !1, refetchOnWindowFocus: !1,
refetchOnReconnect: !1 refetchOnReconnect: !1
@ -298,46 +299,46 @@ const R = P(null), g = "permissions", Ze = (e) => (e == null ? void 0 : e.storag
children: t, children: t,
fallback: r = /* @__PURE__ */ Z("div", { children: "You are not allowed to do this" }) fallback: r = /* @__PURE__ */ Z("div", { children: "You are not allowed to do this" })
}) => { }) => {
const { can: i } = O(); const { can: o } = f();
return i(e) ? t : r; return o(e) ? t : r;
}, Ne = ({ children: e }) => { }, Ne = ({ children: e }) => {
const { can: t, permissions: r } = O(); const { can: t, permissions: r } = f();
return r && t("admin") ? e : null; return r && t("admin") ? e : null;
}, Re = ({ children: e }) => { }, Re = ({ children: e }) => {
const { can: t, isLoading: r } = O(); const { can: t, isLoading: r } = f();
return K(() => { return K(() => {
r || t("panel_access") || L(); r || t("panel_access") || L();
}, [r, t]), e; }, [r, t]), e;
}; };
function ge() { function ge() {
const [e, t] = y(!1), r = C(null); const [e, t] = y(!1), r = U(null);
return K(() => { return K(() => {
if (process.env.NODE_ENV !== "production") return; if (process.env.NODE_ENV !== "production") return;
let i; let o;
const u = async () => { const d = async () => {
const n = await fetch(`/version.json?t=${Date.now()}`, { const a = await fetch(`/version.json?t=${Date.now()}`, {
cache: "no-store" cache: "no-store"
}); });
if (!n.ok) if (!a.ok)
throw new Error(`Failed to fetch version: ${n.status}`); throw new Error(`Failed to fetch version: ${a.status}`);
const s = await n.json(); const i = await a.json();
return String(s.version); return String(i.version);
}; };
return (async () => { return (async () => {
try { try {
r.current = await u(), i = setInterval(async () => { r.current = await d(), o = setInterval(async () => {
try { try {
const n = await u(); const a = await d();
r.current && n !== r.current && (t(!0), clearInterval(i)); r.current && a !== r.current && (t(!0), clearInterval(o));
} catch (n) { } catch (a) {
console.error("Update check failed:", n); console.error("Update check failed:", a);
} }
}, 3e4); }, 3e4);
} catch (n) { } catch (a) {
console.error("Initial version fetch failed:", n); console.error("Initial version fetch failed:", a);
} }
})(), () => { })(), () => {
i && clearInterval(i); o && clearInterval(o);
}; };
}, []), e ? /* @__PURE__ */ Z( }, []), e ? /* @__PURE__ */ Z(
"div", "div",
@ -407,53 +408,53 @@ function Ie({
children: e, children: e,
apiBaseUrl: t, apiBaseUrl: t,
keycloakClientId: r, keycloakClientId: r,
permissionClientId: i, permissionClientId: o,
loading: u = /* @__PURE__ */ Z(ne, {}), loading: d = /* @__PURE__ */ Z(ne, {}),
updateChecker: l = !1, updateChecker: h = !1,
updateCheckerProps: n, updateCheckerProps: a,
keycloakUrl: s = "https://auth.ibagher.ir", keycloakUrl: i = "https://auth.ibagher.ir",
keycloakRealm: S = "bi", keycloakRealm: s = "bi",
permissionUrl: m = "https://api.d.aiengines.ir/user_api/v1/permissions/list", permissionUrl: m = "https://api.d.aiengines.ir/user_api/v1/permissions/list",
keycloakEnabled: a, keycloakEnabled: u,
permissionEnabled: c permissionEnabled: l
}) { }) {
const [E, h] = y(!1), F = a ?? !!r, q = c ?? !!i, d = z( const [E, F] = y(!1), S = u ?? !!r, q = l ?? !!o, c = z(
() => ({ () => ({
api: { api: {
baseUrl: t || "" baseUrl: t || ""
}, },
keycloak: F ? { keycloak: S ? {
url: s, url: i,
realm: S, realm: s,
clientId: r clientId: r
} : null, } : null,
permission: q ? { permission: q ? {
url: m, url: m,
clientId: i clientId: o
} : null } : null
}), }),
[ [
t, t,
F,
q,
s,
S, S,
q,
i,
s,
r, r,
m, m,
i o
] ]
); );
if (K(() => { if (K(() => {
h(!0); F(!0);
}, []), K(() => { }, []), K(() => {
E && le(d); E && le(c);
}, [E, d]), !E) }, [E, c]), !E)
return null; return null;
let p = e; let p = e;
return q && (p = /* @__PURE__ */ Z(be, { config: d.permission, loading: u, children: p })), F && (p = /* @__PURE__ */ Z(de, { config: d.keycloak, loading: u, children: p })), /* @__PURE__ */ v(re, { theme: we, children: [ return q && (p = /* @__PURE__ */ Z(be, { config: c.permission, loading: d, children: p })), S && (p = /* @__PURE__ */ Z(de, { config: c.keycloak, loading: d, children: p })), /* @__PURE__ */ v(re, { theme: we, children: [
/* @__PURE__ */ Z(We, {}), /* @__PURE__ */ Z(We, {}),
/* @__PURE__ */ v(_, { client: Be, children: [ /* @__PURE__ */ v(_, { client: Be, children: [
l && /* @__PURE__ */ Z(ge, { ...n }), h && /* @__PURE__ */ Z(ge, { ...a }),
p p
] }) ] })
] }); ] });
@ -469,7 +470,7 @@ export {
Xe as checkPermission, Xe as checkPermission,
Le as clearCachedPermissions, Le as clearCachedPermissions,
le as configureApi, le as configureApi,
Ue as createApi, Ce as createApi,
Te as createPermissionSet, Te as createPermissionSet,
Fe as fetcher, Fe as fetcher,
he as getApi, he as getApi,
@ -477,13 +478,13 @@ export {
X as getKeycloakToken, X as getKeycloakToken,
ze as getPermissions, ze as getPermissions,
V as initKeycloak, V as initKeycloak,
U as isKeycloakAuthenticated, C as isKeycloakAuthenticated,
ae as isKeycloakInitialized, ae as isKeycloakInitialized,
Ce as loginKeycloak, Ue as loginKeycloak,
L as logoutKeycloak, L as logoutKeycloak,
I as permissionKeys, I as permissionKeys,
Ke as setCachedPermissions, Ke as setCachedPermissions,
M as updateKeycloakToken, M as updateKeycloakToken,
O as usePermission, f as usePermission,
xe as usePermissionsQuery xe as usePermissionsQuery
}; };

8
dist/form.js vendored
View File

@ -1,6 +1,6 @@
import { jsx as n, jsxs as M } from "react/jsx-runtime"; import { jsx as n, jsxs as M } from "react/jsx-runtime";
import { Input as I, Checkbox as ee, Textarea as re, RadioGroup as te, HStack as ne, Radio as oe, Select as le, Modal as ie, ModalOverlay as ce, ModalContent as ue, ModalHeader as se, ModalCloseButton as ae, ModalBody as de, VStack as fe, SimpleGrid as pe, ModalFooter as be, Button as A, FormControl as ve, FormLabel as me, FormErrorMessage as xe, useDisclosure as Fe } from "@chakra-ui/react"; import { Input as I, Checkbox as ee, Textarea as re, RadioGroup as te, HStack as ne, Radio as oe, Select as le, Modal as ie, ModalOverlay as ce, ModalContent as ue, ModalHeader as se, ModalCloseButton as ae, ModalBody as de, VStack as fe, SimpleGrid as pe, ModalFooter as be, Button as A, FormControl as ve, FormLabel as me, FormErrorMessage as xe, useDisclosure as Fe } from "@chakra-ui/react";
import { createContext as he, useContext as ge, useMemo as x, useRef as ke, useEffect as G, useState as Re, useCallback as B } from "react"; import { useContext as he, useMemo as x, useRef as ge, useEffect as G, createContext as ke, useState as Re, useCallback as B } from "react";
import { Controller as P, useForm as Se, useWatch as Ce } from "react-hook-form"; import { Controller as P, useForm as Se, useWatch as Ce } from "react-hook-form";
const Me = {}, C = { const Me = {}, C = {
create: { create: {
@ -11,7 +11,7 @@ const Me = {}, C = {
titlePrefix: "ویرایش", titlePrefix: "ویرایش",
submitText: "ویرایش" submitText: "ویرایش"
} }
}, H = he(null); }, H = ke(null);
function ye({ item: e, mode: r }) { function ye({ item: e, mode: r }) {
return e ? [r, e.rowId, e.entityId, e.id].filter(Boolean).join("-") : r; return e ? [r, e.rowId, e.entityId, e.id].filter(Boolean).join("-") : r;
} }
@ -20,7 +20,7 @@ function F({ required: e, validate: r, rules: t }) {
return e && (o.required = typeof e == "string" ? e : "این فیلد الزامی است."), r && (o.validate = r), o; return e && (o.required = typeof e == "string" ? e : "این فیلد الزامی است."), r && (o.validate = r), o;
} }
function v() { function v() {
const e = ge(H); const e = he(H);
if (!e) if (!e)
throw new Error("Field باید داخل FormModal استفاده شود."); throw new Error("Field باید داخل FormModal استفاده شود.");
return e; return e;
@ -269,7 +269,7 @@ function Ae({
item: t, item: t,
mode: g, mode: g,
isEdit: b isEdit: b
}) : p, [d, p, t, g, b]), V = ke(S); }) : p, [d, p, t, g, b]), V = ge(S);
G(() => { G(() => {
V.current = S; V.current = S;
}, [S]); }, [S]);

10
dist/table.js vendored
View File

@ -3,8 +3,8 @@ import { VStack as oe, Box as _, Tbody as re, Tr as H, Td as F, Text as R, Thead
import { P as ue } from "./chunks/Pagination-BFHGSAKW.js"; import { P as ue } from "./chunks/Pagination-BFHGSAKW.js";
import { toFaDigits as q } from "./utils.js"; import { toFaDigits as q } from "./utils.js";
import { useReactTable as ae, getCoreRowModel as de, flexRender as J } from "@tanstack/react-table"; import { useReactTable as ae, getCoreRowModel as de, flexRender as J } from "@tanstack/react-table";
import { createContext as me, useMemo as P, useCallback as p, useState as fe, useRef as ge, useEffect as he, useContext as be } from "react"; import { useMemo as P, useCallback as p, useState as me, useRef as fe, useEffect as ge, createContext as he, useContext as be } from "react";
const K = me(null); const K = he(null);
function C() { function C() {
const e = be(K); const e = be(K);
if (!e) if (!e)
@ -35,7 +35,7 @@ function xe({
u !== d && (a == null || a(u)); u !== d && (a == null || a(u));
}, },
[z, d, a] [z, d, a]
), [A, U] = fe(L), m = p( ), [A, U] = me(L), m = p(
(n) => { (n) => {
U((i) => { U((i) => {
const u = typeof n == "function" ? n(i) : n; const u = typeof n == "function" ? n(i) : n;
@ -43,11 +43,11 @@ function xe({
}); });
}, },
[k] [k]
), M = ge({ ), M = fe({
page: d, page: d,
size: h size: h
}); });
he(() => { ge(() => {
if (!b) if (!b)
return; return;
const n = M.current, i = n.page !== d || n.size !== h; const n = M.current, i = n.page !== d || n.size !== h;

View File

@ -13,6 +13,7 @@
"./table": "./dist/table.js", "./table": "./dist/table.js",
"./form": "./dist/form.js" "./form": "./dist/form.js"
}, },
"sideEffects": false,
"files": [ "files": [
"dist" "dist"
], ],

View File

@ -29,7 +29,11 @@ const createApi = (config) => {
// request interceptors // request interceptors
const shouldUseAuth = Boolean(config.keycloak);
const handleAuthRequestInterceptor = async (config) => { const handleAuthRequestInterceptor = async (config) => {
if (!shouldUseAuth) return config;
await waitForKeycloak(); await waitForKeycloak();
let token = getKeycloakToken(); let token = getKeycloakToken();