@qfei-design/make-app-approval 0.2.15 → 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,297 +1,326 @@
1
- import { jsxs as N, jsx as n } from "react/jsx-runtime";
2
- import { useState as D, useRef as O, useEffect as J, useMemo as be, useId as we } from "react";
3
- import { getApprovalStatusDisplay as ke } from "./index.mjs";
4
- const ue = (e) => typeof e == "object" && e !== null, ye = (e) => ue(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, ee = (e, t) => {
5
- if (!ue(e) || !Array.isArray(e.rows) || !e.rows.every(ye) || 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((l) => l.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
- }, A = (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
- }, ne = (e) => e == null || e === "UNSUBMITTED" ? "状态未知" : ke(e).label, Se = ({ initialPage: e, query: t, provider: l, components: P, onOpen: $, onReload: I, logger: E }) => {
15
- const [f, y] = D(e), [b, x] = D(2), [p, T] = D("idle"), h = O(void 0), [S, L] = D(!1), C = O(void 0);
16
- J(() => () => {
17
- C.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 c = async () => {
20
- if (C.current || f.rows.length >= f.total) return;
21
- const o = new AbortController();
22
- C.current = o, T("loading");
23
- const u = { operation: "list", tab: t.tab, page: b, pageSize: t.pageSize };
24
- A(E, { ...u, 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 d = ee(await l.loadPage({ ...t, page: b }, { signal: o.signal }), t.pageSize);
27
- if (o.signal.aborted) return;
28
- if (d.total < f.total) {
29
- A(E, { ...u, phase: "skip", rowCount: d.rows.length }), I();
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((M) => M.id));
33
- if (!d.rows.length || d.rows.some((M) => m.has(M.id))) throw new Error("Invalid append page");
34
- y({ rows: [...f.rows, ...d.rows], total: d.total }), x((M) => M + 1), T("idle"), A(E, { ...u, phase: "success", rowCount: d.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
- o.signal.aborted || (T("error"), A(E, { ...u, phase: "error" }));
37
+ l.signal.aborted || (N("error"), E(m, { ...A, phase: "error" }));
37
38
  } finally {
38
- C.current === o && (C.current = void 0);
39
+ d.current === l && (d.current = void 0);
39
40
  }
40
- }, R = (o) => {
41
- const { scrollHeight: u, scrollTop: d, clientHeight: m } = o.currentTarget;
42
- p === "idle" && u - d - m < 120 && c();
43
- }, { Button: V } = P;
44
- return /* @__PURE__ */ N(
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: R,
49
- onTouchStart: (o) => {
50
- h.current = o.currentTarget.scrollTop <= 0 && o.touches.length === 1 && p !== "loading" ? { start: o.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: (o) => {
53
- !h.current || o.touches.length !== 1 || (h.current.distance = o.touches[0].clientY - h.current.start, L(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 o = (h.current?.distance ?? 0) >= 60;
57
- h.current = void 0, L(!1), o && I();
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, L(!1);
61
+ f.current = void 0, x(!1);
61
62
  },
62
63
  "aria-label": "审批卡片列表",
63
- "aria-busy": p === "loading",
64
+ "aria-busy": y === "loading",
64
65
  children: [
65
- S && /* @__PURE__ */ n("p", { role: "status", className: "make-app-approval-mobile-feedback", children: "松开刷新" }),
66
- f.rows.map((o) => /* @__PURE__ */ N("button", { type: "button", className: "make-app-approval-mobile-card", onClick: () => $(o), "aria-label": `打开 ${o.applicationNo} 的审批详情`, children: [
67
- /* @__PURE__ */ n("strong", { children: o.applicationType || "审批申请" }),
68
- /* @__PURE__ */ N("span", { className: "make-app-approval-mobile-card-line", children: [
69
- /* @__PURE__ */ n("span", { children: "申请单ID:" }),
70
- /* @__PURE__ */ n("span", { children: o.applicationNo })
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: [
70
+ /* @__PURE__ */ o("span", { children: "申请单ID:" }),
71
+ /* @__PURE__ */ o("span", { children: l.applicationNo })
71
72
  ] }),
72
- t.tab === "approved" && /* @__PURE__ */ N("span", { className: "make-app-approval-mobile-card-line", children: [
73
- /* @__PURE__ */ n("span", { children: "审批结果:" }),
74
- /* @__PURE__ */ n("span", { children: o.completionResult || "—" })
73
+ a.tab === "approved" && /* @__PURE__ */ T("span", { className: "make-app-approval-mobile-card-line", children: [
74
+ /* @__PURE__ */ o("span", { children: "审批结果:" }),
75
+ /* @__PURE__ */ o("span", { children: l.completionResult || "—" })
75
76
  ] }),
76
- t.tab === "initiated" && /* @__PURE__ */ N("span", { className: "make-app-approval-mobile-card-line", children: [
77
- /* @__PURE__ */ n("span", { children: "流程状态:" }),
78
- /* @__PURE__ */ n("span", { children: ne(o.processStatus) })
77
+ a.tab === "initiated" && /* @__PURE__ */ T("span", { className: "make-app-approval-mobile-card-line", children: [
78
+ /* @__PURE__ */ o("span", { children: "流程状态:" }),
79
+ /* @__PURE__ */ o("span", { children: ue(l.processStatus) })
79
80
  ] }),
80
- /* @__PURE__ */ N("span", { className: "make-app-approval-mobile-card-footer", children: [
81
- /* @__PURE__ */ N("span", { className: "make-app-approval-mobile-person", children: [
82
- /* @__PURE__ */ n("span", { className: "make-app-approval-mobile-avatar", "aria-hidden": "true", children: o.applicantName.slice(-2) }),
83
- /* @__PURE__ */ n("span", { children: o.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__ */ n("span", { children: t.tab === "approved" ? `完成于 ${o.completionTime || "—"}` : `申请于 ${o.applicationTime || "—"}` })
86
+ /* @__PURE__ */ o("span", { children: a.tab === "approved" ? `完成于 ${l.completionTime || "—"}` : `申请于 ${l.applicationTime || "—"}` })
86
87
  ] })
87
- ] }, o.id)),
88
- !f.rows.length && /* @__PURE__ */ n("p", { className: "make-app-approval-mobile-feedback", children: "暂无审批记录" }),
89
- p === "error" ? /* @__PURE__ */ N("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
- /* @__PURE__ */ n(V, { htmlType: "button", variant: "text", onClick: () => {
92
- c();
92
+ /* @__PURE__ */ o(B, { htmlType: "button", variant: "text", onClick: () => {
93
+ M();
93
94
  }, children: "重试加载" })
94
- ] }) : p === "loading" ? /* @__PURE__ */ n("p", { role: "status", className: "make-app-approval-mobile-feedback", children: "加载中" }) : f.rows.length < f.total ? /* @__PURE__ */ n(V, { htmlType: "button", variant: "text", onClick: () => {
95
- c();
96
- }, children: "加载更多" }) : f.rows.length > 0 && /* @__PURE__ */ n("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
- }, Ne = {
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
- }, ce = Object.fromEntries(
106
- Object.entries(Ne).map(([e, t]) => [e, `data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`])
107
- ), oe = 64, pe = [
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
- ], de = (e, t) => {
113
- const l = t === "initiated" ? [...pe, { key: "statusLabel", title: "流程状态", width: 140 }] : pe, P = l.reduce((I, E) => I + E.width, oe), $ = Math.max(0, e - P) / l.length;
114
- return l.map((I) => ({
115
- ...I,
116
- width: I.width + $,
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: ce[I.key] ?? ce.applicationType })
138
+ prefixRender: () => {
139
+ const C = S();
140
+ return { icon: C[s.key] ?? C.applicationType };
141
+ }
120
142
  }));
121
- }, Te = ({ table: e, query: t, initialPage: l, loadPage: P, onChange: $, retryViewport: I, onReload: E, logger: f }) => {
122
- const y = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Set();
123
- let x = [];
124
- const p = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new Set();
125
- let h = l, S = l.total, L = 0, C = !1, c = !1, R;
126
- const V = (r) => Number.isSafeInteger(r) && r >= 0 && r * t.pageSize < S, o = (r, a, g) => A(f, { operation: "list", phase: a, tab: t.tab, page: r + 1, pageSize: t.pageSize, rowCount: g }), u = () => {
127
- C || $({ total: S, rows: x, failed: c || T.size > 0, loading: y.size > 0 });
128
- }, d = (r) => {
129
- r.finished || (r.finished = !0, r.removeAbort(), y.get(r.page) === r && y.delete(r.page), e.markPageLoadFailed(r.page, r.request), r.controller.abort(), o(r.page, "cancel"));
130
- }, m = (r) => {
131
- L = r;
132
- const a = e.getPagesInView() ?? [], g = new Set([L, ...a].flatMap((w) => [w - 1, w, w + 1]).filter(V));
133
- for (const w of y.values()) g.has(w.page) || d(w);
134
- for (const w of T) g.has(w) || T.delete(w);
135
- }, M = (r, a, g) => {
136
- const w = a.rows.map((v) => {
137
- const F = { ...v, statusLabel: ne(v.processStatus) };
138
- return p.set(F, v), F;
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(w, r, a.total, g)) {
141
- o(r, "skip");
162
+ if (!e.setVirtualPageData(g, r, t.total, h)) {
163
+ l(r, "skip");
142
164
  return;
143
165
  }
144
- S = a.total;
166
+ I = t.total;
145
167
  try {
146
- x = ee({ rows: e.getTableData() ?? [], total: S }, Number.MAX_SAFE_INTEGER).rows.map((v) => p.get(v) ?? v);
147
- } catch (v) {
148
- c = !0, x = [], h = void 0, R && clearTimeout(R), R = void 0;
149
- for (const F of y.values()) d(F);
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 !== S && (h = void 0), T.delete(r);
153
- for (const v of y.values()) V(v.page) || d(v);
154
- !V(r) && r > 0 && e.scrollToRow(Math.max(0, S - 1)), o(r, "success", a.rows.length);
155
- }, B = () => {
156
- if (C || R) return;
157
- const r = [...y.values()].filter((a) => !a.running && !a.finished).sort((a, g) => Math.abs(a.page - L) - Math.abs(g.page - L) || a.page - g.page);
158
- for (const a of r) {
159
- if (b.size >= 2) break;
160
- a.running = !0, b.add(a), o(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 g = await P({ ...t, page: a.page + 1 }, { signal: a.controller.signal });
163
- if (C || a.finished || a.controller.signal.aborted) return;
164
- const w = ee(g, t.pageSize);
165
- a.finished = !0, a.removeAbort(), y.delete(a.page), M(a.page, w, 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
- !C && !a.controller.signal.aborted && (T.add(a.page), o(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(), y.get(a.page) === a && y.delete(a.page)), b.delete(a), u(), B();
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
- u();
174
- }, H = () => {
175
- R && clearTimeout(R), R = setTimeout(() => {
176
- R = void 0, B();
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(), C || c || a.signal.aborted || !V(r)) {
182
- e.markPageLoadFailed(r, a), o(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 g = y.get(r);
186
- if (g?.request === a && !g.finished) return;
187
- if (g && d(g), 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
- M(0, v, a);
213
+ V(0, R, t);
192
214
  } catch {
193
- T.add(r), e.markPageLoadFailed(r, a), o(r, "error");
215
+ N.add(r), e.markPageLoadFailed(r, t), l(r, "error");
194
216
  }
195
- u();
217
+ A();
196
218
  return;
197
219
  }
198
- const w = { page: r, request: a, controller: new AbortController(), running: !1, finished: !1, removeAbort: () => {
199
- } }, W = () => {
200
- d(w), u();
220
+ const g = { page: r, request: t, controller: new AbortController(), running: !1, finished: !1, removeAbort: () => {
221
+ } }, K = () => {
222
+ b(g), A();
201
223
  };
202
- a.signal.addEventListener("abort", W, { once: !0 }), w.removeAbort = () => a.signal.removeEventListener("abort", W), y.set(r, w), H(), u();
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 (C) return;
227
+ if (d) return;
206
228
  const r = e.getPagesInView();
207
- r?.length && (m(r[0]), y.size && H(), u());
229
+ r?.length && (W(r[0]), v.size && L(), A());
208
230
  },
209
231
  retry() {
210
- if (!C) {
211
- if (c) {
212
- E();
232
+ if (!d) {
233
+ if (M) {
234
+ m();
213
235
  return;
214
236
  }
215
- T.size !== 0 && (T.clear(), I(), u());
237
+ N.size !== 0 && (N.clear(), S(), A());
216
238
  }
217
239
  },
218
240
  dispose() {
219
- C = !0, R && clearTimeout(R), R = void 0;
220
- for (const r of y.values()) d(r);
221
- x = [], T.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
- }, he = 40, Ce = (e) => {
225
- const t = O(void 0);
226
- return e.initialPage ? /* @__PURE__ */ n(
227
- Me,
246
+ }, ye = 40, $e = (e) => {
247
+ const a = H(void 0);
248
+ return e.initialPage ? /* @__PURE__ */ o(
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: (l) => {
233
- t.current = { query: e.query, position: l };
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
- ) : /* @__PURE__ */ n("div", { className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" });
237
- }, Me = ({ components: { Button: e }, initialPage: t, query: l, provider: P, themeKey: $, onOpen: I, onReload: E, logger: f, restoreScroll: y, rememberScroll: b }) => {
238
- const x = O(null), p = O(null), T = O(null), [h, S] = D(!1), [L, C] = D(0), [c, R] = D({ ...t, failed: !1, loading: !1 }), V = O(t.rows), o = O(y), u = O({ provider: P, onOpen: I, onReload: E, logger: f, rememberScroll: b });
239
- u.current = { provider: P, onOpen: I, onReload: E, logger: f, rememberScroll: b };
240
- const d = O(() => {
258
+ ) : /* @__PURE__ */ o("div", { className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" });
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 J(() => {
243
- const m = x.current;
244
- if (!m) return;
245
- let M = !1, B, H, r, a, g, w = t.total;
246
- A(u.current.logger, { operation: "table", phase: "start" });
247
- const W = () => {
248
- M || (S(!0), A(u.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 (M) return;
252
- const F = () => {
253
- const i = p.current, s = i?.getScrollState();
254
- i && s && v.globalEventBus.emitWithNamespace("scroll:change", i.tableId, s);
255
- }, X = (i = !1) => {
256
- if (!M)
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: s, height: K } = m.getBoundingClientRect();
259
- if (s <= 0 || K <= 0 || !i && g?.width === s && g.height === K) return;
260
- const j = getComputedStyle(m), ie = {
261
- rowHeight: he,
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: j.fontFamily || "Arial, sans-serif",
265
- ...j.color ? { textColor: j.color } : {},
266
- ...j.getPropertyValue("--make-approval-bg").trim() ? { rowBgColor: j.getPropertyValue("--make-approval-bg").trim() } : {},
267
- ...j.getPropertyValue("--make-approval-header").trim() ? { headerBgColor: j.getPropertyValue("--make-approval-header").trim() } : {},
268
- ...j.getPropertyValue("--make-approval-border").trim() ? { borderColor: j.getPropertyValue("--make-approval-border").trim() } : {}
269
- }, fe = Math.max(Math.ceil(300 / l.pageSize), Math.ceil(K * 3 / he / l.pageSize) + 2) * l.pageSize, se = { enabled: !0, totalRowCount: w, pageSize: l.pageSize, maxCachedRows: fe };
270
- if (p.current) {
271
- const k = g?.width !== s ? de(s, l.tab) : void 0;
272
- if (p.current.updateProps({
273
- canvasWidth: s,
274
- canvasHeight: K,
275
- style: ie,
276
- virtualOptions: se,
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({
302
+ canvasWidth: O,
303
+ canvasHeight: J,
304
+ style: oe,
305
+ virtualOptions: fe,
277
306
  ...k ? { columns: k } : {}
278
307
  }), k) {
279
- const z = p.current.getScrollState(), U = Math.max(0, k.reduce((_, ae) => _ + ae.width, oe) - s);
280
- z && z.scrollX > U && p.current.scrollTo(U, z.scrollY, !1);
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
- g = { width: s, height: K }, F();
311
+ U = { width: O, height: J }, G();
283
312
  return;
284
313
  }
285
- p.current = new v.CanvasTableComponent(m, {
286
- columns: de(s, l.tab),
287
- canvasWidth: s,
288
- canvasHeight: K,
289
- style: ie,
314
+ d.current = new j.CanvasTableComponent(t, {
315
+ columns: we(O, n.tab, me),
316
+ canvasWidth: O,
317
+ canvasHeight: J,
318
+ style: oe,
290
319
  rowKey: "id",
291
320
  minCanvasWidth: 0,
292
321
  minCanvasHeight: 0,
293
- showSN: { enabled: !0, width: oe, formatter: (k, z) => z + 1 },
294
- virtualOptions: se,
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",
@@ -302,232 +331,235 @@ const ue = (e) => typeof e == "object" && e !== null, ye = (e) => ue(e) ? ["id",
302
331
  bodyRowHeadSuffixOptions: {
303
332
  enabled: !0,
304
333
  width: 20,
305
- render: ({ group: k, x: z, height: U, rowData: _ }) => {
306
- const ae = _?.id, Q = new v.RectShape({ name: "approval-open", x: z, y: U / 2 - 10, cursor: "pointer", tooltip: "查看审批详情", attrs: { width: 20, height: 20, fill: "transparent", stroke: "transparent" } });
307
- Q.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="${j.color || "#64748b"}" stroke-width="1.8"><path d="M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5"/></svg>`)
311
- } })), Q.on("mousedown", (re) => re.stopPropagation?.()), Q.on("click", (re) => {
312
- re.stopPropagation?.();
313
- const le = V.current.find((ve) => ve.id === ae);
314
- le && u.current.onOpen(le);
315
- }), k.addChild(Q);
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 = p.current;
320
- g = { width: s, height: K };
321
- const te = Te({
322
- table: G,
323
- query: l,
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: F,
327
- onReload: () => u.current.onReload(),
328
- loadPage: (k, z) => u.current.provider.loadPage(k, z),
329
- logger: (k) => A(u.current.logger, k),
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),
330
359
  onChange: (k) => {
331
- M || (w = k.total, V.current = k.rows, R((z) => z.total === k.total && z.failed === k.failed && z.loading === k.loading && z.rows.length === k.rows.length && z.rows.every((U, _) => U === k.rows[_]) ? z : 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
- T.current = te, H = v.globalEventBus.onWithNamespace("data:load", G.tableId, (k, z) => te.load(k, z)), r = v.globalEventBus.onWithNamespace("scroll:change", G.tableId, () => te.viewportChanged()), o.current && G.scrollTo(o.current.scrollX, o.current.scrollY), S(!1), A(u.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
- W();
365
+ re();
337
366
  }
338
367
  };
339
- d.current = () => X(!0);
340
- const Y = () => X();
341
- B = new ResizeObserver(Y), B.observe(m), window.addEventListener("resize", Y), a = () => window.removeEventListener("resize", Y), X();
342
- }).catch(W), () => {
343
- M = !0, B?.disconnect(), a?.(), d.current = () => {
344
- }, p.current && (o.current = p.current.getScrollState(), o.current && u.current.rememberScroll(o.current)), H?.(), r?.(), T.current?.dispose(), T.current = null, p.current?.destroy(), p.current = null, A(u.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, l, L]), J(() => {
347
- d.current();
348
- }, [$]), /* @__PURE__ */ N("div", { className: "make-app-approval-table-frame", "aria-busy": c.loading, children: [
349
- /* @__PURE__ */ n("div", { ref: x, className: "make-app-approval-canvas", role: "group", "aria-label": "审批记录表格" }),
350
- h && /* @__PURE__ */ N("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
- /* @__PURE__ */ n(e, { htmlType: "button", variant: "default", onClick: () => {
353
- S(!1), C((m) => m + 1);
381
+ /* @__PURE__ */ o(e, { htmlType: "button", variant: "default", onClick: () => {
382
+ B(!1), A((t) => t + 1);
354
383
  }, children: "重新加载表格" })
355
384
  ] }),
356
- !h && c.failed && /* @__PURE__ */ N("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__ */ n(e, { htmlType: "button", variant: "default", onClick: () => T.current?.retry(), children: "重试加载" })
387
+ /* @__PURE__ */ o(e, { htmlType: "button", variant: "default", onClick: () => M.current?.retry(), children: "重试加载" })
359
388
  ] }),
360
- !h && !c.failed && c.loading && /* @__PURE__ */ N("div", { className: "make-app-approval-table-loading", role: "status", "aria-label": "正在加载审批记录", "aria-live": "polite", children: [
361
- /* @__PURE__ */ n("span", { className: "make-app-approval-loading-spinner", "aria-hidden": "true" }),
362
- /* @__PURE__ */ n("span", { children: "加载中" })
389
+ !p && !b.failed && b.loading && /* @__PURE__ */ T("div", { className: "make-app-approval-table-loading", role: "status", "aria-label": "正在加载审批记录", "aria-live": "polite", children: [
390
+ /* @__PURE__ */ o("span", { className: "make-app-approval-loading-spinner", "aria-hidden": "true" }),
391
+ /* @__PURE__ */ o("span", { children: "加载中" })
363
392
  ] }),
364
- /* @__PURE__ */ N("ul", { className: "make-app-approval-accessible-rows", "aria-label": "审批记录文字视图", children: [
365
- c.total === 0 && /* @__PURE__ */ n("li", { children: "暂无审批记录" }),
366
- c.rows.map((m) => /* @__PURE__ */ N("li", { children: [
367
- /* @__PURE__ */ N("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
- l.tab === "initiated" ? `,${ne(m.processStatus)}` : "",
403
+ t.applicationTime,
404
+ n.tab === "initiated" ? `,${ue(t.processStatus)}` : "",
376
405
  "。"
377
406
  ] }),
378
- /* @__PURE__ */ N(e, { htmlType: "button", variant: "text", onClick: () => I(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
- }, Re = [], Ie = (e, t, l, P) => {
387
- const [$, I] = D(0), [E, f] = D(), y = O({ provider: e, logger: P });
388
- y.current = { provider: e, logger: P };
389
- const b = be(() => ({}), [t, l, $]);
390
- J(() => {
391
- const p = new AbortController(), { provider: T, logger: h } = y.current, S = { operation: "list", tab: t.tab, page: t.page, pageSize: t.pageSize };
392
- A(h, { ...S, phase: "start" });
393
- let L = !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(), p.signal.aborted) return;
397
- const C = await T.loadPage(t, { signal: p.signal });
398
- if (p.signal.aborted) return;
399
- const c = ee(C, t.pageSize);
400
- L = !0, f({ ...c, token: b, status: "success" }), A(h, { ...S, phase: "success", rowCount: c.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 (p.signal.aborted) return;
403
- L = !0, f({ token: b, status: "error", rows: Re, total: 0 }), A(h, { ...S, 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
- p.abort(), L || A(h, { ...S, phase: "cancel" });
435
+ y.abort(), x || E(f, { ...I, phase: "cancel" });
407
436
  };
408
- }, [t, b]);
409
- const x = E?.token === b ? E : void 0;
437
+ }, [a, s]);
438
+ const C = m?.token === s ? m : void 0;
410
439
  return {
411
- initialPage: x?.status === "success" ? x : void 0,
412
- total: x?.total ?? 0,
413
- status: x?.status ?? "loading",
414
- reload: () => I((p) => p + 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
- }, Z = { keyword: "", applicantId: "", processStatus: "", startDate: "", endDate: "" }, me = ["pending", "approved"], ge = { pending: "待处理", approved: "已完成", initiated: "已发起" }, q = (e) => {
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: [
446
+ /* @__PURE__ */ o("circle", { cx: "10.5", cy: "10.5", r: "6.5" }),
447
+ /* @__PURE__ */ o("path", { d: "m16 16 5 5" })
448
+ ] }), se = (e) => {
417
449
  if (e === "") return !0;
418
450
  if (!/^\d{4}-\d{2}-\d{2}$/.test(e)) return !1;
419
- const t = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
420
- return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
421
- }, Pe = ({ components: e, provider: t, onOpenApproval: l, applicantOptions: P = [], pageSize: $ = 20, refreshKey: I, themeKey: E, logger: f, className: y, presentation: b = "desktop", tabs: x = me }) => {
422
- const { Input: p, Select: T, DateRangePicker: h, Button: S, Tabs: L } = e, C = we(), [c, R] = D(Z), [V, o] = D(0), [u, d] = D(""), [m, M] = D(""), [B, H] = D({ ...Z, tab: x[0], page: 1, pageSize: $ }), { initialPage: r, status: a, reload: g } = Ie(t, B, I, f), w = O(!1), W = O(!0);
423
- J(() => (W.current = !0, () => {
424
- W.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;
425
457
  }), []);
426
- const v = a === "loading", F = async (i) => {
427
- if (!w.current) {
428
- w.current = !0, M(""), A(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" });
429
461
  try {
430
- await l(i), A(f, { operation: "open", phase: "success" });
462
+ await n(i), E(c, { operation: "open", phase: "success" });
431
463
  } catch {
432
- W.current && M("审批详情打开失败,请重试"), A(f, { operation: "open", phase: "error" });
464
+ U.current && r("审批详情打开失败,请重试"), E(c, { operation: "open", phase: "error" });
433
465
  } finally {
434
- w.current = !1;
466
+ $.current = !1;
435
467
  }
436
468
  }
437
- }, X = (i) => {
438
- i === B.tab || !x.includes(i) || (d(""), M(""), i === "initiated" && R((s) => ({ ...s, keyword: "", applicantId: "", processStatus: "" })), H((s) => ({ ...s, ...i === "initiated" ? { keyword: "", applicantId: "", processStatus: "" } : {}, tab: i, page: 1 })));
439
- }, Y = (i) => {
440
- R((s) => ({ ...s, ...i })), b === "mobile" && (d(""), M(""), H((s) => ({ ...s, ...i, page: 1 })));
441
- };
442
- return /* @__PURE__ */ n("section", { className: ["make-app-approval", b === "mobile" && "make-app-approval--mobile", y].filter(Boolean).join(" "), "aria-label": "我的审批", children: /* @__PURE__ */ N(L, { items: x.map((i) => ({ value: i, label: ge[i] })), value: B.tab, onChange: X, ariaLabel: "审批分类", children: [
443
- /* @__PURE__ */ N("form", { className: "make-app-approval-filters", onSubmit: (i) => {
444
- if (i.preventDefault(), b === "mobile") {
445
- d(""), M(""), H((s) => ({ ...s, keyword: c.keyword.trim(), 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 })));
471
+ }, j = (i) => {
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 }));
446
477
  return;
447
478
  }
448
- if (!q(c.startDate) || !q(c.endDate)) {
449
- d("请选择有效日期");
479
+ if (!se(p.startDate) || !se(p.endDate)) {
480
+ P("请选择有效日期");
450
481
  return;
451
482
  }
452
- if (c.startDate && c.endDate && c.startDate > c.endDate) {
453
- d("开始日期不能晚于结束日期");
483
+ if (p.startDate && p.endDate && p.startDate > p.endDate) {
484
+ P("开始日期不能晚于结束日期");
454
485
  return;
455
486
  }
456
- d(""), M(""), H((s) => ({ ...s, ...c, keyword: c.keyword.trim(), page: 1 }));
487
+ P(""), r(""), h((u) => ({ ...u, ...p, keyword: p.keyword.trim(), page: 1 }));
457
488
  }, children: [
458
- B.tab !== "initiated" && /* @__PURE__ */ N("div", { className: "make-app-approval-filter-field", children: [
459
- b === "mobile" && /* @__PURE__ */ n(S, { htmlType: "submit", variant: "text", ariaLabel: "搜索申请单ID", children: /* @__PURE__ */ N("svg", { "aria-hidden": "true", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", children: [
460
- /* @__PURE__ */ n("circle", { cx: "10.5", cy: "10.5", r: "6.5" }),
461
- /* @__PURE__ */ n("path", { d: "m16 16 5 5" })
462
- ] }) }),
463
- /* @__PURE__ */ n(p, { id: `${C}-keyword`, ariaLabel: "申请单ID", placeholder: "搜索申请单ID", value: c.keyword, onChange: (i) => {
464
- R((s) => ({ ...s, keyword: i })), b === "mobile" && !i && H((s) => ({ ...s, 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 }));
465
493
  } })
466
494
  ] }),
467
- /* @__PURE__ */ n("div", { className: "make-app-approval-date-control", children: /* @__PURE__ */ n(
468
- h,
495
+ /* @__PURE__ */ o("div", { className: "make-app-approval-date-control", children: /* @__PURE__ */ o(
496
+ I,
469
497
  {
470
- id: `${C}-period`,
498
+ id: `${M}-period`,
471
499
  ariaLabel: "申请时间",
472
500
  placeholder: ["开始日期", "结束日期"],
473
- value: [c.startDate, c.endDate],
474
- onChange: ([i, s]) => {
475
- if (b === "mobile" && (!q(i) || !q(s) || i && s && i > s)) {
476
- d("请选择有效日期范围");
501
+ value: [p.startDate, p.endDate],
502
+ onChange: ([i, u]) => {
503
+ if (s === "mobile" && (!se(i) || !se(u) || i && u && i > u)) {
504
+ P("请选择有效日期范围");
477
505
  return;
478
506
  }
479
- if (b === "mobile" && !!i != !!s) {
480
- R((K) => ({ ...K, startDate: i, endDate: s }));
507
+ if (s === "mobile" && !!i != !!u) {
508
+ B((_) => ({ ..._, startDate: i, endDate: u }));
481
509
  return;
482
510
  }
483
- Y({ startDate: i, endDate: s });
511
+ j({ startDate: i, endDate: u });
484
512
  }
485
513
  },
486
- V
514
+ b
487
515
  ) }),
488
- B.tab !== "initiated" && /* @__PURE__ */ n("div", { className: "make-app-approval-filter-field", children: /* @__PURE__ */ n(
489
- T,
516
+ t.tab !== "initiated" && /* @__PURE__ */ o("div", { className: "make-app-approval-filter-field", children: /* @__PURE__ */ o(
517
+ f,
490
518
  {
491
- id: `${C}-applicant`,
519
+ id: `${M}-applicant`,
492
520
  ariaLabel: "申请人",
493
521
  purpose: "applicant",
494
- value: c.applicantId ?? "",
495
- options: [{ value: "", label: "全部申请人" }, ...P.filter((i) => i.value !== "")],
496
- onChange: (i) => Y({ applicantId: i })
522
+ value: p.applicantId ?? "",
523
+ ...C === "standard" && l?.value === p.applicantId ? { selectedOption: l } : {},
524
+ options: [{ value: "", label: "全部申请人" }, ...w.filter((i) => i.value !== "")],
525
+ onChange: (i, u) => {
526
+ A((_) => i ? u?.value === i ? u : w.find((O) => O.value === i) ?? (_?.value === i ? _ : void 0) : void 0), j({ applicantId: i });
527
+ }
497
528
  }
498
529
  ) }),
499
- b !== "mobile" && /* @__PURE__ */ N("div", { className: "make-app-approval-filter-actions", children: [
500
- /* @__PURE__ */ n(S, { htmlType: "submit", variant: "primary", children: "查询" }),
501
- /* @__PURE__ */ n(S, { htmlType: "button", variant: "default", onClick: () => {
502
- R(Z), o((i) => i + 1), d(""), M(""), H((i) => ({ ...i, ...Z, 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 }));
503
534
  }, children: "重置" }),
504
- /* @__PURE__ */ n(S, { htmlType: "button", variant: "default", disabled: v, loading: v, onClick: g, children: "刷新" })
535
+ /* @__PURE__ */ o(x, { htmlType: "button", variant: "default", disabled: X, loading: X, onClick: R, children: "刷新" })
505
536
  ] })
506
537
  ] }),
507
- u && /* @__PURE__ */ n("p", { role: "alert", className: "make-app-approval-error", children: u }),
508
- m && /* @__PURE__ */ n("p", { role: "alert", className: "make-app-approval-error", children: m }),
509
- /* @__PURE__ */ N("div", { className: "make-app-approval-results", "aria-busy": v, children: [
510
- b === "mobile" ? r && /* @__PURE__ */ n(Se, { initialPage: r, query: B, provider: t, onReload: g, components: e, onOpen: (i) => {
511
- F(i);
512
- }, logger: f }, JSON.stringify([B, I, r])) : /* @__PURE__ */ n(Ce, { components: e, initialPage: r, query: B, provider: t, onOpen: (i) => {
513
- F(i);
514
- }, onReload: g, themeKey: E, logger: f }),
515
- v && /* @__PURE__ */ n("div", { className: "make-app-approval-overlay", role: "status", children: "正在加载审批记录…" }),
516
- a === "error" && /* @__PURE__ */ N("div", { className: "make-app-approval-overlay", role: "alert", children: [
517
- /* @__PURE__ */ n("span", { children: "审批列表加载失败,请重试" }),
518
- /* @__PURE__ */ n(S, { htmlType: "button", variant: "default", onClick: g, 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: [
548
+ /* @__PURE__ */ o("span", { children: "审批列表加载失败,请重试" }),
549
+ /* @__PURE__ */ o(x, { htmlType: "button", variant: "default", onClick: R, children: "重试" })
519
550
  ] })
520
551
  ] })
521
- ] }) });
522
- }, Ee = (e) => {
523
- const t = e.pageSize ?? 20, l = e.tabs ?? me;
524
- if (!l.length || new Set(l).size !== l.length || l.some((P) => !Object.hasOwn(ge, P))) 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");
525
557
  if (!e.scopeKey.trim()) throw new Error("MyApprovalsPage requires scopeKey");
526
- for (const P of ["Input", "Select", "DateRangePicker", "Button", "Tabs"])
527
- if (!e.components?.[P]) throw new Error(`MyApprovalsPage requires components.${P}`);
528
- if (!Number.isSafeInteger(t) || t < 1 || t > 200) throw new Error("pageSize must be an integer from 1 to 200");
529
- return /* @__PURE__ */ n(Pe, { ...e, tabs: l, pageSize: t }, JSON.stringify([e.scopeKey, t, l]));
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]));
530
562
  };
531
563
  export {
532
- Ee as MyApprovalsPage
564
+ Ge as MyApprovalsPage
533
565
  };