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