@qfei-design/make-app-approval 0.2.16 → 0.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/list.mjs CHANGED
@@ -1,536 +1,565 @@
1
- import { jsxs as y, jsx as o, Fragment as we } from "react/jsx-runtime";
2
- import { useState as V, useRef as $, useEffect as q, useMemo as ke, useId as ye } from "react";
3
- import { getApprovalStatusDisplay as Se } from "./index.mjs";
4
- const fe = (e) => typeof e == "object" && e !== null, Ne = (e) => fe(e) ? ["id", "entityKey", "recordId"].every((t) => typeof e[t] == "string" && e[t].trim().length > 0) && ["applicationNo", "applicationType", "applicantName", "applicationTime"].every((t) => typeof e[t] == "string") && ["taskId", "processInstanceId"].every((t) => e[t] === void 0 || typeof e[t] == "string" && e[t].trim().length > 0) && ["completionTime", "completionResult"].every((t) => e[t] === void 0 || typeof e[t] == "string") && (e.referenceType === void 0 || e.referenceType === "task" || e.referenceType === "instance") && (e.referenceType !== "instance" || typeof e.processInstanceId == "string" && e.processInstanceId.trim().length > 0) && (typeof e.processStatus == "string" || e.processStatus === null) : !1, re = (e, t) => {
5
- if (!fe(e) || !Array.isArray(e.rows) || !e.rows.every(Ne) || typeof e.total != "number" || !Number.isSafeInteger(e.total) || e.total < 0 || e.rows.length > t || e.rows.length > e.total || new Set(e.rows.map((s) => s.id)).size !== e.rows.length)
1
+ import { jsxs as T, jsx as o, Fragment as Ie } from "react/jsx-runtime";
2
+ import { u as Se } from "./theme-qxOS-jIA.js";
3
+ import { useState as D, useRef as H, useEffect as ae, useMemo as Pe, useId as ze } from "react";
4
+ import { getApprovalStatusDisplay as Ee, toMakeApprovalThemeStyle as Be } from "./index.mjs";
5
+ const Ce = (e) => typeof e == "object" && e !== null, Le = (e) => Ce(e) ? ["id", "entityKey", "recordId"].every((a) => typeof e[a] == "string" && e[a].trim().length > 0) && ["applicationNo", "applicationType", "applicantName", "applicationTime"].every((a) => typeof e[a] == "string") && ["taskId", "processInstanceId"].every((a) => e[a] === void 0 || typeof e[a] == "string" && e[a].trim().length > 0) && ["completionTime", "completionResult"].every((a) => e[a] === void 0 || typeof e[a] == "string") && (e.referenceType === void 0 || e.referenceType === "task" || e.referenceType === "instance") && (e.referenceType !== "instance" || typeof e.processInstanceId == "string" && e.processInstanceId.trim().length > 0) && (typeof e.processStatus == "string" || e.processStatus === null) : !1, ce = (e, a) => {
6
+ if (!Ce(e) || !Array.isArray(e.rows) || !e.rows.every(Le) || typeof e.total != "number" || !Number.isSafeInteger(e.total) || e.total < 0 || e.rows.length > a || e.rows.length > e.total || new Set(e.rows.map((n) => n.id)).size !== e.rows.length)
6
7
  throw new Error("Invalid approval page contract");
7
8
  return { rows: e.rows, total: e.total };
8
- }, E = (e, t) => {
9
+ }, E = (e, a) => {
9
10
  try {
10
- e ? e(t) : t.phase === "error" ? console.warn("[make-app-approval]", t) : console.info("[make-app-approval]", t);
11
+ e ? e(a) : a.phase === "error" ? console.warn("[make-app-approval]", a) : console.info("[make-app-approval]", a);
11
12
  } catch {
12
13
  console.warn("[make-app-approval] diagnostic sink failed");
13
14
  }
14
- }, le = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : Se(e).label, Te = ({ initialPage: e, query: t, provider: s, components: R, onOpen: F, onReload: P, logger: L }) => {
15
- const [f, k] = V(e), [b, I] = V(2), [l, S] = V("idle"), h = $(void 0), [x, C] = V(!1), M = $(void 0);
16
- q(() => () => {
17
- M.current?.abort();
15
+ }, ue = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : Ee(e).label, Oe = ({ initialPage: e, query: a, provider: n, components: w, onOpen: F, onReload: S, logger: m }) => {
16
+ const [c, v] = D(e), [s, C] = D(2), [y, N] = D("idle"), f = H(void 0), [I, x] = D(!1), d = H(void 0);
17
+ ae(() => () => {
18
+ d.current?.abort();
18
19
  }, []);
19
- const N = async () => {
20
- if (M.current || f.rows.length >= f.total) return;
21
- const n = new AbortController();
22
- M.current = n, S("loading");
23
- const p = { operation: "list", tab: t.tab, page: b, pageSize: t.pageSize };
24
- E(L, { ...p, phase: "start" });
20
+ const M = async () => {
21
+ if (d.current || c.rows.length >= c.total) return;
22
+ const l = new AbortController();
23
+ d.current = l, N("loading");
24
+ const A = { operation: "list", tab: a.tab, page: s, pageSize: a.pageSize };
25
+ E(m, { ...A, phase: "start" });
25
26
  try {
26
- const T = re(await s.loadPage({ ...t, page: b }, { signal: n.signal }), t.pageSize);
27
- if (n.signal.aborted) return;
28
- if (T.total < f.total) {
29
- E(L, { ...p, phase: "skip", rowCount: T.rows.length }), P();
27
+ const b = ce(await n.loadPage({ ...a, page: s }, { signal: l.signal }), a.pageSize);
28
+ if (l.signal.aborted) return;
29
+ if (b.total < c.total) {
30
+ E(m, { ...A, phase: "skip", rowCount: b.rows.length }), S();
30
31
  return;
31
32
  }
32
- const m = new Set(f.rows.map((A) => A.id));
33
- if (!T.rows.length || T.rows.some((A) => m.has(A.id))) throw new Error("Invalid append page");
34
- k({ rows: [...f.rows, ...T.rows], total: T.total }), I((A) => A + 1), S("idle"), E(L, { ...p, phase: "success", rowCount: T.rows.length });
33
+ const W = new Set(c.rows.map((V) => V.id));
34
+ if (!b.rows.length || b.rows.some((V) => W.has(V.id))) throw new Error("Invalid append page");
35
+ v({ rows: [...c.rows, ...b.rows], total: b.total }), C((V) => V + 1), N("idle"), E(m, { ...A, phase: "success", rowCount: b.rows.length });
35
36
  } catch {
36
- n.signal.aborted || (S("error"), E(L, { ...p, phase: "error" }));
37
+ l.signal.aborted || (N("error"), E(m, { ...A, phase: "error" }));
37
38
  } finally {
38
- M.current === n && (M.current = void 0);
39
+ d.current === l && (d.current = void 0);
39
40
  }
40
- }, c = (n) => {
41
- const { scrollHeight: p, scrollTop: T, clientHeight: m } = n.currentTarget;
42
- l === "idle" && p - T - m < 120 && N();
43
- }, { Button: B } = R;
44
- return /* @__PURE__ */ y(
41
+ }, p = (l) => {
42
+ const { scrollHeight: A, scrollTop: b, clientHeight: W } = l.currentTarget;
43
+ y === "idle" && A - b - W < 120 && M();
44
+ }, { Button: B } = w;
45
+ return /* @__PURE__ */ T(
45
46
  "div",
46
47
  {
47
48
  className: "make-app-approval-mobile-list",
48
- onScroll: c,
49
- onTouchStart: (n) => {
50
- h.current = n.currentTarget.scrollTop <= 0 && n.touches.length === 1 && l !== "loading" ? { start: n.touches[0].clientY, distance: 0 } : void 0;
49
+ onScroll: p,
50
+ onTouchStart: (l) => {
51
+ f.current = l.currentTarget.scrollTop <= 0 && l.touches.length === 1 && y !== "loading" ? { start: l.touches[0].clientY, distance: 0 } : void 0;
51
52
  },
52
- onTouchMove: (n) => {
53
- !h.current || n.touches.length !== 1 || (h.current.distance = n.touches[0].clientY - h.current.start, C(h.current.distance >= 60));
53
+ onTouchMove: (l) => {
54
+ !f.current || l.touches.length !== 1 || (f.current.distance = l.touches[0].clientY - f.current.start, x(f.current.distance >= 60));
54
55
  },
55
56
  onTouchEnd: () => {
56
- const n = (h.current?.distance ?? 0) >= 60;
57
- h.current = void 0, C(!1), n && P();
57
+ const l = (f.current?.distance ?? 0) >= 60;
58
+ f.current = void 0, x(!1), l && S();
58
59
  },
59
60
  onTouchCancel: () => {
60
- h.current = void 0, C(!1);
61
+ f.current = void 0, x(!1);
61
62
  },
62
63
  "aria-label": "审批卡片列表",
63
- "aria-busy": l === "loading",
64
+ "aria-busy": y === "loading",
64
65
  children: [
65
- x && /* @__PURE__ */ o("p", { role: "status", className: "make-app-approval-mobile-feedback", children: "松开刷新" }),
66
- f.rows.map((n) => /* @__PURE__ */ y("button", { type: "button", className: "make-app-approval-mobile-card", onClick: () => F(n), "aria-label": `打开 ${n.applicationNo} 的审批详情`, children: [
67
- /* @__PURE__ */ o("strong", { children: n.applicationType || "审批申请" }),
68
- /* @__PURE__ */ y("span", { className: "make-app-approval-mobile-card-line", children: [
66
+ I && /* @__PURE__ */ o("p", { role: "status", className: "make-app-approval-mobile-feedback", children: "松开刷新" }),
67
+ c.rows.map((l) => /* @__PURE__ */ T("button", { type: "button", className: "make-app-approval-mobile-card", onClick: () => F(l), "aria-label": `打开 ${l.applicationNo} 的审批详情`, children: [
68
+ /* @__PURE__ */ o("strong", { children: l.applicationType || "审批申请" }),
69
+ /* @__PURE__ */ T("span", { className: "make-app-approval-mobile-card-line", children: [
69
70
  /* @__PURE__ */ o("span", { children: "申请单ID:" }),
70
- /* @__PURE__ */ o("span", { children: n.applicationNo })
71
+ /* @__PURE__ */ o("span", { children: l.applicationNo })
71
72
  ] }),
72
- t.tab === "approved" && /* @__PURE__ */ y("span", { className: "make-app-approval-mobile-card-line", children: [
73
+ a.tab === "approved" && /* @__PURE__ */ T("span", { className: "make-app-approval-mobile-card-line", children: [
73
74
  /* @__PURE__ */ o("span", { children: "审批结果:" }),
74
- /* @__PURE__ */ o("span", { children: n.completionResult || "—" })
75
+ /* @__PURE__ */ o("span", { children: l.completionResult || "—" })
75
76
  ] }),
76
- t.tab === "initiated" && /* @__PURE__ */ y("span", { className: "make-app-approval-mobile-card-line", children: [
77
+ a.tab === "initiated" && /* @__PURE__ */ T("span", { className: "make-app-approval-mobile-card-line", children: [
77
78
  /* @__PURE__ */ o("span", { children: "流程状态:" }),
78
- /* @__PURE__ */ o("span", { children: le(n.processStatus) })
79
+ /* @__PURE__ */ o("span", { children: ue(l.processStatus) })
79
80
  ] }),
80
- /* @__PURE__ */ y("span", { className: "make-app-approval-mobile-card-footer", children: [
81
- /* @__PURE__ */ y("span", { className: "make-app-approval-mobile-person", children: [
82
- /* @__PURE__ */ o("span", { className: "make-app-approval-mobile-avatar", "aria-hidden": "true", children: n.applicantName.slice(-2) }),
83
- /* @__PURE__ */ o("span", { children: n.applicantName || "—" })
81
+ /* @__PURE__ */ T("span", { className: "make-app-approval-mobile-card-footer", children: [
82
+ /* @__PURE__ */ T("span", { className: "make-app-approval-mobile-person", children: [
83
+ /* @__PURE__ */ o("span", { className: "make-app-approval-mobile-avatar", "aria-hidden": "true", children: l.applicantName.slice(-2) }),
84
+ /* @__PURE__ */ o("span", { children: l.applicantName || "—" })
84
85
  ] }),
85
- /* @__PURE__ */ o("span", { children: t.tab === "approved" ? `完成于 ${n.completionTime || "—"}` : `申请于 ${n.applicationTime || "—"}` })
86
+ /* @__PURE__ */ o("span", { children: a.tab === "approved" ? `完成于 ${l.completionTime || "—"}` : `申请于 ${l.applicationTime || "—"}` })
86
87
  ] })
87
- ] }, n.id)),
88
- !f.rows.length && /* @__PURE__ */ o("p", { className: "make-app-approval-mobile-feedback", children: "暂无审批记录" }),
89
- l === "error" ? /* @__PURE__ */ y("div", { role: "alert", className: "make-app-approval-mobile-feedback", children: [
88
+ ] }, l.id)),
89
+ !c.rows.length && /* @__PURE__ */ o("p", { className: "make-app-approval-mobile-feedback", children: "暂无审批记录" }),
90
+ y === "error" ? /* @__PURE__ */ T("div", { role: "alert", className: "make-app-approval-mobile-feedback", children: [
90
91
  "部分审批记录加载失败",
91
92
  /* @__PURE__ */ o(B, { htmlType: "button", variant: "text", onClick: () => {
92
- N();
93
+ M();
93
94
  }, children: "重试加载" })
94
- ] }) : l === "loading" ? /* @__PURE__ */ o("p", { role: "status", className: "make-app-approval-mobile-feedback", children: "加载中" }) : f.rows.length < f.total ? /* @__PURE__ */ o(B, { htmlType: "button", variant: "text", onClick: () => {
95
- N();
96
- }, children: "加载更多" }) : f.rows.length > 0 && /* @__PURE__ */ o("p", { className: "make-app-approval-mobile-feedback", children: "没有更多了" })
95
+ ] }) : y === "loading" ? /* @__PURE__ */ o("p", { role: "status", className: "make-app-approval-mobile-feedback", children: "加载中" }) : c.rows.length < c.total ? /* @__PURE__ */ o(B, { htmlType: "button", variant: "text", onClick: () => {
96
+ M();
97
+ }, children: "加载更多" }) : c.rows.length > 0 && /* @__PURE__ */ o("p", { className: "make-app-approval-mobile-feedback", children: "没有更多了" })
97
98
  ]
98
99
  }
99
100
  );
100
- }, Ce = {
101
+ }, He = (e) => {
102
+ const a = Be(e), n = {}, w = (S, m) => {
103
+ const c = a[`--make-approval-theme-${m}`];
104
+ c !== void 0 && (n[S] = c);
105
+ }, F = (S, m) => {
106
+ const c = a[`--make-approval-theme-${m}`];
107
+ c !== void 0 && (n[S] = Number.parseFloat(c));
108
+ };
109
+ for (const [S, m] of Object.entries({ primaryColor: "primary", onPrimaryColor: "on-primary", textColor: "text", headerTextColor: "heading-text", rowBgColor: "surface", canvasBgColor: "page", headerBgColor: "subtle-surface", borderColor: "border-color", hoverColor: "hover-surface", selectedBgColor: "selected-surface", activeBgColor: "active-surface", activeBorderColor: "focus-ring", secondaryTextColor: "secondary-text", placeholderTextColor: "placeholder-text", tooltipBgColor: "elevated-surface", tooltipTextColor: "text", fontFamily: "font-family" })) w(S, m);
110
+ for (const [S, m] of Object.entries({ fontSize: "font-size-body", fontWeight: "font-weight-body", headerFontSize: "font-size-field-label", headerFontWeight: "font-weight-heading", secondaryFontSize: "font-size-meta", rowHeight: "row-height", headerHeight: "header-height", cellPadding: "spacing-table-cell", headerCellPadding: "spacing-table-header", tooltipFontSize: "font-size-meta", tooltipBorderRadius: "radius-popup" })) F(S, m);
111
+ return n.headerTextColor === void 0 && n.textColor !== void 0 && (n.headerTextColor = n.textColor), n;
112
+ }, De = (e, a) => a === "canvas-table/semantic-theme/v1" ? e : {}, Te = {
101
113
  applicationNo: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-fingerprint-pattern" aria-hidden="true"><path d="M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"></path><path d="M14 13.12c0 2.38 0 6.38-1 8.88"></path><path d="M17.29 21.02c.12-.6.43-2.3.5-3.02"></path><path d="M2 12a10 10 0 0 1 18-6"></path><path d="M2 16h.01"></path><path d="M21.8 16c.2-2 .131-5.354 0-6"></path><path d="M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"></path><path d="M8.65 22c.21-.66.45-1.32.57-2"></path><path d="M9 6.8a6 6 0 0 1 9 5.2v2"></path></svg>',
102
114
  applicationType: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-type" aria-hidden="true"><path d="M12 4v16"></path><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"></path><path d="M9 20h6"></path></svg>',
103
115
  applicantName: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user-round" aria-hidden="true"><circle cx="12" cy="8" r="5"></circle><path d="M20 21a8 8 0 0 0-16 0"></path></svg>',
104
116
  applicationTime: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1d212a" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-calendar-clock" aria-hidden="true"><path d="M16 14v2.2l1.6 1"></path><path d="M16 2v3"></path><path d="M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338"></path><path d="M3 9h5.859"></path><path d="M8 2v3"></path><circle cx="16" cy="16" r="6"></circle></svg>'
105
- }, pe = Object.fromEntries(
106
- Object.entries(Ce).map(([e, t]) => [e, `data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`])
107
- ), se = 64, de = [
117
+ }, ve = Object.fromEntries(
118
+ Object.entries(Te).map(([e, a]) => [e, `data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`])
119
+ ), Fe = (e) => {
120
+ const a = e.replace(/[&<>"']/g, (n) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&apos;" })[n]);
121
+ return Object.fromEntries(Object.entries(Te).map(([n, w]) => [n, `data:image/svg+xml;charset=utf-8,${encodeURIComponent(w.replaceAll("#1d212a", a))}`]));
122
+ }, he = 64, be = [
108
123
  { key: "applicationNo", title: "申请单ID", width: 260 },
109
124
  { key: "applicationType", title: "业务表单", width: 180 },
110
125
  { key: "applicantName", title: "申请人", width: 170 },
111
126
  { key: "applicationTime", title: "申请时间", width: 220 }
112
- ], he = (e, t) => {
113
- const s = t === "initiated" ? [...de, { key: "statusLabel", title: "流程状态", width: 140 }] : de, R = s.reduce((P, L) => P + L.width, se), F = Math.max(0, e - R) / s.length;
114
- return s.map((P) => ({
115
- ...P,
116
- width: P.width + F,
127
+ ], we = (e, a, n) => {
128
+ let w, F = ve;
129
+ const S = () => {
130
+ const s = typeof n == "function" ? n() : n;
131
+ return s !== w && (w = s, F = s ? Fe(s) : ve), F;
132
+ }, m = a === "initiated" ? [...be, { key: "statusLabel", title: "流程状态", width: 140 }] : be, c = m.reduce((s, C) => s + C.width, he), v = Math.max(0, e - c) / m.length;
133
+ return m.map((s) => ({
134
+ ...s,
135
+ width: s.width + v,
117
136
  showEllipsis: !0,
118
137
  sortable: !1,
119
- prefixRender: () => ({ icon: pe[P.key] ?? pe.applicationType })
138
+ prefixRender: () => {
139
+ const C = S();
140
+ return { icon: C[s.key] ?? C.applicationType };
141
+ }
120
142
  }));
121
- }, Me = ({ table: e, query: t, initialPage: s, loadPage: R, onChange: F, retryViewport: P, onReload: L, logger: f }) => {
122
- const k = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Set();
123
- let I = [];
124
- const l = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new Set();
125
- let h = s, x = s.total, C = 0, M = !1, N = !1, c;
126
- const B = (r) => Number.isSafeInteger(r) && r >= 0 && r * t.pageSize < x, n = (r, a, d) => E(f, { operation: "list", phase: a, tab: t.tab, page: r + 1, pageSize: t.pageSize, rowCount: d }), p = () => {
127
- M || F({ total: x, rows: I, failed: N || S.size > 0, loading: k.size > 0 });
128
- }, T = (r) => {
129
- r.finished || (r.finished = !0, r.removeAbort(), k.get(r.page) === r && k.delete(r.page), e.markPageLoadFailed(r.page, r.request), r.controller.abort(), n(r.page, "cancel"));
130
- }, m = (r) => {
131
- C = r;
132
- const a = e.getPagesInView() ?? [], d = new Set([C, ...a].flatMap((g) => [g - 1, g, g + 1]).filter(B));
133
- for (const g of k.values()) d.has(g.page) || T(g);
134
- for (const g of S) d.has(g) || S.delete(g);
135
- }, A = (r, a, d) => {
136
- const g = a.rows.map((v) => {
137
- const W = { ...v, statusLabel: le(v.processStatus) };
138
- return l.set(W, v), W;
143
+ }, Ve = ({ table: e, query: a, initialPage: n, loadPage: w, onChange: F, retryViewport: S, onReload: m, logger: c }) => {
144
+ const v = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set();
145
+ let C = [];
146
+ const y = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new Set();
147
+ let f = n, I = n.total, x = 0, d = !1, M = !1, p;
148
+ const B = (r) => Number.isSafeInteger(r) && r >= 0 && r * a.pageSize < I, l = (r, t, h) => E(c, { operation: "list", phase: t, tab: a.tab, page: r + 1, pageSize: a.pageSize, rowCount: h }), A = () => {
149
+ d || F({ total: I, rows: C, failed: M || N.size > 0, loading: v.size > 0 });
150
+ }, b = (r) => {
151
+ r.finished || (r.finished = !0, r.removeAbort(), v.get(r.page) === r && v.delete(r.page), e.markPageLoadFailed(r.page, r.request), r.controller.abort(), l(r.page, "cancel"));
152
+ }, W = (r) => {
153
+ x = r;
154
+ const t = e.getPagesInView() ?? [], h = new Set([x, ...t].flatMap((g) => [g - 1, g, g + 1]).filter(B));
155
+ for (const g of v.values()) h.has(g.page) || b(g);
156
+ for (const g of N) h.has(g) || N.delete(g);
157
+ }, V = (r, t, h) => {
158
+ const g = t.rows.map((R) => {
159
+ const $ = { ...R, statusLabel: ue(R.processStatus) };
160
+ return y.set($, R), $;
139
161
  });
140
- if (!e.setVirtualPageData(g, r, a.total, d)) {
141
- n(r, "skip");
162
+ if (!e.setVirtualPageData(g, r, t.total, h)) {
163
+ l(r, "skip");
142
164
  return;
143
165
  }
144
- x = a.total;
166
+ I = t.total;
145
167
  try {
146
- I = re({ rows: e.getTableData() ?? [], total: x }, Number.MAX_SAFE_INTEGER).rows.map((v) => l.get(v) ?? v);
147
- } catch (v) {
148
- N = !0, I = [], h = void 0, c && clearTimeout(c), c = void 0;
149
- for (const W of k.values()) T(W);
150
- throw v;
168
+ C = ce({ rows: e.getTableData() ?? [], total: I }, Number.MAX_SAFE_INTEGER).rows.map((R) => y.get(R) ?? R);
169
+ } catch (R) {
170
+ M = !0, C = [], f = void 0, p && clearTimeout(p), p = void 0;
171
+ for (const $ of v.values()) b($);
172
+ throw R;
151
173
  }
152
- h && h.total !== x && (h = void 0), S.delete(r);
153
- for (const v of k.values()) B(v.page) || T(v);
154
- !B(r) && r > 0 && e.scrollToRow(Math.max(0, x - 1)), n(r, "success", a.rows.length);
155
- }, D = () => {
156
- if (M || c) return;
157
- const r = [...k.values()].filter((a) => !a.running && !a.finished).sort((a, d) => Math.abs(a.page - C) - Math.abs(d.page - C) || a.page - d.page);
158
- for (const a of r) {
159
- if (b.size >= 2) break;
160
- a.running = !0, b.add(a), n(a.page, "start"), (async () => {
174
+ f && f.total !== I && (f = void 0), N.delete(r);
175
+ for (const R of v.values()) B(R.page) || b(R);
176
+ !B(r) && r > 0 && e.scrollToRow(Math.max(0, I - 1)), l(r, "success", t.rows.length);
177
+ }, P = () => {
178
+ if (d || p) return;
179
+ const r = [...v.values()].filter((t) => !t.running && !t.finished).sort((t, h) => Math.abs(t.page - x) - Math.abs(h.page - x) || t.page - h.page);
180
+ for (const t of r) {
181
+ if (s.size >= 2) break;
182
+ t.running = !0, s.add(t), l(t.page, "start"), (async () => {
161
183
  try {
162
- const d = await R({ ...t, page: a.page + 1 }, { signal: a.controller.signal });
163
- if (M || a.finished || a.controller.signal.aborted) return;
164
- const g = re(d, t.pageSize);
165
- a.finished = !0, a.removeAbort(), k.delete(a.page), A(a.page, g, a.request);
184
+ const h = await w({ ...a, page: t.page + 1 }, { signal: t.controller.signal });
185
+ if (d || t.finished || t.controller.signal.aborted) return;
186
+ const g = ce(h, a.pageSize);
187
+ t.finished = !0, t.removeAbort(), v.delete(t.page), V(t.page, g, t.request);
166
188
  } catch {
167
- !M && !a.controller.signal.aborted && (S.add(a.page), n(a.page, "error"), e.markPageLoadFailed(a.page, a.request));
189
+ !d && !t.controller.signal.aborted && (N.add(t.page), l(t.page, "error"), e.markPageLoadFailed(t.page, t.request));
168
190
  } finally {
169
- a.finished || (a.finished = !0, a.removeAbort(), k.get(a.page) === a && k.delete(a.page)), b.delete(a), p(), D();
191
+ t.finished || (t.finished = !0, t.removeAbort(), v.get(t.page) === t && v.delete(t.page)), s.delete(t), A(), P();
170
192
  }
171
193
  })();
172
194
  }
173
- p();
174
- }, Y = () => {
175
- c && clearTimeout(c), c = setTimeout(() => {
176
- c = void 0, D();
195
+ A();
196
+ }, L = () => {
197
+ p && clearTimeout(p), p = setTimeout(() => {
198
+ p = void 0, P();
177
199
  }, 120);
178
200
  };
179
201
  return {
180
- load(r, a) {
181
- if (a.useRequestIdentity(), M || N || a.signal.aborted || !B(r)) {
182
- e.markPageLoadFailed(r, a), n(r, "skip");
202
+ load(r, t) {
203
+ if (t.useRequestIdentity(), d || M || t.signal.aborted || !B(r)) {
204
+ e.markPageLoadFailed(r, t), l(r, "skip");
183
205
  return;
184
206
  }
185
- const d = k.get(r);
186
- if (d?.request === a && !d.finished) return;
187
- if (d && T(d), m(r), r === 0 && h) {
188
- const v = h;
189
- h = void 0;
207
+ const h = v.get(r);
208
+ if (h?.request === t && !h.finished) return;
209
+ if (h && b(h), W(r), r === 0 && f) {
210
+ const R = f;
211
+ f = void 0;
190
212
  try {
191
- A(0, v, a);
213
+ V(0, R, t);
192
214
  } catch {
193
- S.add(r), e.markPageLoadFailed(r, a), n(r, "error");
215
+ N.add(r), e.markPageLoadFailed(r, t), l(r, "error");
194
216
  }
195
- p();
217
+ A();
196
218
  return;
197
219
  }
198
- const g = { page: r, request: a, controller: new AbortController(), running: !1, finished: !1, removeAbort: () => {
220
+ const g = { page: r, request: t, controller: new AbortController(), running: !1, finished: !1, removeAbort: () => {
199
221
  } }, K = () => {
200
- T(g), p();
222
+ b(g), A();
201
223
  };
202
- a.signal.addEventListener("abort", K, { once: !0 }), g.removeAbort = () => a.signal.removeEventListener("abort", K), k.set(r, g), Y(), p();
224
+ t.signal.addEventListener("abort", K, { once: !0 }), g.removeAbort = () => t.signal.removeEventListener("abort", K), v.set(r, g), L(), A();
203
225
  },
204
226
  viewportChanged() {
205
- if (M) return;
227
+ if (d) return;
206
228
  const r = e.getPagesInView();
207
- r?.length && (m(r[0]), k.size && Y(), p());
229
+ r?.length && (W(r[0]), v.size && L(), A());
208
230
  },
209
231
  retry() {
210
- if (!M) {
211
- if (N) {
212
- L();
232
+ if (!d) {
233
+ if (M) {
234
+ m();
213
235
  return;
214
236
  }
215
- S.size !== 0 && (S.clear(), P(), p());
237
+ N.size !== 0 && (N.clear(), S(), A());
216
238
  }
217
239
  },
218
240
  dispose() {
219
- M = !0, c && clearTimeout(c), c = void 0;
220
- for (const r of k.values()) T(r);
221
- I = [], S.clear(), h = void 0;
241
+ d = !0, p && clearTimeout(p), p = void 0;
242
+ for (const r of v.values()) b(r);
243
+ C = [], N.clear(), f = void 0;
222
244
  }
223
245
  };
224
- }, ue = 40, Re = (e) => {
225
- const t = $(void 0);
246
+ }, ye = 40, $e = (e) => {
247
+ const a = H(void 0);
226
248
  return e.initialPage ? /* @__PURE__ */ o(
227
- Pe,
249
+ je,
228
250
  {
229
251
  ...e,
230
252
  initialPage: e.initialPage,
231
- restoreScroll: t.current?.query === e.query ? t.current.position : void 0,
232
- rememberScroll: (s) => {
233
- t.current = { query: e.query, position: s };
253
+ restoreScroll: a.current?.query === e.query ? a.current.position : void 0,
254
+ rememberScroll: (n) => {
255
+ a.current = { query: e.query, position: n };
234
256
  }
235
257
  }
236
258
  ) : /* @__PURE__ */ o("div", { className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" });
237
- }, Pe = ({ components: { Button: e }, initialPage: t, query: s, provider: R, themeKey: F, onOpen: P, onReload: L, logger: f, restoreScroll: k, rememberScroll: b }) => {
238
- const I = $(null), l = $(null), S = $(null), [h, x] = V(!1), [C, M] = V(0), [N, c] = V({ ...t, failed: !1, loading: !1 }), B = $(t.rows), n = $(k), p = $({ provider: R, onOpen: P, onReload: L, logger: f, rememberScroll: b });
239
- p.current = { provider: R, onOpen: P, onReload: L, logger: f, rememberScroll: b };
240
- const T = $(() => {
259
+ }, je = ({ components: { Button: e }, initialPage: a, query: n, provider: w, themeKey: F, onOpen: S, onReload: m, logger: c, restoreScroll: v, rememberScroll: s }) => {
260
+ const C = Se("desktop"), y = He(C.theme), N = H(y);
261
+ N.current = y;
262
+ const f = JSON.stringify(y), I = H({}), x = H(null), d = H(null), M = H(null), [p, B] = D(!1), [l, A] = D(0), [b, W] = D({ ...a, failed: !1, loading: !1 }), V = H(a.rows), P = H(v), L = H({ provider: w, onOpen: S, onReload: m, logger: c, rememberScroll: s });
263
+ L.current = { provider: w, onOpen: S, onReload: m, logger: c, rememberScroll: s };
264
+ const r = H(() => {
241
265
  });
242
- return q(() => {
243
- const m = I.current;
244
- if (!m) return;
245
- let A = !1, D, Y, r, a, d, g = t.total;
246
- E(p.current.logger, { operation: "table", phase: "start" });
247
- const K = () => {
248
- A || (x(!0), E(p.current.logger, { operation: "table", phase: "error" }));
266
+ return ae(() => {
267
+ const t = x.current;
268
+ if (!t) return;
269
+ let h = !1, g, K, R, $, U, X = a.total, Z = !1;
270
+ E(L.current.logger, { operation: "table", phase: "start" });
271
+ const re = () => {
272
+ h || (B(!0), E(L.current.logger, { operation: "table", phase: "error" }));
249
273
  };
250
- return import("@qfei-design/canvas-table").then((v) => {
251
- if (A) return;
252
- const W = () => {
253
- const X = l.current, O = X?.getScrollState();
254
- X && O && v.globalEventBus.emitWithNamespace("scroll:change", X.tableId, O);
255
- }, _ = (X = !1) => {
256
- if (!A)
274
+ return import("@qfei-design/canvas-table").then((j) => {
275
+ if (h) return;
276
+ const q = "CANVAS_TABLE_THEME_CONTRACT" in j ? j.CANVAS_TABLE_THEME_CONTRACT : void 0, G = () => {
277
+ const _ = d.current, O = _?.getScrollState();
278
+ _ && O && j.globalEventBus.emitWithNamespace("scroll:change", _.tableId, O);
279
+ }, i = (_ = !1) => {
280
+ if (!h)
257
281
  try {
258
- const { width: O, height: j } = m.getBoundingClientRect();
259
- if (O <= 0 || j <= 0 || !X && d?.width === O && d.height === j) return;
260
- const H = getComputedStyle(m), i = {
261
- rowHeight: ue,
282
+ const { width: O, height: J } = t.getBoundingClientRect();
283
+ if (O <= 0 || J <= 0 || !_ && U?.width === O && U.height === J) return;
284
+ const Y = getComputedStyle(t);
285
+ q !== "canvas-table/semantic-theme/v1" && Object.keys(N.current).length > 0 && !Z && (Z = !0, E(L.current.logger, { operation: "table", phase: "skip", reason: "canvas-theme-contract-unavailable" }));
286
+ const oe = {
287
+ rowHeight: ye,
262
288
  headerHeight: 40,
263
289
  fontSize: 14,
264
- fontFamily: H.fontFamily || "Arial, sans-serif",
265
- ...H.color ? { textColor: H.color } : {},
266
- ...H.getPropertyValue("--make-approval-bg").trim() ? { rowBgColor: H.getPropertyValue("--make-approval-bg").trim() } : {},
267
- ...H.getPropertyValue("--make-approval-header").trim() ? { headerBgColor: H.getPropertyValue("--make-approval-header").trim() } : {},
268
- ...H.getPropertyValue("--make-approval-border").trim() ? { borderColor: H.getPropertyValue("--make-approval-border").trim() } : {}
269
- }, u = Math.max(Math.ceil(300 / s.pageSize), Math.ceil(j * 3 / ue / s.pageSize) + 2) * s.pageSize, J = { enabled: !0, totalRowCount: g, pageSize: s.pageSize, maxCachedRows: u };
270
- if (l.current) {
271
- const w = d?.width !== O ? he(O, s.tab) : void 0;
272
- if (l.current.updateProps({
290
+ fontFamily: Y.fontFamily || "Arial, sans-serif",
291
+ ...Y.color ? { textColor: Y.color } : {},
292
+ ...Y.getPropertyValue("--make-approval-bg").trim() ? { rowBgColor: Y.getPropertyValue("--make-approval-bg").trim() } : {},
293
+ ...Y.getPropertyValue("--make-approval-header").trim() ? { headerBgColor: Y.getPropertyValue("--make-approval-header").trim() } : {},
294
+ ...Y.getPropertyValue("--make-approval-border").trim() ? { borderColor: Y.getPropertyValue("--make-approval-border").trim() } : {},
295
+ ...De(N.current, q)
296
+ };
297
+ I.current = oe;
298
+ const Re = oe.rowHeight ?? ye, me = () => I.current.headerTextColor, Me = Math.max(Math.ceil(300 / n.pageSize), Math.ceil(J * 3 / Re / n.pageSize) + 2) * n.pageSize, fe = { enabled: !0, totalRowCount: X, pageSize: n.pageSize, maxCachedRows: Me };
299
+ if (d.current) {
300
+ const k = U?.width !== O ? we(O, n.tab, me) : void 0;
301
+ if (d.current.updateProps({
273
302
  canvasWidth: O,
274
- canvasHeight: j,
275
- style: i,
276
- virtualOptions: J,
277
- ...w ? { columns: w } : {}
278
- }), w) {
279
- const z = l.current.getScrollState(), Q = Math.max(0, w.reduce((Z, ne) => Z + ne.width, se) - O);
280
- z && z.scrollX > Q && l.current.scrollTo(Q, z.scrollY, !1);
303
+ canvasHeight: J,
304
+ style: oe,
305
+ virtualOptions: fe,
306
+ ...k ? { columns: k } : {}
307
+ }), k) {
308
+ const z = d.current.getScrollState(), Q = Math.max(0, k.reduce((ee, de) => ee + de.width, he) - O);
309
+ z && z.scrollX > Q && d.current.scrollTo(Q, z.scrollY, !1);
281
310
  }
282
- d = { width: O, height: j }, W();
311
+ U = { width: O, height: J }, G();
283
312
  return;
284
313
  }
285
- l.current = new v.CanvasTableComponent(m, {
286
- columns: he(O, s.tab),
314
+ d.current = new j.CanvasTableComponent(t, {
315
+ columns: we(O, n.tab, me),
287
316
  canvasWidth: O,
288
- canvasHeight: j,
289
- style: i,
317
+ canvasHeight: J,
318
+ style: oe,
290
319
  rowKey: "id",
291
320
  minCanvasWidth: 0,
292
321
  minCanvasHeight: 0,
293
- showSN: { enabled: !0, width: se, formatter: (w, z) => z + 1 },
294
- virtualOptions: J,
322
+ showSN: { enabled: !0, width: he, formatter: (k, z) => z + 1 },
323
+ virtualOptions: fe,
295
324
  selectable: { enabled: !1 },
296
325
  rowSortable: { enabled: !1 },
297
326
  editApplyMode: "controlled",
298
- customEdit: (w) => {
299
- w.cancel();
327
+ customEdit: (k) => {
328
+ k.cancel();
300
329
  },
301
330
  emptyStateOptions: { text: "暂无审批记录" },
302
331
  bodyRowHeadSuffixOptions: {
303
332
  enabled: !0,
304
333
  width: 20,
305
- render: ({ group: w, x: z, height: Q, rowData: Z }) => {
306
- const ne = Z?.id, ee = new v.RectShape({ name: "approval-open", x: z, y: Q / 2 - 10, cursor: "pointer", tooltip: "查看审批详情", attrs: { width: 20, height: 20, fill: "transparent", stroke: "transparent" } });
307
- ee.addChild(new v.ImgShape({ name: "approval-open-icon", x: 3, y: 3, attrs: {
334
+ render: ({ group: k, x: z, height: Q, rowData: ee }) => {
335
+ const de = ee?.id, ie = new j.RectShape({ name: "approval-open", x: z, y: Q / 2 - 10, cursor: "pointer", tooltip: "查看审批详情", attrs: { width: 20, height: 20, fill: "transparent", stroke: "transparent" } });
336
+ ie.addChild(new j.ImgShape({ name: "approval-open-icon", x: 3, y: 3, attrs: {
308
337
  width: 14,
309
338
  height: 14,
310
- img: "data:image/svg+xml;charset=utf-8," + encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="${H.color || "#64748b"}" stroke-width="1.8"><path d="M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5"/></svg>`)
311
- } })), ee.on("mousedown", (ie) => ie.stopPropagation?.()), ee.on("click", (ie) => {
312
- ie.stopPropagation?.();
313
- const ce = B.current.find((be) => be.id === ne);
314
- ce && p.current.onOpen(ce);
315
- }), w.addChild(ee);
339
+ img: "data:image/svg+xml;charset=utf-8," + encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="${String(I.current.textColor || "#64748b").replace(/[&<>"']/g, (te) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&apos;" })[te])}" stroke-width="1.8"><path d="M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5"/></svg>`)
340
+ } })), ie.on("mousedown", (te) => te.stopPropagation?.()), ie.on("click", (te) => {
341
+ te.stopPropagation?.();
342
+ const ge = V.current.find((Ae) => Ae.id === de);
343
+ ge && L.current.onOpen(ge);
344
+ }), k.addChild(ie);
316
345
  }
317
346
  }
318
347
  });
319
- const G = l.current;
320
- d = { width: O, height: j };
321
- const oe = Me({
322
- table: G,
323
- query: s,
324
- initialPage: t,
348
+ const ne = d.current;
349
+ U = { width: O, height: J };
350
+ const pe = Ve({
351
+ table: ne,
352
+ query: n,
353
+ initialPage: a,
325
354
  // 公开滚动同步事件会重新检测缺页,不移动视口,也不复用失败身份。
326
- retryViewport: W,
327
- onReload: () => p.current.onReload(),
328
- loadPage: (w, z) => p.current.provider.loadPage(w, z),
329
- logger: (w) => E(p.current.logger, w),
330
- onChange: (w) => {
331
- A || (g = w.total, B.current = w.rows, c((z) => z.total === w.total && z.failed === w.failed && z.loading === w.loading && z.rows.length === w.rows.length && z.rows.every((Q, Z) => Q === w.rows[Z]) ? z : w));
355
+ retryViewport: G,
356
+ onReload: () => L.current.onReload(),
357
+ loadPage: (k, z) => L.current.provider.loadPage(k, z),
358
+ logger: (k) => E(L.current.logger, k),
359
+ onChange: (k) => {
360
+ h || (X = k.total, V.current = k.rows, W((z) => z.total === k.total && z.failed === k.failed && z.loading === k.loading && z.rows.length === k.rows.length && z.rows.every((Q, ee) => Q === k.rows[ee]) ? z : k));
332
361
  }
333
362
  });
334
- S.current = oe, Y = v.globalEventBus.onWithNamespace("data:load", G.tableId, (w, z) => oe.load(w, z)), r = v.globalEventBus.onWithNamespace("scroll:change", G.tableId, () => oe.viewportChanged()), n.current && G.scrollTo(n.current.scrollX, n.current.scrollY), x(!1), E(p.current.logger, { operation: "table", phase: "success" });
363
+ M.current = pe, K = j.globalEventBus.onWithNamespace("data:load", ne.tableId, (k, z) => pe.load(k, z)), R = j.globalEventBus.onWithNamespace("scroll:change", ne.tableId, () => pe.viewportChanged()), P.current && ne.scrollTo(P.current.scrollX, P.current.scrollY), B(!1), E(L.current.logger, { operation: "table", phase: "success" });
335
364
  } catch {
336
- K();
365
+ re();
337
366
  }
338
367
  };
339
- T.current = () => _(!0);
340
- const U = () => _();
341
- D = new ResizeObserver(U), D.observe(m), window.addEventListener("resize", U), a = () => window.removeEventListener("resize", U), _();
342
- }).catch(K), () => {
343
- A = !0, D?.disconnect(), a?.(), T.current = () => {
344
- }, l.current && (n.current = l.current.getScrollState(), n.current && p.current.rememberScroll(n.current)), Y?.(), r?.(), S.current?.dispose(), S.current = null, l.current?.destroy(), l.current = null, E(p.current.logger, { operation: "table", phase: "destroy" });
368
+ r.current = () => i(!0);
369
+ const u = () => i();
370
+ g = new ResizeObserver(u), g.observe(t), window.addEventListener("resize", u), $ = () => window.removeEventListener("resize", u), i();
371
+ }).catch(re), () => {
372
+ h = !0, g?.disconnect(), $?.(), r.current = () => {
373
+ }, d.current && (P.current = d.current.getScrollState(), P.current && L.current.rememberScroll(P.current)), K?.(), R?.(), M.current?.dispose(), M.current = null, d.current?.destroy(), d.current = null, E(L.current.logger, { operation: "table", phase: "destroy" });
345
374
  };
346
- }, [t, s, C]), q(() => {
347
- T.current();
348
- }, [F]), /* @__PURE__ */ y("div", { className: "make-app-approval-table-frame", "aria-busy": N.loading, children: [
349
- /* @__PURE__ */ o("div", { ref: I, className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" }),
350
- h && /* @__PURE__ */ y("div", { className: "make-app-approval-overlay", role: "alert", children: [
375
+ }, [a, n, l]), ae(() => {
376
+ r.current();
377
+ }, [F, f]), /* @__PURE__ */ T("div", { className: "make-app-approval-table-frame", "aria-busy": b.loading, children: [
378
+ /* @__PURE__ */ o("div", { ref: x, className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" }),
379
+ p && /* @__PURE__ */ T("div", { className: "make-app-approval-overlay", role: "alert", children: [
351
380
  "表格加载失败 ",
352
381
  /* @__PURE__ */ o(e, { htmlType: "button", variant: "default", onClick: () => {
353
- x(!1), M((m) => m + 1);
382
+ B(!1), A((t) => t + 1);
354
383
  }, children: "重新加载表格" })
355
384
  ] }),
356
- !h && N.failed && /* @__PURE__ */ y("div", { className: "make-app-approval-table-feedback", role: "alert", children: [
385
+ !p && b.failed && /* @__PURE__ */ T("div", { className: "make-app-approval-table-feedback", role: "alert", children: [
357
386
  "部分审批记录加载失败 ",
358
- /* @__PURE__ */ o(e, { htmlType: "button", variant: "default", onClick: () => S.current?.retry(), children: "重试加载" })
387
+ /* @__PURE__ */ o(e, { htmlType: "button", variant: "default", onClick: () => M.current?.retry(), children: "重试加载" })
359
388
  ] }),
360
- !h && !N.failed && N.loading && /* @__PURE__ */ y("div", { className: "make-app-approval-table-loading", role: "status", "aria-label": "正在加载审批记录", "aria-live": "polite", children: [
389
+ !p && !b.failed && b.loading && /* @__PURE__ */ T("div", { className: "make-app-approval-table-loading", role: "status", "aria-label": "正在加载审批记录", "aria-live": "polite", children: [
361
390
  /* @__PURE__ */ o("span", { className: "make-app-approval-loading-spinner", "aria-hidden": "true" }),
362
391
  /* @__PURE__ */ o("span", { children: "加载中" })
363
392
  ] }),
364
- /* @__PURE__ */ y("ul", { className: "make-app-approval-accessible-rows", "aria-label": "审批记录文字视图", children: [
365
- N.total === 0 && /* @__PURE__ */ o("li", { children: "暂无审批记录" }),
366
- N.rows.map((m) => /* @__PURE__ */ y("li", { children: [
367
- /* @__PURE__ */ y("span", { children: [
368
- m.applicationNo,
393
+ /* @__PURE__ */ T("ul", { className: "make-app-approval-accessible-rows", "aria-label": "审批记录文字视图", children: [
394
+ b.total === 0 && /* @__PURE__ */ o("li", { children: "暂无审批记录" }),
395
+ b.rows.map((t) => /* @__PURE__ */ T("li", { children: [
396
+ /* @__PURE__ */ T("span", { children: [
397
+ t.applicationNo,
369
398
  ",",
370
- m.applicationType,
399
+ t.applicationType,
371
400
  ",",
372
- m.applicantName,
401
+ t.applicantName,
373
402
  ",",
374
- m.applicationTime,
375
- s.tab === "initiated" ? `,${le(m.processStatus)}` : "",
403
+ t.applicationTime,
404
+ n.tab === "initiated" ? `,${ue(t.processStatus)}` : "",
376
405
  "。"
377
406
  ] }),
378
- /* @__PURE__ */ y(e, { htmlType: "button", variant: "text", onClick: () => P(m), children: [
407
+ /* @__PURE__ */ T(e, { htmlType: "button", variant: "text", onClick: () => S(t), children: [
379
408
  "打开 ",
380
- m.applicationNo || m.applicationType,
409
+ t.applicationNo || t.applicationType,
381
410
  " 的审批详情"
382
411
  ] })
383
- ] }, m.id))
412
+ ] }, t.id))
384
413
  ] })
385
414
  ] });
386
- }, Ie = [], xe = (e, t, s, R) => {
387
- const [F, P] = V(0), [L, f] = V(), k = $({ provider: e, logger: R });
388
- k.current = { provider: e, logger: R };
389
- const b = ke(() => ({}), [t, s, F]);
390
- q(() => {
391
- const l = new AbortController(), { provider: S, logger: h } = k.current, x = { operation: "list", tab: t.tab, page: t.page, pageSize: t.pageSize };
392
- E(h, { ...x, phase: "start" });
393
- let C = !1;
415
+ }, We = [], _e = (e, a, n, w) => {
416
+ const [F, S] = D(0), [m, c] = D(), v = H({ provider: e, logger: w });
417
+ v.current = { provider: e, logger: w };
418
+ const s = Pe(() => ({}), [a, n, F]);
419
+ ae(() => {
420
+ const y = new AbortController(), { provider: N, logger: f } = v.current, I = { operation: "list", tab: a.tab, page: a.page, pageSize: a.pageSize };
421
+ E(f, { ...I, phase: "start" });
422
+ let x = !1;
394
423
  return (async () => {
395
424
  try {
396
- if (await Promise.resolve(), l.signal.aborted) return;
397
- const M = await S.loadPage(t, { signal: l.signal });
398
- if (l.signal.aborted) return;
399
- const N = re(M, t.pageSize);
400
- C = !0, f({ ...N, token: b, status: "success" }), E(h, { ...x, phase: "success", rowCount: N.rows.length });
425
+ if (await Promise.resolve(), y.signal.aborted) return;
426
+ const d = await N.loadPage(a, { signal: y.signal });
427
+ if (y.signal.aborted) return;
428
+ const M = ce(d, a.pageSize);
429
+ x = !0, c({ ...M, token: s, status: "success" }), E(f, { ...I, phase: "success", rowCount: M.rows.length });
401
430
  } catch {
402
- if (l.signal.aborted) return;
403
- C = !0, f({ token: b, status: "error", rows: Ie, total: 0 }), E(h, { ...x, phase: "error" });
431
+ if (y.signal.aborted) return;
432
+ x = !0, c({ token: s, status: "error", rows: We, total: 0 }), E(f, { ...I, phase: "error" });
404
433
  }
405
434
  })(), () => {
406
- l.abort(), C || E(h, { ...x, phase: "cancel" });
435
+ y.abort(), x || E(f, { ...I, phase: "cancel" });
407
436
  };
408
- }, [t, b]);
409
- const I = L?.token === b ? L : void 0;
437
+ }, [a, s]);
438
+ const C = m?.token === s ? m : void 0;
410
439
  return {
411
- initialPage: I?.status === "success" ? I : void 0,
412
- total: I?.total ?? 0,
413
- status: I?.status ?? "loading",
414
- reload: () => P((l) => l + 1)
440
+ initialPage: C?.status === "success" ? C : void 0,
441
+ total: C?.total ?? 0,
442
+ status: C?.status ?? "loading",
443
+ reload: () => S((y) => y + 1)
415
444
  };
416
- }, te = { keyword: "", applicantId: "", processStatus: "", startDate: "", endDate: "" }, ge = ["pending", "approved"], ve = { pending: "待处理", approved: "已完成", initiated: "已发起" }, me = /* @__PURE__ */ y("svg", { "aria-hidden": "true", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", children: [
445
+ }, le = { keyword: "", applicantId: "", processStatus: "", startDate: "", endDate: "" }, Ne = ["pending", "approved"], xe = { pending: "待处理", approved: "已完成", initiated: "已发起" }, ke = /* @__PURE__ */ T("svg", { "aria-hidden": "true", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", children: [
417
446
  /* @__PURE__ */ o("circle", { cx: "10.5", cy: "10.5", r: "6.5" }),
418
447
  /* @__PURE__ */ o("path", { d: "m16 16 5 5" })
419
- ] }), ae = (e) => {
448
+ ] }), se = (e) => {
420
449
  if (e === "") return !0;
421
450
  if (!/^\d{4}-\d{2}-\d{2}$/.test(e)) return !1;
422
- const t = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
423
- return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
424
- }, ze = ({ components: e, provider: t, onOpenApproval: s, applicantOptions: R = [], pageSize: F = 20, refreshKey: P, themeKey: L, logger: f, className: k, presentation: b = "desktop", spacing: I = "host", tabs: l = ge }) => {
425
- const { Input: S, Select: h, DateRangePicker: x, Button: C, Tabs: M } = e, N = ye(), [c, B] = V(te), [n, p] = V(), [T, m] = V(0), [A, D] = V(""), [Y, r] = V(""), [a, d] = V({ ...te, tab: l[0], page: 1, pageSize: F }), { initialPage: g, status: K, reload: v } = xe(t, a, P, f), W = $(!1), _ = $(!0);
426
- q(() => (_.current = !0, () => {
427
- _.current = !1;
451
+ const a = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
452
+ return Number.isFinite(a.getTime()) && a.toISOString().slice(0, 10) === e;
453
+ }, Ke = ({ components: e, provider: a, onOpenApproval: n, applicantOptions: w = [], pageSize: F = 20, refreshKey: S, themeKey: m, logger: c, className: v, presentation: s = "desktop", spacing: C = "host", tabs: y = Ne }) => {
454
+ const { Input: N, Select: f, DateRangePicker: I, Button: x, Tabs: d } = e, M = ze(), [p, B] = D(le), [l, A] = D(), [b, W] = D(0), [V, P] = D(""), [L, r] = D(""), [t, h] = D({ ...le, tab: y[0], page: 1, pageSize: F }), { initialPage: g, status: K, reload: R } = _e(a, t, S, c), $ = H(!1), U = H(!0);
455
+ ae(() => (U.current = !0, () => {
456
+ U.current = !1;
428
457
  }), []);
429
- const U = K === "loading", X = async (i) => {
430
- if (!W.current) {
431
- W.current = !0, r(""), E(f, { operation: "open", phase: "start" });
458
+ const X = K === "loading", Z = async (i) => {
459
+ if (!$.current) {
460
+ $.current = !0, r(""), E(c, { operation: "open", phase: "start" });
432
461
  try {
433
- await s(i), E(f, { operation: "open", phase: "success" });
462
+ await n(i), E(c, { operation: "open", phase: "success" });
434
463
  } catch {
435
- _.current && r("审批详情打开失败,请重试"), E(f, { operation: "open", phase: "error" });
464
+ U.current && r("审批详情打开失败,请重试"), E(c, { operation: "open", phase: "error" });
436
465
  } finally {
437
- W.current = !1;
466
+ $.current = !1;
438
467
  }
439
468
  }
440
- }, O = (i) => {
441
- i === a.tab || !l.includes(i) || (D(""), r(""), i === "initiated" && (B((u) => ({ ...u, keyword: "", applicantId: "", processStatus: "" })), p(void 0)), d((u) => ({ ...u, ...i === "initiated" ? { keyword: "", applicantId: "", processStatus: "" } : {}, tab: i, page: 1 })));
469
+ }, re = (i) => {
470
+ i === t.tab || !y.includes(i) || (P(""), r(""), i === "initiated" && (B((u) => ({ ...u, keyword: "", applicantId: "", processStatus: "" })), A(void 0)), h((u) => ({ ...u, ...i === "initiated" ? { keyword: "", applicantId: "", processStatus: "" } : {}, tab: i, page: 1 })));
442
471
  }, j = (i) => {
443
- B((u) => ({ ...u, ...i })), b === "mobile" && (D(""), r(""), d((u) => ({ ...u, ...i, page: 1 })));
444
- }, H = /* @__PURE__ */ y(we, { children: [
445
- /* @__PURE__ */ y("form", { className: "make-app-approval-filters", onSubmit: (i) => {
446
- if (i.preventDefault(), b === "mobile") {
447
- D(""), r(""), d((u) => ({ ...u, keyword: c.keyword.trim(), page: 1 }));
472
+ B((u) => ({ ...u, ...i })), s === "mobile" && (P(""), r(""), h((u) => ({ ...u, ...i, page: 1 })));
473
+ }, q = /* @__PURE__ */ T(Ie, { children: [
474
+ /* @__PURE__ */ T("form", { className: "make-app-approval-filters", onSubmit: (i) => {
475
+ if (i.preventDefault(), s === "mobile") {
476
+ P(""), r(""), h((u) => ({ ...u, keyword: p.keyword.trim(), page: 1 }));
448
477
  return;
449
478
  }
450
- if (!ae(c.startDate) || !ae(c.endDate)) {
451
- D("请选择有效日期");
479
+ if (!se(p.startDate) || !se(p.endDate)) {
480
+ P("请选择有效日期");
452
481
  return;
453
482
  }
454
- if (c.startDate && c.endDate && c.startDate > c.endDate) {
455
- D("开始日期不能晚于结束日期");
483
+ if (p.startDate && p.endDate && p.startDate > p.endDate) {
484
+ P("开始日期不能晚于结束日期");
456
485
  return;
457
486
  }
458
- D(""), r(""), d((u) => ({ ...u, ...c, keyword: c.keyword.trim(), page: 1 }));
487
+ P(""), r(""), h((u) => ({ ...u, ...p, keyword: p.keyword.trim(), page: 1 }));
459
488
  }, children: [
460
- a.tab !== "initiated" && /* @__PURE__ */ y("div", { className: "make-app-approval-filter-field", children: [
461
- b === "mobile" && (I === "standard" ? /* @__PURE__ */ o("button", { type: "submit", className: "make-app-approval-mobile-search-button", "aria-label": "搜索申请单ID", children: me }) : /* @__PURE__ */ o(C, { htmlType: "submit", variant: "text", ariaLabel: "搜索申请单ID", children: me })),
462
- /* @__PURE__ */ o(S, { id: `${N}-keyword`, ariaLabel: "申请单ID", placeholder: "搜索申请单ID", value: c.keyword, onChange: (i) => {
463
- B((u) => ({ ...u, keyword: i })), b === "mobile" && !i && d((u) => ({ ...u, keyword: "", page: 1 }));
489
+ t.tab !== "initiated" && /* @__PURE__ */ T("div", { className: "make-app-approval-filter-field", children: [
490
+ s === "mobile" && (C === "standard" ? /* @__PURE__ */ o("button", { type: "submit", className: "make-app-approval-mobile-search-button", "aria-label": "搜索申请单ID", children: ke }) : /* @__PURE__ */ o(x, { htmlType: "submit", variant: "text", ariaLabel: "搜索申请单ID", children: ke })),
491
+ /* @__PURE__ */ o(N, { id: `${M}-keyword`, ariaLabel: "申请单ID", placeholder: "搜索申请单ID", value: p.keyword, onChange: (i) => {
492
+ B((u) => ({ ...u, keyword: i })), s === "mobile" && !i && h((u) => ({ ...u, keyword: "", page: 1 }));
464
493
  } })
465
494
  ] }),
466
495
  /* @__PURE__ */ o("div", { className: "make-app-approval-date-control", children: /* @__PURE__ */ o(
467
- x,
496
+ I,
468
497
  {
469
- id: `${N}-period`,
498
+ id: `${M}-period`,
470
499
  ariaLabel: "申请时间",
471
500
  placeholder: ["开始日期", "结束日期"],
472
- value: [c.startDate, c.endDate],
501
+ value: [p.startDate, p.endDate],
473
502
  onChange: ([i, u]) => {
474
- if (b === "mobile" && (!ae(i) || !ae(u) || i && u && i > u)) {
475
- D("请选择有效日期范围");
503
+ if (s === "mobile" && (!se(i) || !se(u) || i && u && i > u)) {
504
+ P("请选择有效日期范围");
476
505
  return;
477
506
  }
478
- if (b === "mobile" && !!i != !!u) {
479
- B((J) => ({ ...J, startDate: i, endDate: u }));
507
+ if (s === "mobile" && !!i != !!u) {
508
+ B((_) => ({ ..._, startDate: i, endDate: u }));
480
509
  return;
481
510
  }
482
511
  j({ startDate: i, endDate: u });
483
512
  }
484
513
  },
485
- T
514
+ b
486
515
  ) }),
487
- a.tab !== "initiated" && /* @__PURE__ */ o("div", { className: "make-app-approval-filter-field", children: /* @__PURE__ */ o(
488
- h,
516
+ t.tab !== "initiated" && /* @__PURE__ */ o("div", { className: "make-app-approval-filter-field", children: /* @__PURE__ */ o(
517
+ f,
489
518
  {
490
- id: `${N}-applicant`,
519
+ id: `${M}-applicant`,
491
520
  ariaLabel: "申请人",
492
521
  purpose: "applicant",
493
- value: c.applicantId ?? "",
494
- ...I === "standard" && n?.value === c.applicantId ? { selectedOption: n } : {},
495
- options: [{ value: "", label: "全部申请人" }, ...R.filter((i) => i.value !== "")],
522
+ value: p.applicantId ?? "",
523
+ ...C === "standard" && l?.value === p.applicantId ? { selectedOption: l } : {},
524
+ options: [{ value: "", label: "全部申请人" }, ...w.filter((i) => i.value !== "")],
496
525
  onChange: (i, u) => {
497
- p((J) => i ? u?.value === i ? u : R.find((G) => G.value === i) ?? (J?.value === i ? J : void 0) : void 0), j({ applicantId: i });
526
+ A((_) => i ? u?.value === i ? u : w.find((O) => O.value === i) ?? (_?.value === i ? _ : void 0) : void 0), j({ applicantId: i });
498
527
  }
499
528
  }
500
529
  ) }),
501
- b !== "mobile" && /* @__PURE__ */ y("div", { className: "make-app-approval-filter-actions", children: [
502
- /* @__PURE__ */ o(C, { htmlType: "submit", variant: "primary", children: "查询" }),
503
- /* @__PURE__ */ o(C, { htmlType: "button", variant: "default", onClick: () => {
504
- B(te), p(void 0), m((i) => i + 1), D(""), r(""), d((i) => ({ ...i, ...te, page: 1 }));
530
+ s !== "mobile" && /* @__PURE__ */ T("div", { className: "make-app-approval-filter-actions", children: [
531
+ /* @__PURE__ */ o(x, { htmlType: "submit", variant: "primary", children: "查询" }),
532
+ /* @__PURE__ */ o(x, { htmlType: "button", variant: "default", onClick: () => {
533
+ B(le), A(void 0), W((i) => i + 1), P(""), r(""), h((i) => ({ ...i, ...le, page: 1 }));
505
534
  }, children: "重置" }),
506
- /* @__PURE__ */ o(C, { htmlType: "button", variant: "default", disabled: U, loading: U, onClick: v, children: "刷新" })
535
+ /* @__PURE__ */ o(x, { htmlType: "button", variant: "default", disabled: X, loading: X, onClick: R, children: "刷新" })
507
536
  ] })
508
537
  ] }),
509
- A && /* @__PURE__ */ o("p", { role: "alert", className: "make-app-approval-error", children: A }),
510
- Y && /* @__PURE__ */ o("p", { role: "alert", className: "make-app-approval-error", children: Y }),
511
- /* @__PURE__ */ y("div", { className: "make-app-approval-results", "aria-busy": U, children: [
512
- b === "mobile" ? g && /* @__PURE__ */ o(Te, { initialPage: g, query: a, provider: t, onReload: v, components: e, onOpen: (i) => {
513
- X(i);
514
- }, logger: f }, JSON.stringify([a, P, g])) : /* @__PURE__ */ o(Re, { components: e, initialPage: g, query: a, provider: t, onOpen: (i) => {
515
- X(i);
516
- }, onReload: v, themeKey: L, logger: f }),
517
- U && /* @__PURE__ */ o("div", { className: "make-app-approval-overlay", role: "status", children: "正在加载审批记录…" }),
518
- K === "error" && /* @__PURE__ */ y("div", { className: "make-app-approval-overlay", role: "alert", children: [
538
+ V && /* @__PURE__ */ o("p", { role: "alert", className: "make-app-approval-error", children: V }),
539
+ L && /* @__PURE__ */ o("p", { role: "alert", className: "make-app-approval-error", children: L }),
540
+ /* @__PURE__ */ T("div", { className: "make-app-approval-results", "aria-busy": X, children: [
541
+ s === "mobile" ? g && /* @__PURE__ */ o(Oe, { initialPage: g, query: t, provider: a, onReload: R, components: e, onOpen: (i) => {
542
+ Z(i);
543
+ }, logger: c }, JSON.stringify([t, S, g])) : /* @__PURE__ */ o($e, { components: e, initialPage: g, query: t, provider: a, onOpen: (i) => {
544
+ Z(i);
545
+ }, onReload: R, themeKey: m, logger: c }),
546
+ X && /* @__PURE__ */ o("div", { className: "make-app-approval-overlay", role: "status", children: "正在加载审批记录…" }),
547
+ K === "error" && /* @__PURE__ */ T("div", { className: "make-app-approval-overlay", role: "alert", children: [
519
548
  /* @__PURE__ */ o("span", { children: "审批列表加载失败,请重试" }),
520
- /* @__PURE__ */ o(C, { htmlType: "button", variant: "default", onClick: v, children: "重试" })
549
+ /* @__PURE__ */ o(x, { htmlType: "button", variant: "default", onClick: R, children: "重试" })
521
550
  ] })
522
551
  ] })
523
- ] });
524
- return /* @__PURE__ */ o("section", { className: ["make-app-approval", b === "mobile" && "make-app-approval--mobile", I === "standard" && "make-app-approval--standard", k].filter(Boolean).join(" "), "aria-label": "我的审批", children: /* @__PURE__ */ o(M, { items: l.map((i) => ({ value: i, label: ve[i] })), value: a.tab, onChange: O, ariaLabel: "审批分类", children: I === "standard" ? /* @__PURE__ */ o("div", { className: "make-app-approval-panel", children: H }) : H }) });
525
- }, Be = (e) => {
526
- const t = e.pageSize ?? 20, s = e.tabs ?? ge;
527
- if (!s.length || new Set(s).size !== s.length || s.some((R) => !Object.hasOwn(ve, R))) throw new Error("MyApprovalsPage requires valid unique tabs");
552
+ ] }), G = Se(s);
553
+ return /* @__PURE__ */ o("section", { className: ["make-app-approval", s === "mobile" && "make-app-approval--mobile", C === "standard" && "make-app-approval--standard", v].filter(Boolean).join(" "), "aria-label": "我的审批", style: G.style, "data-make-approval-theme": G.style ? G.presentation : void 0, "data-make-approval-presentation": s === "mobile" ? "mobile" : void 0, children: /* @__PURE__ */ o(d, { items: y.map((i) => ({ value: i, label: xe[i] })), value: t.tab, onChange: re, ariaLabel: "审批分类", children: C === "standard" ? /* @__PURE__ */ o("div", { className: "make-app-approval-panel", children: q }) : q }) });
554
+ }, Ge = (e) => {
555
+ const a = e.pageSize ?? 20, n = e.tabs ?? Ne;
556
+ if (!n.length || new Set(n).size !== n.length || n.some((w) => !Object.hasOwn(xe, w))) throw new Error("MyApprovalsPage requires valid unique tabs");
528
557
  if (!e.scopeKey.trim()) throw new Error("MyApprovalsPage requires scopeKey");
529
- for (const R of ["Input", "Select", "DateRangePicker", "Button", "Tabs"])
530
- if (!e.components?.[R]) throw new Error(`MyApprovalsPage requires components.${R}`);
531
- if (!Number.isSafeInteger(t) || t < 1 || t > 200) throw new Error("pageSize must be an integer from 1 to 200");
532
- return /* @__PURE__ */ o(ze, { ...e, tabs: s, pageSize: t }, JSON.stringify([e.scopeKey, t, s]));
558
+ for (const w of ["Input", "Select", "DateRangePicker", "Button", "Tabs"])
559
+ if (!e.components?.[w]) throw new Error(`MyApprovalsPage requires components.${w}`);
560
+ if (!Number.isSafeInteger(a) || a < 1 || a > 200) throw new Error("pageSize must be an integer from 1 to 200");
561
+ return /* @__PURE__ */ o(Ke, { ...e, tabs: n, pageSize: a }, JSON.stringify([e.scopeKey, a, n]));
533
562
  };
534
563
  export {
535
- Be as MyApprovalsPage
564
+ Ge as MyApprovalsPage
536
565
  };