This commit is contained in:
what 2024-11-09 22:47:38 +08:00
parent 35b902b30d
commit bae404e449
17 changed files with 925 additions and 934 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-DQw7fSp9.js";
import { P as s, O as u, Q as e } from "./common/main-CcbZvxSB.js";
import "prop-types";
export {
s as auth,

910
dist/common/main-CcbZvxSB.js vendored Normal file
View File

@ -0,0 +1,910 @@
var pi = Object.defineProperty;
var Nt = (e) => {
throw TypeError(e);
};
var mi = (e, t, i) => t in e ? pi(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
var k = (e, t, i) => mi(e, typeof t != "symbol" ? t + "" : t, i), xt = (e, t, i) => t.has(e) || Nt("Cannot " + i);
var m = (e, t, i) => (xt(e, t, "read from private field"), i ? i.call(e) : t.get(e)), F = (e, t, i) => t.has(e) ? Nt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, i), B = (e, t, i, n) => (xt(e, t, "write to private field"), n ? n.call(e, i) : t.set(e, i), i);
var Et = (e, t, i, n) => ({
set _(r) {
B(e, t, r, i);
},
get _() {
return m(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 Y, useId as Dt, useLayoutEffect as hi } from "react";
import g from "lodash";
import R from "classnames";
import { Form as Ze, Input as fi, Button as lt, Breadcrumb as yi, Tree as wi, Pagination as Ci, Table as bi, Empty as ki, Popconfirm as vi, Tooltip as Si, Popover as Pi } from "antd";
import { useMergedState as $i } from "rc-util";
import re, { FieldContext as Ni, Field as qt } from "rc-field-form";
import { useParams as xi, generatePath as Ei, createBrowserRouter as Ti, useInRouterContext as Fi, Navigate as Ri } from "react-router-dom";
import L from "prop-types";
import * as Tt from "react-is";
import { useNotification as Li } from "rc-notification";
import { N as We, a as Be, w as ct, S as Oi } from "./vender-egxe712p.js";
import Ft from "immutability-helper";
import Vi from "rc-drawer";
import ji 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), ([i, n]) => g.isObjectLike(n) ? Ht(n, i) : [[`${g.isUndefined(t) ? "" : t + "."}${i}`, n]]), Jt = (e, t = () => !1) => g.some(e, (i) => !!g.some(i, t) || (g.isEmpty(i) || !g.isPlainObject(i) && !g.isArray(i) ? void 0 : Jt(i, t))), et = (e, t) => e && typeof e == "object" ? Array.isArray(e) ? e.map((i) => et(i, t)) : Object.keys(e).reduce((i, n) => (t[n] ? i[t[n]] = et(e[n], t) : i[n] = et(e[n], t), i), {}) : e;
g.mixin({ toPrimitive: (e, t) => {
let i = "string";
i = Array.isArray(e) ? "array" : typeof e, g.isObject(e) && (i = "json");
const n = `${i}2${t}`;
return Reflect.has(Rt, n) ? Rt[n](e) : e;
}, toPairsDeep: Ht, deepSome: Jt, replaceKeys: et });
var je, qe, Ae, ce, Te, Fe;
class Kt {
constructor(t, i) {
F(this, je, /* @__PURE__ */ new Map());
F(this, qe, !0);
F(this, Ae, []);
F(this, ce);
F(this, Te, () => m(this, ce));
F(this, Fe, () => Promise.resolve());
k(this, "get", (...t) => new Promise((i, n) => {
const r = JSON.stringify(t);
if (m(this, je).has(r)) return i(m(this, Fe).call(this, m(this, ce), ...t));
if (m(this, ce) === void 0) m(this, Ae).push([t, i, n]), m(this, qe) && (B(this, qe, !1), Promise.resolve(typeof m(this, Te) == "function" ? m(this, Te).call(this) : m(this, Te)).then((s) => B(this, ce, s || null)).finally(() => {
m(this, Ae).forEach(([s, a, o]) => {
try {
const l = m(this, Fe).call(this, m(this, ce), ...s);
m(this, je).set(JSON.stringify(s), l), a(l);
} catch (l) {
o(l);
}
}), m(this, Ae).length = 0;
}));
else {
const s = m(this, Fe).call(this, m(this, ce), ...t);
m(this, je).set(r, s), i(s);
}
}));
B(this, Fe, i), B(this, Te, t);
}
}
je = new WeakMap(), qe = new WeakMap(), Ae = new WeakMap(), ce = new WeakMap(), Te = new WeakMap(), Fe = new WeakMap();
const Dn = () => c("div", { children: "Empty" }), Ge = C.createContext({ ele: {}, mount: () => {
}, unmount: () => {
} }), K = ({ rootClassName: e, className: t, children: i, actions: n, title: r, subTitle: s, extras: a, style: o = {} }) => {
const { mount: l, unmount: u } = C.useContext(Ge);
return n && K.Action({ children: n }), r && K.Title({ children: r }), s && K.SubTitle({ children: s }), a && K.Extra({ children: a }), x(() => (l("rootClassName", e), () => u(e)), [e]), c("div", { className: R("ff-container", t), style: o, children: i });
}, Qe = (e) => ({ children: t, className: i }) => {
const { mount: n, unmount: r } = C.useContext(Ge);
return x(() => (n(e, C.createElement("div", { key: `ff-${e}`, className: R(`ff-popup-${e}`, i) }, t)), () => r(e)), [i, t]), null;
};
K.Action = Qe("actions"), K.Title = Qe("title"), K.SubTitle = Qe("sub-title"), K.Extra = Qe("extras"), K.propTypes = { className: L.string, style: L.object, title: L.any, subTitle: L.any, actions: L.any, extras: L.any };
const qn = () => c(K, { 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, i] = P({}), n = ge((s, a) => i((o) => ({ ...o, [s]: a })), []), r = ge((s) => i((a) => ({ ...a, [s]: 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((i, n) => c("path", { d: i }, n)) }) }), Gt = ({ className: e, content: t, icon: i, $close: n }) => $(C.Fragment, { children: [i && c("div", { className: R("ff-notification-icon", e), children: c(bt, { type: i }) }), t] }), Ai = ({}) => c(K, { children: "Confirm" });
var fe, Ie;
const Z = class Z {
constructor() {
F(this, Ie, null);
k(this, "init", (t) => B(this, Ie, new Map(t)));
k(this, "check", (t) => !m(this, Ie).has(t) || m(this, Ie).get(t));
if (m(Z, fe)) return m(Z, fe);
}
};
fe = new WeakMap(), Ie = new WeakMap(), F(Z, fe, null), k(Z, "getInstance", () => (m(Z, fe) || B(Z, fe, new Z()), m(Z, fe)));
let dt = Z;
const Ii = dt.getInstance(), Yt = (e = {}, t = {}, i = {}, n = "") => g.deepSome(e, (r, s) => s === "type" && r === "code") ? Xt(e, t, i, n) : Qt(e, t, n), Xt = async (e = {}, t = {}, i = {}, n = "") => {
let r = /* @__PURE__ */ Object.create(null);
for (let s in e) {
let a;
if (Reflect.has(e[s], "type") && ["code", "field", "router", "query", "string"].includes(e[s].type)) {
const { type: o, value: l = "", default: u = n } = e[s];
switch (o) {
case "code":
a = await Pe.exec(l, t, i);
break;
case "field":
a = g.get(t, l) ?? g.get(t, l.substring(l.indexOf(".") + 1));
break;
case "router":
case "query":
a = ue.getPageParams(l);
break;
case "string":
a = l;
}
a ?? (a = u);
} else a = await Xt(e[s], t, i, n);
g.set(r, s, a);
}
return r;
}, Qt = (e = {}, t = {}, i = "") => Object.keys(e || {}).reduce((n, r) => {
if (g.isPlainObject(e[r])) {
let s;
if (Reflect.has(e[r], "type") && ["field", "router", "query", "string"].includes(e[r].type)) {
const { type: a, value: o = "", default: l = i } = e[r];
switch (a) {
case "field":
s = g.get(t, o) ?? g.get(t, o.substring(o.indexOf(".") + 1));
break;
case "router":
case "query":
s = ue.getPageParams(o);
break;
case "string":
s = o;
}
s ?? (s = l);
} else s = Qt(e[r], t, i);
g.set(n, r, s);
}
return n;
}, {});
var ye, He;
const ee = class ee {
constructor() {
F(this, He, null);
k(this, "init", (t) => B(this, He, t));
k(this, "get", (t, i) => g.get(m(this, He), t, i));
if (m(ee, ye)) return m(ee, ye);
}
};
ye = new WeakMap(), He = new WeakMap(), F(ee, ye, null), k(ee, "getInstance", () => (m(ee, ye) || B(ee, ye, new ee()), m(ee, ye)));
let ut = ee;
const Ue = ut.getInstance(), Mi = (e, t, i, n, r) => {
const s = C.lazy(() => X.getWidgetComponent(e).catch((a) => ({ default: () => `${a}` })));
return c(C.Suspense, { children: c(s, { value: t, record: i, $setting: n, base62params: r }) }, e);
}, zi = (e, t = {}) => (At(e), At(t), pe(() => e == null ? void 0 : e.map(({ widgetByJs: i, widgetByJsSetting: n, ...r }, s) => i && !i.endsWith("/BasicShowFieldData") ? { ...r, render: (a, o) => {
const l = Mi(i, a, o, n, t);
return g.isFunction(r == null ? void 0 : r.render) ? r.render(l, a, o) : l;
} } : r), [e, t])), Jn = (e) => {
const [t, i] = 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 && i(r)), () => n = !0;
}, [e]), t;
}, Kn = (e, t = {}) => {
const [i, n] = P({ dataSource: [] });
return Ye(() => {
let r = !1;
return e && N.get(`/api/${e}/${N.encode({ page: 1, ...t })}`).then((s) => !r && n(s)), () => r = !0;
}, [e, t]), i;
}, gt = (e, t = null, i = null, n = "id") => pe(() => {
if (g.isEmpty(e) || !e.some(({ uuid: s }) => Ii.check(s))) return !1;
if (g.isEmpty(i) || g.isEmpty(t)) return !0;
const r = t.map((s) => `${s == null ? void 0 : s[n]}`);
return e.some(({ uuid: s }) => !s || !i.has(s) || i.get(s).some((a) => r.includes(`${a}`)));
}, [e, t, i, n]), Wi = ({ className: e, itemClassName: t, classNames: i = {}, dataSource: n, isPaginate: r, isItemOperations: s, isBatchOperations: a, batchOperations: o, itemOperations: l, itemOperationsAccess: u, resource: d, primaryKey: p, title: h, itemGridLayout: f, $setting: y, tabs: b, isConditionFormLayout: w, isTreeSider: E, treeSiderConfig: W }) => {
const { getBase62params: q, onClickCallback: D, onTabChange: H } = _e(Le), { total: A, page: M, pageSize: I, tab: z } = (q == null ? void 0 : q()) || {}, _ = ge((V, v, se) => c(Bi, { className: R("ff-data-list-framework-item", t), operations: s && v ? l == null ? void 0 : l.filter((O) => !(p && O.uuid && u.has(O.uuid)) || u.get(O.uuid).includes(v == null ? void 0 : v[p])) : [], data: d ? { [d]: v } : v, children: V, onClickCallback: D }), [d, p, s, D, l, u]);
return $("div", { className: R("ff-data-list-framework", e), children: [c(ii, { className: i == null ? void 0 : i.sider, isTreeSider: E, ...W }), $("div", { className: R("ff-data-list-container", i == null ? void 0 : i.container), children: [c(vt, { className: i == null ? void 0 : i.filter, isConditionFormLayout: w }), c(ti, { title: h, className: i == null ? void 0 : i.toolbar, tabs: b, tab: z, onTabChange: H }), c(Xi, { ...f, className: i == null ? void 0 : i.content, style: { "--col-num": (y == null ? void 0 : y.colNum) || 1 }, primaryKey: p, itemRender: _, dataSource: n }), c(ni, { className: i == null ? void 0 : i.footer, isPaginate: r, isOperations: a, operations: o, total: A, page: M, pageSize: I })] })] });
}, Bi = ({ className: e, operations: t, children: i, data: n, onClickCallback: r }) => $("div", { className: R("data-list-grid-layout-item-container", e), children: [i, !!(t != null && t.length) && c("div", { className: "data-list-grid-layout-item-actions", children: t.map((s) => c("span", { className: "data-list-grid-layout-item-action", children: c(S.Link, { uuid: s.uuid, type: s.type, name: s.name, widget: s.widget, widgetType: s.widgetType, widgetProps: s.widgetProps, widgetSetting: s.widgetSetting, widgetContainerProps: s.widgetContainerSetting, data: n, onAfterClick: (a) => a !== !1 && (r == null ? void 0 : r(s.isRefresh, n)) }, s.uuid || useId()) }, (s == null ? void 0 : s.uuid) || useId())) })] }), Ui = ({ listCode: e, className: t, classNames: i = {}, itemClassName: n, dataSource: r, columns: s, isItemOperations: a, isBatchOperations: o, batchOperations: l, itemOperations: u, itemOperationsAccess: d, resource: p, primaryKey: h, title: f, tabs: y, isPaginate: b, isTreeSider: w, treeSiderConfig: E, isConditionFormLayout: W, ...q }) => {
const { getBase62params: D, onClickCallback: H, onTabChange: A } = _e(Le), { total: M, page: I, tab: z, pageSize: _ } = (D == null ? void 0 : D()) || {}, V = gt(u, r, d, h);
return $("div", { className: R("ff-data-table-framework", t), children: [c(ii, { className: i == null ? void 0 : i.sider, isTreeSider: w, ...E }), $("div", { className: R("ff-data-table-container", i == null ? void 0 : i.container), children: [c(vt, { listCode: e, isConditionFormLayout: W }), c(ti, { title: f, className: i == null ? void 0 : i.toolbar, tabs: y, tab: z, onTabChange: A }), c(Ji, { ...q, primaryKey: h, className: "ff-data-table-content", columns: s, dataSource: r, operationRender: V ? (v) => c("div", { className: "ff-data-table-actions", children: u == null ? void 0 : u.reduce((se, O, me) => [...se, c(S.Link, { size: "small", uuid: O.uuid, type: O.type, name: O.name, widget: O.widget, widgetType: O.widgetType, widgetProps: O.widgetProps, widgetData: O.widgetData, widgetSetting: O.widgetSetting, widgetContainerProps: O.widgetContainerSetting, data: v, onAfterClick: ($e) => $e !== !1 && (H == null ? void 0 : H(O.isRefresh, data)) }, O.uuid || me)], []) }) : null }), c(ni, { isPaginate: b, isOperations: o, operations: l, total: M, page: I, pageSize: _ })] })] });
}, Le = C.createContext({ listCode: "", getBase62params: (e, t) => {
}, onReload: () => {
}, onClickCallback: () => {
}, onConditonChange: () => {
}, onTabChange: () => {
}, onSiderChange: () => {
}, onKeywordChange: () => {
}, onPageChange: () => {
}, onPageSizeChange: () => {
} }), Di = ({ isItemGridLayout: e, theme: t, themeProps: i, onClickCallback: n, onReload: r, getBase62params: s, listCode: a, onPageChange: o, onPageSizeChange: l, onTabChange: u, onSiderChange: d, onKeywordChange: p, onConditonChange: h, ...f }) => {
const [y, b] = P();
return x(() => {
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, { ...f, $setting: i }))) : y || b(null);
}, [t, i]), c(Le.Provider, { value: { listCode: a, onClickCallback: n, onReload: r, getBase62params: s, onPageChange: o, onPageSizeChange: l, onTabChange: u, onSiderChange: d, onKeywordChange: p, onConditonChange: h }, children: y ? C.cloneElement(y, { ...f, $setting: i }) : c(e ? Wi : Ui, { ...f, $setting: i }) });
};
var we, de, Re, it;
const te = class te {
constructor() {
F(this, de, null);
F(this, Re, /* @__PURE__ */ new Map());
F(this, it, () => {
if (m(this, de)) return m(this, de).port.postMessage({ command: "status", data: [] });
B(this, de, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), m(this, de).port.onmessage = (t) => {
var i, n;
(i = t.data) != null && i.uuid ? m(this, Re).forEach((r, s) => {
var a;
(r == "*" || (a = r == null ? void 0 : r.includes) != null && a.call(r, t.data.uuid)) && s(t.data);
}) : ((n = t.data) == null ? void 0 : n.readyState) == WebSocket.CLOSED && N.get("/api/user-api-token").then(({ token: r, expire_at: s }) => {
m(this, de).port.postMessage({ command: "initWs", data: [`ws${g.trimStart(N.appUrl, "http")}api/user-resource-status-ws?token=${r}`] });
});
}, m(this, de).port.postMessage({ command: "status", data: [] });
});
k(this, "subscribe", (t, i = []) => (i ? Array.isArray(i) && i.length == 0 ? i = "*" : Array.isArray(i) || (i = [i].flat()) : i = "*", m(this, Re).set(t, i), m(this, Re).size == 1 && m(this, it).call(this), () => this.unsubscribe(t)));
k(this, "unsubscribe", (t) => m(this, Re).delete(t));
if (m(te, we)) return m(te, we);
}
};
we = new WeakMap(), de = new WeakMap(), Re = new WeakMap(), it = new WeakMap(), F(te, we, null), k(te, "getInstance", () => (m(te, we) || B(te, we, new te()), m(te, we)));
let pt = te;
const Zt = pt.getInstance(), kt = C.forwardRef(({ listCode: e, base62params: t, className: i, itemClassName: n, theme: r, themeProps: s, classNames: a }, o) => {
const l = li(), u = Y(t), d = Y(/* @__PURE__ */ new Map()), p = Y([]), [{ resource: h, primaryKey: f, batchOperations: y = [], itemOperations: b = [], columns: w = [], themeConfig: E, theme: W, isConditionFormLayout: q = !1, isTreeSider: D, treeSiderConfig: H, isItemGridLayout: A, itemGridLayout: M, title: I, isPaginate: z, tabs: _ }, V] = P({ isItemGridLayout: !1, itemGridLayout: {} }), v = g.throttle((T) => {
p.current = [], N.list(e, g.pick({ ...u.current, ...T }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: U, condition: Oe, total: Ne, tab: he, sider: xe, page: ae, pageSize: oe, operationsAccess: le, dataSource: Ee }) => {
u.current = { tab: he, condition: Oe, sider: xe, keyword: U, total: Ne, pageSize: oe, page: Ee != null && Ee.length ? ae : 1 }, p.current = Ee, d.current = new Map(le), l();
});
}, 380, { leading: !1, trailing: !0 }), se = gt(b, p.current, d.current, f), O = gt(y);
x(() => {
let T = null;
return e && N.get(`/api/_/${e}`).resp(({ data: U, res: Oe }) => {
U != null && U.isDynamicRefresh && (T = Zt.subscribe(() => v(), Oe)), u.current.pageSize = U.pageSize, V(U);
}).catch(() => V({})), p.current = [], () => T == null ? void 0 : T();
}, [e]), nn(() => {
e && v(t);
}, [e, t]);
const me = () => {
v();
}, $e = (T = 0, U = null) => {
if (T === 2) {
const Oe = g.get(U, "__PARENT_ID__", ""), Ne = g.get(U, f, g.get(U, [h, f], "")), he = g.findIndex(p.current, ["__PARENT_ID__", Oe]), xe = g.findIndex(he > -1 ? g.get(p.current, [he, "children"]) : p.current, [f, Ne]);
xe > -1 ? (N.get(`/api/${e}/detail/${Ne}`).then((ae) => {
const oe = g.get(p.current, he > -1 ? [he, "children", xe, "children"] : [xe, "children"]);
p.current = Ft(p.current, he > -1 ? { [he]: { children: { $splice: [[xe, 1, { ...ae, children: oe }]] } } } : { $splice: [[xe, 1, { ...ae, children: oe }]] }), l();
}), N.post(`/api/${e}/list-operations-access`, { ids: Ne }).then((ae) => new Map(ae)).then((ae) => {
d.current.forEach((oe, le) => {
var Ee;
(Ee = ae.get(le)) != null && Ee.some((st) => st == Ne) || d.current.set(le, oe.filter((st) => st !== Ne));
}), ae.forEach((oe, le) => {
d.current.has(le) ? d.current.set(le, g.uniq([...d.current.get(le) || [], ...oe])) : d.current.set(le, oe);
}), l();
})) : me();
} else T === 1 && me();
};
C.useImperativeHandle(o, () => ({ onReload: me, onClickCallback: $e }));
const rt = { listCode: e, title: I, itemClassName: n, classNames: a, resource: h, primaryKey: f, theme: r || W, themeProps: s || E, isTreeSider: D, treeSiderConfig: H, isPaginate: z, tabs: _, isItemOperations: se, isBatchOperations: O, batchOperations: y, itemOperations: b, isItemGridLayout: A, columns: w, itemGridLayout: M, isConditionFormLayout: q, itemOperationsAccess: d.current, dataSource: p.current };
return c(Di, { ...rt, className: R("ff-data-list-helper", i), getBase62params: (T, U, Oe = !1) => T == "init" ? t : T ? g.get(u.current, T, U) : u.current, onReload: me, onClickCallback: $e, onConditonChange: (T, U) => v({ keyword: U, 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, U) => v({ page: T, pageSize: U }), onPageSizeChange: (T) => v({ pageSize: T, page: 1 }) });
}), ei = (e, t, i, n, r = {}, s = 0) => {
const a = { "--grid-layout-h": `${n}`, "--grid-layout-w": `${i}`, "--grid-layout-x": `${e}`, "--grid-layout-y": `${t}`, "--grid-layout-row-height-offset": "0px" };
return r != null && r.autoHeight ? a.height = "fit-content" : a["--grid-layout-row"] = `${n}`, a["--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), a["--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), s && (a.height = `${s}px`), a;
}, Ot = (e, t, i, n) => `${e || 0}px ${t || 0}px ${i || 0}px ${n || 0}px`, vt = ({ className: e, isConditionFormLayout: t }) => {
var p, h;
const [i, n] = P({}), { listCode: r, onKeywordChange: s, onConditonChange: a, getBase62params: o } = C.useContext(Le), { 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: ((p = i.fields) == null ? void 0 : p.length) > 1 ? (f) => a({ [i.resource]: f[i.resource] }, f.keyword) : () => {
}, onValuesChange: (f) => {
g.isEmpty(g.omit(f, ["keyword"])) || d.submit();
}, children: ((h = i.fields) == null ? void 0 : h.length) > 1 ? c(St, { ...i, children: c(qi, { 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: ei(20, 0, 5, 2), children: c(Ze.Item, { name: ["keyword"], children: c(fi.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (f) => s(f) }) }) }) }) }) });
}, qi = ({ cols: e, fields: t, onReset: i }) => {
const [n, r] = P(!1), s = pe(() => t == null ? void 0 : t.toReversed().some((a) => a.y > 1 || a.x + a.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: i, children: "重置" }), c(lt, { type: "primary", htmlType: "submit", children: "查询" }), s && c(S.Link, { className: "ff-data-list-filter-expanded-button", widget: () => r((a) => !a), 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 ti = ({ className: e, title: t, tabs: i, tab: n, onTabChange: r }) => {
const [s, a] = $i(i == null ? void 0 : i[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(yi, { className: "ff-data-list-tabs", itemRender: ({ label: o, code: l }) => c("span", { onClick: () => a(l), className: R("ff-data-list-tab", { active: l == s }), children: o }), items: i }), $("div", { className: "ff-data-list-actions", children: [c(S.Link, { icon: "icon-reload" }), c(S.Link, { icon: "icon-setting" })] })] });
}, Hi = [{ 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" }] }] }], ii = ({ className: e, width: t = 280, isTreeSider: i }) => i ? c(wi.DirectoryTree, { className: R("ff-data-list-sider", e), style: { "--sider-width": t }, showLine: !0, showIcon: !1, treeData: Hi }) : null, ni = ({ className: e, operations: t, isOperations: i, isPaginate: n, total: r, page: s, pageSize: a }) => {
const { onPageChange: o, onPageSizeChange: l, onClickCallback: u } = C.useContext(Le);
return i && !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, p) => 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 || p)) }), n && c(Ci, { size: "small", total: r, pageSize: a, showSizeChanger: !1, showTotal: (d) => `${s} 页 / 总共 ${d}`, onChange: o, onShowSizeChange: l })] }) : null;
}, ri = (e, t, i = !0) => i !== !0 && i-- <= 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(ri(r.children, t, i)) : n), []) : [], Ji = ({ className: e, primaryKey: t, columns: i = [], dataSource: n = [], operationRender: r, operationWidth: s = 180, ...a }) => {
Dt();
const o = Y(null), l = Y(null), [u, d] = P([]), [p, h] = P({ width: 0, height: 0 });
x(() => {
d(ri(n, t));
}, [n, t]), hi(() => {
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 = zi(i);
return c("div", { ref: l, className: R("ff-data-list-table", e), children: p.height ? c(bi, { ...a, 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(s / p.width * 100).toFixed(2)}%`, render: (y, b, w) => r(b, w) }] : []), dataSource: n, size: "middle", scroll: { x: "max-content", y: p.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: d, expandedRowKeys: u } }) : null });
}, Ki = "RC_FORM_INTERNAL_HOOKS", si = (e, { initialValue: t, initialValueLanguage: i, convertJs: n, convertJsSetting: r, type: s = "string" }, a = null) => {
const o = Y(!1), l = _e(Ni), [u, d] = P(), [p, h] = P(i != "javascript" && e ? l.getFieldValue(e) : void 0), { registerWatch: f } = l.getInternalHooks(Ki) || {};
return x(() => f == null ? void 0 : f((y, b, w) => {
if (!o.current) return;
const E = g.get(b, e);
g.isEqual(E, p) || h(g.toPrimitive(E, s));
}), [p]), x(() => {
i == "javascript" && t ? Pe.exec(t, {}, { getFieldValueForBasicForm: (y) => a ? a.getFieldValue(y) : l.getFieldValue(y), getFieldValue: (y) => l.getFieldValue(y) }).then((y) => h(g.toPrimitive(y, s))).catch((y) => notification.error({ message: `布局数据错误: ${JSON.stringify(y)}` })).finally(() => o.current = !0) : (t && h(g.toPrimitive(t ?? l.getFieldValue(e), s)), o.current = !0);
}, [t, i]), Ye(() => {
o.current && n && X.getWidgetComponent(n).then(({ default: y }) => y({ value: p, record: l.getFieldsValue(!0), $setting: r })).then(d).catch((y) => console.error("布局数据转换错误: ", y, n));
}, [p, n, r]), [u || p, p];
}, ai = (e, t, i = "@pkg/grid-layouts", n = null) => pe(() => {
var r;
return (r = g.sortBy(e, ["y", "x"])) == null ? void 0 : r.map(({ i: s, x: a, y: o, w: l, h: u, field: { boxStyle: d, widgetPrefix: p = i, widget: h, ...f } }, y) => c("div", { className: "grid-layout-item", style: ei(a, o, l, u, d, h === "Height" && (f == null ? void 0 : f.initialValue)), children: c(_i, { ...f, basicForm: n, itemWidget: h != null && h.startsWith("@") || h != null && h.startsWith("blob:") ? h : `${p}/${h}`, itemWidgetRender: t }) }, s || y));
}, [e]), _i = ({ itemWidget: e, itemWidgetRender: t, basicForm: i, ...n }) => {
const [r, s] = P();
return x(() => {
X.getWidgetComponent(e).then(({ defaultProps: a = {}, default: o }) => {
s(C.createElement(t(o, a, i), n));
}).catch((a) => {
console.error(a), s(e);
});
}, [e]), r;
}, oi = ({ cols: e = 12, rowHeight: t = 21, fields: i = [], data: n, containerPadding: r = [0, 0], itemMargin: s = [4, 0], formProps: a = {}, className: o, ...l }) => {
const [u] = re.useForm(), d = ai(i, Gi, "@pkg/grid-layouts"), p = pe(() => [{ name: "__PROPS__", value: a }], [a]);
return Ye(() => {
u.setFieldsValue(n);
}, [n]), c(re, { fields: p, form: u, component: !1, children: c("div", { ...l, className: R("ff-grid-layout", o), style: { "--grid-layout-item-margin-y": `${(s == null ? void 0 : s[0]) || 0}px`, "--grid-layout-item-margin-x": `${(s == null ? void 0 : s[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 }) });
}, Gi = (e, t = {}, i = null) => (n) => {
const { code: r, label: s, extras: a, isVirtual: o, initialValue: l, initialValueLanguage: u, convertJs: d, convertJsSetting: p, ...h } = g.merge({}, t, n), [f, y] = si(o ? null : r, { initialValue: l, initialValueLanguage: u, convertJs: d, convertJsSetting: p, type: (h == null ? void 0 : h.type) || "string" }, i);
return c(e, { ...h, value: f, rawValue: y, $setting: a || {} });
}, _n = (Vt = oi, function({ code: e, data: t, ...i }) {
const [n, r] = P({ resource: null, cols: 12, rowHeight: 21, fields: [] });
return x(() => {
e && N.get(`/api/_/${e}`).then((s) => r(g.pick(s, ["resource", "cols", "rowHeight", "fields"])));
}, [e]), (n == null ? void 0 : n.resource) && c(Vt, { ...i, 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: i, ...n }) => {
const r = e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, [s, a] = P();
return x(() => {
r && X.getWidgetComponent(r).then(({ defaultProps: o = {}, default: l }) => ({ default: Yi(l, o, i) })).catch((o) => ({ default: () => `${o}` })).then((o) => a(C.createElement(o.default, n)));
}, [r]), s;
}, Yi = (e, t = {}, i = null) => (n) => {
const { code: r, label: s, extras: a, isVirtual: o, initialValue: l, initialValueLanguage: u, convertJs: d, convertJsSetting: p, value: h, ...f } = g.merge({}, t, n), [y, b] = si(o ? null : r, { initialValue: l, initialValueLanguage: u, convertJs: d, convertJsSetting: p, type: (f == null ? void 0 : f.type) || "string" }, i);
return c(e, { ...f, value: y, rawValue: b, $setting: a || {} });
}, Xi = ({ cols: e, rowHeight: t, itemMargin: i, fields: n, primaryKey: r, dataSource: s, itemClassName: a, itemRender: o = (p, h, f) => p, empty: l = c(ki, { description: null }), className: u, style: d = {} }) => {
const p = Dt(), h = pe(() => c(oi, { cols: e, rowHeight: t, itemMargin: i, fields: n, className: a }), [n, e, t, i]);
return c("div", { className: R("ff-data-list-content", u), style: d, children: g.isEmpty(s) ? l : s == null ? void 0 : s.map((f, y) => c(C.Fragment, { children: o(C.cloneElement(h, { data: f }), f, y) }, `${p}-${(f == null ? void 0 : f[r]) || y}`)) });
}, Qi = ({ component: e }) => {
const { base62params: t } = xi();
return c(K, { children: c(kt, { listCode: e, base62params: N.decode(t) }) });
}, Zi = () => "Empty", en = ({ component: e, $setting: t }) => {
const [i, n] = P();
x(() => {
if (!e) return n(c(Zi, { description: null }));
X.getWidgetComponent(e).catch((s) => ({ default: () => `${s}` })).then((s) => C.createElement(s.default, { $setting: t })).then(n);
}, [e]);
const r = ue.getPageParams() || {};
return i ? C.cloneElement(i, r) : null;
};
var Ce, Q, be, ke, Je, Ke;
const ie = class ie {
constructor() {
F(this, Q, /* @__PURE__ */ new Map());
F(this, be, {});
F(this, ke, null);
k(this, "init", (t, i) => {
B(this, Q, t), B(this, be, i);
});
k(this, "get", (t) => (m(this, Q).has(t) || (t = Array.from(m(this, Q).keys()).find((i) => m(this, Q).get(i).uri === t)), m(this, Q).get(t) || {}));
k(this, "redirect", (t, i, n = {}) => {
const { uri: r, type: s, widgetProps: a } = this.get(t) || {};
let o = Ei(r || t, s != "list" ? i : g.mapValues(i, (u) => N.encode(u)));
const l = new URLSearchParams();
for (const u in a || {}) (a == null ? void 0 : a.type) == "query" && l.append(u, i[u]);
return l.size > 0 && (o = `${o}?${l.toString()}`), m(this, ke).navigate(o, n);
});
k(this, "getMenus", (t) => {
var i;
return ((i = m(this, be)) == null ? void 0 : i[t]) || [];
});
k(this, "findMenuPathByUuid", (t) => {
let i = [];
for (const n in m(this, be)) if (i = m(this, Je).call(this, m(this, be)[n], t, [n]), i.length > 1) return i;
return i;
});
k(this, "getMenusByRouteUuid", (t) => m(this, Ke).call(this, t, Object.values(m(this, be)).flat()));
F(this, Je, (t, i, n = []) => {
if (g.isEmpty(t)) return n;
for (const { uuid: r, children: s } of t) {
if (r == i) return n.concat(r);
if (!g.isEmpty(s)) return n.concat(r, m(this, Je).call(this, s, i));
}
return n;
});
F(this, Ke, (t, i) => {
var r;
let n = [];
for (const s of i) s.widgetType == "redirect" && (s.uuid == t || s.widget == t ? n.push(s) : (r = s.children) != null && r.length && (n = n.concat(m(this, Ke).call(this, t, s.children))));
return n;
});
k(this, "getCurrentMenu", () => {
const { uuid: t } = this.getCurrentRoute() || {};
if (!t) return;
const i = this.getMenusByRouteUuid(t);
return g.isEmpty(i) ? void 0 : i[0];
});
k(this, "getCurrentRoute", (t = 0) => {
var n;
const i = (n = m(this, ke).state.matches[m(this, ke).state.matches.length - 1 - t]) == null ? void 0 : n.route;
if (!i) return null;
for (let [r, s] of m(this, Q)) if (s.uri === i.path) return s;
return null;
});
k(this, "getPageParams", (t) => {
var s;
const { location: i, matches: n } = m(this, ke).state, r = ((s = n[n.length - 1]) == null ? void 0 : s.params) || {};
return i.search && new URLSearchParams(i.search).forEach((a, o) => {
r[o] = a;
}), t ? g.get(r, t) : r;
});
k(this, "createBrowserRouter", (t = {}) => {
if (m(this, Q).size == 0) return null;
const i = Ue.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/frameworks/BasicLayout"), n = Ue.get(X.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), r = { [i]: 0 }, s = (o, l) => () => X.getWidgetComponent(o).then((u) => u.default || function() {
return `${o}`;
}).then((u) => ({ Component: () => C.createElement(_t, {}, C.createElement(u, l)) })), a = Array.from(m(this, Q).values()).reduce((o, { uuid: l, uri: u, name: d, type: p, component: h, widgetSetting: f, isLogin: y, isLayout: b, extra: w }) => {
let E = {}, W = 0;
switch (p) {
case "list":
E.element = C.createElement(Qi, { 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: s(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: s(i, {}), children: [] }]);
return a.push({ index: !0, element: C.createElement(tn, { to: n, replace: !0 }) }), B(this, ke, Ti(a, t));
});
if (m(ie, Ce)) return m(ie, Ce);
}
};
Ce = new WeakMap(), Q = new WeakMap(), be = new WeakMap(), ke = new WeakMap(), Je = new WeakMap(), Ke = new WeakMap(), F(ie, Ce, null), k(ie, "getInstance", () => (m(ie, Ce) || B(ie, Ce, new ie()), m(ie, Ce)));
let mt = ie;
const tn = ({ to: e, replace: t }) => Fi() ? C.createElement(Ri, { to: e, replace: t }) : (window.document.location = e, "redirect"), ue = mt.getInstance(), Ve = new Worker(new URL("/ff-worker/index.js", self.location)), jt = { getConfigure: (e) => Ue.get(e), route: { redirect: (...e) => ue.redirect(...e), getPageParams: (...e) => ue.getPageParams(...e), getCurrentRoute: () => ue.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, Me, ve;
const j = class j {
constructor() {
k(this, "exec", (t, i = {}, n = {}, r = "") => new Promise((s, a) => {
const o = Et(j, nt)._++;
m(j, Me).set(o, n), j.mQueue.set(o, [s, a]), Ve.postMessage({ id: o, session: r, category: "eval", method: t, args: i });
}));
k(this, "clear", (t) => Ve.postMessage({ session: t, category: "clear" }));
if (m(j, ve)) return m(j, ve);
Promise.resolve().then(() => Nn).then((t) => {
jt.http = t.http;
}), Ve.addEventListener("message", ({ data: { id: t, task_id: i, method: n, args: r, category: s, data: a, error: o, session: l } }) => {
if (s === "eval" && j.mQueue.has(t)) o !== null ? j.mQueue.get(t)[1](o) : j.mQueue.get(t)[0](a), m(j, Me).delete(t), j.mQueue.delete(t);
else if (s === "util") try {
const u = g.get(jt, n.split("/")) || g.get(m(j, Me).get(i), n.split("/"));
if (!g.isFunction(u)) throw `${n} not found`;
Promise.resolve(Reflect.apply(u, void 0, r)).then((d) => {
Ve.postMessage({ id: t, task_id: i, category: s, method: n, args: r, session: l, data: d, error: null });
}).catch((d) => {
Ve.postMessage({ id: t, task_id: i, category: s, method: n, args: r, session: l, data: null, error: d });
});
} catch (u) {
Ve.postMessage({ id: t, task_id: i, category: s, method: n, args: r, session: l, data: null, error: u });
}
}, !1);
}
};
nt = new WeakMap(), Me = new WeakMap(), ve = new WeakMap(), k(j, "mQueue", /* @__PURE__ */ new Map()), F(j, nt, 0), F(j, Me, /* @__PURE__ */ new Map()), F(j, ve, null), k(j, "getInstance", () => (m(j, ve) || B(j, ve, new j()), m(j, ve)));
let ht = j;
const Pe = ht.getInstance(), li = () => {
const e = Y(!0), [, t] = C.useReducer((i) => i + 1, 0);
return x(() => () => e.current = !1, []), () => e.current && t();
}, At = (e) => {
const t = Y();
return x(() => {
t.current = e;
}, [e]), t.current;
}, Yn = (e) => {
const [t, i] = P(e), n = Y(null), r = ge((s, a) => {
n.current = a, i(s);
}, []);
return x(() => {
n.current && (n.current(t), n.current = null);
}, [t]), [t, r];
}, Ye = (e = (n) => {
}, t, i = g.isEqual) => {
const n = C.useRef();
i(t, n.current) || (n.current = g.cloneDeep(t)), C.useEffect(e, [n.current]);
}, nn = Ye, ci = (e, t = "string") => {
var i;
if (!Array.isArray(e)) return e;
for (let n = 0; n < e.length; n++) e[n].value = g.toPrimitive((i = e[n]) == null ? void 0 : i.value, t), e[n] && Reflect.has(e[n], "children") && (e[n].children = ci(e[n].children, t));
return e;
}, Xn = (e, t = "json", i = "string", n, r = null) => {
const [s] = re.useForm(n), [a, o] = P([{ label: "无", value: "", disabled: !0 }]), l = Y([]), u = re.useWatch((d) => l.current.length === 0 ? null : g.pick(d, l.current), s) || null;
return x(() => {
Array.isArray(e) ? o(e) : t === "javascript" && e ? Pe.exec(e, {}, { getFieldValue: (d) => (l.current.includes(d) || l.current.push(d), s.getFieldValue(d)), getFieldValueForBasicForm: (d) => (l.current.includes(d) || l.current.push(d), r ? r.getFieldValue(d) : s.getFieldValue(d)) }).then((d) => {
o(g.toPrimitive(d, "array"));
}) : e && o(g.toPrimitive(e, "array"));
}, [e, t, u]), ci(a, i);
}, Qn = (e) => {
const [t, i] = 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 = (s) => N.request(n, !1).resp((a) => (console.log("useSubscribeRequest", s), i(a), a));
return Ye(() => {
let s = null;
return r().then((a) => {
s = Zt.subscribe(g.throttle(r, 180, { leading: !1, trailing: !0 }), a.res);
}), () => s == null ? void 0 : s();
}, n), t;
}, rn = (e) => {
const [t, i] = C.useState({ gridItems: [], hideItems: [] });
return C.useEffect(() => {
e && N.get(`/api/_/${e}`).then(({ pk: n, uuid: r, code: s, resource: a, align: o, cols: l, rowHeight: u, marginX: d, marginY: p, listenChangeFields: h, listenChangeFieldsFunc: f, fields: y }) => ({ pk: n, uuid: r, code: s, resource: a, align: o, cols: l, rowHeight: u, marginX: d, marginY: p, 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(i);
}, [e]), t;
}, sn = ({ max: e = 0, min: t = 0, type: i = "", message: n, pattern: r, required: s = !1, validator: a } = {}, o, l) => {
const [u, d] = P([]);
return x(() => {
const p = [];
if (s) {
let h = l;
switch (l) {
case "number":
case "string":
case "array":
break;
case "bool":
h = "boolean";
break;
case "json":
h = "object";
}
p.push({ type: h, required: !0, whitespace: !0, message: "该项必填" });
}
switch (i) {
case "string":
p.push({ type: i, max: e, min: t, message: n || (t && e ? `字符必须在 ${t} ~ ${e} 之间` : `${e ? "最多能有" : "最少要有"} ${t || e} 个字符`) });
break;
case "pattern":
p.push({ type: "string", pattern: r, message: n });
break;
case "validator":
a && p.push(({ getFieldValue: h }) => ({ validator: async (f, y) => {
const b = await Pe.exec(a, { value: y, fieldName: o }, { getFieldValue: h });
return g.isString(b) && b ? Promise.reject(b) : g.isBoolean(b) && !b ? Promise.reject(n) : Promise.resolve();
} }));
}
d(p);
}, [e, t, i, n, r, s, a]), u;
}, an = (e, t, i) => {
const [n, r] = P(null);
return x(() => {
const { initDataUri: s = `/api/${e}`, initDataMethod: a = "GET" } = i || {};
t && N.request({ method: a, url: g.trimEnd(`${s}/${t}`, "/") }).then((o) => {
r(o);
});
}, [e, t, i]), n;
}, on = (e, t, i, n = {}) => {
const r = li(), s = Y(!0), a = Y([]), [o, l] = P(i), u = re.useWatch((d) => JSON.stringify(g.pick(d, a.current)), t) || "{}";
return x(() => {
e && Pe.exec(e, n, { getFieldValue: g.wrap(t.getFieldValue, (d, p) => (a.current.some((h) => g.isEqual(h, p)) || (a.current.push(p), r()), d(p))), isFieldTouched: t.isFieldTouched, isFieldsTouched: t.isFieldsTouched }).then((d) => s.current && l(d));
}, [e, u, t, n]), x(() => () => s.current = !1, []), o;
}, ln = ({ type: e, initialValue: t, initialValueLanguage: i, onChange: n, form: r }) => {
const s = on(i == "javascript" && t, r, i == "javascript" ? void 0 : t, {});
return x(() => {
i == "javascript" ? n(g.toPrimitive(s, e)) : t && n(g.toPrimitive(t, e));
}, [e, t, s]), null;
}, cn = ({ widget: e = "Input", widgetPrefix: t = "@pkg/grid-layout-forms", widgetDecorator: i, subWidgets: n, basicForm: r, ...s }) => {
const a = e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, [o, l] = P();
return x(() => {
a && X.getWidgetComponent(a).then(({ defaultProps: u = {}, default: d }) => ({ default: di(d, u, r) })).catch((u) => ({ default: () => `${u}` })).then((u) => l(C.createElement(u.default, s)));
}, [a]), o && C.cloneElement(o, s);
}, di = (e, t = {}, i = null) => (n) => {
const { type: r, code: s, label: a, noStyle: o, placeholder: l, extras: u, validators: d, help: p, isVirtual: h, $isReserved: f, initialValue: y, initialValueLanguage: b, convertJs: w, convertJsSetting: E, widgetPerfix: W, boxStyle: q, widgetDecorator: D, subWidgets: H, ...A } = { ...t, ...n }, M = sn(d || {}, s, r), I = { label: a, noStyle: o, colon: !1, layout: "vertical" }, z = { placeholder: l, ...A }, _ = ge((V) => V == null ? void 0 : g.toPrimitive(V, r), [r]);
return c(qt, { name: s, rules: M, initialValue: _(y), normalize: _, children: (V, v, se) => {
var O;
return c(e, { type: r, rcform: se, itemProps: { validateStatus: v.errors.length > 0 ? "error" : "success", tooltip: p, help: v.errors.length > 0 ? v.errors.join("、") : null, required: ((O = M == null ? void 0 : M[0]) == null ? void 0 : O.required) || !1, ...I }, fieldProps: { ...z, ...V }, $setting: u || {} });
} });
}, St = ({ cols: e = 24, rowHeight: t = 16, itemMargin: i = [8, 16], containerPadding: n = [0, 0], fields: r = [], children: s, basicForm: a = null }) => {
const o = ai(r, di, "@pkg/grid-layout-forms");
return $("div", { className: "ff-grid-layout-form", style: { "--grid-layout-item-margin-x": `${(i == null ? void 0 : i[0]) ?? 8}px`, "--grid-layout-item-margin-y": `${(i == null ? void 0 : i[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, s && C.cloneElement(s, { cols: e, rowHeight: t, itemMargin: i, containerPadding: n, fields: r })] });
};
St.propTypes = { fields: L.array };
const dn = (It = St, ({ code: e, layout: t, name: i, primaryKey: n = 0, style: r = {}, formProps: s = {}, form: a, isPreview: o = !1, className: l, onFinish: u, onValuesChange: d = () => {
}, ...p }) => {
const { align: h, autoComplete: f, resource: y, items: b, hides: w, rowHeight: E, marginX: W, marginY: q, cols: D, listenChangeFields: H, listenChangeFieldsFunc: A, pk: M, uuid: I } = rn(e), [z] = re.useForm(a), _ = pe(() => [{ name: "__PK__", value: M }, { name: "__PROPS__", value: s }, { name: "__RESOURCE__", value: y }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: I }, { name: "__PRIMARY_KEY__", value: n }], [M, e, I, y, n, s]);
return $(re, { className: l, name: i || e, layout: t || h, fields: _, form: z, autoComplete: f, style: { ...r, position: "relative" }, onFinish: u, onValuesChange: (V, v) => (({ changedValues: se, allValues: O, listenChangeFields: me, listenChangeFieldsFunc: $e, onValuesChange: rt, code: T }) => {
rt(se, O), $e && Array.isArray(me) && Pe.exec($e, { changedValues: se, allValues: O }, { getFieldValue: z.getFieldValue, setFieldValue: z.setFieldValue, setFieldsValue: z.setFieldsValue, isFieldTouched: z.isFieldTouched, isFieldsTouched: z.isFieldsTouched });
})({ changedValues: V, allValues: v, listenChangeFields: H, listenChangeFieldsFunc: A, onValuesChange: d, code: e }), children: [c(It, { ...p, form: z, code: e, fields: b, cols: D, rowHeight: E, itemMargin: [W, q] }), w == null ? void 0 : w.map((V) => {
var v;
return c(qt, { name: V.code, children: c(ln, { form: z, name: V.code, type: V.type, initialValue: V.initialValue, initialValueLanguage: (v = V.extras) == null ? void 0 : v.initialValueLanguage }) }, JSON.stringify(V.code));
})] }, e);
});
var It;
const ui = ({ $setting: e, $close: t, extras: i, code: n, primaryKey: r, ...s }) => {
const [a] = re.useForm(), o = an(n, r, e);
return x(() => {
o && a.setFieldsValue(o);
}, [o]), c(K, { actions: $(C.Fragment, { children: [c(S, { name: "保存", type: "primary", widget: () => {
const l = a.getFieldValue("__RESOURCE__"), { initDataUri: u = `/api/${n}` } = e || {};
a.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: i, children: c(dn, { form: a, code: n, primaryKey: r, ...s }) });
}, un = (e, t, i, { isReplaceRouteHistory: n = !1 } = {}) => ue.redirect(i, t, { replace: n }), Mt = (e, t, i, { status: { loading: n, disabled: r }, setStatus: s }) => {
const a = { loading: (o) => o === void 0 ? n : s((l) => ({ ...l, loading: o })), disabled: (o) => o === void 0 ? r : s((l) => ({ ...l, disabled: o })) };
return g.isFunction(i) ? i.call(null, { ...t, ...a }) : g.isString(i) && i ? Pe.exec(i, t, a) : null;
}, zt = (e, t, i, n, r) => g.isString(i) && i ? X.getWidgetComponent(i).then(({ default: s }) => G.modal(s, { ...t, $setting: n }, r != null && r.title ? { ...r, title: g.template(r.title)(e) } : r)).catch((s) => {
G.error(i, { content: s.toString() });
}) : G.modal(i, { ...t, $setting: n }, r != null && r.title ? { ...r, title: g.template(r.title)(e) } : r), gn = (e, t, i, n, r) => G.modal(ui, { ...t, $setting: n, code: i }, r != null && r.title ? { ...r, title: g.template(r.title)(e) } : r), pn = (e, t, i, n, r) => G.modal(kt, { base62params: t, $setting: n, listCode: i }, r != null && r.title ? { ...r, title: g.template(r.title)(e) } : r), mn = ({ widget: e, widgetType: t, widgetData: i, widgetProps: n, widgetSetting: r, widgetContainerProps: s }, { onAfterClick: a, onBeforeClick: o }) => {
const l = _e(Le), [u, d] = P({ leading: !0, trailing: !1 }), p = 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(zt, e, r, s);
case "grid-layout-form":
return g.partialRight(gn, e, r, s);
case "data-list":
return g.partialRight(pn, e, r, s);
default:
if ($t(e) || C.isValidElement(e)) return g.partialRight(zt, e, r, s);
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) => p(h, { ...i, ...f })).then((f) => a == null ? void 0 : a(f)).catch(console.error)), 300, { leading: !0, trailing: !1 }), u];
}, Wt = /* @__PURE__ */ new Set(), ft = (e = [], t = 0) => {
const i = e[t];
if (i.length && !Wt.has(i)) {
const n = document.createElement("script");
n.setAttribute("src", i), n.setAttribute("data-namespace", i), e.length > t + 1 && (n.onload = () => {
ft(e, t + 1);
}, n.onerror = () => {
ft(e, t + 1);
}), Wt.add(i), document.body.appendChild(n);
}
}, yt = ({ className: e, type: t, style: i = {}, ...n }) => c("span", { role: "img", className: R("ff-iconfont", e), style: i, ...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: i, name: n, icon: r, type: s = "default", iconPosition: a = "start", noAuthType: o, onAfterClick: l, onBeforeClick: u, data: d, loading: p, disabled: h, tooltip: f, popConfirm: y, widget: b, widgetType: w, widgetData: E, widgetProps: W, widgetSetting: q, widgetContainerProps: D, ...H }) {
const A = { type: "primary", className: R("ff-button", t), iconPosition: a };
s === "danger" ? A.danger = !0 : s === "default" && (A.type = s), e === "link" || e === "dashed" ? (A.type = e, s === "default" && (A.className = R(A.className, "ff-default"))) : e !== "circle" && e !== "round" || (A.shape = e), r && (A.icon = c(yt, { type: r }));
const [M, I] = P(!1), [z, { disabled: _, loading: V }] = mn({ widget: b, widgetType: w, widgetData: E, widgetProps: W, widgetSetting: q, widgetContainerProps: D }, { onAfterClick: l, onBeforeClick: u });
return c(vi, { okText: "确定", cancelText: "取消", ...y || {}, disabled: _ || h, open: M, onOpenChange: (v) => {
if (!v) return I(v);
y ? I(v) : z(d);
}, onConfirm: () => {
z(d);
}, onClick: (v) => {
v.stopPropagation();
}, children: c(Si, { ...f, title: M ? null : f == null ? void 0 : f.title, trigger: ["hover", "click"], children: c(lt, { loading: V || p, disabled: _ || h, ...A, ...H, children: i || n }) }) });
}, S = Xe("default"), hn = Xe("link"), fn = Xe("circle"), yn = Xe("round"), wn = Xe("dashed"), Bt = ({ data: e, widget: t, widgetType: i = "fsdpf-component", children: n, widgetData: r, widgetProps: s, widgetSetting: a, widgetContainerProps: o }) => {
const l = _e(Le), [u, d] = P(!1), [p, h] = P("hover"), [f, y] = P({}), [b, w] = P(), { placement: E, align: W, arrow: q = { pointAtCenter: !0 }, getPopupContainer: D, ...H } = o || {};
x(() => {
i == "grid-layout-form" ? w(C.createElement(ui, { ...r, $setting: a, code: t })) : i == "data-list" ? w(C.createElement(kt, { base62params: e, $setting: a, listCode: t })) : g.isString(t) ? X.getWidgetComponent(t).then(({ default: I }) => {
w(C.createElement(I, { ...r, $setting: a }));
}).catch((I) => w(I.toString())) : $t(t) ? w(C.createElement(t, { ...r, $setting: a })) : C.isValidElement(t) && w(C.cloneElement(t, { ...r, $setting: a }));
}, [t, i, r]), x(() => {
Promise.resolve(Yt(s, e, { list: l })).then(y);
}, [s, e]);
const A = (I) => {
d(I), !I && h("hover");
}, M = (I) => {
d(!0), h("click");
};
return c(Pi, { zIndex: 1080, placement: E, onPopupClick: M, onClick: M, open: u, align: W, arrow: q, trigger: p, getPopupContainer: D, content: c(Cn, { ...H, children: b && C.cloneElement(b, { ...f, $close: () => A(!1) }) }), children: n, onOpenChange: A });
}, Cn = ({ title: e, className: t, children: i, width: n, height: r, ...s }) => {
const [a, o] = P({}), l = ge((p, h) => o((f) => ({ ...f, [p]: h })), []), u = ge((p) => o((h) => ({ ...h, [p]: void 0 })), []), d = e ? C.createElement("div", { className: "ff-popup-title" }, e) : a == null ? void 0 : a.title;
return c(Ge.Provider, { value: { ele: a, mount: l, unmount: u }, children: $("div", { className: R("ff-popup ff-popover", t), style: { width: n, height: r }, ...s, children: [$("div", { className: "ff-popup-header", children: [d, a == null ? void 0 : a["sub-title"]] }), i, $("div", { className: "ff-popup-footer", children: [a == null ? void 0 : a.extras, a == null ? void 0 : a.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: i }) => {
const [n] = re.useForm(), r = pe(() => [{ name: "__PROPS__", value: t }], [t]);
return c(K, { actions: $(C.Fragment, { children: [c(S, { name: "取消", widget: () => i(!1) }), c(S, { name: "确定", type: "primary", widget: () => n.validateFields(!0).then(i) })] }), children: c(re, { fields: r, form: n, className: "ff-modal-form", children: e == null ? void 0 : e.map(({ code: s, ...a }) => c(cn, { code: s, ...a }, s)) }) });
}, kn = ({ className: e, $close: t, children: i, title: n, subTitle: r, actions: s, extras: a, zIndex: o, ...l }) => $(Vi, { ...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: i }), $("div", { className: "ff-popup-footer", children: [a, s] })] }), vn = ({ className: e, $close: t, $event: i, children: n, title: r, subTitle: s, actions: a, extras: o, zIndex: l, placement: u, ...d }) => {
const p = (i == null ? void 0 : i.pageX) === void 0 ? { animation: null, maskAnimation: null, mousePosition: { x: null, y: null } } : { animation: "zoom", maskAnimation: "fade", mousePosition: { x: i == null ? void 0 : i.pageX, y: i == null ? void 0 : i.pageY } };
return c(ji, { ...d, ...p, 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, s] }), c("div", { className: "ff-popup-body", children: n }), $("div", { className: "ff-popup-footer", children: [o, a] })] }) });
}, gi = ({ placement: e, $close: t, $event: i, children: n, title: r, ...s }) => {
const [a, o] = P({}), [l, u] = P(!0), d = ge((y, b) => o((w) => ({ ...w, [y]: b })), []), p = ge((y) => o((b) => ({ ...b, [y]: void 0 })), []);
let h = { ...s, className: a.rootClassName, title: a.title || r && C.createElement("div", { className: R("ff-popup-title") }, r), subTitle: a["sub-title"], actions: a.actions, extras: a.extras, children: n, $close: t, $event: i, onClose: () => u(!1) };
const f = () => {
t(!1);
};
return c(Ge.Provider, { value: { ele: a, mount: d, unmount: p }, children: e && e !== "center" ? c(kn, { ...h, placement: e, open: l, afterOpenChange: (y) => !y && f() }) : c(vn, { ...h, visible: l, afterClose: f }) });
};
gi.propTypes = { placement: L.oneOf(["center", "left", "top", "right", "bottom"]) };
const J = () => {
const [e, t] = Li({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (s) => {
const { offsetHeight: a } = s;
return { height: a };
}, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, i] = C.useReducer((s) => s + 1, 0);
x(() => {
J.$onClick = n, J.$queue.forEach(([s, a, o], l, u) => {
r([a, o], ...s), delete u[l];
});
}, []);
const n = (s, a = {}, o = {}) => new Promise((l, u) => r([l, u], s, a, o)), r = ([s, a], o, l = {}, u = {}) => {
const d = J.$index++, p = (h) => ((f, y) => (J.$popups.delete(f), i(), y == null ? void 0 : y()))(d, () => s(h));
if (o === Gt) return e.open({ ...u, key: d, content: C.createElement(o, { ...l, $close: () => e.close(d) }) });
J.$popups.set(d, C.createElement(gi, { zIndex: d, maskClosable: !1, $event: l == null ? void 0 : l.$event, ...u, key: d, $close: p }, C.isValidElement(o) ? C.cloneElement(o, { ...l, $close: p }) : o != null && o.name || Tt.isForwardRef(o) || (o == null ? void 0 : o.$$typeof) === Tt.ForwardRef ? C.createElement(o, { ...l, $close: p }) : o)), i();
};
return $(C.Fragment, { children: [Array.from(J.$popups).map(([s, a]) => a), t] });
};
J.$popups = /* @__PURE__ */ new Map(), J.$index = 0, J.$queue = [], J.$onClick = (...e) => new Promise((t, i) => {
J.$queue.push([e, t, i]);
});
const Ut = (e, t, i = {}) => J.$onClick(e, t, i), at = (e, { showProgress: t, duration: i, ...n } = { duration: 1.5 }) => J.$onClick(Gt, { content: e, ...n }, { showProgress: t, duration: i }), G = { modal: Ut, confirm: (e, t = {}) => J.$onClick(Ai, { content: e, ...t }, { placement: "center" }), form: (e, t = {}, i = {}) => Ut(bn, { formProps: i, fields: e }, { placement: "center", ...t }).then((n) => {
if (n === !1) throw !1;
return n;
}), notification: at, success: (e, t = { duration: 1.5 }) => at(e, { ...t, className: "ff-notification-success", icon: "check" }), error: (e, t = { duration: 1.5 }) => at(e, { ...t, className: "ff-notification-error", icon: "close" }) };
We.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, We.inc(), e;
}, (e) => (We.done(), Promise.reject({ code: -1, msg: e }))), Be.interceptors.response.use(({ data: e, headers: t }) => (We.done(), { ...e, res: t == null ? void 0 : t.res }), function(e) {
return We.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 && ue.redirect(Ue.get("Common.WEBSITE_LOGIN_PAGE")));
const wt = { appUrl: "", init: (e, t, i) => {
wt.appUrl = i, Be.defaults.baseURL = i, Be.defaults.timeout = 15e3, Object.assign(wt, new ct(e, t, Be));
} }, N = wt;
class Pt extends Error {
constructor(t, i) {
super(i), Error.captureStackTrace && Error.captureStackTrace(this, Pt), !i instanceof De && (this.name = `${t} Error Runtime`);
}
}
class De extends Error {
constructor(t, ...i) {
super(...i), Error.captureStackTrace && Error.captureStackTrace(this, De), this.name = `${t} Not Found`;
}
}
const ot = "mine", tt = "token";
var Se, ze;
const ne = class ne {
constructor() {
F(this, ze, /* @__PURE__ */ new Map());
k(this, "setVendor", (t, i) => m(this, ze).set(t, new Kt(i, async (n, r) => {
var a, o;
if (!(n != null && n.default)) throw "@pkg not found";
let s = () => r;
switch ("function") {
case typeof (s = (a = n.default) == null ? void 0 : a[`./${r}/index.jsx`]):
case typeof (s = (o = n.default) == null ? void 0 : o[`./${r}/index.js`]):
return s();
}
throw new De(r);
})));
k(this, "getWidgetComponent", async (t) => {
if (!t) throw "getWidgetComponent widget is required";
if (t != null && t.startsWith("blob:") || t != null && t.startsWith("http:") || t != null && t.startsWith("https:")) return await import(t);
const [, i] = t == null ? void 0 : t.split("@pkg/");
if (!i) throw new De(t);
try {
return m(this, ze).has("pkg") ? await m(this, ze).get("pkg").get(i) : await import(`${N.appUrl}/api/pkg-import/web?name=${t}`);
} catch (n) {
throw new Pt(t, n);
}
});
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/ff-design/components/DataListSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "grid-layout-setting", isLayout: !0, uri: "/grid-layout-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/GridLayoutSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "grid-layout-form-setting", isLayout: !0, uri: "/grid-layout-form-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/GridLayoutFormSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "resource-api-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ResourceApiSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "charts-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ChartsSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "fsm-setting", isLayout: !0, uri: "/fsm-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/FsmSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "component-setting", isLayout: !0, uri: "/component-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ComponentSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "login", uri: "/login", name: "登录", type: "fsdpf-component", isLogin: !1, component: "@pkg/ff/components/Login" }, { uuid: "not-found", uri: "*", name: "Not Found", type: "fsdpf-component", isLogin: !1, component: "@pkg/ff/components/NotFound" }].map(({ uuid: i, ...n }) => [i, { uuid: i, ...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((i, { uuid: n, auth: r }) => [...i, [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 i = t.split(".");
if (!Array.isArray(i) || i.length !== 3) throw "登录令牌无效!";
const { iat: n } = JSON.parse(window.atob(i[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 i;
try {
const n = this.getUserToken();
if (!n) return Promise.resolve(null);
const { iat: r } = JSON.parse(window.atob((i = n == null ? void 0 : n.split(".")) == null ? void 0 : i[1])), { iat: s, ...a } = N.decode(window.localStorage.getItem(ot) || "", {});
return s === r ? Promise.resolve(a) : 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, i, n = {}) => N.post("/api/user-token", { username: t, passwd: Oi.hash(i), platform: "web", ...n }).then(({ token: r }) => (window.localStorage.setItem(tt, r), r)));
k(this, "logout", () => {
window.localStorage.removeItem(ot), window.localStorage.removeItem(tt);
});
if (m(ne, Se)) return m(ne, Se);
}
};
Se = new WeakMap(), ze = new WeakMap(), F(ne, Se, null), k(ne, "getInstance", () => (m(ne, Se) || B(ne, Se, new ne()), m(ne, Se)));
let Ct = ne;
const X = 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 i = document.querySelector(`style[ff-style-token="${t}"]`);
return i ? (i.innerHTML = e, e) : (i = document.createElement("style"), i.setAttribute("ff-style-token", t), i.setAttribute("type", "text/css"), i.innerHTML = e, document.head.appendChild(i), e);
}, Nn = Object.freeze(Object.defineProperty({ __proto__: null, AppContext: Sn, AppGlobalParamsContext: Pn, cache: Kt, configure: Ue, default: X, func: Pe, http: N, insertStyle: $n, isReactComponent: $t, route: ue }, Symbol.toStringTag, { value: "Module" })), xn = (e, t, i = "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 s = 0; s < r; s++) {
const { [i]: a } = e[s], o = xn(a, t, i);
if (!g.isEmpty(o)) return o;
}
return {};
};
export {
$t as $,
Xn as A,
Qn as B,
dn as C,
Di as D,
St as E,
cn as F,
_n as G,
Ki as H,
ui as I,
rn as J,
sn as K,
an as L,
on as M,
yt as N,
S as O,
Ii as P,
mn as Q,
Zt as R,
K as S,
Ge as T,
_t as U,
J as V,
G as W,
Dn as X,
qn as Y,
Hn as Z,
X as _,
ri as a,
$n as a0,
N as a1,
Kt as a2,
Ue as a3,
Pe as a4,
ue as a5,
Sn as a6,
Pn as a7,
xn as a8,
oi as b,
Gn as c,
ai as d,
vt as e,
ti as f,
ei as g,
ii as h,
ni as i,
kt as j,
Le as k,
Ji as l,
Xi as m,
Wi as n,
Ui as o,
Mi as p,
zi as q,
Jn as r,
Kn as s,
gt as t,
si as u,
li as v,
At as w,
Yn as x,
Ye as y,
nn as z
};

View File

@ -1,919 +0,0 @@
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-egxe712p.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/web?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-DQw7fSp9.js";
import { X as s, N as p, Y as n, Z as t, W as d } from "./common/main-CcbZvxSB.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-DQw7fSp9.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-CcbZvxSB.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-DQw7fSp9.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-CcbZvxSB.js";
export {
s as DataListContent,
e as DataListContext,

View File

@ -1,5 +1,5 @@
import "lodash";
import { a as t } from "../common/main-DQw7fSp9.js";
import { a as t } from "../common/main-CcbZvxSB.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-DQw7fSp9.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-CcbZvxSB.js";
export {
r as GridLayoutForm,
u as GridLayoutFormHelper,

View File

@ -1,5 +1,5 @@
import "lodash";
import { a8 as a } from "../common/main-DQw7fSp9.js";
import { a8 as a } from "../common/main-CcbZvxSB.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-DQw7fSp9.js";
import { b as d, c as e, H as u, G as i, u as t, d as o } from "./common/main-CcbZvxSB.js";
export {
d as GridLayout,
e as GridLayoutWidget,

View File

@ -1,4 +1,4 @@
import { g as t } from "../common/main-DQw7fSp9.js";
import { g as t } from "../common/main-CcbZvxSB.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 r, y as o, A as p, w as i, x as f, B as m, v as c } from "./common/main-DQw7fSp9.js";
import { z as r, y as o, A as p, w as i, x as f, B as m, v as c } from "./common/main-CcbZvxSB.js";
import { _ as l } from "./common/vender-egxe712p.js";
export {
r as useDeepEffect,

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-DQw7fSp9.js";
import { N as a } from "./common/main-CcbZvxSB.js";
export {
a as default
};

2
dist/index.js vendored
View File

@ -1,4 +1,4 @@
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-DQw7fSp9.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-CcbZvxSB.js";
export {
t as AppContext,
e as AppGlobalParamsContext,

2
dist/res-ws.js vendored
View File

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

2
dist/style.css vendored

File diff suppressed because one or more lines are too long

View File

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