diff --git a/dist/button.js b/dist/button.js index edfdfb8..dae582f 100644 --- a/dist/button.js +++ b/dist/button.js @@ -1,6 +1,6 @@ -import { ae as e, ad as s, af as u } from "./common/main-FyOEZueW.js"; +import { ah as s, ag as u, ai as e } from "./common/main-Bv6_dpPM.js"; export { - e as auth, - s as default, - u as useButton + s as auth, + u as default, + e as useButton }; diff --git a/dist/common/main-Bv6_dpPM.js b/dist/common/main-Bv6_dpPM.js new file mode 100644 index 0000000..2160bfa --- /dev/null +++ b/dist/common/main-Bv6_dpPM.js @@ -0,0 +1,1154 @@ +var En = Object.defineProperty; +var It = (e) => { + throw TypeError(e); +}; +var jn = (e, t, n) => t in e ? En(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; +var $ = (e, t, n) => jn(e, typeof t != "symbol" ? t + "" : t, n), Mt = (e, t, n) => t.has(e) || It("Cannot " + n); +var y = (e, t, n) => (Mt(e, t, "read from private field"), n ? n.call(e) : t.get(e)), j = (e, t, n) => t.has(e) ? It("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), _ = (e, t, n, a) => (Mt(e, t, "write to private field"), a ? a.call(e, n) : t.set(e, n), n); +var zt = (e, t, n, a) => ({ + set _(i) { + _(e, t, i, n); + }, + get _() { + return y(e, t, a); + } +}); +import { jsx as g, jsxs as O } from "react/jsx-runtime"; +import S, { useEffect as L, useState as E, useCallback as J, useRef as W, useContext as ae, useMemo as U, useId as mt, isValidElement as An, useLayoutEffect as Ln } from "react"; +import w from "prop-types"; +import V from "classnames"; +import * as Bt from "react-is"; +import { useNotification as Vn } from "rc-notification"; +import h from "lodash"; +import Q, { Field as $t, FieldContext as Qt } from "rc-field-form"; +import { M as dt, N as Ee, a as je, P as ht, S as In } from "./vender-CtjyT19B.js"; +import Zt from "immutability-helper"; +import { Space as Mn, Form as Xe, Input as zn, Button as Ze, Pagination as Bn, Tree as Dn, Breadcrumb as qn, Table as Un, Empty as Wn, Popover as _n, Popconfirm as Kn, Tooltip as Hn } from "antd"; +import { useMergedState as Jn } from "rc-util"; +import { generatePath as Gn, useInRouterContext as en, useParams as Yn, useLocation as Xn, createBrowserRouter as Qn, Navigate as Zn } from "react-router-dom"; +import "rc-util/lib/hooks/useMergedState"; +import ea from "rc-drawer"; +import ta from "rc-dialog"; +var $e, Ve, Ne, de, xe, ve; +class tn { + constructor(t, n) { + j(this, $e, /* @__PURE__ */ new Map()); + j(this, Ve, !0); + j(this, Ne, []); + j(this, de); + j(this, xe, () => y(this, de)); + j(this, ve, () => Promise.resolve()); + $(this, "get", (...t) => new Promise((n, a) => { + const i = JSON.stringify(t); + if (y(this, $e).has(i)) return n(y(this, ve).call(this, y(this, de), ...t)); + if (y(this, de) === void 0) y(this, Ne).push([t, n, a]), y(this, Ve) && (_(this, Ve, !1), Promise.resolve(typeof y(this, xe) == "function" ? y(this, xe).call(this) : y(this, xe)).then((r) => _(this, de, r || null)).finally(() => { + y(this, Ne).forEach(([r, o, s]) => { + try { + const l = y(this, ve).call(this, y(this, de), ...r); + y(this, $e).set(JSON.stringify(r), l), o(l); + } catch (l) { + s(l); + } + }), y(this, Ne).length = 0; + })); + else { + const r = y(this, ve).call(this, y(this, de), ...t); + y(this, $e).set(i, r), n(r); + } + })); + _(this, ve, n), _(this, xe, t); + } +} +$e = new WeakMap(), Ve = new WeakMap(), Ne = new WeakMap(), de = new WeakMap(), xe = new WeakMap(), ve = new WeakMap(); +const Ci = () => g("div", { children: "Empty" }), qe = S.createContext({ ele: {}, mount: () => { +}, unmount: () => { +} }), H = ({ rootClassName: e, className: t, children: n, actions: a, title: i, subTitle: r, extras: o, style: s = {} }) => { + const { mount: l, unmount: p } = S.useContext(qe); + return H.Action({ children: a }), H.Title({ children: i }), H.SubTitle({ children: r }), H.Extra({ children: o }), L(() => (l("rootClassName", e), () => p(e)), [e]), g("div", { className: V("ff-container", t), style: s, children: n }); +}, Ye = (e) => ({ children: t, className: n }) => { + const { mount: a, unmount: i } = S.useContext(qe); + return L(() => (t && a(e, S.createElement("div", { key: `ff-${e}`, className: V(`ff-popup-${e}`, n) }, t)), () => i(e)), [n, t]), null; +}; +H.Action = Ye("actions"), H.Title = Ye("title"), H.SubTitle = Ye("sub-title"), H.Extra = Ye("extras"), H.propTypes = { className: w.string, style: w.object, title: w.any, subTitle: w.any, actions: w.any, extras: w.any }; +const ki = () => g(H, { className: "ff-loading", children: O("div", { className: "loader", children: [O("div", { className: "square", children: [g("span", {}), g("span", {}), g("span", {})] }), O("div", { className: "square", children: [g("span", {}), g("span", {}), g("span", {})] }), O("div", { className: "square", children: [g("span", {}), g("span", {}), g("span", {})] }), O("div", { className: "square", children: [g("span", {}), g("span", {}), g("span", {})] })] }) }), Si = () => g("div", { children: "NotFound" }), nn = ({ children: e }) => { + const [t, n] = E({}), a = J((r, o) => n((s) => ({ ...s, [r]: o })), []), i = J((r) => n((o) => ({ ...o, [r]: void 0 })), []); + return typeof (e == null ? void 0 : e.type) == "string" ? e : g(qe.Provider, { value: { ele: t, mount: a, unmount: i }, children: S.cloneElement(e, { className: t.rootClassName, title: t.title, subTitle: t["sub-title"], actions: t.actions, extras: t.extras }) }); +}; +nn.propTypes = { children: w.element.isRequired }; +const Dt = { 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"] }, Nt = ({ type: e, props: t }) => g("i", { ...t, children: g("svg", { viewBox: "0 0 1024 1024", width: "1em", height: "1em", fill: "currentColor", children: (Dt[e] || Dt.info).map((n, a) => g("path", { d: n }, a)) }) }), an = ({ className: e, content: t, icon: n, $close: a }) => O(S.Fragment, { children: [n && g("div", { className: V("ff-notification-icon", e), children: g(Nt, { type: n }) }), t] }), na = ({}) => g(H, { children: "Confirm" }); +var pe, Re; +const ie = class ie { + constructor() { + j(this, Re, /* @__PURE__ */ new Map()); + $(this, "init", (t) => _(this, Re, new Map(t))); + $(this, "check", (t) => !y(this, Re).has(t) || y(this, Re).get(t)); + if (y(ie, pe)) return y(ie, pe); + } +}; +pe = new WeakMap(), Re = new WeakMap(), j(ie, pe, null), $(ie, "getInstance", () => (y(ie, pe) || _(ie, pe, new ie()), y(ie, pe))); +let ft = ie; +const aa = ft.getInstance(), ia = (e, t, n = "children") => { + if (h.isEmpty(e)) return {}; + const a = h.find(e, ["value", t]); + if (!h.isEmpty(a)) return a; + const i = e.length; + for (let r = 0; r < i; r++) { + const { [n]: o } = e[r], s = ia(o, t, n); + if (!h.isEmpty(s)) return s; + } + return {}; +}, rn = (e = "Input", t = "@pkg/ff/grid-layout-forms") => e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`; +var me, Ie; +const re = class re { + constructor() { + j(this, Ie, null); + $(this, "init", (t) => _(this, Ie, t)); + $(this, "get", (t, n) => h.get(y(this, Ie), t, n)); + if (y(re, me)) return y(re, me); + } +}; +me = new WeakMap(), Ie = new WeakMap(), j(re, me, null), $(re, "getInstance", () => (y(re, me) || _(re, me, new re()), y(re, me))); +let yt = re; +const Ae = yt.getInstance(), qt = { 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" }, ce = (e, t) => { + let n = "string"; + n = Array.isArray(e) ? "array" : typeof e, h.isObject(e) && (n = "json"); + const a = `${n}2${t}`; + return Reflect.has(qt, a) ? qt[a](e) : e; +}, ra = (e) => e === null ? "null" : Array.isArray(e) ? "array" : typeof e == "object" ? "json" : typeof e == "boolean" ? "bool" : typeof e == "string" ? "string" : typeof e == "number" ? Number.isInteger(e) ? "integer" : "float" : typeof e, Ue = (e = {}, t = {}, n = {}, a = "") => sn(e, (i, r) => r === "type" && i === "code") ? on(e, t, n, a) : ln(e, t, a), sn = (e, t = () => !1) => h.some(e, (n) => !!h.some(n, t) || (h.isEmpty(n) || !h.isPlainObject(n) && !h.isArray(n) ? void 0 : sn(n, t))), on = async (e = {}, t = {}, n = {}, a = "") => { + let i = /* @__PURE__ */ Object.create(null); + for (let r in e) { + let o; + if (Reflect.has(e[r], "type") && ["code", "field", "router", "query", "string"].includes(e[r].type)) { + const { type: s, value: l = "", default: p = a } = e[r]; + switch (s) { + case "code": + try { + o = await Se.exec(l, t, n); + } catch (c) { + console.error("getWidgetPropsData", c); + } + break; + case "field": + o = h.get(t, l) ?? h.get(t, l.substring(l.indexOf(".") + 1)); + break; + case "router": + case "query": + o = ke.getPageParams(l); + break; + case "string": + o = l; + } + o ?? (o = p); + } else o = await on(e[r], t, n, a); + h.set(i, r, o); + } + return i; +}, ln = (e = {}, t = {}, n = "") => Object.keys(e || {}).reduce((a, i) => { + if (h.isPlainObject(e[i])) { + let r; + if (Reflect.has(e[i], "type") && ["field", "router", "query", "string"].includes(e[i].type)) { + const { type: o, value: s = "", default: l = n } = e[i]; + switch (o) { + case "field": + r = h.get(t, s) ?? h.get(t, s.substring(s.indexOf(".") + 1)); + break; + case "router": + case "query": + r = ke.getPageParams(s); + break; + case "string": + r = s; + } + r ?? (r = l); + } else r = ln(e[i], t, n); + h.set(a, i, r); + } + return a; +}, {}), ut = (e, t) => e && typeof e == "object" ? Array.isArray(e) ? e.map((n) => ut(n, t)) : Object.keys(e).reduce((n, a) => (t[a] ? n[t[a]] = ut(e[a], t) : n[a] = ut(e[a], t), n), {}) : e, xi = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => { + const t = 16 * Math.random() | 0; + return (e === "x" ? t : 3 & t | 8).toString(16); +}), vi = (e) => { + var t, n; + return e ? (n = (t = e.match(/^@pkg(?:[^\/]*\/){3}(?[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : n.name : ""; +}, Pi = (e) => { + var t, n; + return e ? (n = (t = e.match(/^@pkg(?:[^\/]*\/){2}(?[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : n.category : ""; +}, Ti = (e) => { + var t, n; + return e ? (n = (t = e.match(/^@pkg(?:[^\/]*\/){1}(?[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : n.owner : ""; +}, sa = (e, t = 32, n = "auto") => { + const a = wt(e), i = n === "auto" ? "x64" : n; + if (t === 32) return dt.x86.hash32(a).toString(); + if (t === 128) return i === "x64" ? dt.x64.hash128(a) : dt.x86.hash128(a); + throw new Error("bits 只能是 32 或 128"); +}, wt = (e) => e == null ? "null" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : typeof e == "function" ? e.toString() : Array.isArray(e) ? "[" + e.map(wt).join(",") + "]" : typeof e == "object" ? "{" + Object.keys(e).sort().map((t) => `${t}:${wt(e[t])}`).join(",") + "}" : String(e), oa = () => { + let e = 1; + const t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new Map(); + return (...a) => a.length === 0 ? "" : a.map((i) => { + return String((r = i) === null || typeof r != "object" && typeof r != "function" ? (n.has(r) || n.set(r, e++), n.get(r)) : (t.has(r) || t.set(r, e++), t.get(r))); + var r; + }).join("::"); +}; +var tt, Me, ze, nt; +const at = class at { + constructor(...t) { + j(this, Me, []); + j(this, ze, (t) => { + var n; + for (let a of t) Array.isArray(a[0]) ? y(this, ze).call(this, a) : y(this, Me).push(y(n = at, tt).call(n, a[0], a[1])); + }); + $(this, "toValue", async (t, n = null) => { + const a = { getValue: () => t, getRecord: () => n }; + let i = t; + for (const r of y(this, Me)) try { + const o = await r; + if (typeof o != "function") { + console.warn("middleware is not a function, skip:", o); + continue; + } + i = await o.call(a, i); + } catch (o) { + console.error("middleware error, skip:", o); + } + return i; + }); + $(this, "toRender", (t, n, a = null) => S.createElement(y(this, nt), { value: t, record: n }, a)); + j(this, nt, ({ value: t, record: n, children: a }) => { + const [i, r] = E(a); + return _e(() => { + let o = !1; + return r(a), this.toValue(t, n).then((s) => !o && r(s)).catch((s) => !o && r(`${s}`)), () => o = !0; + }, [t, n]), i; + }); + y(this, ze).call(this, t); + } +}; +tt = new WeakMap(), Me = new WeakMap(), ze = new WeakMap(), nt = new WeakMap(), j(at, tt, h.memoize((t, n) => { + if (typeof t == "function") return t(n); + if (typeof t == "string") return ne.getWidgetComponent(t).then((a) => { + var i; + return ((i = a.default) == null ? void 0 : i.call(a, n)) || ((r) => r); + }); + throw new TypeError("middleware must be a string or a function"); +}, oa())); +let et = at; +const Z = S.createContext({ listCode: "", classNames: {}, getBase62params: (e, t) => { +}, onReload: () => { +}, onClickCallback: () => { +}, onConditionChange: () => { +}, onTabChange: () => { +}, onSiderChange: () => { +}, onKeywordChange: () => { +}, onPageChange: () => { +}, onPageSizeChange: () => { +}, reload: () => { +}, setPage: () => { +}, setPageSize: () => { +}, setTab: () => { +}, setSider: () => { +}, setKeyword: () => { +}, setCondition: () => { +} }), Ut = ({ className: e, record: t, column: n, ...a }) => { + if (n != null && n.editableByJs && (n != null && n.uuid)) { + const { formSetting: i = { primaryKey: "id" }, widgetSetting: r = {}, widgetContainerSetting: o = {} } = (n == null ? void 0 : n.editableByJsSetting) || {}; + return g(P.Popover, { widget: la, widgetData: { record: t, column: n }, widgetSetting: { widgetSetting: r, formSetting: i }, widgetContainerProps: { title: n != null && n.title ? `${n.title} - 编辑` : "编辑", ...o, width: (o == null ? void 0 : o.width) || 260, arrow: !0 }, children: g("td", { className: V("ff-data-list-cell-editable", e), ...a }) }); + } + return g("td", { className: e, ...a }); +}, la = ({ record: e, column: t, $close: n, $setting: a }) => { + const i = W(ra(h.get(e, t == null ? void 0 : t.dataIndex))), { listCode: r, onClickCallback: o } = ae(Z), [s] = Q.useForm(), { formSetting: l, widgetSetting: p } = a, c = (l == null ? void 0 : l.primaryKey) || "id", d = () => { + s.setFieldsValue({ value: h.get(e, t == null ? void 0 : t.dataIndex), __PROPS__: e }); + }; + return _e(() => d(), [e, t == null ? void 0 : t.dataIndex, r]), g(H, { actions: O(S.Fragment, { children: [g(P, { size: "small", onClick: d, children: "重置" }), O(Mn.Compact, { block: !0, children: [g(P, { size: "small", widget: n, children: "取消" }), g(P, { type: "primary", size: "small", widget: () => s.validateFields().then(({ value: f }) => { + const m = h.get(e, c.substring(c.indexOf(".") + 1)); + if (!m) throw "获取更新主键失败!"; + A.put(`/api/${r}-storeBy-${t == null ? void 0 : t.uuid}/${m}`, { value: f }).msg(() => o(2, e)).then(n); + }).catch(console.warn), children: "保存" })] })] }), children: O(Q, { form: s, children: [g(Et, { label: "", type: i.current, code: "value", widget: t == null ? void 0 : t.editableByJs, extras: p }), g($t, { noStyle: !0, name: ["__PROPS__"], children: () => { + } })] }) }); +}, ca = (e) => function(t) { + return e(t, getRecord()); +}, da = (e, t = {}) => U(() => e == null ? void 0 : e.map(({ widgetByJs: n, widgetByJsSetting: a, ...i }, r) => { + const o = (l) => ({ record: l, column: i }); + let s = []; + return n && s.push([n, a]), s.length > 0 ? (i != null && i.render && s.push([ca, i.render]), { ...i, onCell: o, render: (l, p) => new et(s).toRender(l, p, "-") }) : { ...i, onCell: o }; +}), [e, t]), ua = (e = {}) => U(() => { + var t; + return e.body ?? (e.body = { cell: Ut }), (t = e.body).cell ?? (t.cell = Ut), e; +}, [e]), $i = (e) => { + const [t, n] = E({}); + return L(() => { + let a = !1; + return e && A.get(`/api/_/${e}`).then((i) => h.pick(i, ["uuid", "name", "code", "resource", "marginX", "marginY", "cols", "rowHeight", "primaryKey", "columns", "itemOperations", "batchOperations", "isConditionFormLayout", "layout", "tabs", "pageSize", "layoutConfig"])).then((i) => !a && n(i)), () => a = !0; + }, [e]), t; +}, Ni = (e, t = {}) => { + const [n, a] = E({ dataSource: [] }); + return We(() => { + let i = !1; + return e && A.get(`/api/${e}/${A.encode({ page: 1, ...t })}`).then((r) => !i && a(r)), () => i = !0; + }, [e, t]), n; +}, cn = (e = [], t = /* @__PURE__ */ new Map(), n = "id", a) => { + const i = J(a ? (r) => h.get(r, n, h.get(r, [a, n])) : (r) => h.get(r, n), [n, a]); + return J((r) => e == null ? void 0 : e.filter((o) => !o.uuid || !t.has(o.uuid) || t.get(o.uuid).some((s) => s == i(r))), [e, t, i]); +}, bt = (e = [], t = /* @__PURE__ */ new Map(), n = [], a = "id", i) => { + const r = J(i ? (o) => h.get(o, a, h.get(o, [i, a])) : (o) => h.get(o, a), [a, i]); + return U(() => { + if (h.isEmpty(e) || !e.some(({ uuid: s }) => aa.check(s))) return !1; + if (h.isEmpty(t) || h.isEmpty(n)) return !0; + const o = n.map((s) => r(s)); + return e.some(({ uuid: s }) => !s || !t.has(s) || t.get(s).some((l) => o.some((p) => p == l))); + }, [e, n, t, r]); +}, ga = (e, t, n = "id", a = null) => { + const i = st(), r = W(!1), o = W(e.dataSource), s = W(e.itemOperationsAccess); + return L(() => (o.current = e.dataSource, s.current = e.itemOperationsAccess, () => r.current = !1), [e.dataSource, e.itemOperationsAccess]), r.current && (e.dataSource = o.current, e.itemOperationsAccess = s.current), [e, (l = 0, p = null) => { + var c, d; + if (r.current = !1, l === 1) return (c = e.onReload) == null ? void 0 : c.call(e); + if (l === 2) { + const f = h.get(p, "__PARENT_ID__", ""), m = h.get(p, n, h.get(p, [a, n], "")), u = h.findIndex(o.current, ["__PARENT_ID__", f]), b = h.findIndex(u > -1 ? h.get(o.current, [u, "children"]) : o.current, [n, m]); + if (b === -1) return (d = e.onReload) == null ? void 0 : d.call(e); + Promise.all([A.get(`/api/${t}/detail/${m}`), A.post(`/api/${t}/list-operations-access`, { ids: m })]).then(([k, C]) => { + const x = h.get(o.current, u > -1 ? [u, "children", b, "children"] : [b, "children"]); + o.current = Zt(o.current, u > -1 ? { [u]: { children: { $splice: [[b, 1, { ...k, children: x }]] } } } : { $splice: [[b, 1, { ...k, children: x }]] }); + const v = new Map(C); + s.current.forEach((F, R) => { + var B; + (B = v.get(R)) != null && B.some((M) => M == m) || s.current.set(R, F.filter((M) => M !== m)); + }), v.forEach((F, R) => { + s.current.has(R) ? s.current.set(R, h.uniq([...s.current.get(R) || [], ...F])) : s.current.set(R, F); + }); + }).then(() => { + r.current = !0, i(); + }); + } + }]; +}, pa = (e, t) => { + const n = st(), a = W(t), i = W(/* @__PURE__ */ new Map()), r = W([]), o = h.throttle((l) => { + r.current = [], A.list(e, h.pick({ ...a.current, ...l }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: p, condition: c, total: d, tab: f, sider: m, page: u, pageSize: b, operationsAccess: k, dataSource: C }) => { + a.current = { tab: f, condition: c, sider: m, keyword: p, total: d, pageSize: b, page: C != null && C.length ? u : 1 }, r.current = C, i.current = new Map(k), n(); + }); + }, 380, { leading: !1, trailing: !0 }); + _e(() => { + r.current = [], e && o(t); + }, [e, t]); + const s = U(() => h.pick(a.current, ["total", "tab", "page", "pageSize", "condition", "sider", "keyword"]), [a.current]); + return Object.assign(s, { onTabChange: (l) => o({ tab: l, page: 1 }), onPageChange: (l, p) => o({ page: l, pageSize: p }), onPageSizeChange: (l) => o({ pageSize: l, page: 1 }), onConditionChange: (l, p) => o({ keyword: p, condition: Zt(a.current.condition || {}, { $merge: l || {} }), page: 1 }), onSiderChange: (l) => o({ sider: l, page: 1 }), onKeywordChange: (l) => o({ keyword: l, page: 1 }), itemOperationsAccess: i.current, dataSource: r.current, onReload: o, payload: t == null ? void 0 : t.payload }); +}, ma = ({ listCode: e, className: t, layouts: n = {}, dataSource: a, isPaginate: i, isItemOperations: r, isBatchOperations: o, batchOperations: s, itemOperations: l, itemOperationsAccess: p, resource: c, primaryKey: d, title: f, itemGridLayout: m, $setting: u, tabs: b, isConditionFormLayout: k, isTreeSider: C, treeSiderConfig: x }) => { + const { classNames: v, onClickCallback: F } = ae(Z), R = h.pick(u, ["column", "colWidth", "beforeRender", "afterRender", "style"]), B = cn(l, p, d, c), M = J((I, T, z) => g(ha, { className: V("ff-data-list-framework-item", v.item), operations: r ? B(T) : [], data: c ? { [c]: T } : T, children: I, onClickCallback: F }), [c, d, r, F, l, p]); + return O("div", { className: V("ff-data-list-framework", t), children: [g(n.sider, { isTreeSider: C, ...x }), O("div", { className: V("ff-data-list-container", v == null ? void 0 : v.container), children: [g(n.filter, { isConditionFormLayout: k }), g(n.toolbar, { title: f, tabs: b }), g(Na, { ...R, ...m, primaryKey: d, itemRender: M, dataSource: a }), g(n.footer, { isPaginate: i, isOperations: o, operations: s })] })] }); +}, ha = ({ className: e, operations: t, children: n, data: a, onClickCallback: i }) => O("div", { className: V("data-list-grid-layout-item-container", e), children: [n, !!(t != null && t.length) && g("div", { className: "data-list-grid-layout-item-actions", children: t.map((r) => g("span", { className: "data-list-grid-layout-item-action", children: g(P.Link, { uuid: r.uuid, type: r.type, name: r.name, widget: r.widget, widgetType: r.widgetType, widgetProps: r.widgetProps, widgetSetting: r.widgetSetting, widgetContainerProps: r.widgetContainerSetting, data: a, confirm: r.confirm, onAfterClick: (o) => o !== !1 && (i == null ? void 0 : i(r.isRefresh, a)) }, r.uuid || mt()) }, (r == null ? void 0 : r.uuid) || mt())) })] }), fa = ({ listCode: e, className: t, layouts: n = {}, dataSource: a, columns: i, isItemOperations: r, isBatchOperations: o, batchOperations: s, itemOperations: l, itemOperationsAccess: p, resource: c, primaryKey: d, title: f, tabs: m, isPaginate: u, isTreeSider: b, treeSiderConfig: k, isConditionFormLayout: C, ...x }) => { + const { classNames: v, onClickCallback: F } = ae(Z), R = cn(l, p, d, c), B = bt(l, p, a, d, c); + return O("div", { className: V("ff-data-table-framework", t), children: [g(n.sider, { isTreeSider: b, ...k }), O("div", { className: V("ff-data-table-container", v == null ? void 0 : v.container), children: [g(n.filter, { isConditionFormLayout: C }), g(n.toolbar, { title: f, tabs: m }), g(Sa, { ...x, primaryKey: d, className: "ff-data-table-content", columns: i, dataSource: a, operationRender: B ? (M) => { + var I; + return g("div", { className: "ff-data-table-actions", children: (I = R(M)) == null ? void 0 : I.map((T, z) => g(P.Link, { size: "small", uuid: T.uuid, type: T.type, name: T.name, widget: T.widget, widgetType: T.widgetType, widgetProps: T.widgetProps, widgetData: T.widgetData, widgetSetting: T.widgetSetting, widgetContainerProps: T.widgetContainerSetting, data: M, confirm: T.confirm, onAfterClick: (N) => N !== !1 && (F == null ? void 0 : F(T.isRefresh, M)) }, T.uuid || z)) }); + } : null }), g(n.footer, { isPaginate: u, isOperations: o, operations: s })] })] }); +}, Rt = (e, t, n = null) => { + var a; + return (a = h.sortBy(e, ["y", "x"])) == null ? void 0 : a.map(({ i, x: r, y: o, w: s, h: l, field: { boxStyle: p, ...c } }, d) => g("div", { className: "grid-layout-item", style: dn(r, o, s, l, p), children: g(t, { ...c, basicForm: n }) }, i ?? d)); +}, dn = (e, t, n, a, i = {}, r = 0) => { + const o = { "--grid-layout-h": `${a}`, "--grid-layout-w": `${n}`, "--grid-layout-x": `${e}`, "--grid-layout-y": `${t}`, "--grid-layout-row-height-offset": "0px" }; + return i != null && i.autoHeight ? o.height = "fit-content" : o["--grid-layout-row"] = `${a}`, i != null && i.alignItems && (o["--grid-layout-box-align-items"] = i.alignItems), i != null && i.justifyContent && (o["--grid-layout-box-justify-content"] = i.justifyContent), o["--grid-layout-box-margin"] = Wt(i == null ? void 0 : i.marginTop, i == null ? void 0 : i.marginRight, i == null ? void 0 : i.marginBottom, i == null ? void 0 : i.marginLeft), o["--grid-layout-box-padding"] = Wt(i == null ? void 0 : i.paddingTop, i == null ? void 0 : i.paddingRight, i == null ? void 0 : i.paddingBottom, i == null ? void 0 : i.paddingLeft), r && (o.height = `${r}px`), o; +}, Wt = (e, t, n, a) => `${e || 0}px ${t || 0}px ${n || 0}px ${a || 0}px`, Ri = (e = "Text", t = "@pkg/ff/grid-layouts") => e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, un = ({ className: e, isConditionFormLayout: t }) => { + var f, m; + const [n, a] = E({}), { listCode: i, onKeywordChange: r, onConditionChange: o, getBase62params: s, classNames: l } = S.useContext(Z), { keyword: p, condition: c } = (s == null ? void 0 : s()) || {}, [d] = Xe.useForm(); + return L(() => { + i && t && A.get(`/api/_/${i}/list-condition-form-layout`).then(({ resource: u, marginX: b, marginY: k, rowHeight: C, cols: x, fields: v }) => { + a({ resource: u, itemMargin: [b, k], rowHeight: C, cols: x, fields: v }); + }).catch(() => a({})); + }, [i, t]), L(() => { + d.setFieldsValue({ keyword: p, ...c }); + }, [JSON.stringify([p, c])]), g("div", { className: V("ff-data-list-filter", l.filter, e), children: g(Xe, { form: d, layout: "vertical", autoComplete: "off", onFinish: ((f = n.fields) == null ? void 0 : f.length) > 1 ? (u) => o({ [n.resource]: u[n.resource] }, u.keyword) : () => { + }, onValuesChange: (u) => { + h.isEmpty(h.omit(u, ["keyword"])) || d.submit(); + }, children: ((m = n.fields) == null ? void 0 : m.length) > 1 ? g(jt, { ...n, children: g(ya, { onReset: () => { + const { keyword: u, condition: b } = s("init") || {}; + d.setFieldsValue({ keyword: u, ...b }); + } }) }) : g("div", { className: "ff-data-list-filter-default-form ff-grid-layout-form", children: g("div", { className: "grid-layout-item", style: dn(20, 0, 5, 2), children: g(Xe.Item, { name: ["keyword"], children: g(zn.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (u) => r(u) }) }) }) }) }) }); +}, ya = ({ cols: e, fields: t, onReset: n }) => { + const [a, i] = E(!1), r = U(() => t == null ? void 0 : t.toReversed().some((o) => o.y > 1 || o.x + o.w >= e - 5), [e, t]); + return O(Xe.Item, { label: " ", style: { "--item-span": 5 }, className: V("ff-data-list-filter-actions", { expanded: a }), children: [g(Ze, { onClick: n, children: "重置" }), g(Ze, { type: "primary", htmlType: "submit", children: "查询" }), r && g(P.Link, { className: "ff-data-list-filter-expanded-button", widget: () => i((o) => !o), type: "primary", name: a ? "关闭" : "展开", icon: a ? "icon-up" : "icon-down", iconPosition: "end" })] }); +}; +un.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 wa = ({ className: e, operations: t, isOperations: n, isPaginate: a }) => { + const { onPageChange: i, onPageSizeChange: r, onClickCallback: o, getBase62params: s } = S.useContext(Z), { total: l, page: p, pageSize: c } = (s == null ? void 0 : s()) || {}; + return n && !h.isEmpty(t) || a ? O("div", { className: V("ff-data-list-footer", e), children: [g("div", { className: "ff-data-list-actions", children: t == null ? void 0 : t.map((d, f) => g(P, { uuid: d.uuid, type: d.type, name: d.name, widget: d.widget, widgetType: d.widgetType, widgetProps: d.widgetProps, widgetData: d.widgetData, widgetSetting: d.widgetSetting, widgetContainerProps: d.widgetContainerSetting, onAfterClick: (m) => m !== !1 && (o == null ? void 0 : o(d.isRefresh, null)) }, d.uuid || f)) }), a && g(Bn, { size: "small", total: l, pageSize: c, showSizeChanger: !1, showTotal: (d) => `第 ${p} 页 / 总共 ${d} 条`, onChange: i, onShowSizeChange: r })] }) : null; +}, ba = [{ title: "parent 1", key: "0-0", children: [{ title: "parent 1-0", key: "0-0-0", disabled: !0, children: [{ title: "leaf", key: "0-0-0-0", disableCheckbox: !0 }, { title: "leaf", key: "0-0-0-1" }] }, { title: "parent 1-1", key: "0-0-1", children: [{ title: g("span", { style: { color: "#1677ff" }, children: "sss" }), key: "0-0-1-0" }] }] }], Ca = ({ className: e, width: t = 280, isTreeSider: n }) => { + const { classNames: a } = ae(Z); + return n ? g(Dn.DirectoryTree, { className: V("ff-data-list-sider", a.sider, e), style: { "--sider-width": t }, showLine: !0, showIcon: !1, treeData: ba }) : null; +}, ka = ({ className: e, title: t, tabs: n }) => { + const { getBase62params: a, onTabChange: i, onReload: r, classNames: o } = ae(Z), { tab: s } = (a == null ? void 0 : a()) || {}, [l, p] = Jn((n == null ? void 0 : n[0].value) ?? (n == null ? void 0 : n[0].code), { value: s, onChange: i }); + return O("div", { className: V("ff-data-list-toolbar", o.toolbar, e), children: [g("div", { className: "ff-data-list-title", children: t }), g(qn, { className: "ff-data-list-tabs", itemRender: ({ label: c, code: d, value: f }) => g("span", { onClick: () => p(f ?? d), className: V("ff-data-list-tab", { active: (f ?? d) == l }), children: c }), items: n }), O("div", { className: "ff-data-list-actions", children: [g(P.Link, { icon: "icon-reload", widget: () => r() }), g(P.Link, { icon: "icon-setting" })] })] }); +}, gn = ({ isItemGridLayout: e, theme: t, themeProps: n, onClickCallback: a, onReload: i, listCode: r, total: o = 0, page: s = 0, onPageChange: l, pageSize: p = 30, onPageSizeChange: c, tab: d, onTabChange: f, keyword: m, onKeywordChange: u, condition: b, onConditionChange: k, sider: C, onSiderChange: x, layouts: v, classNames: F = {}, payload: R = {}, ...B }) => { + const [M, I] = E(), T = J((N, K) => { + const D = { tab: d, page: s, pageSize: p, keyword: m, sider: C, condition: b, total: o, payload: R }; + return N && N != "init" ? h.get(D, N, K) : D; + }, [JSON.stringify(b), JSON.stringify(R), d, s, p, m, C, o]), z = U(() => { + let N = { sider: Ca, filter: un, footer: wa, toolbar: ka }; + v === !1 ? N = { sider: null, filter: null, footer: null, toolbar: null } : h.isPlainObject(v) && (N = Object.assign({}, N, v)); + for (const K in N) if (N[K]) { + if (An(N[K])) { + const D = N[K]; + N[K] = (ge) => S.cloneElement(D, ge); + } + } else N[K] = () => g(S.Fragment, {}); + return N; + }, [v]); + return L(() => { + t ? ne.getWidgetComponent(t).then((N) => { + if (!N) throw `${t} not found`; + return N; + }).catch((N) => ({ default: () => `${N}` })).then((N) => I(S.createElement(N.default, { ...B, layouts: z, $setting: n }))) : I(g(e ? ma : fa, { ...B, layouts: z, $setting: n })); + }, [t, n]), g(Z.Provider, { value: { classNames: F, listCode: r, onClickCallback: a, onReload: i, getBase62params: T, onPageChange: l, onPageSizeChange: c, onTabChange: f, onSiderChange: x, onKeywordChange: u, onConditionChange: k, setPage: l, setPageSize: c, setTab: f, setSider: x, setKeyword: u, setCondition: k }, children: M && S.cloneElement(M, B) }); +}; +gn.propTypes = { classNames: w.exact({ sider: w.string, filter: w.string, footer: w.string, toolbar: w.string, container: w.string, content: w.string, item: w.string }), layouts: w.oneOfType([w.exact({ sider: w.oneOfType([w.elementType, w.element]), filter: w.oneOfType([w.elementType, w.element]), footer: w.oneOfType([w.elementType, w.element]), toolbar: w.oneOfType([w.elementType, w.element]) }), w.bool]) }; +var he, ue, Pe, it; +const se = class se { + constructor() { + j(this, ue, null); + j(this, Pe, /* @__PURE__ */ new Map()); + j(this, it, () => { + if (y(this, ue)) return y(this, ue).port.postMessage({ command: "status", data: [] }); + _(this, ue, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), y(this, ue).port.onmessage = (t) => { + var n, a; + (n = t.data) != null && n.uuid ? y(this, Pe).forEach((i, r) => { + var o; + (i == "*" || (o = i == null ? void 0 : i.includes) != null && o.call(i, t.data.uuid)) && r(t.data); + }) : ((a = t.data) == null ? void 0 : a.readyState) == WebSocket.CLOSED && A.get("/api/user-api-token").then(({ token: i, expire_at: r }) => { + y(this, ue).port.postMessage({ command: "initWs", data: [`ws${h.trimStart(A.appUrl, "http")}api/user-resource-status-ws?token=${i}`] }); + }); + }, y(this, ue).port.postMessage({ command: "status", data: [] }); + }); + $(this, "subscribe", (t, n = []) => (n ? Array.isArray(n) && n.length == 0 ? n = "*" : Array.isArray(n) || (n = [n].flat()) : n = "*", y(this, Pe).set(t, n), y(this, Pe).size == 1 && y(this, it).call(this), () => this.unsubscribe(t))); + $(this, "unsubscribe", (t) => y(this, Pe).delete(t)); + if (y(se, he)) return y(se, he); + } +}; +he = new WeakMap(), ue = new WeakMap(), Pe = new WeakMap(), it = new WeakMap(), j(se, he, null), $(se, "getInstance", () => (y(se, he) || _(se, he, new se()), y(se, he))); +let Ct = se; +const pn = Ct.getInstance(), Ft = S.forwardRef(({ listCode: e, base62params: t, className: n, theme: a, themeProps: i, layouts: r, classNames: o }, s) => { + const [{ resource: l, primaryKey: p, batchOperations: c = [], itemOperations: d = [], columns: f = [], themeConfig: m, theme: u, isConditionFormLayout: b = !1, isTreeSider: k, treeSiderConfig: C, isItemGridLayout: x, itemGridLayout: v, title: F, isPaginate: R, tabs: B }, M] = E({ isItemGridLayout: !1, itemGridLayout: {} }), I = pa(e, t), [{ dataSource: T, itemOperationsAccess: z, condition: N, tab: K, keyword: D, page: ge, total: He, pageSize: Je, sider: lt, onConditionChange: X, onTabChange: Sn, onKeywordChange: xn, onPageChange: vn, onPageSizeChange: Pn, onSiderChange: Tn, onReload: ct, payload: $n }, Vt] = ga(I, e, p, l), Nn = bt(d, z, T, p), Rn = bt(c); + L(() => { + let ee = null; + return e && A.get(`/api/_/${e}`).resp(({ data: Ge, res: On }) => { + Ge != null && Ge.isDynamicRefresh && (ee = pn.subscribe(() => ct(), On)), M(Ge); + }).catch(() => M({})), () => ee == null ? void 0 : ee(); + }, [e]), S.useImperativeHandle(s, () => ({ onReload: ct, onClickCallback: Vt })); + const Fn = { listCode: e, title: F, classNames: o, layouts: r, resource: l, primaryKey: p, theme: a || u, themeProps: i || m, isTreeSider: k, treeSiderConfig: C, isPaginate: R, tabs: B, isItemOperations: Nn, itemOperations: d == null ? void 0 : d.map((ee) => h.isEmpty(ee == null ? void 0 : ee.confirm) ? ee : { ...ee, confirm: Object.assign({}, ee.confirm, { getPopupContainer: () => document.body }) }), isBatchOperations: Rn, batchOperations: c, isItemGridLayout: x, columns: f, itemGridLayout: v, isConditionFormLayout: b, itemOperationsAccess: z, dataSource: T, onConditionChange: X, onTabChange: Sn, onKeywordChange: xn, onPageChange: vn, onPageSizeChange: Pn, onSiderChange: Tn, condition: N, tab: K, keyword: D, page: ge, total: He, pageSize: Je, sider: lt, payload: $n }; + return g(gn, { ...Fn, className: V("ff-data-list-helper", n), onReload: ct, onClickCallback: Vt }); +}), mn = (e, t, n = !0) => n !== !0 && n-- <= 0 ? [] : h.isArray(e) && !h.isEmpty(e) ? e.reduce((a, i) => (Reflect.has(i, t) && Reflect.has(i, "children") && a.push(i[t]), Reflect.has(i, "children") && !h.isEmpty(i.children) ? a.concat(mn(i.children, t, n)) : a), []) : [], Sa = ({ className: e, primaryKey: t, columns: n = [], dataSource: a = [], operationRender: i, operationWidth: r = 180, components: o = {}, ...s }) => { + const { classNames: l } = ae(Z), p = W(null), c = W(null), [d, f] = E([]), [m, u] = E({ width: 0, height: 0 }); + L(() => { + f(mn(a, t)); + }, [a, t]), Ln(() => { + const C = new ResizeObserver(() => { + var x; + u({ width: ((x = p.current) == null ? void 0 : x.nativeElement.querySelector(".ant-table-body").scrollWidth) || c.current.offsetWidth, height: c.current.offsetHeight }); + }); + return c.current && C.observe(c.current), () => { + c.current && C.unobserve(c.current); + }; + }, []); + const b = da(n), k = ua(o); + return g("div", { ref: c, className: V("ff-data-list-table", l.content, e), children: m.height ? g(Un, { bordered: !0, ...s, components: k, ref: p, rowKey: (C) => (C == null ? void 0 : C[t]) ?? Math.random(), columns: b == null ? void 0 : b.concat(i ? [{ title: "操作", align: "center", fixed: "right", width: `${Math.ceil(r / m.width * 100).toFixed(2)}%`, render: (C, x, v) => i(x, v) }] : []), dataSource: a, size: "middle", scroll: { x: "max-content", y: m.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: f, expandedRowKeys: d } }) : null }); +}, xa = "RC_FORM_INTERNAL_HOOKS", va = (e) => { + const [t, n] = S.useState({ items: [] }); + return L(() => { + e && A.get(`/api/_/${e}`).then(({ uuid: a, code: i, name: r, resource: o, primaryKey: s, marginX: l, marginY: p, cols: c, rowHeight: d, fields: f, theme: m, themeSetting: u }) => ({ uuid: a, code: i, name: r, resource: o, primaryKey: s, marginX: l, marginY: p, cols: c, rowHeight: d, theme: m, themeProps: u, items: f })).then(n); + }, [e]), t; +}, Pa = (e, { initialValue: t, initialValueLanguage: n, convertJs: a, convertJsSetting: i, type: r = "string" }, o = null) => { + const s = W(!1), l = ae(Qt), [p, c] = E(), [d, f] = E(n != "javascript" && e ? l.getFieldValue(e) : void 0), { registerWatch: m } = l.getInternalHooks(xa) || {}; + return L(() => m == null ? void 0 : m((u, b, k) => { + if (!s.current) return; + const C = h.get(b, e); + h.isEqual(C, d) || f(ce(C, r)); + }), [d]), L(() => { + n == "javascript" && t ? Se.exec(t, {}, { getFieldValueForBasicForm: (u) => o ? o.getFieldValue(u) : l.getFieldValue(u), getFieldValue: (u) => l.getFieldValue(u) }).then((u) => f(ce(u, r))).catch((u) => notification.error({ message: `布局数据错误: ${JSON.stringify(u)}` })).finally(() => s.current = !0) : (t && f(ce(t ?? l.getFieldValue(e), r)), s.current = !0); + }, [t, n]), We(() => { + s.current && a && new et([a, i]).toValue(d, l.getFieldsValue(!0)).then(c).catch((u) => { + c(u), console.error("布局数据转换错误: ", u, a); + }); + }, [d, a, i]), [p ?? d, d]; +}, Fi = (e, t, n = null) => U(() => Rt(e, t, n), [e]), Ot = (e, t, n = {}, a = {}, i = {}) => { + const r = ae(Qt), o = st(), s = W(!0), l = W([]), [p, c] = E(t), [d, f] = E(), m = Q.useWatch((u) => JSON.stringify(h.pick(u, l.current)), r) || "{}"; + return _e(() => { + e && Se.exec(e, n, { ...a, getFieldValueForBasicForm: (u) => i ? i.getFieldValue(u) : null, getFieldValue: h.wrap(r.getFieldValue, (u, b) => (l.current.some((k) => h.isEqual(k, b)) || (l.current.push(b), o()), u == null ? void 0 : u(b))), isFieldTouched: r.isFieldTouched, isFieldsTouched: r.isFieldsTouched }).then((u) => { + s.current && (c(u), f(null)); + }).catch((u) => { + s.current && (c(t), f(u)); + }); + }, [e, m, r, n, a]), L(() => () => s.current = !1, []), e ? [p, d] : [t, null]; +}, Ta = ({ widget: e, widgetPrefix: t = "@pkg/ff/grid-layouts", basicForm: n, ...a }) => { + const i = e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, [r, o] = E(); + return L(() => { + i && ne.getWidgetComponent(i).then(({ defaultProps: s = {}, default: l }) => ({ default: $a(l, s, n) })).catch((s) => ({ default: () => `${s}` })).then((s) => o(S.createElement(s.default, a))); + }, [i]), r; +}, $a = (e, t = {}, n = null) => (a) => { + const { code: i, label: r, extras: o, isVirtual: s, initialValue: l, initialValueLanguage: p, convertJs: c, convertJsSetting: d, value: f, ...m } = h.merge({}, t, a), [u, b] = Pa(s ? null : i, { initialValue: l, initialValueLanguage: p, convertJs: c, convertJsSetting: d, type: (m == null ? void 0 : m.type) || "string" }, n), k = U(() => { + const v = Object.keys((t == null ? void 0 : t.extras) || {}); + return h.over([h.partialRight(h.pick, v), h.partialRight(h.omit, v)]); + }, [t == null ? void 0 : t.extras]), [C, x] = k(m); + return g(e, { ...x, value: u, rawValue: b, $setting: Object.assign({}, o, C) }); +}, hn = ({ theme: e, basicForm: t, items: n = [{ key: "default", label: "默认" }], fields: a = [], itemRender: i, activeKeyFunc: r = "", chunks: o = [], widgetSetting: s = {}, children: l }) => { + const [p, c] = E(); + L(() => { + e ? ne.getWidgetComponent(e).then((u) => { + if (!(u != null && u.default)) throw "not found"; + return u; + }).catch((u) => ({ default: () => `${e} ${u}` })).then((u) => c(S.createElement(u.default, {}))) : c(null); + }, [e]); + const d = U(() => n == null ? void 0 : n.map((u) => ({ ...u, children: i(a == null ? void 0 : a.filter((b) => !(b != null && b.group) && u.key == "default" || b.group == u.key), u.key == "default" ? l : null) })).concat(o), [n, l, o]), [f, m] = Ot(r, d == null ? void 0 : d.map((u) => u.key), {}, {}, t); + return m && console.log(e, "activeKeyFunc", m), p && S.cloneElement(p, { activeKey: ce(f, "array"), items: d, $setting: s }); +}, fn = ({ name: e, form: t = null, basicForm: n = null, style: a = {}, className: i, cols: r = 12, rowHeight: o = 21, containerPadding: s = [0, 0], itemMargin: l = [4, 0], formProps: p = {}, formFields: c = [], fields: d = [], data: f, theme: m, themeProps: u = {}, children: b, ...k }) => { + const [C] = Q.useForm(t), x = U(() => [{ name: "__PROPS__", value: p }].concat(c), [p, c]); + We(() => (C.setFieldsValue(f), () => C.resetFields()), [f]); + const v = (F, R) => { + const B = Rt(F, Ta, n); + return O("div", { className: V("ff-grid-layout", i), style: { ...a, "--grid-layout-item-margin-y": `${(l == null ? void 0 : l[0]) || 0}px`, "--grid-layout-item-margin-x": `${(l == null ? void 0 : l[1]) || 0}px`, "--grid-layout-container-padding-y": `${(s == null ? void 0 : s[0]) || 0}px`, "--grid-layout-container-padding-x": `${(s == null ? void 0 : s[1]) || 0}px`, "--grid-layout-cols": r, "--grid-layout-row-height": `${o}px` }, children: [B, R && S.cloneElement(R, { cols: r, rowHeight: o, itemMargin: l, containerPadding: s, fields: F, basicForm: n })] }); + }; + return g(Q, { ...k, fields: x, form: C, component: !1, children: m ? g(hn, { ...u, theme: m, itemRender: v, fields: d, children: b }) : v(d, b) }); +}, Oi = /* @__PURE__ */ ((e) => function({ code: t, data: n, ...a }) { + const { uuid: i, resource: r, items: o, hides: s, rowHeight: l, marginX: p, marginY: c, cols: d, theme: f, themeProps: m } = va(t), u = U(() => [{ name: "__RESOURCE__", value: r }, { name: "__LAYOUT_KEY__", value: t }, { name: "__LAYOUT_UUID__", value: i }], [t, i, r]); + return r && g(e, { name: t, theme: f, themeProps: m, ...a, fields: o, formFields: u, rowHeight: l, cols: d, itemMargin: [p, c], data: r ? { [r]: n } : n }); +})(fn), Na = ({ column: e = 0, colWidth: t = 0, cols: n, rowHeight: a, itemMargin: i, fields: r, primaryKey: o, dataSource: s, itemClassName: l, beforeRender: p = null, afterRender: c = null, itemRender: d = (b, k, C) => b, empty: f = g(Wn, { description: null }), className: m, style: u = {} }) => { + const { classNames: b } = ae(Z), k = U(() => g(fn, { cols: n, rowHeight: a, itemMargin: i, fields: r, className: l }), [r, n, a, i]), C = h.isEmpty(s); + return O("div", { className: V("ff-data-list-content", b.content, m), style: Object.assign({}, u, e && { "--col-num": e }, t && { "--col-width": t }), children: [p == null ? void 0 : p(s), C ? f : s.map((x, v) => { + const F = d(S.cloneElement(k, { data: x }), x, v); + return S.cloneElement(F, { key: `${(x == null ? void 0 : x[o]) ?? v}-${sa(x)}` }); + }), c == null ? void 0 : c(s)] }); +}, Ra = ({ component: e, $props: t }) => { + const { base62params: n } = Ue(t, {}); + return g(H, { children: g(Ft, { listCode: e, base62params: A.decode(n) }) }); +}, Ei = () => g(yn, {}), yn = () => "Empty", Fa = ({ component: e, $setting: t, $props: n }) => { + const [a, i] = E(); + L(() => { + if (!e) return i(g(yn, { description: null })); + ne.getWidgetComponent(e).catch((o) => ({ default: () => `${o}` })).then((o) => S.createElement(o.default, { $setting: t })).then(i); + }, [e]); + const r = Ue(n, {}); + return a ? S.cloneElement(a, r) : null; +}, ji = () => "NotFoundPage"; +var fe, te, ye, we, Be, De; +const oe = class oe { + constructor() { + j(this, te, /* @__PURE__ */ new Map()); + j(this, ye, {}); + j(this, we, null); + $(this, "init", (t, n) => { + _(this, te, t), _(this, ye, n); + }); + $(this, "get", (t) => (y(this, te).has(t) || (t = Array.from(y(this, te).keys()).find((n) => y(this, te).get(n).uri === t)), y(this, te).get(t) || {})); + $(this, "redirect", (t, n, a = {}) => { + const { uri: i, type: r, widgetProps: o } = this.get(t) || {}, { router: s, query: l, ...p } = n || {}, c = Object.assign({}, p, s), d = Object.assign({}, p, l); + r == "list" && (c.base62params = A.encode(c != null && c.base62params ? c.base62params : c)); + let f = Gn(i || t, c); + const m = new URLSearchParams(); + for (const u in o || {}) (o == null ? void 0 : o.type) == "query" && Object.has(d, u) && m.append(u, JSON.stringify(d[u])); + return m.size > 0 && (f = `${f}?${m.toString()}`), a != null && a.isOpenWindow ? window.open(f) : y(this, we).navigate(f, { replace: !!(a != null && a.isReplaceRouteHistory) }); + }); + $(this, "getMenus", (t) => { + var n; + return ((n = y(this, ye)) == null ? void 0 : n[t]) || []; + }); + $(this, "findMenuPathByUuid", (t) => { + let n = []; + for (const a in y(this, ye)) if (n = y(this, Be).call(this, y(this, ye)[a], t, [a]), n.length > 1) return n; + return n; + }); + $(this, "getMenusByRouteUuid", (t) => y(this, De).call(this, t, Object.values(y(this, ye)).flat())); + j(this, Be, (t, n, a = []) => { + if (h.isEmpty(t)) return a; + for (const { uuid: i, children: r } of t) { + if (i == n) return a.concat(i); + if (!h.isEmpty(r)) return a.concat(i, y(this, Be).call(this, r, n)); + } + return a; + }); + j(this, De, (t, n) => { + var i; + let a = []; + for (const r of n) r.widgetType == "redirect" && (r.uuid == t || r.widget == t ? a.push(r) : (i = r.children) != null && i.length && (a = a.concat(y(this, De).call(this, t, r.children)))); + return a; + }); + $(this, "getCurrentMenu", () => { + const { uuid: t } = this.getCurrentRoute() || {}; + if (!t) return; + const n = this.getMenusByRouteUuid(t); + return h.isEmpty(n) ? void 0 : n[0]; + }); + $(this, "getCurrentRoute", (t = 0) => { + var a; + const n = (a = y(this, we).state.matches[y(this, we).state.matches.length - 1 - t]) == null ? void 0 : a.route; + if (!n) return null; + for (let [i, r] of y(this, te)) if (r.uri === n.path) return r; + return null; + }); + $(this, "getPageParams", (t) => { + var i, r, o; + let n = "", a = {}; + if (en()) a = Yn(), n = (i = Xn()) == null ? void 0 : i.search; + else { + const { location: s = {}, matches: l = [] } = ((r = y(this, we)) == null ? void 0 : r.state) || {}; + a = ((o = l[l.length - 1]) == null ? void 0 : o.params) || {}, n = s.search; + } + return n && new URLSearchParams(n).forEach((s, l) => { + a[l] = s; + }), t ? h.get(a, t) : a; + }); + $(this, "createBrowserRouter", (t = {}) => { + if (y(this, te).size == 0) return null; + const n = Ae.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/ff/frameworks/DefaultTheme"), a = Ae.get(ne.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), i = { [n]: 0 }, r = (s, l) => () => Promise.all([ne.getWidgetComponent(s), Ue(l)]).then(([p, c]) => [p.default || function() { + return `${s}`; + }, c]).then(([p, c]) => ({ Component: () => S.createElement(nn, {}, S.createElement(p, { $setting: c })) })), o = Array.from(y(this, te).values()).reduce((s, { uuid: l, uri: p, name: c, type: d, component: f, widgetSetting: m, widgetProps: u, isLogin: b, isLayout: k, extra: C }) => { + let x = {}, v = 0; + switch (d) { + case "list": + x.element = S.createElement(Ra, { component: f, $props: u }); + break; + case "fsdpf-component": + x.element = S.createElement(Fa, { key: f, component: f, $setting: m, $props: u }); + } + const F = (C == null ? void 0 : C.theme) ?? (C == null ? void 0 : C.layout); + if (F) { + const R = (C == null ? void 0 : C.themeProps) ?? (C == null ? void 0 : C.layoutProps); + if (!i[F]) return i[F] = s.length, [...s, { path: "/", lazy: r(F, R), children: [{ path: p, ...x }] }]; + v = i[F]; + } + return k && v > -1 ? (s[v].children.push({ path: p, ...x }), s) : [...s, { path: p, ...x }]; + }, [{ path: "/", lazy: r(n, {}), children: [] }]); + return o.push({ index: !0, element: S.createElement(Oa, { to: a, replace: !0 }) }), _(this, we, Qn(o, t)); + }); + if (y(oe, fe)) return y(oe, fe); + } +}; +fe = new WeakMap(), te = new WeakMap(), ye = new WeakMap(), we = new WeakMap(), Be = new WeakMap(), De = new WeakMap(), j(oe, fe, null), $(oe, "getInstance", () => (y(oe, fe) || _(oe, fe, new oe()), y(oe, fe))); +let kt = oe; +const Oa = ({ to: e, replace: t }) => en() ? S.createElement(Zn, { to: e, replace: t }) : (window.document.location = e, "redirect"), ke = kt.getInstance(), Te = new Worker(new URL("/ff-worker/index.js", self.location)), _t = { getConfigure: (e) => Ae.get(e), route: { redirect: (...e) => ke.redirect(...e), getPageParams: (...e) => ke.getPageParams(...e), getCurrentRoute: () => ke.getCurrentRoute() }, popup: { notification: (...e) => Y.notification(...e), success: (...e) => Y.success(...e), error: (...e) => Y.error(...e), form: (...e) => Y.form(...e), modal: (...e) => Y.modal(...e), confirm: (...e) => Y.confirm(...e) } }; +var rt, Fe, be; +const q = class q { + constructor() { + $(this, "exec", (t, n = {}, a = {}, i = "") => new Promise((r, o) => { + if (!/^(?!\s*(\/\/|\/\*|\*)).*?\S+/m.test(t)) return r(); + const s = zt(q, rt)._++; + y(q, Fe).set(s, a), q.mQueue.set(s, [r, o]), Te.postMessage({ id: s, session: i, category: "eval", method: t, args: n }); + })); + $(this, "clear", (t) => Te.postMessage({ session: t, category: "clear" })); + if (y(q, be)) return y(q, be); + Promise.resolve().then(() => ai).then((t) => { + _t.http = t.http; + }), Te.addEventListener("message", ({ data: { id: t, task_id: n, method: a, args: i, category: r, data: o, error: s, session: l } }) => { + if (r === "eval" && q.mQueue.has(t)) s !== null ? q.mQueue.get(t)[1](s) : q.mQueue.get(t)[0](o), y(q, Fe).delete(t), q.mQueue.delete(t); + else if (r === "util") try { + const p = h.get(_t, a.split("/")) || h.get(y(q, Fe).get(n), a.split("/")); + if (!h.isFunction(p)) throw `${a} not found`; + Promise.resolve(Reflect.apply(p, void 0, i)).then((c) => { + Te.postMessage({ id: t, task_id: n, category: r, method: a, args: i, session: l, data: c, error: null }); + }).catch((c) => { + Te.postMessage({ id: t, task_id: n, category: r, method: a, args: i, session: l, data: null, error: c }); + }); + } catch (p) { + Te.postMessage({ id: t, task_id: n, category: r, method: a, args: i, session: l, data: null, error: p }); + } + }, !1); + } +}; +rt = new WeakMap(), Fe = new WeakMap(), be = new WeakMap(), $(q, "mQueue", /* @__PURE__ */ new Map()), j(q, rt, 0), j(q, Fe, /* @__PURE__ */ new Map()), j(q, be, null), $(q, "getInstance", () => (y(q, be) || _(q, be, new q()), y(q, be))); +let St = q; +const Se = St.getInstance(), st = () => { + const e = W(!0), [, t] = S.useReducer((n) => n + 1, 0); + return L(() => () => e.current = !1, []), () => e.current && t(); +}, Ai = (e) => { + const t = W(); + return L(() => { + t.current = e; + }, [e]), t.current; +}, Li = (e) => { + const [t, n] = E(e), a = W(null), i = J((r, o) => { + a.current = o, n(r); + }, []); + return L(() => { + a.current && (a.current(t), a.current = null); + }, [t]), [t, i]; +}, We = (e = (a) => { +}, t, n = h.isEqual) => { + const a = S.useRef(); + n(t, a.current) || (a.current = h.cloneDeep(t)), S.useEffect(e, [a.current]); +}, _e = We, wn = (e, t = "string") => { + var n; + if (!Array.isArray(e)) return e; + for (let a = 0; a < e.length; a++) e[a].value = ce((n = e[a]) == null ? void 0 : n.value, t), e[a] && Reflect.has(e[a], "children") && (e[a].children = wn(e[a].children, t)); + return e; +}, Vi = (e, t = "json", n = "string", a, i = null) => { + const [r] = Q.useForm(a), [o, s] = E([{ label: "无", value: "", disabled: !0 }]), l = W([]), p = Q.useWatch((c) => l.current.length === 0 ? null : h.pick(c, l.current), r) || null; + return L(() => { + Array.isArray(e) ? s(e) : t === "javascript" && e ? Se.exec(e, {}, { getFieldValue: (c) => (l.current.includes(c) || l.current.push(c), r.getFieldValue(c)), getFieldValueForBasicForm: (c) => (l.current.includes(c) || l.current.push(c), i ? i.getFieldValue(c) : r.getFieldValue(c)) }).then((c) => { + s(ce(c, "array")); + }).catch((c) => console.error("useOptions", c)) : e && s(ce(e, "array")); + }, [e, t, p]), wn(o, n); +}, Ii = (e) => { + const [t, n] = E(), a = { type: "GET" }; + if (typeof e == "string" ? a.url = e : h.isPlainObject(e) && Object.assign(a, e), !(a != null && a.url)) throw "url is required"; + const i = (r) => A.request(a, !1).resp((o) => (console.log("useSubscribeRequest", r), n(o), o)); + return We(() => { + let r = null; + return i().then((o) => { + r = pn.subscribe(h.throttle(i, 180, { leading: !1, trailing: !0 }), o.res); + }), () => r == null ? void 0 : r(); + }, a), t; +}, Ea = (e) => { + const [t, n] = S.useState({ items: [], hides: [] }); + return S.useEffect(() => { + e && A.get(`/api/_/${e}`).then(({ pk: a, uuid: i, code: r, resource: o, align: s, cols: l, rowHeight: p, marginX: c, marginY: d, listenChangeFields: f, listenChangeFieldsFunc: m, fields: u, theme: b, themeSetting: k }) => ({ pk: a, uuid: i, code: r, resource: o, align: s, cols: l, rowHeight: p, marginX: c, marginY: d, theme: b, themeProps: k, listenChangeFields: f, listenChangeFieldsFunc: m, ...u.reduce((C, x) => { + var v; + return (v = x == null ? void 0 : x.field) != null && v.hidden ? C.hides.push(x == null ? void 0 : x.field) : C.items.push(x), C; + }, { items: [], hides: [] }) })).then(n); + }, [e]), t; +}, ja = ({ max: e = 0, min: t = 0, type: n = "", message: a, pattern: i, required: r = !1, validator: o } = {}, s, l) => { + const [p, c] = E([]); + return L(() => { + const d = []; + if (r) { + let f = l; + switch (l) { + case "number": + case "string": + case "array": + break; + case "bool": + f = "boolean"; + break; + case "json": + f = "object"; + } + d.push({ type: f, required: !0, whitespace: !0, message: "该项必填" }); + } + switch (n) { + case "string": + d.push({ type: n, max: e, min: t, message: a || (t && e ? `字符必须在 ${t} ~ ${e} 之间` : `${e ? "最多能有" : "最少要有"} ${t || e} 个字符`) }); + break; + case "pattern": + d.push({ type: "string", pattern: i, message: a }); + break; + case "validator": + o && d.push(({ getFieldValue: f }) => ({ validator: async (m, u) => { + const b = await Se.exec(o, { value: u, fieldName: s }, { getFieldValue: f }); + return h.isString(b) && b ? Promise.reject(b) : h.isBoolean(b) && !b ? Promise.reject(a) : Promise.resolve(); + } })); + } + c(d); + }, [e, t, n, a, i, r, o]), p; +}, Aa = (e, t, n) => { + const [a, i] = E(null); + return L(() => { + const { initDataUri: r = `/api/${e}`, initDataMethod: o = "GET" } = n || {}; + t && A.request({ method: o, url: h.trimEnd(`${r}/${t}`, "/") }).then((s) => { + i(s); + }); + }, [e, t, n]), a; +}, La = (e, t, n) => J((a, i = { serialize: (r) => r, onSuccess: () => { +}, onFail: (r) => (r == null ? void 0 : r.errorFields) && Y.error("请先完善表单信息", { duration: 2e3 }) }) => { + const r = a.getFieldValue("__RESOURCE__"), { submitDataUri: o = `/api/${e}`, submitDataMethod: s = "POST" } = n || {}; + return a.validateFields().then((l) => r ? h.pick(l, [r]) : l).then(i.serialize).then((l) => A.request({ method: s, url: h.trimEnd(`${o}/${t || ""}`, "/"), data: l }).msg(i.onSuccess)).catch(i.onFail); +}, [e, t, n]), Va = (e, t, n, a) => { + const i = Aa(t, n, a); + L(() => { + i ? e.setFieldsValue(i) : e.resetFields(); + }, [e, i]); + const r = La(t, n, a); + return h.partial(r, e); +}, Ia = (e, t, n = [], a = {}) => { + const i = W({}), r = W(), o = h.debounce(st(), 180), s = ["disabled", "required"], l = (f, m) => { + s.includes(f) && (i.current[f] = m), o(); + }, p = U(() => ({ setDisabled: (f) => l("disabled", f), setRequired: (f) => l("required", f), getDisabled: () => i.current.disabled, getRequired: () => i.current.required }), [t]), [c, d] = Ot(t, -1, {}, p, a); + if (!d && r.current != c && (c >= 0 || !h.isEmpty(n == null ? void 0 : n[c]))) { + r.current = c; + const { widget: f, widgetPrefix: m, props: u } = n == null ? void 0 : n[c]; + e = rn(f, m), i.current = h.merge(u, h.pick(i.current, s)); + } + return [e, i.current]; +}, Kt = (e) => e === void 0 || e === !1 ? "" : (Array.isArray(e) ? e : [e]).join("_"), Mi = ({ value: e, onChange: t }, n = null) => { + const a = W(), [i] = Q.useForm(n), r = W({}); + return _e(() => { + h.isEqual(a.current, e) || i.setFieldsValue(e); + }, [e]), L(() => () => i.resetFields(), []), [U(() => i.__INTERNAL__ ? i : { ...i, __INTERNAL__: { itemRef: (o) => (s) => { + const l = Kt(o); + s ? r.current[l] = s : delete r.current[l]; + } }, scrollToField: (o, s = {}) => { + console.warn("useMergedFormValuesChange scrollToField not work, unreferenced antd form"); + }, focusField: (o) => { + console.warn("useMergedFormValuesChange focusField not work, unreferenced antd form"); + }, getFieldInstance: (o) => { + const s = Kt(o); + return r.current[s]; + } }, [i]), (o, s) => { + a.current = s, t == null || t(s); + }]; +}, Et = ({ widget: e = "Input", widgetPrefix: t = "@pkg/ff/grid-layout-forms", widgetDecorator: n, subWidgets: a = [], basicForm: i, ...r }) => { + const o = rn(e, t), [s, l] = Ia(o, n, a, i), [p, c] = E(); + return L(() => { + s && ne.getWidgetComponent(s).then(({ defaultProps: d = {}, default: f }) => ({ default: Ma(f, d, i) })).catch((d) => ({ default: () => `${d}` })).then((d) => c(S.createElement(d.default, r))); + }, [s]), p && S.cloneElement(p, { ...r, ...l }); +}, Ma = (e, t = {}, n = null) => (a) => { + const { type: i, code: r, label: o, noStyle: s, placeholder: l, required: p = !1, extras: c, validators: d, help: f, isVirtual: m, $isReserved: u, initialValue: b, initialValueLanguage: k, ...C } = h.omit(h.merge({}, t, a), ["convertJs", "convertJsSetting", "widget", "widgetPerfix", "widgetDecorator", "subWidgets", "boxStyle"]), x = ja(Object.assign({}, d, p ? { required: !0 } : {}), r, i), v = U(() => { + const I = Object.keys((t == null ? void 0 : t.extras) || {}); + return h.over([h.partialRight(h.pick, I), h.partialRight(h.omit, I)]); + }, [t == null ? void 0 : t.extras]), [F, R] = v(C), B = { label: o, noStyle: s, colon: !1, layout: "vertical" }, M = J((I) => I == null ? void 0 : ce(I, i), [i]); + return g($t, { name: r, rules: x, initialValue: M(b), normalize: M, children: (I, T, z) => { + var N; + return g(e, { type: i, rcform: z, basicForm: n, itemProps: { validateStatus: T.errors.length > 0 ? "error" : "success", tooltip: f || null, help: T.errors.length > 0 ? T.errors.join("、") : null, required: ((N = x == null ? void 0 : x[0]) == null ? void 0 : N.required) || !1, ...B }, fieldProps: { placeholder: l, ...R, ...I }, $setting: Object.assign({}, c, F) }); + } }); +}, jt = ({ name: e, form: t = null, basicForm: n = null, style: a = {}, className: i, cols: r = 24, rowHeight: o = 16, itemMargin: s = [8, 16], containerPadding: l = [0, 0], fields: p = [], hides: c = [], primaryKey: d = 0, formProps: f = {}, formFields: m = [], listenChangeFields: u, listenChangeFieldsFunc: b, onValuesChange: k, theme: C, themeProps: x = {}, children: v, ...F }) => { + const [R] = Q.useForm(t), B = J((T, z) => { + k(T, z), b && Array.isArray(u) && Se.exec(b, { changedValues: T, allValues: z }, { getFieldValue: R.getFieldValue, setFieldValue: R.setFieldValue, setFieldsValue: R.setFieldsValue, isFieldTouched: R.isFieldTouched, isFieldsTouched: R.isFieldsTouched }).catch((N) => console.error("onFormValuesChange", e, N)); + }, [e, R, k, u, b]), M = U(() => [{ name: "__PROPS__", value: f }, { name: "__PRIMARY_KEY__", value: d }].concat(m), [d, f, m]), I = (T, z) => { + const N = Rt(T, Et, n); + return O("div", { className: V("ff-grid-layout-form", i), style: { ...a, "--grid-layout-item-margin-x": `${(s == null ? void 0 : s[0]) ?? 8}px`, "--grid-layout-item-margin-y": `${(s == null ? void 0 : s[1]) ?? 16}px`, "--grid-layout-container-padding-y": `${(l == null ? void 0 : l[0]) || 0}px`, "--grid-layout-container-padding-x": `${(l == null ? void 0 : l[1]) || 0}px`, "--grid-layout-cols": r, "--grid-layout-row-height": `${o}px` }, children: [N, z && S.cloneElement(z, { cols: r, rowHeight: o, itemMargin: s, containerPadding: l, fields: T, basicForm: n })] }); + }; + return O(Q, { ...F, form: R, fields: M, onValuesChange: B, children: [C ? g(hn, { ...x, theme: C, itemRender: I, fields: p, children: v }) : I(p, v), c == null ? void 0 : c.map((T) => { + var z; + return g($t, { name: T.code, children: g(za, { form: R, basicForm: n, name: T.code, type: T.type, initialValue: T.initialValue, initialValueLanguage: (z = T.extras) == null ? void 0 : z.initialValueLanguage }) }, JSON.stringify(T.code)); + })] }); +}, za = ({ type: e, initialValue: t, initialValueLanguage: n, onChange: a, basicForm: i }) => { + const [r, o] = Ot(n == "javascript" && t, n == "javascript" ? void 0 : t, {}, {}, i); + return L(() => { + n == "javascript" ? a(ce(r, e)) : t && a(ce(t, e)); + }, [e, t, r]), null; +}; +jt.propTypes = { fields: w.array, hides: w.array }; +const Ba = /* @__PURE__ */ ((e) => ({ code: t, isPreview: n = !1, ...a }) => { + const { align: i, autoComplete: r, resource: o, items: s, hides: l, rowHeight: p, marginX: c, marginY: d, cols: f, listenChangeFields: m, listenChangeFieldsFunc: u, pk: b, uuid: k, theme: C, themeProps: x } = Ea(t), v = U(() => [{ name: "__PK__", value: b }, { name: "__RESOURCE__", value: o }, { name: "__LAYOUT_KEY__", value: t }, { name: "__LAYOUT_UUID__", value: k }], [b, t, k, o]); + return g(e, { name: t, autoComplete: r, theme: C, themeProps: x, ...a, formFields: v, listenChangeFields: m, listenChangeFieldsFunc: u, fields: s, hides: l, cols: f, rowHeight: p, itemMargin: [c, d] }); +})(jt), bn = ({ $setting: e, $close: t, extras: n, code: a, primaryKey: i, ...r }) => { + const [o] = Q.useForm(), s = Va(o, a, i, e); + return g(H, { actions: O(S.Fragment, { children: [g(P, { name: (e == null ? void 0 : e.okText) || "保存", type: "primary", widget: () => s({ onSuccess: t }) }), g(P, { name: (e == null ? void 0 : e.cancelText) || "取消", widget: () => t(!1) })] }), extras: n, children: g(Ba, { form: o, code: a, primaryKey: i, ...r }) }); +}, Ht = /* @__PURE__ */ new Set(), xt = (e = [], t = 0) => { + const n = e[t]; + if (n.length && !Ht.has(n)) { + const a = document.createElement("script"); + a.setAttribute("src", n), a.setAttribute("data-namespace", n), e.length > t + 1 && (a.onload = () => { + xt(e, t + 1); + }, a.onerror = () => { + xt(e, t + 1); + }), Ht.add(n), document.body.appendChild(a); + } +}, vt = ({ className: e, type: t, style: n = {}, ...a }) => g("span", { role: "img", className: V("ff-iconfont", e), style: n, ...a, children: g("svg", { style: { width: "1em", height: "1em", fill: "currentColor", overflow: "hidden" }, viewBox: "0 0 1024 1024", children: g("use", { xlinkHref: `#${t}` }) }) }); +vt.propTypes = { className: w.string, type: w.string.isRequired, style: w.object }, vt.init = xt; +const Da = (e, t, n, a) => ke.redirect(n, t, a), qa = (e, t = {}, n, a = {}) => { + var r; + const i = (r = a.router) == null ? void 0 : r.reduce((o, [s, l, p]) => { + const c = h.get(t, ["router", s]); + if (!c && c !== 0 && l) throw `请传入 ${p}`; + return `${o}/${c}`; + }, `/api/${n}`); + return A.del(i, t.param).msg(); +}, Jt = (e, t, n, { status: { loading: a, disabled: i }, setStatus: r }) => { + const o = { loading: (s) => s === void 0 ? a : r((l) => ({ ...l, loading: s })), disabled: (s) => s === void 0 ? i : r((l) => ({ ...l, disabled: s })) }; + return h.isFunction(n) ? n.call(null, { ...t, ...o }) : h.isString(n) && n ? Se.exec(n, t, o) : null; +}, Gt = (e, t, n, a, i) => h.isString(n) && n ? ne.getWidgetComponent(n).then(({ default: r }) => Y.modal(r, { ...t, $setting: a }, i != null && i.title ? { ...i, title: h.template(i.title)(e) } : i)).catch((r) => { + Y.error(n, { content: r.toString() }); +}) : Y.modal(n, { ...t, $setting: a }, i != null && i.title ? { ...i, title: h.template(i.title)(e) } : i), Ua = (e, t, n, a, i) => Y.modal(bn, { ...t, $setting: a, code: n }, i != null && i.title ? { ...i, title: h.template(i.title)(e) } : i), Wa = (e, t, n, a, i) => Y.modal(Ft, { base62params: t, $setting: a, listCode: n }, i != null && i.title ? { ...i, title: h.template(i.title)(e) } : i), _a = ({ widget: e, widgetType: t, widgetData: n, widgetProps: a, widgetSetting: i, widgetContainerProps: r }, { onAfterClick: o, onBeforeClick: s }) => { + const l = ae(Z), [p, c] = E({ leading: !0, trailing: !1 }), d = U(() => { + switch (t) { + case "redirect": + return h.partialRight(Da, e, i); + case "func": + return h.partialRight(Jt, (i == null ? void 0 : i.code) ?? e, { status: p, setStatus: c }); + case "component": + case "fsdpf-component": + return h.partialRight(Gt, e, i, r); + case "grid-layout-form": + return h.partialRight(Ua, e, i, r); + case "data-list": + return h.partialRight(Wa, e, i, r); + case "destroy": + return h.partialRight(qa, e, i, r); + default: + if (Lt(e) || S.isValidElement(e)) return h.partialRight(Gt, e, i, r); + if (h.isFunction(e)) return h.partialRight(Jt, (i == null ? void 0 : i.code) || e, { status: p, setStatus: c }); + } + return (...f) => console.error("useButton unknown widgetType", t, ...f); + }, [e, t]); + return [h.debounce((f) => (s == null || s(f), Promise.resolve(Ue(a, f, { list: l })).then((m) => d(f, { ...n, ...m })).then((m) => o == null ? void 0 : o(m)).catch(console.error)), 300, { leading: !0, trailing: !1 }), p]; +}, Cn = ({ type: e, name: t, className: n, icon: a, iconPosition: i, size: r }, o = "default") => U(() => { + const s = { type: "primary", className: V("ff-button", n), iconPosition: i, size: r }; + return e === "danger" ? s.danger = !0 : e === "default" && (s.type = e), o === "link" || o === "dashed" ? (s.type = o, e === "default" && (s.className = V(s.className, "ff-default"))) : o !== "circle" && o !== "round" || (s.shape = o), a && (s.icon = g(vt, { type: a })), t && (s.children = t), s; +}, [o, e, n, a, i]), ot = ({ data: e, widget: t, widgetType: n = "fsdpf-component", widgetData: a, widgetProps: i, widgetSetting: r, widgetContainerProps: o, onAfterClick: s, onBeforeClick: l, children: p, extras: c }) => { + const d = ae(Z), [f, m] = E(!1), [u, b] = E("hover"), [k, C] = E({}), [x, v] = E(), { placement: F, align: R, zIndex: B, arrow: M = { pointAtCenter: !0 }, getPopupContainer: I, isPopupMountBodyContainer: T = !1, ...z } = o || {}; + L(() => { + n == "grid-layout-form" ? v(S.createElement(bn, { ...a, $setting: r, code: t })) : n == "data-list" ? v(S.createElement(Ft, { base62params: e, $setting: r, listCode: t })) : h.isString(t) ? ne.getWidgetComponent(t).then(({ default: D }) => { + v(S.createElement(D, { ...a, $setting: r })); + }).catch((D) => v(D.toString())) : Lt(t) ? v(S.createElement(t, { ...a, $setting: r })) : S.isValidElement(t) && v(S.cloneElement(t, { ...a, $setting: r })); + }, [t, n, a]), L(() => { + Promise.resolve(Ue(i, e, { list: d })).then(C); + }, [i, e, d.getBase62params]); + const N = (D, ge = !1) => (m(D), !D && b("hover"), D ? l == null ? void 0 : l(k) : s == null ? void 0 : s(ge)), K = (D) => { + m(!0), b("click"); + }; + return g(_n, { zIndex: B, placement: F, onPopupClick: K, onClick: K, open: f, align: R, arrow: M, trigger: u, getPopupContainer: I || T ? void 0 : (D) => D, styles: { body: { padding: 0 } }, content: g(Ka, { ...z, extras: c, children: x && S.cloneElement(x, { ...k, $close: (D) => N(!1, D) }) }), children: p, onOpenChange: N }); +}, Ka = ({ title: e, className: t, children: n, extras: a, width: i, height: r, ...o }) => { + const [s, l] = E({}), p = J((m, u) => l((b) => ({ ...b, [m]: u })), []), c = J((m) => l((u) => ({ ...u, [m]: void 0 })), []), d = e ? S.createElement("div", { className: "ff-popup-title" }, e) : s == null ? void 0 : s.title, f = a ?? S.createElement("div", { className: "ff-popup-reserved-extras" }, a); + return g(qe.Provider, { value: { ele: s, mount: p, unmount: c }, children: O("div", { className: V("ff-popup ff-popover", t, s.rootClassName), style: { width: i, height: r }, ...o, children: [O("div", { className: "ff-popup-header", children: [d, s == null ? void 0 : s["sub-title"]] }), n, O("div", { className: "ff-popup-footer", children: [f, s == null ? void 0 : s.extras, s == null ? void 0 : s.actions] })] }) }); +}; +ot.propTypes = { widgetType: w.oneOf(["fsdpf-component", "grid-layout-form", "data-list"]) }; +const Ke = (e) => function({ className: t, variant: n, children: a, name: i, icon: r, type: o = "default", iconPosition: s = "start", noAuthType: l, onAfterClick: p, onBeforeClick: c, data: d, loading: f, disabled: m, tooltip: u, confirm: b, widget: k = () => { +}, widgetType: C, widgetData: x, widgetProps: v, widgetSetting: F, widgetContainerProps: R, ...B }) { + const { mode: M, ...I } = R || {}, T = Cn({ className: t, name: i, type: o, icon: r, iconPosition: s }, n ?? e), z = g(Ze, { ...T, ...B, children: a || i }); + if (M === "popover" && !["destroy", "redirect", "func"].includes(C)) return g(ot, { data: d, widget: k, widgetType: C, widgetData: x, widgetProps: v, widgetSetting: F, widgetContainerProps: I, onAfterClick: p, onBeforeClick: c, children: z }); + const N = h.isEmpty(u) || !u.enabled ? {} : u, K = h.isEmpty(b) ? { enabled: !1 } : Object.assign({ enabled: !0 }, b), [D, ge] = E(!1), [He, { disabled: Je, loading: lt }] = _a({ widget: k, widgetType: C, widgetData: x, widgetProps: v, widgetSetting: F, widgetContainerProps: I }, { onAfterClick: p, onBeforeClick: c }); + return g(Kn, { okText: "确定", cancelText: "取消", getPopupContainer: (X) => X, ...K, disabled: Je || m, open: D, onOpenChange: (X) => { + if (!X) return ge(X); + K.enabled ? ge(X) : He(d); + }, onConfirm: (X) => { + He(d, X); + }, onClick: (X) => { + X.stopPropagation(); + }, children: g(Hn, { getPopupContainer: (X) => X, ...N, title: D ? null : N == null ? void 0 : N.title, trigger: ["hover", "click"], children: S.cloneElement(z, { loading: lt || f, disabled: Je || m }) }) }); +}, P = Ke("default"); +P.propTypes = { type: w.oneOf(["primary", "default", "danger", ""]), size: w.oneOf(["large", "middle", "small"]), name: w.string, icon: w.string, iconPosition: w.oneOf(["start", "end"]), data: w.any, widget: w.any, widgetType: w.oneOf(["destroy", "redirect", "func", "component", "fsdpf-component", "grid-layout-form", "grid-layout", "data-list"]), widgetData: w.object, widgetProps: w.object, widgetSetting: w.object, widgetContainerProps: w.object, tooltip: w.exact({ title: w.string.isRequired, placement: w.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: w.oneOfType([w.bool, w.number]), getPopupContainer: w.func }), confirm: w.exact({ title: w.string.isRequired, cancelText: w.string, okText: w.string, okType: w.oneOf(["primary", "default", "danger", ""]), placement: w.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: w.oneOfType([w.bool, w.number]), getPopupContainer: w.func, arrow: w.oneOfType([w.bool, w.exact({ pointAtCenter: w.bool })]) }) }; +const Ha = Ke("link"), Ja = Ke("circle"), Ga = Ke("round"), Ya = Ke("dashed"), Yt = ({ options: e = [], triggerWeights: t = ["grid-layout-form", "grid-layout", "fsdpf-component", "print"], onAfterClick: n = (m, u, b) => { +}, onBeforeClick: a = (m, u, b) => { +}, labelVariant: i = "link", labelSize: r, labelRender: o, btnVariant: s, btnSize: l, btnRender: p = (m, u) => g(P, { ...m, data: u }, m.uuid || mt()), widgetContainerProps: c = {}, children: d, data: f }) => { + if (h.isEmpty(e)) return d; + const [m, u] = U(() => (e || []).reduce((k, C) => { + const x = t.indexOf(C.widgetType); + return x === -1 ? k[1].push(C) : k[0] ? x < t.indexOf(k[0].widgetType) ? (k[1].push(k[0]), k[0] = C) : k[1].push(C) : k[0] = C, k; + }, [null, []]), [e, t]); + o ? d = o(m, f) || d : d || (d = g(Ze, { ...Cn(Object.assign(m != null && m.name || m != null && m.icon ? {} : { icon: "icon-location" }, m, { size: r }), i) })); + const b = u.map((k) => p(Object.assign({ uuid: k.uuid, type: k.type, name: k.name, widget: k.widget, widgetType: k.widgetType, widgetProps: k.widgetProps, widgetData: k.widgetData, widgetSetting: k.widgetSetting, widgetContainerProps: k.widgetContainerSetting, confirm: k.confirm, onAfterClick: h.partialRight(n, k, f), onBeforeClick: h.partialRight(a, k, f) }, { size: l, variant: s }), f)); + return g(ot, { widget: m == null ? void 0 : m.widget, widgetType: m == null ? void 0 : m.widgetType, widgetProps: m == null ? void 0 : m.widgetProps, widgetSetting: m == null ? void 0 : m.widgetSetting, widgetContainerProps: Object.assign({}, c, m == null ? void 0 : m.widgetContainerProps), data: f, widgetData: m == null ? void 0 : m.widgetData, extras: b, onAfterClick: h.partialRight(n, m, f), onBeforeClick: h.partialRight(a, m, f), children: d }); +}; +Yt.propTypes = { triggerWeights: w.array, options: w.arrayOf(w.shape({ ...P.propTypes, widgetType: P.propTypes.widgetType.isRequired })), btnSize: P.propTypes.size, btnRender: w.func, btnVariant: w.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelVariant: w.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelRender: w.func, labelSize: P.propTypes.size, onAfterClick: w.func, onBeforeClick: w.func, widgetContainerProps: P.propTypes.widgetContainerProps, data: P.propTypes.data }, P.Link = Ha, P.Link.defaultProps = P.defaultProps, P.Link.propTypes = P.propTypes, P.Circle = Ja, P.Circle.defaultProps = P.defaultProps, P.Circle.propTypes = P.propTypes, P.Round = Ga, P.Round.defaultProps = P.defaultProps, P.Round.propTypes = P.propTypes, P.Dashed = Ya, P.Dashed.defaultProps = P.defaultProps, P.Dashed.propTypes = P.propTypes, P.Popover = ot, P.GroupPopover = Yt; +const Xa = ({ fields: e, formProps: t, $close: n }) => { + const [a] = Q.useForm(), i = U(() => [{ name: "__PROPS__", value: t }], [t]); + return g(H, { actions: O(S.Fragment, { children: [g(P, { name: "取消", widget: () => n(!1) }), g(P, { name: "确定", type: "primary", widget: () => a.validateFields(!0).then(n) })] }), children: g(Q, { fields: i, form: a, className: "ff-modal-form", children: e == null ? void 0 : e.map(({ code: r, ...o }) => g(Et, { code: r, ...o }, r)) }) }); +}, Qa = ({ className: e, $close: t, children: n, title: a, subTitle: i, actions: r, extras: o, ...s }) => O(ea, { ...s, prefixCls: "ff-drawer", className: V("ff-popup", e), maskMotion: { motionAppear: !0, motionName: "mask-motion" }, motion: (l) => ({ motionAppear: !0, motionName: `panel-motion-${l}` }), children: [O("div", { className: "ff-popup-header", children: [g("button", { "aria-label": "Close", className: "ff-popup-close", onClick: s.onClose, children: g(Nt, { type: "close" }) }), a, i] }), g("div", { className: "ff-popup-body", children: n }), O("div", { className: "ff-popup-footer", children: [o, r] })] }), Za = ({ className: e, $close: t, $event: n, children: a, title: i, subTitle: r, actions: o, extras: s, placement: l, ...p }) => { + const c = (n == null ? void 0 : n.pageX) === void 0 ? { animation: null, maskAnimation: null, mousePosition: { x: null, y: null } } : { animation: "zoom", maskAnimation: "fade", mousePosition: { x: n == null ? void 0 : n.pageX, y: n == null ? void 0 : n.pageY } }; + return g(ta, { ...p, ...c, prefixCls: "ff-modal", modalRender: () => O("div", { className: V("ff-modal-content ff-popup", e), children: [O("div", { className: "ff-popup-header", children: [g("button", { "aria-label": "Close", className: "ff-popup-close", onClick: p.onClose, children: g(Nt, { type: "close" }) }), i, r] }), g("div", { className: "ff-popup-body", children: a }), O("div", { className: "ff-popup-footer", children: [s, o] })] }) }); +}, kn = ({ placement: e, $close: t, $event: n, children: a, title: i, ...r }) => { + const [o, s] = E({}), [l, p] = E(!0), c = J((u, b) => s((k) => ({ ...k, [u]: b })), []), d = J((u) => s((b) => ({ ...b, [u]: void 0 })), []); + let f = { ...r, className: o.rootClassName, title: o.title || i && S.createElement("div", { className: V("ff-popup-title") }, i), subTitle: o["sub-title"], actions: o.actions, extras: o.extras, children: a, $close: t, $event: n, onClose: () => p(!1) }; + const m = () => { + t(!1); + }; + return g(qe.Provider, { value: { ele: o, mount: c, unmount: d }, children: e && e !== "center" ? g(Qa, { ...f, placement: e, open: l, afterOpenChange: (u) => !u && m() }) : g(Za, { ...f, visible: l, afterClose: m }) }); +}; +kn.propTypes = { placement: w.oneOf(["center", "left", "top", "right", "bottom"]) }; +const G = () => { + const [e, t] = Vn({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (r) => { + const { offsetHeight: o } = r; + return { height: o }; + }, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, n] = S.useReducer((r) => r + 1, 0); + L(() => { + G.$onClick = a, G.$queue.forEach(([r, o, s], l, p) => { + i([o, s], ...r), delete p[l]; + }); + }, []); + const a = (r, o = {}, s = {}) => new Promise((l, p) => i([l, p], r, o, s)), i = ([r, o], s, l = {}, p = {}) => { + const c = G.$index++, d = (f) => ((m, u) => (G.$popups.delete(m), n(), u == null ? void 0 : u()))(c, () => r(f)); + if (s === an) return e.open({ ...p, key: c, content: S.createElement(s, { ...l, $close: () => e.close(c) }) }); + G.$popups.set(c, S.createElement(kn, { maskClosable: !1, $event: l == null ? void 0 : l.$event, ...p, key: c, $close: d }, S.isValidElement(s) ? S.cloneElement(s, { ...l, $close: d }) : s != null && s.name || Bt.isForwardRef(s) || (s == null ? void 0 : s.$$typeof) === Bt.ForwardRef ? S.createElement(s, { ...l, $close: d }) : s)), n(); + }; + return O(S.Fragment, { children: [Array.from(G.$popups).map(([r, o]) => o), t] }); +}; +G.$popups = /* @__PURE__ */ new Map(), G.$index = 0, G.$queue = [], G.$onClick = (...e) => new Promise((t, n) => { + G.$queue.push([e, t, n]); +}); +const Xt = (e, t, n = {}) => G.$onClick(e, t, n), gt = (e, { showProgress: t, duration: n, ...a } = { duration: 1.5 }) => G.$onClick(an, { content: e, ...a }, { showProgress: t, duration: n }), Y = { modal: Xt, confirm: (e, t = {}) => G.$onClick(na, { content: e, ...t }, { placement: "center" }), form: (e, t = {}, n = {}) => Xt(Xa, { formProps: n, fields: e }, { placement: "center", ...t }).then((a) => { + if (a === !1) throw !1; + return a; +}), notification: gt, success: (e, t = { duration: 1.5 }) => gt(e, { ...t, className: "ff-notification-success", icon: "check" }), error: (e, t = { duration: 1.5 }) => gt(e, { ...t, className: "ff-notification-error", icon: "close" }) }; +Ee.configure({ showSpinner: !1 }), je.interceptors.request.use((e) => { + e.headers.Platform = "web", e.headers.SaaS = window.localStorage.getItem("SaaS"); + const t = window.localStorage.getItem(Qe); + return e.headers.Authorization = t ? `Bearer ${t} ` : void 0, Ee.inc(), e; +}, (e) => (Ee.done(), Promise.reject({ code: -1, msg: e }))), je.interceptors.response.use(({ data: e, headers: t }) => (Ee.done(), { ...e, res: t == null ? void 0 : t.res }), function(e) { + return Ee.done(), Promise.reject(e.message); +}), window.addEventListener("unhandledrejection", ht.onUnhandledRejection), ht.onMsg = (e, t) => Y[[0, 1].includes(e) ? "success" : "error"](t).then(() => e === 20300 && ke.redirect(Ae.get("Common.WEBSITE_LOGIN_PAGE"))); +const Pt = { appUrl: "", init: (e, t, n) => { + Pt.appUrl = n, je.defaults.baseURL = n, je.defaults.timeout = 15e3, Object.assign(Pt, new ht(e, t, je)); +} }, A = Pt; +class At extends Error { + constructor(t, n) { + super(n), Error.captureStackTrace && Error.captureStackTrace(this, At), !n instanceof Le && (this.name = `${t} Error Runtime`); + } +} +class Le extends Error { + constructor(t, ...n) { + super(...n), Error.captureStackTrace && Error.captureStackTrace(this, Le), this.name = `${t} Not Found`; + } +} +const pt = "mine", Qe = "token"; +var Ce, Oe; +const le = class le { + constructor() { + j(this, Oe, /* @__PURE__ */ new Map()); + $(this, "setVendor", (t, n) => y(this, Oe).set(t, new tn(n, async (a, i) => { + var o, s; + if (!(a != null && a.default)) throw "@pkg not found"; + let r = () => i; + switch ("function") { + case typeof (r = (o = a.default) == null ? void 0 : o[`./${i}/index.jsx`]): + case typeof (r = (s = a.default) == null ? void 0 : s[`./${i}/index.js`]): + return r(); + } + throw new Le(i); + }))); + $(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 [, n] = t == null ? void 0 : t.split("@pkg/"); + if (!n) throw new Le(t); + try { + return y(this, Oe).has("pkg") ? await y(this, Oe).get("pkg").get(n) : await import(`${A.appUrl}/api/pkg-import/web?name=${t}`); + } catch (a) { + throw new At(t, a); + } + }); + $(this, "getRoutes", () => A.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: n, ...a }) => [n, { uuid: n, ...a }])).then((t) => new Map(t))); + $(this, "getMenus", () => A.get("/api/my-menu")); + $(this, "getConfigure", () => A.get("api/init-configure")); + $(this, "getWidgetOperationAuth", () => A.get("/api/init-widget-operation-auth").then((t) => t.reduce((n, { uuid: a, auth: i }) => [...n, [a, i]], []))); + $(this, "getPhoneNumber", (t) => A.get(`/api/user-wx-phone-number/${t}`)); + $(this, "getUserToken", () => { + const t = window.localStorage.getItem(Qe); + if (!t) return ""; + const n = t.split("."); + if (!Array.isArray(n) || n.length !== 3) throw "登录令牌无效!"; + const { iat: a } = JSON.parse(window.atob(n[1])); + if (Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - a > 2592e3) throw "登录令牌已过期, 请重新登录!"; + return t; + }); + $(this, "checkUserToken", () => { + try { + return !!this.getUserToken(); + } catch { + return !1; + } + }); + $(this, "getUserInfo", (t = !0) => { + var n; + try { + const a = this.getUserToken(); + if (!a) return Promise.resolve(null); + const { iat: i } = JSON.parse(window.atob((n = a == null ? void 0 : a.split(".")) == null ? void 0 : n[1])), { iat: r, ...o } = A.decode(window.localStorage.getItem(pt) || "", {}); + return r === i ? Promise.resolve(o) : A.get("/api/mine-info").then(({ User: s = null }) => (window.localStorage.setItem(pt, A.encode({ ...s, iat: i })), s)); + } catch (a) { + console.error(a), t && Y.error("请登录").then(this.logout); + } + return Promise.resolve(null); + }); + $(this, "login", (t, n, a = {}) => A.post("/api/user-token", { username: t, passwd: In.hash(n), platform: "web", ...a }).then(({ token: i }) => (window.localStorage.setItem(Qe, i), i))); + $(this, "logout", (t) => (window.localStorage.removeItem(pt), window.localStorage.removeItem(Qe), t == null ? void 0 : t())); + if (y(le, Ce)) return y(le, Ce); + } +}; +Ce = new WeakMap(), Oe = new WeakMap(), j(le, Ce, null), $(le, "getInstance", () => (y(le, Ce) || _(le, Ce, new le()), y(le, Ce))); +let Tt = le; +const ne = Tt.getInstance(), ei = S.createContext({ user: {}, initUser: () => { +}, initUserComplete: !1 }), ti = S.createContext({ set: () => { +}, get: () => { +}, assign: () => { +}, currentRoute: () => { +} }), Lt = (e) => !!(e != null && e.name) && (e.prototype instanceof S.Component || /^[A-Z]/.test(e.name)), ni = (e, t) => { + if (!e || typeof window > "u") return; + let n = document.querySelector(`style[ff-style-token="${t}"]`); + return n ? (n.innerHTML = e, e) : (n = document.createElement("style"), n.setAttribute("ff-style-token", t), n.setAttribute("type", "text/css"), n.innerHTML = e, document.head.appendChild(n), e); +}, ai = Object.freeze(Object.defineProperty({ __proto__: null, AppContext: ei, AppGlobalParamsContext: ti, cache: tn, configure: Ae, default: ne, func: Se, http: A, insertStyle: ni, isReactComponent: Lt, route: ke }, Symbol.toStringTag, { value: "Module" })); +export { + Li as $, + ka as A, + Ca as B, + wa as C, + et as D, + Ft as E, + Z as F, + Oi as G, + xa as H, + Sa as I, + Na as J, + ma as K, + fa as L, + da as M, + ua as N, + $i as O, + Ni as P, + cn as Q, + pn as R, + bt as S, + ga as T, + pa as U, + Ra as V, + Fa as W, + Ei as X, + ji as Y, + st as Z, + Ai as _, + rn as a, + We as a0, + _e as a1, + Vi as a2, + Ii as a3, + Ba as a4, + jt as a5, + Et as a6, + bn as a7, + Ea as a8, + ja as a9, + ti as aA, + Aa as aa, + La as ab, + Va as ac, + Ia as ad, + Mi as ae, + vt as af, + P as ag, + aa as ah, + _a as ai, + H as aj, + qe as ak, + nn as al, + G as am, + Y as an, + Ci as ao, + ki as ap, + Si as aq, + ne as ar, + Lt as as, + ni as at, + A as au, + tn as av, + Ae as aw, + Se as ax, + ke as ay, + ei as az, + ra as b, + Ue as c, + sn as d, + vi as e, + Pi as f, + ia as g, + Ti as h, + sa as i, + dn as j, + Ri as k, + Rt as l, + oa as m, + mn as n, + fn as o, + Ta as p, + hn as q, + ut as r, + va as s, + ce as t, + xi as u, + Pa as v, + Fi as w, + Ot as x, + gn as y, + un as z +}; diff --git a/dist/common/main-FyOEZueW.js b/dist/common/main-FyOEZueW.js deleted file mode 100644 index dda15c5..0000000 --- a/dist/common/main-FyOEZueW.js +++ /dev/null @@ -1,1135 +0,0 @@ -var jn = Object.defineProperty; -var It = (e) => { - throw TypeError(e); -}; -var An = (e, t, n) => t in e ? jn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; -var N = (e, t, n) => An(e, typeof t != "symbol" ? t + "" : t, n), Mt = (e, t, n) => t.has(e) || It("Cannot " + n); -var y = (e, t, n) => (Mt(e, t, "read from private field"), n ? n.call(e) : t.get(e)), E = (e, t, n) => t.has(e) ? It("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), _ = (e, t, n, r) => (Mt(e, t, "write to private field"), r ? r.call(e, n) : t.set(e, n), n); -var zt = (e, t, n, r) => ({ - set _(i) { - _(e, t, i, n); - }, - get _() { - return y(e, t, r); - } -}); -import { jsx as d, jsxs as $ } from "react/jsx-runtime"; -import x, { useEffect as A, useState as R, useCallback as X, useRef as U, useContext as re, useMemo as H, useId as ft, isValidElement as Ln, useLayoutEffect as Vn } from "react"; -import w from "prop-types"; -import V from "classnames"; -import * as Bt from "react-is"; -import { useNotification as In } from "rc-notification"; -import u from "lodash"; -import Q, { Field as $t, FieldContext as en } from "rc-field-form"; -import { M as ut, N as Le, a as Ve, P as ht, S as Mn } from "./vender-CtjyT19B.js"; -import tn from "immutability-helper"; -import { Space as zn, Form as Qe, Input as Bn, Button as et, Pagination as Dn, Tree as qn, Breadcrumb as Wn, Table as Un, Empty as _n, Popover as Hn, Popconfirm as Kn, Tooltip as Jn } from "antd"; -import { useMergedState as Gn } from "rc-util"; -import { generatePath as Yn, useInRouterContext as nn, useParams as Xn, useLocation as Qn, createBrowserRouter as Zn, Navigate as er } from "react-router-dom"; -import "rc-util/lib/hooks/useMergedState"; -import tr from "rc-drawer"; -import nr from "rc-dialog"; -var Oe, ze, Re, de, ve, Pe; -class rn { - constructor(t, n) { - E(this, Oe, /* @__PURE__ */ new Map()); - E(this, ze, !0); - E(this, Re, []); - E(this, de); - E(this, ve, () => y(this, de)); - E(this, Pe, () => Promise.resolve()); - N(this, "get", (...t) => new Promise((n, r) => { - const i = JSON.stringify(t); - if (y(this, Oe).has(i)) return n(y(this, Pe).call(this, y(this, de), ...t)); - if (y(this, de) === void 0) y(this, Re).push([t, n, r]), y(this, ze) && (_(this, ze, !1), Promise.resolve(typeof y(this, ve) == "function" ? y(this, ve).call(this) : y(this, ve)).then((a) => _(this, de, a || null)).finally(() => { - y(this, Re).forEach(([a, o, s]) => { - try { - const l = y(this, Pe).call(this, y(this, de), ...a); - y(this, Oe).set(JSON.stringify(a), l), o(l); - } catch (l) { - s(l); - } - }), y(this, Re).length = 0; - })); - else { - const a = y(this, Pe).call(this, y(this, de), ...t); - y(this, Oe).set(i, a), n(a); - } - })); - _(this, Pe, n), _(this, ve, t); - } -} -Oe = new WeakMap(), ze = new WeakMap(), Re = new WeakMap(), de = new WeakMap(), ve = new WeakMap(), Pe = new WeakMap(); -const Ci = () => d("div", { children: "Empty" }), _e = x.createContext({ ele: {}, mount: () => { -}, unmount: () => { -} }), J = ({ rootClassName: e, className: t, children: n, actions: r, title: i, subTitle: a, extras: o, style: s = {} }) => { - const { mount: l, unmount: g } = x.useContext(_e); - return J.Action({ children: r }), J.Title({ children: i }), J.SubTitle({ children: a }), J.Extra({ children: o }), A(() => (l("rootClassName", e), () => g(e)), [e]), d("div", { className: V("ff-container", t), style: s, children: n }); -}, Xe = (e) => ({ children: t, className: n }) => { - const { mount: r, unmount: i } = x.useContext(_e); - return A(() => (t && r(e, x.createElement("div", { key: `ff-${e}`, className: V(`ff-popup-${e}`, n) }, t)), () => i(e)), [n, t]), null; -}; -J.Action = Xe("actions"), J.Title = Xe("title"), J.SubTitle = Xe("sub-title"), J.Extra = Xe("extras"), J.propTypes = { className: w.string, style: w.object, title: w.any, subTitle: w.any, actions: w.any, extras: w.any }; -const ki = () => d(J, { className: "ff-loading", children: $("div", { className: "loader", children: [$("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] }), $("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] }), $("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] }), $("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] })] }) }), xi = () => d("div", { children: "NotFound" }), an = ({ children: e }) => { - const [t, n] = R({}), r = X((a, o) => n((s) => ({ ...s, [a]: o })), []), i = X((a) => n((o) => ({ ...o, [a]: void 0 })), []); - return typeof (e == null ? void 0 : e.type) == "string" ? e : d(_e.Provider, { value: { ele: t, mount: r, unmount: i }, children: x.cloneElement(e, { className: t.rootClassName, title: t.title, subTitle: t["sub-title"], actions: t.actions, extras: t.extras }) }); -}; -an.propTypes = { children: w.element.isRequired }; -const Dt = { 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"] }, Ft = ({ type: e, props: t }) => d("i", { ...t, children: d("svg", { viewBox: "0 0 1024 1024", width: "1em", height: "1em", fill: "currentColor", children: (Dt[e] || Dt.info).map((n, r) => d("path", { d: n }, r)) }) }), sn = ({ className: e, content: t, icon: n, $close: r }) => $(x.Fragment, { children: [n && d("div", { className: V("ff-notification-icon", e), children: d(Ft, { type: n }) }), t] }), rr = ({}) => d(J, { children: "Confirm" }); -var pe, Ee; -const ie = class ie { - constructor() { - E(this, Ee, /* @__PURE__ */ new Map()); - N(this, "init", (t) => _(this, Ee, new Map(t))); - N(this, "check", (t) => !y(this, Ee).has(t) || y(this, Ee).get(t)); - if (y(ie, pe)) return y(ie, pe); - } -}; -pe = new WeakMap(), Ee = new WeakMap(), E(ie, pe, null), N(ie, "getInstance", () => (y(ie, pe) || _(ie, pe, new ie()), y(ie, pe))); -let yt = ie; -const ir = yt.getInstance(), ar = (e, t, n = "children") => { - if (u.isEmpty(e)) return {}; - const r = u.find(e, ["value", t]); - if (!u.isEmpty(r)) return r; - const i = e.length; - for (let a = 0; a < i; a++) { - const { [n]: o } = e[a], s = ar(o, t, n); - if (!u.isEmpty(s)) return s; - } - return {}; -}, on = (e = "Input", t = "@pkg/ff/grid-layout-forms") => e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`; -var me, Be; -const ae = class ae { - constructor() { - E(this, Be, null); - N(this, "init", (t) => _(this, Be, t)); - N(this, "get", (t, n) => u.get(y(this, Be), t, n)); - if (y(ae, me)) return y(ae, me); - } -}; -me = new WeakMap(), Be = new WeakMap(), E(ae, me, null), N(ae, "getInstance", () => (y(ae, me) || _(ae, me, new ae()), y(ae, me))); -let wt = ae; -const Ie = wt.getInstance(), qt = { 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" }, ge = (e, t) => { - let n = "string"; - n = Array.isArray(e) ? "array" : typeof e, u.isObject(e) && (n = "json"); - const r = `${n}2${t}`; - return Reflect.has(qt, r) ? qt[r](e) : e; -}, sr = (e) => e === null ? "null" : Array.isArray(e) ? "array" : typeof e == "object" ? "json" : typeof e == "boolean" ? "bool" : typeof e == "string" ? "string" : typeof e == "number" ? Number.isInteger(e) ? "integer" : "float" : typeof e, He = (e = {}, t = {}, n = {}, r = "") => ln(e, (i, a) => a === "type" && i === "code") ? cn(e, t, n, r) : dn(e, t, r), ln = (e, t = () => !1) => u.some(e, (n) => !!u.some(n, t) || (u.isEmpty(n) || !u.isPlainObject(n) && !u.isArray(n) ? void 0 : ln(n, t))), cn = async (e = {}, t = {}, n = {}, r = "") => { - let i = /* @__PURE__ */ Object.create(null); - for (let a in e) { - let o; - if (Reflect.has(e[a], "type") && ["code", "field", "router", "query", "string"].includes(e[a].type)) { - const { type: s, value: l = "", default: g = r } = e[a]; - switch (s) { - case "code": - try { - o = await xe.exec(l, t, n); - } catch (c) { - console.error("getWidgetPropsData", c); - } - break; - case "field": - o = u.get(t, l) ?? u.get(t, l.substring(l.indexOf(".") + 1)); - break; - case "router": - case "query": - o = ke.getPageParams(l); - break; - case "string": - o = l; - } - o ?? (o = g); - } else o = await cn(e[a], t, n, r); - u.set(i, a, o); - } - return i; -}, dn = (e = {}, t = {}, n = "") => Object.keys(e || {}).reduce((r, i) => { - if (u.isPlainObject(e[i])) { - let a; - if (Reflect.has(e[i], "type") && ["field", "router", "query", "string"].includes(e[i].type)) { - const { type: o, value: s = "", default: l = n } = e[i]; - switch (o) { - case "field": - a = u.get(t, s) ?? u.get(t, s.substring(s.indexOf(".") + 1)); - break; - case "router": - case "query": - a = ke.getPageParams(s); - break; - case "string": - a = s; - } - a ?? (a = l); - } else a = dn(e[i], t, n); - u.set(r, i, a); - } - return r; -}, {}), gt = (e, t) => e && typeof e == "object" ? Array.isArray(e) ? e.map((n) => gt(n, t)) : Object.keys(e).reduce((n, r) => (t[r] ? n[t[r]] = gt(e[r], t) : n[r] = gt(e[r], t), n), {}) : e, Si = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => { - const t = 16 * Math.random() | 0; - return (e === "x" ? t : 3 & t | 8).toString(16); -}), vi = (e) => { - var t, n; - return e ? (n = (t = e.match(/^@pkg(?:[^\/]*\/){3}(?[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : n.name : ""; -}, Pi = (e) => { - var t, n; - return e ? (n = (t = e.match(/^@pkg(?:[^\/]*\/){2}(?[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : n.category : ""; -}, Ni = (e) => { - var t, n; - return e ? (n = (t = e.match(/^@pkg(?:[^\/]*\/){1}(?[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : n.owner : ""; -}, or = (e, t = 32, n = "auto") => { - const r = bt(e), i = n === "auto" ? "x64" : n; - if (t === 32) return ut.x86.hash32(r).toString(); - if (t === 128) return i === "x64" ? ut.x64.hash128(r) : ut.x86.hash128(r); - throw new Error("bits 只能是 32 或 128"); -}, bt = (e) => e == null ? "null" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : typeof e == "function" ? e.toString() : Array.isArray(e) ? "[" + e.map(bt).join(",") + "]" : typeof e == "object" ? "{" + Object.keys(e).sort().map((t) => `${t}:${bt(e[t])}`).join(",") + "}" : String(e), lr = () => { - let e = 1; - const t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new Map(); - return (...r) => r.length === 0 ? "" : r.map((i) => { - return String((a = i) === null || typeof a != "object" && typeof a != "function" ? (n.has(a) || n.set(a, e++), n.get(a)) : (t.has(a) || t.set(a, e++), t.get(a))); - var a; - }).join("::"); -}; -var nt, De, qe, rt; -const it = class it { - constructor(...t) { - E(this, De, []); - E(this, qe, (t) => { - var n; - for (let r of t) Array.isArray(r[0]) ? y(this, qe).call(this, r) : y(this, De).push(y(n = it, nt).call(n, r[0], r[1])); - }); - N(this, "toValue", async (t, n = null) => { - const r = { getValue: () => t, getRecord: () => n }; - let i = t; - for (const a of y(this, De)) try { - const o = await a; - if (typeof o != "function") { - console.warn("middleware is not a function, skip:", o); - continue; - } - i = await o.call(r, i); - } catch (o) { - console.error("middleware error, skip:", o); - } - return i; - }); - N(this, "toRender", (t, n, r = null) => x.createElement(y(this, rt), { value: t, record: n }, r)); - E(this, rt, ({ value: t, record: n, children: r }) => { - const [i, a] = R(r); - return Je(() => { - let o = !1; - return a(r), this.toValue(t, n).then((s) => !o && a(s)).catch((s) => !o && a(`${s}`)), () => o = !0; - }, [t, n]), i; - }); - y(this, qe).call(this, t); - } -}; -nt = new WeakMap(), De = new WeakMap(), qe = new WeakMap(), rt = new WeakMap(), E(it, nt, u.memoize((t, n) => { - if (typeof t == "function") return t(n); - if (typeof t == "string") return ce.getWidgetComponent(t).then((r) => { - var i; - return ((i = r.default) == null ? void 0 : i.call(r, n)) || ((a) => a); - }); - throw new TypeError("middleware must be a string or a function"); -}, lr())); -let tt = it; -const Z = x.createContext({ listCode: "", classNames: {}, getBase62params: (e, t) => { -}, onReload: () => { -}, onClickCallback: () => { -}, onConditionChange: () => { -}, onTabChange: () => { -}, onSiderChange: () => { -}, onKeywordChange: () => { -}, onPageChange: () => { -}, onPageSizeChange: () => { -}, reload: () => { -}, setPage: () => { -}, setPageSize: () => { -}, setTab: () => { -}, setSider: () => { -}, setKeyword: () => { -}, setCondition: () => { -} }), Wt = ({ className: e, record: t, column: n, ...r }) => { - if (n != null && n.editableByJs && (n != null && n.uuid)) { - const { formSetting: i = { primaryKey: "id" }, widgetSetting: a = {}, widgetContainerSetting: o = {} } = (n == null ? void 0 : n.editableByJsSetting) || {}; - return d(P.Popover, { widget: cr, widgetData: { record: t, column: n }, widgetSetting: { widgetSetting: a, formSetting: i }, widgetContainerProps: { title: n != null && n.title ? `${n.title} - 编辑` : "编辑", ...o, width: (o == null ? void 0 : o.width) || 260, arrow: !0 }, children: d("td", { className: V("ff-data-list-cell-editable", e), ...r }) }); - } - return d("td", { className: e, ...r }); -}, cr = ({ record: e, column: t, $close: n, $setting: r }) => { - const i = U(sr(u.get(e, t == null ? void 0 : t.dataIndex))), { listCode: a, onClickCallback: o } = re(Z), [s] = Q.useForm(), { formSetting: l, widgetSetting: g } = r, c = (l == null ? void 0 : l.primaryKey) || "id", p = () => { - s.setFieldsValue({ value: u.get(e, t == null ? void 0 : t.dataIndex), __PROPS__: e }); - }; - return Je(() => p(), [e, t == null ? void 0 : t.dataIndex, a]), d(J, { actions: $(x.Fragment, { children: [d(P, { size: "small", onClick: p, children: "重置" }), $(zn.Compact, { block: !0, children: [d(P, { size: "small", widget: n, children: "取消" }), d(P, { type: "primary", size: "small", widget: () => s.validateFields().then(({ value: h }) => { - const m = u.get(e, c.substring(c.indexOf(".") + 1)); - if (!m) throw "获取更新主键失败!"; - j.put(`/api/${a}-storeBy-${t == null ? void 0 : t.uuid}/${m}`, { value: h }).msg(() => o(2, e)).then(n); - }).catch(console.warn), children: "保存" })] })] }), children: $(Q, { form: s, children: [d(Rt, { label: "", type: i.current, code: "value", widget: t == null ? void 0 : t.editableByJs, extras: g }), d($t, { noStyle: !0, name: ["__PROPS__"], children: () => { - } })] }) }); -}, dr = (e) => function(t) { - return e(t, getRecord()); -}, ur = (e, t = {}) => H(() => e == null ? void 0 : e.map(({ widgetByJs: n, widgetByJsSetting: r, ...i }, a) => { - const o = (l) => ({ record: l, column: i }); - let s = []; - return n && s.push([n, r]), s.length > 0 ? (i != null && i.render && s.push([dr, i.render]), { ...i, onCell: o, render: (l, g) => new tt(s).toRender(l, g, "-") }) : { ...i, onCell: o }; -}), [e, t]), gr = (e = {}) => H(() => { - var t; - return e.body ?? (e.body = { cell: Wt }), (t = e.body).cell ?? (t.cell = Wt), e; -}, [e]), Ti = (e) => { - const [t, n] = R({}); - return A(() => { - let r = !1; - return e && j.get(`/api/_/${e}`).then((i) => u.pick(i, ["uuid", "name", "code", "resource", "marginX", "marginY", "cols", "rowHeight", "primaryKey", "columns", "itemOperations", "batchOperations", "isConditionFormLayout", "layout", "tabs", "pageSize", "layoutConfig"])).then((i) => !r && n(i)), () => r = !0; - }, [e]), t; -}, $i = (e, t = {}) => { - const [n, r] = R({ dataSource: [] }); - return Ke(() => { - let i = !1; - return e && j.get(`/api/${e}/${j.encode({ page: 1, ...t })}`).then((a) => !i && r(a)), () => i = !0; - }, [e, t]), n; -}, un = (e = [], t = /* @__PURE__ */ new Map(), n = "id", r) => { - const i = X(r ? (a) => u.get(a, n, u.get(a, [r, n])) : (a) => u.get(a, n), [n, r]); - return X((a) => e == null ? void 0 : e.filter((o) => !o.uuid || !t.has(o.uuid) || t.get(o.uuid).some((s) => s == i(a))), [e, t, i]); -}, Ct = (e = [], t = /* @__PURE__ */ new Map(), n = [], r = "id", i) => { - const a = X(i ? (o) => u.get(o, r, u.get(o, [i, r])) : (o) => u.get(o, r), [r, i]); - return H(() => { - if (u.isEmpty(e) || !e.some(({ uuid: s }) => ir.check(s))) return !1; - if (u.isEmpty(t) || u.isEmpty(n)) return !0; - const o = n.map((s) => a(s)); - return e.some(({ uuid: s }) => !s || !t.has(s) || t.get(s).some((l) => o.some((g) => g == l))); - }, [e, n, t, a]); -}, pr = (e, t, n = "id", r = null) => { - const i = ot(), a = U(!1), o = U(e.dataSource), s = U(e.itemOperationsAccess); - return A(() => (o.current = e.dataSource, s.current = e.itemOperationsAccess, () => a.current = !1), [e.dataSource, e.itemOperationsAccess]), a.current && (e.dataSource = o.current, e.itemOperationsAccess = s.current), [e, (l = 0, g = null) => { - var c, p; - if (a.current = !1, l === 1) return (c = e.onReload) == null ? void 0 : c.call(e); - if (l === 2) { - const h = u.get(g, "__PARENT_ID__", ""), m = u.get(g, n, u.get(g, [r, n], "")), f = u.findIndex(o.current, ["__PARENT_ID__", h]), C = u.findIndex(f > -1 ? u.get(o.current, [f, "children"]) : o.current, [n, m]); - if (C === -1) return (p = e.onReload) == null ? void 0 : p.call(e); - Promise.all([j.get(`/api/${t}/detail/${m}`), j.post(`/api/${t}/list-operations-access`, { ids: m })]).then(([b, k]) => { - const S = u.get(o.current, f > -1 ? [f, "children", C, "children"] : [C, "children"]); - o.current = tn(o.current, f > -1 ? { [f]: { children: { $splice: [[C, 1, { ...b, children: S }]] } } } : { $splice: [[C, 1, { ...b, children: S }]] }); - const v = new Map(k); - s.current.forEach((F, I) => { - var W; - (W = v.get(I)) != null && W.some((z) => z == m) || s.current.set(I, F.filter((z) => z !== m)); - }), v.forEach((F, I) => { - s.current.has(I) ? s.current.set(I, u.uniq([...s.current.get(I) || [], ...F])) : s.current.set(I, F); - }); - }).then(() => { - a.current = !0, i(); - }); - } - }]; -}, mr = (e, t) => { - const n = ot(), r = U(t), i = U(/* @__PURE__ */ new Map()), a = U([]), o = u.throttle((l) => { - a.current = [], j.list(e, u.pick({ ...r.current, ...l }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: g, condition: c, total: p, tab: h, sider: m, page: f, pageSize: C, operationsAccess: b, dataSource: k }) => { - r.current = { tab: h, condition: c, sider: m, keyword: g, total: p, pageSize: C, page: k != null && k.length ? f : 1 }, a.current = k, i.current = new Map(b), n(); - }); - }, 380, { leading: !1, trailing: !0 }); - Je(() => { - a.current = [], e && o(t); - }, [e, t]); - const s = H(() => u.pick(r.current, ["total", "tab", "page", "pageSize", "condition", "sider", "keyword"]), [r.current]); - return Object.assign(s, { onTabChange: (l) => o({ tab: l, page: 1 }), onPageChange: (l, g) => o({ page: l, pageSize: g }), onPageSizeChange: (l) => o({ pageSize: l, page: 1 }), onConditionChange: (l, g) => o({ keyword: g, condition: tn(r.current.condition || {}, { $merge: l || {} }), page: 1 }), onSiderChange: (l) => o({ sider: l, page: 1 }), onKeywordChange: (l) => o({ keyword: l, page: 1 }), itemOperationsAccess: i.current, dataSource: a.current, onReload: o, payload: t == null ? void 0 : t.payload }); -}, fr = ({ listCode: e, className: t, layouts: n, dataSource: r, isPaginate: i, isItemOperations: a, isBatchOperations: o, batchOperations: s, itemOperations: l, itemOperationsAccess: g, resource: c, primaryKey: p, title: h, itemGridLayout: m, $setting: f, tabs: C, isConditionFormLayout: b, isTreeSider: k, treeSiderConfig: S }) => { - const { classNames: v, onClickCallback: F } = re(Z), I = u.pick(f, ["column", "colWidth", "beforeRender", "afterRender", "style"]), W = un(l, g, p, c), z = X((M, O, B) => d(hr, { className: V("ff-data-list-framework-item", v.item), operations: a ? W(O) : [], data: c ? { [c]: O } : O, children: M, onClickCallback: F }), [c, p, a, F, l, g]); - return $("div", { className: V("ff-data-list-framework", t), children: [d(n.sider, { isTreeSider: k, ...S }), $("div", { className: V("ff-data-list-container", v == null ? void 0 : v.container), children: [d(n.filter, { isConditionFormLayout: b }), d(n.toolbar, { title: h, tabs: C }), d($r, { ...I, ...m, primaryKey: p, itemRender: z, dataSource: r }), d(n.footer, { isPaginate: i, isOperations: o, operations: s })] })] }); -}, hr = ({ className: e, operations: t, children: n, data: r, onClickCallback: i }) => $("div", { className: V("data-list-grid-layout-item-container", e), children: [n, !!(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: r, confirm: a.confirm, onAfterClick: (o) => o !== !1 && (i == null ? void 0 : i(a.isRefresh, r)) }, a.uuid || ft()) }, (a == null ? void 0 : a.uuid) || ft())) })] }), yr = ({ listCode: e, className: t, layouts: n, dataSource: r, columns: i, isItemOperations: a, isBatchOperations: o, batchOperations: s, itemOperations: l, itemOperationsAccess: g, resource: c, primaryKey: p, title: h, tabs: m, isPaginate: f, isTreeSider: C, treeSiderConfig: b, isConditionFormLayout: k, ...S }) => { - const { classNames: v, onClickCallback: F } = re(Z), I = un(l, g, p, c), W = Ct(l, g, r, p, c); - return $("div", { className: V("ff-data-table-framework", t), children: [d(n.sider, { isTreeSider: C, ...b }), $("div", { className: V("ff-data-table-container", v == null ? void 0 : v.container), children: [d(n.filter, { isConditionFormLayout: k }), d(n.toolbar, { title: h, tabs: m }), d(Sr, { ...S, primaryKey: p, className: "ff-data-table-content", columns: i, dataSource: r, operationRender: W ? (z) => { - var M; - return d("div", { className: "ff-data-table-actions", children: (M = I(z)) == null ? void 0 : M.map((O, B) => d(P.Link, { size: "small", uuid: O.uuid, type: O.type, name: O.name, widget: O.widget, widgetType: O.widgetType, widgetProps: O.widgetProps, widgetData: O.widgetData, widgetSetting: O.widgetSetting, widgetContainerProps: O.widgetContainerSetting, data: z, confirm: O.confirm, onAfterClick: (T) => T !== !1 && (F == null ? void 0 : F(O.isRefresh, z)) }, O.uuid || B)) }); - } : null }), d(n.footer, { isPaginate: f, isOperations: o, operations: s })] })] }); -}, gn = (e, t, n, r, i = {}, a = 0) => { - const o = { "--grid-layout-h": `${r}`, "--grid-layout-w": `${n}`, "--grid-layout-x": `${e}`, "--grid-layout-y": `${t}`, "--grid-layout-row-height-offset": "0px" }; - return i != null && i.autoHeight ? o.height = "fit-content" : o["--grid-layout-row"] = `${r}`, i != null && i.alignItems && (o["--grid-layout-box-align-items"] = i.alignItems), i != null && i.justifyContent && (o["--grid-layout-box-justify-content"] = i.justifyContent), o["--grid-layout-box-margin"] = Ut(i == null ? void 0 : i.marginTop, i == null ? void 0 : i.marginRight, i == null ? void 0 : i.marginBottom, i == null ? void 0 : i.marginLeft), o["--grid-layout-box-padding"] = Ut(i == null ? void 0 : i.paddingTop, i == null ? void 0 : i.paddingRight, i == null ? void 0 : i.paddingBottom, i == null ? void 0 : i.paddingLeft), a && (o.height = `${a}px`), o; -}, Ut = (e, t, n, r) => `${e || 0}px ${t || 0}px ${n || 0}px ${r || 0}px`, Fi = (e = "Text", t = "@pkg/ff/grid-layouts") => e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, pn = ({ className: e, isConditionFormLayout: t }) => { - var h, m; - const [n, r] = R({}), { listCode: i, onKeywordChange: a, onConditionChange: o, getBase62params: s, classNames: l } = x.useContext(Z), { keyword: g, condition: c } = (s == null ? void 0 : s()) || {}, [p] = Qe.useForm(); - return A(() => { - i && t && j.get(`/api/_/${i}/list-condition-form-layout`).then(({ resource: f, marginX: C, marginY: b, rowHeight: k, cols: S, fields: v }) => { - r({ resource: f, itemMargin: [C, b], rowHeight: k, cols: S, fields: v }); - }).catch(() => r({})); - }, [i, t]), A(() => { - p.setFieldsValue({ keyword: g, ...c }); - }, [JSON.stringify([g, c])]), d("div", { className: V("ff-data-list-filter", l.filter, e), children: d(Qe, { form: p, layout: "vertical", autoComplete: "off", onFinish: ((h = n.fields) == null ? void 0 : h.length) > 1 ? (f) => o({ [n.resource]: f[n.resource] }, f.keyword) : () => { - }, onValuesChange: (f) => { - u.isEmpty(u.omit(f, ["keyword"])) || p.submit(); - }, children: ((m = n.fields) == null ? void 0 : m.length) > 1 ? d(Et, { ...n, children: d(wr, { onReset: () => { - const { keyword: f, condition: C } = s("init") || {}; - p.setFieldsValue({ keyword: f, ...C }); - } }) }) : d("div", { className: "ff-data-list-filter-default-form ff-grid-layout-form", children: d("div", { className: "grid-layout-item", style: gn(20, 0, 5, 2), children: d(Qe.Item, { name: ["keyword"], children: d(Bn.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (f) => a(f) }) }) }) }) }) }); -}, wr = ({ cols: e, fields: t, onReset: n }) => { - const [r, i] = R(!1), a = H(() => t == null ? void 0 : t.toReversed().some((o) => o.y > 1 || o.x + o.w >= e - 5), [e, t]); - return $(Qe.Item, { label: " ", style: { "--item-span": 5 }, className: V("ff-data-list-filter-actions", { expanded: r }), children: [d(et, { onClick: n, children: "重置" }), d(et, { type: "primary", htmlType: "submit", children: "查询" }), a && d(P.Link, { className: "ff-data-list-filter-expanded-button", widget: () => i((o) => !o), type: "primary", name: r ? "关闭" : "展开", icon: r ? "icon-up" : "icon-down", iconPosition: "end" })] }); -}; -pn.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 br = ({ className: e, operations: t, isOperations: n, isPaginate: r }) => { - const { onPageChange: i, onPageSizeChange: a, onClickCallback: o, getBase62params: s } = x.useContext(Z), { total: l, page: g, pageSize: c } = (s == null ? void 0 : s()) || {}; - return n && !u.isEmpty(t) || r ? $("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(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 && (o == null ? void 0 : o(p.isRefresh, null)) }, p.uuid || h)) }), r && d(Dn, { size: "small", total: l, pageSize: c, showSizeChanger: !1, showTotal: (p) => `第 ${g} 页 / 总共 ${p} 条`, onChange: i, onShowSizeChange: a })] }) : null; -}, Cr = [{ 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" }] }] }], kr = ({ className: e, width: t = 280, isTreeSider: n }) => { - const { classNames: r } = re(Z); - return n ? d(qn.DirectoryTree, { className: V("ff-data-list-sider", r.sider, e), style: { "--sider-width": t }, showLine: !0, showIcon: !1, treeData: Cr }) : null; -}, xr = ({ className: e, title: t, tabs: n }) => { - const { getBase62params: r, onTabChange: i, onReload: a, classNames: o } = re(Z), { tab: s } = (r == null ? void 0 : r()) || {}, [l, g] = Gn((n == null ? void 0 : n[0].value) ?? (n == null ? void 0 : n[0].code), { value: s, onChange: i }); - return $("div", { className: V("ff-data-list-toolbar", o.toolbar, e), children: [d("div", { className: "ff-data-list-title", children: t }), d(Wn, { className: "ff-data-list-tabs", itemRender: ({ label: c, code: p, value: h }) => d("span", { onClick: () => g(h ?? p), className: V("ff-data-list-tab", { active: (h ?? p) == l }), children: c }), items: n }), $("div", { className: "ff-data-list-actions", children: [d(P.Link, { icon: "icon-reload", widget: () => a() }), d(P.Link, { icon: "icon-setting" })] })] }); -}, mn = ({ isItemGridLayout: e, theme: t, themeProps: n, onClickCallback: r, onReload: i, listCode: a, total: o = 0, page: s = 0, onPageChange: l, pageSize: g = 30, onPageSizeChange: c, tab: p, onTabChange: h, keyword: m, onKeywordChange: f, condition: C, onConditionChange: b, sider: k, onSiderChange: S, layouts: v, classNames: F = {}, payload: I = {}, ...W }) => { - const [z, M] = R(), O = X((T, D) => { - const L = { tab: p, page: s, pageSize: g, keyword: m, sider: k, condition: C, total: o, payload: I }; - return T && T != "init" ? u.get(L, T, D) : L; - }, [JSON.stringify(C), JSON.stringify(I), p, s, g, m, k, o]), B = H(() => { - let T = { sider: kr, filter: pn, footer: br, toolbar: xr }; - v === !1 ? T = { sider: null, filter: null, footer: null, toolbar: null } : u.isPlainObject(v) && (T = Object.assign({}, T, v)); - for (const D in T) if (T[D]) { - if (Ln(T[D])) { - const L = T[D]; - T[D] = (ee) => x.cloneElement(L, ee); - } - } else T[D] = () => d(x.Fragment, {}); - return T; - }, [v]); - return A(() => { - t ? ce.getWidgetComponent(t).then((T) => { - if (!T) throw `${t} not found`; - return T; - }).catch((T) => ({ default: () => `${T}` })).then((T) => M(x.createElement(T.default, { ...W, layouts: B, $setting: n }))) : M(d(e ? fr : yr, { ...W, layouts: B, $setting: n })); - }, [t, n]), d(Z.Provider, { value: { classNames: F, listCode: a, onClickCallback: r, onReload: i, getBase62params: O, onPageChange: l, onPageSizeChange: c, onTabChange: h, onSiderChange: S, onKeywordChange: f, onConditionChange: b, setPage: l, setPageSize: c, setTab: h, setSider: S, setKeyword: f, setCondition: b }, children: z && x.cloneElement(z, W) }); -}; -mn.propTypes = { classNames: w.exact({ sider: w.string, filter: w.string, footer: w.string, toolbar: w.string, container: w.string, content: w.string, item: w.string }), layouts: w.oneOfType([w.exact({ sider: w.oneOfType([w.elementType, w.element]), filter: w.oneOfType([w.elementType, w.element]), footer: w.oneOfType([w.elementType, w.element]), toolbar: w.oneOfType([w.elementType, w.element]) }), w.bool]) }; -var fe, ue, Ne, at; -const se = class se { - constructor() { - E(this, ue, null); - E(this, Ne, /* @__PURE__ */ new Map()); - E(this, at, () => { - if (y(this, ue)) return y(this, ue).port.postMessage({ command: "status", data: [] }); - _(this, ue, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), y(this, ue).port.onmessage = (t) => { - var n, r; - (n = t.data) != null && n.uuid ? y(this, Ne).forEach((i, a) => { - var o; - (i == "*" || (o = i == null ? void 0 : i.includes) != null && o.call(i, t.data.uuid)) && a(t.data); - }) : ((r = t.data) == null ? void 0 : r.readyState) == WebSocket.CLOSED && j.get("/api/user-api-token").then(({ token: i, expire_at: a }) => { - y(this, ue).port.postMessage({ command: "initWs", data: [`ws${u.trimStart(j.appUrl, "http")}api/user-resource-status-ws?token=${i}`] }); - }); - }, y(this, ue).port.postMessage({ command: "status", data: [] }); - }); - N(this, "subscribe", (t, n = []) => (n ? Array.isArray(n) && n.length == 0 ? n = "*" : Array.isArray(n) || (n = [n].flat()) : n = "*", y(this, Ne).set(t, n), y(this, Ne).size == 1 && y(this, at).call(this), () => this.unsubscribe(t))); - N(this, "unsubscribe", (t) => y(this, Ne).delete(t)); - if (y(se, fe)) return y(se, fe); - } -}; -fe = new WeakMap(), ue = new WeakMap(), Ne = new WeakMap(), at = new WeakMap(), E(se, fe, null), N(se, "getInstance", () => (y(se, fe) || _(se, fe, new se()), y(se, fe))); -let kt = se; -const fn = kt.getInstance(), Ot = x.forwardRef(({ listCode: e, base62params: t, className: n, theme: r, themeProps: i, layouts: a, classNames: o }, s) => { - const [{ resource: l, primaryKey: g, batchOperations: c = [], itemOperations: p = [], columns: h = [], themeConfig: m, theme: f, isConditionFormLayout: C = !1, isTreeSider: b, treeSiderConfig: k, isItemGridLayout: S, itemGridLayout: v, title: F, isPaginate: I, tabs: W }, z] = R({ isItemGridLayout: !1, itemGridLayout: {} }), M = mr(e, t), [{ dataSource: O, itemOperationsAccess: B, condition: T, tab: D, keyword: L, page: ee, total: Se, pageSize: Te, sider: $e, onConditionChange: K, onTabChange: Lt, onKeywordChange: ct, onPageChange: Pn, onPageSizeChange: Nn, onSiderChange: Tn, onReload: dt, payload: $n }, Vt] = pr(M, e, g, l), Fn = Ct(p, B, O, g), On = Ct(c); - A(() => { - let te = null; - return e && j.get(`/api/_/${e}`).resp(({ data: Ye, res: En }) => { - Ye != null && Ye.isDynamicRefresh && (te = fn.subscribe(() => dt(), En)), z(Ye); - }).catch(() => z({})), () => te == null ? void 0 : te(); - }, [e]), x.useImperativeHandle(s, () => ({ onReload: dt, onClickCallback: Vt })); - const Rn = { listCode: e, title: F, classNames: o, layouts: a, resource: l, primaryKey: g, theme: r || f, themeProps: i || m, isTreeSider: b, treeSiderConfig: k, isPaginate: I, tabs: W, isItemOperations: Fn, itemOperations: p == null ? void 0 : p.map((te) => u.isEmpty(te == null ? void 0 : te.confirm) ? te : { ...te, confirm: Object.assign({}, te.confirm, { getPopupContainer: () => document.body }) }), isBatchOperations: On, batchOperations: c, isItemGridLayout: S, columns: h, itemGridLayout: v, isConditionFormLayout: C, itemOperationsAccess: B, dataSource: O, onConditionChange: K, onTabChange: Lt, onKeywordChange: ct, onPageChange: Pn, onPageSizeChange: Nn, onSiderChange: Tn, condition: T, tab: D, keyword: L, page: ee, total: Se, pageSize: Te, sider: $e, payload: $n }; - return d(mn, { ...Rn, className: V("ff-data-list-helper", n), onReload: dt, onClickCallback: Vt }); -}), hn = (e, t, n = !0) => n !== !0 && n-- <= 0 ? [] : u.isArray(e) && !u.isEmpty(e) ? e.reduce((r, i) => (Reflect.has(i, t) && Reflect.has(i, "children") && r.push(i[t]), Reflect.has(i, "children") && !u.isEmpty(i.children) ? r.concat(hn(i.children, t, n)) : r), []) : [], Sr = ({ className: e, primaryKey: t, columns: n = [], dataSource: r = [], operationRender: i, operationWidth: a = 180, components: o = {}, ...s }) => { - const { classNames: l } = re(Z), g = U(null), c = U(null), [p, h] = R([]), [m, f] = R({ width: 0, height: 0 }); - A(() => { - h(hn(r, t)); - }, [r, t]), Vn(() => { - const k = new ResizeObserver(() => { - var S; - f({ width: ((S = g.current) == null ? void 0 : S.nativeElement.querySelector(".ant-table-body").scrollWidth) || c.current.offsetWidth, height: c.current.offsetHeight }); - }); - return c.current && k.observe(c.current), () => { - c.current && k.unobserve(c.current); - }; - }, []); - const C = ur(n), b = gr(o); - return d("div", { ref: c, className: V("ff-data-list-table", l.content, e), children: m.height ? d(Un, { bordered: !0, ...s, components: b, ref: g, rowKey: (k) => (k == null ? void 0 : k[t]) ?? Math.random(), columns: C == null ? void 0 : C.concat(i ? [{ title: "操作", align: "center", fixed: "right", width: `${Math.ceil(a / m.width * 100).toFixed(2)}%`, render: (k, S, v) => i(S, v) }] : []), dataSource: r, size: "middle", scroll: { x: "max-content", y: m.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: h, expandedRowKeys: p } }) : null }); -}, vr = "RC_FORM_INTERNAL_HOOKS", Pr = (e, { initialValue: t, initialValueLanguage: n, convertJs: r, convertJsSetting: i, type: a = "string" }, o = null) => { - const s = U(!1), l = re(en), [g, c] = R(), [p, h] = R(n != "javascript" && e ? l.getFieldValue(e) : void 0), { registerWatch: m } = l.getInternalHooks(vr) || {}; - return A(() => m == null ? void 0 : m((f, C, b) => { - if (!s.current) return; - const k = u.get(C, e); - u.isEqual(k, p) || h(ge(k, a)); - }), [p]), A(() => { - n == "javascript" && t ? xe.exec(t, {}, { getFieldValueForBasicForm: (f) => o ? o.getFieldValue(f) : l.getFieldValue(f), getFieldValue: (f) => l.getFieldValue(f) }).then((f) => h(ge(f, a))).catch((f) => notification.error({ message: `布局数据错误: ${JSON.stringify(f)}` })).finally(() => s.current = !0) : (t && h(ge(t ?? l.getFieldValue(e), a)), s.current = !0); - }, [t, n]), Ke(() => { - s.current && r && new tt([r, i]).toValue(p, l.getFieldsValue(!0)).then(c).catch((f) => { - c(f), console.error("布局数据转换错误: ", f, r); - }); - }, [p, r, i]), [g ?? p, p]; -}, yn = (e, t, n = null) => H(() => { - var r; - return (r = u.sortBy(e, ["y", "x"])) == null ? void 0 : r.map(({ i, x: a, y: o, w: s, h: l, field: { boxStyle: g, ...c } }, p) => d("div", { className: "grid-layout-item", style: gn(a, o, s, l, g), children: d(t, { ...c, basicForm: n }) }, i ?? p)); -}, [e]), Nr = ({ widget: e, widgetPrefix: t = "@pkg/ff/grid-layouts", basicForm: n, ...r }) => { - const i = e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, [a, o] = R(); - return A(() => { - i && ce.getWidgetComponent(i).then(({ defaultProps: s = {}, default: l }) => ({ default: Tr(l, s, n) })).catch((s) => ({ default: () => `${s}` })).then((s) => o(x.createElement(s.default, r))); - }, [i]), a; -}, Tr = (e, t = {}, n = null) => (r) => { - const { code: i, label: a, extras: o, isVirtual: s, initialValue: l, initialValueLanguage: g, convertJs: c, convertJsSetting: p, value: h, ...m } = u.merge({}, t, r), [f, C] = Pr(s ? null : i, { initialValue: l, initialValueLanguage: g, convertJs: c, convertJsSetting: p, type: (m == null ? void 0 : m.type) || "string" }, n), b = H(() => { - const v = Object.keys((t == null ? void 0 : t.extras) || {}); - return u.over([u.partialRight(u.pick, v), u.partialRight(u.omit, v)]); - }, [t == null ? void 0 : t.extras]), [k, S] = b(m); - return d(e, { ...S, value: f, rawValue: C, $setting: Object.assign({}, o, k) }); -}, wn = ({ className: e, cols: t = 12, rowHeight: n = 21, containerPadding: r = [0, 0], itemMargin: i = [4, 0], formProps: a = {}, fields: o = [], data: s, basicForm: l = null, ...g }) => { - const [c] = Q.useForm(), p = yn(o, Nr, l), h = H(() => [{ name: "__PROPS__", value: a }], [a]); - return Ke(() => (c.setFieldsValue(s), () => c.resetFields()), [s]), d(Q, { fields: h, form: c, component: !1, children: d("div", { ...g, className: V("ff-grid-layout", e), style: { "--grid-layout-item-margin-y": `${(i == null ? void 0 : i[0]) || 0}px`, "--grid-layout-item-margin-x": `${(i == null ? void 0 : i[1]) || 0}px`, "--grid-layout-container-padding-y": `${(r == null ? void 0 : r[0]) || 0}px`, "--grid-layout-container-padding-x": `${(r == null ? void 0 : r[1]) || 0}px`, "--grid-layout-cols": t, "--grid-layout-row-height": `${n}px` }, children: p }) }); -}, Oi = (_t = wn, function({ code: e, data: t, ...n }) { - const [r, i] = R({ resource: null, cols: 12, rowHeight: 21, fields: [] }); - return A(() => { - e && j.get(`/api/_/${e}`).then((a) => i(u.pick(a, ["resource", "cols", "rowHeight", "fields"]))); - }, [e]), (r == null ? void 0 : r.resource) && d(_t, { ...n, rowHeight: r.rowHeight, cols: r.cols, fields: r.fields, data: r != null && r.resource ? { [r == null ? void 0 : r.resource]: t } : {} }); -}); -var _t; -const $r = ({ column: e = 0, colWidth: t = 0, cols: n, rowHeight: r, itemMargin: i, fields: a, primaryKey: o, dataSource: s, itemClassName: l, beforeRender: g = null, afterRender: c = null, itemRender: p = (C, b, k) => C, empty: h = d(_n, { description: null }), className: m, style: f = {} }) => { - const { classNames: C } = re(Z), b = H(() => d(wn, { cols: n, rowHeight: r, itemMargin: i, fields: a, className: l }), [a, n, r, i]), k = u.isEmpty(s); - return $("div", { className: V("ff-data-list-content", C.content, m), style: Object.assign({}, f, e && { "--col-num": e }, t && { "--col-width": t }), children: [g == null ? void 0 : g(s), k ? h : s.map((S, v) => { - const F = p(x.cloneElement(b, { data: S }), S, v); - return x.cloneElement(F, { key: `${(S == null ? void 0 : S[o]) ?? v}-${or(S)}` }); - }), c == null ? void 0 : c(s)] }); -}, Fr = ({ component: e, $props: t }) => { - const { base62params: n } = He(t, {}); - return d(J, { children: d(Ot, { listCode: e, base62params: j.decode(n) }) }); -}, Ri = () => d(bn, {}), bn = () => "Empty", Or = ({ component: e, $setting: t, $props: n }) => { - const [r, i] = R(); - A(() => { - if (!e) return i(d(bn, { description: null })); - ce.getWidgetComponent(e).catch((o) => ({ default: () => `${o}` })).then((o) => x.createElement(o.default, { $setting: t })).then(i); - }, [e]); - const a = He(n, {}); - return r ? x.cloneElement(r, a) : null; -}, Ei = () => "NotFoundPage"; -var he, ne, ye, we, We, Ue; -const oe = class oe { - constructor() { - E(this, ne, /* @__PURE__ */ new Map()); - E(this, ye, {}); - E(this, we, null); - N(this, "init", (t, n) => { - _(this, ne, t), _(this, ye, n); - }); - N(this, "get", (t) => (y(this, ne).has(t) || (t = Array.from(y(this, ne).keys()).find((n) => y(this, ne).get(n).uri === t)), y(this, ne).get(t) || {})); - N(this, "redirect", (t, n, r = {}) => { - const { uri: i, type: a, widgetProps: o } = this.get(t) || {}, { router: s, query: l, ...g } = n || {}, c = Object.assign({}, g, s), p = Object.assign({}, g, l); - a == "list" && (c.base62params = j.encode(c != null && c.base62params ? c.base62params : c)); - let h = Yn(i || t, c); - const m = new URLSearchParams(); - for (const f in o || {}) (o == null ? void 0 : o.type) == "query" && Object.has(p, f) && m.append(f, JSON.stringify(p[f])); - return m.size > 0 && (h = `${h}?${m.toString()}`), r != null && r.isOpenWindow ? window.open(h) : y(this, we).navigate(h, { replace: !!(r != null && r.isReplaceRouteHistory) }); - }); - N(this, "getMenus", (t) => { - var n; - return ((n = y(this, ye)) == null ? void 0 : n[t]) || []; - }); - N(this, "findMenuPathByUuid", (t) => { - let n = []; - for (const r in y(this, ye)) if (n = y(this, We).call(this, y(this, ye)[r], t, [r]), n.length > 1) return n; - return n; - }); - N(this, "getMenusByRouteUuid", (t) => y(this, Ue).call(this, t, Object.values(y(this, ye)).flat())); - E(this, We, (t, n, r = []) => { - if (u.isEmpty(t)) return r; - for (const { uuid: i, children: a } of t) { - if (i == n) return r.concat(i); - if (!u.isEmpty(a)) return r.concat(i, y(this, We).call(this, a, n)); - } - return r; - }); - E(this, Ue, (t, n) => { - var i; - let r = []; - for (const a of n) a.widgetType == "redirect" && (a.uuid == t || a.widget == t ? r.push(a) : (i = a.children) != null && i.length && (r = r.concat(y(this, Ue).call(this, t, a.children)))); - return r; - }); - N(this, "getCurrentMenu", () => { - const { uuid: t } = this.getCurrentRoute() || {}; - if (!t) return; - const n = this.getMenusByRouteUuid(t); - return u.isEmpty(n) ? void 0 : n[0]; - }); - N(this, "getCurrentRoute", (t = 0) => { - var r; - const n = (r = y(this, we).state.matches[y(this, we).state.matches.length - 1 - t]) == null ? void 0 : r.route; - if (!n) return null; - for (let [i, a] of y(this, ne)) if (a.uri === n.path) return a; - return null; - }); - N(this, "getPageParams", (t) => { - var i, a, o; - let n = "", r = {}; - if (nn()) r = Xn(), n = (i = Qn()) == null ? void 0 : i.search; - else { - const { location: s = {}, matches: l = [] } = ((a = y(this, we)) == null ? void 0 : a.state) || {}; - r = ((o = l[l.length - 1]) == null ? void 0 : o.params) || {}, n = s.search; - } - return n && new URLSearchParams(n).forEach((s, l) => { - r[l] = s; - }), t ? u.get(r, t) : r; - }); - N(this, "createBrowserRouter", (t = {}) => { - if (y(this, ne).size == 0) return null; - const n = Ie.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/ff/frameworks/DefaultTheme"), r = Ie.get(ce.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), i = { [n]: 0 }, a = (s, l) => () => Promise.all([ce.getWidgetComponent(s), He(l)]).then(([g, c]) => [g.default || function() { - return `${s}`; - }, c]).then(([g, c]) => ({ Component: () => x.createElement(an, {}, x.createElement(g, { $setting: c })) })), o = Array.from(y(this, ne).values()).reduce((s, { uuid: l, uri: g, name: c, type: p, component: h, widgetSetting: m, widgetProps: f, isLogin: C, isLayout: b, extra: k }) => { - let S = {}, v = 0; - switch (p) { - case "list": - S.element = x.createElement(Fr, { component: h, $props: f }); - break; - case "fsdpf-component": - S.element = x.createElement(Or, { key: h, component: h, $setting: m, $props: f }); - } - const F = (k == null ? void 0 : k.theme) ?? (k == null ? void 0 : k.layout); - if (F) { - const I = (k == null ? void 0 : k.themeProps) ?? (k == null ? void 0 : k.layoutProps); - if (!i[F]) return i[F] = s.length, [...s, { path: "/", lazy: a(F, I), children: [{ path: g, ...S }] }]; - v = i[F]; - } - return b && v > -1 ? (s[v].children.push({ path: g, ...S }), s) : [...s, { path: g, ...S }]; - }, [{ path: "/", lazy: a(n, {}), children: [] }]); - return o.push({ index: !0, element: x.createElement(Rr, { to: r, replace: !0 }) }), _(this, we, Zn(o, t)); - }); - if (y(oe, he)) return y(oe, he); - } -}; -he = new WeakMap(), ne = new WeakMap(), ye = new WeakMap(), we = new WeakMap(), We = new WeakMap(), Ue = new WeakMap(), E(oe, he, null), N(oe, "getInstance", () => (y(oe, he) || _(oe, he, new oe()), y(oe, he))); -let xt = oe; -const Rr = ({ to: e, replace: t }) => nn() ? x.createElement(er, { to: e, replace: t }) : (window.document.location = e, "redirect"), ke = xt.getInstance(), Fe = new Worker(new URL("/ff-worker/index.js", self.location)), Ht = { getConfigure: (e) => Ie.get(e), route: { redirect: (...e) => ke.redirect(...e), getPageParams: (...e) => ke.getPageParams(...e), getCurrentRoute: () => ke.getCurrentRoute() }, popup: { notification: (...e) => Y.notification(...e), success: (...e) => Y.success(...e), error: (...e) => Y.error(...e), form: (...e) => Y.form(...e), modal: (...e) => Y.modal(...e), confirm: (...e) => Y.confirm(...e) } }; -var st, je, be; -const q = class q { - constructor() { - N(this, "exec", (t, n = {}, r = {}, i = "") => new Promise((a, o) => { - if (!/^(?!\s*(\/\/|\/\*|\*)).*?\S+/m.test(t)) return a(); - const s = zt(q, st)._++; - y(q, je).set(s, r), q.mQueue.set(s, [a, o]), Fe.postMessage({ id: s, session: i, category: "eval", method: t, args: n }); - })); - N(this, "clear", (t) => Fe.postMessage({ session: t, category: "clear" })); - if (y(q, be)) return y(q, be); - Promise.resolve().then(() => ri).then((t) => { - Ht.http = t.http; - }), Fe.addEventListener("message", ({ data: { id: t, task_id: n, method: r, args: i, category: a, data: o, error: s, session: l } }) => { - if (a === "eval" && q.mQueue.has(t)) s !== null ? q.mQueue.get(t)[1](s) : q.mQueue.get(t)[0](o), y(q, je).delete(t), q.mQueue.delete(t); - else if (a === "util") try { - const g = u.get(Ht, r.split("/")) || u.get(y(q, je).get(n), r.split("/")); - if (!u.isFunction(g)) throw `${r} not found`; - Promise.resolve(Reflect.apply(g, void 0, i)).then((c) => { - Fe.postMessage({ id: t, task_id: n, category: a, method: r, args: i, session: l, data: c, error: null }); - }).catch((c) => { - Fe.postMessage({ id: t, task_id: n, category: a, method: r, args: i, session: l, data: null, error: c }); - }); - } catch (g) { - Fe.postMessage({ id: t, task_id: n, category: a, method: r, args: i, session: l, data: null, error: g }); - } - }, !1); - } -}; -st = new WeakMap(), je = new WeakMap(), be = new WeakMap(), N(q, "mQueue", /* @__PURE__ */ new Map()), E(q, st, 0), E(q, je, /* @__PURE__ */ new Map()), E(q, be, null), N(q, "getInstance", () => (y(q, be) || _(q, be, new q()), y(q, be))); -let St = q; -const xe = St.getInstance(), ot = () => { - const e = U(!0), [, t] = x.useReducer((n) => n + 1, 0); - return A(() => () => e.current = !1, []), () => e.current && t(); -}, ji = (e) => { - const t = U(); - return A(() => { - t.current = e; - }, [e]), t.current; -}, Ai = (e) => { - const [t, n] = R(e), r = U(null), i = X((a, o) => { - r.current = o, n(a); - }, []); - return A(() => { - r.current && (r.current(t), r.current = null); - }, [t]), [t, i]; -}, Ke = (e = (r) => { -}, t, n = u.isEqual) => { - const r = x.useRef(); - n(t, r.current) || (r.current = u.cloneDeep(t)), x.useEffect(e, [r.current]); -}, Je = Ke, Cn = (e, t = "string") => { - var n; - if (!Array.isArray(e)) return e; - for (let r = 0; r < e.length; r++) e[r].value = ge((n = e[r]) == null ? void 0 : n.value, t), e[r] && Reflect.has(e[r], "children") && (e[r].children = Cn(e[r].children, t)); - return e; -}, Li = (e, t = "json", n = "string", r, i = null) => { - const [a] = Q.useForm(r), [o, s] = R([{ label: "无", value: "", disabled: !0 }]), l = U([]), g = Q.useWatch((c) => l.current.length === 0 ? null : u.pick(c, l.current), a) || null; - return A(() => { - Array.isArray(e) ? s(e) : t === "javascript" && e ? xe.exec(e, {}, { getFieldValue: (c) => (l.current.includes(c) || l.current.push(c), a.getFieldValue(c)), getFieldValueForBasicForm: (c) => (l.current.includes(c) || l.current.push(c), i ? i.getFieldValue(c) : a.getFieldValue(c)) }).then((c) => { - s(ge(c, "array")); - }).catch((c) => console.error("useOptions", c)) : e && s(ge(e, "array")); - }, [e, t, g]), Cn(o, n); -}, Vi = (e) => { - const [t, n] = R(), r = { type: "GET" }; - if (typeof e == "string" ? r.url = e : u.isPlainObject(e) && Object.assign(r, e), !(r != null && r.url)) throw "url is required"; - const i = (a) => j.request(r, !1).resp((o) => (console.log("useSubscribeRequest", a), n(o), o)); - return Ke(() => { - let a = null; - return i().then((o) => { - a = fn.subscribe(u.throttle(i, 180, { leading: !1, trailing: !0 }), o.res); - }), () => a == null ? void 0 : a(); - }, r), t; -}, Er = (e) => { - const [t, n] = x.useState({ gridItems: [], hideItems: [] }); - return x.useEffect(() => { - e && j.get(`/api/_/${e}`).then(({ pk: r, uuid: i, code: a, resource: o, align: s, cols: l, rowHeight: g, marginX: c, marginY: p, listenChangeFields: h, listenChangeFieldsFunc: m, fields: f }) => ({ pk: r, uuid: i, code: a, resource: o, align: s, cols: l, rowHeight: g, marginX: c, marginY: p, listenChangeFields: h, listenChangeFieldsFunc: m, ...f.reduce((C, b) => { - var k; - return (k = b == null ? void 0 : b.field) != null && k.hidden ? C.hides.push(b == null ? void 0 : b.field) : C.items.push(b), C; - }, { items: [], hides: [] }) })).then(n); - }, [e]), t; -}, jr = ({ max: e = 0, min: t = 0, type: n = "", message: r, pattern: i, required: a = !1, validator: o } = {}, s, l) => { - const [g, c] = R([]); - return A(() => { - const p = []; - if (a) { - 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 (n) { - case "string": - p.push({ type: n, max: e, min: t, message: r || (t && e ? `字符必须在 ${t} ~ ${e} 之间` : `${e ? "最多能有" : "最少要有"} ${t || e} 个字符`) }); - break; - case "pattern": - p.push({ type: "string", pattern: i, message: r }); - break; - case "validator": - o && p.push(({ getFieldValue: h }) => ({ validator: async (m, f) => { - const C = await xe.exec(o, { value: f, fieldName: s }, { getFieldValue: h }); - return u.isString(C) && C ? Promise.reject(C) : u.isBoolean(C) && !C ? Promise.reject(r) : Promise.resolve(); - } })); - } - c(p); - }, [e, t, n, r, i, a, o]), g; -}, Ar = (e, t, n) => { - const [r, i] = R(null); - return A(() => { - const { initDataUri: a = `/api/${e}`, initDataMethod: o = "GET" } = n || {}; - t && j.request({ method: o, url: u.trimEnd(`${a}/${t}`, "/") }).then((s) => { - i(s); - }); - }, [e, t, n]), r; -}, Lr = (e, t, n) => X((r, i = { serialize: (a) => a, onSuccess: () => { -}, onFail: (a) => (a == null ? void 0 : a.errorFields) && Y.error("请先完善表单信息", { duration: 2e3 }) }) => { - const a = r.getFieldValue("__RESOURCE__"), { submitDataUri: o = `/api/${e}`, submitDataMethod: s = "POST" } = n || {}; - return r.validateFields().then((l) => a ? u.pick(l, [a]) : l).then(i.serialize).then((l) => j.request({ method: s, url: u.trimEnd(`${o}/${t || ""}`, "/"), data: l }).msg(i.onSuccess)).catch(i.onFail); -}, [e, t, n]), Vr = (e, t, n, r) => { - const i = Ar(t, n, r); - A(() => { - i ? e.setFieldsValue(i) : e.resetFields(); - }, [e, i]); - const a = Lr(t, n, r); - return u.partial(a, e); -}, kn = (e, t, n = {}, r = {}, i = {}) => { - const a = re(en), o = ot(), s = U(!0), l = U([]), [g, c] = R(t), [p, h] = R(), m = Q.useWatch((f) => JSON.stringify(u.pick(f, l.current)), a) || "{}"; - return Je(() => { - e && xe.exec(e, n, { ...r, getFieldValueForBasicForm: (f) => i ? i.getFieldValue(f) : null, getFieldValue: u.wrap(a.getFieldValue, (f, C) => (l.current.some((b) => u.isEqual(b, C)) || (l.current.push(C), o()), f == null ? void 0 : f(C))), isFieldTouched: a.isFieldTouched, isFieldsTouched: a.isFieldsTouched }).then((f) => { - s.current && (c(f), h(null)); - }).catch((f) => { - s.current && (c(t), h(f)); - }); - }, [e, m, a, n, r]), A(() => () => s.current = !1, []), e ? [g, p] : [t, null]; -}, Ir = (e, t, n = [], r = {}) => { - const i = U({}), a = U(), o = u.debounce(ot(), 180), s = ["disabled", "required"], l = (h, m) => { - s.includes(h) && (i.current[h] = m), o(); - }, g = H(() => ({ setDisabled: (h) => l("disabled", h), setRequired: (h) => l("required", h), getDisabled: () => i.current.disabled, getRequired: () => i.current.required }), [t]), [c, p] = kn(t, -1, {}, g, r); - if (!p && a.current != c && (c >= 0 || !u.isEmpty(n == null ? void 0 : n[c]))) { - a.current = c; - const { widget: h, widgetPrefix: m, props: f } = n == null ? void 0 : n[c]; - e = on(h, m), i.current = u.merge(f, u.pick(i.current, s)); - } - return [e, i.current]; -}, Kt = (e) => e === void 0 || e === !1 ? "" : (Array.isArray(e) ? e : [e]).join("_"), Ii = ({ value: e, onChange: t }, n = null) => { - const r = U(), [i] = Q.useForm(n), a = U({}); - return Je(() => { - u.isEqual(r.current, e) || i.setFieldsValue(e); - }, [e]), A(() => () => i.resetFields(), []), [H(() => i.__INTERNAL__ ? i : { ...i, __INTERNAL__: { itemRef: (o) => (s) => { - const l = Kt(o); - s ? a.current[l] = s : delete a.current[l]; - } }, scrollToField: (o, s = {}) => { - console.warn("useMergedFormValuesChange scrollToField not work, unreferenced antd form"); - }, focusField: (o) => { - console.warn("useMergedFormValuesChange focusField not work, unreferenced antd form"); - }, getFieldInstance: (o) => { - const s = Kt(o); - return a.current[s]; - } }, [i]), (o, s) => { - r.current = s, t == null || t(s); - }]; -}, Mr = ({ type: e, initialValue: t, initialValueLanguage: n, onChange: r, basicForm: i }) => { - const [a, o] = kn(n == "javascript" && t, n == "javascript" ? void 0 : t, {}, {}, i); - return A(() => { - n == "javascript" ? r(ge(a, e)) : t && r(ge(t, e)); - }, [e, t, a]), null; -}, Rt = ({ widget: e = "Input", widgetPrefix: t = "@pkg/ff/grid-layout-forms", widgetDecorator: n, subWidgets: r = [], basicForm: i, ...a }) => { - const o = on(e, t), [s, l] = Ir(o, n, r, i), [g, c] = R(); - return A(() => { - s && ce.getWidgetComponent(s).then(({ defaultProps: p = {}, default: h }) => ({ default: zr(h, p, i) })).catch((p) => ({ default: () => `${p}` })).then((p) => c(x.createElement(p.default, a))); - }, [s]), g && x.cloneElement(g, { ...a, ...l }); -}, zr = (e, t = {}, n = null) => (r) => { - const { type: i, code: a, label: o, noStyle: s, placeholder: l, required: g = !1, extras: c, validators: p, help: h, isVirtual: m, $isReserved: f, initialValue: C, initialValueLanguage: b, ...k } = u.omit(u.merge({}, t, r), ["convertJs", "convertJsSetting", "widget", "widgetPerfix", "widgetDecorator", "subWidgets", "boxStyle"]), S = jr(Object.assign({}, p, g ? { required: !0 } : {}), a, i), v = H(() => { - const M = Object.keys((t == null ? void 0 : t.extras) || {}); - return u.over([u.partialRight(u.pick, M), u.partialRight(u.omit, M)]); - }, [t == null ? void 0 : t.extras]), [F, I] = v(k), W = { label: o, noStyle: s, colon: !1, layout: "vertical" }, z = X((M) => M == null ? void 0 : ge(M, i), [i]); - return d($t, { name: a, rules: S, initialValue: z(C), normalize: z, children: (M, O, B) => { - var T; - return d(e, { type: i, rcform: B, basicForm: n, itemProps: { validateStatus: O.errors.length > 0 ? "error" : "success", tooltip: h || null, help: O.errors.length > 0 ? O.errors.join("、") : null, required: ((T = S == null ? void 0 : S[0]) == null ? void 0 : T.required) || !1, ...W }, fieldProps: { placeholder: l, ...I, ...M }, $setting: Object.assign({}, c, F) }); - } }); -}, Et = ({ cols: e = 24, rowHeight: t = 16, itemMargin: n = [8, 16], containerPadding: r = [0, 0], fields: i = [], children: a, basicForm: o = null }) => { - const s = yn(i, Rt, o); - return $("div", { className: "ff-grid-layout-form", style: { "--grid-layout-item-margin-x": `${(n == null ? void 0 : n[0]) ?? 8}px`, "--grid-layout-item-margin-y": `${(n == null ? void 0 : n[1]) ?? 16}px`, "--grid-layout-container-padding-y": `${(r == null ? void 0 : r[0]) || 0}px`, "--grid-layout-container-padding-x": `${(r == null ? void 0 : r[1]) || 0}px`, "--grid-layout-cols": e, "--grid-layout-row-height": `${t}px` }, children: [s, a && x.cloneElement(a, { cols: e, rowHeight: t, itemMargin: n, containerPadding: r, fields: i })] }); -}; -Et.propTypes = { fields: w.array }; -const Br = (Jt = Et, ({ code: e, layout: t, name: n, primaryKey: r = 0, style: i = {}, formProps: a = {}, form: o, basicForm: s, isPreview: l = !1, className: g, onFinish: c, onValuesChange: p = () => { -}, ...h }) => { - const { align: m, autoComplete: f, resource: C, items: b, hides: k, rowHeight: S, marginX: v, marginY: F, cols: I, listenChangeFields: W, listenChangeFieldsFunc: z, pk: M, uuid: O } = Er(e), [B] = Q.useForm(o), T = H(() => [{ name: "__PK__", value: M }, { name: "__PROPS__", value: a }, { name: "__RESOURCE__", value: C }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: O }, { name: "__PRIMARY_KEY__", value: r }], [M, e, O, C, r, a]); - return $(Q, { className: g, name: n || e, layout: t || m, fields: T, form: B, autoComplete: f, style: { ...i, position: "relative" }, onFinish: c, onValuesChange: (D, L) => (({ changedValues: ee, allValues: Se, listenChangeFields: Te, listenChangeFieldsFunc: $e, onValuesChange: K, code: Lt }) => { - K(ee, Se), $e && Array.isArray(Te) && xe.exec($e, { changedValues: ee, allValues: Se }, { getFieldValue: B.getFieldValue, setFieldValue: B.setFieldValue, setFieldsValue: B.setFieldsValue, isFieldTouched: B.isFieldTouched, isFieldsTouched: B.isFieldsTouched }).catch((ct) => console.error("onFormValuesChange", ct)); - })({ changedValues: D, allValues: L, listenChangeFields: W, listenChangeFieldsFunc: z, onValuesChange: p, code: e }), children: [d(Jt, { ...h, form: B, basicForm: s, code: e, fields: b, cols: I, rowHeight: S, itemMargin: [v, F] }), k == null ? void 0 : k.map((D) => { - var L; - return d($t, { name: D.code, children: d(Mr, { form: B, basicForm: s, name: D.code, type: D.type, initialValue: D.initialValue, initialValueLanguage: (L = D.extras) == null ? void 0 : L.initialValueLanguage }) }, JSON.stringify(D.code)); - })] }, e); -}); -var Jt; -const xn = ({ $setting: e, $close: t, extras: n, code: r, primaryKey: i, ...a }) => { - const [o] = Q.useForm(), s = Vr(o, r, i, e); - return d(J, { actions: $(x.Fragment, { children: [d(P, { name: (e == null ? void 0 : e.okText) || "保存", type: "primary", widget: () => s({ onSuccess: t }) }), d(P, { name: (e == null ? void 0 : e.cancelText) || "取消", widget: () => t(!1) })] }), extras: n, children: d(Br, { form: o, code: r, primaryKey: i, ...a }) }); -}, Gt = /* @__PURE__ */ new Set(), vt = (e = [], t = 0) => { - const n = e[t]; - if (n.length && !Gt.has(n)) { - const r = document.createElement("script"); - r.setAttribute("src", n), r.setAttribute("data-namespace", n), e.length > t + 1 && (r.onload = () => { - vt(e, t + 1); - }, r.onerror = () => { - vt(e, t + 1); - }), Gt.add(n), document.body.appendChild(r); - } -}, Pt = ({ className: e, type: t, style: n = {}, ...r }) => d("span", { role: "img", className: V("ff-iconfont", e), style: n, ...r, children: d("svg", { style: { width: "1em", height: "1em", fill: "currentColor", overflow: "hidden" }, viewBox: "0 0 1024 1024", children: d("use", { xlinkHref: `#${t}` }) }) }); -Pt.propTypes = { className: w.string, type: w.string.isRequired, style: w.object }, Pt.init = vt; -const Dr = (e, t, n, r) => ke.redirect(n, t, r), qr = (e, t = {}, n, r = {}) => { - var a; - const i = (a = r.router) == null ? void 0 : a.reduce((o, [s, l, g]) => { - const c = u.get(t, ["router", s]); - if (!c && c !== 0 && l) throw `请传入 ${g}`; - return `${o}/${c}`; - }, `/api/${n}`); - return j.del(i, t.param).msg(); -}, Yt = (e, t, n, { status: { loading: r, disabled: i }, setStatus: a }) => { - const o = { loading: (s) => s === void 0 ? r : a((l) => ({ ...l, loading: s })), disabled: (s) => s === void 0 ? i : a((l) => ({ ...l, disabled: s })) }; - return u.isFunction(n) ? n.call(null, { ...t, ...o }) : u.isString(n) && n ? xe.exec(n, t, o) : null; -}, Xt = (e, t, n, r, i) => u.isString(n) && n ? ce.getWidgetComponent(n).then(({ default: a }) => Y.modal(a, { ...t, $setting: r }, i != null && i.title ? { ...i, title: u.template(i.title)(e) } : i)).catch((a) => { - Y.error(n, { content: a.toString() }); -}) : Y.modal(n, { ...t, $setting: r }, i != null && i.title ? { ...i, title: u.template(i.title)(e) } : i), Wr = (e, t, n, r, i) => Y.modal(xn, { ...t, $setting: r, code: n }, i != null && i.title ? { ...i, title: u.template(i.title)(e) } : i), Ur = (e, t, n, r, i) => Y.modal(Ot, { base62params: t, $setting: r, listCode: n }, i != null && i.title ? { ...i, title: u.template(i.title)(e) } : i), _r = ({ widget: e, widgetType: t, widgetData: n, widgetProps: r, widgetSetting: i, widgetContainerProps: a }, { onAfterClick: o, onBeforeClick: s }) => { - const l = re(Z), [g, c] = R({ leading: !0, trailing: !1 }), p = H(() => { - switch (t) { - case "redirect": - return u.partialRight(Dr, e, i); - case "func": - return u.partialRight(Yt, (i == null ? void 0 : i.code) ?? e, { status: g, setStatus: c }); - case "component": - case "fsdpf-component": - return u.partialRight(Xt, e, i, a); - case "grid-layout-form": - return u.partialRight(Wr, e, i, a); - case "data-list": - return u.partialRight(Ur, e, i, a); - case "destroy": - return u.partialRight(qr, e, i, a); - default: - if (At(e) || x.isValidElement(e)) return u.partialRight(Xt, e, i, a); - if (u.isFunction(e)) return u.partialRight(Yt, (i == null ? void 0 : i.code) || e, { status: g, setStatus: c }); - } - return (...h) => console.error("useButton unknown widgetType", t, ...h); - }, [e, t]); - return [u.debounce((h) => (s == null || s(h), Promise.resolve(He(r, h, { list: l })).then((m) => p(h, { ...n, ...m })).then((m) => o == null ? void 0 : o(m)).catch(console.error)), 300, { leading: !0, trailing: !1 }), g]; -}, Sn = ({ type: e, name: t, className: n, icon: r, iconPosition: i, size: a }, o = "default") => H(() => { - const s = { type: "primary", className: V("ff-button", n), iconPosition: i, size: a }; - return e === "danger" ? s.danger = !0 : e === "default" && (s.type = e), o === "link" || o === "dashed" ? (s.type = o, e === "default" && (s.className = V(s.className, "ff-default"))) : o !== "circle" && o !== "round" || (s.shape = o), r && (s.icon = d(Pt, { type: r })), t && (s.children = t), s; -}, [o, e, n, r, i]), lt = ({ data: e, widget: t, widgetType: n = "fsdpf-component", widgetData: r, widgetProps: i, widgetSetting: a, widgetContainerProps: o, onAfterClick: s, onBeforeClick: l, children: g, extras: c }) => { - const p = re(Z), [h, m] = R(!1), [f, C] = R("hover"), [b, k] = R({}), [S, v] = R(), { placement: F, align: I, zIndex: W, arrow: z = { pointAtCenter: !0 }, getPopupContainer: M, isPopupMountBodyContainer: O = !1, ...B } = o || {}; - A(() => { - n == "grid-layout-form" ? v(x.createElement(xn, { ...r, $setting: a, code: t })) : n == "data-list" ? v(x.createElement(Ot, { base62params: e, $setting: a, listCode: t })) : u.isString(t) ? ce.getWidgetComponent(t).then(({ default: L }) => { - v(x.createElement(L, { ...r, $setting: a })); - }).catch((L) => v(L.toString())) : At(t) ? v(x.createElement(t, { ...r, $setting: a })) : x.isValidElement(t) && v(x.cloneElement(t, { ...r, $setting: a })); - }, [t, n, r]), A(() => { - Promise.resolve(He(i, e, { list: p })).then(k); - }, [i, e, p.getBase62params]); - const T = (L, ee = !1) => (m(L), !L && C("hover"), L ? l == null ? void 0 : l(b) : s == null ? void 0 : s(ee)), D = (L) => { - m(!0), C("click"); - }; - return d(Hn, { zIndex: W, placement: F, onPopupClick: D, onClick: D, open: h, align: I, arrow: z, trigger: f, getPopupContainer: M || O ? void 0 : (L) => L, styles: { body: { padding: 0 } }, content: d(Hr, { ...B, extras: c, children: S && x.cloneElement(S, { ...b, $close: (L) => T(!1, L) }) }), children: g, onOpenChange: T }); -}, Hr = ({ title: e, className: t, children: n, extras: r, width: i, height: a, ...o }) => { - const [s, l] = R({}), g = X((m, f) => l((C) => ({ ...C, [m]: f })), []), c = X((m) => l((f) => ({ ...f, [m]: void 0 })), []), p = e ? x.createElement("div", { className: "ff-popup-title" }, e) : s == null ? void 0 : s.title, h = r ?? x.createElement("div", { className: "ff-popup-reserved-extras" }, r); - return d(_e.Provider, { value: { ele: s, mount: g, unmount: c }, children: $("div", { className: V("ff-popup ff-popover", t, s.rootClassName), style: { width: i, height: a }, ...o, children: [$("div", { className: "ff-popup-header", children: [p, s == null ? void 0 : s["sub-title"]] }), n, $("div", { className: "ff-popup-footer", children: [h, s == null ? void 0 : s.extras, s == null ? void 0 : s.actions] })] }) }); -}; -lt.propTypes = { widgetType: w.oneOf(["fsdpf-component", "grid-layout-form", "data-list"]) }; -const Ge = (e) => function({ className: t, variant: n, children: r, name: i, icon: a, type: o = "default", iconPosition: s = "start", noAuthType: l, onAfterClick: g, onBeforeClick: c, data: p, loading: h, disabled: m, tooltip: f, confirm: C, widget: b = () => { -}, widgetType: k, widgetData: S, widgetProps: v, widgetSetting: F, widgetContainerProps: I, ...W }) { - const { mode: z, ...M } = I || {}, O = Sn({ className: t, name: i, type: o, icon: a, iconPosition: s }, n ?? e), B = d(et, { ...O, ...W, children: r || i }); - if (z === "popover" && !["destroy", "redirect", "func"].includes(k)) return d(lt, { data: p, widget: b, widgetType: k, widgetData: S, widgetProps: v, widgetSetting: F, widgetContainerProps: M, onAfterClick: g, onBeforeClick: c, children: B }); - const T = u.isEmpty(f) || !f.enabled ? {} : f, D = u.isEmpty(C) ? { enabled: !1 } : Object.assign({ enabled: !0 }, C), [L, ee] = R(!1), [Se, { disabled: Te, loading: $e }] = _r({ widget: b, widgetType: k, widgetData: S, widgetProps: v, widgetSetting: F, widgetContainerProps: M }, { onAfterClick: g, onBeforeClick: c }); - return d(Kn, { okText: "确定", cancelText: "取消", getPopupContainer: (K) => K, ...D, disabled: Te || m, open: L, onOpenChange: (K) => { - if (!K) return ee(K); - D.enabled ? ee(K) : Se(p); - }, onConfirm: (K) => { - Se(p, K); - }, onClick: (K) => { - K.stopPropagation(); - }, children: d(Jn, { getPopupContainer: (K) => K, ...T, title: L ? null : T == null ? void 0 : T.title, trigger: ["hover", "click"], children: x.cloneElement(B, { loading: $e || h, disabled: Te || m }) }) }); -}, P = Ge("default"); -P.propTypes = { type: w.oneOf(["primary", "default", "danger", ""]), size: w.oneOf(["large", "middle", "small"]), name: w.string, icon: w.string, iconPosition: w.oneOf(["start", "end"]), data: w.any, widget: w.any, widgetType: w.oneOf(["destroy", "redirect", "func", "component", "fsdpf-component", "grid-layout-form", "grid-layout", "data-list"]), widgetData: w.object, widgetProps: w.object, widgetSetting: w.object, widgetContainerProps: w.object, tooltip: w.exact({ title: w.string.isRequired, placement: w.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: w.oneOfType([w.bool, w.number]), getPopupContainer: w.func }), confirm: w.exact({ title: w.string.isRequired, cancelText: w.string, okText: w.string, okType: w.oneOf(["primary", "default", "danger", ""]), placement: w.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: w.oneOfType([w.bool, w.number]), getPopupContainer: w.func, arrow: w.oneOfType([w.bool, w.exact({ pointAtCenter: w.bool })]) }) }; -const Kr = Ge("link"), Jr = Ge("circle"), Gr = Ge("round"), Yr = Ge("dashed"), Qt = ({ options: e = [], triggerWeights: t = ["grid-layout-form", "grid-layout", "fsdpf-component", "print"], onAfterClick: n = (m, f, C) => { -}, onBeforeClick: r = (m, f, C) => { -}, labelVariant: i = "link", labelSize: a, labelRender: o, btnVariant: s, btnSize: l, btnRender: g = (m, f) => d(P, { ...m, data: f }, m.uuid || ft()), widgetContainerProps: c = {}, children: p, data: h }) => { - if (u.isEmpty(e)) return p; - const [m, f] = H(() => (e || []).reduce((b, k) => { - const S = t.indexOf(k.widgetType); - return S === -1 ? b[1].push(k) : b[0] ? S < t.indexOf(b[0].widgetType) ? (b[1].push(b[0]), b[0] = k) : b[1].push(k) : b[0] = k, b; - }, [null, []]), [e, t]); - o ? p = o(m, h) || p : p || (p = d(et, { ...Sn(Object.assign(m != null && m.name || m != null && m.icon ? {} : { icon: "icon-location" }, m, { size: a }), i) })); - const C = f.map((b) => g(Object.assign({ uuid: b.uuid, type: b.type, name: b.name, widget: b.widget, widgetType: b.widgetType, widgetProps: b.widgetProps, widgetData: b.widgetData, widgetSetting: b.widgetSetting, widgetContainerProps: b.widgetContainerSetting, confirm: b.confirm, onAfterClick: u.partialRight(n, b, h), onBeforeClick: u.partialRight(r, b, h) }, { size: l, variant: s }), h)); - return d(lt, { widget: m == null ? void 0 : m.widget, widgetType: m == null ? void 0 : m.widgetType, widgetProps: m == null ? void 0 : m.widgetProps, widgetSetting: m == null ? void 0 : m.widgetSetting, widgetContainerProps: Object.assign({}, c, m == null ? void 0 : m.widgetContainerProps), data: h, widgetData: m == null ? void 0 : m.widgetData, extras: C, onAfterClick: u.partialRight(n, m, h), onBeforeClick: u.partialRight(r, m, h), children: p }); -}; -Qt.propTypes = { triggerWeights: w.array, options: w.arrayOf(w.shape({ ...P.propTypes, widgetType: P.propTypes.widgetType.isRequired })), btnSize: P.propTypes.size, btnRender: w.func, btnVariant: w.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelVariant: w.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelRender: w.func, labelSize: P.propTypes.size, onAfterClick: w.func, onBeforeClick: w.func, widgetContainerProps: P.propTypes.widgetContainerProps, data: P.propTypes.data }, P.Link = Kr, P.Link.defaultProps = P.defaultProps, P.Link.propTypes = P.propTypes, P.Circle = Jr, P.Circle.defaultProps = P.defaultProps, P.Circle.propTypes = P.propTypes, P.Round = Gr, P.Round.defaultProps = P.defaultProps, P.Round.propTypes = P.propTypes, P.Dashed = Yr, P.Dashed.defaultProps = P.defaultProps, P.Dashed.propTypes = P.propTypes, P.Popover = lt, P.GroupPopover = Qt; -const Xr = ({ fields: e, formProps: t, $close: n }) => { - const [r] = Q.useForm(), i = H(() => [{ name: "__PROPS__", value: t }], [t]); - return d(J, { actions: $(x.Fragment, { children: [d(P, { name: "取消", widget: () => n(!1) }), d(P, { name: "确定", type: "primary", widget: () => r.validateFields(!0).then(n) })] }), children: d(Q, { fields: i, form: r, className: "ff-modal-form", children: e == null ? void 0 : e.map(({ code: a, ...o }) => d(Rt, { code: a, ...o }, a)) }) }); -}, Qr = ({ className: e, $close: t, children: n, title: r, subTitle: i, actions: a, extras: o, ...s }) => $(tr, { ...s, prefixCls: "ff-drawer", className: V("ff-popup", e), maskMotion: { motionAppear: !0, motionName: "mask-motion" }, motion: (l) => ({ motionAppear: !0, motionName: `panel-motion-${l}` }), children: [$("div", { className: "ff-popup-header", children: [d("button", { "aria-label": "Close", className: "ff-popup-close", onClick: s.onClose, children: d(Ft, { type: "close" }) }), r, i] }), d("div", { className: "ff-popup-body", children: n }), $("div", { className: "ff-popup-footer", children: [o, a] })] }), Zr = ({ className: e, $close: t, $event: n, children: r, title: i, subTitle: a, actions: o, extras: s, placement: l, ...g }) => { - const c = (n == null ? void 0 : n.pageX) === void 0 ? { animation: null, maskAnimation: null, mousePosition: { x: null, y: null } } : { animation: "zoom", maskAnimation: "fade", mousePosition: { x: n == null ? void 0 : n.pageX, y: n == null ? void 0 : n.pageY } }; - return d(nr, { ...g, ...c, prefixCls: "ff-modal", modalRender: () => $("div", { className: V("ff-modal-content ff-popup", e), children: [$("div", { className: "ff-popup-header", children: [d("button", { "aria-label": "Close", className: "ff-popup-close", onClick: g.onClose, children: d(Ft, { type: "close" }) }), i, a] }), d("div", { className: "ff-popup-body", children: r }), $("div", { className: "ff-popup-footer", children: [s, o] })] }) }); -}, vn = ({ placement: e, $close: t, $event: n, children: r, title: i, ...a }) => { - const [o, s] = R({}), [l, g] = R(!0), c = X((f, C) => s((b) => ({ ...b, [f]: C })), []), p = X((f) => s((C) => ({ ...C, [f]: void 0 })), []); - let h = { ...a, className: o.rootClassName, title: o.title || i && x.createElement("div", { className: V("ff-popup-title") }, i), subTitle: o["sub-title"], actions: o.actions, extras: o.extras, children: r, $close: t, $event: n, onClose: () => g(!1) }; - const m = () => { - t(!1); - }; - return d(_e.Provider, { value: { ele: o, mount: c, unmount: p }, children: e && e !== "center" ? d(Qr, { ...h, placement: e, open: l, afterOpenChange: (f) => !f && m() }) : d(Zr, { ...h, visible: l, afterClose: m }) }); -}; -vn.propTypes = { placement: w.oneOf(["center", "left", "top", "right", "bottom"]) }; -const G = () => { - const [e, t] = In({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (a) => { - const { offsetHeight: o } = a; - return { height: o }; - }, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, n] = x.useReducer((a) => a + 1, 0); - A(() => { - G.$onClick = r, G.$queue.forEach(([a, o, s], l, g) => { - i([o, s], ...a), delete g[l]; - }); - }, []); - const r = (a, o = {}, s = {}) => new Promise((l, g) => i([l, g], a, o, s)), i = ([a, o], s, l = {}, g = {}) => { - const c = G.$index++, p = (h) => ((m, f) => (G.$popups.delete(m), n(), f == null ? void 0 : f()))(c, () => a(h)); - if (s === sn) return e.open({ ...g, key: c, content: x.createElement(s, { ...l, $close: () => e.close(c) }) }); - G.$popups.set(c, x.createElement(vn, { maskClosable: !1, $event: l == null ? void 0 : l.$event, ...g, key: c, $close: p }, x.isValidElement(s) ? x.cloneElement(s, { ...l, $close: p }) : s != null && s.name || Bt.isForwardRef(s) || (s == null ? void 0 : s.$$typeof) === Bt.ForwardRef ? x.createElement(s, { ...l, $close: p }) : s)), n(); - }; - return $(x.Fragment, { children: [Array.from(G.$popups).map(([a, o]) => o), t] }); -}; -G.$popups = /* @__PURE__ */ new Map(), G.$index = 0, G.$queue = [], G.$onClick = (...e) => new Promise((t, n) => { - G.$queue.push([e, t, n]); -}); -const Zt = (e, t, n = {}) => G.$onClick(e, t, n), pt = (e, { showProgress: t, duration: n, ...r } = { duration: 1.5 }) => G.$onClick(sn, { content: e, ...r }, { showProgress: t, duration: n }), Y = { modal: Zt, confirm: (e, t = {}) => G.$onClick(rr, { content: e, ...t }, { placement: "center" }), form: (e, t = {}, n = {}) => Zt(Xr, { formProps: n, fields: e }, { placement: "center", ...t }).then((r) => { - if (r === !1) throw !1; - return r; -}), notification: pt, success: (e, t = { duration: 1.5 }) => pt(e, { ...t, className: "ff-notification-success", icon: "check" }), error: (e, t = { duration: 1.5 }) => pt(e, { ...t, className: "ff-notification-error", icon: "close" }) }; -Le.configure({ showSpinner: !1 }), Ve.interceptors.request.use((e) => { - e.headers.Platform = "web", e.headers.SaaS = window.localStorage.getItem("SaaS"); - const t = window.localStorage.getItem(Ze); - return e.headers.Authorization = t ? `Bearer ${t} ` : void 0, Le.inc(), e; -}, (e) => (Le.done(), Promise.reject({ code: -1, msg: e }))), Ve.interceptors.response.use(({ data: e, headers: t }) => (Le.done(), { ...e, res: t == null ? void 0 : t.res }), function(e) { - return Le.done(), Promise.reject(e.message); -}), window.addEventListener("unhandledrejection", ht.onUnhandledRejection), ht.onMsg = (e, t) => Y[[0, 1].includes(e) ? "success" : "error"](t).then(() => e === 20300 && ke.redirect(Ie.get("Common.WEBSITE_LOGIN_PAGE"))); -const Nt = { appUrl: "", init: (e, t, n) => { - Nt.appUrl = n, Ve.defaults.baseURL = n, Ve.defaults.timeout = 15e3, Object.assign(Nt, new ht(e, t, Ve)); -} }, j = Nt; -class jt extends Error { - constructor(t, n) { - super(n), Error.captureStackTrace && Error.captureStackTrace(this, jt), !n instanceof Me && (this.name = `${t} Error Runtime`); - } -} -class Me extends Error { - constructor(t, ...n) { - super(...n), Error.captureStackTrace && Error.captureStackTrace(this, Me), this.name = `${t} Not Found`; - } -} -const mt = "mine", Ze = "token"; -var Ce, Ae; -const le = class le { - constructor() { - E(this, Ae, /* @__PURE__ */ new Map()); - N(this, "setVendor", (t, n) => y(this, Ae).set(t, new rn(n, async (r, i) => { - var o, s; - if (!(r != null && r.default)) throw "@pkg not found"; - let a = () => i; - switch ("function") { - case typeof (a = (o = r.default) == null ? void 0 : o[`./${i}/index.jsx`]): - case typeof (a = (s = r.default) == null ? void 0 : s[`./${i}/index.js`]): - return a(); - } - throw new Me(i); - }))); - N(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 [, n] = t == null ? void 0 : t.split("@pkg/"); - if (!n) throw new Me(t); - try { - return y(this, Ae).has("pkg") ? await y(this, Ae).get("pkg").get(n) : await import(`${j.appUrl}/api/pkg-import/web?name=${t}`); - } catch (r) { - throw new jt(t, r); - } - }); - N(this, "getRoutes", () => j.get("/api/my-router").then((t) => [...t, { uuid: "data-list-setting", isLayout: !0, uri: "/data-list-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/DataListSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "grid-layout-setting", isLayout: !0, uri: "/grid-layout-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/GridLayoutSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "grid-layout-form-setting", isLayout: !0, uri: "/grid-layout-form-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/GridLayoutFormSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "resource-api-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ResourceApiSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "charts-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ChartsSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "fsm-setting", isLayout: !0, uri: "/fsm-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/FsmSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "component-setting", isLayout: !0, uri: "/component-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ComponentSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "login", uri: "/login", name: "登录", type: "fsdpf-component", isLogin: !1, component: "@pkg/ff/components/Login" }, { uuid: "not-found", uri: "*", name: "Not Found", type: "fsdpf-component", isLogin: !1, component: "@pkg/ff/components/NotFound" }].map(({ uuid: n, ...r }) => [n, { uuid: n, ...r }])).then((t) => new Map(t))); - N(this, "getMenus", () => j.get("/api/my-menu")); - N(this, "getConfigure", () => j.get("api/init-configure")); - N(this, "getWidgetOperationAuth", () => j.get("/api/init-widget-operation-auth").then((t) => t.reduce((n, { uuid: r, auth: i }) => [...n, [r, i]], []))); - N(this, "getPhoneNumber", (t) => j.get(`/api/user-wx-phone-number/${t}`)); - N(this, "getUserToken", () => { - const t = window.localStorage.getItem(Ze); - if (!t) return ""; - const n = t.split("."); - if (!Array.isArray(n) || n.length !== 3) throw "登录令牌无效!"; - const { iat: r } = JSON.parse(window.atob(n[1])); - if (Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - r > 2592e3) throw "登录令牌已过期, 请重新登录!"; - return t; - }); - N(this, "checkUserToken", () => { - try { - return !!this.getUserToken(); - } catch { - return !1; - } - }); - N(this, "getUserInfo", (t = !0) => { - var n; - try { - const r = this.getUserToken(); - if (!r) return Promise.resolve(null); - const { iat: i } = JSON.parse(window.atob((n = r == null ? void 0 : r.split(".")) == null ? void 0 : n[1])), { iat: a, ...o } = j.decode(window.localStorage.getItem(mt) || "", {}); - return a === i ? Promise.resolve(o) : j.get("/api/mine-info").then(({ User: s = null }) => (window.localStorage.setItem(mt, j.encode({ ...s, iat: i })), s)); - } catch (r) { - console.error(r), t && Y.error("请登录").then(this.logout); - } - return Promise.resolve(null); - }); - N(this, "login", (t, n, r = {}) => j.post("/api/user-token", { username: t, passwd: Mn.hash(n), platform: "web", ...r }).then(({ token: i }) => (window.localStorage.setItem(Ze, i), i))); - N(this, "logout", (t) => (window.localStorage.removeItem(mt), window.localStorage.removeItem(Ze), t == null ? void 0 : t())); - if (y(le, Ce)) return y(le, Ce); - } -}; -Ce = new WeakMap(), Ae = new WeakMap(), E(le, Ce, null), N(le, "getInstance", () => (y(le, Ce) || _(le, Ce, new le()), y(le, Ce))); -let Tt = le; -const ce = Tt.getInstance(), ei = x.createContext({ user: {}, initUser: () => { -}, initUserComplete: !1 }), ti = x.createContext({ set: () => { -}, get: () => { -}, assign: () => { -}, currentRoute: () => { -} }), At = (e) => !!(e != null && e.name) && (e.prototype instanceof x.Component || /^[A-Z]/.test(e.name)), ni = (e, t) => { - if (!e || typeof window > "u") return; - let n = document.querySelector(`style[ff-style-token="${t}"]`); - return n ? (n.innerHTML = e, e) : (n = document.createElement("style"), n.setAttribute("ff-style-token", t), n.setAttribute("type", "text/css"), n.innerHTML = e, document.head.appendChild(n), e); -}, ri = Object.freeze(Object.defineProperty({ __proto__: null, AppContext: ei, AppGlobalParamsContext: ti, cache: rn, configure: Ie, default: ce, func: xe, http: j, insertStyle: ni, isReactComponent: At, route: ke }, Symbol.toStringTag, { value: "Module" })); -export { - Vi as $, - Z as A, - Sr as B, - $r as C, - tt as D, - fr as E, - yr as F, - Oi as G, - vr as H, - ur as I, - gr as J, - Ti as K, - $i as L, - un as M, - Ct as N, - pr as O, - mr as P, - Fr as Q, - fn as R, - Or as S, - Ri as T, - Ei as U, - ot as V, - ji as W, - Ai as X, - Ke as Y, - Je as Z, - Li as _, - on as a, - Br as a0, - Et as a1, - Rt as a2, - xn as a3, - Er as a4, - jr as a5, - Ar as a6, - Lr as a7, - Vr as a8, - kn as a9, - Ir as aa, - Ii as ab, - Pt as ac, - P as ad, - ir as ae, - _r as af, - J as ag, - _e as ah, - an as ai, - G as aj, - Y as ak, - Ci as al, - ki as am, - xi as an, - ce as ao, - At as ap, - ni as aq, - j as ar, - rn as as, - Ie as at, - xe as au, - ke as av, - ei as aw, - ti as ax, - sr as b, - He as c, - ln as d, - vi as e, - Pi as f, - ar as g, - Ni as h, - or as i, - gn as j, - Fi as k, - hn as l, - lr as m, - wn as n, - Nr as o, - Pr as p, - yn as q, - gt as r, - mn as s, - ge as t, - Si as u, - pn as v, - xr as w, - kr as x, - br as y, - Ot as z -}; diff --git a/dist/components.js b/dist/components.js index fc1cc13..423690a 100644 --- a/dist/components.js +++ b/dist/components.js @@ -1,8 +1,8 @@ -import { al as s, ac as n, am as p, an as m, ak as t } from "./common/main-FyOEZueW.js"; +import { ao as p, af as s, ap as n, aq as t, an as d } from "./common/main-Bv6_dpPM.js"; export { - s as Empty, - n as Icon, - p as Loading, - m as NotFound, - t as Popup + p as Empty, + s as Icon, + n as Loading, + t as NotFound, + d as Popup }; diff --git a/dist/container.js b/dist/container.js index cedfea2..8df8204 100644 --- a/dist/container.js +++ b/dist/container.js @@ -1,9 +1,9 @@ -import { ah as o, al as s, am as n, an as p, ai as t, ak as d, aj as r, ag as u } from "./common/main-FyOEZueW.js"; +import { ak as e, ao as s, ap as p, aq as n, al as t, an as d, am as r, aj as u } from "./common/main-Bv6_dpPM.js"; export { - o as Context, + e as Context, s as Empty, - n as Loading, - p as NotFound, + p as Loading, + n as NotFound, t as PageRender, d as Popup, r as PopupRender, diff --git a/dist/data-converter.js b/dist/data-converter.js index acd8a80..2008ae3 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-FyOEZueW.js"; +import { D as p } from "./common/main-Bv6_dpPM.js"; export { p as default }; diff --git a/dist/data-list.js b/dist/data-list.js index 4681cda..22c09b7 100644 --- a/dist/data-list.js +++ b/dist/data-list.js @@ -1,4 +1,4 @@ -import { C as t, A as e, v as r, y as o, E as i, z as l, x as u, B as D, w as n, F as L, s as C, J as m, I as p, P as b, L as c, N as F, M as d, O, K as k } from "./common/main-FyOEZueW.js"; +import { J as t, F as e, z as r, C as o, K as i, E as l, B as u, I as D, A as n, L, y as C, N as m, M as p, U as b, P as c, S as F, Q as d, T as O, O as S } from "./common/main-Bv6_dpPM.js"; export { t as DataListContent, e as DataListContext, @@ -18,5 +18,5 @@ export { F as useHasOperationColumn, d as useItemOperationsAccess, O as useOperationCallback, - k as useStructure + S as useStructure }; diff --git a/dist/data-list/utils.js b/dist/data-list/utils.js index 2faa31a..e3da690 100644 --- a/dist/data-list/utils.js +++ b/dist/data-list/utils.js @@ -1,5 +1,5 @@ import "lodash"; -import { l as a } from "../common/main-FyOEZueW.js"; +import { n as a } from "../common/main-Bv6_dpPM.js"; export { a as getDefaultExpandRowKeys }; diff --git a/dist/grid-layout-form.js b/dist/grid-layout-form.js index 4d69ae5..79dd0ea 100644 --- a/dist/grid-layout-form.js +++ b/dist/grid-layout-form.js @@ -1,15 +1,15 @@ -import { a1 as e, a3 as r, a2 as u, a0 as o, a9 as t, a8 as m, a6 as F, a7 as d, ab as i, a5 as g, a4 as l, aa as n } from "./common/main-FyOEZueW.js"; +import { a5 as s, a7 as r, a6 as u, a4 as o, x as t, ac as m, aa as d, ab as F, ae as i, a9 as c, a8 as g, ad as l } from "./common/main-Bv6_dpPM.js"; export { - e as GridLayoutForm, + s as GridLayoutForm, r as GridLayoutFormHelper, u as GridLayoutFormWidget, o as default, t as useFnRun, m as useFormAction, - F as useFormData, - d as useFormSubmit, + d as useFormData, + F as useFormSubmit, i as useMergedFormValuesChange, - g as useRules, - l as useStructure, - n as useWidgetDecorator + c as useRules, + g as useStructure, + l as useWidgetDecorator }; diff --git a/dist/grid-layout-form/utils.js b/dist/grid-layout-form/utils.js index 7d6331f..cb1ad42 100644 --- a/dist/grid-layout-form/utils.js +++ b/dist/grid-layout-form/utils.js @@ -1,6 +1,6 @@ import "lodash"; -import { g as o, a as g } from "../common/main-FyOEZueW.js"; +import { a as o, g } from "../common/main-Bv6_dpPM.js"; export { - o as getOptionItemByValue, - g as getWidgetByNormalize + o as getNormalizeWidget, + g as getOptionItemByValue }; diff --git a/dist/grid-layout.js b/dist/grid-layout.js index cd257d2..e9dc10f 100644 --- a/dist/grid-layout.js +++ b/dist/grid-layout.js @@ -1,9 +1,12 @@ -import { n as d, o as e, H as i, G as o, p as t, q as u } from "./common/main-FyOEZueW.js"; +import { o as u, q as e, p as r, H as t, G as d, v as o, x as i, w as G, s as y } from "./common/main-Bv6_dpPM.js"; export { - d as GridLayout, - e as GridLayoutWidget, - i as HOOK_MARK, - o as default, - t as useField, - u as useGridLayoutFields + u as GridLayout, + e as GridLayoutFramework, + r as GridLayoutWidget, + t as HOOK_MARK, + d as default, + o as useField, + i as useFnRun, + G as useGridLayoutFields, + y as useStructure }; diff --git a/dist/grid-layout/utils.js b/dist/grid-layout/utils.js index 55e260d..eb10afb 100644 --- a/dist/grid-layout/utils.js +++ b/dist/grid-layout/utils.js @@ -1,5 +1,6 @@ -import { j as o, k as a } from "../common/main-FyOEZueW.js"; +import { j as a, l, k as o } from "../common/main-Bv6_dpPM.js"; export { - o as getBoxStyle, - a as getWidgetByNormalize + a as getBoxStyle, + l as getNormalizeFields, + o as getNormalizeWidget }; diff --git a/dist/hooks.js b/dist/hooks.js index 88850f1..6256efa 100644 --- a/dist/hooks.js +++ b/dist/hooks.js @@ -1,7 +1,7 @@ import "lodash"; import "rc-field-form"; import "react"; -import { Z as r, Y as o, _ as p, W as f, X as i, $ as m, V as c } from "./common/main-FyOEZueW.js"; +import { a1 as r, a0 as o, a2 as p, _ as f, $ as i, a3 as m, Z as c } from "./common/main-Bv6_dpPM.js"; import { default as b } from "rc-util/lib/hooks/useMergedState"; export { r as useDeepEffect, diff --git a/dist/iconfont.js b/dist/iconfont.js index 9c0517b..8d55ae3 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 { ac as a } from "./common/main-FyOEZueW.js"; +import { af as a } from "./common/main-Bv6_dpPM.js"; export { a as default }; diff --git a/dist/index.js b/dist/index.js index 6ea1a8d..9cbaed4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,10 +1,10 @@ -import { aw as t, ax as e, as as o, at as p, ao as n, au as r, ar as c, aq as u, ap as f, av as l } from "./common/main-FyOEZueW.js"; +import { az as t, aA as e, av as o, aw as n, ar as p, ax as r, au as c, at as u, as as f, ay as l } from "./common/main-Bv6_dpPM.js"; export { t as AppContext, e as AppGlobalParamsContext, o as cache, - p as configure, - n as default, + n as configure, + p as default, r as func, c as http, u as insertStyle, diff --git a/dist/pages.js b/dist/pages.js index c1ef417..a538dd2 100644 --- a/dist/pages.js +++ b/dist/pages.js @@ -1,4 +1,4 @@ -import { S as t, Q as e, T as o, U as g } from "./common/main-FyOEZueW.js"; +import { W as t, V as e, X as o, Y as g } from "./common/main-Bv6_dpPM.js"; export { t as CustomPage, e as DataListPage, diff --git a/dist/res-ws.js b/dist/res-ws.js index bd7baf2..13490a0 100644 --- a/dist/res-ws.js +++ b/dist/res-ws.js @@ -1,5 +1,5 @@ import "lodash"; -import { R as a } from "./common/main-FyOEZueW.js"; +import { R as a } from "./common/main-Bv6_dpPM.js"; export { a as default }; diff --git a/dist/utils.js b/dist/utils.js index 83c858f..affcb8b 100644 --- a/dist/utils.js +++ b/dist/utils.js @@ -1,5 +1,5 @@ import "lodash"; -import { d as r, f as i, e as g, h as m, b as o, c as p, i as P, m as d, r as k, t as u, u as h } from "./common/main-FyOEZueW.js"; +import { d as r, f as i, e as g, h as m, b as o, c as p, i as P, m as d, r as k, t as u, u as h } from "./common/main-Bv6_dpPM.js"; import "./common/vender-CtjyT19B.js"; export { r as deepSome, diff --git a/package.json b/package.json index 489c0e5..7560599 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ff", "private": true, - "version": "0.5.19", + "version": "0.6.0", "author": "www.fsdpf.com", "type": "module", "main": "./dist/index.js",