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