1069 lines
82 KiB
JavaScript
1069 lines
82 KiB
JavaScript
var Ei = Object.defineProperty;
|
|
var Lt = (e) => {
|
|
throw TypeError(e);
|
|
};
|
|
var Oi = (e, t, i) => t in e ? Ei(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
var $ = (e, t, i) => Oi(e, typeof t != "symbol" ? t + "" : t, i), At = (e, t, i) => t.has(e) || Lt("Cannot " + i);
|
|
var y = (e, t, i) => (At(e, t, "read from private field"), i ? i.call(e) : t.get(e)), E = (e, t, i) => t.has(e) ? Lt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, i), U = (e, t, i, n) => (At(e, t, "write to private field"), n ? n.call(e, i) : t.set(e, i), i);
|
|
var Vt = (e, t, i, n) => ({
|
|
set _(r) {
|
|
U(e, t, r, i);
|
|
},
|
|
get _() {
|
|
return y(e, t, n);
|
|
}
|
|
});
|
|
import { jsx as p, jsxs as O } from "react/jsx-runtime";
|
|
import x, { useEffect as L, useState as F, useCallback as X, useMemo as H, useRef as W, useContext as ce, useId as pt, isValidElement as ji, useLayoutEffect as Li } from "react";
|
|
import w from "prop-types";
|
|
import I from "classnames";
|
|
import * as It from "react-is";
|
|
import { useNotification as Ai } from "rc-notification";
|
|
import d from "lodash";
|
|
import te, { FieldContext as Yt, Field as Xt } from "rc-field-form";
|
|
import { M as ct, N as Oe, a as je, P as mt, S as Vi } from "./vender-CtjyT19B.js";
|
|
import Qt from "immutability-helper";
|
|
import { Form as Ge, Input as Ii, Button as Xe, Pagination as Mi, Tree as zi, Breadcrumb as Bi, Table as Di, Empty as qi, Popconfirm as Wi, Tooltip as Ui, Popover as Hi } from "antd";
|
|
import { useMergedState as Ji } from "rc-util";
|
|
import { generatePath as Ki, useInRouterContext as Zt, useParams as _i, useLocation as Gi, createBrowserRouter as Yi, Navigate as Xi } from "react-router-dom";
|
|
import "rc-util/lib/hooks/useMergedState";
|
|
import Qi from "rc-drawer";
|
|
import Zi from "rc-dialog";
|
|
var Ne, Ve, Te, de, ve, Se;
|
|
class ei {
|
|
constructor(t, i) {
|
|
E(this, Ne, /* @__PURE__ */ new Map());
|
|
E(this, Ve, !0);
|
|
E(this, Te, []);
|
|
E(this, de);
|
|
E(this, ve, () => y(this, de));
|
|
E(this, Se, () => Promise.resolve());
|
|
$(this, "get", (...t) => new Promise((i, n) => {
|
|
const r = JSON.stringify(t);
|
|
if (y(this, Ne).has(r)) return i(y(this, Se).call(this, y(this, de), ...t));
|
|
if (y(this, de) === void 0) y(this, Te).push([t, i, n]), y(this, Ve) && (U(this, Ve, !1), Promise.resolve(typeof y(this, ve) == "function" ? y(this, ve).call(this) : y(this, ve)).then((a) => U(this, de, a || null)).finally(() => {
|
|
y(this, Te).forEach(([a, o, s]) => {
|
|
try {
|
|
const l = y(this, Se).call(this, y(this, de), ...a);
|
|
y(this, Ne).set(JSON.stringify(a), l), o(l);
|
|
} catch (l) {
|
|
s(l);
|
|
}
|
|
}), y(this, Te).length = 0;
|
|
}));
|
|
else {
|
|
const a = y(this, Se).call(this, y(this, de), ...t);
|
|
y(this, Ne).set(r, a), i(a);
|
|
}
|
|
}));
|
|
U(this, Se, i), U(this, ve, t);
|
|
}
|
|
}
|
|
Ne = new WeakMap(), Ve = new WeakMap(), Te = new WeakMap(), de = new WeakMap(), ve = new WeakMap(), Se = new WeakMap();
|
|
const ur = () => p("div", { children: "Empty" }), qe = x.createContext({ ele: {}, mount: () => {
|
|
}, unmount: () => {
|
|
} }), Y = ({ rootClassName: e, className: t, children: i, actions: n, title: r, subTitle: a, extras: o, style: s = {} }) => {
|
|
const { mount: l, unmount: u } = x.useContext(qe);
|
|
return Y.Action({ children: n }), Y.Title({ children: r }), Y.SubTitle({ children: a }), Y.Extra({ children: o }), L(() => (l("rootClassName", e), () => u(e)), [e]), p("div", { className: I("ff-container", t), style: s, children: i });
|
|
}, _e = (e) => ({ children: t, className: i }) => {
|
|
const { mount: n, unmount: r } = x.useContext(qe);
|
|
return L(() => (t && n(e, x.createElement("div", { key: `ff-${e}`, className: I(`ff-popup-${e}`, i) }, t)), () => r(e)), [i, t]), null;
|
|
};
|
|
Y.Action = _e("actions"), Y.Title = _e("title"), Y.SubTitle = _e("sub-title"), Y.Extra = _e("extras"), Y.propTypes = { className: w.string, style: w.object, title: w.any, subTitle: w.any, actions: w.any, extras: w.any };
|
|
const gr = () => p(Y, { className: "ff-loading", children: O("div", { className: "loader", children: [O("div", { className: "square", children: [p("span", {}), p("span", {}), p("span", {})] }), O("div", { className: "square", children: [p("span", {}), p("span", {}), p("span", {})] }), O("div", { className: "square", children: [p("span", {}), p("span", {}), p("span", {})] }), O("div", { className: "square", children: [p("span", {}), p("span", {}), p("span", {})] })] }) }), pr = () => p("div", { children: "NotFound" }), ti = ({ children: e }) => {
|
|
const [t, i] = F({}), n = X((a, o) => i((s) => ({ ...s, [a]: o })), []), r = X((a) => i((o) => ({ ...o, [a]: void 0 })), []);
|
|
return typeof (e == null ? void 0 : e.type) == "string" ? e : p(qe.Provider, { value: { ele: t, mount: n, unmount: r }, children: x.cloneElement(e, { className: t.rootClassName, title: t.title, subTitle: t["sub-title"], actions: t.actions, extras: t.extras }) });
|
|
};
|
|
ti.propTypes = { children: w.element.isRequired };
|
|
const Mt = { 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"] }, $t = ({ type: e, props: t }) => p("i", { ...t, children: p("svg", { viewBox: "0 0 1024 1024", width: "1em", height: "1em", fill: "currentColor", children: (Mt[e] || Mt.info).map((i, n) => p("path", { d: i }, n)) }) }), ii = ({ className: e, content: t, icon: i, $close: n }) => O(x.Fragment, { children: [i && p("div", { className: I("ff-notification-icon", e), children: p($t, { type: i }) }), t] }), en = ({}) => p(Y, { children: "Confirm" });
|
|
var pe, Re;
|
|
const ne = class ne {
|
|
constructor() {
|
|
E(this, Re, /* @__PURE__ */ new Map());
|
|
$(this, "init", (t) => U(this, Re, new Map(t)));
|
|
$(this, "check", (t) => !y(this, Re).has(t) || y(this, Re).get(t));
|
|
if (y(ne, pe)) return y(ne, pe);
|
|
}
|
|
};
|
|
pe = new WeakMap(), Re = new WeakMap(), E(ne, pe, null), $(ne, "getInstance", () => (y(ne, pe) || U(ne, pe, new ne()), y(ne, pe)));
|
|
let ft = ne;
|
|
const tn = ft.getInstance(), nn = (e, t, i = "children") => {
|
|
if (d.isEmpty(e)) return {};
|
|
const n = d.find(e, ["value", t]);
|
|
if (!d.isEmpty(n)) return n;
|
|
const r = e.length;
|
|
for (let a = 0; a < r; a++) {
|
|
const { [i]: o } = e[a], s = nn(o, t, i);
|
|
if (!d.isEmpty(s)) return s;
|
|
}
|
|
return {};
|
|
}, ni = (e = "Input", t = "@pkg/ff/grid-layout-forms") => e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`;
|
|
var me, Ie;
|
|
const re = class re {
|
|
constructor() {
|
|
E(this, Ie, null);
|
|
$(this, "init", (t) => U(this, Ie, t));
|
|
$(this, "get", (t, i) => d.get(y(this, Ie), t, i));
|
|
if (y(re, me)) return y(re, me);
|
|
}
|
|
};
|
|
me = new WeakMap(), Ie = new WeakMap(), E(re, me, null), $(re, "getInstance", () => (y(re, me) || U(re, me, new re()), y(re, me)));
|
|
let ht = re;
|
|
const Le = ht.getInstance(), zt = { 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" }, ee = (e, t) => {
|
|
let i = "string";
|
|
i = Array.isArray(e) ? "array" : typeof e, d.isObject(e) && (i = "json");
|
|
const n = `${i}2${t}`;
|
|
return Reflect.has(zt, n) ? zt[n](e) : e;
|
|
}, We = (e = {}, t = {}, i = {}, n = "") => ri(e, (r, a) => a === "type" && r === "code") ? ai(e, t, i, n) : si(e, t, n), ri = (e, t = () => !1) => d.some(e, (i) => !!d.some(i, t) || (d.isEmpty(i) || !d.isPlainObject(i) && !d.isArray(i) ? void 0 : ri(i, t))), ai = async (e = {}, t = {}, i = {}, n = "") => {
|
|
let r = /* @__PURE__ */ Object.create(null);
|
|
for (let a in e) {
|
|
let o;
|
|
if (Reflect.has(e[a], "type") && ["code", "field", "router", "query", "string"].includes(e[a].type)) {
|
|
const { type: s, value: l = "", default: u = n } = e[a];
|
|
switch (s) {
|
|
case "code":
|
|
o = await xe.exec(l, t, i);
|
|
break;
|
|
case "field":
|
|
o = d.get(t, l) ?? d.get(t, l.substring(l.indexOf(".") + 1));
|
|
break;
|
|
case "router":
|
|
case "query":
|
|
o = ke.getPageParams(l);
|
|
break;
|
|
case "string":
|
|
o = l;
|
|
}
|
|
o ?? (o = u);
|
|
} else o = await ai(e[a], t, i, n);
|
|
d.set(r, a, o);
|
|
}
|
|
return r;
|
|
}, si = (e = {}, t = {}, i = "") => Object.keys(e || {}).reduce((n, r) => {
|
|
if (d.isPlainObject(e[r])) {
|
|
let a;
|
|
if (Reflect.has(e[r], "type") && ["field", "router", "query", "string"].includes(e[r].type)) {
|
|
const { type: o, value: s = "", default: l = i } = e[r];
|
|
switch (o) {
|
|
case "field":
|
|
a = d.get(t, s) ?? d.get(t, s.substring(s.indexOf(".") + 1));
|
|
break;
|
|
case "router":
|
|
case "query":
|
|
a = ke.getPageParams(s);
|
|
break;
|
|
case "string":
|
|
a = s;
|
|
}
|
|
a ?? (a = l);
|
|
} else a = si(e[r], t, i);
|
|
d.set(n, r, a);
|
|
}
|
|
return n;
|
|
}, {}), dt = (e, t) => e && typeof e == "object" ? Array.isArray(e) ? e.map((i) => dt(i, t)) : Object.keys(e).reduce((i, n) => (t[n] ? i[t[n]] = dt(e[n], t) : i[n] = dt(e[n], t), i), {}) : e, mr = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
const t = 16 * Math.random() | 0;
|
|
return (e === "x" ? t : 3 & t | 8).toString(16);
|
|
}), fr = (e) => {
|
|
var t, i;
|
|
return e ? (i = (t = e.match(/^@pkg(?:[^\/]*\/){3}(?<name>[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : i.name : "";
|
|
}, hr = (e) => {
|
|
var t, i;
|
|
return e ? (i = (t = e.match(/^@pkg(?:[^\/]*\/){2}(?<category>[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : i.category : "";
|
|
}, yr = (e) => {
|
|
var t, i;
|
|
return e ? (i = (t = e.match(/^@pkg(?:[^\/]*\/){1}(?<owner>[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : i.owner : "";
|
|
}, rn = (e, t = 32, i = "auto") => {
|
|
const n = yt(e), r = i === "auto" ? "x64" : i;
|
|
if (t === 32) return ct.x86.hash32(n).toString();
|
|
if (t === 128) return r === "x64" ? ct.x64.hash128(n) : ct.x86.hash128(n);
|
|
throw new Error("bits 只能是 32 或 128");
|
|
}, yt = (e) => e == null ? "null" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : typeof e == "function" ? e.toString() : Array.isArray(e) ? "[" + e.map(yt).join(",") + "]" : typeof e == "object" ? "{" + Object.keys(e).sort().map((t) => `${t}:${yt(e[t])}`).join(",") + "}" : String(e);
|
|
var Ze, Me, ze, et;
|
|
const tt = class tt {
|
|
constructor(...t) {
|
|
E(this, Me, []);
|
|
E(this, ze, (t) => {
|
|
var i;
|
|
for (let n of t) Array.isArray(n[0]) ? y(this, ze).call(this, n) : y(this, Me).push(y(i = tt, Ze).call(i, n[0], n[1]));
|
|
});
|
|
$(this, "toValue", async (t, i = null) => {
|
|
const n = { getValue: () => t, getRecord: () => i };
|
|
return await y(this, Me).reduce(async (r, a) => {
|
|
try {
|
|
const o = await r;
|
|
return (await a).call(n, o);
|
|
} catch (o) {
|
|
return console.error(o), r;
|
|
}
|
|
}, t);
|
|
});
|
|
$(this, "toRender", (t, i, n = null) => x.createElement(y(this, et), { value: t, record: i }, n));
|
|
E(this, et, ({ value: t, record: i, children: n }) => {
|
|
const [r, a] = F(n);
|
|
return at(() => {
|
|
let o = !1;
|
|
return a(n), this.toValue(t, i).then((s) => ee(s, "string")).then((s) => !o && a(s)).catch((s) => !o && a(`${s}`)), () => o = !0;
|
|
}, [t, i]), r;
|
|
});
|
|
y(this, ze).call(this, t);
|
|
}
|
|
};
|
|
Ze = new WeakMap(), Me = new WeakMap(), ze = new WeakMap(), et = new WeakMap(), E(tt, Ze, d.memoize((t, i) => le.getWidgetComponent(t).then((n) => {
|
|
var r;
|
|
return ((r = n.default) == null ? void 0 : r.call(n, i)) || ((a) => a);
|
|
}), (t, i) => `${t}::${ee(i, "string")}`));
|
|
let Qe = tt;
|
|
const an = (e, t = {}) => H(() => e == null ? void 0 : e.map(({ widgetByJs: i, widgetByJsSetting: n, ...r }, a) => i ? { ...r, render: (o, s) => new Qe([i, n]).toRender(o, s, "-") } : r), [e, t]), wr = (e) => {
|
|
const [t, i] = F({});
|
|
return L(() => {
|
|
let n = !1;
|
|
return e && j.get(`/api/_/${e}`).then((r) => d.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;
|
|
}, br = (e, t = {}) => {
|
|
const [i, n] = F({ dataSource: [] });
|
|
return Ue(() => {
|
|
let r = !1;
|
|
return e && j.get(`/api/${e}/${j.encode({ page: 1, ...t })}`).then((a) => !r && n(a)), () => r = !0;
|
|
}, [e, t]), i;
|
|
}, oi = (e = [], t = /* @__PURE__ */ new Map(), i = "id", n) => {
|
|
const r = X(n ? (a) => d.get(a, i, d.get(a, [n, i])) : (a) => d.get(a, i), [i, n]);
|
|
return X((a) => e == null ? void 0 : e.filter((o) => !o.uuid || !t.has(o.uuid) || t.get(o.uuid).some((s) => s == r(a))), [e, t, r]);
|
|
}, wt = (e = [], t = /* @__PURE__ */ new Map(), i = [], n = "id", r) => {
|
|
const a = X(r ? (o) => d.get(o, n, d.get(o, [r, n])) : (o) => d.get(o, n), [n, r]);
|
|
return H(() => {
|
|
if (d.isEmpty(e) || !e.some(({ uuid: s }) => tn.check(s))) return !1;
|
|
if (d.isEmpty(t) || d.isEmpty(i)) return !0;
|
|
const o = i.map((s) => a(s));
|
|
return e.some(({ uuid: s }) => !s || !t.has(s) || t.get(s).some((l) => o.some((u) => u == l)));
|
|
}, [e, i, t, a]);
|
|
}, sn = (e, t, i = "id", n = null) => {
|
|
const r = rt(), a = W(!1), o = W(e.dataSource), s = W(e.itemOperationsAccess);
|
|
return L(() => (o.current = e.dataSource, s.current = e.itemOperationsAccess, () => a.current = !1), [e.dataSource, e.itemOperationsAccess]), a.current && (e.dataSource = o.current, e.itemOperationsAccess = s.current), [e, (l = 0, u = null) => {
|
|
var c, g;
|
|
if (a.current = !1, l === 1) return (c = e.onReload) == null ? void 0 : c.call(e);
|
|
if (l === 2) {
|
|
const f = d.get(u, "__PARENT_ID__", ""), m = d.get(u, i, d.get(u, [n, i], "")), h = d.findIndex(o.current, ["__PARENT_ID__", f]), b = d.findIndex(h > -1 ? d.get(o.current, [h, "children"]) : o.current, [i, m]);
|
|
if (b === -1) return (g = e.onReload) == null ? void 0 : g.call(e);
|
|
Promise.all([j.get(`/api/${t}/detail/${m}`), j.post(`/api/${t}/list-operations-access`, { ids: m })]).then(([C, k]) => {
|
|
const P = d.get(o.current, h > -1 ? [h, "children", b, "children"] : [b, "children"]);
|
|
o.current = Qt(o.current, h > -1 ? { [h]: { children: { $splice: [[b, 1, { ...C, children: P }]] } } } : { $splice: [[b, 1, { ...C, children: P }]] });
|
|
const S = new Map(k);
|
|
s.current.forEach((R, V) => {
|
|
var q;
|
|
(q = S.get(V)) != null && q.some((A) => A == m) || s.current.set(V, R.filter((A) => A !== m));
|
|
}), S.forEach((R, V) => {
|
|
s.current.has(V) ? s.current.set(V, d.uniq([...s.current.get(V) || [], ...R])) : s.current.set(V, R);
|
|
});
|
|
}).then(() => {
|
|
a.current = !0, r();
|
|
});
|
|
}
|
|
}];
|
|
}, on = (e, t) => {
|
|
const i = rt(), n = W(t), r = W(/* @__PURE__ */ new Map()), a = W([]), o = d.throttle((l) => {
|
|
a.current = [], j.list(e, d.pick({ ...n.current, ...l }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: u, condition: c, total: g, tab: f, sider: m, page: h, pageSize: b, operationsAccess: C, dataSource: k }) => {
|
|
n.current = { tab: f, condition: c, sider: m, keyword: u, total: g, pageSize: b, page: k != null && k.length ? h : 1 }, a.current = k, r.current = new Map(C), i();
|
|
});
|
|
}, 380, { leading: !1, trailing: !0 });
|
|
at(() => {
|
|
a.current = [], e && o(t);
|
|
}, [e, t]);
|
|
const s = H(() => d.pick(n.current, ["total", "tab", "page", "pageSize", "condition", "sider", "keyword"]), [n.current]);
|
|
return Object.assign(s, { onTabChange: (l) => o({ tab: l, page: 1 }), onPageChange: (l, u) => o({ page: l, pageSize: u }), onPageSizeChange: (l) => o({ pageSize: l, page: 1 }), onConditionChange: (l, u) => o({ keyword: u, condition: Qt(n.current.condition || {}, { $merge: l || {} }), page: 1 }), onSiderChange: (l) => o({ sider: l, page: 1 }), onKeywordChange: (l) => o({ keyword: l, page: 1 }), itemOperationsAccess: r.current, dataSource: a.current, onReload: o, payload: t == null ? void 0 : t.payload });
|
|
}, ln = ({ listCode: e, className: t, layouts: i, dataSource: n, isPaginate: r, isItemOperations: a, isBatchOperations: o, batchOperations: s, itemOperations: l, itemOperationsAccess: u, resource: c, primaryKey: g, title: f, itemGridLayout: m, $setting: h, tabs: b, isConditionFormLayout: C, isTreeSider: k, treeSiderConfig: P }) => {
|
|
const { classNames: S, onClickCallback: R } = ce(ie), V = d.pick(h, ["column", "colWidth", "beforeRender", "afterRender", "style"]), q = oi(l, u, g, c), A = X((M, T, z) => p(cn, { className: I("ff-data-list-framework-item", S.item), operations: a ? q(T) : [], data: c ? { [c]: T } : T, children: M, onClickCallback: R }), [c, g, a, R, l, u]);
|
|
return O("div", { className: I("ff-data-list-framework", t), children: [p(i.sider, { isTreeSider: k, ...P }), O("div", { className: I("ff-data-list-container", S == null ? void 0 : S.container), children: [p(i.filter, { isConditionFormLayout: C }), p(i.toolbar, { title: f, tabs: b }), p(kn, { ...V, ...m, primaryKey: g, itemRender: A, dataSource: n }), p(i.footer, { isPaginate: r, isOperations: o, operations: s })] })] });
|
|
}, cn = ({ className: e, operations: t, children: i, data: n, onClickCallback: r }) => O("div", { className: I("data-list-grid-layout-item-container", e), children: [i, !!(t != null && t.length) && p("div", { className: "data-list-grid-layout-item-actions", children: t.map((a) => p("span", { className: "data-list-grid-layout-item-action", children: p(N.Link, { uuid: a.uuid, type: a.type, name: a.name, widget: a.widget, widgetType: a.widgetType, widgetProps: a.widgetProps, widgetSetting: a.widgetSetting, widgetContainerProps: a.widgetContainerSetting, data: n, confirm: a.confirm, onAfterClick: (o) => o !== !1 && (r == null ? void 0 : r(a.isRefresh, n)) }, a.uuid || pt()) }, (a == null ? void 0 : a.uuid) || pt())) })] }), dn = ({ listCode: e, className: t, layouts: i, dataSource: n, columns: r, isItemOperations: a, isBatchOperations: o, batchOperations: s, itemOperations: l, itemOperationsAccess: u, resource: c, primaryKey: g, title: f, tabs: m, isPaginate: h, isTreeSider: b, treeSiderConfig: C, isConditionFormLayout: k, ...P }) => {
|
|
const { classNames: S, onClickCallback: R } = ce(ie), V = oi(l, u, g, c), q = wt(l, u, n, g, c);
|
|
return O("div", { className: I("ff-data-table-framework", t), children: [p(i.sider, { isTreeSider: b, ...C }), O("div", { className: I("ff-data-table-container", S == null ? void 0 : S.container), children: [p(i.filter, { isConditionFormLayout: k }), p(i.toolbar, { title: f, tabs: m }), p(hn, { ...P, primaryKey: g, className: "ff-data-table-content", columns: r, dataSource: n, operationRender: q ? (A) => {
|
|
var M;
|
|
return p("div", { className: "ff-data-table-actions", children: (M = V(A)) == null ? void 0 : M.map((T, z) => p(N.Link, { size: "small", uuid: T.uuid, type: T.type, name: T.name, widget: T.widget, widgetType: T.widgetType, widgetProps: T.widgetProps, widgetData: T.widgetData, widgetSetting: T.widgetSetting, widgetContainerProps: T.widgetContainerSetting, data: A, confirm: T.confirm, onAfterClick: (v) => v !== !1 && (R == null ? void 0 : R(T.isRefresh, A)) }, T.uuid || z)) });
|
|
} : null }), p(i.footer, { isPaginate: h, isOperations: o, operations: s })] })] });
|
|
}, ie = x.createContext({ listCode: "", classNames: {}, getBase62params: (e, t) => {
|
|
}, onReload: () => {
|
|
}, onClickCallback: () => {
|
|
}, onConditionChange: () => {
|
|
}, onTabChange: () => {
|
|
}, onSiderChange: () => {
|
|
}, onKeywordChange: () => {
|
|
}, onPageChange: () => {
|
|
}, onPageSizeChange: () => {
|
|
} }), li = (e, t, i, n, r = {}, a = 0) => {
|
|
const o = { "--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 ? o.height = "fit-content" : o["--grid-layout-row"] = `${n}`, r != null && r.alignItems && (o["--grid-layout-box-align-items"] = r.alignItems), r != null && r.justifyContent && (o["--grid-layout-box-justify-content"] = r.justifyContent), o["--grid-layout-box-margin"] = Bt(r == null ? void 0 : r.marginTop, r == null ? void 0 : r.marginRight, r == null ? void 0 : r.marginBottom, r == null ? void 0 : r.marginLeft), o["--grid-layout-box-padding"] = Bt(r == null ? void 0 : r.paddingTop, r == null ? void 0 : r.paddingRight, r == null ? void 0 : r.paddingBottom, r == null ? void 0 : r.paddingLeft), a && (o.height = `${a}px`), o;
|
|
}, Bt = (e, t, i, n) => `${e || 0}px ${t || 0}px ${i || 0}px ${n || 0}px`, Cr = (e = "Text", t = "@pkg/ff/grid-layouts") => e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, ci = ({ className: e, isConditionFormLayout: t }) => {
|
|
var f, m;
|
|
const [i, n] = F({}), { listCode: r, onKeywordChange: a, onConditionChange: o, getBase62params: s, classNames: l } = x.useContext(ie), { keyword: u, condition: c } = (s == null ? void 0 : s()) || {}, [g] = Ge.useForm();
|
|
return L(() => {
|
|
r && t && j.get(`/api/_/${r}/list-condition-form-layout`).then(({ resource: h, marginX: b, marginY: C, rowHeight: k, cols: P, fields: S }) => {
|
|
n({ resource: h, itemMargin: [b, C], rowHeight: k, cols: P, fields: S });
|
|
}).catch(() => n({}));
|
|
}, [r, t]), L(() => {
|
|
g.setFieldsValue({ keyword: u, ...c });
|
|
}, [JSON.stringify([u, c])]), p("div", { className: I("ff-data-list-filter", l.filter, e), children: p(Ge, { form: g, layout: "vertical", autoComplete: "off", onFinish: ((f = i.fields) == null ? void 0 : f.length) > 1 ? (h) => o({ [i.resource]: h[i.resource] }, h.keyword) : () => {
|
|
}, onValuesChange: (h) => {
|
|
d.isEmpty(d.omit(h, ["keyword"])) || g.submit();
|
|
}, children: ((m = i.fields) == null ? void 0 : m.length) > 1 ? p(Tt, { ...i, children: p(un, { onReset: () => {
|
|
const { keyword: h, condition: b } = s("init") || {};
|
|
g.setFieldsValue({ keyword: h, ...b });
|
|
} }) }) : p("div", { className: "ff-data-list-filter-default-form ff-grid-layout-form", children: p("div", { className: "grid-layout-item", style: li(20, 0, 5, 2), children: p(Ge.Item, { name: ["keyword"], children: p(Ii.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (h) => a(h) }) }) }) }) }) });
|
|
}, un = ({ cols: e, fields: t, onReset: i }) => {
|
|
const [n, r] = F(!1), a = H(() => t == null ? void 0 : t.toReversed().some((o) => o.y > 1 || o.x + o.w >= e - 5), [e, t]);
|
|
return O(Ge.Item, { label: " ", style: { "--item-span": 5 }, className: I("ff-data-list-filter-actions", { expanded: n }), children: [p(Xe, { onClick: i, children: "重置" }), p(Xe, { type: "primary", htmlType: "submit", children: "查询" }), a && p(N.Link, { className: "ff-data-list-filter-expanded-button", widget: () => r((o) => !o), type: "primary", name: n ? "关闭" : "展开", icon: n ? "icon-up" : "icon-down", iconPosition: "end" })] });
|
|
};
|
|
ci.reservedFields = [{ x: 0, y: 0, h: 3, w: 5, field: { isVirtual: !0, widgetPrefix: "@pkg/ff/grid-layout-forms", widget: "Input", code: "keyword", label: "关键字", placeholder: "多关键字 | 分割", extras: { prefix: "icon-search" } } }];
|
|
const gn = ({ className: e, operations: t, isOperations: i, isPaginate: n }) => {
|
|
const { onPageChange: r, onPageSizeChange: a, onClickCallback: o, getBase62params: s } = x.useContext(ie), { total: l, page: u, pageSize: c } = (s == null ? void 0 : s()) || {};
|
|
return i && !d.isEmpty(t) || n ? O("div", { className: I("ff-data-list-footer", e), children: [p("div", { className: "ff-data-list-actions", children: t == null ? void 0 : t.map((g, f) => p(N, { uuid: g.uuid, type: g.type, name: g.name, widget: g.widget, widgetType: g.widgetType, widgetProps: g.widgetProps, widgetData: g.widgetData, widgetSetting: g.widgetSetting, widgetContainerProps: g.widgetContainerSetting, onAfterClick: (m) => m !== !1 && (o == null ? void 0 : o(g.isRefresh, null)) }, g.uuid || f)) }), n && p(Mi, { size: "small", total: l, pageSize: c, showSizeChanger: !1, showTotal: (g) => `第 ${u} 页 / 总共 ${g} 条`, onChange: r, onShowSizeChange: a })] }) : null;
|
|
}, pn = [{ 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: p("span", { style: { color: "#1677ff" }, children: "sss" }), key: "0-0-1-0" }] }] }], mn = ({ className: e, width: t = 280, isTreeSider: i }) => {
|
|
const { classNames: n } = ce(ie);
|
|
return i ? p(zi.DirectoryTree, { className: I("ff-data-list-sider", n.sider, e), style: { "--sider-width": t }, showLine: !0, showIcon: !1, treeData: pn }) : null;
|
|
}, fn = ({ className: e, title: t, tabs: i }) => {
|
|
const { getBase62params: n, onTabChange: r, onReload: a, classNames: o } = ce(ie), { tab: s } = (n == null ? void 0 : n()) || {}, [l, u] = Ji((i == null ? void 0 : i[0].value) ?? (i == null ? void 0 : i[0].code), { value: s, onChange: r });
|
|
return O("div", { className: I("ff-data-list-toolbar", o.toolbar, e), children: [p("div", { className: "ff-data-list-title", children: t }), p(Bi, { className: "ff-data-list-tabs", itemRender: ({ label: c, code: g, value: f }) => p("span", { onClick: () => u(f ?? g), className: I("ff-data-list-tab", { active: (f ?? g) == l }), children: c }), items: i }), O("div", { className: "ff-data-list-actions", children: [p(N.Link, { icon: "icon-reload", widget: () => a() }), p(N.Link, { icon: "icon-setting" })] })] });
|
|
}, di = ({ isItemGridLayout: e, theme: t, themeProps: i, onClickCallback: n, onReload: r, listCode: a, total: o = 0, page: s = 0, onPageChange: l, pageSize: u = 30, onPageSizeChange: c, tab: g, onTabChange: f, keyword: m, onKeywordChange: h, condition: b, onConditionChange: C, sider: k, onSiderChange: P, layouts: S, classNames: R = {}, payload: V = {}, ...q }) => {
|
|
const [A, M] = F(), T = X((v, B) => {
|
|
const K = { tab: g, page: s, pageSize: u, keyword: m, sider: k, condition: b, total: o, payload: V };
|
|
return v && v != "init" ? d.get(K, v, B) : K;
|
|
}, [JSON.stringify(b), JSON.stringify(V), g, s, u, m, k, o]), z = H(() => {
|
|
let v = { sider: mn, filter: ci, footer: gn, toolbar: fn };
|
|
S === !1 ? v = { sider: null, filter: null, footer: null, toolbar: null } : d.isPlainObject(S) && (v = Object.assign({}, v, S));
|
|
for (const B in v) if (v[B]) {
|
|
if (ji(v[B])) {
|
|
const K = v[B];
|
|
v[B] = (ge) => x.cloneElement(K, ge);
|
|
}
|
|
} else v[B] = () => p(x.Fragment, {});
|
|
return v;
|
|
}, [S]);
|
|
return L(() => {
|
|
t ? le.getWidgetComponent(t).then((v) => {
|
|
if (!v) throw `${t} not found`;
|
|
return v;
|
|
}).catch((v) => ({ default: () => `${v}` })).then((v) => M(x.createElement(v.default, { ...q, layouts: z, $setting: i }))) : M(p(e ? ln : dn, { ...q, layouts: z, $setting: i }));
|
|
}, [t, i]), p(ie.Provider, { value: { classNames: R, listCode: a, onClickCallback: n, onReload: r, getBase62params: T, onPageChange: l, onPageSizeChange: c, onTabChange: f, onSiderChange: P, onKeywordChange: h, onConditionChange: C }, children: A && x.cloneElement(A, q) });
|
|
};
|
|
di.propTypes = { classNames: w.exact({ sider: w.string, filter: w.string, footer: w.string, toolbar: w.string, container: w.string, content: w.string, item: w.string }), layouts: w.oneOfType([w.exact({ sider: w.oneOfType([w.elementType, w.element]), filter: w.oneOfType([w.elementType, w.element]), footer: w.oneOfType([w.elementType, w.element]), toolbar: w.oneOfType([w.elementType, w.element]) }), w.bool]) };
|
|
var fe, ue, Pe, it;
|
|
const ae = class ae {
|
|
constructor() {
|
|
E(this, ue, null);
|
|
E(this, Pe, /* @__PURE__ */ new Map());
|
|
E(this, it, () => {
|
|
if (y(this, ue)) return y(this, ue).port.postMessage({ command: "status", data: [] });
|
|
U(this, ue, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), y(this, ue).port.onmessage = (t) => {
|
|
var i, n;
|
|
(i = t.data) != null && i.uuid ? y(this, Pe).forEach((r, a) => {
|
|
var o;
|
|
(r == "*" || (o = r == null ? void 0 : r.includes) != null && o.call(r, t.data.uuid)) && a(t.data);
|
|
}) : ((n = t.data) == null ? void 0 : n.readyState) == WebSocket.CLOSED && j.get("/api/user-api-token").then(({ token: r, expire_at: a }) => {
|
|
y(this, ue).port.postMessage({ command: "initWs", data: [`ws${d.trimStart(j.appUrl, "http")}api/user-resource-status-ws?token=${r}`] });
|
|
});
|
|
}, y(this, ue).port.postMessage({ command: "status", data: [] });
|
|
});
|
|
$(this, "subscribe", (t, i = []) => (i ? Array.isArray(i) && i.length == 0 ? i = "*" : Array.isArray(i) || (i = [i].flat()) : i = "*", y(this, Pe).set(t, i), y(this, Pe).size == 1 && y(this, it).call(this), () => this.unsubscribe(t)));
|
|
$(this, "unsubscribe", (t) => y(this, Pe).delete(t));
|
|
if (y(ae, fe)) return y(ae, fe);
|
|
}
|
|
};
|
|
fe = new WeakMap(), ue = new WeakMap(), Pe = new WeakMap(), it = new WeakMap(), E(ae, fe, null), $(ae, "getInstance", () => (y(ae, fe) || U(ae, fe, new ae()), y(ae, fe)));
|
|
let bt = ae;
|
|
const ui = bt.getInstance(), Nt = x.forwardRef(({ listCode: e, base62params: t, className: i, theme: n, themeProps: r, layouts: a, classNames: o }, s) => {
|
|
const [{ resource: l, primaryKey: u, batchOperations: c = [], itemOperations: g = [], columns: f = [], themeConfig: m, theme: h, isConditionFormLayout: b = !1, isTreeSider: C, treeSiderConfig: k, isItemGridLayout: P, itemGridLayout: S, title: R, isPaginate: V, tabs: q }, A] = F({ isItemGridLayout: !1, itemGridLayout: {} }), M = on(e, t), [{ dataSource: T, itemOperationsAccess: z, condition: v, tab: B, keyword: K, page: ge, total: J, pageSize: st, sider: Je, onConditionChange: ot, onTabChange: Ot, onKeywordChange: xi, onPageChange: vi, onPageSizeChange: Si, onSiderChange: Pi, onReload: lt, payload: $i }, jt] = sn(M, e, u, l), Ni = wt(g, z, T, u), Ti = wt(c);
|
|
L(() => {
|
|
let Q = null;
|
|
return e && j.get(`/api/_/${e}`).resp(({ data: Ke, res: Fi }) => {
|
|
Ke != null && Ke.isDynamicRefresh && (Q = ui.subscribe(() => lt(), Fi)), A(Ke);
|
|
}).catch(() => A({})), () => Q == null ? void 0 : Q();
|
|
}, [e]), x.useImperativeHandle(s, () => ({ onReload: lt, onClickCallback: jt }));
|
|
const Ri = { listCode: e, title: R, classNames: o, layouts: a, resource: l, primaryKey: u, theme: n || h, themeProps: r || m, isTreeSider: C, treeSiderConfig: k, isPaginate: V, tabs: q, isItemOperations: Ni, itemOperations: g == null ? void 0 : g.map((Q) => d.isEmpty(Q == null ? void 0 : Q.confirm) ? Q : { ...Q, confirm: Object.assign({}, Q.confirm, { getPopupContainer: () => document.body }) }), isBatchOperations: Ti, batchOperations: c, isItemGridLayout: P, columns: f, itemGridLayout: S, isConditionFormLayout: b, itemOperationsAccess: z, dataSource: T, onConditionChange: ot, onTabChange: Ot, onKeywordChange: xi, onPageChange: vi, onPageSizeChange: Si, onSiderChange: Pi, condition: v, tab: B, keyword: K, page: ge, total: J, pageSize: st, sider: Je, payload: $i };
|
|
return p(di, { ...Ri, className: I("ff-data-list-helper", i), onReload: lt, onClickCallback: jt });
|
|
}), gi = (e, t, i = !0) => i !== !0 && i-- <= 0 ? [] : d.isArray(e) && !d.isEmpty(e) ? e.reduce((n, r) => (Reflect.has(r, t) && Reflect.has(r, "children") && n.push(r[t]), Reflect.has(r, "children") && !d.isEmpty(r.children) ? n.concat(gi(r.children, t, i)) : n), []) : [], hn = ({ className: e, primaryKey: t, columns: i = [], dataSource: n = [], operationRender: r, operationWidth: a = 180, ...o }) => {
|
|
const { classNames: s } = ce(ie), l = W(null), u = W(null), [c, g] = F([]), [f, m] = F({ width: 0, height: 0 });
|
|
L(() => {
|
|
g(gi(n, t));
|
|
}, [n, t]), Li(() => {
|
|
const b = new ResizeObserver(() => {
|
|
var C;
|
|
m({ width: ((C = l.current) == null ? void 0 : C.nativeElement.querySelector(".ant-table-body").scrollWidth) || u.current.offsetWidth, height: u.current.offsetHeight });
|
|
});
|
|
return u.current && b.observe(u.current), () => {
|
|
u.current && b.unobserve(u.current);
|
|
};
|
|
}, []);
|
|
const h = an(i);
|
|
return p("div", { ref: u, className: I("ff-data-list-table", s.content, e), children: f.height ? p(Di, { ...o, ref: l, rowKey: (b) => (b == null ? void 0 : b[t]) ?? Math.random(), columns: h == null ? void 0 : h.concat(r ? [{ title: "操作", align: "center", fixed: "right", width: `${Math.ceil(a / f.width * 100).toFixed(2)}%`, render: (b, C, k) => r(C, k) }] : []), dataSource: n, size: "middle", scroll: { x: "max-content", y: f.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: g, expandedRowKeys: c } }) : null });
|
|
}, yn = "RC_FORM_INTERNAL_HOOKS", wn = (e, { initialValue: t, initialValueLanguage: i, convertJs: n, convertJsSetting: r, type: a = "string" }, o = null) => {
|
|
const s = W(!1), l = ce(Yt), [u, c] = F(), [g, f] = F(i != "javascript" && e ? l.getFieldValue(e) : void 0), { registerWatch: m } = l.getInternalHooks(yn) || {};
|
|
return L(() => m == null ? void 0 : m((h, b, C) => {
|
|
if (!s.current) return;
|
|
const k = d.get(b, e);
|
|
d.isEqual(k, g) || f(ee(k, a));
|
|
}), [g]), L(() => {
|
|
i == "javascript" && t ? xe.exec(t, {}, { getFieldValueForBasicForm: (h) => o ? o.getFieldValue(h) : l.getFieldValue(h), getFieldValue: (h) => l.getFieldValue(h) }).then((h) => f(ee(h, a))).catch((h) => notification.error({ message: `布局数据错误: ${JSON.stringify(h)}` })).finally(() => s.current = !0) : (t && f(ee(t ?? l.getFieldValue(e), a)), s.current = !0);
|
|
}, [t, i]), Ue(() => {
|
|
s.current && n && new Qe([n, r]).toValue(g, l.getFieldsValue(!0)).then(c).catch((h) => {
|
|
c(h), console.error("布局数据转换错误: ", h, n);
|
|
});
|
|
}, [g, n, r]), [u ?? g, g];
|
|
}, pi = (e, t, i = null) => H(() => {
|
|
var n;
|
|
return (n = d.sortBy(e, ["y", "x"])) == null ? void 0 : n.map(({ i: r, x: a, y: o, w: s, h: l, field: { boxStyle: u, ...c } }, g) => p("div", { className: "grid-layout-item", style: li(a, o, s, l, u), children: p(t, { ...c, basicForm: i }) }, r ?? g));
|
|
}, [e]), bn = ({ widget: e, widgetPrefix: t = "@pkg/ff/grid-layouts", basicForm: i, ...n }) => {
|
|
const r = e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, [a, o] = F();
|
|
return L(() => {
|
|
r && le.getWidgetComponent(r).then(({ defaultProps: s = {}, default: l }) => ({ default: Cn(l, s, i) })).catch((s) => ({ default: () => `${s}` })).then((s) => o(x.createElement(s.default, n)));
|
|
}, [r]), a;
|
|
}, Cn = (e, t = {}, i = null) => (n) => {
|
|
const { code: r, label: a, extras: o, isVirtual: s, initialValue: l, initialValueLanguage: u, convertJs: c, convertJsSetting: g, value: f, ...m } = d.merge({}, t, n), [h, b] = wn(s ? null : r, { initialValue: l, initialValueLanguage: u, convertJs: c, convertJsSetting: g, type: (m == null ? void 0 : m.type) || "string" }, i), C = H(() => {
|
|
const S = Object.keys((t == null ? void 0 : t.extras) || {});
|
|
return d.over([d.partialRight(d.pick, S), d.partialRight(d.omit, S)]);
|
|
}, [t == null ? void 0 : t.extras]), [k, P] = C(m);
|
|
return p(e, { ...P, value: h, rawValue: b, $setting: Object.assign({}, o, k) });
|
|
}, mi = ({ className: e, cols: t = 12, rowHeight: i = 21, containerPadding: n = [0, 0], itemMargin: r = [4, 0], formProps: a = {}, fields: o = [], data: s, basicForm: l = null, ...u }) => {
|
|
const [c] = te.useForm(), g = pi(o, bn, l), f = H(() => [{ name: "__PROPS__", value: a }], [a]);
|
|
return Ue(() => (c.setFieldsValue(s), () => c.resetFields()), [s]), p(te, { fields: f, form: c, component: !1, children: p("div", { ...u, className: I("ff-grid-layout", e), style: { "--grid-layout-item-margin-y": `${(r == null ? void 0 : r[0]) || 0}px`, "--grid-layout-item-margin-x": `${(r == null ? void 0 : r[1]) || 0}px`, "--grid-layout-container-padding-y": `${(n == null ? void 0 : n[0]) || 0}px`, "--grid-layout-container-padding-x": `${(n == null ? void 0 : n[1]) || 0}px`, "--grid-layout-cols": t, "--grid-layout-row-height": `${i}px` }, children: g }) });
|
|
}, kr = (Dt = mi, function({ code: e, data: t, ...i }) {
|
|
const [n, r] = F({ resource: null, cols: 12, rowHeight: 21, fields: [] });
|
|
return L(() => {
|
|
e && j.get(`/api/_/${e}`).then((a) => r(d.pick(a, ["resource", "cols", "rowHeight", "fields"])));
|
|
}, [e]), (n == null ? void 0 : n.resource) && p(Dt, { ...i, rowHeight: n.rowHeight, cols: n.cols, fields: n.fields, data: n != null && n.resource ? { [n == null ? void 0 : n.resource]: t } : {} });
|
|
});
|
|
var Dt;
|
|
const kn = ({ column: e = 0, colWidth: t = 0, cols: i, rowHeight: n, itemMargin: r, fields: a, primaryKey: o, dataSource: s, itemClassName: l, beforeRender: u = null, afterRender: c = null, itemRender: g = (b, C, k) => b, empty: f = p(qi, { description: null }), className: m, style: h = {} }) => {
|
|
const { classNames: b } = ce(ie), C = H(() => p(mi, { cols: i, rowHeight: n, itemMargin: r, fields: a, className: l }), [a, i, n, r]), k = d.isEmpty(s);
|
|
return O("div", { className: I("ff-data-list-content", b.content, m), style: Object.assign({}, h, e && { "--col-num": e }, t && { "--col-width": t }), children: [u == null ? void 0 : u(s), k ? f : s.map((P, S) => {
|
|
const R = g(x.cloneElement(C, { data: P }), P, S);
|
|
return x.cloneElement(R, { key: `${(P == null ? void 0 : P[o]) ?? S}-${rn(P)}` });
|
|
}), c == null ? void 0 : c(s)] });
|
|
}, xn = ({ component: e, $props: t }) => {
|
|
const { base62params: i } = We(t, {});
|
|
return p(Y, { children: p(Nt, { listCode: e, base62params: j.decode(i) }) });
|
|
}, xr = () => p(fi, {}), fi = () => "Empty", vn = ({ component: e, $setting: t, $props: i }) => {
|
|
const [n, r] = F();
|
|
L(() => {
|
|
if (!e) return r(p(fi, { description: null }));
|
|
le.getWidgetComponent(e).catch((o) => ({ default: () => `${o}` })).then((o) => x.createElement(o.default, { $setting: t })).then(r);
|
|
}, [e]);
|
|
const a = We(i, {});
|
|
return n ? x.cloneElement(n, a) : null;
|
|
}, vr = () => "NotFoundPage";
|
|
var he, Z, ye, we, Be, De;
|
|
const se = class se {
|
|
constructor() {
|
|
E(this, Z, /* @__PURE__ */ new Map());
|
|
E(this, ye, {});
|
|
E(this, we, null);
|
|
$(this, "init", (t, i) => {
|
|
U(this, Z, t), U(this, ye, i);
|
|
});
|
|
$(this, "get", (t) => (y(this, Z).has(t) || (t = Array.from(y(this, Z).keys()).find((i) => y(this, Z).get(i).uri === t)), y(this, Z).get(t) || {}));
|
|
$(this, "redirect", (t, i, n = {}) => {
|
|
const { uri: r, type: a, widgetProps: o } = this.get(t) || {}, { router: s, query: l, ...u } = i || {}, c = Object.assign({}, u, s), g = Object.assign({}, u, l);
|
|
a == "list" && (c.base62params = j.encode(c != null && c.base62params ? c.base62params : c));
|
|
let f = Ki(r || t, c);
|
|
const m = new URLSearchParams();
|
|
for (const h in o || {}) (o == null ? void 0 : o.type) == "query" && Object.has(g, h) && m.append(h, JSON.stringify(g[h]));
|
|
return m.size > 0 && (f = `${f}?${m.toString()}`), n != null && n.isOpenWindow ? window.open(f) : y(this, we).navigate(f, { replace: !!(n != null && n.isReplaceRouteHistory) });
|
|
});
|
|
$(this, "getMenus", (t) => {
|
|
var i;
|
|
return ((i = y(this, ye)) == null ? void 0 : i[t]) || [];
|
|
});
|
|
$(this, "findMenuPathByUuid", (t) => {
|
|
let i = [];
|
|
for (const n in y(this, ye)) if (i = y(this, Be).call(this, y(this, ye)[n], t, [n]), i.length > 1) return i;
|
|
return i;
|
|
});
|
|
$(this, "getMenusByRouteUuid", (t) => y(this, De).call(this, t, Object.values(y(this, ye)).flat()));
|
|
E(this, Be, (t, i, n = []) => {
|
|
if (d.isEmpty(t)) return n;
|
|
for (const { uuid: r, children: a } of t) {
|
|
if (r == i) return n.concat(r);
|
|
if (!d.isEmpty(a)) return n.concat(r, y(this, Be).call(this, a, i));
|
|
}
|
|
return n;
|
|
});
|
|
E(this, De, (t, i) => {
|
|
var r;
|
|
let n = [];
|
|
for (const a of i) a.widgetType == "redirect" && (a.uuid == t || a.widget == t ? n.push(a) : (r = a.children) != null && r.length && (n = n.concat(y(this, De).call(this, t, a.children))));
|
|
return n;
|
|
});
|
|
$(this, "getCurrentMenu", () => {
|
|
const { uuid: t } = this.getCurrentRoute() || {};
|
|
if (!t) return;
|
|
const i = this.getMenusByRouteUuid(t);
|
|
return d.isEmpty(i) ? void 0 : i[0];
|
|
});
|
|
$(this, "getCurrentRoute", (t = 0) => {
|
|
var n;
|
|
const i = (n = y(this, we).state.matches[y(this, we).state.matches.length - 1 - t]) == null ? void 0 : n.route;
|
|
if (!i) return null;
|
|
for (let [r, a] of y(this, Z)) if (a.uri === i.path) return a;
|
|
return null;
|
|
});
|
|
$(this, "getPageParams", (t) => {
|
|
var r, a, o;
|
|
let i = "", n = {};
|
|
if (Zt()) n = _i(), i = (r = Gi()) == null ? void 0 : r.search;
|
|
else {
|
|
const { location: s = {}, matches: l = [] } = ((a = y(this, we)) == null ? void 0 : a.state) || {};
|
|
n = ((o = l[l.length - 1]) == null ? void 0 : o.params) || {}, i = s.search;
|
|
}
|
|
return i && new URLSearchParams(i).forEach((s, l) => {
|
|
n[l] = s;
|
|
}), t ? d.get(n, t) : n;
|
|
});
|
|
$(this, "createBrowserRouter", (t = {}) => {
|
|
if (y(this, Z).size == 0) return null;
|
|
const i = Le.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/ff/frameworks/DefaultTheme"), n = Le.get(le.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), r = { [i]: 0 }, a = (s, l) => () => Promise.all([le.getWidgetComponent(s), We(l)]).then(([u, c]) => [u.default || function() {
|
|
return `${s}`;
|
|
}, c]).then(([u, c]) => ({ Component: () => x.createElement(ti, {}, x.createElement(u, { $setting: c })) })), o = Array.from(y(this, Z).values()).reduce((s, { uuid: l, uri: u, name: c, type: g, component: f, widgetSetting: m, widgetProps: h, isLogin: b, isLayout: C, extra: k }) => {
|
|
let P = {}, S = 0;
|
|
switch (g) {
|
|
case "list":
|
|
P.element = x.createElement(xn, { component: f, $props: h });
|
|
break;
|
|
case "fsdpf-component":
|
|
P.element = x.createElement(vn, { key: f, component: f, $setting: m, $props: h });
|
|
}
|
|
const R = (k == null ? void 0 : k.theme) ?? (k == null ? void 0 : k.layout);
|
|
if (R) {
|
|
const V = (k == null ? void 0 : k.themeProps) ?? (k == null ? void 0 : k.layoutProps);
|
|
if (!r[R]) return r[R] = s.length, [...s, { path: "/", lazy: a(R, V), children: [{ path: u, ...P }] }];
|
|
S = r[R];
|
|
}
|
|
return C && S > -1 ? (s[S].children.push({ path: u, ...P }), s) : [...s, { path: u, ...P }];
|
|
}, [{ path: "/", lazy: a(i, {}), children: [] }]);
|
|
return o.push({ index: !0, element: x.createElement(Sn, { to: n, replace: !0 }) }), U(this, we, Yi(o, t));
|
|
});
|
|
if (y(se, he)) return y(se, he);
|
|
}
|
|
};
|
|
he = new WeakMap(), Z = new WeakMap(), ye = new WeakMap(), we = new WeakMap(), Be = new WeakMap(), De = new WeakMap(), E(se, he, null), $(se, "getInstance", () => (y(se, he) || U(se, he, new se()), y(se, he)));
|
|
let Ct = se;
|
|
const Sn = ({ to: e, replace: t }) => Zt() ? x.createElement(Xi, { to: e, replace: t }) : (window.document.location = e, "redirect"), ke = Ct.getInstance(), $e = new Worker(new URL("/ff-worker/index.js", self.location)), qt = { getConfigure: (e) => Le.get(e), route: { redirect: (...e) => ke.redirect(...e), getPageParams: (...e) => ke.getPageParams(...e), getCurrentRoute: () => ke.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, Fe, be;
|
|
const D = class D {
|
|
constructor() {
|
|
$(this, "exec", (t, i = {}, n = {}, r = "") => new Promise((a, o) => {
|
|
if (!/^(?!\s*(\/\/|\/\*|\*)).*?\S+/m.test(t)) return a();
|
|
const s = Vt(D, nt)._++;
|
|
y(D, Fe).set(s, n), D.mQueue.set(s, [a, o]), $e.postMessage({ id: s, session: r, category: "eval", method: t, args: i });
|
|
}));
|
|
$(this, "clear", (t) => $e.postMessage({ session: t, category: "clear" }));
|
|
if (y(D, be)) return y(D, be);
|
|
Promise.resolve().then(() => _n).then((t) => {
|
|
qt.http = t.http;
|
|
}), $e.addEventListener("message", ({ data: { id: t, task_id: i, method: n, args: r, category: a, data: o, error: s, session: l } }) => {
|
|
if (a === "eval" && D.mQueue.has(t)) s !== null ? D.mQueue.get(t)[1](s) : D.mQueue.get(t)[0](o), y(D, Fe).delete(t), D.mQueue.delete(t);
|
|
else if (a === "util") try {
|
|
const u = d.get(qt, n.split("/")) || d.get(y(D, Fe).get(i), n.split("/"));
|
|
if (!d.isFunction(u)) throw `${n} not found`;
|
|
Promise.resolve(Reflect.apply(u, void 0, r)).then((c) => {
|
|
$e.postMessage({ id: t, task_id: i, category: a, method: n, args: r, session: l, data: c, error: null });
|
|
}).catch((c) => {
|
|
$e.postMessage({ id: t, task_id: i, category: a, method: n, args: r, session: l, data: null, error: c });
|
|
});
|
|
} catch (u) {
|
|
$e.postMessage({ id: t, task_id: i, category: a, method: n, args: r, session: l, data: null, error: u });
|
|
}
|
|
}, !1);
|
|
}
|
|
};
|
|
nt = new WeakMap(), Fe = new WeakMap(), be = new WeakMap(), $(D, "mQueue", /* @__PURE__ */ new Map()), E(D, nt, 0), E(D, Fe, /* @__PURE__ */ new Map()), E(D, be, null), $(D, "getInstance", () => (y(D, be) || U(D, be, new D()), y(D, be)));
|
|
let kt = D;
|
|
const xe = kt.getInstance(), rt = () => {
|
|
const e = W(!0), [, t] = x.useReducer((i) => i + 1, 0);
|
|
return L(() => () => e.current = !1, []), () => e.current && t();
|
|
}, Sr = (e) => {
|
|
const t = W();
|
|
return L(() => {
|
|
t.current = e;
|
|
}, [e]), t.current;
|
|
}, Pr = (e) => {
|
|
const [t, i] = F(e), n = W(null), r = X((a, o) => {
|
|
n.current = o, i(a);
|
|
}, []);
|
|
return L(() => {
|
|
n.current && (n.current(t), n.current = null);
|
|
}, [t]), [t, r];
|
|
}, Ue = (e = (n) => {
|
|
}, t, i = d.isEqual) => {
|
|
const n = x.useRef();
|
|
i(t, n.current) || (n.current = d.cloneDeep(t)), x.useEffect(e, [n.current]);
|
|
}, at = Ue, hi = (e, t = "string") => {
|
|
var i;
|
|
if (!Array.isArray(e)) return e;
|
|
for (let n = 0; n < e.length; n++) e[n].value = ee((i = e[n]) == null ? void 0 : i.value, t), e[n] && Reflect.has(e[n], "children") && (e[n].children = hi(e[n].children, t));
|
|
return e;
|
|
}, $r = (e, t = "json", i = "string", n, r = null) => {
|
|
const [a] = te.useForm(n), [o, s] = F([{ label: "无", value: "", disabled: !0 }]), l = W([]), u = te.useWatch((c) => l.current.length === 0 ? null : d.pick(c, l.current), a) || null;
|
|
return L(() => {
|
|
Array.isArray(e) ? s(e) : t === "javascript" && e ? xe.exec(e, {}, { getFieldValue: (c) => (l.current.includes(c) || l.current.push(c), a.getFieldValue(c)), getFieldValueForBasicForm: (c) => (l.current.includes(c) || l.current.push(c), r ? r.getFieldValue(c) : a.getFieldValue(c)) }).then((c) => {
|
|
s(ee(c, "array"));
|
|
}) : e && s(ee(e, "array"));
|
|
}, [e, t, u]), hi(o, i);
|
|
}, Nr = (e) => {
|
|
const [t, i] = F(), n = { type: "GET" };
|
|
if (typeof e == "string" ? n.url = e : d.isPlainObject(e) && Object.assign(n, e), !(n != null && n.url)) throw "url is required";
|
|
const r = (a) => j.request(n, !1).resp((o) => (console.log("useSubscribeRequest", a), i(o), o));
|
|
return Ue(() => {
|
|
let a = null;
|
|
return r().then((o) => {
|
|
a = ui.subscribe(d.throttle(r, 180, { leading: !1, trailing: !0 }), o.res);
|
|
}), () => a == null ? void 0 : a();
|
|
}, n), t;
|
|
}, Pn = (e) => {
|
|
const [t, i] = x.useState({ gridItems: [], hideItems: [] });
|
|
return x.useEffect(() => {
|
|
e && j.get(`/api/_/${e}`).then(({ pk: n, uuid: r, code: a, resource: o, align: s, cols: l, rowHeight: u, marginX: c, marginY: g, listenChangeFields: f, listenChangeFieldsFunc: m, fields: h }) => ({ pk: n, uuid: r, code: a, resource: o, align: s, cols: l, rowHeight: u, marginX: c, marginY: g, listenChangeFields: f, listenChangeFieldsFunc: m, ...h.reduce((b, C) => {
|
|
var k;
|
|
return (k = C == null ? void 0 : C.field) != null && k.hidden ? b.hides.push(C == null ? void 0 : C.field) : b.items.push(C), b;
|
|
}, { items: [], hides: [] }) })).then(i);
|
|
}, [e]), t;
|
|
}, $n = ({ max: e = 0, min: t = 0, type: i = "", message: n, pattern: r, required: a = !1, validator: o } = {}, s, l) => {
|
|
const [u, c] = F([]);
|
|
return L(() => {
|
|
const g = [];
|
|
if (a) {
|
|
let f = l;
|
|
switch (l) {
|
|
case "number":
|
|
case "string":
|
|
case "array":
|
|
break;
|
|
case "bool":
|
|
f = "boolean";
|
|
break;
|
|
case "json":
|
|
f = "object";
|
|
}
|
|
g.push({ type: f, required: !0, whitespace: !0, message: "该项必填" });
|
|
}
|
|
switch (i) {
|
|
case "string":
|
|
g.push({ type: i, max: e, min: t, message: n || (t && e ? `字符必须在 ${t} ~ ${e} 之间` : `${e ? "最多能有" : "最少要有"} ${t || e} 个字符`) });
|
|
break;
|
|
case "pattern":
|
|
g.push({ type: "string", pattern: r, message: n });
|
|
break;
|
|
case "validator":
|
|
o && g.push(({ getFieldValue: f }) => ({ validator: async (m, h) => {
|
|
const b = await xe.exec(o, { value: h, fieldName: s }, { getFieldValue: f });
|
|
return d.isString(b) && b ? Promise.reject(b) : d.isBoolean(b) && !b ? Promise.reject(n) : Promise.resolve();
|
|
} }));
|
|
}
|
|
c(g);
|
|
}, [e, t, i, n, r, a, o]), u;
|
|
}, Nn = (e, t, i) => {
|
|
const [n, r] = F(null);
|
|
return L(() => {
|
|
const { initDataUri: a = `/api/${e}`, initDataMethod: o = "GET" } = i || {};
|
|
t && j.request({ method: o, url: d.trimEnd(`${a}/${t}`, "/") }).then((s) => {
|
|
r(s);
|
|
});
|
|
}, [e, t, i]), n;
|
|
}, yi = (e, t, i = {}, n = {}, r = {}) => {
|
|
const a = ce(Yt), o = rt(), s = W(!0), l = W([]), [u, c] = F(t), g = te.useWatch((f) => JSON.stringify(d.pick(f, l.current)), a) || "{}";
|
|
return at(() => {
|
|
e && xe.exec(e, i, { ...n, getFieldValueForBasicForm: (f) => r ? r.getFieldValue(f) : null, getFieldValue: d.wrap(a.getFieldValue, (f, m) => (l.current.some((h) => d.isEqual(h, m)) || (l.current.push(m), o()), f == null ? void 0 : f(m))), isFieldTouched: a.isFieldTouched, isFieldsTouched: a.isFieldsTouched }).then((f) => s.current && c(f));
|
|
}, [e, g, a, i, n]), L(() => () => s.current = !1, []), u;
|
|
}, Tn = (e, t, i = [], n = {}) => {
|
|
const r = W({});
|
|
if (!t) return [e, r.current];
|
|
const a = W(), o = d.debounce(rt(), 180), s = ["disabled", "required"], l = (g, f) => {
|
|
s.includes(g) && (r.current[g] = f), o();
|
|
}, u = H(() => ({ setDisabled: (g) => l("disabled", g), setRequired: (g) => l("required", g), getDisabled: () => r.current.disabled, getRequired: () => r.current.required }), [t]), c = yi(t, -1, {}, u, n) ?? -1;
|
|
if (a.current != c && (c >= 0 || !d.isEmpty(i == null ? void 0 : i[c]))) {
|
|
a.current = c;
|
|
const { widget: g, widgetPrefix: f, props: m } = i == null ? void 0 : i[c];
|
|
e = ni(g, f), r.current = d.merge(m, d.pick(r.current, s));
|
|
}
|
|
return [e, r.current];
|
|
}, Wt = (e) => e === void 0 || e === !1 ? "" : (Array.isArray(e) ? e : [e]).join("_"), Tr = ({ value: e, onChange: t }, i = null) => {
|
|
const n = W(), [r] = te.useForm(i), a = W({});
|
|
return at(() => {
|
|
d.isEqual(n.current, e) || r.setFieldsValue(e);
|
|
}, [e]), L(() => () => r.resetFields(), []), [H(() => r.__INTERNAL__ ? r : { ...r, __INTERNAL__: { itemRef: (o) => (s) => {
|
|
const l = Wt(o);
|
|
s ? a.current[l] = s : delete a.current[l];
|
|
} }, scrollToField: (o, s = {}) => {
|
|
console.warn("useMergedFormValuesChange scrollToField not work, unreferenced antd form");
|
|
}, focusField: (o) => {
|
|
console.warn("useMergedFormValuesChange focusField not work, unreferenced antd form");
|
|
}, getFieldInstance: (o) => {
|
|
const s = Wt(o);
|
|
return a.current[s];
|
|
} }, [r]), (o, s) => {
|
|
n.current = s, t == null || t(s);
|
|
}];
|
|
}, Rn = ({ type: e, initialValue: t, initialValueLanguage: i, onChange: n, basicForm: r }) => {
|
|
const a = yi(i == "javascript" && t, i == "javascript" ? void 0 : t, {}, {}, r);
|
|
return L(() => {
|
|
i == "javascript" ? n(ee(a, e)) : t && n(ee(t, e));
|
|
}, [e, t, a]), null;
|
|
}, wi = ({ widget: e = "Input", widgetPrefix: t = "@pkg/ff/grid-layout-forms", widgetDecorator: i, subWidgets: n = [], basicForm: r, ...a }) => {
|
|
const o = ni(e, t), [s, l] = Tn(o, i, n, r), [u, c] = F();
|
|
return L(() => {
|
|
s && le.getWidgetComponent(s).then(({ defaultProps: g = {}, default: f }) => ({ default: Fn(f, g, r) })).catch((g) => ({ default: () => `${g}` })).then((g) => c(x.createElement(g.default, a)));
|
|
}, [s]), u && x.cloneElement(u, { ...a, ...l });
|
|
}, Fn = (e, t = {}, i = null) => (n) => {
|
|
const { type: r, code: a, label: o, noStyle: s, placeholder: l, required: u = !1, extras: c, validators: g, help: f, isVirtual: m, $isReserved: h, initialValue: b, initialValueLanguage: C, ...k } = d.omit(d.merge({}, t, n), ["convertJs", "convertJsSetting", "widget", "widgetPerfix", "widgetDecorator", "subWidgets", "boxStyle"]), P = $n(Object.assign({}, g, u ? { required: !0 } : {}), a, r), S = H(() => {
|
|
const M = Object.keys((t == null ? void 0 : t.extras) || {});
|
|
return d.over([d.partialRight(d.pick, M), d.partialRight(d.omit, M)]);
|
|
}, [t == null ? void 0 : t.extras]), [R, V] = S(k), q = { label: o, noStyle: s, colon: !1, layout: "vertical" }, A = X((M) => M == null ? void 0 : ee(M, r), [r]);
|
|
return p(Xt, { name: a, rules: P, initialValue: A(b), normalize: A, children: (M, T, z) => {
|
|
var v;
|
|
return p(e, { type: r, rcform: z, basicForm: i, itemProps: { validateStatus: T.errors.length > 0 ? "error" : "success", tooltip: f || null, help: T.errors.length > 0 ? T.errors.join("、") : null, required: ((v = P == null ? void 0 : P[0]) == null ? void 0 : v.required) || !1, ...q }, fieldProps: { placeholder: l, ...V, ...M }, $setting: Object.assign({}, c, R) });
|
|
} });
|
|
}, Tt = ({ cols: e = 24, rowHeight: t = 16, itemMargin: i = [8, 16], containerPadding: n = [0, 0], fields: r = [], children: a, basicForm: o = null }) => {
|
|
const s = pi(r, wi, o);
|
|
return O("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: [s, a && x.cloneElement(a, { cols: e, rowHeight: t, itemMargin: i, containerPadding: n, fields: r })] });
|
|
};
|
|
Tt.propTypes = { fields: w.array };
|
|
const En = (Ut = Tt, ({ code: e, layout: t, name: i, primaryKey: n = 0, style: r = {}, formProps: a = {}, form: o, basicForm: s, isPreview: l = !1, className: u, onFinish: c, onValuesChange: g = () => {
|
|
}, ...f }) => {
|
|
const { align: m, autoComplete: h, resource: b, items: C, hides: k, rowHeight: P, marginX: S, marginY: R, cols: V, listenChangeFields: q, listenChangeFieldsFunc: A, pk: M, uuid: T } = Pn(e), [z] = te.useForm(o), v = H(() => [{ name: "__PK__", value: M }, { name: "__PROPS__", value: a }, { name: "__RESOURCE__", value: b }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: T }, { name: "__PRIMARY_KEY__", value: n }], [M, e, T, b, n, a]);
|
|
return O(te, { className: u, name: i || e, layout: t || m, fields: v, form: z, autoComplete: h, style: { ...r, position: "relative" }, onFinish: c, onValuesChange: (B, K) => (({ changedValues: ge, allValues: J, listenChangeFields: st, listenChangeFieldsFunc: Je, onValuesChange: ot, code: Ot }) => {
|
|
ot(ge, J), Je && Array.isArray(st) && xe.exec(Je, { changedValues: ge, allValues: J }, { getFieldValue: z.getFieldValue, setFieldValue: z.setFieldValue, setFieldsValue: z.setFieldsValue, isFieldTouched: z.isFieldTouched, isFieldsTouched: z.isFieldsTouched });
|
|
})({ changedValues: B, allValues: K, listenChangeFields: q, listenChangeFieldsFunc: A, onValuesChange: g, code: e }), children: [p(Ut, { ...f, form: z, basicForm: s, code: e, fields: C, cols: V, rowHeight: P, itemMargin: [S, R] }), k == null ? void 0 : k.map((B) => {
|
|
var K;
|
|
return p(Xt, { name: B.code, children: p(Rn, { form: z, basicForm: s, name: B.code, type: B.type, initialValue: B.initialValue, initialValueLanguage: (K = B.extras) == null ? void 0 : K.initialValueLanguage }) }, JSON.stringify(B.code));
|
|
})] }, e);
|
|
});
|
|
var Ut;
|
|
const bi = ({ $setting: e, $close: t, extras: i, code: n, primaryKey: r, ...a }) => {
|
|
const [o] = te.useForm(), s = Nn(n, r, e);
|
|
return L(() => {
|
|
s && o.setFieldsValue(s);
|
|
}, [s]), p(Y, { actions: O(x.Fragment, { children: [p(N, { name: "保存", type: "primary", widget: () => {
|
|
const l = o.getFieldValue("__RESOURCE__"), { initDataUri: u = `/api/${n}` } = e || {};
|
|
o.validateFields(!0).then((c) => l ? d.pick(c, [l]) : c).then((c) => j.post(r ? `${u}/${r}` : `${u}`, c).msg(t)).catch(() => G.error("请先完善表单信息", { duration: 2e3 }));
|
|
} }), p(N, { name: "取消", widget: () => t(!1) })] }), extras: i, children: p(En, { form: o, code: n, primaryKey: r, ...a }) });
|
|
}, Ht = /* @__PURE__ */ new Set(), xt = (e = [], t = 0) => {
|
|
const i = e[t];
|
|
if (i.length && !Ht.has(i)) {
|
|
const n = document.createElement("script");
|
|
n.setAttribute("src", i), n.setAttribute("data-namespace", i), e.length > t + 1 && (n.onload = () => {
|
|
xt(e, t + 1);
|
|
}, n.onerror = () => {
|
|
xt(e, t + 1);
|
|
}), Ht.add(i), document.body.appendChild(n);
|
|
}
|
|
}, vt = ({ className: e, type: t, style: i = {}, ...n }) => p("span", { role: "img", className: I("ff-iconfont", e), style: i, ...n, children: p("svg", { style: { width: "1em", height: "1em", fill: "currentColor", overflow: "hidden" }, viewBox: "0 0 1024 1024", children: p("use", { xlinkHref: `#${t}` }) }) });
|
|
vt.propTypes = { className: w.string, type: w.string.isRequired, style: w.object }, vt.init = xt;
|
|
const On = (e, t, i, n) => ke.redirect(i, t, n), jn = (e, t = {}, i, n = {}) => {
|
|
var a;
|
|
const r = (a = n.router) == null ? void 0 : a.reduce((o, [s, l, u]) => {
|
|
const c = d.get(t, ["router", s]);
|
|
if (!c && c !== 0 && l) throw `请传入 ${u}`;
|
|
return `${o}/${c}`;
|
|
}, `/api/${i}`);
|
|
return j.del(r, t.param).msg();
|
|
}, Jt = (e, t, i, { status: { loading: n, disabled: r }, setStatus: a }) => {
|
|
const o = { loading: (s) => s === void 0 ? n : a((l) => ({ ...l, loading: s })), disabled: (s) => s === void 0 ? r : a((l) => ({ ...l, disabled: s })) };
|
|
return d.isFunction(i) ? i.call(null, { ...t, ...o }) : d.isString(i) && i ? xe.exec(i, t, o) : null;
|
|
}, Kt = (e, t, i, n, r) => d.isString(i) && i ? le.getWidgetComponent(i).then(({ default: a }) => G.modal(a, { ...t, $setting: n }, r != null && r.title ? { ...r, title: d.template(r.title)(e) } : r)).catch((a) => {
|
|
G.error(i, { content: a.toString() });
|
|
}) : G.modal(i, { ...t, $setting: n }, r != null && r.title ? { ...r, title: d.template(r.title)(e) } : r), Ln = (e, t, i, n, r) => G.modal(bi, { ...t, $setting: n, code: i }, r != null && r.title ? { ...r, title: d.template(r.title)(e) } : r), An = (e, t, i, n, r) => G.modal(Nt, { base62params: t, $setting: n, listCode: i }, r != null && r.title ? { ...r, title: d.template(r.title)(e) } : r), Vn = ({ widget: e, widgetType: t, widgetData: i, widgetProps: n, widgetSetting: r, widgetContainerProps: a }, { onAfterClick: o, onBeforeClick: s }) => {
|
|
const l = ce(ie), [u, c] = F({ leading: !0, trailing: !1 }), g = H(() => {
|
|
switch (t) {
|
|
case "redirect":
|
|
return d.partialRight(On, e, r);
|
|
case "func":
|
|
return d.partialRight(Jt, (r == null ? void 0 : r.code) ?? e, { status: u, setStatus: c });
|
|
case "fsdpf-component":
|
|
return d.partialRight(Kt, e, r, a);
|
|
case "grid-layout-form":
|
|
return d.partialRight(Ln, e, r, a);
|
|
case "data-list":
|
|
return d.partialRight(An, e, r, a);
|
|
case "destroy":
|
|
return d.partialRight(jn, e, r, a);
|
|
default:
|
|
if (Et(e) || x.isValidElement(e)) return d.partialRight(Kt, e, r, a);
|
|
if (d.isFunction(e)) return d.partialRight(Jt, (r == null ? void 0 : r.code) || e, { status: u, setStatus: c });
|
|
}
|
|
return (...f) => console.error("useButton unknown widgetType", t, ...f);
|
|
}, [e, t]);
|
|
return [d.debounce((f) => (s == null || s(f), Promise.resolve(We(n, f, { list: l })).then((m) => g(f, { ...i, ...m })).then((m) => o == null ? void 0 : o(m)).catch(console.error)), 300, { leading: !0, trailing: !1 }), u];
|
|
}, Ci = ({ type: e, name: t, className: i, icon: n, iconPosition: r, size: a }, o = "default") => H(() => {
|
|
const s = { type: "primary", className: I("ff-button", i), iconPosition: r, size: a };
|
|
return e === "danger" ? s.danger = !0 : e === "default" && (s.type = e), o === "link" || o === "dashed" ? (s.type = o, e === "default" && (s.className = I(s.className, "ff-default"))) : o !== "circle" && o !== "round" || (s.shape = o), n && (s.icon = p(vt, { type: n })), t && (s.children = t), s;
|
|
}, [o, e, i, n, r]), He = (e) => function({ className: t, variant: i, children: n, name: r, icon: a, type: o = "default", iconPosition: s = "start", noAuthType: l, onAfterClick: u, onBeforeClick: c, data: g, loading: f, disabled: m, tooltip: h, confirm: b, widget: C = () => {
|
|
}, widgetType: k, widgetData: P, widgetProps: S, widgetSetting: R, widgetContainerProps: V, ...q }) {
|
|
const A = d.isEmpty(h) || !h.enabled ? {} : h, M = d.isEmpty(b) ? { enabled: !1 } : Object.assign({ enabled: !0 }, b), T = Ci({ className: t, name: r, type: o, icon: a, iconPosition: s }, i ?? e), [z, v] = F(!1), [B, { disabled: K, loading: ge }] = Vn({ widget: C, widgetType: k, widgetData: P, widgetProps: S, widgetSetting: R, widgetContainerProps: V }, { onAfterClick: u, onBeforeClick: c });
|
|
return p(Wi, { okText: "确定", cancelText: "取消", getPopupContainer: (J) => J, ...M, disabled: K || m, open: z, onOpenChange: (J) => {
|
|
if (!J) return v(J);
|
|
M.enabled ? v(J) : B(g);
|
|
}, onConfirm: (J) => {
|
|
B(g, J);
|
|
}, onClick: (J) => {
|
|
J.stopPropagation();
|
|
}, children: p(Ui, { getPopupContainer: (J) => J, ...A, title: z ? null : A == null ? void 0 : A.title, trigger: ["hover", "click"], children: p(Xe, { loading: ge || f, disabled: K || m, ...T, ...q, children: n || r }) }) });
|
|
}, N = He("default");
|
|
N.propTypes = { type: w.oneOf(["primary", "default", "danger", ""]), size: w.oneOf(["large", "middle", "small"]), name: w.string, icon: w.string, iconPosition: w.oneOf(["start", "end"]), data: w.any, widget: w.any, widgetType: w.oneOf(["destroy", "redirect", "func", "fsdpf-component", "grid-layout-form", "grid-layout", "data-list"]), widgetData: w.object, widgetProps: w.object, widgetSetting: w.object, widgetContainerProps: w.object, tooltip: w.exact({ title: w.string.isRequired, placement: w.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: w.oneOfType([w.bool, w.number]), getPopupContainer: w.func }), confirm: w.exact({ title: w.string.isRequired, cancelText: w.string, okText: w.string, okType: w.oneOf(["primary", "default", "danger", ""]), placement: w.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: w.oneOfType([w.bool, w.number]), getPopupContainer: w.func, arrow: w.oneOfType([w.bool, w.exact({ pointAtCenter: w.bool })]) }) };
|
|
const In = He("link"), Mn = He("circle"), zn = He("round"), Bn = He("dashed"), Rt = ({ data: e, widget: t, widgetType: i = "fsdpf-component", widgetData: n, widgetProps: r, widgetSetting: a, widgetContainerProps: o, onAfterClick: s, onBeforeClick: l, children: u, extras: c }) => {
|
|
const g = ce(ie), [f, m] = F(!1), [h, b] = F("hover"), [C, k] = F({}), [P, S] = F(), { placement: R, align: V, arrow: q = { pointAtCenter: !0 }, getPopupContainer: A, ...M } = o || {};
|
|
L(() => {
|
|
i == "grid-layout-form" ? S(x.createElement(bi, { ...n, $setting: a, code: t })) : i == "data-list" ? S(x.createElement(Nt, { base62params: e, $setting: a, listCode: t })) : d.isString(t) ? le.getWidgetComponent(t).then(({ default: v }) => {
|
|
S(x.createElement(v, { ...n, $setting: a }));
|
|
}).catch((v) => S(v.toString())) : Et(t) ? S(x.createElement(t, { ...n, $setting: a })) : x.isValidElement(t) && S(x.cloneElement(t, { ...n, $setting: a }));
|
|
}, [t, i, n]), L(() => {
|
|
Promise.resolve(We(r, e, { list: g })).then(k);
|
|
}, [r, e, g.getBase62params]);
|
|
const T = (v, B = !1) => (m(v), !v && b("hover"), v ? l == null ? void 0 : l(C) : s == null ? void 0 : s(B)), z = (v) => {
|
|
m(!0), b("click");
|
|
};
|
|
return p(Hi, { placement: R, onPopupClick: z, onClick: z, open: f, align: V, arrow: q, trigger: h, getPopupContainer: A, content: p(Dn, { ...M, extras: c, children: P && x.cloneElement(P, { ...C, $close: (v) => T(!1, v) }) }), children: u, onOpenChange: T });
|
|
}, Dn = ({ title: e, className: t, children: i, extras: n, width: r, height: a, ...o }) => {
|
|
const [s, l] = F({}), u = X((m, h) => l((b) => ({ ...b, [m]: h })), []), c = X((m) => l((h) => ({ ...h, [m]: void 0 })), []), g = e ? x.createElement("div", { className: "ff-popup-title" }, e) : s == null ? void 0 : s.title, f = n ?? x.createElement("div", { className: "ff-popup-reserved-extras" }, n);
|
|
return p(qe.Provider, { value: { ele: s, mount: u, unmount: c }, children: O("div", { className: I("ff-popup ff-popover", t, s.rootClassName), style: { width: r, height: a }, ...o, children: [O("div", { className: "ff-popup-header", children: [g, s == null ? void 0 : s["sub-title"]] }), i, O("div", { className: "ff-popup-footer", children: [f, s == null ? void 0 : s.extras, s == null ? void 0 : s.actions] })] }) });
|
|
};
|
|
Rt.propTypes = { widgetType: w.oneOf(["fsdpf-component", "grid-layout-form", "data-list"]) };
|
|
const _t = ({ options: e = [], triggerWeights: t = ["grid-layout-form", "grid-layout", "fsdpf-component", "print"], onAfterClick: i = (m, h, b) => {
|
|
}, onBeforeClick: n = (m, h, b) => {
|
|
}, labelVariant: r = "link", labelSize: a, labelRender: o, btnVariant: s, btnSize: l, btnRender: u = (m, h) => p(N, { ...m, data: h }, m.uuid || pt()), widgetContainerProps: c = {}, children: g, data: f }) => {
|
|
if (d.isEmpty(e)) return g;
|
|
const [m, h] = H(() => (e || []).reduce((C, k) => {
|
|
const P = t.indexOf(k.widgetType);
|
|
return P === -1 ? C[1].push(k) : C[0] ? P < t.indexOf(C[0].widgetType) ? (C[1].push(C[0]), C[0] = k) : C[1].push(k) : C[0] = k, C;
|
|
}, [null, []]), [e, t]);
|
|
o ? g = o(m, f) || g : g || (g = p(Xe, { ...Ci(Object.assign(m != null && m.name || m != null && m.icon ? {} : { icon: "icon-location" }, m, { size: a }), r) }));
|
|
const b = h.map((C) => u(Object.assign({ uuid: C.uuid, type: C.type, name: C.name, widget: C.widget, widgetType: C.widgetType, widgetProps: C.widgetProps, widgetData: C.widgetData, widgetSetting: C.widgetSetting, widgetContainerProps: C.widgetContainerSetting, confirm: C.confirm, onAfterClick: d.partialRight(i, C, f), onBeforeClick: d.partialRight(n, C, f) }, { size: l, variant: s }), f));
|
|
return p(Rt, { widget: m == null ? void 0 : m.widget, widgetType: m == null ? void 0 : m.widgetType, widgetProps: m == null ? void 0 : m.widgetProps, widgetSetting: m == null ? void 0 : m.widgetSetting, widgetContainerProps: Object.assign({}, c, m == null ? void 0 : m.widgetContainerProps), data: f, widgetData: m == null ? void 0 : m.widgetData, extras: b, onAfterClick: d.partialRight(i, m, f), onBeforeClick: d.partialRight(n, m, f), children: g });
|
|
};
|
|
_t.propTypes = { triggerWeights: w.array, options: w.arrayOf(w.shape({ ...N.propTypes, widgetType: N.propTypes.widgetType.isRequired })), btnSize: N.propTypes.size, btnRender: w.func, btnVariant: w.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelVariant: w.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelRender: w.func, labelSize: N.propTypes.size, onAfterClick: w.func, onBeforeClick: w.func, widgetContainerProps: N.propTypes.widgetContainerProps, data: N.propTypes.data }, N.Link = In, N.Link.defaultProps = N.defaultProps, N.Link.propTypes = N.propTypes, N.Circle = Mn, N.Circle.defaultProps = N.defaultProps, N.Circle.propTypes = N.propTypes, N.Round = zn, N.Round.defaultProps = N.defaultProps, N.Round.propTypes = N.propTypes, N.Dashed = Bn, N.Dashed.defaultProps = N.defaultProps, N.Dashed.propTypes = N.propTypes, N.Popover = Rt, N.GroupPopover = _t;
|
|
const qn = ({ fields: e, formProps: t, $close: i }) => {
|
|
const [n] = te.useForm(), r = H(() => [{ name: "__PROPS__", value: t }], [t]);
|
|
return p(Y, { actions: O(x.Fragment, { children: [p(N, { name: "取消", widget: () => i(!1) }), p(N, { name: "确定", type: "primary", widget: () => n.validateFields(!0).then(i) })] }), children: p(te, { fields: r, form: n, className: "ff-modal-form", children: e == null ? void 0 : e.map(({ code: a, ...o }) => p(wi, { code: a, ...o }, a)) }) });
|
|
}, Wn = ({ className: e, $close: t, children: i, title: n, subTitle: r, actions: a, extras: o, ...s }) => O(Qi, { ...s, prefixCls: "ff-drawer", className: I("ff-popup", e), maskMotion: { motionAppear: !0, motionName: "mask-motion" }, motion: (l) => ({ motionAppear: !0, motionName: `panel-motion-${l}` }), children: [O("div", { className: "ff-popup-header", children: [p("button", { "aria-label": "Close", className: "ff-popup-close", onClick: s.onClose, children: p($t, { type: "close" }) }), n, r] }), p("div", { className: "ff-popup-body", children: i }), O("div", { className: "ff-popup-footer", children: [o, a] })] }), Un = ({ className: e, $close: t, $event: i, children: n, title: r, subTitle: a, actions: o, extras: s, placement: l, ...u }) => {
|
|
const c = (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 p(Zi, { ...u, ...c, prefixCls: "ff-modal", modalRender: () => O("div", { className: I("ff-modal-content ff-popup", e), children: [O("div", { className: "ff-popup-header", children: [p("button", { "aria-label": "Close", className: "ff-popup-close", onClick: u.onClose, children: p($t, { type: "close" }) }), r, a] }), p("div", { className: "ff-popup-body", children: n }), O("div", { className: "ff-popup-footer", children: [s, o] })] }) });
|
|
}, ki = ({ placement: e, $close: t, $event: i, children: n, title: r, ...a }) => {
|
|
const [o, s] = F({}), [l, u] = F(!0), c = X((h, b) => s((C) => ({ ...C, [h]: b })), []), g = X((h) => s((b) => ({ ...b, [h]: void 0 })), []);
|
|
let f = { ...a, className: o.rootClassName, title: o.title || r && x.createElement("div", { className: I("ff-popup-title") }, r), subTitle: o["sub-title"], actions: o.actions, extras: o.extras, children: n, $close: t, $event: i, onClose: () => u(!1) };
|
|
const m = () => {
|
|
t(!1);
|
|
};
|
|
return p(qe.Provider, { value: { ele: o, mount: c, unmount: g }, children: e && e !== "center" ? p(Wn, { ...f, placement: e, open: l, afterOpenChange: (h) => !h && m() }) : p(Un, { ...f, visible: l, afterClose: m }) });
|
|
};
|
|
ki.propTypes = { placement: w.oneOf(["center", "left", "top", "right", "bottom"]) };
|
|
const _ = () => {
|
|
const [e, t] = Ai({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (a) => {
|
|
const { offsetHeight: o } = a;
|
|
return { height: o };
|
|
}, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, i] = x.useReducer((a) => a + 1, 0);
|
|
L(() => {
|
|
_.$onClick = n, _.$queue.forEach(([a, o, s], l, u) => {
|
|
r([o, s], ...a), delete u[l];
|
|
});
|
|
}, []);
|
|
const n = (a, o = {}, s = {}) => new Promise((l, u) => r([l, u], a, o, s)), r = ([a, o], s, l = {}, u = {}) => {
|
|
const c = _.$index++, g = (f) => ((m, h) => (_.$popups.delete(m), i(), h == null ? void 0 : h()))(c, () => a(f));
|
|
if (s === ii) return e.open({ ...u, key: c, content: x.createElement(s, { ...l, $close: () => e.close(c) }) });
|
|
_.$popups.set(c, x.createElement(ki, { maskClosable: !1, $event: l == null ? void 0 : l.$event, ...u, key: c, $close: g }, x.isValidElement(s) ? x.cloneElement(s, { ...l, $close: g }) : s != null && s.name || It.isForwardRef(s) || (s == null ? void 0 : s.$$typeof) === It.ForwardRef ? x.createElement(s, { ...l, $close: g }) : s)), i();
|
|
};
|
|
return O(x.Fragment, { children: [Array.from(_.$popups).map(([a, o]) => o), t] });
|
|
};
|
|
_.$popups = /* @__PURE__ */ new Map(), _.$index = 0, _.$queue = [], _.$onClick = (...e) => new Promise((t, i) => {
|
|
_.$queue.push([e, t, i]);
|
|
});
|
|
const Gt = (e, t, i = {}) => _.$onClick(e, t, i), ut = (e, { showProgress: t, duration: i, ...n } = { duration: 1.5 }) => _.$onClick(ii, { content: e, ...n }, { showProgress: t, duration: i }), G = { modal: Gt, confirm: (e, t = {}) => _.$onClick(en, { content: e, ...t }, { placement: "center" }), form: (e, t = {}, i = {}) => Gt(qn, { formProps: i, fields: e }, { placement: "center", ...t }).then((n) => {
|
|
if (n === !1) throw !1;
|
|
return n;
|
|
}), notification: ut, success: (e, t = { duration: 1.5 }) => ut(e, { ...t, className: "ff-notification-success", icon: "check" }), error: (e, t = { duration: 1.5 }) => ut(e, { ...t, className: "ff-notification-error", icon: "close" }) };
|
|
Oe.configure({ showSpinner: !1 }), je.interceptors.request.use((e) => {
|
|
e.headers.Platform = "web", e.headers.SaaS = window.localStorage.getItem("SaaS");
|
|
const t = window.localStorage.getItem(Ye);
|
|
return e.headers.Authorization = t ? `Bearer ${t} ` : void 0, Oe.inc(), e;
|
|
}, (e) => (Oe.done(), Promise.reject({ code: -1, msg: e }))), je.interceptors.response.use(({ data: e, headers: t }) => (Oe.done(), { ...e, res: t == null ? void 0 : t.res }), function(e) {
|
|
return Oe.done(), Promise.reject(e.message);
|
|
}), window.addEventListener("unhandledrejection", mt.onUnhandledRejection), mt.onMsg = (e, t) => G[[0, 1].includes(e) ? "success" : "error"](t).then(() => e === 20300 && ke.redirect(Le.get("Common.WEBSITE_LOGIN_PAGE")));
|
|
const St = { appUrl: "", init: (e, t, i) => {
|
|
St.appUrl = i, je.defaults.baseURL = i, je.defaults.timeout = 15e3, Object.assign(St, new mt(e, t, je));
|
|
} }, j = St;
|
|
class Ft extends Error {
|
|
constructor(t, i) {
|
|
super(i), Error.captureStackTrace && Error.captureStackTrace(this, Ft), !i instanceof Ae && (this.name = `${t} Error Runtime`);
|
|
}
|
|
}
|
|
class Ae extends Error {
|
|
constructor(t, ...i) {
|
|
super(...i), Error.captureStackTrace && Error.captureStackTrace(this, Ae), this.name = `${t} Not Found`;
|
|
}
|
|
}
|
|
const gt = "mine", Ye = "token";
|
|
var Ce, Ee;
|
|
const oe = class oe {
|
|
constructor() {
|
|
E(this, Ee, /* @__PURE__ */ new Map());
|
|
$(this, "setVendor", (t, i) => y(this, Ee).set(t, new ei(i, async (n, r) => {
|
|
var o, s;
|
|
if (!(n != null && n.default)) throw "@pkg not found";
|
|
let a = () => r;
|
|
switch ("function") {
|
|
case typeof (a = (o = n.default) == null ? void 0 : o[`./${r}/index.jsx`]):
|
|
case typeof (a = (s = n.default) == null ? void 0 : s[`./${r}/index.js`]):
|
|
return a();
|
|
}
|
|
throw new Ae(r);
|
|
})));
|
|
$(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 Ae(t);
|
|
try {
|
|
return y(this, Ee).has("pkg") ? await y(this, Ee).get("pkg").get(i) : await import(`${j.appUrl}/api/pkg-import/web?name=${t}`);
|
|
} catch (n) {
|
|
throw new Ft(t, n);
|
|
}
|
|
});
|
|
$(this, "getRoutes", () => j.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)));
|
|
$(this, "getMenus", () => j.get("/api/my-menu"));
|
|
$(this, "getConfigure", () => j.get("api/init-configure"));
|
|
$(this, "getWidgetOperationAuth", () => j.get("/api/init-widget-operation-auth").then((t) => t.reduce((i, { uuid: n, auth: r }) => [...i, [n, r]], [])));
|
|
$(this, "getPhoneNumber", (t) => j.get(`/api/user-wx-phone-number/${t}`));
|
|
$(this, "getUserToken", () => {
|
|
const t = window.localStorage.getItem(Ye);
|
|
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;
|
|
});
|
|
$(this, "checkUserToken", () => {
|
|
try {
|
|
return !!this.getUserToken();
|
|
} catch {
|
|
return !1;
|
|
}
|
|
});
|
|
$(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: a, ...o } = j.decode(window.localStorage.getItem(gt) || "", {});
|
|
return a === r ? Promise.resolve(o) : j.get("/api/mine-info").then(({ User: s = null }) => (window.localStorage.setItem(gt, j.encode({ ...s, iat: r })), s));
|
|
} catch (n) {
|
|
console.error(n), t && G.error("请登录").then(this.logout);
|
|
}
|
|
return Promise.resolve(null);
|
|
});
|
|
$(this, "login", (t, i, n = {}) => j.post("/api/user-token", { username: t, passwd: Vi.hash(i), platform: "web", ...n }).then(({ token: r }) => (window.localStorage.setItem(Ye, r), r)));
|
|
$(this, "logout", (t) => (window.localStorage.removeItem(gt), window.localStorage.removeItem(Ye), t == null ? void 0 : t()));
|
|
if (y(oe, Ce)) return y(oe, Ce);
|
|
}
|
|
};
|
|
Ce = new WeakMap(), Ee = new WeakMap(), E(oe, Ce, null), $(oe, "getInstance", () => (y(oe, Ce) || U(oe, Ce, new oe()), y(oe, Ce)));
|
|
let Pt = oe;
|
|
const le = Pt.getInstance(), Hn = x.createContext({ user: {}, initUser: () => {
|
|
}, initUserComplete: !1 }), Jn = x.createContext({ set: () => {
|
|
}, get: () => {
|
|
}, assign: () => {
|
|
}, currentRoute: () => {
|
|
} }), Et = (e) => !!(e != null && e.name) && (e.prototype instanceof x.Component || /^[A-Z]/.test(e.name)), Kn = (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);
|
|
}, _n = Object.freeze(Object.defineProperty({ __proto__: null, AppContext: Hn, AppGlobalParamsContext: Jn, cache: ei, configure: Le, default: le, func: xe, http: j, insertStyle: Kn, isReactComponent: Et, route: ke }, Symbol.toStringTag, { value: "Module" }));
|
|
export {
|
|
wi as $,
|
|
kn as A,
|
|
ln as B,
|
|
dn as C,
|
|
Qe as D,
|
|
an as E,
|
|
wr as F,
|
|
kr as G,
|
|
yn as H,
|
|
br as I,
|
|
oi as J,
|
|
wt as K,
|
|
sn as L,
|
|
on as M,
|
|
xn as N,
|
|
vn as O,
|
|
xr as P,
|
|
vr as Q,
|
|
ui as R,
|
|
rt as S,
|
|
Sr as T,
|
|
Pr as U,
|
|
Ue as V,
|
|
at as W,
|
|
$r as X,
|
|
Nr as Y,
|
|
En as Z,
|
|
Tt as _,
|
|
ni as a,
|
|
bi as a0,
|
|
Pn as a1,
|
|
$n as a2,
|
|
Nn as a3,
|
|
yi as a4,
|
|
Tn as a5,
|
|
Tr as a6,
|
|
vt as a7,
|
|
N as a8,
|
|
tn as a9,
|
|
Vn as aa,
|
|
Y as ab,
|
|
qe as ac,
|
|
ti as ad,
|
|
_ as ae,
|
|
G as af,
|
|
ur as ag,
|
|
gr as ah,
|
|
pr as ai,
|
|
le as aj,
|
|
Et as ak,
|
|
Kn as al,
|
|
j as am,
|
|
ei as an,
|
|
Le as ao,
|
|
xe as ap,
|
|
ke as aq,
|
|
Hn as ar,
|
|
Jn as as,
|
|
We as b,
|
|
fr as c,
|
|
ri as d,
|
|
hr as e,
|
|
yr as f,
|
|
nn as g,
|
|
rn as h,
|
|
li as i,
|
|
Cr as j,
|
|
gi as k,
|
|
mi as l,
|
|
bn as m,
|
|
wn as n,
|
|
pi as o,
|
|
di as p,
|
|
ci as q,
|
|
dt as r,
|
|
fn as s,
|
|
ee as t,
|
|
mr as u,
|
|
mn as v,
|
|
gn as w,
|
|
Nt as x,
|
|
ie as y,
|
|
hn as z
|
|
};
|