ff-dist/dist/common/main-hocekuUg.js

912 lines
70 KiB
JavaScript
Raw Normal View History

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