1563 lines
109 KiB
JavaScript
1563 lines
109 KiB
JavaScript
var $r = Object.defineProperty;
|
|
var mi = (t) => {
|
|
throw TypeError(t);
|
|
};
|
|
var Pr = (t, e, i) => e in t ? $r(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
var T = (t, e, i) => Pr(t, typeof e != "symbol" ? e + "" : e, i), fi = (t, e, i) => e.has(t) || mi("Cannot " + i);
|
|
var c = (t, e, i) => (fi(t, e, "read from private field"), i ? i.call(t) : e.get(t)), x = (t, e, i) => e.has(t) ? mi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), q = (t, e, i, r) => (fi(t, e, "write to private field"), r ? r.call(t, i) : e.set(t, i), i);
|
|
var yi = (t, e, i, r) => ({
|
|
set _(n) {
|
|
q(t, e, n, i);
|
|
},
|
|
get _() {
|
|
return c(t, e, r);
|
|
}
|
|
});
|
|
import { jsx as m, jsxs as I } from "react/jsx-runtime";
|
|
import E, { useEffect as U, useState as A, useCallback as _, useRef as J, useContext as ge, useMemo as K, useId as Vt, isValidElement as xr, useLayoutEffect as vr } from "react";
|
|
import me from "pathe";
|
|
import b from "prop-types";
|
|
import F from "classnames";
|
|
import { useNotification as Nr } from "rc-notification";
|
|
import f from "lodash";
|
|
import oe, { Field as Qt, FieldContext as Fi } from "rc-field-form";
|
|
import { useMountedState as Tr, useDeepCompareEffect as Zt, useUpdateEffect as ji, usePrevious as Ai } from "react-use";
|
|
import { _ as Or, M as Lt, N as tt, b as Ve, i as zt, c as Rr, S as Fr } from "./vender-hQk7ADWo.js";
|
|
import jr from "rc-util/lib/hooks/useMergedState";
|
|
import Li from "immutability-helper";
|
|
import { Space as Ar, Form as wt, Input as Lr, Button as Ct, Pagination as Ir, Tree as Mr, Breadcrumb as Dr, Empty as Bt, Table as wi, Popover as Vr, Popconfirm as zr, Tooltip as Br } from "antd";
|
|
import { useMergedState as Wr } from "rc-util";
|
|
import { generatePath as Ur, useInRouterContext as Ii, useParams as qr, useLocation as Kr, createBrowserRouter as Hr, Navigate as Jr } from "react-router-dom";
|
|
import _r from "rc-drawer";
|
|
import Yr from "rc-dialog";
|
|
import * as bi from "react-is";
|
|
var He, rt, Je, Pe, ze, Be;
|
|
class Mi {
|
|
constructor(e, i) {
|
|
x(this, He, /* @__PURE__ */ new Map());
|
|
x(this, rt, !0);
|
|
x(this, Je, []);
|
|
x(this, Pe);
|
|
x(this, ze, () => c(this, Pe));
|
|
x(this, Be, () => Promise.resolve());
|
|
T(this, "get", (...e) => new Promise((i, r) => {
|
|
const n = JSON.stringify(e);
|
|
if (c(this, He).has(n)) return i(c(this, Be).call(this, c(this, Pe), ...e));
|
|
if (c(this, Pe) === void 0) c(this, Je).push([e, i, r]), c(this, rt) && (q(this, rt, !1), Promise.resolve(typeof c(this, ze) == "function" ? c(this, ze).call(this) : c(this, ze)).then((o) => q(this, Pe, o || null)).finally(() => {
|
|
c(this, Je).forEach(([o, a, s]) => {
|
|
try {
|
|
const l = c(this, Be).call(this, c(this, Pe), ...o);
|
|
c(this, He).set(JSON.stringify(o), l), a(l);
|
|
} catch (l) {
|
|
s(l);
|
|
}
|
|
}), c(this, Je).length = 0;
|
|
}));
|
|
else {
|
|
const o = c(this, Be).call(this, c(this, Pe), ...e);
|
|
c(this, He).set(n, o), i(o);
|
|
}
|
|
}));
|
|
q(this, Be, i), q(this, ze, e);
|
|
}
|
|
}
|
|
He = new WeakMap(), rt = new WeakMap(), Je = new WeakMap(), Pe = new WeakMap(), ze = new WeakMap(), Be = new WeakMap();
|
|
const So = () => m("div", { children: "Empty" }), ht = E.createContext({ ele: {}, mount: () => {
|
|
}, unmount: () => {
|
|
} }), ee = ({ rootClassName: t, className: e, children: i, actions: r, title: n, subTitle: o, extras: a, style: s = {} }) => {
|
|
const { mount: l, unmount: d } = E.useContext(ht);
|
|
return ee.Action({ children: r }), ee.Title({ children: n }), ee.SubTitle({ children: o }), ee.Extra({ children: a }), U(() => (l("rootClassName", t), () => d(t)), [t]), m("div", { className: F("ff-container", e), style: s, children: i });
|
|
}, yt = (t) => ({ children: e, className: i }) => {
|
|
const { mount: r, unmount: n } = E.useContext(ht);
|
|
return U(() => (e && r(t, E.createElement("div", { key: `ff-${t}`, className: F(`ff-popup-${t}`, i) }, e)), () => n(t)), [i, e]), null;
|
|
};
|
|
ee.Action = yt("actions"), ee.Title = yt("title"), ee.SubTitle = yt("sub-title"), ee.Extra = yt("extras"), ee.propTypes = { className: b.string, style: b.object, title: b.any, subTitle: b.any, actions: b.any, extras: b.any };
|
|
const Eo = () => m(ee, { className: "ff-loading", children: I("div", { className: "loader", children: [I("div", { className: "square", children: [m("span", {}), m("span", {}), m("span", {})] }), I("div", { className: "square", children: [m("span", {}), m("span", {}), m("span", {})] }), I("div", { className: "square", children: [m("span", {}), m("span", {}), m("span", {})] }), I("div", { className: "square", children: [m("span", {}), m("span", {}), m("span", {})] })] }) }), $o = () => m("div", { children: "NotFound" }), Di = ({ children: t }) => {
|
|
const [e, i] = A({}), r = _((o, a) => i((s) => ({ ...s, [o]: a })), []), n = _((o) => i((a) => ({ ...a, [o]: void 0 })), []);
|
|
return typeof (t == null ? void 0 : t.type) == "string" ? t : m(ht.Provider, { value: { ele: e, mount: r, unmount: n }, children: E.cloneElement(t, { className: e.rootClassName, title: e.title, subTitle: e["sub-title"], actions: e.actions, extras: e.extras }) });
|
|
};
|
|
Di.propTypes = { children: b.element.isRequired };
|
|
const Ci = { 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"] }, ei = ({ type: t, props: e }) => m("i", { ...e, children: m("svg", { viewBox: "0 0 1024 1024", width: "1em", height: "1em", fill: "currentColor", children: (Ci[t] || Ci.info).map((i, r) => m("path", { d: i }, r)) }) }), Vi = ({ className: t, content: e, icon: i, $close: r }) => I(E.Fragment, { children: [i && m("div", { className: F("ff-notification-icon", t), children: m(ei, { type: i }) }), e] }), Gr = ({}) => m(ee, { children: "Confirm" });
|
|
var Oe, _e;
|
|
const fe = class fe {
|
|
constructor() {
|
|
x(this, _e, /* @__PURE__ */ new Map());
|
|
T(this, "init", (e) => q(this, _e, new Map(e)));
|
|
T(this, "check", (e) => !c(this, _e).has(e) || c(this, _e).get(e));
|
|
if (c(fe, Oe)) return c(fe, Oe);
|
|
}
|
|
};
|
|
Oe = new WeakMap(), _e = new WeakMap(), x(fe, Oe, null), T(fe, "getInstance", () => (c(fe, Oe) || q(fe, Oe, new fe()), c(fe, Oe)));
|
|
let Wt = fe;
|
|
const zi = Wt.getInstance(), Xr = (t, e, i = "children") => {
|
|
if (f.isEmpty(t)) return {};
|
|
const r = f.find(t, ["value", e]);
|
|
if (!f.isEmpty(r)) return r;
|
|
const n = t.length;
|
|
for (let o = 0; o < n; o++) {
|
|
const { [i]: a } = t[o], s = Xr(a, e, i);
|
|
if (!f.isEmpty(s)) return s;
|
|
}
|
|
return {};
|
|
}, Bi = (t = "Input", e = "@pkg/ff/grid-layout-forms") => t != null && t.startsWith("@") || t != null && t.startsWith("blob:") ? t : `${e}/${t}`;
|
|
var Re, nt;
|
|
const ye = class ye {
|
|
constructor() {
|
|
x(this, nt, null);
|
|
T(this, "init", (e) => q(this, nt, e));
|
|
T(this, "get", (e, i) => f.get(c(this, nt), e, i));
|
|
if (c(ye, Re)) return c(ye, Re);
|
|
}
|
|
};
|
|
Re = new WeakMap(), nt = new WeakMap(), x(ye, Re, null), T(ye, "getInstance", () => (c(ye, Re) || q(ye, Re, new ye()), c(ye, Re)));
|
|
let Ut = ye;
|
|
const qe = Ut.getInstance();
|
|
var Ye, Et, ot, at, $t;
|
|
const Te = class Te {
|
|
constructor(...e) {
|
|
x(this, ot, []);
|
|
x(this, at, (e) => {
|
|
var i;
|
|
for (let r of e) Array.isArray(r[0]) ? c(this, at).call(this, r) : c(this, ot).push(c(i = Te, Et).call(i, r[0], r[1]));
|
|
});
|
|
T(this, "toValue", async (e, i = null) => {
|
|
const r = { getValue: () => e, getRecord: () => i };
|
|
let n = e;
|
|
for (const o of c(this, ot)) try {
|
|
const a = await o;
|
|
if (typeof a != "function") {
|
|
console.warn("middleware is not a function, skip:", a);
|
|
continue;
|
|
}
|
|
n = await a.call(r, n);
|
|
} catch (a) {
|
|
console.error("middleware error, skip:", a);
|
|
}
|
|
return n;
|
|
});
|
|
T(this, "toRender", (e, i, r = null) => E.createElement(c(this, $t), { value: e, record: i }, r));
|
|
x(this, $t, ({ value: e, record: i, children: r }) => {
|
|
const [n, o] = A(r), a = Tr();
|
|
return Zt(() => {
|
|
o(r), this.toValue(e, i).then((s) => a() && o(s)).catch((s) => a() && o(`${s}`));
|
|
}, [e, i]), n;
|
|
});
|
|
c(this, at).call(this, e);
|
|
}
|
|
};
|
|
Ye = new WeakMap(), Et = new WeakMap(), ot = new WeakMap(), at = new WeakMap(), $t = new WeakMap(), x(Te, Ye, null), x(Te, Et, f.memoize((e, i) => {
|
|
if (typeof e == "function") return e(i);
|
|
if (typeof e == "string") return se.getWidgetComponent(e).then((r) => {
|
|
var n;
|
|
return ((n = r.default) == null ? void 0 : n.call(r, i)) || ((o) => o);
|
|
});
|
|
throw new TypeError("middleware must be a string or a function");
|
|
}, (...e) => {
|
|
var i;
|
|
return c(Te, Ye) || q(Te, Ye, xn()), c(i = Te, Ye).call(i, ...e);
|
|
}));
|
|
let kt = Te;
|
|
const le = E.createContext({ listCode: "", classNames: {}, getBase62params: (t, e) => {
|
|
}, getSelectedRows: () => [], onReload: () => {
|
|
}, onClickCallback: () => {
|
|
}, onConditionChange: () => {
|
|
}, onTabChange: () => {
|
|
}, onSiderChange: () => {
|
|
}, onKeywordChange: () => {
|
|
}, onPageChange: () => {
|
|
}, onPageSizeChange: () => {
|
|
}, reload: () => {
|
|
}, setPage: () => {
|
|
}, setPageSize: () => {
|
|
}, setTab: () => {
|
|
}, setSider: () => {
|
|
}, setKeyword: () => {
|
|
}, setCondition: () => {
|
|
} }), ki = ({ className: t, record: e, column: i, ...r }) => {
|
|
if (i != null && i.editableByJs && (i != null && i.uuid)) {
|
|
const { formSetting: n = { primaryKey: "id" }, widgetSetting: o = {}, widgetContainerSetting: a = {} } = (i == null ? void 0 : i.editableByJsSetting) || {};
|
|
return m(O.Popover, { widget: Wi, widgetData: { record: e, column: i }, widgetSetting: { widgetSetting: o, formSetting: n }, widgetContainerProps: { title: i != null && i.title ? `${i.title} - 编辑` : "编辑", ...a, width: (a == null ? void 0 : a.width) || 260, arrow: !0 }, children: m("td", { className: F("ff-data-list-cell-editable", t), ...r }) });
|
|
}
|
|
return m("td", { className: t, ...r });
|
|
}, Wi = ({ record: t, column: e, $close: i, $setting: r }) => {
|
|
const n = J($n(f.get(t, e == null ? void 0 : e.dataIndex))), { listCode: o, onClickCallback: a } = ge(le), [s] = oe.useForm(), { formSetting: l, widgetSetting: d } = r, { primaryKey: u = "id", help: p, validators: h } = l || {}, g = () => {
|
|
s.setFieldsValue({ value: f.get(t, e == null ? void 0 : e.dataIndex), __PROPS__: t });
|
|
};
|
|
return Ot(() => g(), [t, e == null ? void 0 : e.dataIndex, o]), m(ee, { actions: I(E.Fragment, { children: [m(O, { size: "small", onClick: g, children: "重置" }), I(Ar.Compact, { block: !0, children: [m(O, { size: "small", widget: i, children: "取消" }), m(O, { type: "primary", size: "small", widget: () => s.validateFields().then(({ value: y }) => {
|
|
const w = f.get(t, u.substring(u.indexOf(".") + 1));
|
|
if (!w) throw "获取更新主键失败!";
|
|
z.put(`/api/${o}-storeBy-${e == null ? void 0 : e.uuid}/${w}`, { value: y }).msg(() => a(2, t)).then(i);
|
|
}).catch(console.warn), children: "保存" })] })] }), children: I(oe, { form: s, children: [m(ri, { label: "", code: "value", type: n.current, widget: e == null ? void 0 : e.editableByJs, help: p, extras: d, validators: h }), m(Qt, { noStyle: !0, name: ["__PROPS__"], children: () => {
|
|
} })] }) });
|
|
};
|
|
Wi.displayName = "DataListCellEditableContainer";
|
|
const Qr = (t) => function(e) {
|
|
return t(e, getRecord());
|
|
}, Zr = async ({ widgetByJs: t, widgetByJsSetting: e }) => {
|
|
const i = await se.getWidgetComponent(t).then((r) => r.default || ((n) => n));
|
|
return function(r) {
|
|
return m(i, { value: r, $setting: e });
|
|
};
|
|
}, en = (t, e = {}) => K(() => {
|
|
var i;
|
|
return (i = t == null ? void 0 : t.filter(Boolean)) == null ? void 0 : i.map(({ widgetByJs: r, widgetByJsSetting: n, middlewares: o, ...a }, s) => {
|
|
const l = (d) => ({ record: d, column: a });
|
|
return o || (o = []), r && o.push([Zr, { widgetByJs: r, widgetByJsSetting: n }]), o.length > 0 ? (a != null && a.render && o.push([Qr, a.render]), { ...a, onCell: l, render: (d, u) => new kt(o).toRender(d, u, "-") }) : { ...a, onCell: l };
|
|
});
|
|
}, [t, e]), tn = (t = {}) => K(() => {
|
|
var e;
|
|
return t.body ?? (t.body = { cell: ki }), (e = t.body).cell ?? (e.cell = ki), t;
|
|
}, [t]), Po = (t) => {
|
|
const [e, i] = A({});
|
|
return U(() => {
|
|
let r = !1;
|
|
return t && z.get(`/api/_/${t}`).then((n) => f.pick(n, ["uuid", "name", "code", "resource", "marginX", "marginY", "cols", "rowHeight", "primaryKey", "columns", "itemOperations", "batchOperations", "isConditionFormLayout", "layout", "tabs", "pageSize", "layoutConfig", "selectionType"])).then((n) => !r && i(n)), () => r = !0;
|
|
}, [t]), e;
|
|
}, xo = (t, e = {}) => {
|
|
const [i, r] = A({ dataSource: [] });
|
|
return mt(() => {
|
|
let n = !1;
|
|
return t && z.get(`/api/${t}/${z.encode({ page: 1, ...e })}`).then((o) => !n && r(o)), () => n = !0;
|
|
}, [t, e]), i;
|
|
}, Ui = (t = [], e = /* @__PURE__ */ new Map(), i = "id", r) => {
|
|
const n = _(r ? (o) => f.get(o, i, f.get(o, [r, i])) : (o) => f.get(o, i), [i, r]);
|
|
return _((o) => t == null ? void 0 : t.filter((a) => !a.uuid || !e.has(a.uuid) || e.get(a.uuid).some((s) => s == n(o))), [t, e, n]);
|
|
}, qt = (t = [], e = /* @__PURE__ */ new Map(), i = [], r = "id", n) => {
|
|
const o = _(n ? (a) => f.get(a, r, f.get(a, [n, r])) : (a) => f.get(a, r), [r, n]);
|
|
return K(() => {
|
|
if (f.isEmpty(t) || !t.some(({ uuid: s }) => zi.check(s))) return !1;
|
|
if (f.isEmpty(e) || f.isEmpty(i)) return !0;
|
|
const a = i.map((s) => o(s));
|
|
return t.some(({ uuid: s }) => !s || !e.has(s) || e.get(s).some((l) => a.some((d) => d == l)));
|
|
}, [t, i, e, o]);
|
|
}, rn = (t, e, i = "id", r = null) => {
|
|
const n = Tt(), o = J(!1), a = J(t.dataSource), s = J(t.itemOperationsAccess);
|
|
return U(() => (a.current = t.dataSource, s.current = t.itemOperationsAccess, () => o.current = !1), [t.dataSource, t.itemOperationsAccess]), o.current && (t.dataSource = a.current, t.itemOperationsAccess = s.current), [t, (l = 0, d = null) => {
|
|
var u, p;
|
|
if (o.current = !1, l === 1) return (u = t.onReload) == null ? void 0 : u.call(t);
|
|
if (l === 2) {
|
|
const h = f.get(d, "__PARENT_ID__", ""), g = f.get(d, i, f.get(d, [r, i], "")), y = f.findIndex(a.current, ["__PARENT_ID__", h]), w = f.findIndex(y > -1 ? f.get(a.current, [y, "children"]) : a.current, [i, g]);
|
|
if (w === -1) return (p = t.onReload) == null ? void 0 : p.call(t);
|
|
Promise.all([z.get(`/api/${e}/detail/${g}`), z.post(`/api/${e}/list-operations-access`, { ids: g })]).then(([C, S]) => {
|
|
const P = f.get(a.current, y > -1 ? [y, "children", w, "children"] : [w, "children"]);
|
|
a.current = Li(a.current, y > -1 ? { [y]: { children: { $splice: [[w, 1, { ...C, children: P }]] } } } : { $splice: [[w, 1, { ...C, children: P }]] });
|
|
const k = new Map(S);
|
|
s.current.forEach(($, R) => {
|
|
var L;
|
|
(L = k.get(R)) != null && L.some((v) => v == g) || s.current.set(R, $.filter((v) => v !== g));
|
|
}), k.forEach(($, R) => {
|
|
s.current.has(R) ? s.current.set(R, f.uniq([...s.current.get(R) || [], ...$])) : s.current.set(R, $);
|
|
});
|
|
}).then(() => {
|
|
o.current = !0, n();
|
|
});
|
|
}
|
|
}];
|
|
}, nn = (t, e) => {
|
|
const i = Tt(), r = J(e), n = J(/* @__PURE__ */ new Map()), o = J([]), a = f.throttle((l) => {
|
|
o.current = [], z.list(t, f.pick({ ...r.current, ...l }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: d, condition: u, total: p, tab: h, sider: g, page: y, pageSize: w, operationsAccess: C, dataSource: S }) => {
|
|
r.current = { tab: h, condition: u, sider: g, keyword: d, total: p, pageSize: w, page: S != null && S.length ? y : 1 }, o.current = S, n.current = new Map(C), i();
|
|
});
|
|
}, 380, { leading: !1, trailing: !0 });
|
|
Ot(() => {
|
|
o.current = [], t && a(e);
|
|
}, [t, e]);
|
|
const s = K(() => f.pick(r.current, ["total", "tab", "page", "pageSize", "condition", "sider", "keyword"]), [r.current]);
|
|
return Object.assign(s, { onTabChange: (l) => a({ tab: l, page: 1 }), onPageChange: (l, d) => a({ page: l, pageSize: d }), onPageSizeChange: (l) => a({ pageSize: l, page: 1 }), onConditionChange: (l, d) => a({ keyword: d, condition: Li(r.current.condition || {}, { $merge: l || {} }), page: 1 }), onSiderChange: (l) => a({ sider: l, page: 1 }), onKeywordChange: (l) => a({ keyword: l, page: 1 }), itemOperationsAccess: n.current, dataSource: o.current, onReload: a, payload: e == null ? void 0 : e.payload });
|
|
}, on = ({ listCode: t, className: e, layouts: i = {}, dataSource: r, isPaginate: n, isItemOperations: o, isBatchOperations: a, batchOperations: s, itemOperations: l, itemOperationsAccess: d, resource: u, primaryKey: p, title: h, itemGridLayout: g, $setting: y, tabs: w, isConditionFormLayout: C, isTreeSider: S, treeSiderConfig: P, rowSelection: k }) => {
|
|
const { classNames: $, onClickCallback: R } = ge(le), L = f.pick(y, ["column", "colWidth", "beforeRender", "afterRender", "style"]), v = Ui(l, d, p, u), j = _((D, N, M) => m(an, { className: F("ff-data-list-framework-item", $ == null ? void 0 : $.item), operations: o ? v(N) : [], data: u ? { [u]: N } : N, children: D, onClickCallback: R }), [u, p, o, R, l, d]);
|
|
return I("div", { className: F("ff-data-list-framework", e), children: [m(i.sider, { isTreeSider: S, ...P }), I("div", { className: F("ff-data-list-container", $ == null ? void 0 : $.container), children: [m(i.filter, { isConditionFormLayout: C }), m(i.toolbar, { title: h, tabs: w }), m(Cn, { ...L, ...g, rowSelection: k, empty: m(i.empty, { className: $ == null ? void 0 : $.empty }), primaryKey: p, itemRender: j, dataSource: r }), m(i.footer, { isPaginate: n, isOperations: a, operations: s })] })] });
|
|
}, an = ({ className: t, operations: e, children: i, data: r, onClickCallback: n, onSelect: o, isSelected: a }) => I("div", { className: F("data-list-grid-layout-item", { "is-selected": a }, t), onClick: o, children: [m("div", { className: "data-list-grid-layout-item-container", children: i }), !!(e != null && e.length) && m("div", { className: "data-list-grid-layout-item-actions", children: e.map((s) => m("span", { className: "data-list-grid-layout-item-action", children: m(O.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: r, confirm: s.confirm, onAfterClick: (l) => l !== !1 && (n == null ? void 0 : n(s.isRefresh, r)) }, s.uuid || Vt()) }, (s == null ? void 0 : s.uuid) || Vt())) })] }), sn = ({ listCode: t, className: e, layouts: i = {}, dataSource: r, columns: n, isItemOperations: o, isBatchOperations: a, batchOperations: s, itemOperations: l, itemOperationsAccess: d, resource: u, primaryKey: p, title: h, tabs: g, isPaginate: y, rowSelection: w, isTreeSider: C, treeSiderConfig: S, isConditionFormLayout: P, ...k }) => {
|
|
const { classNames: $, onClickCallback: R } = ge(le), L = Ui(l, d, p, u), v = qt(l, d, r, p, u);
|
|
return I("div", { className: F("ff-data-table-framework", e), children: [m(i.sider, { isTreeSider: C, ...S }), I("div", { className: F("ff-data-table-container", $ == null ? void 0 : $.container), children: [m(i.filter, { isConditionFormLayout: P }), m(i.toolbar, { title: h, tabs: g }), m(hn, { ...k, primaryKey: p, className: "ff-data-table-content", columns: n, dataSource: r, rowSelection: w, operationRender: v ? (j) => {
|
|
var D;
|
|
return m("div", { className: "ff-data-table-actions", children: (D = L(j)) == null ? void 0 : D.map((N, M) => m(O.Link, { size: "small", uuid: N.uuid, type: N.type, name: N.name, widget: N.widget, widgetType: N.widgetType, widgetProps: N.widgetProps, widgetData: N.widgetData, widgetSetting: N.widgetSetting, widgetContainerProps: N.widgetContainerSetting, data: j, confirm: N.confirm, onAfterClick: (V) => V !== !1 && (R == null ? void 0 : R(N.isRefresh, j)) }, N.uuid || M)) });
|
|
} : null }), m(i.footer, { isPaginate: y, isOperations: a, operations: s })] })] });
|
|
}, ti = (t = [], e, i = null) => {
|
|
var r;
|
|
return (r = f.sortBy(t, ["y", "x"])) == null ? void 0 : r.map(({ i: n, x: o, y: a, w: s, h: l, field: { boxStyle: d, ...u } = {} }, p) => m("div", { className: "grid-layout-item", style: qi(o, a, s, l, d), children: m(e, { ...u, basicForm: i }) }, n ?? p));
|
|
}, qi = (t, e, i, r, n = {}, o = 0) => {
|
|
const a = { "--grid-layout-h": `${r}`, "--grid-layout-w": `${i}`, "--grid-layout-x": `${t}`, "--grid-layout-y": `${e}`, "--grid-layout-row-height-offset": "0px" };
|
|
return n != null && n.autoHeight ? a.height = "fit-content" : a["--grid-layout-row"] = `${r}`, n != null && n.alignItems && (a["--grid-layout-box-align-items"] = n.alignItems), n != null && n.justifyContent && (a["--grid-layout-box-justify-content"] = n.justifyContent), a["--grid-layout-box-margin"] = Si(n == null ? void 0 : n.marginTop, n == null ? void 0 : n.marginRight, n == null ? void 0 : n.marginBottom, n == null ? void 0 : n.marginLeft), a["--grid-layout-box-padding"] = Si(n == null ? void 0 : n.paddingTop, n == null ? void 0 : n.paddingRight, n == null ? void 0 : n.paddingBottom, n == null ? void 0 : n.paddingLeft), o && (a.height = `${o}px`), a;
|
|
}, Si = (t, e, i, r) => `${t || 0}px ${e || 0}px ${i || 0}px ${r || 0}px`, vo = (t = "Text", e = "@pkg/ff/grid-layouts") => t != null && t.startsWith("@") || t != null && t.startsWith("blob:") ? t : `${e}/${t}`, Ki = (t) => Object.keys(t).reduce((e, i) => (/^on[A-Z]/.test(i) && (e[i] = t[i]), e), {}), Hi = ({ className: t, isConditionFormLayout: e }) => {
|
|
var h, g;
|
|
const [i, r] = A({}), { listCode: n, onKeywordChange: o, onConditionChange: a, getBase62params: s, classNames: l } = E.useContext(le), { keyword: d, condition: u } = (s == null ? void 0 : s()) || {}, [p] = wt.useForm();
|
|
return U(() => {
|
|
n && e && z.get(`/api/_/${n}/list-condition-form-layout`).then(({ resource: y, marginX: w, marginY: C, rowHeight: S, cols: P, fields: k }) => {
|
|
r({ resource: y, itemMargin: [w, C], rowHeight: S, cols: P, fields: k });
|
|
}).catch(() => r({}));
|
|
}, [n, e]), U(() => {
|
|
p.setFieldsValue({ keyword: d, ...u });
|
|
}, [JSON.stringify([d, u])]), m("div", { className: F("ff-data-list-filter", l.filter, t), children: m(wt, { form: p, layout: "vertical", autoComplete: "off", onFinish: ((h = i.fields) == null ? void 0 : h.length) > 1 ? (y) => a({ [i.resource]: y[i.resource] }, y.keyword) : () => {
|
|
}, onValuesChange: (y) => {
|
|
f.isEmpty(f.omit(y, ["keyword"])) || p.submit();
|
|
}, children: ((g = i.fields) == null ? void 0 : g.length) > 1 ? m(ni, { ...i, children: m(ln, { onReset: () => {
|
|
const { keyword: y, condition: w } = s("init") || {};
|
|
p.setFieldsValue({ keyword: y, ...w });
|
|
} }) }) : m("div", { className: "ff-data-list-filter-default-form ff-grid-layout-form", children: m("div", { className: "grid-layout-item", style: qi(20, 0, 5, 2), children: m(wt.Item, { name: ["keyword"], children: m(Lr.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (y) => o(y) }) }) }) }) }) });
|
|
}, ln = ({ cols: t, fields: e, onReset: i }) => {
|
|
const [r, n] = A(!1), o = K(() => e == null ? void 0 : e.toReversed().some((a) => a.y > 1 || a.x + a.w >= t - 5), [t, e]);
|
|
return I(wt.Item, { label: " ", style: { "--item-span": 5 }, className: F("ff-data-list-filter-actions", { expanded: r }), children: [m(Ct, { onClick: i, children: "重置" }), m(Ct, { type: "primary", htmlType: "submit", children: "查询" }), o && m(O.Link, { className: "ff-data-list-filter-expanded-button", widget: () => n((a) => !a), type: "primary", name: r ? "关闭" : "展开", icon: r ? "icon-up" : "icon-down", iconPosition: "end" })] });
|
|
};
|
|
Hi.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 cn = ({ className: t, operations: e, isOperations: i, isPaginate: r }) => {
|
|
const { onPageChange: n, onPageSizeChange: o, onClickCallback: a, getBase62params: s } = E.useContext(le), { total: l, page: d, pageSize: u } = (s == null ? void 0 : s()) || {};
|
|
return i && !f.isEmpty(e) || r ? I("div", { className: F("ff-data-list-footer", t), children: [m("div", { className: "ff-data-list-actions", children: e == null ? void 0 : e.map((p, h) => m(O, { 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: (g) => g !== !1 && (a == null ? void 0 : a(p.isRefresh, null)) }, p.uuid || h)) }), r && m(Ir, { size: "small", total: l, pageSize: u, showSizeChanger: !1, showTotal: (p) => `第 ${d} 页 / 总共 ${p} 条`, onChange: n, onShowSizeChange: o })] }) : null;
|
|
}, dn = [{ 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: m("span", { style: { color: "#1677ff" }, children: "sss" }), key: "0-0-1-0" }] }] }], un = ({ className: t, width: e = 280, isTreeSider: i }) => {
|
|
const { classNames: r } = ge(le);
|
|
return i ? m(Mr.DirectoryTree, { className: F("ff-data-list-sider", r.sider, t), style: { "--sider-width": e }, showLine: !0, showIcon: !1, treeData: dn }) : null;
|
|
}, pn = ({ className: t, title: e, tabs: i }) => {
|
|
const { getBase62params: r, onTabChange: n, onReload: o, classNames: a } = ge(le), { tab: s } = (r == null ? void 0 : r()) || {}, [l, d] = Wr((i == null ? void 0 : i[0].value) ?? (i == null ? void 0 : i[0].code), { value: s, onChange: n });
|
|
return I("div", { className: F("ff-data-list-toolbar", a.toolbar, t), children: [m("div", { className: "ff-data-list-title", children: e }), m(Dr, { className: "ff-data-list-tabs", itemRender: ({ label: u, code: p, value: h }) => m("span", { onClick: () => d(h ?? p), className: F("ff-data-list-tab", { active: (h ?? p) == l }), children: u }), items: i }), I("div", { className: "ff-data-list-actions", children: [m(O.Link, { icon: "icon-reload", widget: () => o() }), m(O.Link, { icon: "icon-setting" })] })] });
|
|
}, gn = ({ className: t, ...e }) => m(Bt, { className: F(t, "ff-data-list-empty"), image: Bt.PRESENTED_IMAGE_SIMPLE, ...e }), Ji = ({ isItemGridLayout: t, theme: e, themeProps: i, onClickCallback: r, onReload: n, listCode: o, total: a = 0, page: s = 0, onPageChange: l, pageSize: d = 30, onPageSizeChange: u, tab: p, onTabChange: h, keyword: g, onKeywordChange: y, condition: w, onConditionChange: C, sider: S, onSiderChange: P, layouts: k, classNames: $ = {}, payload: R = {}, dataSource: L = [], rowSelection: v, getSelectedRows: j, primaryKey: D, ...N }) => {
|
|
const [M, V] = A(), B = j ?? (() => L), he = _((W, ce) => {
|
|
const Y = { tab: p, page: s, pageSize: d, keyword: g, sider: S, condition: w, total: a, payload: R };
|
|
return W && W != "init" ? f.get(Y, W, ce) : Y;
|
|
}, [JSON.stringify(w), JSON.stringify(R), p, s, d, g, S, a]), ae = K(() => {
|
|
let W = { sider: un, filter: Hi, footer: cn, toolbar: pn, empty: gn };
|
|
k === !1 ? W = { sider: null, filter: null, footer: null, toolbar: null, empty: null } : f.isPlainObject(k) && (W = Object.assign({}, W, k));
|
|
for (const ce in W) if (W[ce]) {
|
|
if (xr(W[ce])) {
|
|
const Y = W[ce];
|
|
W[ce] = (Ft) => E.cloneElement(Y, Ft);
|
|
}
|
|
} else W[ce] = () => m(E.Fragment, {});
|
|
return W;
|
|
}, [k]);
|
|
return U(() => {
|
|
e ? se.getWidgetComponent(e).then((W) => {
|
|
if (!W) throw `${e} not found`;
|
|
return W;
|
|
}).catch((W) => ({ default: () => `${W}` })).then((W) => V(E.createElement(W.default, { ...N, layouts: ae, $setting: i }))) : V(m(t ? on : sn, { ...N, layouts: ae, $setting: i }));
|
|
}, [e, i]), m(le.Provider, { value: { classNames: $, listCode: o, onClickCallback: r, onReload: n, getBase62params: he, onPageChange: l, onPageSizeChange: u, onTabChange: h, onSiderChange: P, onKeywordChange: y, onConditionChange: C, setPage: l, setPageSize: u, setTab: h, setSider: P, setKeyword: y, setCondition: C, getSelectedRows: B }, children: M && E.cloneElement(M, { dataSource: L, primaryKey: D, rowSelection: v, ...N }) });
|
|
};
|
|
Ji.propTypes = { classNames: b.exact({ sider: b.string, filter: b.string, footer: b.string, toolbar: b.string, container: b.string, content: b.string, item: b.string, empty: b.string }), layouts: b.oneOfType([b.exact({ sider: b.oneOfType([b.elementType, b.element]), filter: b.oneOfType([b.elementType, b.element]), footer: b.oneOfType([b.elementType, b.element]), toolbar: b.oneOfType([b.elementType, b.element]), empty: b.oneOfType([b.elementType, b.element]) }), b.bool]) };
|
|
var Fe, xe, We, Pt;
|
|
const we = class we {
|
|
constructor() {
|
|
x(this, xe, null);
|
|
x(this, We, /* @__PURE__ */ new Map());
|
|
x(this, Pt, () => {
|
|
if (c(this, xe)) return c(this, xe).port.postMessage({ command: "status", data: [] });
|
|
q(this, xe, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), c(this, xe).port.onmessage = (e) => {
|
|
var i, r;
|
|
(i = e.data) != null && i.uuid ? c(this, We).forEach((n, o) => {
|
|
var a;
|
|
(n == "*" || (a = n == null ? void 0 : n.includes) != null && a.call(n, e.data.uuid)) && o(e.data);
|
|
}) : ((r = e.data) == null ? void 0 : r.readyState) == WebSocket.CLOSED && z.get("/api/user-api-token").then(({ token: n, expire_at: o }) => {
|
|
c(this, xe).port.postMessage({ command: "initWs", data: [`ws${f.trimStart(z.appUrl, "http")}api/user-resource-status-ws?token=${n}`] });
|
|
});
|
|
}, c(this, xe).port.postMessage({ command: "status", data: [] });
|
|
});
|
|
T(this, "subscribe", (e, i = []) => (i ? Array.isArray(i) && i.length == 0 ? i = "*" : Array.isArray(i) || (i = [i].flat()) : i = "*", c(this, We).set(e, i), c(this, We).size == 1 && c(this, Pt).call(this), () => this.unsubscribe(e)));
|
|
T(this, "unsubscribe", (e) => c(this, We).delete(e));
|
|
if (c(we, Fe)) return c(we, Fe);
|
|
}
|
|
};
|
|
Fe = new WeakMap(), xe = new WeakMap(), We = new WeakMap(), Pt = new WeakMap(), x(we, Fe, null), T(we, "getInstance", () => (c(we, Fe) || q(we, Fe, new we()), c(we, Fe)));
|
|
let Kt = we;
|
|
const _i = Kt.getInstance(), ii = E.forwardRef(({ listCode: t, base62params: e, className: i, theme: r, themeProps: n, layouts: o, classNames: a, onSelectionChange: s, defaultSelectedRowKeys: l, selectedRowKeys: d, onDataSourceChange: u }, p) => {
|
|
const [{ resource: h, primaryKey: g, batchOperations: y = [], itemOperations: w = [], columns: C = [], themeConfig: S, theme: P, isConditionFormLayout: k = !1, isTreeSider: $, treeSiderConfig: R, isItemGridLayout: L, itemGridLayout: { themeConfig: v, ...j } = {}, title: D, isPaginate: N, tabs: M, selectionType: V }, B] = A({ isItemGridLayout: !1, itemGridLayout: {} }), he = nn(t, e), [{ dataSource: ae, itemOperationsAccess: W, condition: ce, tab: Y, keyword: Ft, page: li, total: ci, pageSize: di, sider: cr, onConditionChange: dr, onTabChange: ur, onKeywordChange: pr, onPageChange: gr, onPageSizeChange: hr, onSiderChange: mr, onReload: jt, payload: fr }, ui] = rn(he, t, g, h), yr = Or(u);
|
|
ji(() => {
|
|
yr(ae, { page: li, pageSize: di, total: ci });
|
|
}, [ae]);
|
|
const [wr, br] = jr([], { defaultValue: l ?? [], value: d }), [pi, Cr] = A([]), gi = _(() => V ? pi : ae, [V, pi, ae]), kr = qt(w, W, ae, g), Sr = qt(y);
|
|
U(() => {
|
|
let X = null;
|
|
return t && z.get(`/api/_/${t}`).resp(({ data: De, res: At }) => {
|
|
De != null && De.isDynamicRefresh && (X = _i.subscribe(() => jt(), At)), B(De);
|
|
}).catch(() => B({})), () => X == null ? void 0 : X();
|
|
}, [t]), E.useImperativeHandle(p, () => ({ onReload: jt, onClickCallback: ui, getSelectedRows: gi }));
|
|
const Er = { listCode: t, title: D, classNames: a, layouts: o, resource: h, primaryKey: g, theme: r || P, themeProps: n || S, isTreeSider: $, treeSiderConfig: R, isPaginate: N, rowSelection: V ? { type: V, columnWidth: 80, selectedRowKeys: wr, onChange: (X, De) => {
|
|
Cr((At) => {
|
|
const hi = new Map(At.map((de) => [de == null ? void 0 : de[g], de]));
|
|
return De.forEach((de) => hi.set(de == null ? void 0 : de[g], de)), X.map((de) => hi.get(de)).filter(Boolean);
|
|
}), br(X), s == null || s(X, De);
|
|
} } : void 0, getSelectedRows: gi, tabs: M, isItemOperations: kr, itemOperations: w == null ? void 0 : w.map((X) => f.isEmpty(X == null ? void 0 : X.confirm) ? X : { ...X, confirm: Object.assign({}, X.confirm, { getPopupContainer: () => document.body }) }), isBatchOperations: Sr, batchOperations: y, isItemGridLayout: L, columns: C, itemGridLayout: { ...j, themeProps: v }, isConditionFormLayout: k, itemOperationsAccess: W, dataSource: ae, onConditionChange: dr, onTabChange: ur, onKeywordChange: pr, onPageChange: gr, onPageSizeChange: hr, onSiderChange: mr, condition: ce, tab: Y, keyword: Ft, page: li, total: ci, pageSize: di, sider: cr, payload: fr };
|
|
return m(Ji, { ...Er, className: F("ff-data-list-helper", i), onReload: jt, onClickCallback: ui });
|
|
}), Yi = (t, e, i = !0) => i !== !0 && i-- <= 0 ? [] : f.isArray(t) && !f.isEmpty(t) ? t.reduce((r, n) => (Reflect.has(n, e) && Reflect.has(n, "children") && r.push(n[e]), Reflect.has(n, "children") && !f.isEmpty(n.children) ? r.concat(Yi(n.children, e, i)) : r), []) : [], hn = ({ className: t, primaryKey: e, columns: i = [], dataSource: r = [], operationRender: n, operationWidth: o = 180, components: a = {}, rowSelection: s, ...l }) => {
|
|
const { classNames: d } = ge(le), u = J(null), p = J(null), [h, g] = A([]), [y, w] = A({ width: 0, height: 0 });
|
|
U(() => {
|
|
g(Yi(r, e));
|
|
}, [r, e]), vr(() => {
|
|
const k = new ResizeObserver(() => {
|
|
var $;
|
|
w({ width: (($ = u.current) == null ? void 0 : $.nativeElement.querySelector(".ant-table-body").scrollWidth) || p.current.offsetWidth, height: p.current.offsetHeight });
|
|
});
|
|
return p.current && k.observe(p.current), () => {
|
|
p.current && k.unobserve(p.current);
|
|
};
|
|
}, []);
|
|
const C = K(() => {
|
|
if (!(y != null && y.width) || !(i != null && i.length)) return i;
|
|
const k = (s ? s.columnWidth ?? 32 : 0) + (n ? o : 0), $ = i.reduce((v, j) => v + (j.isWidthFixed && j.width ? j.width : 0), 0), R = i.filter((v) => !v.isWidthFixed).reduce((v, j) => v + (j.width ?? 100), 0);
|
|
if ($ + R + k >= y.width) return i;
|
|
const L = y.width - $ - k;
|
|
return i.map((v) => v.isWidthFixed ? v : { ...v, width: Math.floor(L * (v.width ?? 100) / R) });
|
|
}, [i, y.width, s, n, o]), S = en(C), P = tn(a);
|
|
return m("div", { ref: p, className: F("ff-data-list-table", d.content, t), children: y.height ? m(wi, { bordered: !0, ...l, components: P, ref: u, rowKey: (k) => (k == null ? void 0 : k[e]) ?? Math.random(), rowSelection: s, columns: (() => {
|
|
var $, R;
|
|
const k = [...S ?? []];
|
|
return s && k.splice((R = ($ = k[0]) == null ? void 0 : $.key) != null && R.startsWith("__") ? 1 : 0, 0, wi.SELECTION_COLUMN), n && k.push({ title: "操作", align: "center", fixed: "right", width: `${Math.ceil(o / y.width * 100).toFixed(2)}%`, render: (L, v, j) => n(v, j) }), k;
|
|
})(), dataSource: r, size: "middle", scroll: { x: "max-content", y: y.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: g, expandedRowKeys: h } }) : null });
|
|
}, mn = "RC_FORM_INTERNAL_HOOKS", fn = (t) => {
|
|
const [e, i] = E.useState({ items: [] });
|
|
return U(() => {
|
|
t && z.get(`/api/_/${t}`).then(({ uuid: r, code: n, name: o, resource: a, primaryKey: s, marginX: l, marginY: d, cols: u, rowHeight: p, fields: h, theme: g, themeSetting: y, groups: w }) => ({ uuid: r, code: n, name: o, resource: a, primaryKey: s, marginX: l, marginY: d, cols: u, rowHeight: p, theme: g, themeProps: y, groups: w, items: h })).then(i);
|
|
}, [t]), e;
|
|
}, yn = (t, { initialValue: e, initialValueLanguage: i, convertJs: r, convertJsSetting: n, type: o = "string" }, a = null) => {
|
|
const s = J(!1), l = ge(Fi), [d, u] = A(), [p, h] = A(i != "javascript" && t ? l.getFieldValue(t) : void 0), { registerWatch: g } = l.getInternalHooks(mn) || {};
|
|
return U(() => g == null ? void 0 : g((y, w, C) => {
|
|
if (!s.current) return;
|
|
const S = f.get(w, t);
|
|
f.isEqual(S, p) || h(pe(S, o));
|
|
}), [p]), U(() => {
|
|
i == "javascript" && e ? Me.exec(e, {}, { getFieldValueForBasicForm: (y) => a ? a.getFieldValue(y) : l.getFieldValue(y), getFieldValue: (y) => l.getFieldValue(y) }).then((y) => h(pe(y, o))).catch((y) => notification.error({ message: `布局数据错误: ${JSON.stringify(y)}` })).finally(() => s.current = !0) : (e && h(pe(e ?? l.getFieldValue(t), o)), s.current = !0);
|
|
}, [e, i]), mt(() => {
|
|
s.current && r && new kt([r, n]).toValue(p, l.getFieldsValue(!0)).then(u).catch((y) => {
|
|
u(y), console.error("布局数据转换错误: ", y, r);
|
|
});
|
|
}, [p, r, n]), [d ?? p, p];
|
|
}, No = (t, e, i = null) => K(() => ti(t, e, i), [t]), Gi = (t, e, i = {}, r = {}, n = {}, o = null) => {
|
|
const a = ge(Fi), s = Tt(), l = J(!0), d = J([]), [u, p] = A(e), [h, g] = A(), y = oe.useWatch((w) => JSON.stringify(f.pick(w, d.current)), a) || "{}";
|
|
return Ot(() => {
|
|
t && Me.exec(t, i, { ...r, getFieldValueForBasicForm: (w) => n ? n.getFieldValue(w) : null, getFieldValue: f.wrap(a.getFieldValue, (w, C) => (d.current.some((S) => f.isEqual(S, C)) || (d.current.push(C), s()), w == null ? void 0 : w(C))), isFieldTouched: a.isFieldTouched, isFieldsTouched: a.isFieldsTouched }).then((w) => {
|
|
l.current && (p(w), g(null));
|
|
}).catch((w) => {
|
|
l.current && (p(e), g(w));
|
|
});
|
|
}, [t, y, a, i, r]), U(() => () => l.current = !1, []), t ? [o ? pe(u, o) : u, h] : [o ? pe(e, o) : e, null];
|
|
}, wn = ({ widget: t, widgetPrefix: e = "@pkg/ff/grid-layouts", basicForm: i, ...r }) => {
|
|
const n = t != null && t.startsWith("@") || t != null && t.startsWith("blob:") ? t : `${e}/${t}`, [o, a] = A();
|
|
return U(() => {
|
|
n && se.getWidgetComponent(n).then(({ defaultProps: s = {}, default: l }) => ({ default: bn(l, s, i) })).catch((s) => ({ default: () => `${s}` })).then((s) => a(E.createElement(s.default, r)));
|
|
}, [n]), o;
|
|
}, bn = (t, e = {}, i = null) => (r) => {
|
|
const { code: n, label: o, extras: a, isVirtual: s, initialValue: l, initialValueLanguage: d, convertJs: u, convertJsSetting: p, value: h, ...g } = f.merge({}, e, r), [y, w] = yn(s ? null : n, { initialValue: l, initialValueLanguage: d, convertJs: u, convertJsSetting: p, type: (g == null ? void 0 : g.type) || "string" }, i), C = K(() => {
|
|
const k = Object.keys((e == null ? void 0 : e.extras) || {});
|
|
return f.over([f.partialRight(f.pick, k), f.partialRight(f.omit, k)]);
|
|
}, [e == null ? void 0 : e.extras]), [S, P] = C(g);
|
|
return m(t, { ...P, value: y, rawValue: w, $setting: Object.assign({}, a, S) });
|
|
}, Xi = ({ theme: t, basicForm: e, items: i = [{ key: "default", label: "默认" }], fields: r = [], itemRender: n, chunks: o = [], children: a, $setting: s = {}, ...l }) => {
|
|
const [d, u] = A();
|
|
U(() => {
|
|
t ? se.getWidgetComponent(t).then((h) => {
|
|
if (!(h != null && h.default)) throw "not found";
|
|
return h;
|
|
}).catch((h) => ({ default: () => `${t} ${h}` })).then((h) => u(E.createElement(h.default, {}))) : u(null);
|
|
}, [t]);
|
|
const p = K(() => i == null ? void 0 : i.map((h) => ({ ...h, children: n(h, r == null ? void 0 : r.filter((g) => !(g != null && g.group) && h.key == "default" || g.group == h.key), h.key == "default" ? a : null) })).concat(o), [i, a, o]);
|
|
return d && E.cloneElement(d, { items: p, basicForm: e, $setting: { ...s, ...l } });
|
|
}, Qi = ({ name: t, form: e = null, basicForm: i = null, style: r = {}, className: n, cols: o = 12, rowHeight: a = 21, containerPadding: s = [0, 0], itemMargin: l = [4, 0], formProps: d = {}, formFields: u = [], fields: p = [], data: h, theme: g, themeProps: y = {}, groups: w = [{ key: "default", label: "默认" }], children: C, ...S }) => {
|
|
const [P] = oe.useForm(e), k = K(() => [{ name: "__PROPS__", value: d }].concat(u), [d, u]);
|
|
mt(() => (P.setFieldsValue(h), () => P.resetFields()), [h]);
|
|
const $ = (R, L, v) => {
|
|
const j = ti(L, wn, i), D = Ki(S);
|
|
return I("div", { ...D, className: F("ff-grid-layout", n), style: { ...r, "--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": o, "--grid-layout-row-height": `${a}px` }, children: [j, v && E.cloneElement(v, { cols: o, rowHeight: a, itemMargin: l, containerPadding: s, fields: L, basicForm: i })] });
|
|
};
|
|
return m(oe, { ...S, fields: k, form: P, component: !1, children: g ? m(Xi, { ...y, items: w, theme: g, itemRender: $, fields: p, children: C, basicForm: i }) : $(0, p, C) });
|
|
}, To = /* @__PURE__ */ ((t) => function({ code: e, data: i, ...r }) {
|
|
const { uuid: n, resource: o, items: a, hides: s, rowHeight: l, marginX: d, marginY: u, cols: p, theme: h, themeProps: g, groups: y } = fn(e) || {}, w = K(() => [{ name: "__RESOURCE__", value: o }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: n }], [e, n, o]);
|
|
return o && m(t, { name: e, theme: h, themeProps: g, groups: y, ...r, fields: a, formFields: w, rowHeight: l, cols: p, itemMargin: [d, u], data: o ? { [o]: i } : i });
|
|
})(Qi), Cn = ({ column: t = 0, colWidth: e = 0, cols: i, rowHeight: r, itemMargin: n, fields: o, primaryKey: a, dataSource: s, beforeRender: l = null, afterRender: d = null, itemClassName: u, itemRender: p = (k, $, R) => k, empty: h = m(Bt, { description: null }), className: g, style: y = {}, theme: w, themeProps: C = {}, groups: S = [{ key: "default", label: "默认" }], rowSelection: P }) => {
|
|
const { classNames: k } = ge(le), $ = _((v) => {
|
|
if (!P) return;
|
|
const { selectedRowKeys: j = [], onChange: D, type: N = "checkbox" } = P, M = v == null ? void 0 : v[a];
|
|
let V;
|
|
V = N === "radio" ? [M] : j.includes(M) ? j.filter((B) => B !== M) : [...j, M], D == null || D(V, s.filter((B) => V.includes(B == null ? void 0 : B[a])));
|
|
}, [P, a, s]), R = K(() => m(Qi, { groups: S, theme: w, themeProps: C, cols: i, rowHeight: r, itemMargin: n, fields: o, className: u }), [o, i, r, n, S, w, C]), L = f.isEmpty(s);
|
|
return I("div", { className: F("ff-data-list-content", k.content, g), style: Object.assign({}, y, t && { "--col-num": t }, e && { "--col-width": e }), children: [l == null ? void 0 : l(s), L ? h : s.map((v, j) => {
|
|
var V;
|
|
const D = (v == null ? void 0 : v[a]) ?? j, N = `${D}-${Pn(v)}`, M = p(E.cloneElement(R, { data: v }), v, j);
|
|
return E.cloneElement(M, { key: N, ...P && { isSelected: (V = P == null ? void 0 : P.selectedRowKeys) == null ? void 0 : V.includes(D), onSelect: () => $(v) } });
|
|
}), d == null ? void 0 : d(s)] });
|
|
}, kn = ({ component: t, $props: e }) => {
|
|
const { base62params: i } = Nt(e, {});
|
|
return m(ee, { children: m(ii, { listCode: t, base62params: z.decode(i) }) });
|
|
}, Oo = () => m(Zi, {}), Zi = () => "Empty", Sn = ({ component: t, $setting: e, $props: i }) => {
|
|
const [r, n] = A(), [o, a] = nr(i);
|
|
return U(() => {
|
|
if (!t) return n(m(Zi, { description: null }));
|
|
se.getWidgetComponent(t).catch((s) => ({ default: () => `${s}` })).then((s) => E.createElement(s.default, { $setting: e })).then(n);
|
|
}, [t]), r ? E.cloneElement(r, { ...o, $setProps: a }) : null;
|
|
}, Ro = () => "NotFoundPage";
|
|
var je, ue, Ae, ke, st, lt;
|
|
const be = class be {
|
|
constructor() {
|
|
x(this, ue, /* @__PURE__ */ new Map());
|
|
x(this, Ae, {});
|
|
x(this, ke, null);
|
|
T(this, "init", (e, i) => {
|
|
q(this, ue, e), q(this, Ae, i);
|
|
});
|
|
T(this, "get", (e) => (c(this, ue).has(e) || (e = Array.from(c(this, ue).keys()).find((i) => c(this, ue).get(i).uri === e)), c(this, ue).get(e) || {}));
|
|
T(this, "redirect", (e, i, r = {}) => {
|
|
var y;
|
|
const { uri: n, type: o, widgetProps: a } = this.get(e) || {}, { router: s, query: l, ...d } = i || {}, u = Object.assign({}, d, s), p = Object.assign({}, d, l);
|
|
o == "list" && (u.base62params = z.encode(u != null && u.base62params ? u.base62params : u));
|
|
let h = Ur(n || e, u);
|
|
const g = new URLSearchParams();
|
|
for (const w in a || {}) ((y = a[w]) == null ? void 0 : y.type) == "query" && Object.has(p, w) && g.append(w, JSON.stringify(p[w]));
|
|
return g.size > 0 && (h = `${h}?${g.toString()}`), r != null && r.isOpenWindow ? window.open(h) : c(this, ke).navigate(h, { replace: !!(r != null && r.isReplaceRouteHistory) });
|
|
});
|
|
T(this, "getMenus", (e) => {
|
|
var i;
|
|
return ((i = c(this, Ae)) == null ? void 0 : i[e]) || [];
|
|
});
|
|
T(this, "findMenuPathByUuid", (e) => {
|
|
let i = [];
|
|
for (const r in c(this, Ae)) if (i = c(this, st).call(this, c(this, Ae)[r], e, [r]), i.length > 1) return i;
|
|
return i;
|
|
});
|
|
T(this, "getMenusByRouteUuid", (e) => c(this, lt).call(this, e, Object.values(c(this, Ae)).flat()));
|
|
x(this, st, (e, i, r = []) => {
|
|
if (f.isEmpty(e)) return r;
|
|
for (const { uuid: n, children: o } of e) {
|
|
if (n == i) return r.concat(n);
|
|
if (!f.isEmpty(o)) return r.concat(n, c(this, st).call(this, o, i));
|
|
}
|
|
return r;
|
|
});
|
|
x(this, lt, (e, i) => {
|
|
var n;
|
|
let r = [];
|
|
for (const o of i) o.widgetType == "redirect" && (o.uuid == e || o.widget == e ? r.push(o) : (n = o.children) != null && n.length && (r = r.concat(c(this, lt).call(this, e, o.children))));
|
|
return r;
|
|
});
|
|
T(this, "getCurrentMenu", () => {
|
|
const { uuid: e } = this.getCurrentRoute() || {};
|
|
if (!e) return;
|
|
const i = this.getMenusByRouteUuid(e);
|
|
return f.isEmpty(i) ? void 0 : i[0];
|
|
});
|
|
T(this, "getCurrentRoute", (e = 0) => {
|
|
var r;
|
|
const i = (r = c(this, ke).state.matches[c(this, ke).state.matches.length - 1 - e]) == null ? void 0 : r.route;
|
|
if (!i) return null;
|
|
for (let [n, o] of c(this, ue)) if (o.uri === i.path) return o;
|
|
return null;
|
|
});
|
|
T(this, "getPageParams", (e) => {
|
|
var a, s;
|
|
const { location: i = {}, matches: r = [] } = ((a = c(this, ke)) == null ? void 0 : a.state) || {}, n = { ...((s = r[r.length - 1]) == null ? void 0 : s.params) || {} }, o = i.search;
|
|
return o && new URLSearchParams(o).forEach((l, d) => {
|
|
n[d] = l;
|
|
}), e ? f.get(n, e) : n;
|
|
});
|
|
T(this, "usePageParams", (e) => {
|
|
var r;
|
|
let i = Ii() ? { ...qr(), ...Object.fromEntries(new URLSearchParams(((r = Kr()) == null ? void 0 : r.search) ?? "")) } : this.getPageParams();
|
|
return e ? f.get(i, e) : i;
|
|
});
|
|
T(this, "createBrowserRouter", (e = {}) => {
|
|
if (c(this, ue).size == 0) return null;
|
|
if (c(this, ke)) return c(this, ke);
|
|
const i = qe.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/ff/frameworks/DefaultTheme"), r = qe.get(se.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), n = { [i]: 0 }, o = (s, l) => () => Promise.all([se.getWidgetComponent(s), Nt(l)]).then(([d, u]) => [d.default || function() {
|
|
return `${s}`;
|
|
}, u]).then(([d, u]) => ({ Component: () => E.createElement(Di, {}, E.createElement(d, { $setting: u })) })), a = Array.from(c(this, ue).values()).reduce((s, { uuid: l, uri: d, name: u, type: p, component: h, widgetSetting: g, widgetProps: y, isLogin: w, isLayout: C, extra: S }) => {
|
|
let P = {}, k = 0;
|
|
switch (p) {
|
|
case "list":
|
|
P.element = E.createElement(kn, { component: h, $props: y });
|
|
break;
|
|
case "fsdpf-component":
|
|
P.element = E.createElement(Sn, { key: h, component: h, $setting: g, $props: y });
|
|
}
|
|
const $ = (S == null ? void 0 : S.theme) ?? (S == null ? void 0 : S.layout);
|
|
if ($) {
|
|
const R = (S == null ? void 0 : S.themeProps) ?? (S == null ? void 0 : S.layoutProps);
|
|
if (!n[$]) return n[$] = s.length, [...s, { path: "/", lazy: o($, R), children: [{ path: d, ...P }] }];
|
|
k = n[$];
|
|
}
|
|
return C && k > -1 ? (s[k].children.push({ path: d, ...P }), s) : [...s, { path: d, ...P }];
|
|
}, [{ path: "/", lazy: o(i, {}), children: [] }]);
|
|
return a.push({ index: !0, element: E.createElement(En, { to: r, replace: !0 }) }), q(this, ke, Hr(a, e));
|
|
});
|
|
if (c(be, je)) return c(be, je);
|
|
}
|
|
};
|
|
je = new WeakMap(), ue = new WeakMap(), Ae = new WeakMap(), ke = new WeakMap(), st = new WeakMap(), lt = new WeakMap(), x(be, je, null), T(be, "getInstance", () => (c(be, je) || q(be, je, new be()), c(be, je)));
|
|
let Ht = be;
|
|
const En = ({ to: t, replace: e }) => Ii() ? E.createElement(Jr, { to: t, replace: e }) : (window.document.location = t, "redirect"), ne = Ht.getInstance(), Ke = new Worker(new URL("/ff-worker/index.js", self.location)), Ei = { getConfigure: (t) => qe.get(t), route: { redirect: (...t) => ne.redirect(...t), getPageParams: (...t) => ne.getPageParams(...t), getCurrentRoute: () => ne.getCurrentRoute() }, popup: { notification: (...t) => re.notification(...t), success: (...t) => re.success(...t), error: (...t) => re.error(...t), form: (...t) => re.form(...t), modal: (...t) => re.modal(...t), confirm: (...t) => re.confirm(...t) } };
|
|
var xt, Ge, Le;
|
|
const H = class H {
|
|
constructor() {
|
|
T(this, "exec", (e, i = {}, r = {}, n = "") => new Promise((o, a) => {
|
|
if (!/^(?!\s*(\/\/|\/\*|\*)).*?\S+/m.test(e)) return o();
|
|
const s = yi(H, xt)._++;
|
|
c(H, Ge).set(s, r), H.mQueue.set(s, [o, a]), Ke.postMessage({ id: s, session: n, category: "eval", method: e, args: i });
|
|
}));
|
|
T(this, "clear", (e) => Ke.postMessage({ session: e, category: "clear" }));
|
|
if (c(H, Le)) return c(H, Le);
|
|
Promise.resolve().then(() => to).then((e) => {
|
|
Ei.http = e.http;
|
|
}), Ke.addEventListener("message", ({ data: { id: e, task_id: i, method: r, args: n, category: o, data: a, error: s, session: l } }) => {
|
|
if (o === "eval" && H.mQueue.has(e)) s !== null ? H.mQueue.get(e)[1](s) : H.mQueue.get(e)[0](a), c(H, Ge).delete(e), H.mQueue.delete(e);
|
|
else if (o === "util") try {
|
|
const d = f.get(Ei, r.split("/")) || f.get(c(H, Ge).get(i), r.split("/"));
|
|
if (!f.isFunction(d)) throw `${r} not found`;
|
|
Promise.resolve(Reflect.apply(d, void 0, n)).then((u) => {
|
|
Ke.postMessage({ id: e, task_id: i, category: o, method: r, args: n, session: l, data: u, error: null });
|
|
}).catch((u) => {
|
|
Ke.postMessage({ id: e, task_id: i, category: o, method: r, args: n, session: l, data: null, error: u });
|
|
});
|
|
} catch (d) {
|
|
Ke.postMessage({ id: e, task_id: i, category: o, method: r, args: n, session: l, data: null, error: d });
|
|
}
|
|
}, !1);
|
|
}
|
|
};
|
|
xt = new WeakMap(), Ge = new WeakMap(), Le = new WeakMap(), T(H, "mQueue", /* @__PURE__ */ new Map()), x(H, xt, 0), x(H, Ge, /* @__PURE__ */ new Map()), x(H, Le, null), T(H, "getInstance", () => (c(H, Le) || q(H, Le, new H()), c(H, Le)));
|
|
let Jt = H;
|
|
const Me = Jt.getInstance(), $i = { null2json: (t) => Object.create(), null2array: (t) => [], null2number: (t) => 0, null2bool: (t) => !1, null2string: (t) => "", null2integer: (t) => 0, null2float: (t) => 0, string2json: (t) => t ? JSON.parse(t) : "{}", string2array: (t) => t.substr(0, 1) === "[" && t.substr(-1) === "]" ? JSON.parse(t) : t.split(","), string2number: (t) => t == "" ? 0 : +t, string2integer: (t) => t == "" ? 0 : +t, string2float: (t) => t == "" ? 0 : +t, string2bool: (t) => {
|
|
switch (`${t}`.toLowerCase()) {
|
|
case "0":
|
|
case "false":
|
|
case "[]":
|
|
case "{}":
|
|
return !1;
|
|
}
|
|
return !!t;
|
|
}, string2string: (t) => t, json2json: (t) => t, json2array: (t) => t ? Object.values(t) : [], json2number: (t) => Object.keys(t).length, json2integer: (t) => Object.keys(t).length, json2float: (t) => Object.keys(t).length, json2bool: (t) => Object.keys(t).length > 0, json2string: (t) => t ? JSON.stringify(t) : "", array2json: (t) => ({ ...t }), array2array: (t) => t, array2number: (t) => t.length, array2integer: (t) => t.length, array2float: (t) => t.length, array2bool: (t) => t.length > 0, array2string: (t) => JSON.stringify(t), number2json: (t) => ({}), number2array: (t) => [t], number2number: (t) => t, number2integer: (t) => t, number2float: (t) => t, number2bool: (t) => !!t, number2string: (t) => t.toString(), boolean2json: (t) => ({}), boolean2array: (t) => [], boolean2number: (t) => +t, boolean2integer: (t) => +t, boolean2float: (t) => +t, boolean2bool: (t) => t, boolean2string: (t) => t ? "true" : "false" }, pe = (t, e) => {
|
|
let i = "string";
|
|
i = Array.isArray(t) ? "array" : typeof t, f.isObject(t) && (i = "json");
|
|
const r = `${i}2${e}`;
|
|
return Reflect.has($i, r) ? $i[r](t) : t;
|
|
}, $n = (t) => t === null ? "null" : Array.isArray(t) ? "array" : typeof t == "object" ? "json" : typeof t == "boolean" ? "bool" : typeof t == "string" ? "string" : typeof t == "number" ? Number.isInteger(t) ? "integer" : "float" : typeof t, Nt = (t = {}, e = {}, i = {}, r = "") => er(t, (n, o) => o === "type" && n === "code") ? tr(t, e, i, r) : ir(t, e, r), er = (t, e = () => !1) => f.some(t, (i) => !!f.some(i, e) || (f.isEmpty(i) || !f.isPlainObject(i) && !f.isArray(i) ? void 0 : er(i, e))), tr = async (t = {}, e = {}, i = {}, r = "") => {
|
|
let n = /* @__PURE__ */ Object.create(null);
|
|
for (let o in t) {
|
|
let a;
|
|
if (Reflect.has(t[o], "type") && ["code", "field", "router", "query", "string"].includes(t[o].type)) {
|
|
const { type: s, value: l = "", default: d = r } = t[o];
|
|
switch (s) {
|
|
case "code":
|
|
try {
|
|
a = await Me.exec(l, e, i);
|
|
} catch (u) {
|
|
console.error("getWidgetPropsData", u);
|
|
}
|
|
break;
|
|
case "field":
|
|
a = f.get(e, l) ?? f.get(e, l.substring(l.indexOf(".") + 1));
|
|
break;
|
|
case "router":
|
|
case "query":
|
|
a = ne.getPageParams(l);
|
|
break;
|
|
case "string":
|
|
a = l;
|
|
}
|
|
a ?? (a = d);
|
|
} else a = await tr(t[o], e, i, r);
|
|
f.set(n, o, a);
|
|
}
|
|
return n;
|
|
}, ir = (t = {}, e = {}, i = "") => Object.keys(t || {}).reduce((r, n) => {
|
|
if (f.isPlainObject(t[n])) {
|
|
let o;
|
|
if (Reflect.has(t[n], "type") && ["field", "router", "query", "string"].includes(t[n].type)) {
|
|
const { type: a, value: s = "", default: l = i } = t[n];
|
|
switch (a) {
|
|
case "field":
|
|
o = f.get(e, s) ?? f.get(e, s.substring(s.indexOf(".") + 1));
|
|
break;
|
|
case "router":
|
|
case "query":
|
|
o = ne.getPageParams(s);
|
|
break;
|
|
case "string":
|
|
o = s;
|
|
}
|
|
o ?? (o = l);
|
|
} else o = ir(t[n], e, i);
|
|
f.set(r, n, o);
|
|
}
|
|
return r;
|
|
}, {}), It = (t, e) => t && typeof t == "object" ? Array.isArray(t) ? t.map((i) => It(i, e)) : Object.keys(t).reduce((i, r) => (e[r] ? i[e[r]] = It(t[r], e) : i[r] = It(t[r], e), i), {}) : t, Fo = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
|
|
const e = 16 * Math.random() | 0;
|
|
return (t === "x" ? e : 3 & e | 8).toString(16);
|
|
}), jo = (t) => {
|
|
var e, i;
|
|
return t ? (i = (e = t.match(/^@pkg(?:[^\/]*\/){3}(?<name>[^\/]+)/)) == null ? void 0 : e.groups) == null ? void 0 : i.name : "";
|
|
}, Ao = (t) => {
|
|
var e, i;
|
|
return t ? (i = (e = t.match(/^@pkg(?:[^\/]*\/){2}(?<category>[^\/]+)/)) == null ? void 0 : e.groups) == null ? void 0 : i.category : "";
|
|
}, Lo = (t) => {
|
|
var e, i;
|
|
return t ? (i = (e = t.match(/^@pkg(?:[^\/]*\/){1}(?<owner>[^\/]+)/)) == null ? void 0 : e.groups) == null ? void 0 : i.owner : "";
|
|
}, Pn = (t, e = 32, i = "auto") => {
|
|
const r = _t(t), n = i === "auto" ? "x64" : i;
|
|
if (e === 32) return Lt.x86.hash32(r).toString();
|
|
if (e === 128) return n === "x64" ? Lt.x64.hash128(r) : Lt.x86.hash128(r);
|
|
throw new Error("bits 只能是 32 或 128");
|
|
}, _t = (t) => t == null ? "null" : typeof t == "string" ? t : typeof t == "number" || typeof t == "boolean" ? String(t) : typeof t == "function" ? t.toString() : Array.isArray(t) ? "[" + t.map(_t).join(",") + "]" : typeof t == "object" ? "{" + Object.keys(t).sort().map((e) => `${e}:${_t(t[e])}`).join(",") + "}" : String(t), xn = () => {
|
|
let t = 1;
|
|
const e = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new Map();
|
|
return (...r) => r.length === 0 ? "" : r.map((n) => {
|
|
return String((o = n) === null || typeof o != "object" && typeof o != "function" ? (i.has(o) || i.set(o, t++), i.get(o)) : (e.has(o) || e.set(o, t++), e.get(o)));
|
|
var o;
|
|
}).join("::");
|
|
}, vn = (t) => {
|
|
if (!t || typeof t != "string" || t.startsWith("/") || t.startsWith("./") || t.startsWith("../")) return !1;
|
|
try {
|
|
let e = t.startsWith("//") ? `http:${t}` : t;
|
|
return e.includes("://") || e.startsWith("//") || (e = `http://${e}`), !!new URL(e).hostname;
|
|
} catch {
|
|
return !1;
|
|
}
|
|
}, Io = (t, e = "") => {
|
|
if (!t || typeof t != "string" || vn(t)) return t;
|
|
let i = e;
|
|
return !i && typeof window < "u" && window.location && (i = `${window.location.protocol}//${window.location.host}`), t.startsWith("/") ? i ? `${i}${t}` : t : i ? `${i}/${t}` : t;
|
|
}, Tt = () => {
|
|
const t = J(!0), [, e] = E.useReducer((i) => i + 1, 0);
|
|
return U(() => () => t.current = !1, []), () => t.current && e();
|
|
}, Mo = (t) => {
|
|
const [e, i] = A(t), r = J(null), n = _((o, a) => {
|
|
r.current = a, i(o);
|
|
}, []);
|
|
return U(() => {
|
|
r.current && (r.current(e), r.current = null);
|
|
}, [e]), [e, n];
|
|
}, mt = (t = (r) => {
|
|
}, e, i = f.isEqual) => {
|
|
const r = E.useRef();
|
|
i(e, r.current) || (r.current = f.cloneDeep(e)), E.useEffect(t, [r.current]);
|
|
}, Ot = mt, rr = (t, e = "string") => {
|
|
var i;
|
|
if (!Array.isArray(t)) return t;
|
|
for (let r = 0; r < t.length; r++) t[r].value = pe((i = t[r]) == null ? void 0 : i.value, e), t[r] && Reflect.has(t[r], "children") && (t[r].children = rr(t[r].children, e));
|
|
return t;
|
|
}, Do = (t, e = "json", i = "string", r, n = null) => {
|
|
const [o] = oe.useForm(r), [a, s] = A([{ label: "无", value: "", disabled: !0 }]), l = J([]), d = oe.useWatch((u) => l.current.length === 0 ? null : f.pick(u, l.current), o) || null;
|
|
return U(() => {
|
|
Array.isArray(t) ? s(t) : e === "javascript" && t ? Me.exec(t, {}, { getFieldValue: (u) => (l.current.includes(u) || l.current.push(u), o.getFieldValue(u)), getFieldValueForBasicForm: (u) => (l.current.includes(u) || l.current.push(u), n ? n.getFieldValue(u) : o.getFieldValue(u)) }).then((u) => {
|
|
s(pe(u, "array"));
|
|
}).catch((u) => console.error("useOptions", u)) : t && s(pe(t, "array"));
|
|
}, [t, e, d]), rr(a, i);
|
|
}, Vo = (t) => {
|
|
const [e, i] = A(), r = { type: "GET" };
|
|
if (typeof t == "string" ? r.url = t : f.isPlainObject(t) && Object.assign(r, t), !(r != null && r.url)) throw "url is required";
|
|
const n = (o) => z.request(r, !1).resp((a) => (console.log("useSubscribeRequest", o), i(a), a));
|
|
return mt(() => {
|
|
let o = null;
|
|
return n().then((a) => {
|
|
o = _i.subscribe(f.throttle(n, 180, { leading: !1, trailing: !0 }), a.res);
|
|
}), () => o == null ? void 0 : o();
|
|
}, r), e;
|
|
}, Nn = (t, e) => _((i) => {
|
|
const r = {};
|
|
for (const [n, o] of Object.entries(i)) {
|
|
const a = t == null ? void 0 : t[n];
|
|
if ((a == null ? void 0 : a.type) === "router" || (a == null ? void 0 : a.type) === "query") {
|
|
const s = ne.getCurrentRoute();
|
|
s != null && s.uuid && ne.redirect(s.uuid, { ...ne.getPageParams(), [a.type]: { [a.value || n]: o } }, { isReplaceRouteHistory: !0 });
|
|
} else r[n] = o;
|
|
}
|
|
Object.keys(r).length > 0 && e(r);
|
|
}, [t, e]), nr = (t, e = {}, i = {}, r = []) => {
|
|
const [n, o] = A({}), [a, s] = A({}), l = Ai(a), d = ne.usePageParams();
|
|
Zt(() => {
|
|
Promise.resolve(Nt(t, e, i)).then(s);
|
|
}, [t, e, d, ...r]), ji(() => {
|
|
const h = l ?? {}, g = Object.keys({ ...h, ...a }).reduce((y, w) => (h[w] !== a[w] && (y[w] = a[w]), y), {});
|
|
Object.keys(g).length > 0 && o((y) => ({ ...y, ...g }));
|
|
}, [a]);
|
|
const u = Nn(t, (h) => {
|
|
o((g) => ({ ...g, ...h }));
|
|
}), p = K(() => Object.fromEntries(Object.entries(n).filter(([h, g]) => g !== a[h])), [n, a]);
|
|
return [n, u, p];
|
|
}, Tn = (t) => {
|
|
const [e, i] = E.useState({ items: [], hides: [] });
|
|
return E.useEffect(() => {
|
|
t && z.get(`/api/_/${t}`).then(({ pk: r, uuid: n, code: o, resource: a, align: s, cols: l, rowHeight: d, marginX: u, marginY: p, listenChangeFields: h, listenChangeFieldsFunc: g, fields: y, theme: w, themeSetting: C, groups: S }) => ({ pk: r, uuid: n, code: o, resource: a, align: s, cols: l, rowHeight: d, marginX: u, marginY: p, theme: w, themeProps: C, groups: S, listenChangeFields: h, listenChangeFieldsFunc: g, ...y.reduce((P, k) => {
|
|
var $;
|
|
return ($ = k == null ? void 0 : k.field) != null && $.hidden ? P.hides.push(k == null ? void 0 : k.field) : P.items.push(k), P;
|
|
}, { items: [], hides: [] }) })).then(i);
|
|
}, [t]), e;
|
|
}, On = ({ max: t = 0, min: e = 0, type: i = "", message: r, pattern: n, required: o = !1, validator: a } = {}, s, l) => {
|
|
const [d, u] = A([]);
|
|
return U(() => {
|
|
const p = [];
|
|
if (o) {
|
|
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: t, min: e, message: r || (e && t ? `字符必须在 ${e} ~ ${t} 之间` : `${t ? "最多能有" : "最少要有"} ${e || t} 个字符`) });
|
|
break;
|
|
case "pattern":
|
|
p.push({ type: "string", pattern: n, message: r });
|
|
break;
|
|
case "validator":
|
|
a && p.push(({ getFieldValue: h }) => ({ validator: async (g, y) => {
|
|
const w = await Me.exec(a, { value: y, fieldName: s }, { getFieldValue: h });
|
|
return f.isString(w) && w ? Promise.reject(w) : f.isBoolean(w) && !w ? Promise.reject(r) : Promise.resolve();
|
|
} }));
|
|
}
|
|
u(p);
|
|
}, [t, e, i, r, n, o, a]), d;
|
|
}, Rn = (t, e, i) => {
|
|
const [r, n] = A(null);
|
|
return U(() => {
|
|
const { initDataUri: o = `/api/${t}`, initDataMethod: a = "GET" } = i || {};
|
|
e && z.request({ method: a, url: f.trimEnd(`${o}/${e}`, "/") }).then((s) => {
|
|
n(s);
|
|
});
|
|
}, [t, e, i]), r;
|
|
}, Fn = (t, e, i) => _((r, n = { serialize: (o) => o, onSuccess: () => {
|
|
}, onFail: (o) => (o == null ? void 0 : o.errorFields) && re.error("请先完善表单信息", { duration: 2e3 }) }) => {
|
|
const o = r.getFieldValue("__RESOURCE__"), { submitDataUri: a = `/api/${t}`, submitDataMethod: s = "POST" } = i || {};
|
|
return r.validateFields().then((l) => o ? f.pick(l, [o]) : l).then(n.serialize).then((l) => z.request({ method: s, url: f.trimEnd(`${a}/${e || ""}`, "/"), data: l }).msg(n.onSuccess)).catch(n.onFail);
|
|
}, [t, e, i]), jn = (t, e, i, r) => {
|
|
const n = Rn(e, i, r);
|
|
U(() => {
|
|
n ? t.setFieldsValue(n) : t.resetFields();
|
|
}, [t, n]);
|
|
const o = Fn(e, i, r);
|
|
return f.partial(o, t);
|
|
}, An = (t, e, i = [], r = {}) => {
|
|
const n = J({}), o = J(), a = f.debounce(Tt(), 180), s = ["disabled", "required"], l = (h, g) => {
|
|
s.includes(h) && (n.current[h] = g), a();
|
|
}, d = K(() => ({ setDisabled: (h) => l("disabled", h), setRequired: (h) => l("required", h), getDisabled: () => n.current.disabled, getRequired: () => n.current.required }), [e]), [u, p] = Gi(e, -1, {}, d, r);
|
|
if (!p && o.current != u && (u >= 0 || !f.isEmpty(i == null ? void 0 : i[u]))) {
|
|
o.current = u;
|
|
const { widget: h, widgetPrefix: g, props: y } = i == null ? void 0 : i[u];
|
|
t = Bi(h, g), n.current = f.merge(y, f.pick(n.current, s));
|
|
}
|
|
return [t, n.current];
|
|
}, Pi = (t) => t === void 0 || t === !1 ? "" : (Array.isArray(t) ? t : [t]).join("_"), zo = ({ value: t, onChange: e }, i = null) => {
|
|
const r = J(), [n] = oe.useForm(i), o = J({});
|
|
return Ot(() => {
|
|
f.isEqual(r.current, t) || n.setFieldsValue(t);
|
|
}, [t]), U(() => () => n.resetFields(), []), [K(() => n.__INTERNAL__ ? n : { ...n, __INTERNAL__: { itemRef: (a) => (s) => {
|
|
const l = Pi(a);
|
|
s ? o.current[l] = s : delete o.current[l];
|
|
} }, scrollToField: (a, s = {}) => {
|
|
console.warn("useMergedFormValuesChange scrollToField not work, unreferenced antd form");
|
|
}, focusField: (a) => {
|
|
console.warn("useMergedFormValuesChange focusField not work, unreferenced antd form");
|
|
}, getFieldInstance: (a) => {
|
|
const s = Pi(a);
|
|
return o.current[s];
|
|
} }, [n]), (a, s) => {
|
|
r.current = s, e == null || e(s);
|
|
}];
|
|
}, ri = ({ widget: t = "Input", widgetPrefix: e = "@pkg/ff/grid-layout-forms", widgetDecorator: i, subWidgets: r = [], basicForm: n, ...o }) => {
|
|
const a = Bi(t, e), [s, l] = An(a, i, r, n), [d, u] = A();
|
|
return U(() => {
|
|
s && se.getWidgetComponent(s).then(({ defaultProps: p = {}, default: h }) => ({ default: Ln(h, p, n) })).catch((p) => ({ default: () => `${p}` })).then((p) => u(E.createElement(p.default, o)));
|
|
}, [s]), d && E.cloneElement(d, { ...o, ...l });
|
|
}, Ln = (t, e = {}, i = null) => (r) => {
|
|
const { type: n, code: o, label: a, noStyle: s, style: l, placeholder: d, required: u = !1, extras: p, validators: h, help: g, isVirtual: y, $isReserved: w, initialValue: C, initialValueLanguage: S, ...P } = f.omit(f.merge({}, e, r), ["convertJs", "convertJsSetting", "widget", "widgetPerfix", "widgetDecorator", "subWidgets", "boxStyle"]), k = On(Object.assign({}, h, u ? { required: !0 } : {}), o, n), $ = K(() => {
|
|
const D = Object.keys((e == null ? void 0 : e.extras) || {});
|
|
return f.over([f.partialRight(f.pick, D), f.partialRight(f.omit, D)]);
|
|
}, [e == null ? void 0 : e.extras]), [R, L] = $(P), v = { label: a, noStyle: s, style: l, colon: !1, layout: "vertical" }, j = _((D) => D == null ? void 0 : pe(D, n), [n]);
|
|
return m(Qt, { name: o, rules: k, initialValue: j(C), normalize: j, children: (D, N, M) => {
|
|
var V;
|
|
return m(t, { type: n, rcform: M, basicForm: i, itemProps: { validateStatus: N.errors.length > 0 ? "error" : "success", tooltip: g || null, help: N.errors.length > 0 ? N.errors.join("、") : null, required: ((V = k == null ? void 0 : k[0]) == null ? void 0 : V.required) || !1, ...v }, fieldProps: { placeholder: d, ...L, ...D }, $setting: Object.assign({}, p, R) });
|
|
} });
|
|
}, ni = ({ name: t, form: e = null, basicForm: i = null, style: r = {}, className: n, cols: o = 24, rowHeight: a = 16, itemMargin: s = [8, 16], containerPadding: l = [0, 0], fields: d = [], hides: u = [], primaryKey: p = 0, formProps: h = {}, formFields: g = [], listenChangeFields: y, listenChangeFieldsFunc: w, onValuesChange: C, theme: S, themeProps: P = {}, groups: k = [{ key: "default", label: "默认" }], children: $, ...R }) => {
|
|
const [L] = oe.useForm(e), v = _((N, M) => {
|
|
C == null || C(N, M), w && Array.isArray(y) && Me.exec(w, { changedValues: N, allValues: M }, { getFieldValue: L.getFieldValue, setFieldValue: L.setFieldValue, setFieldsValue: L.setFieldsValue, isFieldTouched: L.isFieldTouched, isFieldsTouched: L.isFieldsTouched }).catch((V) => console.error("onFormValuesChange", t, V));
|
|
}, [t, L, C, y, w]), j = K(() => [{ name: "__PROPS__", value: h }, { name: "__PRIMARY_KEY__", value: p }].concat(g), [p, h, g]), D = (N, M, V) => {
|
|
const B = ti(M, ri, i), he = Ki(R);
|
|
return I("div", { ...he, className: F("ff-grid-layout-form", n), style: { ...r, "--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": o, "--grid-layout-row-height": `${a}px` }, children: [B, V && E.cloneElement(V, { cols: o, rowHeight: a, itemMargin: s, containerPadding: l, fields: M, basicForm: i })] });
|
|
};
|
|
return I(oe, { ...R, form: L, fields: j, onValuesChange: v, children: [S ? m(Xi, { ...P, items: k, theme: S, itemRender: D, fields: d, children: $, basicForm: i }) : D(0, d, $), u == null ? void 0 : u.map((N) => {
|
|
var M;
|
|
return m(Qt, { name: N.code, children: m(In, { form: L, basicForm: i, name: N.code, type: N.type, initialValue: N.initialValue, initialValueLanguage: (M = N.extras) == null ? void 0 : M.initialValueLanguage }) }, JSON.stringify(N.code));
|
|
})] });
|
|
}, In = ({ type: t, initialValue: e, initialValueLanguage: i, onChange: r, basicForm: n }) => {
|
|
const [o, a] = Gi(i == "javascript" && e, i == "javascript" ? void 0 : e, {}, {}, n);
|
|
return U(() => {
|
|
i == "javascript" ? r(pe(o, t)) : e && r(pe(e, t));
|
|
}, [t, e, o]), null;
|
|
};
|
|
ni.propTypes = { fields: b.array, hides: b.array };
|
|
const Mn = /* @__PURE__ */ ((t) => ({ code: e, isPreview: i = !1, ...r }) => {
|
|
const { align: n, autoComplete: o, resource: a, items: s, hides: l, rowHeight: d, marginX: u, marginY: p, cols: h, listenChangeFields: g, listenChangeFieldsFunc: y, pk: w, uuid: C, theme: S, themeProps: P, groups: k } = Tn(e), $ = K(() => [{ name: "__PK__", value: w }, { name: "__RESOURCE__", value: a }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: C }], [w, e, C, a]);
|
|
return m(t, { name: e, autoComplete: o, theme: S, themeProps: P, groups: k, ...r, formFields: $, listenChangeFields: g, listenChangeFieldsFunc: y, fields: s, hides: l, cols: h, rowHeight: d, itemMargin: [u, p] });
|
|
})(ni), or = ({ $setting: t, $close: e, extras: i, code: r, primaryKey: n, ...o }) => {
|
|
const [a] = oe.useForm(), s = jn(a, r, n, t);
|
|
return m(ee, { actions: I(E.Fragment, { children: [m(O, { name: (t == null ? void 0 : t.okText) || "保存", type: "primary", widget: () => s({ onSuccess: e }) }), m(O, { name: (t == null ? void 0 : t.cancelText) || "取消", widget: () => e(!1) })] }), extras: i, children: m(Mn, { form: a, code: r, primaryKey: n, ...o }) });
|
|
}, xi = /* @__PURE__ */ new Set(), Yt = (t = [], e = 0) => {
|
|
const i = t[e];
|
|
if (i.length && !xi.has(i)) {
|
|
const r = document.createElement("script");
|
|
r.setAttribute("src", i), r.setAttribute("data-namespace", i), t.length > e + 1 && (r.onload = () => {
|
|
Yt(t, e + 1);
|
|
}, r.onerror = () => {
|
|
Yt(t, e + 1);
|
|
}), xi.add(i), document.body.appendChild(r);
|
|
}
|
|
}, St = ({ className: t, type: e, style: i = {}, ...r }) => m("span", { role: "img", className: F("ff-iconfont", t), style: i, ...r, children: m("svg", { style: { width: "1em", height: "1em", fill: "currentColor", overflow: "hidden" }, viewBox: "0 0 1024 1024", children: m("use", { xlinkHref: `#${e}` }) }) });
|
|
St.propTypes = { className: b.string, type: b.string.isRequired, style: b.object }, St.init = Yt;
|
|
const Dn = (t, e, i, r) => ne.redirect(i, e, r), Vn = (t, e = {}, i, r = {}) => {
|
|
var o;
|
|
const n = (o = r.router) == null ? void 0 : o.reduce((a, [s, l, d]) => {
|
|
const u = f.get(e, ["router", s]);
|
|
if (!u && u !== 0 && l) throw `请传入 ${d}`;
|
|
return `${a}/${u}`;
|
|
}, `/api/${i}`);
|
|
return z.del(n, e.param).msg();
|
|
}, vi = (t, e, i, { status: { loading: r, disabled: n }, setStatus: o, listFn: a }) => {
|
|
const s = { loading: (l) => l === void 0 ? r : o((d) => ({ ...d, loading: l })), disabled: (l) => l === void 0 ? n : o((d) => ({ ...d, disabled: l })), list: a };
|
|
return f.isFunction(i) ? i.call(null, e, s) : f.isString(i) && i ? Me.exec(i, e, s) : null;
|
|
}, Ni = (t, e, i, r, n) => f.isString(i) && i ? se.getWidgetComponent(i).then(({ default: o }) => re.modal(o, { ...e, $setting: r }, n != null && n.title ? { ...n, title: f.template(n.title)(t) } : n)).catch((o) => {
|
|
re.error(i, { content: o.toString() });
|
|
}) : re.modal(i, { ...e, $setting: r }, n != null && n.title ? { ...n, title: f.template(n.title)(t) } : n), zn = (t, e, i, r, n) => re.modal(or, { ...e, $setting: r, code: i }, n != null && n.title ? { ...n, title: f.template(n.title)(t) } : n), Bn = (t, e, i, r, n) => re.modal(ii, { base62params: e, $setting: r, listCode: i }, n != null && n.title ? { ...n, title: f.template(n.title)(t) } : n), Wn = ({ widget: t, widgetType: e, widgetData: i, widgetProps: r, widgetSetting: n, widgetContainerProps: o }, { onAfterClick: a, onBeforeClick: s } = {}) => {
|
|
const l = ge(le), [d, u] = A({ leading: !0, trailing: !1 }), p = K(() => {
|
|
switch (e) {
|
|
case "redirect":
|
|
return f.partialRight(Dn, t, n);
|
|
case "func":
|
|
return f.partialRight(vi, (n == null ? void 0 : n.code) ?? t, { status: d, setStatus: u, listFn: l });
|
|
case "component":
|
|
case "fsdpf-component":
|
|
return f.partialRight(Ni, t, n, o);
|
|
case "grid-layout-form":
|
|
return f.partialRight(zn, t, n, o);
|
|
case "data-list":
|
|
return f.partialRight(Bn, t, n, o);
|
|
case "destroy":
|
|
return f.partialRight(Vn, t, n, o);
|
|
default:
|
|
if (ai(t) || E.isValidElement(t)) return f.partialRight(Ni, t, n, o);
|
|
if (f.isFunction(t)) return f.partialRight(vi, (n == null ? void 0 : n.code) || t, { status: d, setStatus: u });
|
|
}
|
|
return (...h) => console.error("useButton unknown widgetType", e, ...h);
|
|
}, [t, e, l.getBase62params, l.getSelectedRows]);
|
|
return [f.debounce((h) => (s == null || s(h), Promise.resolve(Nt(r, h, { list: l })).then((g) => p(h, { ...i, ...g })).then((g) => a == null ? void 0 : a(g)).catch(console.error)), 300, { leading: !0, trailing: !1 }), d];
|
|
}, ar = ({ type: t, name: e, className: i, icon: r, iconPosition: n, size: o }, a = "default") => K(() => {
|
|
const s = { type: "primary", className: F("ff-button", i), iconPosition: n, size: o };
|
|
return t === "danger" ? s.danger = !0 : t === "default" && (s.type = t), a === "link" || a === "dashed" ? (s.type = a, t === "default" && (s.className = F(s.className, "ff-default"))) : a !== "circle" && a !== "round" || (s.shape = a), r && (s.icon = m(St, { type: r })), e && (s.children = e), s;
|
|
}, [a, t, i, r, n]), Rt = ({ data: t, widget: e, widgetType: i = "fsdpf-component", widgetData: r, widgetProps: n, widgetSetting: o, widgetContainerProps: a, onAfterClick: s, onBeforeClick: l, children: d, extras: u }) => {
|
|
const p = ge(le), [h, g] = A(!1), [y, w] = A("hover"), [C, S] = nr(n, t, { list: p }, [p.getBase62params, p.getSelectedRows]), [P, k] = A(), { placement: $, align: R, zIndex: L, arrow: v = { pointAtCenter: !0 }, getPopupContainer: j, isPopupMountBodyContainer: D = !0, ...N } = a || {};
|
|
U(() => {
|
|
i == "grid-layout-form" ? k(E.createElement(or, { ...r, $setting: o, code: e })) : i == "data-list" ? k(E.createElement(ii, { base62params: t, $setting: o, listCode: e })) : f.isString(e) ? se.getWidgetComponent(e).then(({ default: B }) => {
|
|
k(E.createElement(B, { ...r, $setting: o }));
|
|
}).catch((B) => k(B.toString())) : E.isValidElement(e) ? k(E.cloneElement(e, { ...r, $setting: o })) : (ai(e) || f.isFunction(e) && ["component", "fsdpf-component"].includes(i)) && k(E.createElement(e, { ...r, $setting: o }));
|
|
}, [e, i, r]);
|
|
const M = (B, he = !1) => (g(B), !B && w("hover"), B ? l == null ? void 0 : l(C) : s == null ? void 0 : s(he)), V = (B) => {
|
|
g(!0), w("click");
|
|
};
|
|
return m(Vr, { zIndex: L, placement: $, onPopupClick: V, onClick: V, open: h, align: R, arrow: v, trigger: y, getPopupContainer: j || D ? void 0 : (B) => B, content: m(Un, { ...N, extras: u, children: P && E.cloneElement(P, { ...C, $setProps: S, $close: (B) => M(!1, B) }) }), children: d, onOpenChange: M });
|
|
}, Un = ({ title: t, className: e, classNames: i, children: r, extras: n, width: o, height: a, ...s }) => {
|
|
const [l, d] = A({}), u = _((y, w) => d((C) => ({ ...C, [y]: w })), []), p = _((y) => d((w) => ({ ...w, [y]: void 0 })), []), h = t ? E.createElement("div", { className: "ff-popup-title" }, t) : l == null ? void 0 : l.title, g = n ?? E.createElement("div", { className: "ff-popup-reserved-extras" }, n);
|
|
return m(ht.Provider, { value: { ele: l, mount: u, unmount: p }, children: I("div", { className: F("ff-popup ff-popover", e, l.rootClassName), style: { width: o ?? 260, height: a }, ...s, children: [I("div", { className: F("ff-popup-header", "ff-popover-header", i == null ? void 0 : i.header), children: [h, l == null ? void 0 : l["sub-title"]] }), m("div", { className: F("ff-popup-body", "ff-popover-body", i == null ? void 0 : i.body), children: r }), I("div", { className: F("ff-popup-footer", "ff-popover-footer", i == null ? void 0 : i.footer), children: [g, l == null ? void 0 : l.extras, l == null ? void 0 : l.actions] })] }) });
|
|
};
|
|
Rt.propTypes = { widgetType: b.oneOf(["fsdpf-component", "grid-layout-form", "data-list"]) };
|
|
const ft = (t) => function({ className: e, variant: i, children: r, name: n, icon: o, type: a = "default", iconPosition: s = "start", noAuthType: l, onAfterClick: d, onBeforeClick: u, data: p, loading: h, disabled: g, tooltip: y, confirm: w, widget: C = () => {
|
|
}, widgetType: S, widgetData: P, widgetProps: k, widgetSetting: $, widgetContainerProps: R, ...L }) {
|
|
const { mode: v, ...j } = R || {}, D = ar({ className: e, name: n, type: a, icon: o, iconPosition: s }, i ?? t), N = m(Ct, { ...D, ...L, children: r || n });
|
|
if (v === "popover" && !["destroy", "redirect", "func"].includes(S)) return m(Rt, { data: p, widget: C, widgetType: S, widgetData: P, widgetProps: k, widgetSetting: $, widgetContainerProps: j, onAfterClick: d, onBeforeClick: u, children: N });
|
|
const M = f.isEmpty(y) || !y.enabled ? {} : y, V = f.isEmpty(w) ? { enabled: !1 } : Object.assign({ enabled: !0 }, w), [B, he] = A(!1), [ae, { disabled: W, loading: ce }] = Wn({ widget: C, widgetType: S, widgetData: P, widgetProps: k, widgetSetting: $, widgetContainerProps: j }, { onAfterClick: d, onBeforeClick: u });
|
|
return m(zr, { okText: "确定", cancelText: "取消", getPopupContainer: (Y) => Y, ...V, disabled: W || g, open: B, onOpenChange: (Y) => {
|
|
if (!Y) return he(Y);
|
|
V.enabled ? he(Y) : ae(p);
|
|
}, onConfirm: (Y) => {
|
|
ae(p, Y);
|
|
}, onClick: (Y) => {
|
|
Y.stopPropagation();
|
|
}, children: m(Br, { getPopupContainer: (Y) => Y, ...M, title: B ? null : M == null ? void 0 : M.title, trigger: ["hover", "click"], children: E.cloneElement(N, { loading: ce || h, disabled: W || g }) }) });
|
|
}, O = ft("default");
|
|
O.propTypes = { type: b.oneOf(["primary", "default", "danger", ""]), size: b.oneOf(["large", "middle", "small"]), name: b.string, icon: b.string, iconPosition: b.oneOf(["start", "end"]), data: b.any, widget: b.any, widgetType: b.oneOf(["destroy", "redirect", "func", "component", "fsdpf-component", "grid-layout-form", "grid-layout", "data-list"]), widgetData: b.object, widgetProps: b.object, widgetSetting: b.object, widgetContainerProps: b.object, tooltip: b.exact({ title: b.string.isRequired, placement: b.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: b.oneOfType([b.bool, b.number]), getPopupContainer: b.func }), confirm: b.exact({ title: b.string.isRequired, cancelText: b.string, okText: b.string, okType: b.oneOf(["primary", "default", "danger", ""]), placement: b.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: b.oneOfType([b.bool, b.number]), getPopupContainer: b.func, arrow: b.oneOfType([b.bool, b.exact({ pointAtCenter: b.bool })]) }) };
|
|
const qn = ft("link"), Kn = ft("circle"), Hn = ft("round"), Jn = ft("dashed"), Ti = ({ options: t = [], triggerWeights: e = ["grid-layout-form", "grid-layout", "fsdpf-component", "print"], onAfterClick: i = (g, y, w) => {
|
|
}, onBeforeClick: r = (g, y, w) => {
|
|
}, labelVariant: n = "link", labelSize: o, labelRender: a, btnVariant: s, btnSize: l, btnRender: d = (g, y) => m(O, { ...g, data: y }, g.uuid || Vt()), widgetContainerProps: u = {}, children: p, data: h }) => {
|
|
if (f.isEmpty(t)) return p;
|
|
const [g, y] = K(() => (t || []).reduce((C, S) => {
|
|
const P = e.indexOf(S.widgetType);
|
|
return P === -1 ? C[1].push(S) : C[0] ? P < e.indexOf(C[0].widgetType) ? (C[1].push(C[0]), C[0] = S) : C[1].push(S) : C[0] = S, C;
|
|
}, [null, []]), [t, e]);
|
|
a ? p = a(g, h) || p : p || (p = m(Ct, { ...ar(Object.assign(g != null && g.name || g != null && g.icon ? {} : { icon: "icon-location" }, g, { size: o }), n) }));
|
|
const w = y.map((C) => d(Object.assign({ uuid: C.uuid, type: C.type, name: C.name, widget: C.widget, widgetType: C.widgetType, widgetProps: C.widgetProps, widgetData: C.widgetData, widgetSetting: C.widgetSetting, widgetContainerProps: C.widgetContainerSetting, confirm: C.confirm, onAfterClick: f.partialRight(i, C, h), onBeforeClick: f.partialRight(r, C, h) }, { size: l, variant: s }), h));
|
|
return m(Rt, { widget: g == null ? void 0 : g.widget, widgetType: g == null ? void 0 : g.widgetType, widgetProps: g == null ? void 0 : g.widgetProps, widgetSetting: g == null ? void 0 : g.widgetSetting, widgetContainerProps: Object.assign({}, u, g == null ? void 0 : g.widgetContainerProps), data: h, widgetData: g == null ? void 0 : g.widgetData, extras: w, onAfterClick: f.partialRight(i, g, h), onBeforeClick: f.partialRight(r, g, h), children: p });
|
|
};
|
|
Ti.propTypes = { triggerWeights: b.array, options: b.arrayOf(b.shape({ ...O.propTypes, widgetType: O.propTypes.widgetType.isRequired })), btnSize: O.propTypes.size, btnRender: b.func, btnVariant: b.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelVariant: b.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelRender: b.func, labelSize: O.propTypes.size, onAfterClick: b.func, onBeforeClick: b.func, widgetContainerProps: O.propTypes.widgetContainerProps, data: O.propTypes.data }, O.Link = qn, O.Link.defaultProps = O.defaultProps, O.Link.propTypes = O.propTypes, O.Circle = Kn, O.Circle.defaultProps = O.defaultProps, O.Circle.propTypes = O.propTypes, O.Round = Hn, O.Round.defaultProps = O.defaultProps, O.Round.propTypes = O.propTypes, O.Dashed = Jn, O.Dashed.defaultProps = O.defaultProps, O.Dashed.propTypes = O.propTypes, O.Popover = Rt, O.GroupPopover = Ti;
|
|
const _n = ({ fields: t, formProps: e, $close: i }) => {
|
|
const [r] = oe.useForm(), n = K(() => [{ name: "__PROPS__", value: e }], [e]);
|
|
return m(ee, { actions: I(E.Fragment, { children: [m(O, { name: "取消", widget: () => i(!1) }), m(O, { name: "确定", type: "primary", widget: () => r.validateFields(!0).then(i) })] }), children: m(oe, { fields: n, form: r, className: "ff-modal-form", children: t == null ? void 0 : t.map(({ code: o, ...a }) => m(ri, { code: o, ...a }, o)) }) });
|
|
}, Yn = ({ className: t, classNames: e, $close: i, children: r, title: n, subTitle: o, actions: a, extras: s, ...l }) => I(_r, { ...l, prefixCls: "ff-drawer", className: F("ff-popup", t), maskMotion: { motionAppear: !0, motionName: "mask-motion" }, motion: (d) => ({ motionAppear: !0, motionName: `panel-motion-${d}` }), children: [I("div", { className: F("ff-popup-header", "ff-drawer-header", e == null ? void 0 : e.header), children: [m("button", { "aria-label": "Close", className: F("ff-popup-close", "ff-drawer-close", e == null ? void 0 : e.close), onClick: l.onClose, children: m(ei, { type: "close" }) }), n, o] }), m("div", { className: F("ff-popup-body", "ff-drawer-body", e == null ? void 0 : e.body), children: r }), I("div", { className: F("ff-popup-footer", "ff-drawer-footer", e == null ? void 0 : e.footer), children: [s, a] })] }), Gn = ({ className: t, classNames: e, $close: i, $event: r, children: n, title: o, subTitle: a, actions: s, extras: l, placement: d, ...u }) => {
|
|
const p = (r == null ? void 0 : r.pageX) === void 0 ? { animation: null, maskAnimation: null, mousePosition: { x: null, y: null } } : { animation: "zoom", maskAnimation: "fade", mousePosition: { x: r == null ? void 0 : r.pageX, y: r == null ? void 0 : r.pageY } };
|
|
return m(Yr, { ...u, ...p, prefixCls: "ff-modal", modalRender: () => I("div", { className: F("ff-modal-content ff-popup", t), children: [I("div", { className: F("ff-popup-header", "ff-modal-header", e == null ? void 0 : e.header), children: [m("button", { "aria-label": "Close", className: F("ff-popup-close", "ff-modal-close", e == null ? void 0 : e.close), onClick: u.onClose, children: m(ei, { type: "close" }) }), o, a] }), m("div", { className: F("ff-popup-body", "ff-modal-body", e == null ? void 0 : e.body), children: n }), I("div", { className: F("ff-popup-footer", "ff-modal-footer", e == null ? void 0 : e.footer), children: [l, s] })] }) });
|
|
}, sr = ({ placement: t, $close: e, $event: i, children: r, title: n, ...o }) => {
|
|
const [a, s] = A({}), [l, d] = A(!0), u = _((y, w) => s((C) => ({ ...C, [y]: w })), []), p = _((y) => s((w) => ({ ...w, [y]: void 0 })), []);
|
|
let h = { ...o, className: a.rootClassName, title: a.title || n && E.createElement("div", { className: F("ff-popup-title") }, n), subTitle: a["sub-title"], actions: a.actions, extras: a.extras, children: r, $close: e, $event: i, onClose: () => d(!1) };
|
|
const g = () => {
|
|
e(!1);
|
|
};
|
|
return m(ht.Provider, { value: { ele: a, mount: u, unmount: p }, children: t && t !== "center" ? m(Yn, { ...h, placement: t, open: l, afterOpenChange: (y) => !y && g() }) : m(Gn, { ...h, visible: l, afterClose: g }) });
|
|
};
|
|
sr.propTypes = { placement: b.oneOf(["center", "left", "top", "right", "bottom"]) };
|
|
const Xn = ({ widget: t, widgetProps: e, $close: i, onSetProps: r }) => {
|
|
const [n, o] = A(e || {}), a = Ai(e);
|
|
Zt(() => {
|
|
const l = a ?? {}, d = e ?? {}, u = Object.keys({ ...l, ...d }).reduce((p, h) => (l[h] !== d[h] && (p[h] = d[h]), p), {});
|
|
Object.keys(u).length > 0 && o((p) => ({ ...p, ...u }));
|
|
}, [e]);
|
|
const s = _((l) => {
|
|
o((d) => ({ ...d, ...l })), r == null || r(l);
|
|
}, [r]);
|
|
return E.isValidElement(t) ? E.cloneElement(t, { ...n, $close: i, $setProps: s }) : t != null && t.name || bi.isForwardRef(t) || (t == null ? void 0 : t.$$typeof) === bi.ForwardRef ? E.createElement(t, { ...n, $close: i, $setProps: s }) : t;
|
|
}, ie = () => {
|
|
const [t, e] = Nr({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (o) => {
|
|
const { offsetHeight: a } = o;
|
|
return { height: a };
|
|
}, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, i] = E.useReducer((o) => o + 1, 0);
|
|
U(() => {
|
|
ie.$onClick = r, ie.$queue.forEach(([o, a, s], l, d) => {
|
|
n([a, s], ...o), delete d[l];
|
|
});
|
|
}, []);
|
|
const r = (o, a = {}, s = {}) => new Promise((l, d) => n([l, d], o, a, s)), n = ([o, a], s, l = {}, d = {}) => {
|
|
const u = ie.$index++, p = (y) => ((w, C) => (ie.$popups.delete(w), i(), C == null ? void 0 : C()))(u, () => o(y));
|
|
if (s === Vi) return t.open({ ...d, key: u, content: E.createElement(s, { ...l, $close: () => t.close(u) }) });
|
|
const { $setProps: h, ...g } = l;
|
|
ie.$popups.set(u, E.createElement(sr, { maskClosable: !1, $event: g == null ? void 0 : g.$event, ...d, key: u, $close: p }, E.createElement(Xn, { widget: s, widgetProps: g, $close: p, onSetProps: h }))), i();
|
|
};
|
|
return I(E.Fragment, { children: [Array.from(ie.$popups).map(([o, a]) => a), e] });
|
|
};
|
|
ie.$popups = /* @__PURE__ */ new Map(), ie.$index = 0, ie.$queue = [], ie.$onClick = (...t) => new Promise((e, i) => {
|
|
ie.$queue.push([t, e, i]);
|
|
});
|
|
const Oi = (t, e, i = {}) => ie.$onClick(t, e, i), Mt = (t, { showProgress: e, duration: i, ...r } = { duration: 1.5 }) => ie.$onClick(Vi, { content: t, ...r }, { showProgress: e, duration: i }), re = { modal: Oi, confirm: (t, e = {}) => ie.$onClick(Gr, { content: t, ...e }, { placement: "center" }), form: (t, e = {}, i = {}) => Oi(_n, { formProps: i, fields: t }, { placement: "center", ...e }).then((r) => {
|
|
if (r === !1) throw !1;
|
|
return r;
|
|
}), notification: Mt, success: (t, e = { duration: 1.5 }) => Mt(t, { ...e, className: "ff-notification-success", icon: "check" }), error: (t, e = { duration: 1.5 }) => Mt(t, { ...e, className: "ff-notification-error", icon: "close" }) };
|
|
tt.configure({ showSpinner: !1 });
|
|
const lr = () => {
|
|
const t = window.localStorage.getItem(bt);
|
|
return Object.freeze({ Platform: "web", SaaS: window.localStorage.getItem("SaaS"), Authorization: t ? `Bearer ${t} ` : void 0 });
|
|
};
|
|
Ve.interceptors.request.use((t) => (Object.assign(t.headers, lr()), tt.inc(), t), (t) => (tt.done(), Promise.reject({ code: -1, msg: t }))), Ve.interceptors.response.use(({ data: t, headers: e }) => (tt.done(), { ...t, res: e == null ? void 0 : e.res }), function(t) {
|
|
return tt.done(), Promise.reject(t.message);
|
|
}), window.addEventListener("unhandledrejection", zt.onUnhandledRejection), zt.onMsg = (t, e) => re[[0, 1].includes(t) ? "success" : "error"](e).then(() => t === 20300 && ne.redirect(qe.get("Common.WEBSITE_LOGIN_PAGE")));
|
|
var Xe, Ue, Qe;
|
|
const Q = class Q {
|
|
constructor() {
|
|
T(this, "appUrl", "");
|
|
x(this, Xe, null);
|
|
return c(Q, Ue) || (q(Q, Qe, new zt()), q(Q, Ue, new Proxy(this, { get(e, i) {
|
|
if (i in e) {
|
|
const r = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e), i);
|
|
return r != null && r.get ? Reflect.get(e, i, e) : typeof e[i] == "function" ? e[i].bind(e) : e[i];
|
|
}
|
|
return c(Q, Qe)[i];
|
|
} }))), c(Q, Ue);
|
|
}
|
|
init(e, i, r) {
|
|
Ve.defaults.baseURL = this.appUrl = r, Ve.defaults.timeout = 15e3, c(Q, Qe).init(e, i, Ve);
|
|
}
|
|
get driver() {
|
|
return Ve;
|
|
}
|
|
get headers() {
|
|
return lr();
|
|
}
|
|
mock(e = {}) {
|
|
return c(this, Xe) ?? q(this, Xe, new Rr(Ve, { onNoMatch: "passthrough", ...e }));
|
|
}
|
|
unmock() {
|
|
var e;
|
|
(e = c(this, Xe)) == null || e.restore(), q(this, Xe, null);
|
|
}
|
|
};
|
|
Xe = new WeakMap(), Ue = new WeakMap(), Qe = new WeakMap(), x(Q, Ue), x(Q, Qe), T(Q, "getInstance", () => c(Q, Ue) ?? q(Q, Ue, new Q()));
|
|
let Gt = Q;
|
|
const z = Gt.getInstance();
|
|
class oi extends Error {
|
|
constructor(e, i) {
|
|
super(i), Error.captureStackTrace && Error.captureStackTrace(this, oi), !i instanceof it && (this.name = `${e} Error Runtime`);
|
|
}
|
|
}
|
|
class it extends Error {
|
|
constructor(e, ...i) {
|
|
super(...i), Error.captureStackTrace && Error.captureStackTrace(this, it), this.name = `${e} Not Found`;
|
|
}
|
|
}
|
|
const Dt = "mine", bt = "token";
|
|
var Ie, Ze;
|
|
const Ce = class Ce {
|
|
constructor() {
|
|
x(this, Ze, /* @__PURE__ */ new Map());
|
|
T(this, "setVendor", (e, i) => c(this, Ze).set(e, new Mi(i, async (r, n) => {
|
|
var a, s;
|
|
if (!(r != null && r.default)) throw "@pkg not found";
|
|
let o = () => n;
|
|
switch ("function") {
|
|
case typeof (o = (a = r.default) == null ? void 0 : a[`./${n}/index.jsx`]):
|
|
case typeof (o = (s = r.default) == null ? void 0 : s[`./${n}/index.js`]):
|
|
return o();
|
|
}
|
|
throw new it(n);
|
|
})));
|
|
T(this, "getWidgetComponent", async (e) => {
|
|
if (!e) throw "getWidgetComponent widget is required";
|
|
if (e != null && e.startsWith("blob:") || e != null && e.startsWith("http:") || e != null && e.startsWith("https:")) return await import(e);
|
|
const [, i] = e == null ? void 0 : e.split("@pkg/");
|
|
if (!i) throw new it(e);
|
|
try {
|
|
return c(this, Ze).has("pkg") ? await c(this, Ze).get("pkg").get(i) : await import(`${z.appUrl}/api/pkg-import/web?name=${e}`);
|
|
} catch (r) {
|
|
throw new oi(e, r);
|
|
}
|
|
});
|
|
T(this, "getRoutes", () => z.get("/api/my-router").then((e) => [...e, { 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, ...r }) => [i, { uuid: i, ...r }])).then((e) => new Map(e)));
|
|
T(this, "getMenus", () => z.get("/api/my-menu"));
|
|
T(this, "getConfigure", () => z.get("api/init-configure"));
|
|
T(this, "getWidgetOperationAuth", () => z.get("/api/init-widget-operation-auth").then((e) => e.reduce((i, { uuid: r, auth: n }) => [...i, [r, n]], [])));
|
|
T(this, "getPhoneNumber", (e) => z.get(`/api/user-wx-phone-number/${e}`));
|
|
T(this, "getUserToken", () => {
|
|
const e = window.localStorage.getItem(bt);
|
|
if (!e) return "";
|
|
const i = e.split(".");
|
|
if (!Array.isArray(i) || i.length !== 3) throw "登录令牌无效!";
|
|
const { iat: r } = JSON.parse(window.atob(i[1]));
|
|
if (Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - r > 2592e3) throw "登录令牌已过期, 请重新登录!";
|
|
return e;
|
|
});
|
|
T(this, "checkUserToken", () => {
|
|
try {
|
|
return !!this.getUserToken();
|
|
} catch {
|
|
return !1;
|
|
}
|
|
});
|
|
T(this, "getUserInfo", (e = !0) => {
|
|
var i;
|
|
try {
|
|
const r = this.getUserToken();
|
|
if (!r) return Promise.resolve(null);
|
|
const { iat: n } = JSON.parse(window.atob((i = r == null ? void 0 : r.split(".")) == null ? void 0 : i[1])), { iat: o, ...a } = z.decode(window.localStorage.getItem(Dt) || "", {});
|
|
return o === n ? Promise.resolve(a) : z.get("/api/mine-info").then(({ User: s = null }) => (window.localStorage.setItem(Dt, z.encode({ ...s, iat: n })), s));
|
|
} catch (r) {
|
|
console.error(r), e && re.error("请登录").then(this.logout);
|
|
}
|
|
return Promise.resolve(null);
|
|
});
|
|
T(this, "login", (e, i, r = {}) => z.post("/api/user-token", { username: e, passwd: Fr.hash(i), platform: "web", ...r }).then(({ token: n }) => (window.localStorage.setItem(bt, n), n)).then(async (n) => (await this.initAppEnv(), n)));
|
|
T(this, "logout", (e) => (window.localStorage.removeItem(Dt), window.localStorage.removeItem(bt), e == null ? void 0 : e()));
|
|
T(this, "initAppEnv", async () => {
|
|
const [e, i, r, n] = await Promise.all([this.getWidgetOperationAuth(), this.getRoutes(), this.getMenus(), this.getConfigure()]);
|
|
return zi.init(e), qe.init(n), ne.init(i, r), St.init(qe.get("Common.ICONFONT")), { widgetOperationAuth: e, routes: i, menus: r, configures: n };
|
|
});
|
|
if (c(Ce, Ie)) return c(Ce, Ie);
|
|
}
|
|
};
|
|
Ie = new WeakMap(), Ze = new WeakMap(), x(Ce, Ie, null), T(Ce, "getInstance", () => (c(Ce, Ie) || q(Ce, Ie, new Ce()), c(Ce, Ie)));
|
|
let Xt = Ce;
|
|
const se = Xt.getInstance(), Qn = E.createContext({ user: {}, initUser: () => {
|
|
}, initUserComplete: !1 }), Zn = E.createContext({ set: () => {
|
|
}, get: () => {
|
|
}, assign: () => {
|
|
}, currentRoute: () => {
|
|
} }), ai = (t) => {
|
|
if (!t) return !1;
|
|
if (t.prototype instanceof E.Component || t.$$typeof) return !0;
|
|
if (typeof t == "function") {
|
|
const e = t.displayName || t.name;
|
|
return !e || /^[A-Z]/.test(e);
|
|
}
|
|
return !1;
|
|
}, eo = (t, e) => {
|
|
if (!t || typeof window > "u") return;
|
|
let i = document.querySelector(`style[ff-style-token="${e}"]`);
|
|
return i ? (i.innerHTML = t, t) : (i = document.createElement("style"), i.setAttribute("ff-style-token", e), i.setAttribute("type", "text/css"), i.innerHTML = t, document.head.appendChild(i), t);
|
|
}, to = Object.freeze(Object.defineProperty({ __proto__: null, AppContext: Qn, AppGlobalParamsContext: Zn, cache: Mi, configure: qe, default: se, func: Me, http: z, insertStyle: eo, isReactComponent: ai, route: ne }, Symbol.toStringTag, { value: "Module" }));
|
|
var ve, et, Ne, Se, Ee, te, Z, G, $e, ct, dt, ut, pt, vt, gt;
|
|
const si = class si {
|
|
constructor(e, i = "/") {
|
|
x(this, ve, "/");
|
|
x(this, et, /* @__PURE__ */ new Set());
|
|
x(this, Ne, (e) => {
|
|
for (const i of c(this, et)) try {
|
|
i(e);
|
|
} catch (r) {
|
|
console.error("Error in VirtualFS event listener:", r);
|
|
}
|
|
});
|
|
x(this, Se, (e) => {
|
|
const i = Date.now();
|
|
if (e && (e.lastModified = i), c(this, ve) != "/") {
|
|
const r = c(this, G).call(this, c(this, ve));
|
|
r && (r.lastModified = i);
|
|
}
|
|
this.root.lastModified = i;
|
|
});
|
|
x(this, Ee, (e) => {
|
|
let i = me.normalize(e);
|
|
return i.startsWith("/") || (i = "/" + i), i.length > 1 && i.endsWith("/") && (i = i.slice(0, -1)), i;
|
|
});
|
|
x(this, te, (e) => {
|
|
const i = me.join(c(this, ve), e);
|
|
return c(this, Ee).call(this, i);
|
|
});
|
|
x(this, Z, (e) => {
|
|
if (!e || typeof e != "string") return !1;
|
|
const i = c(this, Ee).call(this, e);
|
|
return !i.includes("..") && i.startsWith("/");
|
|
});
|
|
x(this, G, (e) => {
|
|
var o;
|
|
const i = c(this, Ee).call(this, e);
|
|
if (i === "/") return this.root;
|
|
const r = i.split("/").filter((a) => a);
|
|
let n = this.root;
|
|
for (const a of r) {
|
|
if (n.type !== "dir") return null;
|
|
const s = (o = n.children) == null ? void 0 : o.find((l) => l.name === a);
|
|
if (!s) return null;
|
|
n = s;
|
|
}
|
|
return n;
|
|
});
|
|
x(this, $e, (e) => {
|
|
const i = c(this, Ee).call(this, e), r = me.basename(i), n = me.dirname(i);
|
|
return { parent: c(this, G).call(this, n), name: r };
|
|
});
|
|
x(this, ct, (e, i, r) => r === !1 ? e : r === "root" ? e.map((n) => me.join(i, n)) : r === !0 || r === "working" ? e.map((n) => me.relative(c(this, ve), me.join(i, n))) : e);
|
|
x(this, dt, async (e, i, r, n = "") => {
|
|
const o = [], a = c(this, G).call(this, e);
|
|
if (!a || a.type !== "dir") return o;
|
|
const s = a.children;
|
|
for (const l of s) {
|
|
const d = l.name, u = e === "/" ? `/${d}` : `${e}/${d}`, p = n ? `${n}/${d}` : d;
|
|
try {
|
|
if (l.type === "file") i(r ? p : d) && o.push(p);
|
|
else if (l.type === "dir" && r) {
|
|
const h = await c(this, dt).call(this, u, i, r, p);
|
|
o.push(...h);
|
|
}
|
|
} catch {
|
|
continue;
|
|
}
|
|
}
|
|
return o;
|
|
});
|
|
x(this, ut, async (e, i, r, n = "") => {
|
|
const o = [], a = Array.isArray(i) ? i : [i], s = c(this, G).call(this, e);
|
|
if (!s || s.type !== "dir") return o;
|
|
if (!r) {
|
|
for (const d of a) if (c(this, pt).call(this, d)) {
|
|
const u = await c(this, vt).call(this, e, d);
|
|
o.push(...u);
|
|
} else {
|
|
const u = me.join(e, d), p = c(this, Ee).call(this, u);
|
|
c(this, G).call(this, p) && o.push(d);
|
|
}
|
|
return o;
|
|
}
|
|
const l = s.children;
|
|
for (const d of l) {
|
|
const u = d.name, p = e === "/" ? `/${u}` : `${e}/${u}`, h = n ? `${n}/${u}` : u;
|
|
try {
|
|
if (d.type === "file") for (const g of a) {
|
|
let y = !1;
|
|
if (y = c(this, pt).call(this, g) ? c(this, gt).call(this, u, g) : u === g, y) {
|
|
o.push(h);
|
|
break;
|
|
}
|
|
}
|
|
else if (d.type === "dir") {
|
|
const g = await c(this, ut).call(this, p, i, r, h);
|
|
o.push(...g);
|
|
}
|
|
} catch {
|
|
continue;
|
|
}
|
|
}
|
|
return o;
|
|
});
|
|
x(this, pt, (e) => /[*?[\]{}]/.test(e));
|
|
x(this, vt, async (e, i) => {
|
|
const r = [], n = c(this, G).call(this, e);
|
|
if (!n || n.type !== "dir") return r;
|
|
const o = n.children.map((a) => a.name);
|
|
for (const a of o) c(this, gt).call(this, a, i) && r.push(a);
|
|
return r;
|
|
});
|
|
x(this, gt, (e, i) => {
|
|
const r = i.replace(/\./g, "\\.").replace(/\*/g, ".*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (n, o) => "(" + o.split(",").join("|") + ")");
|
|
return new RegExp(`^${r}$`).test(e);
|
|
});
|
|
var r, n, o;
|
|
q(this, ve, i), this.root = { name: "/", type: "dir", children: [], lastModified: Date.now() }, Array.isArray(e) ? this.root.children = e : e && typeof e == "object" && (e.name && e.name !== "/" ? this.root.children.push(e) : (this.root = e, (r = this.root).name ?? (r.name = "/"), (n = this.root).children ?? (n.children = []), (o = this.root).lastModified ?? (o.lastModified = Date.now())));
|
|
}
|
|
async stat(e) {
|
|
const i = c(this, te).call(this, e);
|
|
if (!c(this, Z).call(this, i)) throw new Error(`EINVAL: invalid path '${e}'`);
|
|
const r = c(this, G).call(this, i);
|
|
if (!r) throw new Error(`ENOENT: no such file or directory, stat '${e}'`);
|
|
return { isFile: () => r.type === "file", isDirectory: () => r.type === "dir", lastModified: r.lastModified };
|
|
}
|
|
async dir(e) {
|
|
const i = c(this, te).call(this, e);
|
|
if (!c(this, Z).call(this, i)) throw new Error(`EINVAL: invalid path '${e}'`);
|
|
const r = c(this, G).call(this, i);
|
|
if (!r) throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);
|
|
if (r.type !== "dir") throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);
|
|
return r.children.map((n) => n.name);
|
|
}
|
|
async readFile(e) {
|
|
const i = c(this, te).call(this, e);
|
|
if (!c(this, Z).call(this, i)) throw new Error(`EINVAL: invalid path '${e}'`);
|
|
const r = c(this, G).call(this, i);
|
|
if (!r) throw new Error(`ENOENT: no such file or directory, open '${e}'`);
|
|
if (r.type !== "file") throw new Error("EISDIR: illegal operation on a directory, read");
|
|
return r.content || "";
|
|
}
|
|
async writeFile(e, i) {
|
|
const r = c(this, te).call(this, e);
|
|
if (!c(this, Z).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`);
|
|
const { parent: n, name: o } = c(this, $e).call(this, r);
|
|
if (!n) throw new Error(`ENOENT: no such file or directory, open '${e}'`);
|
|
if (n.type !== "dir") throw new Error("ENOTDIR: not a directory");
|
|
const a = n.children.findIndex((d) => d.name === o), s = a >= 0, l = { name: o, type: "file", content: i, lastModified: Date.now() };
|
|
s ? n.children[a] = l : n.children.push(l), c(this, Se).call(this, n), c(this, Ne).call(this, { action: s ? "update" : "create", path: r, type: "file", timestamp: Date.now() });
|
|
}
|
|
async mkdir(e, i = {}) {
|
|
const r = c(this, te).call(this, e);
|
|
if (!c(this, Z).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`);
|
|
const { recursive: n } = i;
|
|
if (n) {
|
|
const o = r.split("/").filter((s) => s);
|
|
let a = "/";
|
|
for (const s of o)
|
|
if (a = me.join(a, s), !c(this, G).call(this, a)) {
|
|
const { parent: l, name: d } = c(this, $e).call(this, a);
|
|
if (l && l.type === "dir") {
|
|
const u = { name: d, type: "dir", children: [], lastModified: Date.now() };
|
|
l.children.push(u), c(this, Se).call(this, l), c(this, Ne).call(this, { action: "create", path: c(this, Ee).call(this, a), type: "dir", timestamp: Date.now() });
|
|
}
|
|
}
|
|
} else {
|
|
const { parent: o, name: a } = c(this, $e).call(this, r);
|
|
if (!o) throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);
|
|
if (o.type !== "dir") throw new Error("ENOTDIR: not a directory");
|
|
if (o.children.find((l) => l.name === a)) throw new Error(`EEXIST: file already exists, mkdir '${e}'`);
|
|
const s = { name: a, type: "dir", children: [], lastModified: Date.now() };
|
|
o.children.push(s), c(this, Se).call(this, o), c(this, Ne).call(this, { action: "create", path: r, type: "dir", timestamp: Date.now() });
|
|
}
|
|
}
|
|
async unlink(e) {
|
|
const i = c(this, te).call(this, e);
|
|
if (!c(this, Z).call(this, i)) throw new Error(`EINVAL: invalid path '${e}'`);
|
|
const { parent: r, name: n } = c(this, $e).call(this, i);
|
|
if (!r) throw new Error(`ENOENT: no such file or directory, unlink '${e}'`);
|
|
const o = r.children.findIndex((a) => a.name === n);
|
|
if (o < 0) throw new Error(`ENOENT: no such file or directory, unlink '${e}'`);
|
|
if (r.children[o].type !== "file") throw new Error(`EISDIR: illegal operation on a directory, unlink '${e}'`);
|
|
r.children.splice(o, 1), c(this, Se).call(this, r), c(this, Ne).call(this, { action: "delete", path: i, type: "file", timestamp: Date.now() });
|
|
}
|
|
async rmdir(e, i = {}) {
|
|
const r = c(this, te).call(this, e);
|
|
if (!c(this, Z).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`);
|
|
const { parent: n, name: o } = c(this, $e).call(this, r);
|
|
if (!n) throw new Error(`ENOENT: no such file or directory, rmdir '${e}'`);
|
|
const a = n.children.findIndex((l) => l.name === o);
|
|
if (a < 0) throw new Error(`ENOENT: no such file or directory, rmdir '${e}'`);
|
|
const s = n.children[a];
|
|
if (s.type !== "dir") throw new Error(`ENOTDIR: not a directory, rmdir '${e}'`);
|
|
if (!i.recursive && s.children.length > 0) throw new Error(`ENOTEMPTY: directory not empty, rmdir '${e}'`);
|
|
n.children.splice(a, 1), c(this, Se).call(this, n), c(this, Ne).call(this, { action: "delete", path: r, type: "dir", timestamp: Date.now() });
|
|
}
|
|
async rename(e, i) {
|
|
const r = c(this, te).call(this, e), n = c(this, te).call(this, i);
|
|
if (!c(this, Z).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`);
|
|
if (!c(this, Z).call(this, n)) throw new Error(`EINVAL: invalid path '${i}'`);
|
|
if (!c(this, G).call(this, r)) throw new Error(`ENOENT: no such file or directory, rename '${e}' -> '${i}'`);
|
|
const { parent: o, name: a } = c(this, $e).call(this, r), { parent: s, name: l } = c(this, $e).call(this, n);
|
|
if (!s) throw new Error(`ENOENT: no such file or directory, rename '${e}' -> '${i}'`);
|
|
if (c(this, G).call(this, n)) throw new Error(`EEXIST: file already exists, rename '${e}' -> '${i}'`);
|
|
const d = o.children.findIndex((p) => p.name === a), u = { ...o.children[d], name: l, lastModified: Date.now() };
|
|
o.children.splice(d, 1), s.children.push(u), c(this, Se).call(this, o), o !== s && c(this, Se).call(this, s), c(this, Ne).call(this, { action: "rename", path: n, oldPath: r, type: u.type, timestamp: Date.now() });
|
|
}
|
|
async exists(e) {
|
|
const i = c(this, te).call(this, e);
|
|
return c(this, Z).call(this, i) ? c(this, G).call(this, i) !== null : !1;
|
|
}
|
|
getLastModified() {
|
|
return this.root.lastModified;
|
|
}
|
|
subscribe(e) {
|
|
if (typeof e != "function") throw new Error("Callback must be a function");
|
|
return c(this, et).add(e), () => {
|
|
c(this, et).delete(e);
|
|
};
|
|
}
|
|
getWorkingDirectory() {
|
|
return c(this, ve);
|
|
}
|
|
scope(e = "/") {
|
|
const i = c(this, Ee).call(this, e);
|
|
if (!c(this, Z).call(this, i)) throw new Error(`EINVAL: invalid path '${e}'`);
|
|
const r = c(this, G).call(this, i);
|
|
if (!r) throw new Error(`ENOENT: no such file or directory '${e}'`);
|
|
if (r.type !== "dir") throw new Error(`ENOTDIR: not a directory '${e}'`);
|
|
return r.children ?? (r.children = []), r.lastModified ?? (r.lastModified = Date.now()), new si(this.root, i);
|
|
}
|
|
async findFiles(e, i, r = {}) {
|
|
const n = c(this, te).call(this, e);
|
|
if (!c(this, Z).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`);
|
|
const o = c(this, G).call(this, n);
|
|
if (!o) throw new Error(`ENOENT: no such file or directory '${e}'`);
|
|
if (o.type !== "dir") throw new Error(`ENOTDIR: not a directory '${e}'`);
|
|
const { recursive: a = !1, fullPath: s = !1 } = r;
|
|
if (typeof i == "function") {
|
|
const d = await c(this, dt).call(this, n, i, a);
|
|
return c(this, ct).call(this, d, n, s);
|
|
}
|
|
const l = await c(this, ut).call(this, n, i, a);
|
|
return c(this, ct).call(this, l, n, s);
|
|
}
|
|
};
|
|
ve = new WeakMap(), et = new WeakMap(), Ne = new WeakMap(), Se = new WeakMap(), Ee = new WeakMap(), te = new WeakMap(), Z = new WeakMap(), G = new WeakMap(), $e = new WeakMap(), ct = new WeakMap(), dt = new WeakMap(), ut = new WeakMap(), pt = new WeakMap(), vt = new WeakMap(), gt = new WeakMap();
|
|
let Ri = si;
|
|
const io = async (t, e = "/", i = "") => {
|
|
try {
|
|
const r = await t.stat(e), n = e === "/" ? "/" : me.basename(e), o = { title: n, key: i ? `${i}${e}` : e, isLeaf: r.isFile() };
|
|
if (r.isDirectory()) {
|
|
const a = await t.dir(e);
|
|
if (a.length > 0) {
|
|
o.children = [];
|
|
const s = [], l = [];
|
|
for (const d of a) {
|
|
const u = e === "/" ? `/${d}` : `${e}/${d}`;
|
|
try {
|
|
(await t.stat(u)).isDirectory() ? s.push(d) : l.push(d);
|
|
} catch (p) {
|
|
console.warn(`Failed to stat ${u}:`, p.message);
|
|
}
|
|
}
|
|
s.sort(), l.sort();
|
|
for (const d of [...s, ...l]) {
|
|
const u = e === "/" ? `/${d}` : `${e}/${d}`;
|
|
try {
|
|
const p = await io(t, u, i);
|
|
o.children.push(p);
|
|
} catch (p) {
|
|
console.warn(`Failed to process ${u}:`, p.message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return o;
|
|
} catch {
|
|
return null;
|
|
}
|
|
};
|
|
export {
|
|
Io as $,
|
|
tn as A,
|
|
Po as B,
|
|
xo as C,
|
|
kt as D,
|
|
Ui as E,
|
|
qt as F,
|
|
To as G,
|
|
mn as H,
|
|
rn as I,
|
|
nn as J,
|
|
kn as K,
|
|
Sn as L,
|
|
Oo as M,
|
|
Ro as N,
|
|
pe as O,
|
|
$n as P,
|
|
Nt as Q,
|
|
_i as R,
|
|
er as S,
|
|
It as T,
|
|
Fo as U,
|
|
jo as V,
|
|
Ao as W,
|
|
Lo as X,
|
|
Pn as Y,
|
|
xn as Z,
|
|
vn as _,
|
|
Bi as a,
|
|
Tt as a0,
|
|
Mo as a1,
|
|
mt as a2,
|
|
Ot as a3,
|
|
Do as a4,
|
|
Vo as a5,
|
|
Nn as a6,
|
|
nr as a7,
|
|
Mn as a8,
|
|
ni as a9,
|
|
qe as aA,
|
|
Me as aB,
|
|
ne as aC,
|
|
Qn as aD,
|
|
Zn as aE,
|
|
Ri as aF,
|
|
io as aG,
|
|
Xn as aH,
|
|
ri as aa,
|
|
or as ab,
|
|
Tn as ac,
|
|
On as ad,
|
|
Rn as ae,
|
|
Fn as af,
|
|
jn as ag,
|
|
An as ah,
|
|
zo as ai,
|
|
St as aj,
|
|
O as ak,
|
|
zi as al,
|
|
Wn as am,
|
|
ee as an,
|
|
ht as ao,
|
|
Di as ap,
|
|
ie as aq,
|
|
re as ar,
|
|
So as as,
|
|
Eo as at,
|
|
$o as au,
|
|
se as av,
|
|
ai as aw,
|
|
eo as ax,
|
|
z as ay,
|
|
Mi as az,
|
|
qi as b,
|
|
vo as c,
|
|
Ki as d,
|
|
ti as e,
|
|
Yi as f,
|
|
Xr as g,
|
|
Qi as h,
|
|
wn as i,
|
|
Xi as j,
|
|
yn as k,
|
|
No as l,
|
|
Gi as m,
|
|
Ji as n,
|
|
Hi as o,
|
|
pn as p,
|
|
un as q,
|
|
cn as r,
|
|
ii as s,
|
|
le as t,
|
|
fn as u,
|
|
hn as v,
|
|
Cn as w,
|
|
on as x,
|
|
sn as y,
|
|
en as z
|
|
};
|