This commit is contained in:
what 2024-11-01 14:29:34 +08:00
parent 790a9e4117
commit abbca42e21
16 changed files with 939 additions and 931 deletions

2
dist/button.js vendored
View File

@ -1,4 +1,4 @@
import { P as s, O as u, Q as e } from "./common/main-19SFdrvj.js";
import { P as s, O as u, Q as e } from "./common/main-DJpuXYIP.js";
import "prop-types";
export {
s as auth,

View File

@ -1,912 +0,0 @@
var ga = Object.defineProperty;
var $t = (e) => {
throw TypeError(e);
};
var pa = (e, t, a) => t in e ? ga(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
var k = (e, t, a) => pa(e, typeof t != "symbol" ? t + "" : t, a), xt = (e, t, a) => t.has(e) || $t("Cannot " + a);
var p = (e, t, a) => (xt(e, t, "read from private field"), a ? a.call(e) : t.get(e)), F = (e, t, a) => t.has(e) ? $t("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, a), B = (e, t, a, n) => (xt(e, t, "write to private field"), n ? n.call(e, a) : t.set(e, a), a);
var Et = (e, t, a, n) => ({
set _(i) {
B(e, t, i, a);
},
get _() {
return p(e, t, n);
}
});
import { jsx as c, jsxs as N } from "react/jsx-runtime";
import C, { useEffect as $, useState as P, useCallback as ge, useMemo as pe, useContext as Ge, useRef as Q, useId as Dt, useLayoutEffect as ma } from "react";
import g from "lodash";
import R from "classnames";
import { Form as Ze, Input as ha, Button as lt, Breadcrumb as fa, Tree as ya, Pagination as wa, Table as Ca, Empty as ba, Popconfirm as ka, Tooltip as va, Popover as Sa } from "antd";
import { useMergedState as Pa } from "rc-util";
import re, { FieldContext as Na, Field as Wt } from "rc-field-form";
import { useParams as $a, generatePath as xa, createBrowserRouter as Ea, useInRouterContext as Ta, Navigate as Fa } from "react-router-dom";
import O from "prop-types";
import "react-is";
import { useNotification as Ra } from "rc-notification";
import { N as Be, a as Ue, w as ct, S as Oa } from "./vender-DDOSHWIo.js";
import Tt from "immutability-helper";
import La from "rc-drawer";
import Va from "rc-dialog";
const Ft = { null2json: (e) => Object.create(), null2array: (e) => [], null2number: (e) => 0, null2bool: (e) => !1, null2string: (e) => "", null2integer: (e) => 0, null2float: (e) => 0, string2json: (e) => e ? JSON.parse(e) : "{}", string2array: (e) => e.substr(0, 1) === "[" && e.substr(-1) === "]" ? JSON.parse(e) : e.split(","), string2number: (e) => e == "" ? 0 : +e, string2integer: (e) => e == "" ? 0 : +e, string2float: (e) => e == "" ? 0 : +e, string2bool: (e) => {
switch (`${e}`.toLowerCase()) {
case "0":
case "false":
case "[]":
case "{}":
return !1;
}
return !!e;
}, string2string: (e) => e, json2json: (e) => e, json2array: (e) => e ? Object.values(e) : [], json2number: (e) => Object.keys(e).length, json2integer: (e) => Object.keys(e).length, json2float: (e) => Object.keys(e).length, json2bool: (e) => Object.keys(e).length > 0, json2string: (e) => e ? JSON.stringify(e) : "", array2json: (e) => ({ ...e }), array2array: (e) => e, array2number: (e) => e.length, array2integer: (e) => e.length, array2float: (e) => e.length, array2bool: (e) => e.length > 0, array2string: (e) => JSON.stringify(e), number2json: (e) => ({}), number2array: (e) => [e], number2number: (e) => e, number2integer: (e) => e, number2float: (e) => e, number2bool: (e) => !!e, number2string: (e) => e.toString(), boolean2json: (e) => ({}), boolean2array: (e) => [], boolean2number: (e) => +e, boolean2integer: (e) => +e, boolean2float: (e) => +e, boolean2bool: (e) => e, boolean2string: (e) => e ? "true" : "false" }, qt = (e, t) => g.flatMap(g.toPairs(e), ([a, n]) => g.isObjectLike(n) ? qt(n, a) : [[`${g.isUndefined(t) ? "" : t + "."}${a}`, n]]), Ht = (e, t = () => !1) => g.some(e, (a) => !!g.some(a, t) || (g.isEmpty(a) || !g.isPlainObject(a) && !g.isArray(a) ? void 0 : Ht(a, t))), et = (e, t) => e && typeof e == "object" ? Array.isArray(e) ? e.map((a) => et(a, t)) : Object.keys(e).reduce((a, n) => (t[n] ? a[t[n]] = et(e[n], t) : a[n] = et(e[n], t), a), {}) : e;
g.mixin({ toPrimitive: (e, t) => {
let a = "string";
a = Array.isArray(e) ? "array" : typeof e, g.isObject(e) && (a = "json");
const n = `${a}2${t}`;
return Reflect.has(Ft, n) ? Ft[n](e) : e;
}, toPairsDeep: qt, deepSome: Ht, replaceKeys: et });
var Ie, qe, Ae, de, Fe, Re;
class Jt {
constructor(t, a) {
F(this, Ie, /* @__PURE__ */ new Map());
F(this, qe, !0);
F(this, Ae, []);
F(this, de);
F(this, Fe, () => p(this, de));
F(this, Re, () => Promise.resolve());
k(this, "get", (...t) => new Promise((a, n) => {
const i = JSON.stringify(t);
if (p(this, Ie).has(i)) return a(p(this, Re).call(this, p(this, de), ...t));
if (p(this, de) === void 0) p(this, Ae).push([t, a, n]), p(this, qe) && (B(this, qe, !1), Promise.resolve(typeof p(this, Fe) == "function" ? p(this, Fe).call(this) : p(this, Fe)).then((r) => B(this, de, r || null)).finally(() => {
p(this, Ae).forEach(([r, s, o]) => {
try {
const l = p(this, Re).call(this, p(this, de), ...r);
p(this, Ie).set(JSON.stringify(r), l), s(l);
} catch (l) {
o(l);
}
}), p(this, Ae).length = 0;
}));
else {
const r = p(this, Re).call(this, p(this, de), ...t);
p(this, Ie).set(i, r), a(r);
}
}));
B(this, Re, a), B(this, Fe, t);
}
}
Ie = new WeakMap(), qe = new WeakMap(), Ae = new WeakMap(), de = new WeakMap(), Fe = new WeakMap(), Re = new WeakMap();
const Dn = () => c("div", { children: "Empty" }), _e = C.createContext({ ele: {}, mount: () => {
}, unmount: () => {
} }), J = ({ rootClassName: e, className: t, children: a, actions: n, title: i, subTitle: r, extras: s, style: o = {} }) => {
const { mount: l, unmount: u } = C.useContext(_e);
return n && J.Action({ children: n }), i && J.Title({ children: i }), r && J.SubTitle({ children: r }), s && J.Extra({ children: s }), $(() => (l("rootClassName", e), () => u(e)), [e]), c("div", { className: R("ff-container", t), style: o, children: a });
}, Xe = (e) => ({ children: t, className: a }) => {
const { mount: n, unmount: i } = C.useContext(_e);
return $(() => (n(e, C.createElement("div", { key: `ff-${e}`, className: R(`ff-popup-${e}`, a) }, t)), () => i(e)), [a, t]), null;
};
J.Action = Xe("actions"), J.Title = Xe("title"), J.SubTitle = Xe("sub-title"), J.Extra = Xe("extras"), J.propTypes = { className: O.string, style: O.object, title: O.any, subTitle: O.any, actions: O.any, extras: O.any };
const Wn = () => c(J, { className: "ff-loading", children: N("div", { className: "loader", children: [N("div", { className: "square", children: [c("span", {}), c("span", {}), c("span", {})] }), N("div", { className: "square", children: [c("span", {}), c("span", {}), c("span", {})] }), N("div", { className: "square", children: [c("span", {}), c("span", {}), c("span", {})] }), N("div", { className: "square", children: [c("span", {}), c("span", {}), c("span", {})] })] }) }), qn = () => c("div", { children: "NotFound" }), Kt = ({ children: e }) => {
const [t, a] = P({}), n = ge((r, s) => a((o) => ({ ...o, [r]: s })), []), i = ge((r) => a((s) => ({ ...s, [r]: void 0 })), []);
return typeof (e == null ? void 0 : e.type) == "string" ? e : c(_e.Provider, { value: { ele: t, mount: n, unmount: i }, children: C.cloneElement(e, { className: t.rootClassName, title: t.title, subTitle: t["sub-title"], actions: t.actions, extras: t.extras }) });
};
Kt.propTypes = { children: O.element.isRequired };
const Rt = { close: ["M563.8 512l262.5-312.9c4.4-5.2 0.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9c-4.4 5.2-0.7 13.1 6.1 13.1h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"], check: ["M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474c-6.1-7.7-15.3-12.2-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"], info: ["M512 224m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z", "M544 392h-64c-4.4 0-8 3.6-8 8v464c0 4.4 3.6 8 8 8h64c4.4 0 8-3.6 8-8V400c0-4.4-3.6-8-8-8z"] }, bt = ({ type: e, props: t }) => c("i", { ...t, children: c("svg", { viewBox: "0 0 1024 1024", width: "1em", height: "1em", fill: "currentColor", children: (Rt[e] || Rt.info).map((a, n) => c("path", { d: a }, n)) }) }), Gt = ({ className: e, content: t, icon: a, $close: n }) => N(C.Fragment, { children: [a && c("div", { className: R("ff-notification-icon", e), children: c(bt, { type: a }) }), t] }), ja = ({}) => c(J, { children: "Confirm" });
var fe, Me;
const ee = class ee {
constructor() {
F(this, Me, null);
k(this, "init", (t) => B(this, Me, new Map(t)));
k(this, "check", (t) => !p(this, Me).has(t) || p(this, Me).get(t));
if (p(ee, fe)) return p(ee, fe);
}
};
fe = new WeakMap(), Me = new WeakMap(), F(ee, fe, null), k(ee, "getInstance", () => (p(ee, fe) || B(ee, fe, new ee()), p(ee, fe)));
let dt = ee;
const Ia = dt.getInstance(), _t = (e = {}, t = {}, a = {}, n = "") => g.deepSome(e, (i, r) => r === "type" && i === "code") ? Yt(e, t, a, n) : Qt(e, t, n), Yt = async (e = {}, t = {}, a = {}, n = "") => {
let i = /* @__PURE__ */ Object.create(null);
for (let r in e) {
let s;
if (Reflect.has(e[r], "type") && ["code", "field", "router", "query", "string"].includes(e[r].type)) {
const { type: o, value: l = "", default: u = n } = e[r];
switch (o) {
case "code":
s = await Ne.exec(l, t, a);
break;
case "field":
s = g.get(t, l) ?? g.get(t, l.substring(l.indexOf(".") + 1));
break;
case "router":
case "query":
s = Pe.getPageParams(l);
break;
case "string":
s = l;
}
s ?? (s = u);
} else s = await Yt(e[r], t, a, n);
g.set(i, r, s);
}
return i;
}, Qt = (e = {}, t = {}, a = "") => Object.keys(e || {}).reduce((n, i) => {
if (g.isPlainObject(e[i])) {
let r;
if (Reflect.has(e[i], "type") && ["field", "router", "query", "string"].includes(e[i].type)) {
const { type: s, value: o = "", default: l = a } = e[i];
switch (s) {
case "field":
r = g.get(t, o) ?? g.get(t, o.substring(o.indexOf(".") + 1));
break;
case "router":
case "query":
r = Pe.getPageParams(o);
break;
case "string":
r = o;
}
r ?? (r = l);
} else r = Qt(e[i], t, a);
g.set(n, i, r);
}
return n;
}, {});
var ye, He;
const te = class te {
constructor() {
F(this, He, null);
k(this, "init", (t) => B(this, He, t));
k(this, "get", (t, a) => g.get(p(this, He), t, a));
if (p(te, ye)) return p(te, ye);
}
};
ye = new WeakMap(), He = new WeakMap(), F(te, ye, null), k(te, "getInstance", () => (p(te, ye) || B(te, ye, new te()), p(te, ye)));
let ut = te;
const De = ut.getInstance(), Aa = (e, t, a, n, i) => {
const r = C.lazy(() => X.getWidgetComponent(e).catch((s) => ({ default: () => `${s}` })));
return c(C.Suspense, { children: c(r, { value: t, record: a, $setting: n, base62params: i }) }, e);
}, Ma = (e, t = {}) => (jt(e), jt(t), pe(() => e == null ? void 0 : e.map(({ widgetByJs: a, widgetByJsSetting: n, ...i }, r) => a && !a.endsWith("/BasicShowFieldData") ? { ...i, render: (s, o) => {
const l = Aa(a, s, o, n, t);
return g.isFunction(i == null ? void 0 : i.render) ? i.render(l, s, o) : l;
} } : i), [e, t])), Hn = (e) => {
const [t, a] = P({});
return $(() => {
let n = !1;
return e && x.get(`/api/_/${e}`).then((i) => g.pick(i, ["uuid", "name", "code", "resource", "marginX", "marginY", "cols", "rowHeight", "primaryKey", "columns", "itemOperations", "batchOperations", "isConditionFormLayout", "layout", "tabs", "pageSize", "layoutConfig"])).then((i) => !n && a(i)), () => n = !0;
}, [e]), t;
}, Jn = (e, t = {}) => {
const [a, n] = P({ dataSource: [] });
return Ye(() => {
let i = !1;
return e && x.get(`/api/${e}/${x.encode({ page: 1, ...t })}`).then((r) => !i && n(r)), () => i = !0;
}, [e, t]), a;
}, gt = (e, t = null, a = null, n = "id") => pe(() => {
if (g.isEmpty(e) || !e.every(({ uuid: r }) => Ia.check(r))) return !1;
if (g.isEmpty(a) || g.isEmpty(t)) return !0;
const i = t.map((r) => r == null ? void 0 : r[n]);
return e.some(({ uuid: r }) => !r || !a.has(r) || a.get(r).some((s) => i.includes(s)));
}, [e, t, a, n]), za = ({ className: e, itemClassName: t, classNames: a = {}, dataSource: n, isPaginate: i, isItemOperations: r, isBatchOperations: s, batchOperations: o, itemOperations: l, itemOperationsAccess: u, resource: d, primaryKey: m, title: f, itemGridLayout: h, $setting: y, tabs: b, isConditionFormLayout: w, isTreeSider: E, treeSiderConfig: z }) => {
const { getBase62params: q, onClickCallback: D, onTabChange: W } = Ge(Le), { total: A, page: L, pageSize: K, tab: M } = (q == null ? void 0 : q()) || {}, G = ge((j, v, se) => c(Ba, { className: R("ff-data-list-framework-item", t), operations: r && v ? l == null ? void 0 : l.filter((V) => !(m && V.uuid && u.has(V.uuid)) || u.get(V.uuid).includes(v == null ? void 0 : v[m])) : [], data: d ? { [d]: v } : v, children: j, onClickCallback: D }), [d, m, r, D, l, u]);
return N("div", { className: R("ff-data-list-framework", e), children: [c(ta, { className: a == null ? void 0 : a.sider, isTreeSider: E, ...z }), N("div", { className: R("ff-data-list-container", a == null ? void 0 : a.container), children: [c(vt, { className: a == null ? void 0 : a.filter, isConditionFormLayout: w }), c(ea, { title: f, className: a == null ? void 0 : a.toolbar, tabs: b, tab: M, onTabChange: W }), c(Ya, { ...h, className: a == null ? void 0 : a.content, style: { "--col-num": (y == null ? void 0 : y.colNum) || 1 }, primaryKey: m, itemRender: G, dataSource: n }), c(aa, { className: a == null ? void 0 : a.footer, isPaginate: i, isOperations: s, operations: o, total: A, page: L, pageSize: K })] })] });
}, Ba = ({ className: e, operations: t, children: a, data: n, onClickCallback: i }) => N("div", { className: R("data-list-grid-layout-item-container", e), children: [a, !!(t != null && t.length) && c("div", { className: "data-list-grid-layout-item-actions", children: t.map((r) => c("span", { className: "data-list-grid-layout-item-action", children: c(S.Link, { uuid: r.uuid, type: r.type, name: r.name, widget: r.widget, widgetType: r.widgetType, widgetProps: r.widgetProps, widgetSetting: r.widgetSetting, widgetContainerProps: r.widgetContainerSetting, data: n, onAfterClick: (s) => s !== !1 && (i == null ? void 0 : i(r.isRefresh, n)) }, r.uuid || useId()) }, (r == null ? void 0 : r.uuid) || useId())) })] }), Ua = ({ listCode: e, className: t, classNames: a = {}, itemClassName: n, dataSource: i, columns: r, isItemOperations: s, isBatchOperations: o, batchOperations: l, itemOperations: u, itemOperationsAccess: d, resource: m, primaryKey: f, title: h, tabs: y, isPaginate: b, isTreeSider: w, treeSiderConfig: E, isConditionFormLayout: z, ...q }) => {
const { getBase62params: D, onClickCallback: W, onTabChange: A } = Ge(Le), { total: L, page: K, tab: M, pageSize: G } = (D == null ? void 0 : D()) || {}, j = gt(u, i, d, f);
return N("div", { className: R("ff-data-table-framework", t), children: [c(ta, { className: a == null ? void 0 : a.sider, isTreeSider: w, ...E }), N("div", { className: R("ff-data-table-container", a == null ? void 0 : a.container), children: [c(vt, { listCode: e, isConditionFormLayout: z }), c(ea, { title: h, className: a == null ? void 0 : a.toolbar, tabs: y, tab: M, onTabChange: A }), c(Ha, { ...q, className: "ff-data-table-content", columns: r, dataSource: i, operationRender: j ? (v) => c("div", { className: "ff-data-table-actions", children: u == null ? void 0 : u.reduce((se, V, me) => [...se, c(S.Link, { size: "small", uuid: V.uuid, type: V.type, name: V.name, widget: V.widget, widgetType: V.widgetType, widgetProps: V.widgetProps, widgetData: V.widgetData, widgetSetting: V.widgetSetting, widgetContainerProps: V.widgetContainerSetting, data: v, onAfterClick: ($e) => $e !== !1 && (W == null ? void 0 : W(V.isRefresh, data)) }, V.uuid || me)], []) }) : null }), c(aa, { isPaginate: b, isOperations: o, operations: l, total: L, page: K, pageSize: G })] })] });
}, Le = C.createContext({ listCode: "", getBase62params: (e, t) => {
}, onReload: () => {
}, onClickCallback: () => {
}, onConditonChange: () => {
}, onTabChange: () => {
}, onSiderChange: () => {
}, onKeywordChange: () => {
}, onPageChange: () => {
}, onPageSizeChange: () => {
} }), Da = ({ isItemGridLayout: e, theme: t, themeProps: a, onClickCallback: n, onReload: i, getBase62params: r, listCode: s, onPageChange: o, onPageSizeChange: l, onTabChange: u, onSiderChange: d, onKeywordChange: m, onConditonChange: f, ...h }) => {
const [y, b] = P();
return $(() => {
t ? X.getWidgetComponent(t).then((w) => {
if (!w) throw `${t} not found`;
return w;
}).catch((w) => ({ default: () => `${w}` })).then((w) => b(C.createElement(w.default, { ...h, $setting: a }))) : y || b(null);
}, [t, a]), c(Le.Provider, { value: { listCode: s, onClickCallback: n, onReload: i, getBase62params: r, onPageChange: o, onPageSizeChange: l, onTabChange: u, onSiderChange: d, onKeywordChange: m, onConditonChange: f }, children: y ? C.cloneElement(y, { ...h, $setting: a }) : c(e ? za : Ua, { ...h, $setting: a }) });
};
var we, ue, Oe, at;
const ae = class ae {
constructor() {
F(this, ue, null);
F(this, Oe, /* @__PURE__ */ new Map());
F(this, at, () => {
if (p(this, ue)) return p(this, ue).port.postMessage({ command: "status", data: [] });
B(this, ue, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), p(this, ue).port.onmessage = (t) => {
var a, n;
(a = t.data) != null && a.uuid ? p(this, Oe).forEach((i, r) => {
var s;
(i == "*" || (s = i == null ? void 0 : i.includes) != null && s.call(i, t.data.uuid)) && r(t.data);
}) : ((n = t.data) == null ? void 0 : n.readyState) == WebSocket.CLOSED && x.get("/api/user-api-token").then(({ token: i, expire_at: r }) => {
p(this, ue).port.postMessage({ command: "initWs", data: [`ws${g.trimStart(x.appUrl, "http")}api/user-resource-status-ws?token=${i}`] });
});
}, p(this, ue).port.postMessage({ command: "status", data: [] });
});
k(this, "subscribe", (t, a = []) => (a ? Array.isArray(a) && a.length == 0 ? a = "*" : Array.isArray(a) || (a = [a].flat()) : a = "*", p(this, Oe).set(t, a), p(this, Oe).size == 1 && p(this, at).call(this), () => this.unsubscribe(t)));
k(this, "unsubscribe", (t) => p(this, Oe).delete(t));
if (p(ae, we)) return p(ae, we);
}
};
we = new WeakMap(), ue = new WeakMap(), Oe = new WeakMap(), at = new WeakMap(), F(ae, we, null), k(ae, "getInstance", () => (p(ae, we) || B(ae, we, new ae()), p(ae, we)));
let pt = ae;
const Xt = pt.getInstance(), kt = C.forwardRef(({ listCode: e, base62params: t, className: a, itemClassName: n, theme: i, themeProps: r, classNames: s }, o) => {
const l = oa(), u = Q(t), d = Q(/* @__PURE__ */ new Map()), m = Q([]), [{ resource: f, primaryKey: h, batchOperations: y = [], itemOperations: b = [], columns: w = [], themeConfig: E, theme: z, isConditionFormLayout: q = !1, isTreeSider: D, treeSiderConfig: W, isItemGridLayout: A, itemGridLayout: L, title: K, isPaginate: M, tabs: G }, j] = P({ isItemGridLayout: !1, itemGridLayout: {} }), v = g.throttle((T) => {
m.current = [], x.list(e, g.pick({ ...u.current, ...T }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: U, condition: Ve, total: xe, tab: he, sider: Ee, page: oe, pageSize: le, operationsAccess: ce, dataSource: Te }) => {
u.current = { tab: he, condition: Ve, sider: Ee, keyword: U, total: xe, pageSize: le, page: Te != null && Te.length ? oe : 1 }, m.current = Te, d.current = new Map(ce), l();
});
}, 380, { leading: !1, trailing: !0 }), se = gt(b, m.current, d.current, h), V = gt(y);
$(() => {
let T = null;
return e && x.get(`/api/_/${e}`).resp(({ data: U, res: Ve }) => {
U != null && U.isDynamicRefresh && (T = Xt.subscribe(() => v(), Ve)), u.current.pageSize = U.pageSize, j(U);
}).catch(() => j({})), () => T == null ? void 0 : T();
}, [e]), tn(() => {
e && v(t);
}, [e, t]);
const me = () => {
v();
}, $e = (T = 0, U = null) => {
if (T === 2) {
const Ve = g.get(U, "__PARENT_ID__", ""), xe = g.get(U, h, g.get(U, [f, h], "")), he = g.findIndex(m.current, ["__PARENT_ID__", Ve]), Ee = g.findIndex(he > -1 ? g.get(m.current, [he, "children"]) : m.current, [h, xe]);
Ee > -1 ? (x.get(`/api/${e}/detail/${xe}`).then((oe) => {
const le = g.get(m.current, he > -1 ? [he, "children", Ee, "children"] : [Ee, "children"]);
m.current = Tt(m.current, he > -1 ? { [he]: { children: { $splice: [[Ee, 1, { ...oe, children: le }]] } } } : { $splice: [[Ee, 1, { ...oe, children: le }]] }), l();
}), x.post(`/api/${e}/list-operations-access`, { ids: xe }).then((oe) => new Map(oe)).then((oe) => {
d.current.forEach((le, ce) => {
var Te;
(Te = oe.get(ce)) != null && Te.some((rt) => rt == xe) || d.current.set(ce, le.filter((rt) => rt !== xe));
}), oe.forEach((le, ce) => {
d.current.has(ce) ? d.current.set(ce, g.uniq([...d.current.get(ce) || [], ...le])) : d.current.set(ce, le);
}), l();
})) : me();
} else T === 1 && me();
};
C.useImperativeHandle(o, () => ({ onReload: me, onClickCallback: $e }));
const it = { listCode: e, title: K, itemClassName: n, classNames: s, resource: f, primaryKey: h, theme: i || z, themeProps: r || E, isTreeSider: D, treeSiderConfig: W, isPaginate: M, tabs: G, isItemOperations: se, isBatchOperations: V, batchOperations: y, itemOperations: b, isItemGridLayout: A, columns: w, itemGridLayout: L, isConditionFormLayout: q, itemOperationsAccess: d.current, dataSource: m.current };
return c(Da, { ...it, className: R("ff-data-list-helper", a), getBase62params: (T, U, Ve = !1) => T == "init" ? t : T ? g.get(u.current, T, U) : u.current, onReload: me, onClickCallback: $e, onConditonChange: (T, U) => v({ keyword: U, condition: Tt(u.current.condition || {}, { $merge: T || {} }), page: 1 }), onTabChange: (T) => v({ tab: T, page: 1 }), onSiderChange: (T) => v({ sider: T, page: 1 }), onKeywordChange: (T) => v({ keyword: T, page: 1 }), onPageChange: (T, U) => v({ page: T, pageSize: U }), onPageSizeChange: (T) => v({ pageSize: T, page: 1 }) });
}), Zt = (e, t, a, n, i = {}, r = 0) => {
const s = { "--grid-layout-h": `${n}`, "--grid-layout-w": `${a}`, "--grid-layout-x": `${e}`, "--grid-layout-y": `${t}`, "--grid-layout-row-height-offset": "0px" };
return i != null && i.autoHeight ? s.height = "fit-content" : s["--grid-layout-row"] = `${n}`, s["--grid-layout-box-margin"] = Ot(i == null ? void 0 : i.marginTop, i == null ? void 0 : i.marginRight, i == null ? void 0 : i.marginBottom, i == null ? void 0 : i.marginLeft), s["--grid-layout-box-padding"] = Ot(i == null ? void 0 : i.paddingTop, i == null ? void 0 : i.paddingRight, i == null ? void 0 : i.paddingBottom, i == null ? void 0 : i.paddingLeft), r && (s.height = `${r}px`), s;
}, Ot = (e, t, a, n) => `${e || 0}px ${t || 0}px ${a || 0}px ${n || 0}px`, vt = ({ className: e, isConditionFormLayout: t }) => {
var m, f;
const [a, n] = P({}), { listCode: i, onKeywordChange: r, onConditonChange: s, getBase62params: o } = C.useContext(Le), { keyword: l, condition: u } = (o == null ? void 0 : o()) || {}, [d] = Ze.useForm();
return $(() => {
i && t && x.get(`/api/_/${i}/list-condition-form-layout`).then(({ resource: h, marginX: y, marginY: b, rowHeight: w, cols: E, fields: z }) => {
n({ resource: h, itemMargin: [y, b], rowHeight: w, cols: E, fields: z });
}).catch(() => n({}));
}, [i, t]), $(() => {
d.setFieldsValue({ keyword: l, ...u });
}, [JSON.stringify([l, u])]), c("div", { className: R("ff-data-list-filter", e), children: c(Ze, { form: d, layout: "vertical", autoComplete: "off", onFinish: ((m = a.fields) == null ? void 0 : m.length) > 1 ? (h) => s({ [a.resource]: h[a.resource] }, h.keyword) : () => {
}, onValuesChange: (h) => {
g.isEmpty(g.omit(h, ["keyword"])) || d.submit();
}, children: ((f = a.fields) == null ? void 0 : f.length) > 1 ? c(St, { ...a, children: c(Wa, { onReset: () => {
const { keyword: h, condition: y } = o("init") || {};
d.setFieldsValue({ keyword: h, ...y });
} }) }) : c("div", { className: "ff-data-list-filter-default-form ff-grid-layout-form", children: c("div", { className: "grid-layout-item", style: Zt(20, 0, 5, 2), children: c(Ze.Item, { name: ["keyword"], children: c(ha.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (h) => r(h) }) }) }) }) }) });
}, Wa = ({ cols: e, fields: t, onReset: a }) => {
const [n, i] = P(!1), r = pe(() => t == null ? void 0 : t.toReversed().some((s) => s.y > 1 || s.x + s.w >= e - 5), [e, t]);
return N(Ze.Item, { label: " ", style: { "--item-span": 5 }, className: R("ff-data-list-filter-actions", { expanded: n }), children: [c(lt, { onClick: a, children: "重置" }), c(lt, { type: "primary", htmlType: "submit", children: "查询" }), r && c(S.Link, { className: "ff-data-list-filter-expanded-button", widget: () => i((s) => !s), type: "primary", name: n ? "关闭" : "展开", icon: n ? "icon-up" : "icon-down", iconPosition: "end" })] });
};
vt.reservedFields = [{ x: 0, y: 0, h: 3, w: 5, field: { isVirtual: !0, widgetPrefix: "@pkg/grid-layout-forms", widget: "Input", code: "keyword", label: "关键字", placeholder: "多关键字 | 分割", extras: { prefix: "icon-search" } } }];
const ea = ({ className: e, title: t, tabs: a, tab: n, onTabChange: i }) => {
const [r, s] = Pa(a == null ? void 0 : a[0].value, { value: n, onChange: i });
return N("div", { className: R("ff-data-list-toolbar", e), children: [c("div", { className: "ff-data-list-title", children: t }), c(fa, { className: "ff-data-list-tabs", itemRender: ({ label: o, code: l }) => c("span", { onClick: () => s(l), className: R("ff-data-list-tab", { active: l == r }), children: o }), items: a }), N("div", { className: "ff-data-list-actions", children: [c(S.Link, { icon: "icon-reload" }), c(S.Link, { icon: "icon-setting" })] })] });
}, qa = [{ title: "parent 1", key: "0-0", children: [{ title: "parent 1-0", key: "0-0-0", disabled: !0, children: [{ title: "leaf", key: "0-0-0-0", disableCheckbox: !0 }, { title: "leaf", key: "0-0-0-1" }] }, { title: "parent 1-1", key: "0-0-1", children: [{ title: c("span", { style: { color: "#1677ff" }, children: "sss" }), key: "0-0-1-0" }] }] }], ta = ({ className: e, width: t = 280, isTreeSider: a }) => a ? c(ya.DirectoryTree, { className: R("ff-data-list-sider", e), style: { "--sider-width": t }, showLine: !0, showIcon: !1, treeData: qa }) : null, aa = ({ className: e, operations: t, isOperations: a, isPaginate: n, total: i, page: r, pageSize: s }) => {
const { onPageChange: o, onPageSizeChange: l, onClickCallback: u } = C.useContext(Le);
return a && !g.isEmpty(t) || n ? N("div", { className: R("ff-data-list-footer", e), children: [c("div", { className: "ff-data-list-actions", children: t == null ? void 0 : t.map((d, m) => c(S, { uuid: d.uuid, type: d.type, name: d.name, widget: d.widget, widgetType: d.widgetType, widgetProps: d.widgetProps, widgetData: d.widgetData, widgetSetting: d.widgetSetting, widgetContainerProps: d.widgetContainerSetting, onAfterClick: (f) => f !== !1 && (u == null ? void 0 : u(d.isRefresh, null)) }, d.uuid || m)) }), n && c(wa, { size: "small", total: i, pageSize: s, showSizeChanger: !1, showTotal: (d) => `${r} 页 / 总共 ${d}`, onChange: o, onShowSizeChange: l })] }) : null;
}, na = (e, t, a = !0) => a !== !0 && a-- <= 0 ? [] : g.isArray(e) && !g.isEmpty(e) ? e.reduce((n, i) => (Reflect.has(i, t) && Reflect.has(i, "children") && n.push(i[t]), Reflect.has(i, "children") && !g.isEmpty(i.children) ? n.concat(na(i.children, t, a)) : n), []) : [], Ha = ({ className: e, primaryKey: t, columns: a = [], dataSource: n = [], operationRender: i, operationWidth: r = 180, ...s }) => {
Dt();
const o = Q(null), l = Q(null), [u, d] = P([]), [m, f] = P({ width: 0, height: 0 });
$(() => {
d(na(n, t));
}, [n, t]), ma(() => {
const y = new ResizeObserver(() => {
var b;
f({ width: ((b = o.current) == null ? void 0 : b.nativeElement.querySelector(".ant-table-body").scrollWidth) || l.current.offsetWidth, height: l.current.offsetHeight });
});
return l.current && y.observe(l.current), () => {
l.current && y.unobserve(l.current);
};
}, []);
const h = Ma(a);
return c("div", { ref: l, className: R("ff-data-list-table", e), children: m.height ? c(Ca, { ...s, ref: o, rowKey: (y) => (y == null ? void 0 : y[t]) ?? Math.random(), columns: h == null ? void 0 : h.concat(i ? [{ title: "操作", align: "center", fixed: "right", width: `${Math.ceil(r / m.width * 100).toFixed(2)}%`, render: (y, b, w) => i(b, w) }] : []), dataSource: n, size: "middle", scroll: { x: "max-content", y: m.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: d, expandedRowKeys: u } }) : null });
}, Ja = "RC_FORM_INTERNAL_HOOKS", ia = (e, { initialValue: t, initialValueLanguage: a, convertJs: n, convertJsSetting: i, type: r = "string" }, s = null) => {
const o = Q(!1), l = Ge(Na), [u, d] = P(), [m, f] = P(a != "javascript" && e ? l.getFieldValue(e) : void 0), { registerWatch: h } = l.getInternalHooks(Ja) || {};
return $(() => h == null ? void 0 : h((y, b, w) => {
if (!o.current) return;
const E = g.get(b, e);
g.isEqual(E, m) || f(g.toPrimitive(E, r));
}), [m]), $(() => {
a == "javascript" && t ? Ne.exec(t, {}, { getFieldValueForBasicForm: (y) => s ? s.getFieldValue(y) : l.getFieldValue(y), getFieldValue: (y) => l.getFieldValue(y) }).then((y) => f(g.toPrimitive(y, r))).catch((y) => notification.error({ message: `布局数据错误: ${JSON.stringify(y)}` })).finally(() => o.current = !0) : (t && f(g.toPrimitive(t ?? l.getFieldValue(e), r)), o.current = !0);
}, [t, a]), Ye(() => {
o.current && n && X.getWidgetComponent(n).then(({ default: y }) => y({ value: m, record: l.getFieldsValue(!0), $setting: i })).then(d).catch((y) => console.error("布局数据转换错误: ", y, n));
}, [m, n, i]), [u || m, m];
}, ra = (e, t, a = "@pkg/grid-layouts", n = null) => pe(() => {
var i;
return (i = g.sortBy(e, ["y", "x"])) == null ? void 0 : i.map(({ i: r, x: s, y: o, w: l, h: u, field: { boxStyle: d, widgetPrefix: m = a, widget: f, ...h } }, y) => c("div", { className: "grid-layout-item", style: Zt(s, o, l, u, d, f === "Height" && (h == null ? void 0 : h.initialValue)), children: c(Ka, { ...h, basicForm: n, itemWidget: f != null && f.startsWith("@") ? f : `${m}/${f}`, itemWidgetRender: t }) }, r || y));
}, [e]), Ka = ({ itemWidget: e, itemWidgetRender: t, basicForm: a, ...n }) => {
const [i, r] = P();
return $(() => {
X.getWidgetComponent(e).then(({ defaultProps: s = {}, default: o }) => {
r(C.createElement(t(o, s, a), n));
}).catch((s) => {
console.error(s), r(e);
});
}, [e]), i;
}, sa = ({ cols: e = 12, rowHeight: t = 21, fields: a = [], data: n, containerPadding: i = [0, 0], itemMargin: r = [4, 0], formProps: s = {}, className: o, ...l }) => {
const [u] = re.useForm(), d = ra(a, Ga, "@pkg/grid-layouts"), m = pe(() => [{ name: "__PROPS__", value: s }], [s]);
return Ye(() => {
u.setFieldsValue(n);
}, [n]), c(re, { fields: m, form: u, component: !1, children: c("div", { ...l, className: R("ff-grid-layout", o), style: { "--grid-layout-item-margin-y": `${(r == null ? void 0 : r[0]) || 0}px`, "--grid-layout-item-margin-x": `${(r == null ? void 0 : r[1]) || 0}px`, "--grid-layout-container-padding-y": `${(i == null ? void 0 : i[0]) || 0}px`, "--grid-layout-container-padding-x": `${(i == null ? void 0 : i[1]) || 0}px`, "--grid-layout-cols": e, "--grid-layout-row-height": `${t}px` }, children: d }) });
}, Ga = (e, t = {}, a = null) => (n) => {
const { code: i, label: r, extras: s, isVirtual: o, initialValue: l, initialValueLanguage: u, convertJs: d, convertJsSetting: m, ...f } = g.merge({}, t, n), [h, y] = ia(o ? null : i, { initialValue: l, initialValueLanguage: u, convertJs: d, convertJsSetting: m, type: (f == null ? void 0 : f.type) || "string" }, a);
return c(e, { ...f, value: h, rawValue: y, $setting: s || {} });
}, Kn = (Lt = sa, function({ code: e, data: t, ...a }) {
const [n, i] = P({ resource: null, cols: 12, rowHeight: 21, fields: [] });
return $(() => {
e && x.get(`/api/_/${e}`).then((r) => i(g.pick(r, ["resource", "cols", "rowHeight", "fields"])));
}, [e]), (n == null ? void 0 : n.resource) && c(Lt, { ...a, rowHeight: n.rowHeight, cols: n.cols, fields: n.fields, data: n != null && n.resource ? { [n == null ? void 0 : n.resource]: t } : {} });
});
var Lt;
const Gn = ({ widget: e, widgetPrefix: t = "@pkg/grid-layouts", basicForm: a, ...n }) => {
const i = e != null && e.startsWith("@") ? e : `${t}/${e}`, [r, s] = P();
return $(() => {
i && X.getWidgetComponent(i).then(({ defaultProps: o = {}, default: l }) => ({ default: _a(l, o, a) })).catch((o) => ({ default: () => `${o}` })).then((o) => s(C.createElement(o.default, n)));
}, [i]), r;
}, _a = (e, t = {}, a = null) => (n) => {
const { code: i, label: r, extras: s, isVirtual: o, initialValue: l, initialValueLanguage: u, convertJs: d, convertJsSetting: m, value: f, ...h } = g.merge({}, t, n), [y, b] = ia(o ? null : i, { initialValue: l, initialValueLanguage: u, convertJs: d, convertJsSetting: m, type: (h == null ? void 0 : h.type) || "string" }, a);
return c(e, { ...h, value: y, rawValue: b, $setting: s || {} });
}, Ya = ({ cols: e, rowHeight: t, itemMargin: a, fields: n, primaryKey: i, dataSource: r, itemClassName: s, itemRender: o = (m, f, h) => m, empty: l = c(ba, { description: null }), className: u, style: d = {} }) => {
const m = Dt(), f = pe(() => c(sa, { cols: e, rowHeight: t, itemMargin: a, fields: n, className: s }), [n, e, t, a]);
return c("div", { className: R("ff-data-list-content", u), style: d, children: g.isEmpty(r) ? l : r == null ? void 0 : r.map((h, y) => c(C.Fragment, { children: o(C.cloneElement(f, { data: h }), h, y) }, `${m}-${(h == null ? void 0 : h[i]) || y}`)) });
}, Qa = ({ component: e }) => {
const { base62params: t } = $a();
return c(J, { children: c(kt, { listCode: e, base62params: x.decode(t) }) });
}, Xa = () => "Empty", Za = ({ component: e, $setting: t }) => {
const [a, n] = P();
return $(() => {
if (!e) return n(c(Xa, { description: null }));
X.getWidgetComponent(e).catch((i) => ({ default: () => `${i}` })).then((i) => C.createElement(i.default, { $setting: t })).then(n);
}, [e]), a ? C.cloneElement(a, {}) : null;
};
var Ce, Z, be, ke, Je, Ke;
const ne = class ne {
constructor() {
F(this, Z, /* @__PURE__ */ new Map());
F(this, be, {});
F(this, ke, null);
k(this, "init", (t, a) => {
B(this, Z, t), B(this, be, a);
});
k(this, "get", (t) => (p(this, Z).has(t) || (t = Array.from(p(this, Z).keys()).find((a) => p(this, Z).get(a).uri === t)), p(this, Z).get(t) || {}));
k(this, "redirect", (t, a, n = {}) => {
const { uri: i, type: r, widgetProps: s } = this.get(t) || {};
let o = xa(i || t, r != "list" ? a : g.mapValues(a, (u) => x.encode(u)));
const l = new URLSearchParams();
for (const u in s || {}) (s == null ? void 0 : s.type) == "query" && l.append(u, a[u]);
return l.size > 0 && (o = `${o}?${l.toString()}`), p(this, ke).navigate(o, n);
});
k(this, "getMenus", (t) => {
var a;
return ((a = p(this, be)) == null ? void 0 : a[t]) || [];
});
k(this, "findMenuPathByUuid", (t) => {
let a = [];
for (const n in p(this, be)) if (a = p(this, Je).call(this, p(this, be)[n], t, [n]), a.length > 1) return a;
return a;
});
k(this, "getMenusByRouteUuid", (t) => p(this, Ke).call(this, t, Object.values(p(this, be)).flat()));
F(this, Je, (t, a, n = []) => {
if (g.isEmpty(t)) return n;
for (const { uuid: i, children: r } of t) {
if (i == a) return n.concat(i);
if (!g.isEmpty(r)) return n.concat(i, p(this, Je).call(this, r, a));
}
return n;
});
F(this, Ke, (t, a) => {
var i;
let n = [];
for (const r of a) r.widgetType == "redirect" && (r.uuid == t || r.widget == t ? n.push(r) : (i = r.children) != null && i.length && (n = n.concat(p(this, Ke).call(this, t, r.children))));
return n;
});
k(this, "getCurrentMenu", () => {
const { uuid: t } = this.getCurrentRoute() || {};
if (!t) return;
const a = this.getMenusByRouteUuid(t);
return g.isEmpty(a) ? void 0 : a[0];
});
k(this, "getCurrentRoute", (t = 0) => {
var n;
const a = (n = p(this, ke).state.matches[p(this, ke).state.matches.length - 1 - t]) == null ? void 0 : n.route;
if (!a) return null;
for (let [i, r] of p(this, Z)) if (r.uri === a.path) return r;
return null;
});
k(this, "getPageParams", (t) => {
var r;
const { location: a, matches: n } = p(this, ke).state, i = ((r = n[n.length - 1]) == null ? void 0 : r.params) || {};
return a.search && new URLSearchParams(a.search).forEach((s, o) => {
i[o] = s;
}), t ? g.get(i, t) : i;
});
k(this, "createBrowserRouter", (t = {}) => {
if (p(this, Z).size == 0) return null;
const a = De.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/frameworks/BasicLayout"), n = De.get(X.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), i = { [a]: 0 }, r = (o, l) => () => X.getWidgetComponent(o).then((u) => u.default || function() {
return `${o}`;
}).then((u) => ({ Component: () => C.createElement(Kt, {}, C.createElement(u, l)) })), s = Array.from(p(this, Z).values()).reduce((o, { uuid: l, uri: u, name: d, type: m, component: f, widgetSetting: h, isLogin: y, isLayout: b, extra: w }) => {
let E = {}, z = 0;
switch (m) {
case "list":
E.element = C.createElement(Qa, { component: f });
break;
case "fsdpf-component":
E.element = C.createElement(Za, { key: f, component: f, $setting: h });
}
if (w != null && w.layout) {
if (!i[w == null ? void 0 : w.layout]) return i[w == null ? void 0 : w.layout] = o.length, [...o, { path: "/", lazy: r(w == null ? void 0 : w.layout, {}), children: [{ path: u, ...E }] }];
z = i[w == null ? void 0 : w.layout];
}
return b && z > -1 ? (o[z].children.push({ path: u, ...E }), o) : [...o, { path: u, ...E }];
}, [{ path: "/", lazy: r(a, {}), children: [] }]);
return s.push({ index: !0, element: C.createElement(en, { to: n, replace: !0 }) }), B(this, ke, Ea(s, t));
});
if (p(ne, Ce)) return p(ne, Ce);
}
};
Ce = new WeakMap(), Z = new WeakMap(), be = new WeakMap(), ke = new WeakMap(), Je = new WeakMap(), Ke = new WeakMap(), F(ne, Ce, null), k(ne, "getInstance", () => (p(ne, Ce) || B(ne, Ce, new ne()), p(ne, Ce)));
let mt = ne;
const en = ({ to: e, replace: t }) => Ta() ? C.createElement(Fa, { to: e, replace: t }) : (window.document.location = e, "redirect"), Pe = mt.getInstance(), je = new Worker(new URL("/ff-worker/index.js", self.location)), Vt = { getConfigure: (e) => De.get(e), route: { redirect: (...e) => Pe.redirect(...e), getPageParams: (...e) => Pe.getPageParams(...e), getCurrentRoute: () => Pe.getCurrentRoute() }, popup: { notification: (...e) => _.notification(...e), success: (...e) => _.success(...e), error: (...e) => _.error(...e), form: (...e) => _.form(...e), modal: (...e) => _.modal(...e), confirm: (...e) => _.confirm(...e) } };
var nt, ze, ve;
const I = class I {
constructor() {
k(this, "exec", (t, a = {}, n = {}, i = "") => new Promise((r, s) => {
const o = Et(I, nt)._++;
p(I, ze).set(o, n), I.mQueue.set(o, [r, s]), je.postMessage({ id: o, session: i, category: "eval", method: t, args: a });
}));
k(this, "clear", (t) => je.postMessage({ session: t, category: "clear" }));
if (p(I, ve)) return p(I, ve);
Promise.resolve().then(() => Pn).then((t) => {
Vt.http = t.http;
}), je.addEventListener("message", ({ data: { id: t, task_id: a, method: n, args: i, category: r, data: s, error: o, session: l } }) => {
if (r === "eval" && I.mQueue.has(t)) o !== null ? I.mQueue.get(t)[1](o) : I.mQueue.get(t)[0](s), p(I, ze).delete(t), I.mQueue.delete(t);
else if (r === "util") try {
const u = g.get(Vt, n.split("/")) || g.get(p(I, ze).get(a), n.split("/"));
if (!g.isFunction(u)) throw `${n} not found`;
Promise.resolve(Reflect.apply(u, void 0, i)).then((d) => {
je.postMessage({ id: t, task_id: a, category: r, method: n, args: i, session: l, data: d, error: null });
}).catch((d) => {
je.postMessage({ id: t, task_id: a, category: r, method: n, args: i, session: l, data: null, error: d });
});
} catch (u) {
je.postMessage({ id: t, task_id: a, category: r, method: n, args: i, session: l, data: null, error: u });
}
}, !1);
}
};
nt = new WeakMap(), ze = new WeakMap(), ve = new WeakMap(), k(I, "mQueue", /* @__PURE__ */ new Map()), F(I, nt, 0), F(I, ze, /* @__PURE__ */ new Map()), F(I, ve, null), k(I, "getInstance", () => (p(I, ve) || B(I, ve, new I()), p(I, ve)));
let ht = I;
const Ne = ht.getInstance(), oa = () => {
const e = Q(!0), [, t] = C.useReducer((a) => a + 1, 0);
return $(() => () => e.current = !1, []), () => e.current && t();
}, jt = (e) => {
const t = Q();
return $(() => {
t.current = e;
}, [e]), t.current;
}, _n = (e) => {
const [t, a] = P(e), n = Q(null), i = ge((r, s) => {
n.current = s, a(r);
}, []);
return $(() => {
n.current && (n.current(t), n.current = null);
}, [t]), [t, i];
}, Ye = (e = (n) => {
}, t, a = g.isEqual) => {
const n = C.useRef(t);
a(t, n.current) || (n.current = t), C.useEffect(e, [n.current]);
}, tn = Ye, la = (e, t = "string") => {
var a;
if (!Array.isArray(e)) return e;
for (let n = 0; n < e.length; n++) e[n].value = g.toPrimitive((a = e[n]) == null ? void 0 : a.value, t), e[n] && Reflect.has(e[n], "children") && (e[n].children = la(e[n].children, t));
return e;
}, Yn = (e, t = "json", a = "string", n, i = null) => {
const [r] = re.useForm(n), [s, o] = P([{ label: "无", value: "", disabled: !0 }]), l = Q([]), u = re.useWatch((d) => l.current.length === 0 ? null : g.pick(d, l.current), r) || null;
return $(() => {
Array.isArray(e) ? o(e) : t === "javascript" && e ? Ne.exec(e, {}, { getFieldValue: (d) => (l.current.includes(d) || l.current.push(d), r.getFieldValue(d)), getFieldValueForBasicForm: (d) => (l.current.includes(d) || l.current.push(d), i ? i.getFieldValue(d) : r.getFieldValue(d)) }).then((d) => {
o(g.toPrimitive(d, "array"));
}) : e && o(g.toPrimitive(e, "array"));
}, [e, t, u]), la(s, a);
}, Qn = (e) => {
const [t, a] = P(), n = { type: "GET" };
if (typeof e == "string" ? n.url = e : g.isPlainObject(e) && Object.assign(n, e), !(n != null && n.url)) throw "url is required";
const i = (r) => x.request(n, !1).resp((s) => (console.log("useSubscribeRequest", r), a(s), s));
return Ye(() => {
let r = null;
return i().then((s) => {
r = Xt.subscribe(g.throttle(i, 180, { leading: !1, trailing: !0 }), s.res);
}), () => r == null ? void 0 : r();
}, n), t;
}, an = (e) => {
const [t, a] = C.useState({ gridItems: [], hideItems: [] });
return C.useEffect(() => {
e && x.get(`/api/_/${e}`).then(({ pk: n, uuid: i, code: r, resource: s, align: o, cols: l, rowHeight: u, marginX: d, marginY: m, listenChangeFields: f, listenChangeFieldsFunc: h, fields: y }) => ({ pk: n, uuid: i, code: r, resource: s, align: o, cols: l, rowHeight: u, marginX: d, marginY: m, listenChangeFields: f, listenChangeFieldsFunc: h, ...y.reduce((b, w) => {
var E;
return (E = w == null ? void 0 : w.field) != null && E.hidden ? b.hides.push(w == null ? void 0 : w.field) : b.items.push(w), b;
}, { items: [], hides: [] }) })).then(a);
}, [e]), t;
}, nn = ({ max: e = 0, min: t = 0, type: a = "", message: n, pattern: i, required: r = !1, validator: s } = {}, o, l) => {
const [u, d] = P([]);
return $(() => {
const m = [];
if (r) {
let f = l;
switch (l) {
case "number":
case "string":
case "array":
break;
case "bool":
f = "boolean";
break;
case "json":
f = "object";
}
m.push({ type: f, required: !0, whitespace: !0, message: "该项必填" });
}
switch (a) {
case "string":
m.push({ type: a, max: e, min: t, message: n || (t && e ? `字符必须在 ${t} ~ ${e} 之间` : `${e ? "最多能有" : "最少要有"} ${t || e} 个字符`) });
break;
case "pattern":
m.push({ type: "string", pattern: i, message: n });
break;
case "validator":
s && m.push(({ getFieldValue: f }) => ({ validator: async (h, y) => {
const b = await Ne.exec(s, { value: y, fieldName: o }, { getFieldValue: f });
return g.isString(b) && b ? Promise.reject(b) : g.isBoolean(b) && !b ? Promise.reject(n) : Promise.resolve();
} }));
}
d(m);
}, [e, t, a, n, i, r, s]), u;
}, rn = (e, t, a) => {
const [n, i] = P(null);
return $(() => {
const { initDataUri: r = `/api/${e}`, initDataMethod: s = "GET" } = a || {};
t && x.request({ method: s, url: g.trimEnd(`${r}/${t}`, "/") }).then((o) => {
i(o);
});
}, [e, t, a]), n;
}, sn = (e, t, a, n = {}) => {
const i = oa(), r = Q(!0), s = Q([]), [o, l] = P(a), u = re.useWatch((d) => JSON.stringify(g.pick(d, s.current)), t) || "{}";
return $(() => {
e && Ne.exec(e, n, { getFieldValue: g.wrap(t.getFieldValue, (d, m) => (s.current.some((f) => g.isEqual(f, m)) || (s.current.push(m), i()), d(m))), isFieldTouched: t.isFieldTouched, isFieldsTouched: t.isFieldsTouched }).then((d) => r.current && l(d));
}, [e, u, t, n]), $(() => () => r.current = !1, []), o;
}, on = ({ type: e, initialValue: t, initialValueLanguage: a, onChange: n, form: i }) => {
const r = sn(a == "javascript" && t, i, a == "javascript" ? void 0 : t, {});
return $(() => {
a == "javascript" ? n(g.toPrimitive(r, e)) : t && n(g.toPrimitive(t, e));
}, [e, t, r]), null;
}, ln = ({ widget: e = "Input", widgetPrefix: t = "@pkg/grid-layout-forms", widgetDecorator: a, subWidgets: n, basicForm: i, ...r }) => {
const s = e != null && e.startsWith("@") ? e : `${t}/${e}`, [o, l] = P();
return $(() => {
s && X.getWidgetComponent(s).then(({ defaultProps: u = {}, default: d }) => ({ default: ca(d, u, i) })).catch((u) => ({ default: () => `${u}` })).then((u) => l(C.createElement(u.default, r)));
}, [s]), o && C.cloneElement(o, r);
}, ca = (e, t = {}, a = null) => (n) => {
const { type: i, code: r, label: s, noStyle: o, placeholder: l, extras: u, validators: d, help: m, isVirtual: f, $isReserved: h, initialValue: y, initialValueLanguage: b, convertJs: w, convertJsSetting: E, widgetPerfix: z, boxStyle: q, widgetDecorator: D, subWidgets: W, ...A } = { ...t, ...n }, L = nn(d || {}, r, i), K = { label: s, noStyle: o, colon: !1, layout: "vertical" }, M = { placeholder: l, ...A }, G = ge((j) => j == null ? void 0 : g.toPrimitive(j, i), [i]);
return c(Wt, { name: r, rules: L, initialValue: G(y), normalize: G, children: (j, v, se) => {
var V;
return c(e, { type: i, rcform: se, itemProps: { validateStatus: v.errors.length > 0 ? "error" : "success", tooltip: m, help: v.errors.length > 0 ? v.errors.join("、") : null, required: ((V = L == null ? void 0 : L[0]) == null ? void 0 : V.required) || !1, ...K }, fieldProps: { ...M, ...j }, $setting: u || {} });
} });
}, St = ({ cols: e = 24, rowHeight: t = 16, itemMargin: a = [8, 16], containerPadding: n = [0, 0], fields: i = [], children: r }) => {
const s = ra(i, ca, "@pkg/grid-layout-forms");
return N("div", { className: "ff-grid-layout-form", style: { "--grid-layout-item-margin-x": `${(a == null ? void 0 : a[0]) ?? 8}px`, "--grid-layout-item-margin-y": `${(a == null ? void 0 : a[1]) ?? 16}px`, "--grid-layout-container-padding-y": `${(n == null ? void 0 : n[0]) || 0}px`, "--grid-layout-container-padding-x": `${(n == null ? void 0 : n[1]) || 0}px`, "--grid-layout-cols": e, "--grid-layout-row-height": `${t}px` }, children: [s, r && C.cloneElement(r, { cols: e, rowHeight: t, itemMargin: a, containerPadding: n, fields: i })] });
};
St.propTypes = { fields: O.array };
const cn = (It = St, ({ code: e, layout: t, name: a, primaryKey: n = 0, style: i = {}, formProps: r = {}, form: s, isPreview: o = !1, className: l, onFinish: u, onValuesChange: d = () => {
}, ...m }) => {
const { align: f, autoComplete: h, resource: y, items: b, hides: w, rowHeight: E, marginX: z, marginY: q, cols: D, listenChangeFields: W, listenChangeFieldsFunc: A, pk: L, uuid: K } = an(e), [M] = re.useForm(s), G = pe(() => [{ name: "__PK__", value: L }, { name: "__PROPS__", value: r }, { name: "__RESOURCE__", value: y }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: K }, { name: "__PRIMARY_KEY__", value: n }], [L, e, K, y, n, r]);
return N(re, { className: l, name: a || e, layout: t || f, fields: G, form: M, autoComplete: h, style: { ...i, position: "relative" }, onFinish: u, onValuesChange: (j, v) => (({ changedValues: se, allValues: V, listenChangeFields: me, listenChangeFieldsFunc: $e, onValuesChange: it, code: T }) => {
it(se, V), $e && Array.isArray(me) && Ne.exec($e, { changedValues: se, allValues: V }, { getFieldValue: M.getFieldValue, setFieldValue: M.setFieldValue, setFieldsValue: M.setFieldsValue, isFieldTouched: M.isFieldTouched, isFieldsTouched: M.isFieldsTouched });
})({ changedValues: j, allValues: v, listenChangeFields: W, listenChangeFieldsFunc: A, onValuesChange: d, code: e }), children: [c(It, { ...m, form: M, code: e, fields: b, cols: D, rowHeight: E, itemMargin: [z, q] }), w == null ? void 0 : w.map((j) => {
var v;
return c(Wt, { name: j.code, children: c(on, { form: M, name: j.code, type: j.type, initialValue: j.initialValue, initialValueLanguage: (v = j.extras) == null ? void 0 : v.initialValueLanguage }) }, JSON.stringify(j.code));
})] }, e);
});
var It;
const da = ({ $setting: e, $close: t, extras: a, code: n, primaryKey: i, ...r }) => {
const [s] = re.useForm(), o = rn(n, i, e);
return $(() => {
o && s.setFieldsValue(o);
}, [o]), c(J, { actions: N(C.Fragment, { children: [c(S, { name: "保存", type: "primary", widget: () => {
const l = s.getFieldValue("__RESOURCE__"), { initDataUri: u = `/api/${n}` } = e || {};
s.validateFields(!0).then((d) => l ? g.pick(d, [l]) : d).then((d) => x.post(i ? `${u}/${i}` : `${u}`, d).msg(t)).catch(() => _.error("请先完善表单信息", { duration: 2e3 }));
} }), c(S, { name: "取消", widget: () => t(!1) })] }), extras: a, children: c(cn, { form: s, code: n, primaryKey: i, ...r }) });
}, dn = (e, t, { isReplaceRouteHistory: a = !1 } = {}) => Pe.redirect(t, e, { replace: a }), At = (e, t, { status: { loading: a, disabled: n }, setStatus: i }) => {
const r = { loading: (s) => s === void 0 ? a : i((o) => ({ ...o, loading: s })), disabled: (s) => s === void 0 ? n : i((o) => ({ ...o, disabled: s })) };
return g.isFunction(t) ? t.call(null, { ...e, ...r }) : g.isString(t) && t ? Ne.exec(t, e, r) : null;
}, Mt = (e, t, a, n) => g.isString(t) && t ? X.getWidgetComponent(t).then(({ default: i }) => _.modal(i, { ...e, $setting: a }, n)).catch((i) => {
_.error(t, { content: i.toString() });
}) : _.modal(t, { ...e, $setting: a }, n), un = (e, t, a, n) => _.modal(da, { ...e, $setting: a, code: t }, n), gn = (e, t, a, n) => _.modal(kt, { base62params: e, $setting: a, listCode: t }, n), pn = ({ widget: e, widgetType: t, widgetData: a, widgetProps: n, widgetSetting: i, widgetContainerProps: r }, { onAfterClick: s, onBeforeClick: o }) => {
const l = Ge(Le), [u, d] = P({ leading: !0, trailing: !1 }), m = pe(() => {
switch (t) {
case "redirect":
return g.partialRight(dn, e, i);
case "func":
return g.partialRight(At, (i == null ? void 0 : i.code) ?? e, { status: u, setStatus: d });
case "fsdpf-component":
return g.partialRight(Mt, e, i, r);
case "grid-layout-form":
return g.partialRight(un, e, i, r);
case "data-list":
return g.partialRight(gn, e, i, r);
default:
if (Nt(e) || C.isValidElement(e)) return g.partialRight(Mt, e, i, r);
if (g.isFunction(e)) return g.partialRight(At, (i == null ? void 0 : i.code) || e, { status: u, setStatus: d });
}
return (...f) => console.error("useButton unknown widgetType", t, ...f);
}, [e, t]);
return [g.debounce((f) => (o == null || o(f), Promise.resolve(_t(n, f, { list: l })).then((h) => m({ ...a, ...h })).then((h) => s == null ? void 0 : s(h)).catch(console.error)), 300, { leading: !0, trailing: !1 }), u];
}, zt = /* @__PURE__ */ new Set(), ft = (e = [], t = 0) => {
const a = e[t];
if (a.length && !zt.has(a)) {
const n = document.createElement("script");
n.setAttribute("src", a), n.setAttribute("data-namespace", a), e.length > t + 1 && (n.onload = () => {
ft(e, t + 1);
}, n.onerror = () => {
ft(e, t + 1);
}), zt.add(a), document.body.appendChild(n);
}
}, yt = ({ className: e, type: t, style: a = {}, ...n }) => c("span", { role: "img", className: R("ff-iconfont", e), style: a, ...n, children: c("svg", { style: { width: "1em", height: "1em", fill: "currentColor", overflow: "hidden" }, viewBox: "0 0 1024 1024", children: c("use", { xlinkHref: `#${t}` }) }) });
yt.propTypes = { className: O.string, type: O.string.isRequired, style: O.object }, yt.init = ft;
const Qe = (e) => function({ className: t, children: a, name: n, icon: i, type: r = "default", iconPosition: s = "start", noAuthType: o, onAfterClick: l, onBeforeClick: u, data: d, loading: m, disabled: f, tooltip: h, popConfirm: y, widget: b, widgetType: w, widgetData: E, widgetProps: z, widgetSetting: q, widgetContainerProps: D, ...W }) {
const A = { type: "primary", className: R("ff-button", t), iconPosition: s };
r === "danger" ? A.danger = !0 : r === "default" && (A.type = r), e === "link" || e === "dashed" ? (A.type = e, r === "default" && (A.className = R(A.className, "ff-default"))) : e !== "circle" && e !== "round" || (A.shape = e), i && (A.icon = c(yt, { type: i }));
const [L, K] = P(!1), [M, { disabled: G, loading: j }] = pn({ widget: b, widgetType: w, widgetData: E, widgetProps: z, widgetSetting: q, widgetContainerProps: D }, { onAfterClick: l, onBeforeClick: u });
return c(ka, { okText: "确定", cancelText: "取消", ...y || {}, disabled: G || f, open: L, onOpenChange: (v) => {
if (!v) return K(v);
y ? K(v) : M(d);
}, onConfirm: () => {
M(d);
}, onClick: (v) => {
v.stopPropagation();
}, children: c(va, { ...h, title: L ? null : h == null ? void 0 : h.title, trigger: ["hover", "click"], children: c(lt, { loading: j || m, disabled: G || f, ...A, ...W, children: a || n }) }) });
}, S = Qe("default"), mn = Qe("link"), hn = Qe("circle"), fn = Qe("round"), yn = Qe("dashed"), Bt = ({ data: e, widget: t, widgetType: a = "fsdpf-component", children: n, widgetData: i, widgetProps: r, widgetSetting: s, widgetContainerProps: o }) => {
const l = Ge(Le), [u, d] = P(!1), [m, f] = P("hover"), [h, y] = P({}), [b, w] = P(), { placement: E, align: z, arrow: q = { pointAtCenter: !0 }, ...D } = o || {};
$(() => {
a == "grid-layout-form" ? w(C.createElement(da, { ...i, $setting: s, code: t })) : a == "data-list" ? w(C.createElement(kt, { base62params: e, $setting: s, listCode: t })) : g.isString(t) ? X.getWidgetComponent(t).then(({ default: L }) => {
w(C.createElement(L, { ...i, $setting: s }));
}).catch((L) => w(L.toString())) : Nt(t) ? w(C.createElement(t, { ...i, $setting: s })) : C.isValidElement(t) && w(C.cloneElement(t, { ...i, $setting: s }));
}, [t, a, i]), $(() => {
Promise.resolve(_t(r, e, { list: l })).then(y);
}, [r, e]);
const W = (L) => {
d(L), !L && f("hover");
}, A = () => {
d(!0), f("click");
};
return c(Sa, { zIndex: 1080, placement: E, onPopupClick: A, onClick: A, open: u, align: z, arrow: q, trigger: m, content: c(wn, { ...D, children: b && C.cloneElement(b, { ...h, $close: () => W(!1) }) }), children: n, onOpenChange: W });
}, wn = ({ title: e, className: t, children: a, width: n, height: i, ...r }) => {
const [s, o] = P({}), l = ge((m, f) => o((h) => ({ ...h, [m]: f })), []), u = ge((m) => o((f) => ({ ...f, [m]: void 0 })), []), d = e ? C.createElement("div", { className: "ff-popup-title" }, e) : s == null ? void 0 : s.title;
return c(_e.Provider, { value: { ele: s, mount: l, unmount: u }, children: N("div", { className: R("ff-popup ff-popover", t), style: { width: n, height: i }, ...r, children: [N("div", { className: "ff-popup-header", children: [d, s == null ? void 0 : s["sub-title"]] }), a, N("div", { className: "ff-popup-footer", children: [s == null ? void 0 : s.extras, s == null ? void 0 : s.actions] })] }) });
};
Bt.propTypes = { widgetType: O.oneOf(["fsdpf-component", "grid-layout-form", "data-list"]) }, S.propTypes = { type: O.oneOf(["primary", "default", "danger", ""]), name: O.string, icon: O.string, iconPosition: O.oneOf(["start", "end"]), data: O.any, widget: O.any, widgetType: O.oneOf(["destroy", "redirect", "func", "fsdpf-component", "grid-layout-form", "grid-layout", "data-list"]), widgetData: O.object, widgetProps: O.object, widgetSetting: O.object, widgetContainerProps: O.object }, S.Link = mn, S.Link.defaultProps = S.defaultProps, S.Link.propTypes = S.propTypes, S.Circle = hn, S.Circle.defaultProps = S.defaultProps, S.Circle.propTypes = S.propTypes, S.Round = fn, S.Round.defaultProps = S.defaultProps, S.Round.propTypes = S.propTypes, S.Dashed = yn, S.Dashed.defaultProps = S.defaultProps, S.Dashed.propTypes = S.propTypes, S.Popover = Bt;
const Cn = ({ fields: e, formProps: t, $close: a }) => {
const [n] = re.useForm(), i = pe(() => [{ name: "__PROPS__", value: t }], [t]);
return c(J, { actions: N(C.Fragment, { children: [c(S, { name: "取消", widget: () => a(!1) }), c(S, { name: "确定", type: "primary", widget: () => n.validateFields(!0).then(a) })] }), children: c(re, { fields: i, form: n, className: "ff-modal-form", children: e == null ? void 0 : e.map(({ code: r, ...s }) => c(ln, { code: r, ...s }, r)) }) });
}, bn = ({ className: e, $close: t, children: a, title: n, subTitle: i, actions: r, extras: s, zIndex: o, ...l }) => N(La, { ...l, prefixCls: "ff-drawer", className: R("ff-popup", e), height: 378, maskMotion: { motionAppear: !0, motionName: "mask-motion" }, motion: (u) => ({ motionAppear: !0, motionName: `panel-motion-${u}` }), children: [N("div", { className: "ff-popup-header", children: [c("button", { "aria-label": "Close", className: "ff-popup-close", onClick: l.onClose, children: c(bt, { type: "close" }) }), n, i] }), c("div", { className: "ff-popup-body", children: a }), N("div", { className: "ff-popup-footer", children: [s, r] })] }), kn = ({ className: e, $close: t, $event: a, children: n, title: i, subTitle: r, actions: s, extras: o, zIndex: l, placement: u, ...d }) => {
const m = (a == null ? void 0 : a.pageX) === void 0 ? { animation: null, maskAnimation: null, mousePosition: { x: null, y: null } } : { animation: "zoom", maskAnimation: "fade", mousePosition: { x: a == null ? void 0 : a.pageX, y: a == null ? void 0 : a.pageY } };
return c(Va, { ...d, ...m, prefixCls: "ff-modal", modalRender: () => N("div", { className: R("ff-modal-content ff-popup", e), children: [N("div", { className: "ff-popup-header", children: [c("button", { "aria-label": "Close", className: "ff-popup-close", onClick: d.onClose, children: c(bt, { type: "close" }) }), i, r] }), c("div", { className: "ff-popup-body", children: n }), N("div", { className: "ff-popup-footer", children: [o, s] })] }) });
}, ua = ({ placement: e, $close: t, $event: a, children: n, title: i, ...r }) => {
const [s, o] = P({}), [l, u] = P(!0), d = ge((y, b) => o((w) => ({ ...w, [y]: b })), []), m = ge((y) => o((b) => ({ ...b, [y]: void 0 })), []);
let f = { ...r, className: s.rootClassName, title: s.title || i && C.createElement("div", { className: R("ff-popup-title") }, i), subTitle: s["sub-title"], actions: s.actions, extras: s.extras, children: n, $close: t, $event: a, onClose: () => u(!1) };
const h = () => {
t(!1);
};
return c(_e.Provider, { value: { ele: s, mount: d, unmount: m }, children: e && e !== "center" ? c(bn, { ...f, placement: e, open: l, afterOpenChange: (y) => !y && h() }) : c(kn, { ...f, visible: l, afterClose: h }) });
};
ua.propTypes = { placement: O.oneOf(["center", "left", "top", "right", "bottom"]) };
const H = () => {
const [e, t] = Ra({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (r) => {
const { offsetHeight: s } = r;
return { height: s };
}, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, a] = C.useReducer((r) => r + 1, 0);
$(() => {
H.$onClick = n, H.$queue.forEach(([r, s, o], l, u) => {
i([s, o], ...r), delete u[l];
});
}, []);
const n = (r, s = {}, o = {}) => new Promise((l, u) => i([l, u], r, s, o)), i = ([r, s], o, l = {}, u = {}) => {
const d = H.$index++, m = (f) => ((h, y) => (H.$popups.delete(h), a(), y == null ? void 0 : y()))(d, () => r(f));
if (o === Gt) return e.open({ ...u, key: d, content: C.createElement(o, { ...l, $close: () => e.close(d) }) });
H.$popups.set(d, C.createElement(ua, { zIndex: d, maskClosable: !1, $event: l == null ? void 0 : l.$event, ...u, key: d, $close: m }, C.isValidElement(o) ? C.cloneElement(o, { ...l, $close: m }) : o != null && o.name ? C.createElement(o, { ...l, $close: m }) : o)), a();
};
return N(C.Fragment, { children: [Array.from(H.$popups).map(([r, s]) => s), t] });
};
H.$popups = /* @__PURE__ */ new Map(), H.$index = 0, H.$queue = [], H.$onClick = (...e) => new Promise((t, a) => {
H.$queue.push([e, t, a]);
});
const Ut = (e, t, a = {}) => H.$onClick(e, t, a), st = (e, { showProgress: t, duration: a, ...n } = { duration: 1.5 }) => H.$onClick(Gt, { content: e, ...n }, { showProgress: t, duration: a }), _ = { modal: Ut, confirm: (e, t = {}) => H.$onClick(ja, { content: e, ...t }, { placement: "center" }), form: (e, t = {}, a = {}) => Ut(Cn, { formProps: a, fields: e }, { placement: "center", ...t }).then((n) => {
if (n === !1) throw !1;
return n;
}), notification: st, success: (e, t = { duration: 1.5 }) => st(e, { ...t, className: "ff-notification-success", icon: "check" }), error: (e, t = { duration: 1.5 }) => st(e, { ...t, className: "ff-notification-error", icon: "close" }) };
Be.configure({ showSpinner: !1 }), Ue.interceptors.request.use((e) => {
e.headers.Platform = "web", e.headers.SaaS = window.localStorage.getItem("SaaS");
const t = window.localStorage.getItem(tt);
return e.headers.Authorization = t ? `Bearer ${t} ` : void 0, Be.inc(), e;
}, (e) => (Be.done(), Promise.reject({ code: -1, msg: e }))), Ue.interceptors.response.use(({ data: e, headers: t }) => (Be.done(), { ...e, res: t == null ? void 0 : t.res }), function(e) {
return Be.done(), Promise.reject(e.message);
}), window.addEventListener("unhandledrejection", ct.onUnhandledRejection), ct.onMsg = (e, t) => _[[0, 1].includes(e) ? "success" : "error"](t).then(() => e === 20300 && Pe.redirect(De.get("Common.WEBSITE_LOGIN_PAGE")));
const wt = { appUrl: "", init: (e, t, a) => {
wt.appUrl = a, Ue.defaults.baseURL = a, Ue.defaults.timeout = 15e3, Object.assign(wt, new ct(e, t, Ue));
} }, x = wt;
class Pt extends Error {
constructor(t, a) {
super(a), Error.captureStackTrace && Error.captureStackTrace(this, Pt), !a instanceof We && (this.name = `${t} Error Runtime`);
}
}
class We extends Error {
constructor(t, ...a) {
super(...a), Error.captureStackTrace && Error.captureStackTrace(this, We), this.name = `${t} Not Found`;
}
}
const ot = "mine", tt = "token";
var Se, Y;
const ie = class ie {
constructor() {
F(this, Y, /* @__PURE__ */ new Map());
k(this, "setVendor", (t, a) => p(this, Y).set(t, new Jt(a, async (n, i) => {
var s, o;
if (!(n != null && n.default)) throw "@pkg not found";
let r = () => i;
switch ("function") {
case typeof (r = (s = n.default) == null ? void 0 : s[`./${i}/index.jsx`]):
case typeof (r = (o = n.default) == null ? void 0 : o[`./${i}/index.js`]):
return r();
}
throw new We(i);
})));
k(this, "getWidgetComponent", async (t) => {
if (!t) throw "getWidgetComponent widget is required";
const [, a] = t == null ? void 0 : t.split("@ff/"), [, n] = t == null ? void 0 : t.split("@app/"), [, i] = t == null ? void 0 : t.split("@pkg/"), [, r] = t == null ? void 0 : t.split("@fsdpf/");
try {
switch (!0) {
case (!!a && p(this, Y).has("pkg")):
return await p(this, Y).get("pkg").get(a);
case (!!n && p(this, Y).has("pkg")):
return await p(this, Y).get("pkg").get(n);
case (!!i && p(this, Y).has("pkg")):
return await p(this, Y).get("pkg").get(i);
case (!!r && p(this, Y).has("pkg")):
return await p(this, Y).get("pkg").get(r);
default:
throw new We(t);
}
} catch (s) {
throw new Pt(t, s);
}
});
k(this, "getRoutes", () => x.get("/api/my-router").then((t) => [...t, { uuid: "data-list-setting", isLayout: !0, uri: "/data-list-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/DataListSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "grid-layout-setting", isLayout: !0, uri: "/grid-layout-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/GridLayoutSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "grid-layout-form-setting", isLayout: !0, uri: "/grid-layout-form-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/GridLayoutFormSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "resource-api-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/ResourceApiSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "charts-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/ChartsSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "fsm-setting", isLayout: !0, uri: "/fsm-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/FsmSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "component-setting", isLayout: !0, uri: "/component-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/ComponentSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "login", uri: "/login", name: "登录", type: "fsdpf-component", isLogin: !1, component: "@pkg/components/ff/Login" }, { uuid: "not-found", uri: "*", name: "Not Found", type: "fsdpf-component", isLogin: !1, component: "@pkg/components/ff/NotFound" }].map(({ uuid: a, ...n }) => [a, { uuid: a, ...n }])).then((t) => new Map(t)));
k(this, "getMenus", () => x.get("/api/my-menu"));
k(this, "getConfigure", () => x.get("api/init-configure"));
k(this, "getWidgetOperationAuth", () => x.get("/api/init-widget-operation-auth").then((t) => t.reduce((a, { uuid: n, auth: i }) => [...a, [n, i]], [])));
k(this, "getPhoneNumber", (t) => x.get(`/api/user-wx-phone-number/${t}`));
k(this, "getUserToken", () => {
const t = window.localStorage.getItem(tt);
if (!t) return "";
const a = t.split(".");
if (!Array.isArray(a) || a.length !== 3) throw "登录令牌无效!";
const { iat: n } = JSON.parse(window.atob(a[1]));
if (Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - n > 2592e3) throw "登录令牌已过期, 请重新登录!";
return t;
});
k(this, "checkUserToken", () => {
try {
return !!this.getUserToken();
} catch {
return !1;
}
});
k(this, "getUserInfo", (t = !0) => {
var a;
try {
const n = this.getUserToken();
if (!n) return Promise.resolve(null);
const { iat: i } = JSON.parse(window.atob((a = n == null ? void 0 : n.split(".")) == null ? void 0 : a[1])), { iat: r, ...s } = x.decode(window.localStorage.getItem(ot) || "", {});
return r === i ? Promise.resolve(s) : x.get("/api/mine-info").then(({ User: o = null }) => (window.localStorage.setItem(ot, x.encode({ ...o, iat: i })), o));
} catch (n) {
console.error(n), t && Popup.error("请登录").then(logout);
}
return Promise.resolve(null);
});
k(this, "login", (t, a, n = {}) => x.post("/api/user-token", { username: t, passwd: Oa.hash(a), platform: "web", ...n }).then(({ token: i }) => (window.localStorage.setItem(tt, i), i)));
k(this, "logout", () => {
window.localStorage.removeItem(ot), window.localStorage.removeItem(tt);
});
if (p(ie, Se)) return p(ie, Se);
}
};
Se = new WeakMap(), Y = new WeakMap(), F(ie, Se, null), k(ie, "getInstance", () => (p(ie, Se) || B(ie, Se, new ie()), p(ie, Se)));
let Ct = ie;
const X = Ct.getInstance(), vn = C.createContext({ user: {}, initUser: () => {
}, initUserComplete: !1 }), Sn = C.createContext({ set: () => {
}, get: () => {
}, assign: () => {
}, currentRoute: () => {
} }), Nt = (e) => !!(e != null && e.name) && (e.prototype instanceof C.Component || /^[A-Z]/.test(e.name)), Pn = Object.freeze(Object.defineProperty({ __proto__: null, AppContext: vn, AppGlobalParamsContext: Sn, cache: Jt, configure: De, default: X, func: Ne, http: x, isReactComponent: Nt, route: Pe }, Symbol.toStringTag, { value: "Module" })), Nn = (e, t, a = "children") => {
if (g.isEmpty(e)) return {};
const n = g.find(e, ["value", t]);
if (!g.isEmpty(n)) return n;
const i = e.length;
for (let r = 0; r < i; r++) {
const { [a]: s } = e[r], o = Nn(s, t, a);
if (!g.isEmpty(o)) return o;
}
return {};
};
export {
Nt as $,
Yn as A,
Qn as B,
cn as C,
Da as D,
St as E,
ln as F,
Kn as G,
Ja as H,
da as I,
an as J,
nn as K,
rn as L,
sn as M,
yt as N,
S as O,
Ia as P,
pn as Q,
Xt as R,
J as S,
_e as T,
Kt as U,
H as V,
_ as W,
Dn as X,
Wn as Y,
qn as Z,
X as _,
na as a,
x as a0,
Jt as a1,
De as a2,
Ne as a3,
Pe as a4,
vn as a5,
Sn as a6,
Nn as a7,
sa as b,
Gn as c,
ra as d,
vt as e,
ea as f,
Zt as g,
ta as h,
aa as i,
kt as j,
Le as k,
Ha as l,
Ya as m,
za as n,
Ua as o,
Aa as p,
Ma as q,
Hn as r,
Jn as s,
gt as t,
ia as u,
oa as v,
jt as w,
_n as x,
Ye as y,
tn as z
};

919
dist/common/main-DJpuXYIP.js vendored Normal file
View File

@ -0,0 +1,919 @@
var pa = Object.defineProperty;
var Nt = (e) => {
throw TypeError(e);
};
var ma = (e, t, a) => t in e ? pa(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
var k = (e, t, a) => ma(e, typeof t != "symbol" ? t + "" : t, a), xt = (e, t, a) => t.has(e) || Nt("Cannot " + a);
var p = (e, t, a) => (xt(e, t, "read from private field"), a ? a.call(e) : t.get(e)), F = (e, t, a) => t.has(e) ? Nt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, a), z = (e, t, a, n) => (xt(e, t, "write to private field"), n ? n.call(e, a) : t.set(e, a), a);
var Et = (e, t, a, n) => ({
set _(r) {
z(e, t, r, a);
},
get _() {
return p(e, t, n);
}
});
import { jsx as c, jsxs as $ } from "react/jsx-runtime";
import C, { useEffect as x, useState as P, useCallback as ge, useMemo as pe, useContext as _e, useRef as X, useId as Dt, useLayoutEffect as ha } from "react";
import g from "lodash";
import R from "classnames";
import { Form as Ze, Input as fa, Button as lt, Breadcrumb as ya, Tree as wa, Pagination as Ca, Table as ba, Empty as ka, Popconfirm as va, Tooltip as Sa, Popover as Pa } from "antd";
import { useMergedState as $a } from "rc-util";
import ie, { FieldContext as Na, Field as qt } from "rc-field-form";
import { useParams as xa, generatePath as Ea, createBrowserRouter as Ta, useInRouterContext as Fa, Navigate as Ra } from "react-router-dom";
import L from "prop-types";
import * as Tt from "react-is";
import { useNotification as La } from "rc-notification";
import { N as ze, a as Be, w as ct, S as Oa } from "./vender-DDOSHWIo.js";
import Ft from "immutability-helper";
import Va from "rc-drawer";
import ja from "rc-dialog";
const Rt = { null2json: (e) => Object.create(), null2array: (e) => [], null2number: (e) => 0, null2bool: (e) => !1, null2string: (e) => "", null2integer: (e) => 0, null2float: (e) => 0, string2json: (e) => e ? JSON.parse(e) : "{}", string2array: (e) => e.substr(0, 1) === "[" && e.substr(-1) === "]" ? JSON.parse(e) : e.split(","), string2number: (e) => e == "" ? 0 : +e, string2integer: (e) => e == "" ? 0 : +e, string2float: (e) => e == "" ? 0 : +e, string2bool: (e) => {
switch (`${e}`.toLowerCase()) {
case "0":
case "false":
case "[]":
case "{}":
return !1;
}
return !!e;
}, string2string: (e) => e, json2json: (e) => e, json2array: (e) => e ? Object.values(e) : [], json2number: (e) => Object.keys(e).length, json2integer: (e) => Object.keys(e).length, json2float: (e) => Object.keys(e).length, json2bool: (e) => Object.keys(e).length > 0, json2string: (e) => e ? JSON.stringify(e) : "", array2json: (e) => ({ ...e }), array2array: (e) => e, array2number: (e) => e.length, array2integer: (e) => e.length, array2float: (e) => e.length, array2bool: (e) => e.length > 0, array2string: (e) => JSON.stringify(e), number2json: (e) => ({}), number2array: (e) => [e], number2number: (e) => e, number2integer: (e) => e, number2float: (e) => e, number2bool: (e) => !!e, number2string: (e) => e.toString(), boolean2json: (e) => ({}), boolean2array: (e) => [], boolean2number: (e) => +e, boolean2integer: (e) => +e, boolean2float: (e) => +e, boolean2bool: (e) => e, boolean2string: (e) => e ? "true" : "false" }, Ht = (e, t) => g.flatMap(g.toPairs(e), ([a, n]) => g.isObjectLike(n) ? Ht(n, a) : [[`${g.isUndefined(t) ? "" : t + "."}${a}`, n]]), Jt = (e, t = () => !1) => g.some(e, (a) => !!g.some(a, t) || (g.isEmpty(a) || !g.isPlainObject(a) && !g.isArray(a) ? void 0 : Jt(a, t))), et = (e, t) => e && typeof e == "object" ? Array.isArray(e) ? e.map((a) => et(a, t)) : Object.keys(e).reduce((a, n) => (t[n] ? a[t[n]] = et(e[n], t) : a[n] = et(e[n], t), a), {}) : e;
g.mixin({ toPrimitive: (e, t) => {
let a = "string";
a = Array.isArray(e) ? "array" : typeof e, g.isObject(e) && (a = "json");
const n = `${a}2${t}`;
return Reflect.has(Rt, n) ? Rt[n](e) : e;
}, toPairsDeep: Ht, deepSome: Jt, replaceKeys: et });
var Ae, qe, Ie, de, Fe, Re;
class Kt {
constructor(t, a) {
F(this, Ae, /* @__PURE__ */ new Map());
F(this, qe, !0);
F(this, Ie, []);
F(this, de);
F(this, Fe, () => p(this, de));
F(this, Re, () => Promise.resolve());
k(this, "get", (...t) => new Promise((a, n) => {
const r = JSON.stringify(t);
if (p(this, Ae).has(r)) return a(p(this, Re).call(this, p(this, de), ...t));
if (p(this, de) === void 0) p(this, Ie).push([t, a, n]), p(this, qe) && (z(this, qe, !1), Promise.resolve(typeof p(this, Fe) == "function" ? p(this, Fe).call(this) : p(this, Fe)).then((i) => z(this, de, i || null)).finally(() => {
p(this, Ie).forEach(([i, s, o]) => {
try {
const l = p(this, Re).call(this, p(this, de), ...i);
p(this, Ae).set(JSON.stringify(i), l), s(l);
} catch (l) {
o(l);
}
}), p(this, Ie).length = 0;
}));
else {
const i = p(this, Re).call(this, p(this, de), ...t);
p(this, Ae).set(r, i), a(i);
}
}));
z(this, Re, a), z(this, Fe, t);
}
}
Ae = new WeakMap(), qe = new WeakMap(), Ie = new WeakMap(), de = new WeakMap(), Fe = new WeakMap(), Re = new WeakMap();
const Dn = () => c("div", { children: "Empty" }), Ge = C.createContext({ ele: {}, mount: () => {
}, unmount: () => {
} }), J = ({ rootClassName: e, className: t, children: a, actions: n, title: r, subTitle: i, extras: s, style: o = {} }) => {
const { mount: l, unmount: u } = C.useContext(Ge);
return n && J.Action({ children: n }), r && J.Title({ children: r }), i && J.SubTitle({ children: i }), s && J.Extra({ children: s }), x(() => (l("rootClassName", e), () => u(e)), [e]), c("div", { className: R("ff-container", t), style: o, children: a });
}, Qe = (e) => ({ children: t, className: a }) => {
const { mount: n, unmount: r } = C.useContext(Ge);
return x(() => (n(e, C.createElement("div", { key: `ff-${e}`, className: R(`ff-popup-${e}`, a) }, t)), () => r(e)), [a, t]), null;
};
J.Action = Qe("actions"), J.Title = Qe("title"), J.SubTitle = Qe("sub-title"), J.Extra = Qe("extras"), J.propTypes = { className: L.string, style: L.object, title: L.any, subTitle: L.any, actions: L.any, extras: L.any };
const qn = () => c(J, { className: "ff-loading", children: $("div", { className: "loader", children: [$("div", { className: "square", children: [c("span", {}), c("span", {}), c("span", {})] }), $("div", { className: "square", children: [c("span", {}), c("span", {}), c("span", {})] }), $("div", { className: "square", children: [c("span", {}), c("span", {}), c("span", {})] }), $("div", { className: "square", children: [c("span", {}), c("span", {}), c("span", {})] })] }) }), Hn = () => c("div", { children: "NotFound" }), _t = ({ children: e }) => {
const [t, a] = P({}), n = ge((i, s) => a((o) => ({ ...o, [i]: s })), []), r = ge((i) => a((s) => ({ ...s, [i]: void 0 })), []);
return typeof (e == null ? void 0 : e.type) == "string" ? e : c(Ge.Provider, { value: { ele: t, mount: n, unmount: r }, children: C.cloneElement(e, { className: t.rootClassName, title: t.title, subTitle: t["sub-title"], actions: t.actions, extras: t.extras }) });
};
_t.propTypes = { children: L.element.isRequired };
const Lt = { close: ["M563.8 512l262.5-312.9c4.4-5.2 0.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9c-4.4 5.2-0.7 13.1 6.1 13.1h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"], check: ["M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474c-6.1-7.7-15.3-12.2-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"], info: ["M512 224m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z", "M544 392h-64c-4.4 0-8 3.6-8 8v464c0 4.4 3.6 8 8 8h64c4.4 0 8-3.6 8-8V400c0-4.4-3.6-8-8-8z"] }, bt = ({ type: e, props: t }) => c("i", { ...t, children: c("svg", { viewBox: "0 0 1024 1024", width: "1em", height: "1em", fill: "currentColor", children: (Lt[e] || Lt.info).map((a, n) => c("path", { d: a }, n)) }) }), Gt = ({ className: e, content: t, icon: a, $close: n }) => $(C.Fragment, { children: [a && c("div", { className: R("ff-notification-icon", e), children: c(bt, { type: a }) }), t] }), Aa = ({}) => c(J, { children: "Confirm" });
var fe, Me;
const ee = class ee {
constructor() {
F(this, Me, null);
k(this, "init", (t) => z(this, Me, new Map(t)));
k(this, "check", (t) => !p(this, Me).has(t) || p(this, Me).get(t));
if (p(ee, fe)) return p(ee, fe);
}
};
fe = new WeakMap(), Me = new WeakMap(), F(ee, fe, null), k(ee, "getInstance", () => (p(ee, fe) || z(ee, fe, new ee()), p(ee, fe)));
let dt = ee;
const Ia = dt.getInstance(), Yt = (e = {}, t = {}, a = {}, n = "") => g.deepSome(e, (r, i) => i === "type" && r === "code") ? Xt(e, t, a, n) : Qt(e, t, n), Xt = async (e = {}, t = {}, a = {}, n = "") => {
let r = /* @__PURE__ */ Object.create(null);
for (let i in e) {
let s;
if (Reflect.has(e[i], "type") && ["code", "field", "router", "query", "string"].includes(e[i].type)) {
const { type: o, value: l = "", default: u = n } = e[i];
switch (o) {
case "code":
s = await $e.exec(l, t, a);
break;
case "field":
s = g.get(t, l) ?? g.get(t, l.substring(l.indexOf(".") + 1));
break;
case "router":
case "query":
s = Pe.getPageParams(l);
break;
case "string":
s = l;
}
s ?? (s = u);
} else s = await Xt(e[i], t, a, n);
g.set(r, i, s);
}
return r;
}, Qt = (e = {}, t = {}, a = "") => Object.keys(e || {}).reduce((n, r) => {
if (g.isPlainObject(e[r])) {
let i;
if (Reflect.has(e[r], "type") && ["field", "router", "query", "string"].includes(e[r].type)) {
const { type: s, value: o = "", default: l = a } = e[r];
switch (s) {
case "field":
i = g.get(t, o) ?? g.get(t, o.substring(o.indexOf(".") + 1));
break;
case "router":
case "query":
i = Pe.getPageParams(o);
break;
case "string":
i = o;
}
i ?? (i = l);
} else i = Qt(e[r], t, a);
g.set(n, r, i);
}
return n;
}, {});
var ye, He;
const te = class te {
constructor() {
F(this, He, null);
k(this, "init", (t) => z(this, He, t));
k(this, "get", (t, a) => g.get(p(this, He), t, a));
if (p(te, ye)) return p(te, ye);
}
};
ye = new WeakMap(), He = new WeakMap(), F(te, ye, null), k(te, "getInstance", () => (p(te, ye) || z(te, ye, new te()), p(te, ye)));
let ut = te;
const Ue = ut.getInstance(), Ma = (e, t, a, n, r) => {
const i = C.lazy(() => Q.getWidgetComponent(e).catch((s) => ({ default: () => `${s}` })));
return c(C.Suspense, { children: c(i, { value: t, record: a, $setting: n, base62params: r }) }, e);
}, Wa = (e, t = {}) => (At(e), At(t), pe(() => e == null ? void 0 : e.map(({ widgetByJs: a, widgetByJsSetting: n, ...r }, i) => a && !a.endsWith("/BasicShowFieldData") ? { ...r, render: (s, o) => {
const l = Ma(a, s, o, n, t);
return g.isFunction(r == null ? void 0 : r.render) ? r.render(l, s, o) : l;
} } : r), [e, t])), Jn = (e) => {
const [t, a] = P({});
return x(() => {
let n = !1;
return e && N.get(`/api/_/${e}`).then((r) => g.pick(r, ["uuid", "name", "code", "resource", "marginX", "marginY", "cols", "rowHeight", "primaryKey", "columns", "itemOperations", "batchOperations", "isConditionFormLayout", "layout", "tabs", "pageSize", "layoutConfig"])).then((r) => !n && a(r)), () => n = !0;
}, [e]), t;
}, Kn = (e, t = {}) => {
const [a, n] = P({ dataSource: [] });
return Ye(() => {
let r = !1;
return e && N.get(`/api/${e}/${N.encode({ page: 1, ...t })}`).then((i) => !r && n(i)), () => r = !0;
}, [e, t]), a;
}, gt = (e, t = null, a = null, n = "id") => pe(() => {
if (g.isEmpty(e) || !e.some(({ uuid: i }) => Ia.check(i))) return !1;
if (g.isEmpty(a) || g.isEmpty(t)) return !0;
const r = t.map((i) => `${i == null ? void 0 : i[n]}`);
return e.some(({ uuid: i }) => !i || !a.has(i) || a.get(i).some((s) => r.includes(`${s}`)));
}, [e, t, a, n]), za = ({ className: e, itemClassName: t, classNames: a = {}, dataSource: n, isPaginate: r, isItemOperations: i, isBatchOperations: s, batchOperations: o, itemOperations: l, itemOperationsAccess: u, resource: d, primaryKey: m, title: h, itemGridLayout: f, $setting: y, tabs: b, isConditionFormLayout: w, isTreeSider: E, treeSiderConfig: W }) => {
const { getBase62params: q, onClickCallback: U, onTabChange: D } = _e(Oe), { total: I, page: O, pageSize: K, tab: M } = (q == null ? void 0 : q()) || {}, _ = ge((j, v, se) => c(Ba, { className: R("ff-data-list-framework-item", t), operations: i && v ? l == null ? void 0 : l.filter((V) => !(m && V.uuid && u.has(V.uuid)) || u.get(V.uuid).includes(v == null ? void 0 : v[m])) : [], data: d ? { [d]: v } : v, children: j, onClickCallback: U }), [d, m, i, U, l, u]);
return $("div", { className: R("ff-data-list-framework", e), children: [c(aa, { className: a == null ? void 0 : a.sider, isTreeSider: E, ...W }), $("div", { className: R("ff-data-list-container", a == null ? void 0 : a.container), children: [c(vt, { className: a == null ? void 0 : a.filter, isConditionFormLayout: w }), c(ta, { title: h, className: a == null ? void 0 : a.toolbar, tabs: b, tab: M, onTabChange: D }), c(Xa, { ...f, className: a == null ? void 0 : a.content, style: { "--col-num": (y == null ? void 0 : y.colNum) || 1 }, primaryKey: m, itemRender: _, dataSource: n }), c(na, { className: a == null ? void 0 : a.footer, isPaginate: r, isOperations: s, operations: o, total: I, page: O, pageSize: K })] })] });
}, Ba = ({ className: e, operations: t, children: a, data: n, onClickCallback: r }) => $("div", { className: R("data-list-grid-layout-item-container", e), children: [a, !!(t != null && t.length) && c("div", { className: "data-list-grid-layout-item-actions", children: t.map((i) => c("span", { className: "data-list-grid-layout-item-action", children: c(S.Link, { uuid: i.uuid, type: i.type, name: i.name, widget: i.widget, widgetType: i.widgetType, widgetProps: i.widgetProps, widgetSetting: i.widgetSetting, widgetContainerProps: i.widgetContainerSetting, data: n, onAfterClick: (s) => s !== !1 && (r == null ? void 0 : r(i.isRefresh, n)) }, i.uuid || useId()) }, (i == null ? void 0 : i.uuid) || useId())) })] }), Ua = ({ listCode: e, className: t, classNames: a = {}, itemClassName: n, dataSource: r, columns: i, isItemOperations: s, isBatchOperations: o, batchOperations: l, itemOperations: u, itemOperationsAccess: d, resource: m, primaryKey: h, title: f, tabs: y, isPaginate: b, isTreeSider: w, treeSiderConfig: E, isConditionFormLayout: W, ...q }) => {
const { getBase62params: U, onClickCallback: D, onTabChange: I } = _e(Oe), { total: O, page: K, tab: M, pageSize: _ } = (U == null ? void 0 : U()) || {}, j = gt(u, r, d, h);
return $("div", { className: R("ff-data-table-framework", t), children: [c(aa, { className: a == null ? void 0 : a.sider, isTreeSider: w, ...E }), $("div", { className: R("ff-data-table-container", a == null ? void 0 : a.container), children: [c(vt, { listCode: e, isConditionFormLayout: W }), c(ta, { title: f, className: a == null ? void 0 : a.toolbar, tabs: y, tab: M, onTabChange: I }), c(Ja, { ...q, primaryKey: h, className: "ff-data-table-content", columns: i, dataSource: r, operationRender: j ? (v) => c("div", { className: "ff-data-table-actions", children: u == null ? void 0 : u.reduce((se, V, me) => [...se, c(S.Link, { size: "small", uuid: V.uuid, type: V.type, name: V.name, widget: V.widget, widgetType: V.widgetType, widgetProps: V.widgetProps, widgetData: V.widgetData, widgetSetting: V.widgetSetting, widgetContainerProps: V.widgetContainerSetting, data: v, onAfterClick: (Ne) => Ne !== !1 && (D == null ? void 0 : D(V.isRefresh, data)) }, V.uuid || me)], []) }) : null }), c(na, { isPaginate: b, isOperations: o, operations: l, total: O, page: K, pageSize: _ })] })] });
}, Oe = C.createContext({ listCode: "", getBase62params: (e, t) => {
}, onReload: () => {
}, onClickCallback: () => {
}, onConditonChange: () => {
}, onTabChange: () => {
}, onSiderChange: () => {
}, onKeywordChange: () => {
}, onPageChange: () => {
}, onPageSizeChange: () => {
} }), Da = ({ isItemGridLayout: e, theme: t, themeProps: a, onClickCallback: n, onReload: r, getBase62params: i, listCode: s, onPageChange: o, onPageSizeChange: l, onTabChange: u, onSiderChange: d, onKeywordChange: m, onConditonChange: h, ...f }) => {
const [y, b] = P();
return x(() => {
t ? Q.getWidgetComponent(t).then((w) => {
if (!w) throw `${t} not found`;
return w;
}).catch((w) => ({ default: () => `${w}` })).then((w) => b(C.createElement(w.default, { ...f, $setting: a }))) : y || b(null);
}, [t, a]), c(Oe.Provider, { value: { listCode: s, onClickCallback: n, onReload: r, getBase62params: i, onPageChange: o, onPageSizeChange: l, onTabChange: u, onSiderChange: d, onKeywordChange: m, onConditonChange: h }, children: y ? C.cloneElement(y, { ...f, $setting: a }) : c(e ? za : Ua, { ...f, $setting: a }) });
};
var we, ue, Le, at;
const ae = class ae {
constructor() {
F(this, ue, null);
F(this, Le, /* @__PURE__ */ new Map());
F(this, at, () => {
if (p(this, ue)) return p(this, ue).port.postMessage({ command: "status", data: [] });
z(this, ue, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), p(this, ue).port.onmessage = (t) => {
var a, n;
(a = t.data) != null && a.uuid ? p(this, Le).forEach((r, i) => {
var s;
(r == "*" || (s = r == null ? void 0 : r.includes) != null && s.call(r, t.data.uuid)) && i(t.data);
}) : ((n = t.data) == null ? void 0 : n.readyState) == WebSocket.CLOSED && N.get("/api/user-api-token").then(({ token: r, expire_at: i }) => {
p(this, ue).port.postMessage({ command: "initWs", data: [`ws${g.trimStart(N.appUrl, "http")}api/user-resource-status-ws?token=${r}`] });
});
}, p(this, ue).port.postMessage({ command: "status", data: [] });
});
k(this, "subscribe", (t, a = []) => (a ? Array.isArray(a) && a.length == 0 ? a = "*" : Array.isArray(a) || (a = [a].flat()) : a = "*", p(this, Le).set(t, a), p(this, Le).size == 1 && p(this, at).call(this), () => this.unsubscribe(t)));
k(this, "unsubscribe", (t) => p(this, Le).delete(t));
if (p(ae, we)) return p(ae, we);
}
};
we = new WeakMap(), ue = new WeakMap(), Le = new WeakMap(), at = new WeakMap(), F(ae, we, null), k(ae, "getInstance", () => (p(ae, we) || z(ae, we, new ae()), p(ae, we)));
let pt = ae;
const Zt = pt.getInstance(), kt = C.forwardRef(({ listCode: e, base62params: t, className: a, itemClassName: n, theme: r, themeProps: i, classNames: s }, o) => {
const l = la(), u = X(t), d = X(/* @__PURE__ */ new Map()), m = X([]), [{ resource: h, primaryKey: f, batchOperations: y = [], itemOperations: b = [], columns: w = [], themeConfig: E, theme: W, isConditionFormLayout: q = !1, isTreeSider: U, treeSiderConfig: D, isItemGridLayout: I, itemGridLayout: O, title: K, isPaginate: M, tabs: _ }, j] = P({ isItemGridLayout: !1, itemGridLayout: {} }), v = g.throttle((T) => {
m.current = [], N.list(e, g.pick({ ...u.current, ...T }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: B, condition: Ve, total: xe, tab: he, sider: Ee, page: oe, pageSize: le, operationsAccess: ce, dataSource: Te }) => {
u.current = { tab: he, condition: Ve, sider: Ee, keyword: B, total: xe, pageSize: le, page: Te != null && Te.length ? oe : 1 }, m.current = Te, d.current = new Map(ce), l();
});
}, 380, { leading: !1, trailing: !0 }), se = gt(b, m.current, d.current, f), V = gt(y);
x(() => {
let T = null;
return e && N.get(`/api/_/${e}`).resp(({ data: B, res: Ve }) => {
B != null && B.isDynamicRefresh && (T = Zt.subscribe(() => v(), Ve)), u.current.pageSize = B.pageSize, j(B);
}).catch(() => j({})), m.current = [], () => T == null ? void 0 : T();
}, [e]), an(() => {
e && v(t);
}, [e, t]);
const me = () => {
v();
}, Ne = (T = 0, B = null) => {
if (T === 2) {
const Ve = g.get(B, "__PARENT_ID__", ""), xe = g.get(B, f, g.get(B, [h, f], "")), he = g.findIndex(m.current, ["__PARENT_ID__", Ve]), Ee = g.findIndex(he > -1 ? g.get(m.current, [he, "children"]) : m.current, [f, xe]);
Ee > -1 ? (N.get(`/api/${e}/detail/${xe}`).then((oe) => {
const le = g.get(m.current, he > -1 ? [he, "children", Ee, "children"] : [Ee, "children"]);
m.current = Ft(m.current, he > -1 ? { [he]: { children: { $splice: [[Ee, 1, { ...oe, children: le }]] } } } : { $splice: [[Ee, 1, { ...oe, children: le }]] }), l();
}), N.post(`/api/${e}/list-operations-access`, { ids: xe }).then((oe) => new Map(oe)).then((oe) => {
d.current.forEach((le, ce) => {
var Te;
(Te = oe.get(ce)) != null && Te.some((it) => it == xe) || d.current.set(ce, le.filter((it) => it !== xe));
}), oe.forEach((le, ce) => {
d.current.has(ce) ? d.current.set(ce, g.uniq([...d.current.get(ce) || [], ...le])) : d.current.set(ce, le);
}), l();
})) : me();
} else T === 1 && me();
};
C.useImperativeHandle(o, () => ({ onReload: me, onClickCallback: Ne }));
const rt = { listCode: e, title: K, itemClassName: n, classNames: s, resource: h, primaryKey: f, theme: r || W, themeProps: i || E, isTreeSider: U, treeSiderConfig: D, isPaginate: M, tabs: _, isItemOperations: se, isBatchOperations: V, batchOperations: y, itemOperations: b, isItemGridLayout: I, columns: w, itemGridLayout: O, isConditionFormLayout: q, itemOperationsAccess: d.current, dataSource: m.current };
return c(Da, { ...rt, className: R("ff-data-list-helper", a), getBase62params: (T, B, Ve = !1) => T == "init" ? t : T ? g.get(u.current, T, B) : u.current, onReload: me, onClickCallback: Ne, onConditonChange: (T, B) => v({ keyword: B, condition: Ft(u.current.condition || {}, { $merge: T || {} }), page: 1 }), onTabChange: (T) => v({ tab: T, page: 1 }), onSiderChange: (T) => v({ sider: T, page: 1 }), onKeywordChange: (T) => v({ keyword: T, page: 1 }), onPageChange: (T, B) => v({ page: T, pageSize: B }), onPageSizeChange: (T) => v({ pageSize: T, page: 1 }) });
}), ea = (e, t, a, n, r = {}, i = 0) => {
const s = { "--grid-layout-h": `${n}`, "--grid-layout-w": `${a}`, "--grid-layout-x": `${e}`, "--grid-layout-y": `${t}`, "--grid-layout-row-height-offset": "0px" };
return r != null && r.autoHeight ? s.height = "fit-content" : s["--grid-layout-row"] = `${n}`, s["--grid-layout-box-margin"] = Ot(r == null ? void 0 : r.marginTop, r == null ? void 0 : r.marginRight, r == null ? void 0 : r.marginBottom, r == null ? void 0 : r.marginLeft), s["--grid-layout-box-padding"] = Ot(r == null ? void 0 : r.paddingTop, r == null ? void 0 : r.paddingRight, r == null ? void 0 : r.paddingBottom, r == null ? void 0 : r.paddingLeft), i && (s.height = `${i}px`), s;
}, Ot = (e, t, a, n) => `${e || 0}px ${t || 0}px ${a || 0}px ${n || 0}px`, vt = ({ className: e, isConditionFormLayout: t }) => {
var m, h;
const [a, n] = P({}), { listCode: r, onKeywordChange: i, onConditonChange: s, getBase62params: o } = C.useContext(Oe), { keyword: l, condition: u } = (o == null ? void 0 : o()) || {}, [d] = Ze.useForm();
return x(() => {
r && t && N.get(`/api/_/${r}/list-condition-form-layout`).then(({ resource: f, marginX: y, marginY: b, rowHeight: w, cols: E, fields: W }) => {
n({ resource: f, itemMargin: [y, b], rowHeight: w, cols: E, fields: W });
}).catch(() => n({}));
}, [r, t]), x(() => {
d.setFieldsValue({ keyword: l, ...u });
}, [JSON.stringify([l, u])]), c("div", { className: R("ff-data-list-filter", e), children: c(Ze, { form: d, layout: "vertical", autoComplete: "off", onFinish: ((m = a.fields) == null ? void 0 : m.length) > 1 ? (f) => s({ [a.resource]: f[a.resource] }, f.keyword) : () => {
}, onValuesChange: (f) => {
g.isEmpty(g.omit(f, ["keyword"])) || d.submit();
}, children: ((h = a.fields) == null ? void 0 : h.length) > 1 ? c(St, { ...a, children: c(qa, { onReset: () => {
const { keyword: f, condition: y } = o("init") || {};
d.setFieldsValue({ keyword: f, ...y });
} }) }) : c("div", { className: "ff-data-list-filter-default-form ff-grid-layout-form", children: c("div", { className: "grid-layout-item", style: ea(20, 0, 5, 2), children: c(Ze.Item, { name: ["keyword"], children: c(fa.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (f) => i(f) }) }) }) }) }) });
}, qa = ({ cols: e, fields: t, onReset: a }) => {
const [n, r] = P(!1), i = pe(() => t == null ? void 0 : t.toReversed().some((s) => s.y > 1 || s.x + s.w >= e - 5), [e, t]);
return $(Ze.Item, { label: " ", style: { "--item-span": 5 }, className: R("ff-data-list-filter-actions", { expanded: n }), children: [c(lt, { onClick: a, children: "重置" }), c(lt, { type: "primary", htmlType: "submit", children: "查询" }), i && c(S.Link, { className: "ff-data-list-filter-expanded-button", widget: () => r((s) => !s), type: "primary", name: n ? "关闭" : "展开", icon: n ? "icon-up" : "icon-down", iconPosition: "end" })] });
};
vt.reservedFields = [{ x: 0, y: 0, h: 3, w: 5, field: { isVirtual: !0, widgetPrefix: "@pkg/grid-layout-forms", widget: "Input", code: "keyword", label: "关键字", placeholder: "多关键字 | 分割", extras: { prefix: "icon-search" } } }];
const ta = ({ className: e, title: t, tabs: a, tab: n, onTabChange: r }) => {
const [i, s] = $a(a == null ? void 0 : a[0].value, { value: n, onChange: r });
return $("div", { className: R("ff-data-list-toolbar", e), children: [c("div", { className: "ff-data-list-title", children: t }), c(ya, { className: "ff-data-list-tabs", itemRender: ({ label: o, code: l }) => c("span", { onClick: () => s(l), className: R("ff-data-list-tab", { active: l == i }), children: o }), items: a }), $("div", { className: "ff-data-list-actions", children: [c(S.Link, { icon: "icon-reload" }), c(S.Link, { icon: "icon-setting" })] })] });
}, Ha = [{ title: "parent 1", key: "0-0", children: [{ title: "parent 1-0", key: "0-0-0", disabled: !0, children: [{ title: "leaf", key: "0-0-0-0", disableCheckbox: !0 }, { title: "leaf", key: "0-0-0-1" }] }, { title: "parent 1-1", key: "0-0-1", children: [{ title: c("span", { style: { color: "#1677ff" }, children: "sss" }), key: "0-0-1-0" }] }] }], aa = ({ className: e, width: t = 280, isTreeSider: a }) => a ? c(wa.DirectoryTree, { className: R("ff-data-list-sider", e), style: { "--sider-width": t }, showLine: !0, showIcon: !1, treeData: Ha }) : null, na = ({ className: e, operations: t, isOperations: a, isPaginate: n, total: r, page: i, pageSize: s }) => {
const { onPageChange: o, onPageSizeChange: l, onClickCallback: u } = C.useContext(Oe);
return a && !g.isEmpty(t) || n ? $("div", { className: R("ff-data-list-footer", e), children: [c("div", { className: "ff-data-list-actions", children: t == null ? void 0 : t.map((d, m) => c(S, { uuid: d.uuid, type: d.type, name: d.name, widget: d.widget, widgetType: d.widgetType, widgetProps: d.widgetProps, widgetData: d.widgetData, widgetSetting: d.widgetSetting, widgetContainerProps: d.widgetContainerSetting, onAfterClick: (h) => h !== !1 && (u == null ? void 0 : u(d.isRefresh, null)) }, d.uuid || m)) }), n && c(Ca, { size: "small", total: r, pageSize: s, showSizeChanger: !1, showTotal: (d) => `${i} 页 / 总共 ${d}`, onChange: o, onShowSizeChange: l })] }) : null;
}, ra = (e, t, a = !0) => a !== !0 && a-- <= 0 ? [] : g.isArray(e) && !g.isEmpty(e) ? e.reduce((n, r) => (Reflect.has(r, t) && Reflect.has(r, "children") && n.push(r[t]), Reflect.has(r, "children") && !g.isEmpty(r.children) ? n.concat(ra(r.children, t, a)) : n), []) : [], Ja = ({ className: e, primaryKey: t, columns: a = [], dataSource: n = [], operationRender: r, operationWidth: i = 180, ...s }) => {
Dt();
const o = X(null), l = X(null), [u, d] = P([]), [m, h] = P({ width: 0, height: 0 });
x(() => {
d(ra(n, t));
}, [n, t]), ha(() => {
const y = new ResizeObserver(() => {
var b;
h({ width: ((b = o.current) == null ? void 0 : b.nativeElement.querySelector(".ant-table-body").scrollWidth) || l.current.offsetWidth, height: l.current.offsetHeight });
});
return l.current && y.observe(l.current), () => {
l.current && y.unobserve(l.current);
};
}, []);
const f = Wa(a);
return c("div", { ref: l, className: R("ff-data-list-table", e), children: m.height ? c(ba, { ...s, ref: o, rowKey: (y) => (y == null ? void 0 : y[t]) ?? Math.random(), columns: f == null ? void 0 : f.concat(r ? [{ title: "操作", align: "center", fixed: "right", width: `${Math.ceil(i / m.width * 100).toFixed(2)}%`, render: (y, b, w) => r(b, w) }] : []), dataSource: n, size: "middle", scroll: { x: "max-content", y: m.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: d, expandedRowKeys: u } }) : null });
}, Ka = "RC_FORM_INTERNAL_HOOKS", ia = (e, { initialValue: t, initialValueLanguage: a, convertJs: n, convertJsSetting: r, type: i = "string" }, s = null) => {
const o = X(!1), l = _e(Na), [u, d] = P(), [m, h] = P(a != "javascript" && e ? l.getFieldValue(e) : void 0), { registerWatch: f } = l.getInternalHooks(Ka) || {};
return x(() => f == null ? void 0 : f((y, b, w) => {
if (!o.current) return;
const E = g.get(b, e);
g.isEqual(E, m) || h(g.toPrimitive(E, i));
}), [m]), x(() => {
a == "javascript" && t ? $e.exec(t, {}, { getFieldValueForBasicForm: (y) => s ? s.getFieldValue(y) : l.getFieldValue(y), getFieldValue: (y) => l.getFieldValue(y) }).then((y) => h(g.toPrimitive(y, i))).catch((y) => notification.error({ message: `布局数据错误: ${JSON.stringify(y)}` })).finally(() => o.current = !0) : (t && h(g.toPrimitive(t ?? l.getFieldValue(e), i)), o.current = !0);
}, [t, a]), Ye(() => {
o.current && n && Q.getWidgetComponent(n).then(({ default: y }) => y({ value: m, record: l.getFieldsValue(!0), $setting: r })).then(d).catch((y) => console.error("布局数据转换错误: ", y, n));
}, [m, n, r]), [u || m, m];
}, sa = (e, t, a = "@pkg/grid-layouts", n = null) => pe(() => {
var r;
return (r = g.sortBy(e, ["y", "x"])) == null ? void 0 : r.map(({ i, x: s, y: o, w: l, h: u, field: { boxStyle: d, widgetPrefix: m = a, widget: h, ...f } }, y) => c("div", { className: "grid-layout-item", style: ea(s, o, l, u, d, h === "Height" && (f == null ? void 0 : f.initialValue)), children: c(_a, { ...f, basicForm: n, itemWidget: h != null && h.startsWith("@") || h != null && h.startsWith("blob:") ? h : `${m}/${h}`, itemWidgetRender: t }) }, i || y));
}, [e]), _a = ({ itemWidget: e, itemWidgetRender: t, basicForm: a, ...n }) => {
const [r, i] = P();
return x(() => {
Q.getWidgetComponent(e).then(({ defaultProps: s = {}, default: o }) => {
i(C.createElement(t(o, s, a), n));
}).catch((s) => {
console.error(s), i(e);
});
}, [e]), r;
}, oa = ({ cols: e = 12, rowHeight: t = 21, fields: a = [], data: n, containerPadding: r = [0, 0], itemMargin: i = [4, 0], formProps: s = {}, className: o, ...l }) => {
const [u] = ie.useForm(), d = sa(a, Ga, "@pkg/grid-layouts"), m = pe(() => [{ name: "__PROPS__", value: s }], [s]);
return Ye(() => {
u.setFieldsValue(n);
}, [n]), c(ie, { fields: m, form: u, component: !1, children: c("div", { ...l, className: R("ff-grid-layout", o), style: { "--grid-layout-item-margin-y": `${(i == null ? void 0 : i[0]) || 0}px`, "--grid-layout-item-margin-x": `${(i == null ? void 0 : i[1]) || 0}px`, "--grid-layout-container-padding-y": `${(r == null ? void 0 : r[0]) || 0}px`, "--grid-layout-container-padding-x": `${(r == null ? void 0 : r[1]) || 0}px`, "--grid-layout-cols": e, "--grid-layout-row-height": `${t}px` }, children: d }) });
}, Ga = (e, t = {}, a = null) => (n) => {
const { code: r, label: i, extras: s, isVirtual: o, initialValue: l, initialValueLanguage: u, convertJs: d, convertJsSetting: m, ...h } = g.merge({}, t, n), [f, y] = ia(o ? null : r, { initialValue: l, initialValueLanguage: u, convertJs: d, convertJsSetting: m, type: (h == null ? void 0 : h.type) || "string" }, a);
return c(e, { ...h, value: f, rawValue: y, $setting: s || {} });
}, _n = (Vt = oa, function({ code: e, data: t, ...a }) {
const [n, r] = P({ resource: null, cols: 12, rowHeight: 21, fields: [] });
return x(() => {
e && N.get(`/api/_/${e}`).then((i) => r(g.pick(i, ["resource", "cols", "rowHeight", "fields"])));
}, [e]), (n == null ? void 0 : n.resource) && c(Vt, { ...a, rowHeight: n.rowHeight, cols: n.cols, fields: n.fields, data: n != null && n.resource ? { [n == null ? void 0 : n.resource]: t } : {} });
});
var Vt;
const Gn = ({ widget: e, widgetPrefix: t = "@pkg/grid-layouts", basicForm: a, ...n }) => {
const r = e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, [i, s] = P();
return x(() => {
r && Q.getWidgetComponent(r).then(({ defaultProps: o = {}, default: l }) => ({ default: Ya(l, o, a) })).catch((o) => ({ default: () => `${o}` })).then((o) => s(C.createElement(o.default, n)));
}, [r]), i;
}, Ya = (e, t = {}, a = null) => (n) => {
const { code: r, label: i, extras: s, isVirtual: o, initialValue: l, initialValueLanguage: u, convertJs: d, convertJsSetting: m, value: h, ...f } = g.merge({}, t, n), [y, b] = ia(o ? null : r, { initialValue: l, initialValueLanguage: u, convertJs: d, convertJsSetting: m, type: (f == null ? void 0 : f.type) || "string" }, a);
return c(e, { ...f, value: y, rawValue: b, $setting: s || {} });
}, Xa = ({ cols: e, rowHeight: t, itemMargin: a, fields: n, primaryKey: r, dataSource: i, itemClassName: s, itemRender: o = (m, h, f) => m, empty: l = c(ka, { description: null }), className: u, style: d = {} }) => {
const m = Dt(), h = pe(() => c(oa, { cols: e, rowHeight: t, itemMargin: a, fields: n, className: s }), [n, e, t, a]);
return c("div", { className: R("ff-data-list-content", u), style: d, children: g.isEmpty(i) ? l : i == null ? void 0 : i.map((f, y) => c(C.Fragment, { children: o(C.cloneElement(h, { data: f }), f, y) }, `${m}-${(f == null ? void 0 : f[r]) || y}`)) });
}, Qa = ({ component: e }) => {
const { base62params: t } = xa();
return c(J, { children: c(kt, { listCode: e, base62params: N.decode(t) }) });
}, Za = () => "Empty", en = ({ component: e, $setting: t }) => {
const [a, n] = P();
return x(() => {
if (!e) return n(c(Za, { description: null }));
Q.getWidgetComponent(e).catch((r) => ({ default: () => `${r}` })).then((r) => C.createElement(r.default, { $setting: t })).then(n);
}, [e]), a ? C.cloneElement(a, {}) : null;
};
var Ce, Z, be, ke, Je, Ke;
const ne = class ne {
constructor() {
F(this, Z, /* @__PURE__ */ new Map());
F(this, be, {});
F(this, ke, null);
k(this, "init", (t, a) => {
z(this, Z, t), z(this, be, a);
});
k(this, "get", (t) => (p(this, Z).has(t) || (t = Array.from(p(this, Z).keys()).find((a) => p(this, Z).get(a).uri === t)), p(this, Z).get(t) || {}));
k(this, "redirect", (t, a, n = {}) => {
const { uri: r, type: i, widgetProps: s } = this.get(t) || {};
let o = Ea(r || t, i != "list" ? a : g.mapValues(a, (u) => N.encode(u)));
const l = new URLSearchParams();
for (const u in s || {}) (s == null ? void 0 : s.type) == "query" && l.append(u, a[u]);
return l.size > 0 && (o = `${o}?${l.toString()}`), p(this, ke).navigate(o, n);
});
k(this, "getMenus", (t) => {
var a;
return ((a = p(this, be)) == null ? void 0 : a[t]) || [];
});
k(this, "findMenuPathByUuid", (t) => {
let a = [];
for (const n in p(this, be)) if (a = p(this, Je).call(this, p(this, be)[n], t, [n]), a.length > 1) return a;
return a;
});
k(this, "getMenusByRouteUuid", (t) => p(this, Ke).call(this, t, Object.values(p(this, be)).flat()));
F(this, Je, (t, a, n = []) => {
if (g.isEmpty(t)) return n;
for (const { uuid: r, children: i } of t) {
if (r == a) return n.concat(r);
if (!g.isEmpty(i)) return n.concat(r, p(this, Je).call(this, i, a));
}
return n;
});
F(this, Ke, (t, a) => {
var r;
let n = [];
for (const i of a) i.widgetType == "redirect" && (i.uuid == t || i.widget == t ? n.push(i) : (r = i.children) != null && r.length && (n = n.concat(p(this, Ke).call(this, t, i.children))));
return n;
});
k(this, "getCurrentMenu", () => {
const { uuid: t } = this.getCurrentRoute() || {};
if (!t) return;
const a = this.getMenusByRouteUuid(t);
return g.isEmpty(a) ? void 0 : a[0];
});
k(this, "getCurrentRoute", (t = 0) => {
var n;
const a = (n = p(this, ke).state.matches[p(this, ke).state.matches.length - 1 - t]) == null ? void 0 : n.route;
if (!a) return null;
for (let [r, i] of p(this, Z)) if (i.uri === a.path) return i;
return null;
});
k(this, "getPageParams", (t) => {
var i;
const { location: a, matches: n } = p(this, ke).state, r = ((i = n[n.length - 1]) == null ? void 0 : i.params) || {};
return a.search && new URLSearchParams(a.search).forEach((s, o) => {
r[o] = s;
}), t ? g.get(r, t) : r;
});
k(this, "createBrowserRouter", (t = {}) => {
if (p(this, Z).size == 0) return null;
const a = Ue.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/frameworks/BasicLayout"), n = Ue.get(Q.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), r = { [a]: 0 }, i = (o, l) => () => Q.getWidgetComponent(o).then((u) => u.default || function() {
return `${o}`;
}).then((u) => ({ Component: () => C.createElement(_t, {}, C.createElement(u, l)) })), s = Array.from(p(this, Z).values()).reduce((o, { uuid: l, uri: u, name: d, type: m, component: h, widgetSetting: f, isLogin: y, isLayout: b, extra: w }) => {
let E = {}, W = 0;
switch (m) {
case "list":
E.element = C.createElement(Qa, { component: h });
break;
case "fsdpf-component":
E.element = C.createElement(en, { key: h, component: h, $setting: f });
}
if (w != null && w.layout) {
if (!r[w == null ? void 0 : w.layout]) return r[w == null ? void 0 : w.layout] = o.length, [...o, { path: "/", lazy: i(w == null ? void 0 : w.layout, {}), children: [{ path: u, ...E }] }];
W = r[w == null ? void 0 : w.layout];
}
return b && W > -1 ? (o[W].children.push({ path: u, ...E }), o) : [...o, { path: u, ...E }];
}, [{ path: "/", lazy: i(a, {}), children: [] }]);
return s.push({ index: !0, element: C.createElement(tn, { to: n, replace: !0 }) }), z(this, ke, Ta(s, t));
});
if (p(ne, Ce)) return p(ne, Ce);
}
};
Ce = new WeakMap(), Z = new WeakMap(), be = new WeakMap(), ke = new WeakMap(), Je = new WeakMap(), Ke = new WeakMap(), F(ne, Ce, null), k(ne, "getInstance", () => (p(ne, Ce) || z(ne, Ce, new ne()), p(ne, Ce)));
let mt = ne;
const tn = ({ to: e, replace: t }) => Fa() ? C.createElement(Ra, { to: e, replace: t }) : (window.document.location = e, "redirect"), Pe = mt.getInstance(), je = new Worker(new URL("/ff-worker/index.js", self.location)), jt = { getConfigure: (e) => Ue.get(e), route: { redirect: (...e) => Pe.redirect(...e), getPageParams: (...e) => Pe.getPageParams(...e), getCurrentRoute: () => Pe.getCurrentRoute() }, popup: { notification: (...e) => G.notification(...e), success: (...e) => G.success(...e), error: (...e) => G.error(...e), form: (...e) => G.form(...e), modal: (...e) => G.modal(...e), confirm: (...e) => G.confirm(...e) } };
var nt, We, ve;
const A = class A {
constructor() {
k(this, "exec", (t, a = {}, n = {}, r = "") => new Promise((i, s) => {
const o = Et(A, nt)._++;
p(A, We).set(o, n), A.mQueue.set(o, [i, s]), je.postMessage({ id: o, session: r, category: "eval", method: t, args: a });
}));
k(this, "clear", (t) => je.postMessage({ session: t, category: "clear" }));
if (p(A, ve)) return p(A, ve);
Promise.resolve().then(() => Nn).then((t) => {
jt.http = t.http;
}), je.addEventListener("message", ({ data: { id: t, task_id: a, method: n, args: r, category: i, data: s, error: o, session: l } }) => {
if (i === "eval" && A.mQueue.has(t)) o !== null ? A.mQueue.get(t)[1](o) : A.mQueue.get(t)[0](s), p(A, We).delete(t), A.mQueue.delete(t);
else if (i === "util") try {
const u = g.get(jt, n.split("/")) || g.get(p(A, We).get(a), n.split("/"));
if (!g.isFunction(u)) throw `${n} not found`;
Promise.resolve(Reflect.apply(u, void 0, r)).then((d) => {
je.postMessage({ id: t, task_id: a, category: i, method: n, args: r, session: l, data: d, error: null });
}).catch((d) => {
je.postMessage({ id: t, task_id: a, category: i, method: n, args: r, session: l, data: null, error: d });
});
} catch (u) {
je.postMessage({ id: t, task_id: a, category: i, method: n, args: r, session: l, data: null, error: u });
}
}, !1);
}
};
nt = new WeakMap(), We = new WeakMap(), ve = new WeakMap(), k(A, "mQueue", /* @__PURE__ */ new Map()), F(A, nt, 0), F(A, We, /* @__PURE__ */ new Map()), F(A, ve, null), k(A, "getInstance", () => (p(A, ve) || z(A, ve, new A()), p(A, ve)));
let ht = A;
const $e = ht.getInstance(), la = () => {
const e = X(!0), [, t] = C.useReducer((a) => a + 1, 0);
return x(() => () => e.current = !1, []), () => e.current && t();
}, At = (e) => {
const t = X();
return x(() => {
t.current = e;
}, [e]), t.current;
}, Yn = (e) => {
const [t, a] = P(e), n = X(null), r = ge((i, s) => {
n.current = s, a(i);
}, []);
return x(() => {
n.current && (n.current(t), n.current = null);
}, [t]), [t, r];
}, Ye = (e = (n) => {
}, t, a = g.isEqual) => {
const n = C.useRef();
a(t, n.current) || (n.current = g.cloneDeep(t)), C.useEffect(e, [n.current]);
}, an = Ye, ca = (e, t = "string") => {
var a;
if (!Array.isArray(e)) return e;
for (let n = 0; n < e.length; n++) e[n].value = g.toPrimitive((a = e[n]) == null ? void 0 : a.value, t), e[n] && Reflect.has(e[n], "children") && (e[n].children = ca(e[n].children, t));
return e;
}, Xn = (e, t = "json", a = "string", n, r = null) => {
const [i] = ie.useForm(n), [s, o] = P([{ label: "无", value: "", disabled: !0 }]), l = X([]), u = ie.useWatch((d) => l.current.length === 0 ? null : g.pick(d, l.current), i) || null;
return x(() => {
Array.isArray(e) ? o(e) : t === "javascript" && e ? $e.exec(e, {}, { getFieldValue: (d) => (l.current.includes(d) || l.current.push(d), i.getFieldValue(d)), getFieldValueForBasicForm: (d) => (l.current.includes(d) || l.current.push(d), r ? r.getFieldValue(d) : i.getFieldValue(d)) }).then((d) => {
o(g.toPrimitive(d, "array"));
}) : e && o(g.toPrimitive(e, "array"));
}, [e, t, u]), ca(s, a);
}, Qn = (e) => {
const [t, a] = P(), n = { type: "GET" };
if (typeof e == "string" ? n.url = e : g.isPlainObject(e) && Object.assign(n, e), !(n != null && n.url)) throw "url is required";
const r = (i) => N.request(n, !1).resp((s) => (console.log("useSubscribeRequest", i), a(s), s));
return Ye(() => {
let i = null;
return r().then((s) => {
i = Zt.subscribe(g.throttle(r, 180, { leading: !1, trailing: !0 }), s.res);
}), () => i == null ? void 0 : i();
}, n), t;
}, nn = (e) => {
const [t, a] = C.useState({ gridItems: [], hideItems: [] });
return C.useEffect(() => {
e && N.get(`/api/_/${e}`).then(({ pk: n, uuid: r, code: i, resource: s, align: o, cols: l, rowHeight: u, marginX: d, marginY: m, listenChangeFields: h, listenChangeFieldsFunc: f, fields: y }) => ({ pk: n, uuid: r, code: i, resource: s, align: o, cols: l, rowHeight: u, marginX: d, marginY: m, listenChangeFields: h, listenChangeFieldsFunc: f, ...y.reduce((b, w) => {
var E;
return (E = w == null ? void 0 : w.field) != null && E.hidden ? b.hides.push(w == null ? void 0 : w.field) : b.items.push(w), b;
}, { items: [], hides: [] }) })).then(a);
}, [e]), t;
}, rn = ({ max: e = 0, min: t = 0, type: a = "", message: n, pattern: r, required: i = !1, validator: s } = {}, o, l) => {
const [u, d] = P([]);
return x(() => {
const m = [];
if (i) {
let h = l;
switch (l) {
case "number":
case "string":
case "array":
break;
case "bool":
h = "boolean";
break;
case "json":
h = "object";
}
m.push({ type: h, required: !0, whitespace: !0, message: "该项必填" });
}
switch (a) {
case "string":
m.push({ type: a, max: e, min: t, message: n || (t && e ? `字符必须在 ${t} ~ ${e} 之间` : `${e ? "最多能有" : "最少要有"} ${t || e} 个字符`) });
break;
case "pattern":
m.push({ type: "string", pattern: r, message: n });
break;
case "validator":
s && m.push(({ getFieldValue: h }) => ({ validator: async (f, y) => {
const b = await $e.exec(s, { value: y, fieldName: o }, { getFieldValue: h });
return g.isString(b) && b ? Promise.reject(b) : g.isBoolean(b) && !b ? Promise.reject(n) : Promise.resolve();
} }));
}
d(m);
}, [e, t, a, n, r, i, s]), u;
}, sn = (e, t, a) => {
const [n, r] = P(null);
return x(() => {
const { initDataUri: i = `/api/${e}`, initDataMethod: s = "GET" } = a || {};
t && N.request({ method: s, url: g.trimEnd(`${i}/${t}`, "/") }).then((o) => {
r(o);
});
}, [e, t, a]), n;
}, on = (e, t, a, n = {}) => {
const r = la(), i = X(!0), s = X([]), [o, l] = P(a), u = ie.useWatch((d) => JSON.stringify(g.pick(d, s.current)), t) || "{}";
return x(() => {
e && $e.exec(e, n, { getFieldValue: g.wrap(t.getFieldValue, (d, m) => (s.current.some((h) => g.isEqual(h, m)) || (s.current.push(m), r()), d(m))), isFieldTouched: t.isFieldTouched, isFieldsTouched: t.isFieldsTouched }).then((d) => i.current && l(d));
}, [e, u, t, n]), x(() => () => i.current = !1, []), o;
}, ln = ({ type: e, initialValue: t, initialValueLanguage: a, onChange: n, form: r }) => {
const i = on(a == "javascript" && t, r, a == "javascript" ? void 0 : t, {});
return x(() => {
a == "javascript" ? n(g.toPrimitive(i, e)) : t && n(g.toPrimitive(t, e));
}, [e, t, i]), null;
}, cn = ({ widget: e = "Input", widgetPrefix: t = "@pkg/grid-layout-forms", widgetDecorator: a, subWidgets: n, basicForm: r, ...i }) => {
const s = e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, [o, l] = P();
return x(() => {
s && Q.getWidgetComponent(s).then(({ defaultProps: u = {}, default: d }) => ({ default: da(d, u, r) })).catch((u) => ({ default: () => `${u}` })).then((u) => l(C.createElement(u.default, i)));
}, [s]), o && C.cloneElement(o, i);
}, da = (e, t = {}, a = null) => (n) => {
const { type: r, code: i, label: s, noStyle: o, placeholder: l, extras: u, validators: d, help: m, isVirtual: h, $isReserved: f, initialValue: y, initialValueLanguage: b, convertJs: w, convertJsSetting: E, widgetPerfix: W, boxStyle: q, widgetDecorator: U, subWidgets: D, ...I } = { ...t, ...n }, O = rn(d || {}, i, r), K = { label: s, noStyle: o, colon: !1, layout: "vertical" }, M = { placeholder: l, ...I }, _ = ge((j) => j == null ? void 0 : g.toPrimitive(j, r), [r]);
return c(qt, { name: i, rules: O, initialValue: _(y), normalize: _, children: (j, v, se) => {
var V;
return c(e, { type: r, rcform: se, itemProps: { validateStatus: v.errors.length > 0 ? "error" : "success", tooltip: m, help: v.errors.length > 0 ? v.errors.join("、") : null, required: ((V = O == null ? void 0 : O[0]) == null ? void 0 : V.required) || !1, ...K }, fieldProps: { ...M, ...j }, $setting: u || {} });
} });
}, St = ({ cols: e = 24, rowHeight: t = 16, itemMargin: a = [8, 16], containerPadding: n = [0, 0], fields: r = [], children: i, basicForm: s = null }) => {
const o = sa(r, da, "@pkg/grid-layout-forms");
return $("div", { className: "ff-grid-layout-form", style: { "--grid-layout-item-margin-x": `${(a == null ? void 0 : a[0]) ?? 8}px`, "--grid-layout-item-margin-y": `${(a == null ? void 0 : a[1]) ?? 16}px`, "--grid-layout-container-padding-y": `${(n == null ? void 0 : n[0]) || 0}px`, "--grid-layout-container-padding-x": `${(n == null ? void 0 : n[1]) || 0}px`, "--grid-layout-cols": e, "--grid-layout-row-height": `${t}px` }, children: [o, i && C.cloneElement(i, { cols: e, rowHeight: t, itemMargin: a, containerPadding: n, fields: r })] });
};
St.propTypes = { fields: L.array };
const dn = (It = St, ({ code: e, layout: t, name: a, primaryKey: n = 0, style: r = {}, formProps: i = {}, form: s, isPreview: o = !1, className: l, onFinish: u, onValuesChange: d = () => {
}, ...m }) => {
const { align: h, autoComplete: f, resource: y, items: b, hides: w, rowHeight: E, marginX: W, marginY: q, cols: U, listenChangeFields: D, listenChangeFieldsFunc: I, pk: O, uuid: K } = nn(e), [M] = ie.useForm(s), _ = pe(() => [{ name: "__PK__", value: O }, { name: "__PROPS__", value: i }, { name: "__RESOURCE__", value: y }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: K }, { name: "__PRIMARY_KEY__", value: n }], [O, e, K, y, n, i]);
return $(ie, { className: l, name: a || e, layout: t || h, fields: _, form: M, autoComplete: f, style: { ...r, position: "relative" }, onFinish: u, onValuesChange: (j, v) => (({ changedValues: se, allValues: V, listenChangeFields: me, listenChangeFieldsFunc: Ne, onValuesChange: rt, code: T }) => {
rt(se, V), Ne && Array.isArray(me) && $e.exec(Ne, { changedValues: se, allValues: V }, { getFieldValue: M.getFieldValue, setFieldValue: M.setFieldValue, setFieldsValue: M.setFieldsValue, isFieldTouched: M.isFieldTouched, isFieldsTouched: M.isFieldsTouched });
})({ changedValues: j, allValues: v, listenChangeFields: D, listenChangeFieldsFunc: I, onValuesChange: d, code: e }), children: [c(It, { ...m, form: M, code: e, fields: b, cols: U, rowHeight: E, itemMargin: [W, q] }), w == null ? void 0 : w.map((j) => {
var v;
return c(qt, { name: j.code, children: c(ln, { form: M, name: j.code, type: j.type, initialValue: j.initialValue, initialValueLanguage: (v = j.extras) == null ? void 0 : v.initialValueLanguage }) }, JSON.stringify(j.code));
})] }, e);
});
var It;
const ua = ({ $setting: e, $close: t, extras: a, code: n, primaryKey: r, ...i }) => {
const [s] = ie.useForm(), o = sn(n, r, e);
return x(() => {
o && s.setFieldsValue(o);
}, [o]), c(J, { actions: $(C.Fragment, { children: [c(S, { name: "保存", type: "primary", widget: () => {
const l = s.getFieldValue("__RESOURCE__"), { initDataUri: u = `/api/${n}` } = e || {};
s.validateFields(!0).then((d) => l ? g.pick(d, [l]) : d).then((d) => N.post(r ? `${u}/${r}` : `${u}`, d).msg(t)).catch(() => G.error("请先完善表单信息", { duration: 2e3 }));
} }), c(S, { name: "取消", widget: () => t(!1) })] }), extras: a, children: c(dn, { form: s, code: n, primaryKey: r, ...i }) });
}, un = (e, t, a, { isReplaceRouteHistory: n = !1 } = {}) => Pe.redirect(a, t, { replace: n }), Mt = (e, t, a, { status: { loading: n, disabled: r }, setStatus: i }) => {
const s = { loading: (o) => o === void 0 ? n : i((l) => ({ ...l, loading: o })), disabled: (o) => o === void 0 ? r : i((l) => ({ ...l, disabled: o })) };
return g.isFunction(a) ? a.call(null, { ...t, ...s }) : g.isString(a) && a ? $e.exec(a, t, s) : null;
}, Wt = (e, t, a, n, r) => g.isString(a) && a ? Q.getWidgetComponent(a).then(({ default: i }) => G.modal(i, { ...t, $setting: n }, r != null && r.title ? { ...r, title: g.template(r.title)(e) } : r)).catch((i) => {
G.error(a, { content: i.toString() });
}) : G.modal(a, { ...t, $setting: n }, r != null && r.title ? { ...r, title: g.template(r.title)(e) } : r), gn = (e, t, a, n, r) => G.modal(ua, { ...t, $setting: n, code: a }, r != null && r.title ? { ...r, title: g.template(r.title)(e) } : r), pn = (e, t, a, n, r) => G.modal(kt, { base62params: t, $setting: n, listCode: a }, r != null && r.title ? { ...r, title: g.template(r.title)(e) } : r), mn = ({ widget: e, widgetType: t, widgetData: a, widgetProps: n, widgetSetting: r, widgetContainerProps: i }, { onAfterClick: s, onBeforeClick: o }) => {
const l = _e(Oe), [u, d] = P({ leading: !0, trailing: !1 }), m = pe(() => {
switch (t) {
case "redirect":
return g.partialRight(un, e, r);
case "func":
return g.partialRight(Mt, (r == null ? void 0 : r.code) ?? e, { status: u, setStatus: d });
case "fsdpf-component":
return g.partialRight(Wt, e, r, i);
case "grid-layout-form":
return g.partialRight(gn, e, r, i);
case "data-list":
return g.partialRight(pn, e, r, i);
default:
if ($t(e) || C.isValidElement(e)) return g.partialRight(Wt, e, r, i);
if (g.isFunction(e)) return g.partialRight(Mt, (r == null ? void 0 : r.code) || e, { status: u, setStatus: d });
}
return (...h) => console.error("useButton unknown widgetType", t, ...h);
}, [e, t]);
return [g.debounce((h) => (o == null || o(h), Promise.resolve(Yt(n, h, { list: l })).then((f) => m(h, { ...a, ...f })).then((f) => s == null ? void 0 : s(f)).catch(console.error)), 300, { leading: !0, trailing: !1 }), u];
}, zt = /* @__PURE__ */ new Set(), ft = (e = [], t = 0) => {
const a = e[t];
if (a.length && !zt.has(a)) {
const n = document.createElement("script");
n.setAttribute("src", a), n.setAttribute("data-namespace", a), e.length > t + 1 && (n.onload = () => {
ft(e, t + 1);
}, n.onerror = () => {
ft(e, t + 1);
}), zt.add(a), document.body.appendChild(n);
}
}, yt = ({ className: e, type: t, style: a = {}, ...n }) => c("span", { role: "img", className: R("ff-iconfont", e), style: a, ...n, children: c("svg", { style: { width: "1em", height: "1em", fill: "currentColor", overflow: "hidden" }, viewBox: "0 0 1024 1024", children: c("use", { xlinkHref: `#${t}` }) }) });
yt.propTypes = { className: L.string, type: L.string.isRequired, style: L.object }, yt.init = ft;
const Xe = (e) => function({ className: t, children: a, name: n, icon: r, type: i = "default", iconPosition: s = "start", noAuthType: o, onAfterClick: l, onBeforeClick: u, data: d, loading: m, disabled: h, tooltip: f, popConfirm: y, widget: b, widgetType: w, widgetData: E, widgetProps: W, widgetSetting: q, widgetContainerProps: U, ...D }) {
const I = { type: "primary", className: R("ff-button", t), iconPosition: s };
i === "danger" ? I.danger = !0 : i === "default" && (I.type = i), e === "link" || e === "dashed" ? (I.type = e, i === "default" && (I.className = R(I.className, "ff-default"))) : e !== "circle" && e !== "round" || (I.shape = e), r && (I.icon = c(yt, { type: r }));
const [O, K] = P(!1), [M, { disabled: _, loading: j }] = mn({ widget: b, widgetType: w, widgetData: E, widgetProps: W, widgetSetting: q, widgetContainerProps: U }, { onAfterClick: l, onBeforeClick: u });
return c(va, { okText: "确定", cancelText: "取消", ...y || {}, disabled: _ || h, open: O, onOpenChange: (v) => {
if (!v) return K(v);
y ? K(v) : M(d);
}, onConfirm: () => {
M(d);
}, onClick: (v) => {
v.stopPropagation();
}, children: c(Sa, { ...f, title: O ? null : f == null ? void 0 : f.title, trigger: ["hover", "click"], children: c(lt, { loading: j || m, disabled: _ || h, ...I, ...D, children: a || n }) }) });
}, S = Xe("default"), hn = Xe("link"), fn = Xe("circle"), yn = Xe("round"), wn = Xe("dashed"), Bt = ({ data: e, widget: t, widgetType: a = "fsdpf-component", children: n, widgetData: r, widgetProps: i, widgetSetting: s, widgetContainerProps: o }) => {
const l = _e(Oe), [u, d] = P(!1), [m, h] = P("hover"), [f, y] = P({}), [b, w] = P(), { placement: E, align: W, arrow: q = { pointAtCenter: !0 }, ...U } = o || {};
x(() => {
a == "grid-layout-form" ? w(C.createElement(ua, { ...r, $setting: s, code: t })) : a == "data-list" ? w(C.createElement(kt, { base62params: e, $setting: s, listCode: t })) : g.isString(t) ? Q.getWidgetComponent(t).then(({ default: O }) => {
w(C.createElement(O, { ...r, $setting: s }));
}).catch((O) => w(O.toString())) : $t(t) ? w(C.createElement(t, { ...r, $setting: s })) : C.isValidElement(t) && w(C.cloneElement(t, { ...r, $setting: s }));
}, [t, a, r]), x(() => {
Promise.resolve(Yt(i, e, { list: l })).then(y);
}, [i, e]);
const D = (O) => {
d(O), !O && h("hover");
}, I = () => {
d(!0), h("click");
};
return c(Pa, { zIndex: 1080, placement: E, onPopupClick: I, onClick: I, open: u, align: W, arrow: q, trigger: m, content: c(Cn, { ...U, children: b && C.cloneElement(b, { ...f, $close: () => D(!1) }) }), children: n, onOpenChange: D });
}, Cn = ({ title: e, className: t, children: a, width: n, height: r, ...i }) => {
const [s, o] = P({}), l = ge((m, h) => o((f) => ({ ...f, [m]: h })), []), u = ge((m) => o((h) => ({ ...h, [m]: void 0 })), []), d = e ? C.createElement("div", { className: "ff-popup-title" }, e) : s == null ? void 0 : s.title;
return c(Ge.Provider, { value: { ele: s, mount: l, unmount: u }, children: $("div", { className: R("ff-popup ff-popover", t), style: { width: n, height: r }, ...i, children: [$("div", { className: "ff-popup-header", children: [d, s == null ? void 0 : s["sub-title"]] }), a, $("div", { className: "ff-popup-footer", children: [s == null ? void 0 : s.extras, s == null ? void 0 : s.actions] })] }) });
};
Bt.propTypes = { widgetType: L.oneOf(["fsdpf-component", "grid-layout-form", "data-list"]) }, S.propTypes = { type: L.oneOf(["primary", "default", "danger", ""]), name: L.string, icon: L.string, iconPosition: L.oneOf(["start", "end"]), data: L.any, widget: L.any, widgetType: L.oneOf(["destroy", "redirect", "func", "fsdpf-component", "grid-layout-form", "grid-layout", "data-list"]), widgetData: L.object, widgetProps: L.object, widgetSetting: L.object, widgetContainerProps: L.object }, S.Link = hn, S.Link.defaultProps = S.defaultProps, S.Link.propTypes = S.propTypes, S.Circle = fn, S.Circle.defaultProps = S.defaultProps, S.Circle.propTypes = S.propTypes, S.Round = yn, S.Round.defaultProps = S.defaultProps, S.Round.propTypes = S.propTypes, S.Dashed = wn, S.Dashed.defaultProps = S.defaultProps, S.Dashed.propTypes = S.propTypes, S.Popover = Bt;
const bn = ({ fields: e, formProps: t, $close: a }) => {
const [n] = ie.useForm(), r = pe(() => [{ name: "__PROPS__", value: t }], [t]);
return c(J, { actions: $(C.Fragment, { children: [c(S, { name: "取消", widget: () => a(!1) }), c(S, { name: "确定", type: "primary", widget: () => n.validateFields(!0).then(a) })] }), children: c(ie, { fields: r, form: n, className: "ff-modal-form", children: e == null ? void 0 : e.map(({ code: i, ...s }) => c(cn, { code: i, ...s }, i)) }) });
}, kn = ({ className: e, $close: t, children: a, title: n, subTitle: r, actions: i, extras: s, zIndex: o, ...l }) => $(Va, { ...l, prefixCls: "ff-drawer", className: R("ff-popup", e), maskMotion: { motionAppear: !0, motionName: "mask-motion" }, motion: (u) => ({ motionAppear: !0, motionName: `panel-motion-${u}` }), children: [$("div", { className: "ff-popup-header", children: [c("button", { "aria-label": "Close", className: "ff-popup-close", onClick: l.onClose, children: c(bt, { type: "close" }) }), n, r] }), c("div", { className: "ff-popup-body", children: a }), $("div", { className: "ff-popup-footer", children: [s, i] })] }), vn = ({ className: e, $close: t, $event: a, children: n, title: r, subTitle: i, actions: s, extras: o, zIndex: l, placement: u, ...d }) => {
const m = (a == null ? void 0 : a.pageX) === void 0 ? { animation: null, maskAnimation: null, mousePosition: { x: null, y: null } } : { animation: "zoom", maskAnimation: "fade", mousePosition: { x: a == null ? void 0 : a.pageX, y: a == null ? void 0 : a.pageY } };
return c(ja, { ...d, ...m, prefixCls: "ff-modal", modalRender: () => $("div", { className: R("ff-modal-content ff-popup", e), children: [$("div", { className: "ff-popup-header", children: [c("button", { "aria-label": "Close", className: "ff-popup-close", onClick: d.onClose, children: c(bt, { type: "close" }) }), r, i] }), c("div", { className: "ff-popup-body", children: n }), $("div", { className: "ff-popup-footer", children: [o, s] })] }) });
}, ga = ({ placement: e, $close: t, $event: a, children: n, title: r, ...i }) => {
const [s, o] = P({}), [l, u] = P(!0), d = ge((y, b) => o((w) => ({ ...w, [y]: b })), []), m = ge((y) => o((b) => ({ ...b, [y]: void 0 })), []);
let h = { ...i, className: s.rootClassName, title: s.title || r && C.createElement("div", { className: R("ff-popup-title") }, r), subTitle: s["sub-title"], actions: s.actions, extras: s.extras, children: n, $close: t, $event: a, onClose: () => u(!1) };
const f = () => {
t(!1);
};
return c(Ge.Provider, { value: { ele: s, mount: d, unmount: m }, children: e && e !== "center" ? c(kn, { ...h, placement: e, open: l, afterOpenChange: (y) => !y && f() }) : c(vn, { ...h, visible: l, afterClose: f }) });
};
ga.propTypes = { placement: L.oneOf(["center", "left", "top", "right", "bottom"]) };
const H = () => {
const [e, t] = La({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (i) => {
const { offsetHeight: s } = i;
return { height: s };
}, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, a] = C.useReducer((i) => i + 1, 0);
x(() => {
H.$onClick = n, H.$queue.forEach(([i, s, o], l, u) => {
r([s, o], ...i), delete u[l];
});
}, []);
const n = (i, s = {}, o = {}) => new Promise((l, u) => r([l, u], i, s, o)), r = ([i, s], o, l = {}, u = {}) => {
const d = H.$index++, m = (h) => ((f, y) => (H.$popups.delete(f), a(), y == null ? void 0 : y()))(d, () => i(h));
if (o === Gt) return e.open({ ...u, key: d, content: C.createElement(o, { ...l, $close: () => e.close(d) }) });
H.$popups.set(d, C.createElement(ga, { zIndex: d, maskClosable: !1, $event: l == null ? void 0 : l.$event, ...u, key: d, $close: m }, C.isValidElement(o) ? C.cloneElement(o, { ...l, $close: m }) : o != null && o.name || Tt.isForwardRef(o) || (o == null ? void 0 : o.$$typeof) === Tt.ForwardRef ? C.createElement(o, { ...l, $close: m }) : o)), a();
};
return $(C.Fragment, { children: [Array.from(H.$popups).map(([i, s]) => s), t] });
};
H.$popups = /* @__PURE__ */ new Map(), H.$index = 0, H.$queue = [], H.$onClick = (...e) => new Promise((t, a) => {
H.$queue.push([e, t, a]);
});
const Ut = (e, t, a = {}) => H.$onClick(e, t, a), st = (e, { showProgress: t, duration: a, ...n } = { duration: 1.5 }) => H.$onClick(Gt, { content: e, ...n }, { showProgress: t, duration: a }), G = { modal: Ut, confirm: (e, t = {}) => H.$onClick(Aa, { content: e, ...t }, { placement: "center" }), form: (e, t = {}, a = {}) => Ut(bn, { formProps: a, fields: e }, { placement: "center", ...t }).then((n) => {
if (n === !1) throw !1;
return n;
}), notification: st, success: (e, t = { duration: 1.5 }) => st(e, { ...t, className: "ff-notification-success", icon: "check" }), error: (e, t = { duration: 1.5 }) => st(e, { ...t, className: "ff-notification-error", icon: "close" }) };
ze.configure({ showSpinner: !1 }), Be.interceptors.request.use((e) => {
e.headers.Platform = "web", e.headers.SaaS = window.localStorage.getItem("SaaS");
const t = window.localStorage.getItem(tt);
return e.headers.Authorization = t ? `Bearer ${t} ` : void 0, ze.inc(), e;
}, (e) => (ze.done(), Promise.reject({ code: -1, msg: e }))), Be.interceptors.response.use(({ data: e, headers: t }) => (ze.done(), { ...e, res: t == null ? void 0 : t.res }), function(e) {
return ze.done(), Promise.reject(e.message);
}), window.addEventListener("unhandledrejection", ct.onUnhandledRejection), ct.onMsg = (e, t) => G[[0, 1].includes(e) ? "success" : "error"](t).then(() => e === 20300 && Pe.redirect(Ue.get("Common.WEBSITE_LOGIN_PAGE")));
const wt = { appUrl: "", init: (e, t, a) => {
wt.appUrl = a, Be.defaults.baseURL = a, Be.defaults.timeout = 15e3, Object.assign(wt, new ct(e, t, Be));
} }, N = wt;
class Pt extends Error {
constructor(t, a) {
super(a), Error.captureStackTrace && Error.captureStackTrace(this, Pt), !a instanceof De && (this.name = `${t} Error Runtime`);
}
}
class De extends Error {
constructor(t, ...a) {
super(...a), Error.captureStackTrace && Error.captureStackTrace(this, De), this.name = `${t} Not Found`;
}
}
const ot = "mine", tt = "token";
var Se, Y;
const re = class re {
constructor() {
F(this, Y, /* @__PURE__ */ new Map());
k(this, "setVendor", (t, a) => p(this, Y).set(t, new Kt(a, async (n, r) => {
var s, o;
if (!(n != null && n.default)) throw "@pkg not found";
let i = () => r;
switch ("function") {
case typeof (i = (s = n.default) == null ? void 0 : s[`./${r}/index.jsx`]):
case typeof (i = (o = n.default) == null ? void 0 : o[`./${r}/index.js`]):
return i();
}
throw new De(r);
})));
k(this, "getWidgetComponent", async (t) => {
if (!t) throw "getWidgetComponent widget is required";
if (t != null && t.startsWith("@pkg/")) return await import(`${N.appUrl}/api/pkg-import?name=${t}`);
if (t != null && t.startsWith("blob:") || t != null && t.startsWith("http:") || t != null && t.startsWith("https:")) return await import(t);
const [, a] = t == null ? void 0 : t.split("@ff/"), [, n] = t == null ? void 0 : t.split("@app/"), [, r] = t == null ? void 0 : t.split("@pkg/"), [, i] = t == null ? void 0 : t.split("@fsdpf/");
try {
switch (!0) {
case (!!a && p(this, Y).has("pkg")):
return await p(this, Y).get("pkg").get(a);
case (!!n && p(this, Y).has("pkg")):
return await p(this, Y).get("pkg").get(n);
case (!!r && p(this, Y).has("pkg")):
return await p(this, Y).get("pkg").get(r);
case (!!i && p(this, Y).has("pkg")):
return await p(this, Y).get("pkg").get(i);
default:
throw new De(t);
}
} catch (s) {
throw new Pt(t, s);
}
});
k(this, "getRoutes", () => N.get("/api/my-router").then((t) => [...t, { uuid: "data-list-setting", isLayout: !0, uri: "/data-list-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/DataListSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "grid-layout-setting", isLayout: !0, uri: "/grid-layout-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/GridLayoutSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "grid-layout-form-setting", isLayout: !0, uri: "/grid-layout-form-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/GridLayoutFormSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "resource-api-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/ResourceApiSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "charts-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/ChartsSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "fsm-setting", isLayout: !0, uri: "/fsm-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/FsmSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "component-setting", isLayout: !0, uri: "/component-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/components/ff-design/ComponentSetting", extra: { layout: "@pkg/frameworks/DesignTheme" } }, { uuid: "login", uri: "/login", name: "登录", type: "fsdpf-component", isLogin: !1, component: "@pkg/components/ff/Login" }, { uuid: "not-found", uri: "*", name: "Not Found", type: "fsdpf-component", isLogin: !1, component: "@pkg/components/ff/NotFound" }].map(({ uuid: a, ...n }) => [a, { uuid: a, ...n }])).then((t) => new Map(t)));
k(this, "getMenus", () => N.get("/api/my-menu"));
k(this, "getConfigure", () => N.get("api/init-configure"));
k(this, "getWidgetOperationAuth", () => N.get("/api/init-widget-operation-auth").then((t) => t.reduce((a, { uuid: n, auth: r }) => [...a, [n, r]], [])));
k(this, "getPhoneNumber", (t) => N.get(`/api/user-wx-phone-number/${t}`));
k(this, "getUserToken", () => {
const t = window.localStorage.getItem(tt);
if (!t) return "";
const a = t.split(".");
if (!Array.isArray(a) || a.length !== 3) throw "登录令牌无效!";
const { iat: n } = JSON.parse(window.atob(a[1]));
if (Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - n > 2592e3) throw "登录令牌已过期, 请重新登录!";
return t;
});
k(this, "checkUserToken", () => {
try {
return !!this.getUserToken();
} catch {
return !1;
}
});
k(this, "getUserInfo", (t = !0) => {
var a;
try {
const n = this.getUserToken();
if (!n) return Promise.resolve(null);
const { iat: r } = JSON.parse(window.atob((a = n == null ? void 0 : n.split(".")) == null ? void 0 : a[1])), { iat: i, ...s } = N.decode(window.localStorage.getItem(ot) || "", {});
return i === r ? Promise.resolve(s) : N.get("/api/mine-info").then(({ User: o = null }) => (window.localStorage.setItem(ot, N.encode({ ...o, iat: r })), o));
} catch (n) {
console.error(n), t && Popup.error("请登录").then(logout);
}
return Promise.resolve(null);
});
k(this, "login", (t, a, n = {}) => N.post("/api/user-token", { username: t, passwd: Oa.hash(a), platform: "web", ...n }).then(({ token: r }) => (window.localStorage.setItem(tt, r), r)));
k(this, "logout", () => {
window.localStorage.removeItem(ot), window.localStorage.removeItem(tt);
});
if (p(re, Se)) return p(re, Se);
}
};
Se = new WeakMap(), Y = new WeakMap(), F(re, Se, null), k(re, "getInstance", () => (p(re, Se) || z(re, Se, new re()), p(re, Se)));
let Ct = re;
const Q = Ct.getInstance(), Sn = C.createContext({ user: {}, initUser: () => {
}, initUserComplete: !1 }), Pn = C.createContext({ set: () => {
}, get: () => {
}, assign: () => {
}, currentRoute: () => {
} }), $t = (e) => !!(e != null && e.name) && (e.prototype instanceof C.Component || /^[A-Z]/.test(e.name)), $n = (e, t) => {
if (!e || typeof window > "u") return;
let a = document.querySelector(`style[ff-style-token="${t}"]`);
return a ? (a.innerHTML = e, e) : (a = document.createElement("style"), a.setAttribute("ff-style-token", t), a.setAttribute("type", "text/css"), a.innerHTML = e, document.head.appendChild(a), e);
}, Nn = Object.freeze(Object.defineProperty({ __proto__: null, AppContext: Sn, AppGlobalParamsContext: Pn, cache: Kt, configure: Ue, default: Q, func: $e, http: N, insertStyle: $n, isReactComponent: $t, route: Pe }, Symbol.toStringTag, { value: "Module" })), xn = (e, t, a = "children") => {
if (g.isEmpty(e)) return {};
const n = g.find(e, ["value", t]);
if (!g.isEmpty(n)) return n;
const r = e.length;
for (let i = 0; i < r; i++) {
const { [a]: s } = e[i], o = xn(s, t, a);
if (!g.isEmpty(o)) return o;
}
return {};
};
export {
$t as $,
Xn as A,
Qn as B,
dn as C,
Da as D,
St as E,
cn as F,
_n as G,
Ka as H,
ua as I,
nn as J,
rn as K,
sn as L,
on as M,
yt as N,
S as O,
Ia as P,
mn as Q,
Zt as R,
J as S,
Ge as T,
_t as U,
H as V,
G as W,
Dn as X,
qn as Y,
Hn as Z,
Q as _,
ra as a,
$n as a0,
N as a1,
Kt as a2,
Ue as a3,
$e as a4,
Pe as a5,
Sn as a6,
Pn as a7,
xn as a8,
oa as b,
Gn as c,
sa as d,
vt as e,
ta as f,
ea as g,
aa as h,
na as i,
kt as j,
Oe as k,
Ja as l,
Xa as m,
za as n,
Ua as o,
Ma as p,
Wa as q,
Jn as r,
Kn as s,
gt as t,
ia as u,
la as v,
At as w,
Yn as x,
Ye as y,
an as z
};

2
dist/components.js vendored
View File

@ -1,4 +1,4 @@
import { X as s, N as p, Y as n, Z as t, W as d } from "./common/main-19SFdrvj.js";
import { X as s, N as p, Y as n, Z as t, W as d } from "./common/main-DJpuXYIP.js";
export {
s as Empty,
p as Icon,

2
dist/container.js vendored
View File

@ -1,4 +1,4 @@
import { T as o, X as s, Y as p, Z as t, U as d, W as n, V as r, S as u } from "./common/main-19SFdrvj.js";
import { T as o, X as s, Y as p, Z as t, U as d, W as n, V as r, S as u } from "./common/main-DJpuXYIP.js";
export {
o as Context,
s as Empty,

2
dist/data-list.js vendored
View File

@ -1,4 +1,4 @@
import { m as s, k as e, e as r, i, n as o, j as D, h as l, l as u, f as L, o as n, D as d, p as m, q as F, s as p, t as C, r as b } from "./common/main-19SFdrvj.js";
import { m as s, k as e, e as r, i, n as o, j as D, h as l, l as u, f as L, o as n, D as d, p as m, q as F, s as p, t as C, r as b } from "./common/main-DJpuXYIP.js";
export {
s as DataListContent,
e as DataListContext,

View File

@ -1,5 +1,5 @@
import "lodash";
import { a as t } from "../common/main-19SFdrvj.js";
import { a as t } from "../common/main-DJpuXYIP.js";
export {
t as getDefaultExpandRowKeys
};

View File

@ -1,4 +1,4 @@
import { E as r, I as u, F as e, C as o, M as t, L as F, K as d, J as m } from "./common/main-19SFdrvj.js";
import { E as r, I as u, F as e, C as o, M as t, L as F, K as d, J as m } from "./common/main-DJpuXYIP.js";
export {
r as GridLayoutForm,
u as GridLayoutFormHelper,

View File

@ -1,5 +1,5 @@
import "lodash";
import { a7 as a } from "../common/main-19SFdrvj.js";
import { a8 as a } from "../common/main-DJpuXYIP.js";
export {
a as getOptionItemByValue
};

2
dist/grid-layout.js vendored
View File

@ -1,4 +1,4 @@
import { b as d, c as e, H as u, G as i, u as t, d as o } from "./common/main-19SFdrvj.js";
import { b as d, c as e, H as u, G as i, u as t, d as o } from "./common/main-DJpuXYIP.js";
export {
d as GridLayout,
e as GridLayoutWidget,

View File

@ -1,4 +1,4 @@
import { g as t } from "../common/main-19SFdrvj.js";
import { g as t } from "../common/main-DJpuXYIP.js";
export {
t as getBoxStyle
};

2
dist/hooks.js vendored
View File

@ -1,7 +1,7 @@
import "lodash";
import "rc-field-form";
import "react";
import { z as p, y as i, A as o, w as r, x as f, B as c, v as m } from "./common/main-19SFdrvj.js";
import { z as p, y as i, A as o, w as r, x as f, B as c, v as m } from "./common/main-DJpuXYIP.js";
export {
p as useDeepEffect,
i as useDeepEqualEffect,

2
dist/iconfont.js vendored
View File

@ -2,7 +2,7 @@ import "react/jsx-runtime";
import "react";
import "prop-types";
import "classnames";
import { N as a } from "./common/main-19SFdrvj.js";
import { N as a } from "./common/main-DJpuXYIP.js";
export {
a as default
};

13
dist/index.js vendored
View File

@ -1,12 +1,13 @@
import { a5 as t, a6 as e, a1 as o, a2 as p, _ as n, a3 as c, a0 as r, $ as f, a4 as u } from "./common/main-19SFdrvj.js";
import { a6 as t, a7 as e, a2 as o, a3 as n, _ as p, a4 as r, a1 as c, a0 as f, $ as l, a5 as u } from "./common/main-DJpuXYIP.js";
export {
t as AppContext,
e as AppGlobalParamsContext,
o as cache,
p as configure,
n as default,
c as func,
r as http,
f as isReactComponent,
n as configure,
p as default,
r as func,
c as http,
f as insertStyle,
l as isReactComponent,
u as route
};

2
dist/res-ws.js vendored
View File

@ -1,5 +1,5 @@
import "lodash";
import { R as a } from "./common/main-19SFdrvj.js";
import { R as a } from "./common/main-DJpuXYIP.js";
export {
a as default
};

View File

@ -1,7 +1,7 @@
{
"name": "ff",
"private": true,
"version": "0.4.14",
"version": "0.4.15",
"author": "www.fsdpf.com",
"type": "module",
"main": "./dist/index.js",