@zeroman.yang/react-auto-components 0.1.0
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/LICENSE +21 -0
- package/README.md +260 -0
- package/dist/adapters/xlsx.d.ts +7 -0
- package/dist/components/AutoChat/VirtualChatMessages.d.ts +16 -0
- package/dist/components/AutoChat/index.d.ts +4 -0
- package/dist/components/AutoChat/types.d.ts +89 -0
- package/dist/components/AutoChat/useChatScroll.d.ts +10 -0
- package/dist/components/AutoDialog/index.d.ts +46 -0
- package/dist/components/AutoForm/AutoForm.d.ts +2 -0
- package/dist/components/AutoForm/ChoiceField.d.ts +16 -0
- package/dist/components/AutoForm/FormField.d.ts +8 -0
- package/dist/components/AutoForm/index.d.ts +2 -0
- package/dist/components/AutoForm/types.d.ts +28 -0
- package/dist/components/AutoMenu/index.d.ts +35 -0
- package/dist/components/AutoSearchPanel/index.d.ts +21 -0
- package/dist/components/AutoTable/AutoTable.d.ts +2 -0
- package/dist/components/AutoTable/FilterEditor.d.ts +7 -0
- package/dist/components/AutoTable/SettingsPanel.d.ts +7 -0
- package/dist/components/AutoTable/TableHeader.d.ts +18 -0
- package/dist/components/AutoTable/export.d.ts +11 -0
- package/dist/components/AutoTable/features.d.ts +9 -0
- package/dist/components/AutoTable/index.d.ts +4 -0
- package/dist/components/AutoTable/settings.d.ts +34 -0
- package/dist/components/AutoTable/types.d.ts +107 -0
- package/dist/components/AutoTable/useTableData.d.ts +9 -0
- package/dist/components/AutoTable/useTableSettings.d.ts +7 -0
- package/dist/components/AutoTabs/index.d.ts +29 -0
- package/dist/core/AutoConfigProvider.d.ts +34 -0
- package/dist/core/config.d.ts +10 -0
- package/dist/core/i18n.d.ts +2 -0
- package/dist/core/query.d.ts +24 -0
- package/dist/core/types.d.ts +93 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +3246 -0
- package/dist/internal/Popover.d.ts +16 -0
- package/dist/style.css +2 -0
- package/dist/xlsx.js +9 -0
- package/docs/auto-chat.md +89 -0
- package/docs/i18n/de/README.md +203 -0
- package/docs/i18n/de/auto-chat.md +82 -0
- package/docs/i18n/de/migration.md +71 -0
- package/docs/i18n/es/README.md +203 -0
- package/docs/i18n/es/auto-chat.md +82 -0
- package/docs/i18n/es/migration.md +71 -0
- package/docs/i18n/fr/README.md +203 -0
- package/docs/i18n/fr/auto-chat.md +82 -0
- package/docs/i18n/fr/migration.md +71 -0
- package/docs/i18n/ja/README.md +203 -0
- package/docs/i18n/ja/auto-chat.md +82 -0
- package/docs/i18n/ja/migration.md +71 -0
- package/docs/i18n/ko/README.md +203 -0
- package/docs/i18n/ko/auto-chat.md +82 -0
- package/docs/i18n/ko/migration.md +71 -0
- package/docs/i18n/pt-BR/README.md +203 -0
- package/docs/i18n/pt-BR/auto-chat.md +82 -0
- package/docs/i18n/pt-BR/migration.md +71 -0
- package/docs/i18n/ru/README.md +203 -0
- package/docs/i18n/ru/auto-chat.md +82 -0
- package/docs/i18n/ru/migration.md +71 -0
- package/docs/i18n/zh-CN/README.md +217 -0
- package/docs/i18n/zh-CN/auto-chat.md +82 -0
- package/docs/i18n/zh-CN/migration.md +71 -0
- package/docs/i18n/zh-TW/README.md +217 -0
- package/docs/i18n/zh-TW/auto-chat.md +82 -0
- package/docs/i18n/zh-TW/migration.md +71 -0
- package/docs/migration.md +71 -0
- package/package.json +111 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3246 @@
|
|
|
1
|
+
import { c as e } from "react/compiler-runtime";
|
|
2
|
+
import { Fragment as t, cloneElement as n, createContext as r, createElement as i, useCallback as a, useContext as o, useEffect as s, useId as c, useImperativeHandle as l, useLayoutEffect as u, useMemo as d, useRef as f, useState as p, useSyncExternalStore as m } from "react";
|
|
3
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
4
|
+
import { useForm as v, useStore as y } from "@tanstack/react-form";
|
|
5
|
+
import { useVirtualizer as b } from "@tanstack/react-virtual";
|
|
6
|
+
import * as x from "@radix-ui/react-dialog";
|
|
7
|
+
import * as S from "@radix-ui/react-tabs";
|
|
8
|
+
import { FloatingFocusManager as C, FloatingPortal as w, autoUpdate as T, flip as E, offset as D, shift as O, size as k, useClick as A, useDismiss as j, useFloating as M, useInteractions as N, useMergeRefs as P, useRole as F } from "@floating-ui/react";
|
|
9
|
+
import { createExpandedRowModel as I, createPaginatedRowModel as L, createSortedRowModel as R, functionalUpdate as ee, rowExpandingFeature as z, rowPaginationFeature as B, rowSelectionFeature as te, rowSortingFeature as ne, tableFeatures as V, useTable as re } from "@tanstack/react-table";
|
|
10
|
+
import * as ie from "@radix-ui/react-context-menu";
|
|
11
|
+
//#region src/core/config.ts
|
|
12
|
+
function H(e, t, n) {
|
|
13
|
+
return typeof e == "function" ? e(t) : e ?? n;
|
|
14
|
+
}
|
|
15
|
+
function ae(e, t = {}) {
|
|
16
|
+
let n = {}, r = /* @__PURE__ */ new Set();
|
|
17
|
+
for (let t of e) if (t.name) {
|
|
18
|
+
if (r.has(t.name)) throw Error(`Duplicate field: ${t.name}`);
|
|
19
|
+
r.add(t.name), t.defaultValue !== void 0 && (n[t.name] = structuredClone(t.defaultValue));
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
...n,
|
|
23
|
+
...t
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function oe(e) {
|
|
27
|
+
return e.map((e) => ({ ...e }));
|
|
28
|
+
}
|
|
29
|
+
var U = {
|
|
30
|
+
get(e) {
|
|
31
|
+
try {
|
|
32
|
+
let t = globalThis.localStorage?.getItem(e);
|
|
33
|
+
return t ? JSON.parse(t) : void 0;
|
|
34
|
+
} catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
set(e, t) {
|
|
39
|
+
try {
|
|
40
|
+
globalThis.localStorage?.setItem(e, JSON.stringify(t));
|
|
41
|
+
} catch {}
|
|
42
|
+
},
|
|
43
|
+
remove(e) {
|
|
44
|
+
try {
|
|
45
|
+
globalThis.localStorage?.removeItem(e);
|
|
46
|
+
} catch {}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function W(e) {
|
|
50
|
+
return e instanceof Error ? e.message : String(e);
|
|
51
|
+
}
|
|
52
|
+
function G(e, t) {
|
|
53
|
+
if (Object.is(e, t)) return !0;
|
|
54
|
+
if (e instanceof Date && t instanceof Date) return e.getTime() === t.getTime();
|
|
55
|
+
if (!e || !t || typeof e != "object" || typeof t != "object") return !1;
|
|
56
|
+
let n = Object.keys(e), r = Object.keys(t);
|
|
57
|
+
return n.length === r.length && n.every((n) => Object.hasOwn(t, n) && G(e[n], t[n]));
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/core/query.ts
|
|
61
|
+
var se = {
|
|
62
|
+
kind: "group",
|
|
63
|
+
operator: "and",
|
|
64
|
+
children: []
|
|
65
|
+
};
|
|
66
|
+
function K(e, t) {
|
|
67
|
+
let n = [];
|
|
68
|
+
for (let r of t) {
|
|
69
|
+
if (!r.name) continue;
|
|
70
|
+
let t = e[r.name];
|
|
71
|
+
if (r.match !== "isNull" && (t == null || t === "" || Array.isArray(t) && !t.length)) continue;
|
|
72
|
+
let i = r.match ?? (Array.isArray(t) ? "in" : "eq"), a = (r.searchFields ?? [r.name]).map((e) => {
|
|
73
|
+
let n = {
|
|
74
|
+
kind: "condition",
|
|
75
|
+
field: e,
|
|
76
|
+
operator: i,
|
|
77
|
+
value: t,
|
|
78
|
+
ignoreCase: r.ignoreCase
|
|
79
|
+
};
|
|
80
|
+
return r.includeNull ? {
|
|
81
|
+
kind: "group",
|
|
82
|
+
operator: "or",
|
|
83
|
+
children: [n, {
|
|
84
|
+
kind: "condition",
|
|
85
|
+
field: e,
|
|
86
|
+
operator: "isNull",
|
|
87
|
+
value: null
|
|
88
|
+
}]
|
|
89
|
+
} : n;
|
|
90
|
+
});
|
|
91
|
+
n.push(a.length === 1 ? a[0] : {
|
|
92
|
+
kind: "group",
|
|
93
|
+
operator: "or",
|
|
94
|
+
children: a
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
kind: "group",
|
|
99
|
+
operator: "and",
|
|
100
|
+
children: n
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function ce(e, t) {
|
|
104
|
+
if (t.kind === "group") return t.operator === "and" ? t.children.every((t) => ce(e, t)) : t.children.some((t) => ce(e, t));
|
|
105
|
+
let n = e[t.field], r = (e) => t.ignoreCase && typeof e == "string" ? e.toLocaleLowerCase() : e, i = r(n), a = r(t.value);
|
|
106
|
+
switch (t.operator) {
|
|
107
|
+
case "isNull": return n == null;
|
|
108
|
+
case "eq": return Object.is(i, a);
|
|
109
|
+
case "contains": return i != null && String(i).includes(String(a));
|
|
110
|
+
case "in": return Array.isArray(t.value) && t.value.some((e) => Object.is(i, r(e)));
|
|
111
|
+
case "between": return Array.isArray(t.value) && n != null && (t.value[0] == null || n >= t.value[0]) && (t.value[1] == null || n <= t.value[1]);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function q(e) {
|
|
115
|
+
if (e.kind === "group") {
|
|
116
|
+
let t = e.children.map(q).filter(Boolean);
|
|
117
|
+
return t.length > 1 ? `(${t.join(e.operator === "and" ? ";" : ",")})` : t[0] ?? "";
|
|
118
|
+
}
|
|
119
|
+
if (!/^[\w.]+$/.test(e.field)) throw Error(`Invalid query field: ${e.field}`);
|
|
120
|
+
let t = (e) => typeof e == "string" ? `"${e.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"` : String(e);
|
|
121
|
+
if (e.operator === "isNull") return `${e.field}==null`;
|
|
122
|
+
if (e.operator === "in") return `${e.field}=in=(${(Array.isArray(e.value) ? e.value : []).map(t).join(",")})`;
|
|
123
|
+
if (e.operator === "between") {
|
|
124
|
+
let [n, r] = e.value;
|
|
125
|
+
return `(${e.field}=ge=${t(n)};${e.field}=le=${t(r)})`;
|
|
126
|
+
}
|
|
127
|
+
return `${e.field}${e.operator === "contains" ? e.ignoreCase ? "=ilike=" : "=like=" : "=="}${t(e.value)}`;
|
|
128
|
+
}
|
|
129
|
+
function J(e, t, n = 0) {
|
|
130
|
+
if (!e || typeof e != "object" || n > 32) return !1;
|
|
131
|
+
let r = e;
|
|
132
|
+
return r.kind === "group" ? (r.operator === "and" || r.operator === "or") && Array.isArray(r.children) && r.children.length <= 1e3 && r.children.every((e) => J(e, t, n + 1)) : r.kind !== "condition" || typeof r.field != "string" || t && !t.includes(r.field) || ![
|
|
133
|
+
"eq",
|
|
134
|
+
"in",
|
|
135
|
+
"contains",
|
|
136
|
+
"between",
|
|
137
|
+
"isNull"
|
|
138
|
+
].includes(String(r.operator)) ? !1 : r.operator === "in" ? Array.isArray(r.value) : r.operator !== "between" || Array.isArray(r.value) && r.value.length === 2;
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/core/AutoConfigProvider.tsx
|
|
142
|
+
var le = r({
|
|
143
|
+
namespace: "auto",
|
|
144
|
+
size: "medium",
|
|
145
|
+
density: "comfortable",
|
|
146
|
+
form: {
|
|
147
|
+
labelPosition: "top",
|
|
148
|
+
labelWidth: "auto"
|
|
149
|
+
},
|
|
150
|
+
t: (e, t) => t ?? e,
|
|
151
|
+
canAccess: () => !0,
|
|
152
|
+
storage: U,
|
|
153
|
+
notify: () => {},
|
|
154
|
+
fields: {}
|
|
155
|
+
});
|
|
156
|
+
function ue(t) {
|
|
157
|
+
let n = e(26), { config: r, children: i } = t, a = o(le), s = r?.fields, c;
|
|
158
|
+
n[0] !== a.fields || n[1] !== s ? (c = {
|
|
159
|
+
...a.fields,
|
|
160
|
+
...s
|
|
161
|
+
}, n[0] = a.fields, n[1] = s, n[2] = c) : c = n[2];
|
|
162
|
+
let l = r?.form, u;
|
|
163
|
+
n[3] !== a.form || n[4] !== l ? (u = {
|
|
164
|
+
...a.form,
|
|
165
|
+
...l
|
|
166
|
+
}, n[3] = a.form, n[4] = l, n[5] = u) : u = n[5];
|
|
167
|
+
let d;
|
|
168
|
+
n[6] !== r || n[7] !== a.table ? (d = r?.table ? {
|
|
169
|
+
...a.table,
|
|
170
|
+
...r.table
|
|
171
|
+
} : a.table, n[6] = r, n[7] = a.table, n[8] = d) : d = n[8];
|
|
172
|
+
let f;
|
|
173
|
+
n[9] !== r || n[10] !== a.tabs ? (f = r?.tabs ? {
|
|
174
|
+
...a.tabs,
|
|
175
|
+
...r.tabs
|
|
176
|
+
} : a.tabs, n[9] = r, n[10] = a.tabs, n[11] = f) : f = n[11];
|
|
177
|
+
let p;
|
|
178
|
+
n[12] !== r || n[13] !== a.menu ? (p = r?.menu ? {
|
|
179
|
+
...a.menu,
|
|
180
|
+
...r.menu
|
|
181
|
+
} : a.menu, n[12] = r, n[13] = a.menu, n[14] = p) : p = n[14];
|
|
182
|
+
let m;
|
|
183
|
+
n[15] !== r || n[16] !== a || n[17] !== c || n[18] !== u || n[19] !== d || n[20] !== f || n[21] !== p ? (m = {
|
|
184
|
+
...a,
|
|
185
|
+
...r,
|
|
186
|
+
fields: c,
|
|
187
|
+
form: u,
|
|
188
|
+
table: d,
|
|
189
|
+
tabs: f,
|
|
190
|
+
menu: p
|
|
191
|
+
}, n[15] = r, n[16] = a, n[17] = c, n[18] = u, n[19] = d, n[20] = f, n[21] = p, n[22] = m) : m = n[22];
|
|
192
|
+
let h = m, _;
|
|
193
|
+
return n[23] !== i || n[24] !== h ? (_ = /* @__PURE__ */ g(le, {
|
|
194
|
+
value: h,
|
|
195
|
+
children: i
|
|
196
|
+
}), n[23] = i, n[24] = h, n[25] = _) : _ = n[25], _;
|
|
197
|
+
}
|
|
198
|
+
function Y() {
|
|
199
|
+
return o(le);
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/core/i18n.ts
|
|
203
|
+
function X() {
|
|
204
|
+
let t = e(2), { t: n } = Y(), r;
|
|
205
|
+
return t[0] === n ? r = t[1] : (r = (e, t) => {
|
|
206
|
+
let r = t === void 0 ? [] : t;
|
|
207
|
+
return n(e, e).replace(/\{(\d+)\}/g, (e, t) => Number(t) < r.length ? String(r[Number(t)]) : e);
|
|
208
|
+
}, t[0] = n, t[1] = r), r;
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/components/AutoForm/ChoiceField.tsx
|
|
212
|
+
function Z({ id: e, value: t, options: n, onChange: r, disabled: i, multiple: a }) {
|
|
213
|
+
let o = X(), [s, c] = p(!1), [l, u] = p(""), d = f(null), m = n.filter((e) => e.label.toLocaleLowerCase().includes(l.toLocaleLowerCase())), h = b({
|
|
214
|
+
count: m.length,
|
|
215
|
+
getScrollElement: () => d.current,
|
|
216
|
+
estimateSize: () => 36,
|
|
217
|
+
overscan: 4
|
|
218
|
+
}), v = (e) => a ? Array.isArray(t) && t.includes(e.value) : Object.is(t, e.value);
|
|
219
|
+
return /* @__PURE__ */ _("div", {
|
|
220
|
+
onKeyDown: (e) => {
|
|
221
|
+
e.key === "Escape" && c(!1);
|
|
222
|
+
},
|
|
223
|
+
children: [/* @__PURE__ */ _("button", {
|
|
224
|
+
id: e,
|
|
225
|
+
type: "button",
|
|
226
|
+
disabled: i,
|
|
227
|
+
"aria-haspopup": "listbox",
|
|
228
|
+
"aria-expanded": s,
|
|
229
|
+
onClick: () => c(!s),
|
|
230
|
+
children: [
|
|
231
|
+
n.filter(v).map((e) => e.label).join("、") || o("请选择"),
|
|
232
|
+
" ",
|
|
233
|
+
"▾"
|
|
234
|
+
]
|
|
235
|
+
}), s && /* @__PURE__ */ _("div", {
|
|
236
|
+
className: "auto-select-menu",
|
|
237
|
+
children: [
|
|
238
|
+
/* @__PURE__ */ g("input", {
|
|
239
|
+
"aria-label": o("搜索选项"),
|
|
240
|
+
value: l,
|
|
241
|
+
onChange: (e) => u(e.target.value)
|
|
242
|
+
}),
|
|
243
|
+
/* @__PURE__ */ g("div", {
|
|
244
|
+
ref: d,
|
|
245
|
+
role: "listbox",
|
|
246
|
+
"aria-label": o("选项"),
|
|
247
|
+
"aria-multiselectable": a,
|
|
248
|
+
style: {
|
|
249
|
+
height: 220,
|
|
250
|
+
overflow: "auto"
|
|
251
|
+
},
|
|
252
|
+
children: /* @__PURE__ */ g("div", {
|
|
253
|
+
style: {
|
|
254
|
+
height: h.getTotalSize(),
|
|
255
|
+
position: "relative"
|
|
256
|
+
},
|
|
257
|
+
children: h.getVirtualItems().map((e) => {
|
|
258
|
+
let n = m[e.index];
|
|
259
|
+
return /* @__PURE__ */ g("button", {
|
|
260
|
+
type: "button",
|
|
261
|
+
role: "option",
|
|
262
|
+
"aria-selected": v(n),
|
|
263
|
+
disabled: n.disabled,
|
|
264
|
+
style: {
|
|
265
|
+
position: "absolute",
|
|
266
|
+
top: 0,
|
|
267
|
+
transform: `translateY(${e.start}px)`,
|
|
268
|
+
height: e.size,
|
|
269
|
+
width: "100%"
|
|
270
|
+
},
|
|
271
|
+
onClick: () => {
|
|
272
|
+
r(a ? v(n) ? t.filter((e) => e !== n.value) : [...Array.isArray(t) ? t : [], n.value] : n.value), a || c(!1);
|
|
273
|
+
},
|
|
274
|
+
children: n.label
|
|
275
|
+
}, e.key);
|
|
276
|
+
})
|
|
277
|
+
})
|
|
278
|
+
}),
|
|
279
|
+
/* @__PURE__ */ g("button", {
|
|
280
|
+
type: "button",
|
|
281
|
+
onClick: () => c(!1),
|
|
282
|
+
children: o("完成")
|
|
283
|
+
})
|
|
284
|
+
]
|
|
285
|
+
})]
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
function de({ id: e, value: t, options: n, onChange: r, disabled: i }) {
|
|
289
|
+
let a = X(), o = Array.isArray(t) ? t : [], s = [], c = n;
|
|
290
|
+
for (let e = 0; c.length; e++) {
|
|
291
|
+
s.push(c);
|
|
292
|
+
let t = c.find((t) => Object.is(t.value, o[e]));
|
|
293
|
+
if (!t?.children) break;
|
|
294
|
+
c = t.children;
|
|
295
|
+
}
|
|
296
|
+
return /* @__PURE__ */ g("div", {
|
|
297
|
+
className: "auto-actions",
|
|
298
|
+
children: s.map((t, n) => /* @__PURE__ */ _("select", {
|
|
299
|
+
id: n === 0 ? e : void 0,
|
|
300
|
+
"aria-label": a("级联第 {0} 级", [n + 1]),
|
|
301
|
+
disabled: i,
|
|
302
|
+
value: t.findIndex((e) => Object.is(e.value, o[n])),
|
|
303
|
+
onChange: (e) => r([...o.slice(0, n), t[Number(e.target.value)].value]),
|
|
304
|
+
children: [/* @__PURE__ */ g("option", {
|
|
305
|
+
value: -1,
|
|
306
|
+
disabled: !0,
|
|
307
|
+
children: a("请选择")
|
|
308
|
+
}), t.map((e, t) => /* @__PURE__ */ g("option", {
|
|
309
|
+
value: t,
|
|
310
|
+
disabled: e.disabled,
|
|
311
|
+
children: e.label
|
|
312
|
+
}, t))]
|
|
313
|
+
}, n))
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/components/AutoForm/FormField.tsx
|
|
318
|
+
function fe({ field: e, context: t, readOnly: n, resetEpoch: r = 0, onUploadPending: a }) {
|
|
319
|
+
let o = X(), c = Y(), { id: l, value: u, values: d, onChange: m, disabled: v } = t, y = e.type ?? "input", b = H(e.options, d, []), [x, S] = p(!1), [C, w] = p(""), T = f(null), E = f(null);
|
|
320
|
+
if (s(() => (T.current?.abort(), S(!1), w(""), E.current && (E.current.value = ""), () => T.current?.abort()), [r, u]), s(() => (a?.(l, x), () => a?.(l, !1)), [
|
|
321
|
+
l,
|
|
322
|
+
x,
|
|
323
|
+
a
|
|
324
|
+
]), e.render) return e.render(t);
|
|
325
|
+
if (e.component && c.fields[e.component]) return c.fields[e.component](t);
|
|
326
|
+
if (n || y === "text") return /* @__PURE__ */ g("output", {
|
|
327
|
+
id: l,
|
|
328
|
+
children: b.find((e) => Object.is(e.value, u))?.label ?? (u == null ? "—" : Array.isArray(u) ? u.join("、") : String(u))
|
|
329
|
+
});
|
|
330
|
+
if (y === "title") return /* @__PURE__ */ g("h3", { children: e.label });
|
|
331
|
+
if (y === "tip") return /* @__PURE__ */ g("span", {
|
|
332
|
+
className: "auto-muted",
|
|
333
|
+
children: e.tip ?? e.label
|
|
334
|
+
});
|
|
335
|
+
if (y === "append") return e.tip ?? null;
|
|
336
|
+
if (y === "button") return /* @__PURE__ */ g("button", {
|
|
337
|
+
type: "button",
|
|
338
|
+
disabled: v,
|
|
339
|
+
onClick: () => e.onAction?.(d),
|
|
340
|
+
children: e.label
|
|
341
|
+
});
|
|
342
|
+
let D = {
|
|
343
|
+
id: l,
|
|
344
|
+
disabled: v,
|
|
345
|
+
"aria-invalid": !!t.error,
|
|
346
|
+
"aria-describedby": t.error ? `${l}-error` : void 0
|
|
347
|
+
};
|
|
348
|
+
if (y === "switch") return /* @__PURE__ */ g("input", {
|
|
349
|
+
...D,
|
|
350
|
+
type: "checkbox",
|
|
351
|
+
role: "switch",
|
|
352
|
+
checked: !!u,
|
|
353
|
+
onChange: (e) => m(e.target.checked)
|
|
354
|
+
});
|
|
355
|
+
if (y === "progress") return /* @__PURE__ */ g("progress", {
|
|
356
|
+
...D,
|
|
357
|
+
max: e.max ?? 100,
|
|
358
|
+
value: Number(u ?? 0)
|
|
359
|
+
});
|
|
360
|
+
if (y === "textarea") return /* @__PURE__ */ g("textarea", {
|
|
361
|
+
...D,
|
|
362
|
+
rows: e.rows ?? 3,
|
|
363
|
+
placeholder: e.placeholder,
|
|
364
|
+
value: String(u ?? ""),
|
|
365
|
+
onChange: (e) => m(e.target.value)
|
|
366
|
+
});
|
|
367
|
+
if (y === "select-v2") return /* @__PURE__ */ g(Z, {
|
|
368
|
+
...D,
|
|
369
|
+
value: u,
|
|
370
|
+
options: b,
|
|
371
|
+
onChange: m,
|
|
372
|
+
multiple: e.multiple
|
|
373
|
+
});
|
|
374
|
+
if (y === "cascader") return /* @__PURE__ */ g(de, {
|
|
375
|
+
...D,
|
|
376
|
+
value: u,
|
|
377
|
+
options: b,
|
|
378
|
+
onChange: m
|
|
379
|
+
});
|
|
380
|
+
if (y === "select") return /* @__PURE__ */ _("select", {
|
|
381
|
+
...D,
|
|
382
|
+
multiple: e.multiple,
|
|
383
|
+
value: e.multiple ? b.flatMap((e, t) => Array.isArray(u) && u.includes(e.value) ? [String(t)] : []) : String(b.findIndex((e) => Object.is(e.value, u))),
|
|
384
|
+
onChange: (t) => m(e.multiple ? Array.from(t.target.selectedOptions).map((e) => b[Number(e.value)].value) : b[Number(t.target.value)]?.value),
|
|
385
|
+
children: [!e.multiple && /* @__PURE__ */ g("option", {
|
|
386
|
+
value: "-1",
|
|
387
|
+
children: o("请选择")
|
|
388
|
+
}), b.map((e, t) => /* @__PURE__ */ g("option", {
|
|
389
|
+
value: t,
|
|
390
|
+
disabled: e.disabled,
|
|
391
|
+
children: e.label
|
|
392
|
+
}, t))]
|
|
393
|
+
});
|
|
394
|
+
if (y === "radio" || y === "checkbox") return /* @__PURE__ */ g("div", {
|
|
395
|
+
id: l,
|
|
396
|
+
role: "group",
|
|
397
|
+
"aria-label": e.label,
|
|
398
|
+
className: "auto-actions",
|
|
399
|
+
children: b.map((e, t) => /* @__PURE__ */ _("label", { children: [/* @__PURE__ */ g("input", {
|
|
400
|
+
type: y,
|
|
401
|
+
disabled: v || e.disabled,
|
|
402
|
+
name: l,
|
|
403
|
+
checked: y === "radio" ? Object.is(u, e.value) : Array.isArray(u) && u.includes(e.value),
|
|
404
|
+
onChange: (t) => m(y === "radio" ? e.value : t.target.checked ? [...Array.isArray(u) ? u : [], e.value] : (Array.isArray(u) ? u : []).filter((t) => t !== e.value))
|
|
405
|
+
}), e.label] }, t))
|
|
406
|
+
});
|
|
407
|
+
if (y === "upload") return /* @__PURE__ */ _("div", { children: [
|
|
408
|
+
/* @__PURE__ */ g("input", {
|
|
409
|
+
...D,
|
|
410
|
+
ref: E,
|
|
411
|
+
type: "file",
|
|
412
|
+
multiple: e.multiple,
|
|
413
|
+
accept: e.accept,
|
|
414
|
+
onChange: async (t) => {
|
|
415
|
+
let n = Array.from(t.target.files ?? []);
|
|
416
|
+
T.current?.abort();
|
|
417
|
+
let r = new AbortController();
|
|
418
|
+
T.current = r, S(!0), w("");
|
|
419
|
+
try {
|
|
420
|
+
let t = e.upload ? await e.upload(n, r.signal) : n;
|
|
421
|
+
r.signal.aborted || m(t);
|
|
422
|
+
} catch (e) {
|
|
423
|
+
r.signal.aborted || w(W(e));
|
|
424
|
+
} finally {
|
|
425
|
+
r.signal.aborted || S(!1);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}),
|
|
429
|
+
x && /* @__PURE__ */ g("span", {
|
|
430
|
+
role: "status",
|
|
431
|
+
children: o("上传中…")
|
|
432
|
+
}),
|
|
433
|
+
C && /* @__PURE__ */ g("span", {
|
|
434
|
+
role: "alert",
|
|
435
|
+
children: C
|
|
436
|
+
}),
|
|
437
|
+
u != null && /* @__PURE__ */ g("small", { children: Array.isArray(u) ? u.map((e) => e instanceof File ? e.name : String(e)).join("、") : String(u) })
|
|
438
|
+
] });
|
|
439
|
+
if (y === "date" || y === "datetime" || y === "daterange" || y === "datetimerange") {
|
|
440
|
+
let t = y.includes("time"), n = y.endsWith("range"), r = (n) => {
|
|
441
|
+
if (n == null || n === "") return "";
|
|
442
|
+
if (e.dateValue !== "timestamp") return String(n);
|
|
443
|
+
let r = new Date(Number(n));
|
|
444
|
+
if (Number.isNaN(r.getTime())) return "";
|
|
445
|
+
let i = (e) => String(e).padStart(2, "0");
|
|
446
|
+
return `${r.getFullYear()}-${i(r.getMonth() + 1)}-${i(r.getDate())}${t ? `T${i(r.getHours())}:${i(r.getMinutes())}` : ""}`;
|
|
447
|
+
}, a = (n) => n === "" ? null : e.dateValue === "timestamp" ? new Date(t ? n : `${n}T00:00:00`).getTime() : n;
|
|
448
|
+
return /* @__PURE__ */ _("div", {
|
|
449
|
+
className: "auto-actions",
|
|
450
|
+
children: [(n ? [0, 1] : [0]).map((s) => /* @__PURE__ */ i("input", {
|
|
451
|
+
...D,
|
|
452
|
+
id: s ? `${l}-end` : l,
|
|
453
|
+
key: s,
|
|
454
|
+
"aria-label": n ? `${e.label}${o(s ? "结束" : "开始")}` : void 0,
|
|
455
|
+
type: t ? "datetime-local" : "date",
|
|
456
|
+
value: r(n ? Array.isArray(u) ? u[s] : null : u),
|
|
457
|
+
onChange: (e) => {
|
|
458
|
+
if (!n) m(a(e.target.value));
|
|
459
|
+
else {
|
|
460
|
+
let t = Array.isArray(u) ? [...u] : [null, null];
|
|
461
|
+
t[s] = a(e.target.value), m(t);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
})), e.shortcuts?.map((e) => /* @__PURE__ */ g("button", {
|
|
465
|
+
type: "button",
|
|
466
|
+
disabled: v,
|
|
467
|
+
onClick: () => m(e.value()),
|
|
468
|
+
children: e.label
|
|
469
|
+
}, e.label))]
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("input", {
|
|
473
|
+
...D,
|
|
474
|
+
type: y === "integer" ? "number" : y === "email" ? "email" : "text",
|
|
475
|
+
inputMode: y === "float" || y === "percentage" ? "decimal" : void 0,
|
|
476
|
+
min: e.min,
|
|
477
|
+
max: e.max,
|
|
478
|
+
step: e.step ?? (y === "integer" ? 1 : void 0),
|
|
479
|
+
placeholder: e.placeholder,
|
|
480
|
+
value: String(u ?? ""),
|
|
481
|
+
list: y === "autocomplete" ? `${l}-options` : void 0,
|
|
482
|
+
onChange: (e) => {
|
|
483
|
+
let t = e.target.value;
|
|
484
|
+
m(y === "integer" ? t === "" ? void 0 : Number(t) : y === "float" || y === "percentage" ? t.replace(/[^\d.\-]/g, "").replace(/(?!^)-/g, "").replace(/(\..*)\./g, "$1") : t);
|
|
485
|
+
}
|
|
486
|
+
}), y === "autocomplete" && /* @__PURE__ */ g("datalist", {
|
|
487
|
+
id: `${l}-options`,
|
|
488
|
+
children: b.map((e, t) => /* @__PURE__ */ g("option", {
|
|
489
|
+
value: String(e.value),
|
|
490
|
+
children: e.label
|
|
491
|
+
}, t))
|
|
492
|
+
})] });
|
|
493
|
+
}
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/components/AutoForm/AutoForm.tsx
|
|
496
|
+
var pe = typeof window < "u" ? u : s;
|
|
497
|
+
function me({ fields: e, value: t, defaultValue: n, onChange: r, onSubmit: i, disabled: o = !1, readOnly: u = !1, columns: d = 2, labelPosition: m, labelAlign: h, labelWidth: b, density: x, size: S, actions: C = !0, submitLabel: w, resetLabel: T, extraActions: E, onReset: D, children: O, className: k = "", style: A, ref: j }) {
|
|
498
|
+
let M = X(), N = Y(), P = m ?? N.form.labelPosition ?? "top", F = h ?? N.form.labelAlign ?? (P === "left" ? "right" : "left"), I = b ?? N.form.labelWidth ?? "auto", L = I === "auto", [R, ee] = p(null), z = x ?? N.form.density ?? N.density ?? "comfortable", B = S ?? N.form.size ?? N.size ?? "medium", te = c(), ne = f(ae(e, t ?? n)), V = v({ defaultValues: ne.current }), re = y(V.store, (e) => e.values), [ie, oe] = p(0), [U, se] = p(() => /* @__PURE__ */ new Set()), K = a((e, t) => {
|
|
499
|
+
se((n) => {
|
|
500
|
+
if (n.has(e) === t) return n;
|
|
501
|
+
let r = new Set(n);
|
|
502
|
+
return t ? r.add(e) : r.delete(e), r;
|
|
503
|
+
});
|
|
504
|
+
}, []), [ce, q] = p({}), [J, le] = p(!1), [ue, Z] = p(""), de = f(0), me = f(0), he = f(!1), ge = f(null), Q = f(!0);
|
|
505
|
+
pe(() => {
|
|
506
|
+
if (!L || P !== "left" || !ge.current) return;
|
|
507
|
+
let e = ge.current;
|
|
508
|
+
if (e.parentElement?.matches(".auto-search[data-label-width=\"auto\"]")) return;
|
|
509
|
+
let t = () => {
|
|
510
|
+
let t = e.querySelectorAll(":scope > .auto-form-grid > .auto-field[data-field] > label");
|
|
511
|
+
if (!t.length) return;
|
|
512
|
+
let n = 0, r = Infinity;
|
|
513
|
+
if (t.forEach((t) => {
|
|
514
|
+
if (!t.getClientRects().length) return;
|
|
515
|
+
let i = e.ownerDocument.createRange();
|
|
516
|
+
if (typeof i.getBoundingClientRect != "function") return;
|
|
517
|
+
let a = t.style.whiteSpace;
|
|
518
|
+
try {
|
|
519
|
+
t.style.whiteSpace = "nowrap", i.selectNodeContents(t), n = Math.max(n, Math.ceil(i.getBoundingClientRect().width));
|
|
520
|
+
} finally {
|
|
521
|
+
t.style.whiteSpace = a;
|
|
522
|
+
}
|
|
523
|
+
r = Math.min(r, t.parentElement.getBoundingClientRect().width * .45);
|
|
524
|
+
}), n > 0 && r > 0) {
|
|
525
|
+
let e = Math.min(n, Math.floor(r));
|
|
526
|
+
ee((t) => t === e ? t : e);
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
if (t(), typeof ResizeObserver < "u") {
|
|
530
|
+
let n = new ResizeObserver(() => t());
|
|
531
|
+
return n.observe(e), () => n.disconnect();
|
|
532
|
+
}
|
|
533
|
+
}, [
|
|
534
|
+
L,
|
|
535
|
+
P,
|
|
536
|
+
e,
|
|
537
|
+
re,
|
|
538
|
+
B,
|
|
539
|
+
z,
|
|
540
|
+
d,
|
|
541
|
+
N.t,
|
|
542
|
+
N.canAccess
|
|
543
|
+
]), s(() => (Q.current = !0, () => {
|
|
544
|
+
Q.current = !1, me.current++;
|
|
545
|
+
}), []), s(() => {
|
|
546
|
+
t !== void 0 && !G(t, V.state.values) && (de.current++, oe((e) => e + 1), V.reset(t, { keepDefaultValues: !0 }), q({}));
|
|
547
|
+
}, [
|
|
548
|
+
t,
|
|
549
|
+
re,
|
|
550
|
+
V
|
|
551
|
+
]);
|
|
552
|
+
function _e(t, n) {
|
|
553
|
+
if (o || u) return;
|
|
554
|
+
de.current++;
|
|
555
|
+
let i = e.find((e) => e.name === t), a = {
|
|
556
|
+
...V.state.values,
|
|
557
|
+
[t]: n
|
|
558
|
+
}, s = i?.onChange?.(n, a);
|
|
559
|
+
s && (a = {
|
|
560
|
+
...a,
|
|
561
|
+
...s
|
|
562
|
+
});
|
|
563
|
+
for (let [e, t] of Object.entries(a)) V.setFieldValue(e, t);
|
|
564
|
+
q((e) => {
|
|
565
|
+
let n = { ...e };
|
|
566
|
+
return delete n[t], n;
|
|
567
|
+
}), r?.(a);
|
|
568
|
+
}
|
|
569
|
+
async function ve() {
|
|
570
|
+
if (U.size) return Z(M("请等待附件上传完成")), !1;
|
|
571
|
+
let t = ++me.current, n = de.current, r = { ...V.state.values }, i = {};
|
|
572
|
+
return await Promise.all(e.map(async (e) => {
|
|
573
|
+
if (!e.name || H(e.hidden, r, !1) || !N.canAccess(e) || H(e.disabled, r, !1)) return;
|
|
574
|
+
let t = r[e.name];
|
|
575
|
+
if (e.required && (t == null || t === "" || Array.isArray(t) && !t.length)) i[e.name] = M("{0}为必填项", [e.label ?? e.name]);
|
|
576
|
+
else for (let n of e.rules ?? []) try {
|
|
577
|
+
let a = await n(t, r);
|
|
578
|
+
if (a) {
|
|
579
|
+
i[e.name] = a;
|
|
580
|
+
break;
|
|
581
|
+
}
|
|
582
|
+
} catch (t) {
|
|
583
|
+
i[e.name] = W(t);
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
})), !Q.current || t !== me.current || n !== de.current ? !1 : (q(i), Object.keys(i).length === 0);
|
|
587
|
+
}
|
|
588
|
+
function ye(t) {
|
|
589
|
+
de.current++, oe((e) => e + 1), me.current++;
|
|
590
|
+
let i = t ?? ae(e, n);
|
|
591
|
+
V.reset(i, { keepDefaultValues: !0 }), q({}), Z(""), r?.(i), D?.();
|
|
592
|
+
}
|
|
593
|
+
l(j, () => ({
|
|
594
|
+
validate: ve,
|
|
595
|
+
reset: ye,
|
|
596
|
+
getValues: () => ({ ...V.state.values }),
|
|
597
|
+
setValue: _e,
|
|
598
|
+
focus(e) {
|
|
599
|
+
ge.current?.querySelector(`[data-field="${CSS.escape(e)}"] input, [data-field="${CSS.escape(e)}"] select`)?.focus();
|
|
600
|
+
}
|
|
601
|
+
}));
|
|
602
|
+
async function be() {
|
|
603
|
+
if (!(he.current || o || u)) {
|
|
604
|
+
he.current = !0, le(!0), Z("");
|
|
605
|
+
try {
|
|
606
|
+
await ve() && await i?.({ ...V.state.values });
|
|
607
|
+
} catch (e) {
|
|
608
|
+
Q.current && Z(W(e));
|
|
609
|
+
} finally {
|
|
610
|
+
he.current = !1, Q.current && le(!1);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return /* @__PURE__ */ _("form", {
|
|
615
|
+
ref: ge,
|
|
616
|
+
className: `auto-root auto-form ${k}`,
|
|
617
|
+
"data-label-position": P,
|
|
618
|
+
"data-label-align": F,
|
|
619
|
+
"data-label-width": L ? "auto" : typeof I == "number" ? `${I}px` : I,
|
|
620
|
+
"data-density": z,
|
|
621
|
+
"data-size": B,
|
|
622
|
+
style: {
|
|
623
|
+
"--auto-label-width": L ? R ? `${R}px` : "96px" : typeof I == "number" ? `${I}px` : I,
|
|
624
|
+
...A
|
|
625
|
+
},
|
|
626
|
+
noValidate: !0,
|
|
627
|
+
onSubmit: (e) => {
|
|
628
|
+
e.preventDefault(), be();
|
|
629
|
+
},
|
|
630
|
+
children: [
|
|
631
|
+
/* @__PURE__ */ g("div", {
|
|
632
|
+
className: "auto-form-grid",
|
|
633
|
+
style: { "--auto-columns": d },
|
|
634
|
+
children: e.map((e, t) => {
|
|
635
|
+
if (H(e.hidden, re, !1) || !N.canAccess(e)) return null;
|
|
636
|
+
let n = e.name, r = `${te}-${n ?? t}`, i = e.lang ? N.t(e.lang, e.label) : e.label ?? n, a = !n;
|
|
637
|
+
return /* @__PURE__ */ _("div", {
|
|
638
|
+
"data-field": n,
|
|
639
|
+
className: `auto-field ${e.className ?? ""}`,
|
|
640
|
+
style: {
|
|
641
|
+
gridColumn: e.lineBreak ? "1 / -1" : `span ${Math.min(e.span ?? 1, d)}`,
|
|
642
|
+
...e.style
|
|
643
|
+
},
|
|
644
|
+
children: [!a && /* @__PURE__ */ _("label", {
|
|
645
|
+
htmlFor: r,
|
|
646
|
+
children: [i, e.required && /* @__PURE__ */ g("span", {
|
|
647
|
+
"aria-hidden": "true",
|
|
648
|
+
children: " *"
|
|
649
|
+
})]
|
|
650
|
+
}), /* @__PURE__ */ _("div", {
|
|
651
|
+
className: "auto-field-control",
|
|
652
|
+
children: [
|
|
653
|
+
/* @__PURE__ */ g(fe, {
|
|
654
|
+
resetEpoch: ie,
|
|
655
|
+
onUploadPending: K,
|
|
656
|
+
field: e,
|
|
657
|
+
context: {
|
|
658
|
+
id: r,
|
|
659
|
+
value: n ? re[n] : void 0,
|
|
660
|
+
values: re,
|
|
661
|
+
onChange: (e) => n && _e(n, e),
|
|
662
|
+
disabled: o || J || H(e.disabled, re, !1),
|
|
663
|
+
error: n ? ce[n] : void 0
|
|
664
|
+
},
|
|
665
|
+
readOnly: u
|
|
666
|
+
}),
|
|
667
|
+
n && ce[n] && /* @__PURE__ */ g("span", {
|
|
668
|
+
className: "auto-error",
|
|
669
|
+
id: `${r}-error`,
|
|
670
|
+
role: "alert",
|
|
671
|
+
children: ce[n]
|
|
672
|
+
}),
|
|
673
|
+
e.tip && !a && /* @__PURE__ */ g("small", {
|
|
674
|
+
className: "auto-muted",
|
|
675
|
+
children: e.tip
|
|
676
|
+
})
|
|
677
|
+
]
|
|
678
|
+
})]
|
|
679
|
+
}, n ?? t);
|
|
680
|
+
})
|
|
681
|
+
}),
|
|
682
|
+
O,
|
|
683
|
+
ue && /* @__PURE__ */ g("p", {
|
|
684
|
+
role: "alert",
|
|
685
|
+
className: "auto-error",
|
|
686
|
+
children: ue
|
|
687
|
+
}),
|
|
688
|
+
C && !u && /* @__PURE__ */ _("div", {
|
|
689
|
+
className: "auto-actions auto-form-actions",
|
|
690
|
+
children: [
|
|
691
|
+
/* @__PURE__ */ g("button", {
|
|
692
|
+
className: "auto-primary",
|
|
693
|
+
type: "submit",
|
|
694
|
+
disabled: o || J || U.size > 0,
|
|
695
|
+
children: J ? M("提交中…") : w ?? M("提交")
|
|
696
|
+
}),
|
|
697
|
+
/* @__PURE__ */ g("button", {
|
|
698
|
+
type: "button",
|
|
699
|
+
disabled: o || J,
|
|
700
|
+
onClick: () => ye(),
|
|
701
|
+
children: T ?? M("重置")
|
|
702
|
+
}),
|
|
703
|
+
E
|
|
704
|
+
]
|
|
705
|
+
})
|
|
706
|
+
]
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
//#endregion
|
|
710
|
+
//#region src/components/AutoSearchPanel/index.tsx
|
|
711
|
+
function he({ fields: e, value: t, defaultValue: n, onChange: r, onSearch: i, mode: a = "manual", columns: o = 3, labelPosition: s, labelAlign: c, labelWidth: l, density: u, size: d, disabled: m, searchLabel: h, resetLabel: v, extraActions: y, sortTags: b }) {
|
|
712
|
+
let x = X(), S = Y(), C = u ?? S.form.density ?? S.density ?? "comfortable", w = d ?? S.form.size ?? S.size ?? "medium", T = l ?? S.form.labelWidth ?? "auto", E = T === "auto", [D, O] = p(() => ae(e, n)), [k, A] = p(!1), j = t ?? D, M = f(null), N = (t) => i(K(t, e.filter((e) => !H(e.hidden, t, !1))), t);
|
|
713
|
+
return /* @__PURE__ */ g("section", {
|
|
714
|
+
className: "auto-root auto-search",
|
|
715
|
+
"data-density": C,
|
|
716
|
+
"data-size": w,
|
|
717
|
+
"data-label-width": E ? "auto" : typeof T == "number" ? `${T}px` : T,
|
|
718
|
+
children: /* @__PURE__ */ g(me, {
|
|
719
|
+
ref: M,
|
|
720
|
+
fields: e.map((e) => ({
|
|
721
|
+
...e,
|
|
722
|
+
hidden: (t) => H(e.hidden, t, !1) || !!e.more && !k
|
|
723
|
+
})),
|
|
724
|
+
value: j,
|
|
725
|
+
onChange: (e) => {
|
|
726
|
+
O(e), r?.(e), a === "instant" && N(e);
|
|
727
|
+
},
|
|
728
|
+
onSubmit: N,
|
|
729
|
+
columns: o,
|
|
730
|
+
labelPosition: s,
|
|
731
|
+
labelAlign: c,
|
|
732
|
+
labelWidth: T,
|
|
733
|
+
density: C,
|
|
734
|
+
size: w,
|
|
735
|
+
disabled: m,
|
|
736
|
+
actions: !1,
|
|
737
|
+
children: /* @__PURE__ */ _("div", {
|
|
738
|
+
className: "auto-actions auto-form-actions",
|
|
739
|
+
children: [
|
|
740
|
+
/* @__PURE__ */ g("button", {
|
|
741
|
+
type: "submit",
|
|
742
|
+
className: "auto-primary",
|
|
743
|
+
disabled: m,
|
|
744
|
+
children: h ?? x("搜索")
|
|
745
|
+
}),
|
|
746
|
+
/* @__PURE__ */ g("button", {
|
|
747
|
+
type: "button",
|
|
748
|
+
disabled: m,
|
|
749
|
+
onClick: () => {
|
|
750
|
+
let t = ae(e, n);
|
|
751
|
+
O(t), r?.(t), N(t);
|
|
752
|
+
},
|
|
753
|
+
children: v ?? x("重置")
|
|
754
|
+
}),
|
|
755
|
+
y,
|
|
756
|
+
e.some((e) => e.more) && /* @__PURE__ */ g("button", {
|
|
757
|
+
type: "button",
|
|
758
|
+
"aria-expanded": k,
|
|
759
|
+
onClick: () => A(!k),
|
|
760
|
+
children: x(k ? "收起条件" : "更多条件")
|
|
761
|
+
}),
|
|
762
|
+
b?.map((e) => /* @__PURE__ */ _("button", {
|
|
763
|
+
type: "button",
|
|
764
|
+
onClick: e.onRemove,
|
|
765
|
+
children: [e.label, " ×"]
|
|
766
|
+
}, e.id))
|
|
767
|
+
]
|
|
768
|
+
})
|
|
769
|
+
})
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
//#endregion
|
|
773
|
+
//#region src/components/AutoDialog/index.tsx
|
|
774
|
+
var ge = r(null);
|
|
775
|
+
function Q() {
|
|
776
|
+
let e = [], t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
|
|
777
|
+
return {
|
|
778
|
+
get: () => e,
|
|
779
|
+
subscribe: (e) => (t.add(e), () => {
|
|
780
|
+
t.delete(e);
|
|
781
|
+
}),
|
|
782
|
+
add(n) {
|
|
783
|
+
e = [...e, n], t.forEach((e) => e());
|
|
784
|
+
},
|
|
785
|
+
remove(r) {
|
|
786
|
+
e = e.filter((e) => e.id !== r), n.delete(r), t.forEach((e) => e());
|
|
787
|
+
},
|
|
788
|
+
closers: n
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
function _e(t) {
|
|
792
|
+
let n = e(11), { children: r } = t, [i] = p(Q), a = m(i.subscribe, i.get, i.get), o;
|
|
793
|
+
n[0] === i ? o = n[1] : (o = () => ({
|
|
794
|
+
open(e) {
|
|
795
|
+
let t = crypto.randomUUID();
|
|
796
|
+
return i.add({
|
|
797
|
+
id: t,
|
|
798
|
+
render: (n, r) => /* @__PURE__ */ g(be, {
|
|
799
|
+
options: e,
|
|
800
|
+
remove: n,
|
|
801
|
+
register: r
|
|
802
|
+
}, t)
|
|
803
|
+
}), {
|
|
804
|
+
id: t,
|
|
805
|
+
close: async () => {
|
|
806
|
+
let e = i.closers.get(t);
|
|
807
|
+
return e ? e() : (i.remove(t), !0);
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
},
|
|
811
|
+
async close(e) {
|
|
812
|
+
let t = i.closers.get(e);
|
|
813
|
+
return t ? t() : (i.remove(e), !0);
|
|
814
|
+
}
|
|
815
|
+
}), n[0] = i, n[1] = o);
|
|
816
|
+
let [s] = p(o), c;
|
|
817
|
+
if (n[2] !== a || n[3] !== i) {
|
|
818
|
+
let e;
|
|
819
|
+
n[5] === i ? e = n[6] : (e = (e) => e.render(() => i.remove(e.id), (t) => i.closers.set(e.id, t)), n[5] = i, n[6] = e), c = a.map(e), n[2] = a, n[3] = i, n[4] = c;
|
|
820
|
+
} else c = n[4];
|
|
821
|
+
let l;
|
|
822
|
+
return n[7] !== r || n[8] !== s || n[9] !== c ? (l = /* @__PURE__ */ _(ge, {
|
|
823
|
+
value: s,
|
|
824
|
+
children: [r, c]
|
|
825
|
+
}), n[7] = r, n[8] = s, n[9] = c, n[10] = l) : l = n[10], l;
|
|
826
|
+
}
|
|
827
|
+
function ve() {
|
|
828
|
+
let e = o(ge);
|
|
829
|
+
if (!e) throw Error("AutoDialogProvider is required");
|
|
830
|
+
return e;
|
|
831
|
+
}
|
|
832
|
+
function ye(t) {
|
|
833
|
+
let n = e(2), r;
|
|
834
|
+
if (n[0] !== t) {
|
|
835
|
+
let { open: e, onOpenChange: i, ...a } = t;
|
|
836
|
+
r = e ? /* @__PURE__ */ g(be, {
|
|
837
|
+
options: a,
|
|
838
|
+
remove: () => i(!1)
|
|
839
|
+
}) : null, n[0] = t, n[1] = r;
|
|
840
|
+
} else r = n[1];
|
|
841
|
+
return r;
|
|
842
|
+
}
|
|
843
|
+
function be({ options: e, remove: t, register: n }) {
|
|
844
|
+
let r = X(), i = Y(), a = e.size ?? i.size ?? "medium", o = e.draftKey ? `${i.namespace}:draft:${e.draftKey}` : void 0, [c, l] = p(() => ae(e.fields ?? [], (o ? i.storage.get(o) : void 0) ?? e.defaultValue)), u = f(c);
|
|
845
|
+
u.current = c;
|
|
846
|
+
let d = f(null), [m, v] = p(!1), [y, b] = p(""), [S, C] = p(e.fullscreen ?? !1), [w, T] = p({
|
|
847
|
+
x: 0,
|
|
848
|
+
y: 0
|
|
849
|
+
}), E = f(!1), D = f(typeof document > "u" ? null : document.activeElement);
|
|
850
|
+
async function O(n) {
|
|
851
|
+
if (E.current) return !1;
|
|
852
|
+
E.current = !0, v(!0);
|
|
853
|
+
try {
|
|
854
|
+
return e.beforeClose && !await e.beforeClose(n) ? !1 : (o && (n === "submit" ? i.storage.remove(o) : i.storage.set(o, u.current)), t(n), e.onClose?.(n), !0);
|
|
855
|
+
} catch (e) {
|
|
856
|
+
return b(W(e)), !1;
|
|
857
|
+
} finally {
|
|
858
|
+
E.current = !1, v(!1);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
s(() => {
|
|
862
|
+
n?.(() => O("close"));
|
|
863
|
+
});
|
|
864
|
+
async function k() {
|
|
865
|
+
if (!E.current) {
|
|
866
|
+
E.current = !0, v(!0), b("");
|
|
867
|
+
try {
|
|
868
|
+
if (d.current && !await d.current.validate()) return;
|
|
869
|
+
await e.onSubmit?.(d.current?.getValues() ?? u.current), E.current = !1, await O("submit");
|
|
870
|
+
} catch (e) {
|
|
871
|
+
b(W(e));
|
|
872
|
+
} finally {
|
|
873
|
+
E.current = !1, v(!1);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
return /* @__PURE__ */ g(x.Root, {
|
|
878
|
+
open: !0,
|
|
879
|
+
onOpenChange: (e) => {
|
|
880
|
+
e || O("close");
|
|
881
|
+
},
|
|
882
|
+
children: /* @__PURE__ */ _(x.Portal, { children: [/* @__PURE__ */ g(x.Overlay, { className: "auto-overlay-backdrop" }), /* @__PURE__ */ _(x.Content, {
|
|
883
|
+
"aria-describedby": (e.description, void 0),
|
|
884
|
+
className: `auto-root auto-overlay ${S ? "auto-dialog-full" : ""}`,
|
|
885
|
+
"data-size": a,
|
|
886
|
+
style: {
|
|
887
|
+
width: S ? void 0 : e.width ?? 560,
|
|
888
|
+
transform: S ? void 0 : `translate(calc(-50% + ${w.x}px),calc(-50% + ${w.y}px))`
|
|
889
|
+
},
|
|
890
|
+
onCloseAutoFocus: (e) => {
|
|
891
|
+
e.preventDefault(), D.current?.focus();
|
|
892
|
+
},
|
|
893
|
+
children: [
|
|
894
|
+
/* @__PURE__ */ _("header", {
|
|
895
|
+
className: "auto-dialog-header",
|
|
896
|
+
onPointerDown: (t) => {
|
|
897
|
+
if (!e.draggable || S || t.target.closest("button")) return;
|
|
898
|
+
let n = t.currentTarget;
|
|
899
|
+
n.setPointerCapture(t.pointerId);
|
|
900
|
+
let r = {
|
|
901
|
+
x: t.clientX,
|
|
902
|
+
y: t.clientY
|
|
903
|
+
}, i = (e) => T({
|
|
904
|
+
x: Math.max(-innerWidth / 3, Math.min(innerWidth / 3, w.x + e.clientX - r.x)),
|
|
905
|
+
y: Math.max(-innerHeight / 3, Math.min(innerHeight / 3, w.y + e.clientY - r.y))
|
|
906
|
+
}), a = () => {
|
|
907
|
+
n.removeEventListener("pointermove", i), n.removeEventListener("pointerup", a), n.removeEventListener("pointercancel", a);
|
|
908
|
+
};
|
|
909
|
+
n.addEventListener("pointermove", i), n.addEventListener("pointerup", a), n.addEventListener("pointercancel", a);
|
|
910
|
+
},
|
|
911
|
+
children: [/* @__PURE__ */ g(x.Title, { children: e.header ?? e.title }), /* @__PURE__ */ _("div", {
|
|
912
|
+
className: "auto-actions",
|
|
913
|
+
children: [/* @__PURE__ */ g("button", {
|
|
914
|
+
type: "button",
|
|
915
|
+
"aria-label": r("切换全屏"),
|
|
916
|
+
onClick: () => C(!S),
|
|
917
|
+
children: "⛶"
|
|
918
|
+
}), /* @__PURE__ */ g("button", {
|
|
919
|
+
type: "button",
|
|
920
|
+
"aria-label": r("关闭弹窗"),
|
|
921
|
+
disabled: m,
|
|
922
|
+
onClick: () => void O("close"),
|
|
923
|
+
children: "×"
|
|
924
|
+
})]
|
|
925
|
+
})]
|
|
926
|
+
}),
|
|
927
|
+
e.description && /* @__PURE__ */ g(x.Description, { children: e.description }),
|
|
928
|
+
/* @__PURE__ */ _("div", {
|
|
929
|
+
className: "auto-dialog-body",
|
|
930
|
+
children: [e.fields ? /* @__PURE__ */ g(me, {
|
|
931
|
+
ref: d,
|
|
932
|
+
fields: e.fields,
|
|
933
|
+
value: c,
|
|
934
|
+
defaultValue: e.defaultValue,
|
|
935
|
+
onChange: l,
|
|
936
|
+
onSubmit: () => k(),
|
|
937
|
+
actions: !1,
|
|
938
|
+
disabled: m,
|
|
939
|
+
size: a
|
|
940
|
+
}) : e.content, y && /* @__PURE__ */ g("p", {
|
|
941
|
+
role: "alert",
|
|
942
|
+
className: "auto-error",
|
|
943
|
+
children: y
|
|
944
|
+
})]
|
|
945
|
+
}),
|
|
946
|
+
!e.hideFooter && /* @__PURE__ */ g("footer", {
|
|
947
|
+
className: "auto-actions auto-dialog-footer",
|
|
948
|
+
children: e.footer ? e.footer({
|
|
949
|
+
submit: () => void k(),
|
|
950
|
+
cancel: () => void O("cancel"),
|
|
951
|
+
busy: m
|
|
952
|
+
}) : /* @__PURE__ */ _(h, { children: [
|
|
953
|
+
e.showReset && /* @__PURE__ */ g("button", {
|
|
954
|
+
type: "button",
|
|
955
|
+
disabled: m,
|
|
956
|
+
onClick: () => d.current?.reset(),
|
|
957
|
+
children: r("重置")
|
|
958
|
+
}),
|
|
959
|
+
e.extraActions,
|
|
960
|
+
/* @__PURE__ */ g("button", {
|
|
961
|
+
type: "button",
|
|
962
|
+
disabled: m,
|
|
963
|
+
onClick: () => void O("cancel"),
|
|
964
|
+
children: e.cancelLabel ?? r("取消")
|
|
965
|
+
}),
|
|
966
|
+
/* @__PURE__ */ g("button", {
|
|
967
|
+
type: "button",
|
|
968
|
+
className: "auto-primary",
|
|
969
|
+
disabled: m,
|
|
970
|
+
onClick: () => void k(),
|
|
971
|
+
children: m ? r("处理中…") : e.confirmLabel ?? r("确定")
|
|
972
|
+
})
|
|
973
|
+
] })
|
|
974
|
+
})
|
|
975
|
+
]
|
|
976
|
+
})] })
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
//#endregion
|
|
980
|
+
//#region src/components/AutoTabs/index.tsx
|
|
981
|
+
function xe({ items: e, value: t, defaultValue: n, onChange: r, mode: i = "horizontal", keepMounted: a = !0, extra: o, size: s, density: c }) {
|
|
982
|
+
let l = X(), u = Y(), d = c ?? u.tabs?.density ?? u.density ?? "comfortable", f = s ?? u.tabs?.size ?? u.size ?? "medium", m = e.filter((e) => !(typeof e.hidden == "function" ? e.hidden() : e.hidden) && u.canAccess(e)), [h, v] = p(n ?? []), y = t ?? h, b = (m.find((e) => e.id === y[0] && !e.disabled) ?? m.find((e) => !e.disabled))?.id ?? "";
|
|
983
|
+
function x(e, n) {
|
|
984
|
+
t === void 0 && v(e), r?.(e, n);
|
|
985
|
+
}
|
|
986
|
+
return /* @__PURE__ */ _(S.Root, {
|
|
987
|
+
className: `auto-root auto-tabs auto-tabs-${i}`,
|
|
988
|
+
"data-size": f,
|
|
989
|
+
"data-density": d,
|
|
990
|
+
value: b,
|
|
991
|
+
onValueChange: (e) => {
|
|
992
|
+
let t = m.find((t) => t.id === e);
|
|
993
|
+
x([e], t);
|
|
994
|
+
},
|
|
995
|
+
orientation: i === "horizontal" ? "horizontal" : "vertical",
|
|
996
|
+
children: [/* @__PURE__ */ _("div", {
|
|
997
|
+
className: "auto-tabs-heading",
|
|
998
|
+
children: [/* @__PURE__ */ g(S.List, {
|
|
999
|
+
"aria-label": l("页面标签"),
|
|
1000
|
+
className: "auto-tab-list",
|
|
1001
|
+
children: m.map((e) => /* @__PURE__ */ _(S.Trigger, {
|
|
1002
|
+
value: e.id,
|
|
1003
|
+
disabled: e.disabled,
|
|
1004
|
+
children: [
|
|
1005
|
+
e.icon,
|
|
1006
|
+
e.label,
|
|
1007
|
+
e.badge != null && /* @__PURE__ */ g("span", {
|
|
1008
|
+
className: "auto-tab-badge",
|
|
1009
|
+
children: e.badge
|
|
1010
|
+
}),
|
|
1011
|
+
e.loading ? " …" : ""
|
|
1012
|
+
]
|
|
1013
|
+
}, e.id))
|
|
1014
|
+
}), o]
|
|
1015
|
+
}), m.map((e) => /* @__PURE__ */ _(S.Content, {
|
|
1016
|
+
value: e.id,
|
|
1017
|
+
forceMount: a ? !0 : void 0,
|
|
1018
|
+
hidden: e.id !== b,
|
|
1019
|
+
className: "auto-tab-content",
|
|
1020
|
+
children: [e.onRefresh && /* @__PURE__ */ g("button", {
|
|
1021
|
+
onClick: e.onRefresh,
|
|
1022
|
+
children: l("刷新 {0}", [e.label])
|
|
1023
|
+
}), e.children ? /* @__PURE__ */ g(xe, {
|
|
1024
|
+
items: e.children,
|
|
1025
|
+
value: e.id === b && y.length > 1 ? y.slice(1) : void 0,
|
|
1026
|
+
defaultValue: e.defaultActive ? [e.defaultActive] : void 0,
|
|
1027
|
+
keepMounted: a,
|
|
1028
|
+
size: f,
|
|
1029
|
+
density: d,
|
|
1030
|
+
onChange: (t, n) => x([e.id, ...t], n)
|
|
1031
|
+
}) : e.content]
|
|
1032
|
+
}, e.id))]
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
//#endregion
|
|
1036
|
+
//#region src/internal/Popover.tsx
|
|
1037
|
+
function Se({ children: e, content: t, placement: r = "bottom", open: i, onOpenChange: a }) {
|
|
1038
|
+
let o = Y(), [s, c] = p(!1), l = !!e.props.disabled, u = !l && (i ?? s), { refs: d, floatingStyles: f, context: m } = M({
|
|
1039
|
+
open: u,
|
|
1040
|
+
onOpenChange: (e) => {
|
|
1041
|
+
l && e || (i === void 0 && c(e), a?.(e));
|
|
1042
|
+
},
|
|
1043
|
+
placement: r,
|
|
1044
|
+
middleware: [
|
|
1045
|
+
D(8),
|
|
1046
|
+
E({ padding: 8 }),
|
|
1047
|
+
O({ padding: 8 }),
|
|
1048
|
+
k({
|
|
1049
|
+
padding: 8,
|
|
1050
|
+
apply({ availableWidth: e, availableHeight: t, elements: n }) {
|
|
1051
|
+
n.floating.style.setProperty("--auto-popover-available-width", `${Math.max(0, e)}px`), n.floating.style.setProperty("--auto-popover-available-height", `${Math.max(0, t)}px`);
|
|
1052
|
+
}
|
|
1053
|
+
})
|
|
1054
|
+
],
|
|
1055
|
+
whileElementsMounted: T
|
|
1056
|
+
}), v = N([
|
|
1057
|
+
A(m, { enabled: !l }),
|
|
1058
|
+
j(m),
|
|
1059
|
+
F(m)
|
|
1060
|
+
]), y = P([d.setReference, e.props.ref]);
|
|
1061
|
+
return /* @__PURE__ */ _(h, { children: [n(e, {
|
|
1062
|
+
...v.getReferenceProps(e.props),
|
|
1063
|
+
ref: y
|
|
1064
|
+
}), u && /* @__PURE__ */ g(w, { children: /* @__PURE__ */ g(C, {
|
|
1065
|
+
context: m,
|
|
1066
|
+
modal: !1,
|
|
1067
|
+
returnFocus: !0,
|
|
1068
|
+
children: /* @__PURE__ */ g("div", {
|
|
1069
|
+
ref: d.setFloating,
|
|
1070
|
+
className: "auto-root auto-popover",
|
|
1071
|
+
"data-size": o.size,
|
|
1072
|
+
"data-density": o.density,
|
|
1073
|
+
style: f,
|
|
1074
|
+
...v.getFloatingProps({ "aria-label": e.props["aria-label"] ?? o.t("popover.label", "Popover") }),
|
|
1075
|
+
children: /* @__PURE__ */ g("div", {
|
|
1076
|
+
className: "auto-popover-body",
|
|
1077
|
+
children: t
|
|
1078
|
+
})
|
|
1079
|
+
})
|
|
1080
|
+
}) })] });
|
|
1081
|
+
}
|
|
1082
|
+
//#endregion
|
|
1083
|
+
//#region src/components/AutoMenu/index.tsx
|
|
1084
|
+
function Ce(e, t) {
|
|
1085
|
+
for (let n of e) {
|
|
1086
|
+
if (n.disabled) continue;
|
|
1087
|
+
if (n.id === t && !n.children?.length) return [n];
|
|
1088
|
+
let e = n.children && Ce(n.children, t);
|
|
1089
|
+
if (e) return [n, ...e];
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
function we(e) {
|
|
1093
|
+
for (let t of e) {
|
|
1094
|
+
if (t.disabled) continue;
|
|
1095
|
+
if (!t.children?.length) return [t];
|
|
1096
|
+
let e = we(t.children);
|
|
1097
|
+
if (e.length) return [t, ...e];
|
|
1098
|
+
}
|
|
1099
|
+
return [];
|
|
1100
|
+
}
|
|
1101
|
+
function Te(e) {
|
|
1102
|
+
let t = e.target;
|
|
1103
|
+
if (!(t instanceof HTMLButtonElement) || !t.hasAttribute("data-auto-menu-item")) return;
|
|
1104
|
+
let n = [...e.currentTarget.querySelectorAll("button[data-auto-menu-item]:not(:disabled)")], r = n.indexOf(t);
|
|
1105
|
+
if (r < 0) return;
|
|
1106
|
+
let i;
|
|
1107
|
+
e.key === "ArrowDown" ? i = n[(r + 1) % n.length] : e.key === "ArrowUp" ? i = n[(r - 1 + n.length) % n.length] : e.key === "Home" ? i = n[0] : e.key === "End" ? i = n.at(-1) : e.key === "ArrowRight" && t.hasAttribute("aria-expanded") ? (t.getAttribute("aria-expanded") === "false" ? t.click() : i = t.nextElementSibling?.querySelector("button:not(:disabled)") ?? void 0, e.preventDefault()) : e.key === "ArrowLeft" && (t.getAttribute("aria-expanded") === "true" ? (t.click(), e.preventDefault()) : i = t.closest("li")?.parentElement?.closest("li")?.querySelector("button") ?? void 0), i && (e.preventDefault(), i.focus());
|
|
1108
|
+
}
|
|
1109
|
+
function Ee(t) {
|
|
1110
|
+
let n = e(34), { item: r, ...i } = t, a = c(), [o, l] = p(!1), { collapsed: u, currentId: d, expanded: f, selectedIds: m, path: h, depth: v, onToggle: y, onSelect: b, size: x, density: S } = i, C = !!r.children?.length, w;
|
|
1111
|
+
n[0] === l ? w = n[1] : (w = () => l(!1), n[0] = l, n[1] = w), s(w, [u, r.disabled]);
|
|
1112
|
+
let T = f.get(r.id) ?? m.has(r.id), E = r.id === d, D = [...h, r], O = E ? "active" : void 0, k = C && m.has(r.id) ? "true" : void 0, A = E ? "page" : void 0, j = C ? u ? o && !r.disabled : T : void 0, M = C ? u ? `${a}-flyout` : T ? a : void 0 : void 0, N = u ? r.label : void 0, P = () => {
|
|
1113
|
+
C ? u || y(r.id) : b(r, D);
|
|
1114
|
+
}, F;
|
|
1115
|
+
n[2] !== u || n[3] !== r.icon || n[4] !== r.label ? (F = (r.icon != null || u) && /* @__PURE__ */ g("span", {
|
|
1116
|
+
className: "auto-menu-icon",
|
|
1117
|
+
"aria-hidden": "true",
|
|
1118
|
+
children: r.icon ?? Array.from(r.label.trim())[0] ?? "•"
|
|
1119
|
+
}), n[2] = u, n[3] = r.icon, n[4] = r.label, n[5] = F) : F = n[5];
|
|
1120
|
+
let I;
|
|
1121
|
+
n[6] !== u || n[7] !== r.description || n[8] !== r.label ? (I = !u && /* @__PURE__ */ _("span", {
|
|
1122
|
+
className: "auto-menu-text",
|
|
1123
|
+
children: [r.label, r.description != null && /* @__PURE__ */ g("small", { children: r.description })]
|
|
1124
|
+
}), n[6] = u, n[7] = r.description, n[8] = r.label, n[9] = I) : I = n[9];
|
|
1125
|
+
let L;
|
|
1126
|
+
n[10] !== u || n[11] !== r.badge ? (L = !u && r.badge != null && /* @__PURE__ */ g("span", {
|
|
1127
|
+
className: "auto-menu-badge",
|
|
1128
|
+
children: r.badge
|
|
1129
|
+
}), n[10] = u, n[11] = r.badge, n[12] = L) : L = n[12];
|
|
1130
|
+
let R;
|
|
1131
|
+
n[13] !== u || n[14] !== C || n[15] !== T ? (R = !u && C && /* @__PURE__ */ g("span", {
|
|
1132
|
+
className: `auto-menu-arrow${T ? " auto-menu-arrow-open" : ""}`,
|
|
1133
|
+
"aria-hidden": "true",
|
|
1134
|
+
children: "▾"
|
|
1135
|
+
}), n[13] = u, n[14] = C, n[15] = T, n[16] = R) : R = n[16];
|
|
1136
|
+
let ee;
|
|
1137
|
+
n[17] !== r.disabled || n[18] !== r.label || n[19] !== P || n[20] !== F || n[21] !== I || n[22] !== L || n[23] !== R || n[24] !== O || n[25] !== k || n[26] !== A || n[27] !== j || n[28] !== M || n[29] !== N ? (ee = /* @__PURE__ */ _("button", {
|
|
1138
|
+
type: "button",
|
|
1139
|
+
"data-auto-menu-item": "",
|
|
1140
|
+
className: O,
|
|
1141
|
+
"data-active-branch": k,
|
|
1142
|
+
"aria-label": r.label,
|
|
1143
|
+
"aria-current": A,
|
|
1144
|
+
"aria-expanded": j,
|
|
1145
|
+
"aria-controls": M,
|
|
1146
|
+
disabled: r.disabled,
|
|
1147
|
+
title: N,
|
|
1148
|
+
onClick: P,
|
|
1149
|
+
children: [
|
|
1150
|
+
F,
|
|
1151
|
+
I,
|
|
1152
|
+
L,
|
|
1153
|
+
R
|
|
1154
|
+
]
|
|
1155
|
+
}), n[17] = r.disabled, n[18] = r.label, n[19] = P, n[20] = F, n[21] = I, n[22] = L, n[23] = R, n[24] = O, n[25] = k, n[26] = A, n[27] = j, n[28] = M, n[29] = N, n[30] = ee) : ee = n[30];
|
|
1156
|
+
let z = ee, B = C && u ? /* @__PURE__ */ g(Se, {
|
|
1157
|
+
placement: "right-start",
|
|
1158
|
+
open: o && !r.disabled,
|
|
1159
|
+
onOpenChange: l,
|
|
1160
|
+
content: /* @__PURE__ */ _("div", {
|
|
1161
|
+
id: `${a}-flyout`,
|
|
1162
|
+
className: "auto-root auto-menu auto-menu-flyout",
|
|
1163
|
+
"data-size": x,
|
|
1164
|
+
"data-density": S,
|
|
1165
|
+
onKeyDown: (e) => {
|
|
1166
|
+
Te(e), e.key === "ArrowLeft" && !e.defaultPrevented && (e.preventDefault(), l(!1));
|
|
1167
|
+
},
|
|
1168
|
+
children: [/* @__PURE__ */ g("div", {
|
|
1169
|
+
className: "auto-menu-label",
|
|
1170
|
+
children: r.label
|
|
1171
|
+
}), /* @__PURE__ */ g(De, {
|
|
1172
|
+
...i,
|
|
1173
|
+
items: r.children,
|
|
1174
|
+
depth: v + 1,
|
|
1175
|
+
path: D,
|
|
1176
|
+
collapsed: !1,
|
|
1177
|
+
onSelect: (e, t) => {
|
|
1178
|
+
b(e, t), l(!1);
|
|
1179
|
+
}
|
|
1180
|
+
})]
|
|
1181
|
+
}),
|
|
1182
|
+
children: z
|
|
1183
|
+
}) : z, te = C && !u && T && /* @__PURE__ */ g("div", {
|
|
1184
|
+
id: a,
|
|
1185
|
+
children: /* @__PURE__ */ g(De, {
|
|
1186
|
+
...i,
|
|
1187
|
+
items: r.children,
|
|
1188
|
+
depth: v + 1,
|
|
1189
|
+
path: D
|
|
1190
|
+
})
|
|
1191
|
+
}), ne;
|
|
1192
|
+
return n[31] !== B || n[32] !== te ? (ne = /* @__PURE__ */ _("li", {
|
|
1193
|
+
className: "auto-menu-item",
|
|
1194
|
+
children: [B, te]
|
|
1195
|
+
}), n[31] = B, n[32] = te, n[33] = ne) : ne = n[33], ne;
|
|
1196
|
+
}
|
|
1197
|
+
function De(t) {
|
|
1198
|
+
let n = e(11), r, i;
|
|
1199
|
+
n[0] === t ? (r = n[1], i = n[2]) : ({items: r, ...i} = t, n[0] = t, n[1] = r, n[2] = i);
|
|
1200
|
+
let a = i.depth, o;
|
|
1201
|
+
if (n[3] !== r || n[4] !== i) {
|
|
1202
|
+
let e;
|
|
1203
|
+
n[6] === i ? e = n[7] : (e = (e) => /* @__PURE__ */ g(Ee, {
|
|
1204
|
+
item: e,
|
|
1205
|
+
...i
|
|
1206
|
+
}, e.id), n[6] = i, n[7] = e), o = r.map(e), n[3] = r, n[4] = i, n[5] = o;
|
|
1207
|
+
} else o = n[5];
|
|
1208
|
+
let s;
|
|
1209
|
+
return n[8] !== i.depth || n[9] !== o ? (s = /* @__PURE__ */ g("ul", {
|
|
1210
|
+
className: "auto-menu-list",
|
|
1211
|
+
"data-depth": a,
|
|
1212
|
+
children: o
|
|
1213
|
+
}), n[8] = i.depth, n[9] = o, n[10] = s) : s = n[10], s;
|
|
1214
|
+
}
|
|
1215
|
+
function Oe({ items: e, value: t, defaultValue: n, onChange: r, label: i, header: a, footer: o, collapsible: c = !1, collapsed: l, defaultCollapsed: u = !1, onCollapsedChange: d, size: f, density: m, className: h, style: v }) {
|
|
1216
|
+
let y = X(), b = Y(), x = m ?? b.menu?.density ?? b.density ?? "comfortable", S = f ?? b.menu?.size ?? b.size ?? "medium", [C, w] = p(n), [T, E] = p(u), [D, O] = p(/* @__PURE__ */ new Map()), k = l ?? T, A = function e(t, n = !1, r = /* @__PURE__ */ new Set()) {
|
|
1217
|
+
return t.some((e) => r.has(e.id)) ? [] : t.flatMap((t) => {
|
|
1218
|
+
if ((typeof t.hidden == "function" ? t.hidden() : t.hidden) || !b.canAccess(t) || r.has(t.id)) return [];
|
|
1219
|
+
let i = n || t.disabled;
|
|
1220
|
+
if (t.children?.length) {
|
|
1221
|
+
let n = e(t.children, i, new Set(r).add(t.id));
|
|
1222
|
+
return n.length ? [{
|
|
1223
|
+
...t,
|
|
1224
|
+
disabled: i,
|
|
1225
|
+
children: n
|
|
1226
|
+
}] : [];
|
|
1227
|
+
}
|
|
1228
|
+
return [i === t.disabled ? t : {
|
|
1229
|
+
...t,
|
|
1230
|
+
disabled: i
|
|
1231
|
+
}];
|
|
1232
|
+
});
|
|
1233
|
+
}(e), j = t === void 0 ? Ce(A, C ?? "") ?? we(A) : Ce(A, t) ?? [], M = j.map((e) => e.id), N = new Set(M), P = j.at(-1)?.id, F = JSON.stringify(M);
|
|
1234
|
+
s(() => {
|
|
1235
|
+
let e = M.slice(0, -1);
|
|
1236
|
+
e.length && O((t) => {
|
|
1237
|
+
let n = new Map(t);
|
|
1238
|
+
for (let t of e) n.set(t, !0);
|
|
1239
|
+
return n;
|
|
1240
|
+
});
|
|
1241
|
+
}, [F]);
|
|
1242
|
+
function I(e, n) {
|
|
1243
|
+
t === void 0 && w(e.id), r?.(e.id, e, n.map((e) => e.id));
|
|
1244
|
+
}
|
|
1245
|
+
return /* @__PURE__ */ _("nav", {
|
|
1246
|
+
className: `auto-root auto-menu${k ? " auto-menu-collapsed" : ""}${h ? ` ${h}` : ""}`,
|
|
1247
|
+
"data-size": S,
|
|
1248
|
+
"data-density": x,
|
|
1249
|
+
"data-collapsed": k ? "true" : void 0,
|
|
1250
|
+
"aria-label": i ?? y("导航菜单"),
|
|
1251
|
+
style: v,
|
|
1252
|
+
onKeyDown: Te,
|
|
1253
|
+
children: [
|
|
1254
|
+
a != null && /* @__PURE__ */ g("div", {
|
|
1255
|
+
className: "auto-menu-header",
|
|
1256
|
+
children: a
|
|
1257
|
+
}),
|
|
1258
|
+
i != null && !k && /* @__PURE__ */ g("div", {
|
|
1259
|
+
className: "auto-menu-label",
|
|
1260
|
+
children: i
|
|
1261
|
+
}),
|
|
1262
|
+
/* @__PURE__ */ g(De, {
|
|
1263
|
+
items: A,
|
|
1264
|
+
depth: 0,
|
|
1265
|
+
currentId: P,
|
|
1266
|
+
selectedIds: N,
|
|
1267
|
+
expanded: D,
|
|
1268
|
+
collapsed: k,
|
|
1269
|
+
size: S,
|
|
1270
|
+
density: x,
|
|
1271
|
+
onToggle: (e) => O((t) => new Map(t).set(e, !(t.get(e) ?? N.has(e)))),
|
|
1272
|
+
onSelect: I,
|
|
1273
|
+
path: []
|
|
1274
|
+
}),
|
|
1275
|
+
c && /* @__PURE__ */ g("button", {
|
|
1276
|
+
type: "button",
|
|
1277
|
+
className: "auto-menu-collapse-btn",
|
|
1278
|
+
"aria-label": y(k ? "展开菜单" : "收起菜单"),
|
|
1279
|
+
"aria-expanded": !k,
|
|
1280
|
+
onClick: () => {
|
|
1281
|
+
let e = !k;
|
|
1282
|
+
l === void 0 && E(e), d?.(e);
|
|
1283
|
+
},
|
|
1284
|
+
children: k ? "»" : "«"
|
|
1285
|
+
}),
|
|
1286
|
+
o != null && /* @__PURE__ */ g("div", {
|
|
1287
|
+
className: "auto-menu-footer",
|
|
1288
|
+
children: o
|
|
1289
|
+
})
|
|
1290
|
+
]
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
//#endregion
|
|
1294
|
+
//#region src/components/AutoTable/TableHeader.tsx
|
|
1295
|
+
function ke(e, t, n) {
|
|
1296
|
+
return {
|
|
1297
|
+
kind: "group",
|
|
1298
|
+
operator: "and",
|
|
1299
|
+
children: [...(e.kind === "group" && e.operator === "and" ? e.children : [e]).filter((e) => e.kind !== "condition" || e.field !== t), ...n.length ? [{
|
|
1300
|
+
kind: "condition",
|
|
1301
|
+
field: t,
|
|
1302
|
+
operator: "in",
|
|
1303
|
+
value: n
|
|
1304
|
+
}] : []]
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
function Ae(t) {
|
|
1308
|
+
let n = e(30), { column: r, rows: i, query: a, onChange: o } = t, s = X(), [c, l] = p(""), u;
|
|
1309
|
+
if (n[0] !== r.key || n[1] !== r.options || n[2] !== o || n[3] !== a || n[4] !== i || n[5] !== c || n[6] !== s) {
|
|
1310
|
+
let e = a.kind === "group" && a.operator === "and" ? a.children : [a], t;
|
|
1311
|
+
n[8] === r.key ? t = n[9] : (t = (e) => e.kind === "condition" && e.field === r.key, n[8] = r.key, n[9] = t);
|
|
1312
|
+
let d = e.find(t), f = d?.kind === "condition" ? d.operator === "in" && Array.isArray(d.value) ? d.value : [d.value] : [], p = r.options ?? [...new Set(i.map((e) => e[r.key]))].map((e) => ({
|
|
1313
|
+
value: e,
|
|
1314
|
+
label: String(e ?? s("空"))
|
|
1315
|
+
})), m;
|
|
1316
|
+
n[10] === s ? m = n[11] : (m = s("搜索筛选选项"), n[10] = s, n[11] = m);
|
|
1317
|
+
let h;
|
|
1318
|
+
n[12] === s ? h = n[13] : (h = s("搜索选项"), n[12] = s, n[13] = h);
|
|
1319
|
+
let v;
|
|
1320
|
+
n[14] === Symbol.for("react.memo_cache_sentinel") ? (v = (e) => l(e.target.value), n[14] = v) : v = n[14];
|
|
1321
|
+
let y;
|
|
1322
|
+
n[15] !== c || n[16] !== m || n[17] !== h ? (y = /* @__PURE__ */ g("input", {
|
|
1323
|
+
"aria-label": m,
|
|
1324
|
+
placeholder: h,
|
|
1325
|
+
value: c,
|
|
1326
|
+
onChange: v
|
|
1327
|
+
}), n[15] = c, n[16] = m, n[17] = h, n[18] = y) : y = n[18];
|
|
1328
|
+
let b;
|
|
1329
|
+
n[19] !== r.key || n[20] !== o || n[21] !== a ? (b = () => o(ke(a, r.key, [])), n[19] = r.key, n[20] = o, n[21] = a, n[22] = b) : b = n[22];
|
|
1330
|
+
let x;
|
|
1331
|
+
n[23] === s ? x = n[24] : (x = s("清除本列筛选"), n[23] = s, n[24] = x);
|
|
1332
|
+
let S;
|
|
1333
|
+
n[25] !== b || n[26] !== x ? (S = /* @__PURE__ */ g("button", {
|
|
1334
|
+
onClick: b,
|
|
1335
|
+
children: x
|
|
1336
|
+
}), n[25] = b, n[26] = x, n[27] = S) : S = n[27];
|
|
1337
|
+
let C;
|
|
1338
|
+
n[28] === c ? C = n[29] : (C = (e) => e.label.toLocaleLowerCase().includes(c.toLocaleLowerCase()), n[28] = c, n[29] = C), u = /* @__PURE__ */ _("div", {
|
|
1339
|
+
className: "auto-filter-options",
|
|
1340
|
+
children: [
|
|
1341
|
+
y,
|
|
1342
|
+
S,
|
|
1343
|
+
p.filter(C).map((e, t) => /* @__PURE__ */ _("label", {
|
|
1344
|
+
className: "auto-setting-row",
|
|
1345
|
+
children: [
|
|
1346
|
+
/* @__PURE__ */ g("input", {
|
|
1347
|
+
type: "checkbox",
|
|
1348
|
+
checked: f.some((t) => Object.is(t, e.value)),
|
|
1349
|
+
onChange: (t) => o(ke(a, r.key, t.target.checked ? [...f, e.value] : f.filter((t) => !Object.is(t, e.value))))
|
|
1350
|
+
}),
|
|
1351
|
+
e.label,
|
|
1352
|
+
/* @__PURE__ */ g("small", { children: i.filter((t) => Object.is(t[r.key], e.value)).length })
|
|
1353
|
+
]
|
|
1354
|
+
}, t))
|
|
1355
|
+
]
|
|
1356
|
+
}), n[0] = r.key, n[1] = r.options, n[2] = o, n[3] = a, n[4] = i, n[5] = c, n[6] = s, n[7] = u;
|
|
1357
|
+
} else u = n[7];
|
|
1358
|
+
return u;
|
|
1359
|
+
}
|
|
1360
|
+
function je(t) {
|
|
1361
|
+
let n = e(43), { columns: r, rows: i, sort: a, filter: o, onSort: c, onFilter: l, onResize: u, style: d, hasActions: p, allSelected: m, indeterminate: h, onSelectAll: v } = t, y = X(), b = f(null), x, S;
|
|
1362
|
+
n[0] !== m || n[1] !== h ? (x = () => {
|
|
1363
|
+
b.current && (b.current.indeterminate = !m && !!h);
|
|
1364
|
+
}, S = [m, h], n[0] = m, n[1] = h, n[2] = x, n[3] = S) : (x = n[2], S = n[3]), s(x, S);
|
|
1365
|
+
let C;
|
|
1366
|
+
n[4] === o ? C = n[5] : (C = o.kind === "group" && o.operator === "and" ? o.children : [o], n[4] = o, n[5] = C);
|
|
1367
|
+
let w = C, T;
|
|
1368
|
+
n[6] === Symbol.for("react.memo_cache_sentinel") ? (T = { width: 44 }, n[6] = T) : T = n[6];
|
|
1369
|
+
let E;
|
|
1370
|
+
n[7] === y ? E = n[8] : (E = y("选择当前页"), n[7] = y, n[8] = E);
|
|
1371
|
+
let D;
|
|
1372
|
+
n[9] === v ? D = n[10] : (D = (e) => v(e.target.checked), n[9] = v, n[10] = D);
|
|
1373
|
+
let O;
|
|
1374
|
+
n[11] !== m || n[12] !== E || n[13] !== D ? (O = /* @__PURE__ */ g("th", {
|
|
1375
|
+
className: "auto-table-cell-selection",
|
|
1376
|
+
style: T,
|
|
1377
|
+
children: /* @__PURE__ */ g("input", {
|
|
1378
|
+
ref: b,
|
|
1379
|
+
type: "checkbox",
|
|
1380
|
+
"aria-label": E,
|
|
1381
|
+
checked: m,
|
|
1382
|
+
onChange: D
|
|
1383
|
+
})
|
|
1384
|
+
}), n[11] = m, n[12] = E, n[13] = D, n[14] = O) : O = n[14];
|
|
1385
|
+
let k;
|
|
1386
|
+
if (n[15] !== r || n[16] !== o || n[17] !== w || n[18] !== l || n[19] !== u || n[20] !== c || n[21] !== i || n[22] !== a || n[23] !== d || n[24] !== y) {
|
|
1387
|
+
let e;
|
|
1388
|
+
n[26] !== o || n[27] !== w || n[28] !== l || n[29] !== u || n[30] !== c || n[31] !== i || n[32] !== a || n[33] !== d || n[34] !== y ? (e = (e) => {
|
|
1389
|
+
let t = w.some((t) => t.kind === "condition" && t.field === e.key);
|
|
1390
|
+
return /* @__PURE__ */ g("th", {
|
|
1391
|
+
style: d(e),
|
|
1392
|
+
"aria-sort": a.find((t) => t.id === e.key) ? a.find((t) => t.id === e.key)?.desc ? "descending" : "ascending" : "none",
|
|
1393
|
+
children: /* @__PURE__ */ _("div", {
|
|
1394
|
+
className: "auto-column-heading",
|
|
1395
|
+
style: { justifyContent: e.align === "right" ? "flex-end" : e.align === "center" ? "center" : "flex-start" },
|
|
1396
|
+
children: [
|
|
1397
|
+
e.header ?? /* @__PURE__ */ _("button", {
|
|
1398
|
+
"aria-label": y("排序 {0}", [e.label ?? e.key]),
|
|
1399
|
+
disabled: e.sortable === !1,
|
|
1400
|
+
onClick: (t) => {
|
|
1401
|
+
let n = a.find((t) => t.id === e.key), r = n ? n.desc ? void 0 : {
|
|
1402
|
+
...n,
|
|
1403
|
+
desc: !0
|
|
1404
|
+
} : {
|
|
1405
|
+
id: e.key,
|
|
1406
|
+
desc: !1
|
|
1407
|
+
};
|
|
1408
|
+
c([...t.shiftKey ? a.filter((t) => t.id !== e.key) : [], ...r ? [r] : []]);
|
|
1409
|
+
},
|
|
1410
|
+
children: [
|
|
1411
|
+
e.label ?? e.key,
|
|
1412
|
+
" ",
|
|
1413
|
+
a.find((t) => t.id === e.key) ? a.find((t) => t.id === e.key)?.desc ? "↓" : "↑" : ""
|
|
1414
|
+
]
|
|
1415
|
+
}),
|
|
1416
|
+
e.filterable && /* @__PURE__ */ g(Se, {
|
|
1417
|
+
content: /* @__PURE__ */ g(Ae, {
|
|
1418
|
+
column: e,
|
|
1419
|
+
rows: i,
|
|
1420
|
+
query: o,
|
|
1421
|
+
onChange: l
|
|
1422
|
+
}),
|
|
1423
|
+
children: /* @__PURE__ */ g("button", {
|
|
1424
|
+
className: t ? "auto-filter-active" : void 0,
|
|
1425
|
+
"aria-label": y("筛选 {0}", [e.label ?? e.key]),
|
|
1426
|
+
children: "⌄"
|
|
1427
|
+
})
|
|
1428
|
+
}),
|
|
1429
|
+
/* @__PURE__ */ g("span", {
|
|
1430
|
+
className: "auto-resize",
|
|
1431
|
+
role: "separator",
|
|
1432
|
+
tabIndex: 0,
|
|
1433
|
+
"aria-orientation": "vertical",
|
|
1434
|
+
"aria-label": y("调整 {0} 列宽", [e.label ?? e.key]),
|
|
1435
|
+
onKeyDown: (t) => {
|
|
1436
|
+
(t.key === "ArrowLeft" || t.key === "ArrowRight") && (t.preventDefault(), u(e.key, Math.max(e.minWidth ?? 60, Number(d(e).width) + (t.key === "ArrowRight" ? 10 : -10))));
|
|
1437
|
+
},
|
|
1438
|
+
onPointerDown: (t) => {
|
|
1439
|
+
t.preventDefault();
|
|
1440
|
+
let n = t.clientX, r = Number(d(e).width), i = t.currentTarget;
|
|
1441
|
+
i.setPointerCapture(t.pointerId);
|
|
1442
|
+
let a = r, o = (t) => {
|
|
1443
|
+
a = Math.max(e.minWidth ?? 60, r + t.clientX - n), i.style.transform = `translateX(${a - r}px)`;
|
|
1444
|
+
}, s = () => {
|
|
1445
|
+
i.style.transform = "", u(e.key, a), i.removeEventListener("pointermove", o), i.removeEventListener("pointerup", s), i.removeEventListener("pointercancel", s);
|
|
1446
|
+
};
|
|
1447
|
+
i.addEventListener("pointermove", o), i.addEventListener("pointerup", s), i.addEventListener("pointercancel", s);
|
|
1448
|
+
}
|
|
1449
|
+
})
|
|
1450
|
+
]
|
|
1451
|
+
})
|
|
1452
|
+
}, e.key);
|
|
1453
|
+
}, n[26] = o, n[27] = w, n[28] = l, n[29] = u, n[30] = c, n[31] = i, n[32] = a, n[33] = d, n[34] = y, n[35] = e) : e = n[35], k = r.map(e), n[15] = r, n[16] = o, n[17] = w, n[18] = l, n[19] = u, n[20] = c, n[21] = i, n[22] = a, n[23] = d, n[24] = y, n[25] = k;
|
|
1454
|
+
} else k = n[25];
|
|
1455
|
+
let A;
|
|
1456
|
+
n[36] !== p || n[37] !== y ? (A = p && /* @__PURE__ */ g("th", {
|
|
1457
|
+
style: { width: Math.max(140, 64 + (y("编辑").length + y("删除").length) * 8) },
|
|
1458
|
+
children: y("操作")
|
|
1459
|
+
}), n[36] = p, n[37] = y, n[38] = A) : A = n[38];
|
|
1460
|
+
let j;
|
|
1461
|
+
return n[39] !== O || n[40] !== k || n[41] !== A ? (j = /* @__PURE__ */ g("thead", { children: /* @__PURE__ */ _("tr", { children: [
|
|
1462
|
+
O,
|
|
1463
|
+
k,
|
|
1464
|
+
A
|
|
1465
|
+
] }) }), n[39] = O, n[40] = k, n[41] = A, n[42] = j) : j = n[42], j;
|
|
1466
|
+
}
|
|
1467
|
+
//#endregion
|
|
1468
|
+
//#region src/components/AutoTable/features.ts
|
|
1469
|
+
var Me = V({
|
|
1470
|
+
rowSortingFeature: ne,
|
|
1471
|
+
rowPaginationFeature: B,
|
|
1472
|
+
rowSelectionFeature: te,
|
|
1473
|
+
rowExpandingFeature: z,
|
|
1474
|
+
sortedRowModel: R(),
|
|
1475
|
+
expandedRowModel: I(),
|
|
1476
|
+
paginatedRowModel: L()
|
|
1477
|
+
});
|
|
1478
|
+
//#endregion
|
|
1479
|
+
//#region src/components/AutoTable/useTableData.ts
|
|
1480
|
+
function Ne(e, t, n) {
|
|
1481
|
+
let [r, i] = p({
|
|
1482
|
+
rows: [],
|
|
1483
|
+
total: 0
|
|
1484
|
+
}), [o, c] = p(null), [l, u] = p(!1), [d, m] = p(""), [h, g] = p(0), _ = f(t);
|
|
1485
|
+
_.current = t;
|
|
1486
|
+
let v = JSON.stringify(n), y = !!t;
|
|
1487
|
+
return s(() => {
|
|
1488
|
+
if (!y) return;
|
|
1489
|
+
let e = new AbortController();
|
|
1490
|
+
return u(!0), m(""), Promise.resolve().then(() => _.current(JSON.parse(v), { signal: e.signal })).then((t) => {
|
|
1491
|
+
e.signal.aborted || (i(t), c(v));
|
|
1492
|
+
}).catch((t) => {
|
|
1493
|
+
e.signal.aborted || m(W(t));
|
|
1494
|
+
}).finally(() => {
|
|
1495
|
+
e.signal.aborted || u(!1);
|
|
1496
|
+
}), () => e.abort();
|
|
1497
|
+
}, [
|
|
1498
|
+
v,
|
|
1499
|
+
h,
|
|
1500
|
+
y
|
|
1501
|
+
]), {
|
|
1502
|
+
resolved: e !== void 0 || o === v,
|
|
1503
|
+
rows: e ?? r.rows,
|
|
1504
|
+
total: e?.length ?? r.total,
|
|
1505
|
+
loading: l,
|
|
1506
|
+
error: d,
|
|
1507
|
+
refresh: a(() => g((e) => e + 1), [])
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
//#endregion
|
|
1511
|
+
//#region src/components/AutoTable/settings.ts
|
|
1512
|
+
var Pe = (e) => ({
|
|
1513
|
+
activeId: "default",
|
|
1514
|
+
version: 1,
|
|
1515
|
+
presets: [{
|
|
1516
|
+
id: "default",
|
|
1517
|
+
name: "默认方案",
|
|
1518
|
+
value: e
|
|
1519
|
+
}]
|
|
1520
|
+
});
|
|
1521
|
+
function Fe(e, t = {}) {
|
|
1522
|
+
return {
|
|
1523
|
+
layout: Pe({
|
|
1524
|
+
order: e,
|
|
1525
|
+
hidden: [],
|
|
1526
|
+
widths: {},
|
|
1527
|
+
pin: {},
|
|
1528
|
+
density: "inherit",
|
|
1529
|
+
...t
|
|
1530
|
+
}),
|
|
1531
|
+
sort: Pe([]),
|
|
1532
|
+
filter: Pe(se),
|
|
1533
|
+
export: Pe({
|
|
1534
|
+
columns: e,
|
|
1535
|
+
format: "csv",
|
|
1536
|
+
scope: "filtered",
|
|
1537
|
+
fileName: "export"
|
|
1538
|
+
})
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
function $(e) {
|
|
1542
|
+
return (e.presets.find((t) => t.id === e.activeId) ?? e.presets[0]).value;
|
|
1543
|
+
}
|
|
1544
|
+
function Ie(e, t) {
|
|
1545
|
+
return {
|
|
1546
|
+
...e,
|
|
1547
|
+
presets: e.presets.map((n) => n.id === e.activeId ? {
|
|
1548
|
+
...n,
|
|
1549
|
+
value: t
|
|
1550
|
+
} : n)
|
|
1551
|
+
};
|
|
1552
|
+
}
|
|
1553
|
+
function Le(e, t, n, r = {}) {
|
|
1554
|
+
let i = Fe(t, r);
|
|
1555
|
+
(!e || typeof e != "object") && (e = i);
|
|
1556
|
+
let a = e;
|
|
1557
|
+
for (let e of [
|
|
1558
|
+
"layout",
|
|
1559
|
+
"sort",
|
|
1560
|
+
"filter",
|
|
1561
|
+
"export"
|
|
1562
|
+
]) {
|
|
1563
|
+
let t = n[e] ?? 1;
|
|
1564
|
+
i[e].version = t;
|
|
1565
|
+
let r = a[e];
|
|
1566
|
+
r?.version === t && Array.isArray(r.presets) && r.presets.length && r.presets.every((e) => e && typeof e.id == "string" && typeof e.name == "string" && e.value != null) && (Object.assign(i[e], structuredClone(r)), r.presets.some((e) => e.id === r.activeId) || (i[e].activeId = r.presets[0].id));
|
|
1567
|
+
}
|
|
1568
|
+
try {
|
|
1569
|
+
for (let e of i.layout.presets) {
|
|
1570
|
+
let n = e.value;
|
|
1571
|
+
e.value = {
|
|
1572
|
+
order: [.../* @__PURE__ */ new Set([...n.order.filter((e) => t.includes(e)), ...t])],
|
|
1573
|
+
hidden: n.hidden.filter((e) => t.includes(e)),
|
|
1574
|
+
widths: Object.fromEntries(Object.entries(n.widths).filter(([e, n]) => t.includes(e) && Number.isFinite(n) && n >= 40)),
|
|
1575
|
+
pin: Object.fromEntries(Object.entries(n.pin).filter(([e, n]) => t.includes(e) && (n === "left" || n === "right" || n === null))),
|
|
1576
|
+
density: [
|
|
1577
|
+
"inherit",
|
|
1578
|
+
"compact",
|
|
1579
|
+
"normal",
|
|
1580
|
+
"comfortable"
|
|
1581
|
+
].includes(n.density) ? n.density : "inherit"
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1584
|
+
for (let e of i.sort.presets) e.value = e.value.filter((e) => t.includes(e.id) && typeof e.desc == "boolean");
|
|
1585
|
+
for (let e of i.filter.presets) J(e.value, t) || (e.value = se);
|
|
1586
|
+
for (let e of i.export.presets) e.value.columns = e.value.columns.filter((e) => t.includes(e)), [
|
|
1587
|
+
"csv",
|
|
1588
|
+
"json",
|
|
1589
|
+
"xlsx"
|
|
1590
|
+
].includes(e.value.format) || (e.value.format = "csv"), [
|
|
1591
|
+
"page",
|
|
1592
|
+
"filtered",
|
|
1593
|
+
"selected"
|
|
1594
|
+
].includes(e.value.scope) || (e.value.scope = "filtered"), typeof e.value.fileName != "string" && (e.value.fileName = "export");
|
|
1595
|
+
} catch {
|
|
1596
|
+
return Fe(t, r);
|
|
1597
|
+
}
|
|
1598
|
+
return i;
|
|
1599
|
+
}
|
|
1600
|
+
//#endregion
|
|
1601
|
+
//#region src/components/AutoTable/useTableSettings.ts
|
|
1602
|
+
function Re(t, n, r, i) {
|
|
1603
|
+
let a = e(34), o = r === void 0 ? {} : r, c;
|
|
1604
|
+
a[0] === i ? c = a[1] : (c = i === void 0 ? {} : i, a[0] = i, a[1] = c);
|
|
1605
|
+
let l = c, u = Y(), d = `${u.namespace}:table:${t}`, m = JSON.stringify([
|
|
1606
|
+
d,
|
|
1607
|
+
n,
|
|
1608
|
+
o
|
|
1609
|
+
]), h;
|
|
1610
|
+
a[2] !== l || a[3] !== d || a[4] !== n || a[5] !== u.storage || a[6] !== o ? (h = () => Le(u.storage.get(d), n, o, l), a[2] = l, a[3] = d, a[4] = n, a[5] = u.storage, a[6] = o, a[7] = h) : h = a[7];
|
|
1611
|
+
let [g, _] = p(h), [v, y] = p(""), b = f(0), x;
|
|
1612
|
+
a[8] === Symbol.for("react.memo_cache_sentinel") ? (x = Promise.resolve(), a[8] = x) : x = a[8];
|
|
1613
|
+
let S = f(x), C = f(!0), w, T;
|
|
1614
|
+
a[9] === Symbol.for("react.memo_cache_sentinel") ? (w = () => (C.current = !0, () => {
|
|
1615
|
+
C.current = !1;
|
|
1616
|
+
}), T = [], a[9] = w, a[10] = T) : (w = a[9], T = a[10]), s(w, T);
|
|
1617
|
+
let E;
|
|
1618
|
+
a[11] !== l || a[12] !== d || a[13] !== n || a[14] !== u.settings || a[15] !== u.storage || a[16] !== o ? (E = () => {
|
|
1619
|
+
let e = b.current += 1;
|
|
1620
|
+
_(Le(u.storage.get(d), n, o, l));
|
|
1621
|
+
let t = !0;
|
|
1622
|
+
return u.settings && u.settings.load(d).then((r) => {
|
|
1623
|
+
t && b.current === e && r && _(Le(r, n, o, l));
|
|
1624
|
+
}).catch((e) => {
|
|
1625
|
+
t && y(W(e));
|
|
1626
|
+
}), () => {
|
|
1627
|
+
t = !1;
|
|
1628
|
+
};
|
|
1629
|
+
}, a[11] = l, a[12] = d, a[13] = n, a[14] = u.settings, a[15] = u.storage, a[16] = o, a[17] = E) : E = a[17];
|
|
1630
|
+
let D;
|
|
1631
|
+
a[18] !== u.settings || a[19] !== u.storage || a[20] !== m ? (D = [
|
|
1632
|
+
m,
|
|
1633
|
+
u.storage,
|
|
1634
|
+
u.settings
|
|
1635
|
+
], a[18] = u.settings, a[19] = u.storage, a[20] = m, a[21] = D) : D = a[21], s(E, D);
|
|
1636
|
+
let O;
|
|
1637
|
+
a[22] !== d || a[23] !== u.settings || a[24] !== u.storage ? (O = function(e) {
|
|
1638
|
+
if (b.current += 1, _(e), u.storage.set(d, e), y(""), u.settings) {
|
|
1639
|
+
let t = u.settings;
|
|
1640
|
+
S.current = S.current.catch(ze).then(() => t.save(d, e)).catch((e) => {
|
|
1641
|
+
C.current && y(W(e));
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
}, a[22] = d, a[23] = u.settings, a[24] = u.storage, a[25] = O) : O = a[25];
|
|
1645
|
+
let k = O, A;
|
|
1646
|
+
a[26] !== g || a[27] !== k ? (A = () => k(g), a[26] = g, a[27] = k, a[28] = A) : A = a[28];
|
|
1647
|
+
let j;
|
|
1648
|
+
return a[29] !== v || a[30] !== g || a[31] !== A || a[32] !== k ? (j = {
|
|
1649
|
+
settings: g,
|
|
1650
|
+
update: k,
|
|
1651
|
+
error: v,
|
|
1652
|
+
retry: A
|
|
1653
|
+
}, a[29] = v, a[30] = g, a[31] = A, a[32] = k, a[33] = j) : j = a[33], j;
|
|
1654
|
+
}
|
|
1655
|
+
function ze() {}
|
|
1656
|
+
//#endregion
|
|
1657
|
+
//#region src/components/AutoTable/FilterEditor.tsx
|
|
1658
|
+
function Be(t) {
|
|
1659
|
+
let n = e(48), { columns: r, value: i, onChange: a } = t, o = X(), s;
|
|
1660
|
+
n[0] === i ? s = n[1] : (s = i.kind === "group" ? i : {
|
|
1661
|
+
kind: "group",
|
|
1662
|
+
operator: "and",
|
|
1663
|
+
children: [i]
|
|
1664
|
+
}, n[0] = i, n[1] = s);
|
|
1665
|
+
let c = s, l;
|
|
1666
|
+
n[2] !== c || n[3] !== a ? (l = (e, t) => a({
|
|
1667
|
+
...c,
|
|
1668
|
+
children: c.children.map((n, r) => r === e ? t : n)
|
|
1669
|
+
}), n[2] = c, n[3] = a, n[4] = l) : l = n[4];
|
|
1670
|
+
let u = l, d;
|
|
1671
|
+
n[5] === o ? d = n[6] : (d = o("条件关系"), n[5] = o, n[6] = d);
|
|
1672
|
+
let f;
|
|
1673
|
+
n[7] === o ? f = n[8] : (f = o("条件关系"), n[7] = o, n[8] = f);
|
|
1674
|
+
let p = c.operator, m;
|
|
1675
|
+
n[9] !== c || n[10] !== a ? (m = (e) => a({
|
|
1676
|
+
...c,
|
|
1677
|
+
operator: e.target.value
|
|
1678
|
+
}), n[9] = c, n[10] = a, n[11] = m) : m = n[11];
|
|
1679
|
+
let h;
|
|
1680
|
+
n[12] === o ? h = n[13] : (h = o("满足全部"), n[12] = o, n[13] = h);
|
|
1681
|
+
let v;
|
|
1682
|
+
n[14] === h ? v = n[15] : (v = /* @__PURE__ */ g("option", {
|
|
1683
|
+
value: "and",
|
|
1684
|
+
children: h
|
|
1685
|
+
}), n[14] = h, n[15] = v);
|
|
1686
|
+
let y;
|
|
1687
|
+
n[16] === o ? y = n[17] : (y = o("满足任一"), n[16] = o, n[17] = y);
|
|
1688
|
+
let b;
|
|
1689
|
+
n[18] === y ? b = n[19] : (b = /* @__PURE__ */ g("option", {
|
|
1690
|
+
value: "or",
|
|
1691
|
+
children: y
|
|
1692
|
+
}), n[18] = y, n[19] = b);
|
|
1693
|
+
let x;
|
|
1694
|
+
n[20] !== c.operator || n[21] !== b || n[22] !== f || n[23] !== m || n[24] !== v ? (x = /* @__PURE__ */ _("select", {
|
|
1695
|
+
"aria-label": f,
|
|
1696
|
+
value: p,
|
|
1697
|
+
onChange: m,
|
|
1698
|
+
children: [v, b]
|
|
1699
|
+
}), n[20] = c.operator, n[21] = b, n[22] = f, n[23] = m, n[24] = v, n[25] = x) : x = n[25];
|
|
1700
|
+
let S;
|
|
1701
|
+
n[26] !== x || n[27] !== d ? (S = /* @__PURE__ */ _("label", { children: [
|
|
1702
|
+
d,
|
|
1703
|
+
" ",
|
|
1704
|
+
x
|
|
1705
|
+
] }), n[26] = x, n[27] = d, n[28] = S) : S = n[28];
|
|
1706
|
+
let C;
|
|
1707
|
+
n[29] !== u || n[30] !== r || n[31] !== c || n[32] !== a || n[33] !== o ? (C = c.children.map((e, t) => e.kind === "group" ? /* @__PURE__ */ _("div", {
|
|
1708
|
+
className: "auto-setting-row",
|
|
1709
|
+
children: [/* @__PURE__ */ g("span", { children: o("嵌套条件组(可在高级编辑中调整)") }), /* @__PURE__ */ g("button", {
|
|
1710
|
+
onClick: () => a({
|
|
1711
|
+
...c,
|
|
1712
|
+
children: c.children.filter((e, n) => n !== t)
|
|
1713
|
+
}),
|
|
1714
|
+
children: o("移除")
|
|
1715
|
+
})]
|
|
1716
|
+
}, t) : /* @__PURE__ */ _("div", {
|
|
1717
|
+
className: "auto-setting-row",
|
|
1718
|
+
children: [
|
|
1719
|
+
/* @__PURE__ */ g("select", {
|
|
1720
|
+
"aria-label": o("筛选字段 {0}", [t + 1]),
|
|
1721
|
+
value: e.field,
|
|
1722
|
+
onChange: (n) => u(t, {
|
|
1723
|
+
...e,
|
|
1724
|
+
field: n.target.value,
|
|
1725
|
+
value: ""
|
|
1726
|
+
}),
|
|
1727
|
+
children: r.map(He)
|
|
1728
|
+
}),
|
|
1729
|
+
/* @__PURE__ */ g("select", {
|
|
1730
|
+
"aria-label": o("筛选运算 {0}", [t + 1]),
|
|
1731
|
+
value: e.operator,
|
|
1732
|
+
onChange: (n) => {
|
|
1733
|
+
let r = n.target.value;
|
|
1734
|
+
u(t, {
|
|
1735
|
+
...e,
|
|
1736
|
+
operator: r,
|
|
1737
|
+
value: r === "between" ? ["", ""] : r === "in" ? [] : ""
|
|
1738
|
+
});
|
|
1739
|
+
},
|
|
1740
|
+
children: [
|
|
1741
|
+
["eq", o("等于")],
|
|
1742
|
+
["contains", o("包含")],
|
|
1743
|
+
["in", o("属于")],
|
|
1744
|
+
["between", o("范围")],
|
|
1745
|
+
["isNull", o("为空")]
|
|
1746
|
+
].map(Ve)
|
|
1747
|
+
}),
|
|
1748
|
+
e.operator !== "isNull" && /* @__PURE__ */ g("input", {
|
|
1749
|
+
"aria-label": o("筛选值 {0}", [t + 1]),
|
|
1750
|
+
placeholder: e.operator === "between" ? o("最小值,最大值") : e.operator === "in" ? o("值1,值2") : o("输入值"),
|
|
1751
|
+
value: Array.isArray(e.value) ? e.value.join(",") : String(e.value ?? ""),
|
|
1752
|
+
onChange: (n) => {
|
|
1753
|
+
let i = (t) => r.find((t) => t.key === e.field)?.type === "number" ? Number(t) : t;
|
|
1754
|
+
u(t, {
|
|
1755
|
+
...e,
|
|
1756
|
+
value: e.operator === "between" || e.operator === "in" ? n.target.value.split(",").map(i) : i(n.target.value)
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
}),
|
|
1760
|
+
/* @__PURE__ */ g("button", {
|
|
1761
|
+
onClick: () => a({
|
|
1762
|
+
...c,
|
|
1763
|
+
children: c.children.filter((e, n) => n !== t)
|
|
1764
|
+
}),
|
|
1765
|
+
children: o("移除")
|
|
1766
|
+
})
|
|
1767
|
+
]
|
|
1768
|
+
}, t)), n[29] = u, n[30] = r, n[31] = c, n[32] = a, n[33] = o, n[34] = C) : C = n[34];
|
|
1769
|
+
let w;
|
|
1770
|
+
n[35] !== r[0] || n[36] !== c || n[37] !== a ? (w = () => {
|
|
1771
|
+
r[0] && a({
|
|
1772
|
+
...c,
|
|
1773
|
+
children: [...c.children, {
|
|
1774
|
+
kind: "condition",
|
|
1775
|
+
field: r[0].key,
|
|
1776
|
+
operator: "contains",
|
|
1777
|
+
value: ""
|
|
1778
|
+
}]
|
|
1779
|
+
});
|
|
1780
|
+
}, n[35] = r[0], n[36] = c, n[37] = a, n[38] = w) : w = n[38];
|
|
1781
|
+
let T;
|
|
1782
|
+
n[39] === o ? T = n[40] : (T = o("添加条件"), n[39] = o, n[40] = T);
|
|
1783
|
+
let E;
|
|
1784
|
+
n[41] !== w || n[42] !== T ? (E = /* @__PURE__ */ g("button", {
|
|
1785
|
+
onClick: w,
|
|
1786
|
+
children: T
|
|
1787
|
+
}), n[41] = w, n[42] = T, n[43] = E) : E = n[43];
|
|
1788
|
+
let D;
|
|
1789
|
+
return n[44] !== S || n[45] !== C || n[46] !== E ? (D = /* @__PURE__ */ _("div", { children: [
|
|
1790
|
+
S,
|
|
1791
|
+
C,
|
|
1792
|
+
E
|
|
1793
|
+
] }), n[44] = S, n[45] = C, n[46] = E, n[47] = D) : D = n[47], D;
|
|
1794
|
+
}
|
|
1795
|
+
function Ve(e) {
|
|
1796
|
+
let [t, n] = e;
|
|
1797
|
+
return /* @__PURE__ */ g("option", {
|
|
1798
|
+
value: t,
|
|
1799
|
+
children: n
|
|
1800
|
+
}, t);
|
|
1801
|
+
}
|
|
1802
|
+
function He(e) {
|
|
1803
|
+
return /* @__PURE__ */ g("option", {
|
|
1804
|
+
value: e.key,
|
|
1805
|
+
children: e.label ?? e.key
|
|
1806
|
+
}, e.key);
|
|
1807
|
+
}
|
|
1808
|
+
//#endregion
|
|
1809
|
+
//#region src/components/AutoTable/SettingsPanel.tsx
|
|
1810
|
+
function Ue({ value: e, columns: t, onChange: n }) {
|
|
1811
|
+
let r = X(), [i, a] = p("layout"), [o, s] = p(""), [c, l] = p(""), [u, d] = p(""), f = e[i];
|
|
1812
|
+
function m(t) {
|
|
1813
|
+
n({
|
|
1814
|
+
...e,
|
|
1815
|
+
[i]: t
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
let v = $(e.layout), y = $(e.sort), b = $(e.export), x = (t) => n({
|
|
1819
|
+
...e,
|
|
1820
|
+
layout: Ie(e.layout, t)
|
|
1821
|
+
}), S = (t) => n({
|
|
1822
|
+
...e,
|
|
1823
|
+
sort: Ie(e.sort, t)
|
|
1824
|
+
});
|
|
1825
|
+
return /* @__PURE__ */ _("div", {
|
|
1826
|
+
className: "auto-settings",
|
|
1827
|
+
children: [
|
|
1828
|
+
/* @__PURE__ */ g("div", {
|
|
1829
|
+
className: "auto-actions",
|
|
1830
|
+
children: [
|
|
1831
|
+
"layout",
|
|
1832
|
+
"sort",
|
|
1833
|
+
"filter",
|
|
1834
|
+
"export"
|
|
1835
|
+
].map((e, t) => /* @__PURE__ */ g("button", {
|
|
1836
|
+
type: "button",
|
|
1837
|
+
"aria-pressed": i === e,
|
|
1838
|
+
onClick: () => {
|
|
1839
|
+
a(e), l(""), d("");
|
|
1840
|
+
},
|
|
1841
|
+
children: [
|
|
1842
|
+
r("列布局"),
|
|
1843
|
+
r("排序"),
|
|
1844
|
+
r("筛选"),
|
|
1845
|
+
r("导出")
|
|
1846
|
+
][t]
|
|
1847
|
+
}, e))
|
|
1848
|
+
}),
|
|
1849
|
+
/* @__PURE__ */ _("div", {
|
|
1850
|
+
className: "auto-actions auto-preset",
|
|
1851
|
+
children: [
|
|
1852
|
+
/* @__PURE__ */ g("select", {
|
|
1853
|
+
"aria-label": r("当前方案"),
|
|
1854
|
+
value: f.activeId,
|
|
1855
|
+
onChange: (e) => m({
|
|
1856
|
+
...f,
|
|
1857
|
+
activeId: e.target.value
|
|
1858
|
+
}),
|
|
1859
|
+
children: f.presets.map((e) => /* @__PURE__ */ g("option", {
|
|
1860
|
+
value: e.id,
|
|
1861
|
+
children: e.id === "default" ? r("默认方案") : e.name
|
|
1862
|
+
}, e.id))
|
|
1863
|
+
}),
|
|
1864
|
+
/* @__PURE__ */ g("input", {
|
|
1865
|
+
"aria-label": r("方案名称"),
|
|
1866
|
+
placeholder: r("方案名称"),
|
|
1867
|
+
value: o,
|
|
1868
|
+
onChange: (e) => s(e.target.value)
|
|
1869
|
+
}),
|
|
1870
|
+
/* @__PURE__ */ g("button", {
|
|
1871
|
+
disabled: !o.trim(),
|
|
1872
|
+
onClick: () => {
|
|
1873
|
+
let e = crypto.randomUUID();
|
|
1874
|
+
m({
|
|
1875
|
+
...f,
|
|
1876
|
+
activeId: e,
|
|
1877
|
+
presets: [...f.presets, {
|
|
1878
|
+
id: e,
|
|
1879
|
+
name: o.trim(),
|
|
1880
|
+
value: structuredClone($(f))
|
|
1881
|
+
}]
|
|
1882
|
+
}), s("");
|
|
1883
|
+
},
|
|
1884
|
+
children: r("另存方案")
|
|
1885
|
+
}),
|
|
1886
|
+
/* @__PURE__ */ g("button", {
|
|
1887
|
+
disabled: !o.trim(),
|
|
1888
|
+
onClick: () => {
|
|
1889
|
+
m({
|
|
1890
|
+
...f,
|
|
1891
|
+
presets: f.presets.map((e) => e.id === f.activeId ? {
|
|
1892
|
+
...e,
|
|
1893
|
+
name: o.trim()
|
|
1894
|
+
} : e)
|
|
1895
|
+
}), s("");
|
|
1896
|
+
},
|
|
1897
|
+
children: r("重命名")
|
|
1898
|
+
}),
|
|
1899
|
+
/* @__PURE__ */ g("button", {
|
|
1900
|
+
disabled: f.presets.length === 1,
|
|
1901
|
+
onClick: () => {
|
|
1902
|
+
let e = f.presets.filter((e) => e.id !== f.activeId);
|
|
1903
|
+
m({
|
|
1904
|
+
...f,
|
|
1905
|
+
presets: e,
|
|
1906
|
+
activeId: e[0].id
|
|
1907
|
+
});
|
|
1908
|
+
},
|
|
1909
|
+
children: r("删除方案")
|
|
1910
|
+
})
|
|
1911
|
+
]
|
|
1912
|
+
}),
|
|
1913
|
+
i === "layout" && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("label", { children: [
|
|
1914
|
+
r("密度"),
|
|
1915
|
+
" ",
|
|
1916
|
+
/* @__PURE__ */ _("select", {
|
|
1917
|
+
value: v.density,
|
|
1918
|
+
onChange: (e) => x({
|
|
1919
|
+
...v,
|
|
1920
|
+
density: e.target.value
|
|
1921
|
+
}),
|
|
1922
|
+
children: [
|
|
1923
|
+
/* @__PURE__ */ g("option", {
|
|
1924
|
+
value: "inherit",
|
|
1925
|
+
children: r("跟随全局")
|
|
1926
|
+
}),
|
|
1927
|
+
/* @__PURE__ */ g("option", {
|
|
1928
|
+
value: "compact",
|
|
1929
|
+
children: r("紧凑")
|
|
1930
|
+
}),
|
|
1931
|
+
/* @__PURE__ */ g("option", {
|
|
1932
|
+
value: "normal",
|
|
1933
|
+
children: r("标准")
|
|
1934
|
+
}),
|
|
1935
|
+
/* @__PURE__ */ g("option", {
|
|
1936
|
+
value: "comfortable",
|
|
1937
|
+
children: r("宽松")
|
|
1938
|
+
})
|
|
1939
|
+
]
|
|
1940
|
+
})
|
|
1941
|
+
] }), v.order.map((e, n) => {
|
|
1942
|
+
let i = t.find((t) => t.key === e);
|
|
1943
|
+
if (!i) return null;
|
|
1944
|
+
let a = (t) => {
|
|
1945
|
+
let r = [...v.order];
|
|
1946
|
+
r.splice(n, 1), r.splice(t, 0, e), x({
|
|
1947
|
+
...v,
|
|
1948
|
+
order: r
|
|
1949
|
+
});
|
|
1950
|
+
};
|
|
1951
|
+
return /* @__PURE__ */ _("div", {
|
|
1952
|
+
className: "auto-setting-row",
|
|
1953
|
+
draggable: !0,
|
|
1954
|
+
onDragStart: (t) => t.dataTransfer.setData("text/plain", e),
|
|
1955
|
+
onDragOver: (e) => e.preventDefault(),
|
|
1956
|
+
onDrop: (e) => {
|
|
1957
|
+
e.preventDefault();
|
|
1958
|
+
let t = v.order.indexOf(e.dataTransfer.getData("text/plain"));
|
|
1959
|
+
if (t < 0) return;
|
|
1960
|
+
let r = [...v.order], [i] = r.splice(t, 1);
|
|
1961
|
+
r.splice(n, 0, i), x({
|
|
1962
|
+
...v,
|
|
1963
|
+
order: r
|
|
1964
|
+
});
|
|
1965
|
+
},
|
|
1966
|
+
children: [
|
|
1967
|
+
/* @__PURE__ */ _("label", { children: [/* @__PURE__ */ g("input", {
|
|
1968
|
+
type: "checkbox",
|
|
1969
|
+
checked: !v.hidden.includes(e),
|
|
1970
|
+
onChange: (t) => x({
|
|
1971
|
+
...v,
|
|
1972
|
+
hidden: t.target.checked ? v.hidden.filter((t) => t !== e) : [...v.hidden, e]
|
|
1973
|
+
})
|
|
1974
|
+
}), i.label ?? e] }),
|
|
1975
|
+
/* @__PURE__ */ g("input", {
|
|
1976
|
+
"aria-label": r("{0}列宽", [i.label ?? e]),
|
|
1977
|
+
type: "number",
|
|
1978
|
+
min: 40,
|
|
1979
|
+
value: v.widths[e] ?? i.width ?? 150,
|
|
1980
|
+
onChange: (t) => x({
|
|
1981
|
+
...v,
|
|
1982
|
+
widths: {
|
|
1983
|
+
...v.widths,
|
|
1984
|
+
[e]: Math.max(40, Number(t.target.value))
|
|
1985
|
+
}
|
|
1986
|
+
})
|
|
1987
|
+
}),
|
|
1988
|
+
/* @__PURE__ */ _("select", {
|
|
1989
|
+
"aria-label": r("{0}固定", [i.label ?? e]),
|
|
1990
|
+
value: v.pin[e] ?? "",
|
|
1991
|
+
onChange: (t) => x({
|
|
1992
|
+
...v,
|
|
1993
|
+
pin: {
|
|
1994
|
+
...v.pin,
|
|
1995
|
+
[e]: t.target.value || null
|
|
1996
|
+
}
|
|
1997
|
+
}),
|
|
1998
|
+
children: [
|
|
1999
|
+
/* @__PURE__ */ g("option", {
|
|
2000
|
+
value: "",
|
|
2001
|
+
children: r("不固定")
|
|
2002
|
+
}),
|
|
2003
|
+
/* @__PURE__ */ g("option", {
|
|
2004
|
+
value: "left",
|
|
2005
|
+
children: r("左固定")
|
|
2006
|
+
}),
|
|
2007
|
+
/* @__PURE__ */ g("option", {
|
|
2008
|
+
value: "right",
|
|
2009
|
+
children: r("右固定")
|
|
2010
|
+
})
|
|
2011
|
+
]
|
|
2012
|
+
}),
|
|
2013
|
+
/* @__PURE__ */ g("button", {
|
|
2014
|
+
"aria-label": r("上移 {0}", [i.label ?? e]),
|
|
2015
|
+
disabled: !n,
|
|
2016
|
+
onClick: () => a(n - 1),
|
|
2017
|
+
children: "↑"
|
|
2018
|
+
}),
|
|
2019
|
+
/* @__PURE__ */ g("button", {
|
|
2020
|
+
"aria-label": r("下移 {0}", [i.label ?? e]),
|
|
2021
|
+
disabled: n === v.order.length - 1,
|
|
2022
|
+
onClick: () => a(n + 1),
|
|
2023
|
+
children: "↓"
|
|
2024
|
+
})
|
|
2025
|
+
]
|
|
2026
|
+
}, e);
|
|
2027
|
+
})] }),
|
|
2028
|
+
i === "sort" && /* @__PURE__ */ _(h, { children: [y.map((e, n) => /* @__PURE__ */ _("div", {
|
|
2029
|
+
className: "auto-setting-row",
|
|
2030
|
+
children: [
|
|
2031
|
+
/* @__PURE__ */ g("select", {
|
|
2032
|
+
"aria-label": r("排序字段 {0}", [n + 1]),
|
|
2033
|
+
value: e.id,
|
|
2034
|
+
onChange: (e) => S(y.map((t, r) => r === n ? {
|
|
2035
|
+
...t,
|
|
2036
|
+
id: e.target.value
|
|
2037
|
+
} : t)),
|
|
2038
|
+
children: t.map((e) => /* @__PURE__ */ g("option", {
|
|
2039
|
+
value: e.key,
|
|
2040
|
+
children: e.label ?? e.key
|
|
2041
|
+
}, e.key))
|
|
2042
|
+
}),
|
|
2043
|
+
/* @__PURE__ */ _("select", {
|
|
2044
|
+
"aria-label": r("排序方向 {0}", [n + 1]),
|
|
2045
|
+
value: String(e.desc),
|
|
2046
|
+
onChange: (e) => S(y.map((t, r) => r === n ? {
|
|
2047
|
+
...t,
|
|
2048
|
+
desc: e.target.value === "true"
|
|
2049
|
+
} : t)),
|
|
2050
|
+
children: [/* @__PURE__ */ g("option", {
|
|
2051
|
+
value: "false",
|
|
2052
|
+
children: r("升序")
|
|
2053
|
+
}), /* @__PURE__ */ g("option", {
|
|
2054
|
+
value: "true",
|
|
2055
|
+
children: r("降序")
|
|
2056
|
+
})]
|
|
2057
|
+
}),
|
|
2058
|
+
/* @__PURE__ */ g("button", {
|
|
2059
|
+
onClick: () => S(y.filter((e, t) => t !== n)),
|
|
2060
|
+
children: r("移除")
|
|
2061
|
+
})
|
|
2062
|
+
]
|
|
2063
|
+
}, n)), /* @__PURE__ */ g("button", {
|
|
2064
|
+
onClick: () => {
|
|
2065
|
+
let e = t.find((e) => !y.some((t) => t.id === e.key));
|
|
2066
|
+
e && S([...y, {
|
|
2067
|
+
id: e.key,
|
|
2068
|
+
desc: !1
|
|
2069
|
+
}]);
|
|
2070
|
+
},
|
|
2071
|
+
children: r("添加排序")
|
|
2072
|
+
})] }),
|
|
2073
|
+
i === "filter" && /* @__PURE__ */ _(h, { children: [
|
|
2074
|
+
/* @__PURE__ */ g(Be, {
|
|
2075
|
+
columns: t,
|
|
2076
|
+
value: $(e.filter),
|
|
2077
|
+
onChange: (t) => {
|
|
2078
|
+
l(""), n({
|
|
2079
|
+
...e,
|
|
2080
|
+
filter: Ie(e.filter, t)
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
2083
|
+
}),
|
|
2084
|
+
/* @__PURE__ */ g("p", {
|
|
2085
|
+
className: "auto-muted",
|
|
2086
|
+
children: r("高级条件编辑(JSON)")
|
|
2087
|
+
}),
|
|
2088
|
+
/* @__PURE__ */ g("textarea", {
|
|
2089
|
+
"aria-label": r("筛选条件 JSON"),
|
|
2090
|
+
rows: 9,
|
|
2091
|
+
value: c || JSON.stringify($(e.filter), null, 2),
|
|
2092
|
+
onChange: (e) => l(e.target.value),
|
|
2093
|
+
style: { width: "100%" }
|
|
2094
|
+
}),
|
|
2095
|
+
/* @__PURE__ */ g("button", {
|
|
2096
|
+
onClick: () => {
|
|
2097
|
+
try {
|
|
2098
|
+
let i = JSON.parse(c || JSON.stringify($(e.filter)));
|
|
2099
|
+
function a(e) {
|
|
2100
|
+
return e?.kind === "group" && ["and", "or"].includes(e.operator) && Array.isArray(e.children) && e.children.every(a) || e?.kind === "condition" && t.some((t) => t.key === e.field) && [
|
|
2101
|
+
"eq",
|
|
2102
|
+
"in",
|
|
2103
|
+
"contains",
|
|
2104
|
+
"between",
|
|
2105
|
+
"isNull"
|
|
2106
|
+
].includes(e.operator);
|
|
2107
|
+
}
|
|
2108
|
+
if (!a(i)) throw Error(r("条件格式无效"));
|
|
2109
|
+
n({
|
|
2110
|
+
...e,
|
|
2111
|
+
filter: Ie(e.filter, i)
|
|
2112
|
+
}), d("");
|
|
2113
|
+
} catch (e) {
|
|
2114
|
+
d(e instanceof Error ? e.message : String(e));
|
|
2115
|
+
}
|
|
2116
|
+
},
|
|
2117
|
+
children: r("应用条件")
|
|
2118
|
+
}),
|
|
2119
|
+
u && /* @__PURE__ */ g("p", {
|
|
2120
|
+
role: "alert",
|
|
2121
|
+
children: u
|
|
2122
|
+
})
|
|
2123
|
+
] }),
|
|
2124
|
+
i === "export" && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("div", {
|
|
2125
|
+
className: "auto-actions",
|
|
2126
|
+
children: [
|
|
2127
|
+
/* @__PURE__ */ g("input", {
|
|
2128
|
+
"aria-label": r("导出文件名"),
|
|
2129
|
+
value: b.fileName,
|
|
2130
|
+
onChange: (t) => n({
|
|
2131
|
+
...e,
|
|
2132
|
+
export: Ie(e.export, {
|
|
2133
|
+
...b,
|
|
2134
|
+
fileName: t.target.value
|
|
2135
|
+
})
|
|
2136
|
+
})
|
|
2137
|
+
}),
|
|
2138
|
+
/* @__PURE__ */ g("select", {
|
|
2139
|
+
"aria-label": r("导出格式"),
|
|
2140
|
+
value: b.format,
|
|
2141
|
+
onChange: (t) => n({
|
|
2142
|
+
...e,
|
|
2143
|
+
export: Ie(e.export, {
|
|
2144
|
+
...b,
|
|
2145
|
+
format: t.target.value
|
|
2146
|
+
})
|
|
2147
|
+
}),
|
|
2148
|
+
children: [
|
|
2149
|
+
"csv",
|
|
2150
|
+
"json",
|
|
2151
|
+
"xlsx"
|
|
2152
|
+
].map((e) => /* @__PURE__ */ g("option", { children: e }, e))
|
|
2153
|
+
}),
|
|
2154
|
+
/* @__PURE__ */ _("select", {
|
|
2155
|
+
"aria-label": r("导出范围"),
|
|
2156
|
+
value: b.scope,
|
|
2157
|
+
onChange: (t) => n({
|
|
2158
|
+
...e,
|
|
2159
|
+
export: Ie(e.export, {
|
|
2160
|
+
...b,
|
|
2161
|
+
scope: t.target.value
|
|
2162
|
+
})
|
|
2163
|
+
}),
|
|
2164
|
+
children: [
|
|
2165
|
+
/* @__PURE__ */ g("option", {
|
|
2166
|
+
value: "filtered",
|
|
2167
|
+
children: r("已筛选数据")
|
|
2168
|
+
}),
|
|
2169
|
+
/* @__PURE__ */ g("option", {
|
|
2170
|
+
value: "page",
|
|
2171
|
+
children: r("当前页")
|
|
2172
|
+
}),
|
|
2173
|
+
/* @__PURE__ */ g("option", {
|
|
2174
|
+
value: "selected",
|
|
2175
|
+
children: r("已选数据")
|
|
2176
|
+
})
|
|
2177
|
+
]
|
|
2178
|
+
})
|
|
2179
|
+
]
|
|
2180
|
+
}), t.filter((e) => e.export !== !1).map((t) => /* @__PURE__ */ _("label", {
|
|
2181
|
+
className: "auto-setting-row",
|
|
2182
|
+
children: [/* @__PURE__ */ g("input", {
|
|
2183
|
+
type: "checkbox",
|
|
2184
|
+
checked: b.columns.includes(t.key),
|
|
2185
|
+
onChange: (r) => n({
|
|
2186
|
+
...e,
|
|
2187
|
+
export: Ie(e.export, {
|
|
2188
|
+
...b,
|
|
2189
|
+
columns: r.target.checked ? [...b.columns, t.key] : b.columns.filter((e) => e !== t.key)
|
|
2190
|
+
})
|
|
2191
|
+
})
|
|
2192
|
+
}), t.label ?? t.key]
|
|
2193
|
+
}, t.key))] })
|
|
2194
|
+
]
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
//#endregion
|
|
2198
|
+
//#region src/components/AutoTable/export.ts
|
|
2199
|
+
function We(e, t) {
|
|
2200
|
+
let n = t[e.key];
|
|
2201
|
+
if (e.format) return e.format(n, t);
|
|
2202
|
+
if (n == null) return "";
|
|
2203
|
+
let r = e.options?.find((e) => Object.is(e.value, n));
|
|
2204
|
+
if (r) return r.label;
|
|
2205
|
+
if (e.type === "date" || e.type === "datetime") {
|
|
2206
|
+
let t = new Date(n);
|
|
2207
|
+
if (!Number.isNaN(t.getTime())) return e.type === "date" ? t.toLocaleDateString() : t.toLocaleString();
|
|
2208
|
+
}
|
|
2209
|
+
return e.type === "percentage" ? `${Number(n) * 100}%` : typeof n == "number" ? n : typeof n == "object" ? JSON.stringify(n) : String(n);
|
|
2210
|
+
}
|
|
2211
|
+
function Ge(e, t, n) {
|
|
2212
|
+
let r = (n ? [...new Set(n)].flatMap((e) => {
|
|
2213
|
+
let n = t.find((t) => t.key === e);
|
|
2214
|
+
return n ? [n] : [];
|
|
2215
|
+
}) : t).filter((e) => e.export !== !1 && !String(e.key).startsWith("_auto_"));
|
|
2216
|
+
return {
|
|
2217
|
+
headers: r.map((e) => e.label ?? e.key),
|
|
2218
|
+
rows: e.map((e) => r.map((t) => t.exportFormat ? t.exportFormat(e) : We(t, e)))
|
|
2219
|
+
};
|
|
2220
|
+
}
|
|
2221
|
+
function Ke(e) {
|
|
2222
|
+
let t = (e) => {
|
|
2223
|
+
let t = e == null ? "" : String(e);
|
|
2224
|
+
return typeof e == "string" && /^[=+\-@\t\r]/.test(t) && (t = "'" + t), /[",\r\n]/.test(t) ? `"${t.replace(/"/g, "\"\"")}"` : t;
|
|
2225
|
+
};
|
|
2226
|
+
return "" + [e.headers, ...e.rows].map((e) => e.map(t).join(",")).join("\r\n");
|
|
2227
|
+
}
|
|
2228
|
+
function qe(e) {
|
|
2229
|
+
return JSON.stringify(e.rows.map((t) => Object.fromEntries(e.headers.map((e, n) => [e, t[n]]))), null, 2);
|
|
2230
|
+
}
|
|
2231
|
+
function Je(e, t, n) {
|
|
2232
|
+
let r = URL.createObjectURL(new Blob([e], { type: n })), i = document.createElement("a");
|
|
2233
|
+
i.href = r, i.download = t, i.click(), setTimeout(() => URL.revokeObjectURL(r), 1e3);
|
|
2234
|
+
}
|
|
2235
|
+
async function Ye(e, t, n) {
|
|
2236
|
+
let r = [], i = 1;
|
|
2237
|
+
for (let a = 0; a < i; a++) {
|
|
2238
|
+
n.throwIfAborted();
|
|
2239
|
+
let o = await e({
|
|
2240
|
+
...t,
|
|
2241
|
+
pageIndex: a
|
|
2242
|
+
}, { signal: n });
|
|
2243
|
+
if (n.throwIfAborted(), a === 0 && (i = Math.ceil(o.total / t.pageSize)), !o.rows.length && a < i) throw Error("导出数据不完整,请重试");
|
|
2244
|
+
r.push(...o.rows);
|
|
2245
|
+
}
|
|
2246
|
+
return r;
|
|
2247
|
+
}
|
|
2248
|
+
//#endregion
|
|
2249
|
+
//#region src/components/AutoTable/AutoTable.tsx
|
|
2250
|
+
function Xe(e) {
|
|
2251
|
+
let n = X(), r = Y(), { id: i, rowKey: a, title: o, height: c = 440, rowHeight: u = 40, pagination: m = !0 } = e, [v, y] = p({
|
|
2252
|
+
pageIndex: 0,
|
|
2253
|
+
pageSize: e.pageSize ?? 10,
|
|
2254
|
+
sort: [],
|
|
2255
|
+
filter: se
|
|
2256
|
+
}), [x, S] = p({}), [C, w] = p(e.expandAll ?? !1 ? !0 : {}), [T, E] = p(""), [D, O] = p(!1), [k, A] = p("");
|
|
2257
|
+
s(() => {
|
|
2258
|
+
if (!k) return;
|
|
2259
|
+
let e = setTimeout(() => A(""), 2500);
|
|
2260
|
+
return () => clearTimeout(e);
|
|
2261
|
+
}, [k]);
|
|
2262
|
+
let [j, M] = p(null), [N, P] = p(null), [F, I] = p(null), L = d(() => (e.columns ?? Object.keys(e.data?.[0] ?? {}).filter((e) => !e.startsWith("_auto_")).map((e) => ({
|
|
2263
|
+
key: e,
|
|
2264
|
+
label: e
|
|
2265
|
+
}))).filter((e) => r.canAccess(e)), [
|
|
2266
|
+
e.columns,
|
|
2267
|
+
e.data,
|
|
2268
|
+
r
|
|
2269
|
+
]), R = L.map((e) => e.key), { settings: z, update: B, error: te, retry: ne } = Re(i, R, e.versions, {
|
|
2270
|
+
hidden: L.filter((e) => e.hidden).map((e) => e.key),
|
|
2271
|
+
pin: Object.fromEntries(L.filter((e) => e.pin).map((e) => [e.key, e.pin]))
|
|
2272
|
+
}), V = $(z.layout), H = e.size ?? r.table?.size ?? r.size ?? "medium", ae = r.table?.density ?? (r.density === "compact" ? "compact" : "normal"), oe = e.density ?? (V.density === "inherit" ? ae : V.density), U = e.query ?? {
|
|
2273
|
+
...v,
|
|
2274
|
+
sort: $(z.sort),
|
|
2275
|
+
filter: $(z.filter)
|
|
2276
|
+
};
|
|
2277
|
+
function G(t) {
|
|
2278
|
+
let n = {
|
|
2279
|
+
...U,
|
|
2280
|
+
...t
|
|
2281
|
+
};
|
|
2282
|
+
y(n), e.onQueryChange?.(n), e.query === void 0 && (t.sort || t.filter) && B({
|
|
2283
|
+
...z,
|
|
2284
|
+
sort: t.sort ? Ie(z.sort, t.sort) : z.sort,
|
|
2285
|
+
filter: t.filter ? Ie(z.filter, t.filter) : z.filter
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
let K = Ne(e.data, e.dataSource, U), q = d(() => e.dataSource ? Array.from(K.rows) : K.rows.filter((e) => ce(e, U.filter)), [
|
|
2289
|
+
K.rows,
|
|
2290
|
+
e.dataSource,
|
|
2291
|
+
U.filter
|
|
2292
|
+
]), J = d(() => {
|
|
2293
|
+
let e = [.../* @__PURE__ */ new Set([...V.order, ...R])].flatMap((e) => {
|
|
2294
|
+
let t = L.find((t) => t.key === e);
|
|
2295
|
+
return t && !V.hidden.includes(e) ? [t] : [];
|
|
2296
|
+
});
|
|
2297
|
+
return [
|
|
2298
|
+
...e.filter((e) => V.pin[e.key] === "left"),
|
|
2299
|
+
...e.filter((e) => !V.pin[e.key]),
|
|
2300
|
+
...e.filter((e) => V.pin[e.key] === "right")
|
|
2301
|
+
];
|
|
2302
|
+
}, [L, V]), le = d(() => L.map((e) => ({
|
|
2303
|
+
id: e.key,
|
|
2304
|
+
accessorFn: (t) => t[e.key],
|
|
2305
|
+
header: e.label ?? e.key,
|
|
2306
|
+
enableSorting: e.sortable ?? !0,
|
|
2307
|
+
...e.sort ? { sortFn: (t, n) => e.sort(t.original, n.original) } : {}
|
|
2308
|
+
})), [L]), ue = (e) => typeof a == "function" ? a(e) : String(e[a]), Z = f(/* @__PURE__ */ new Map()), de = /* @__PURE__ */ new Map();
|
|
2309
|
+
function fe(t) {
|
|
2310
|
+
for (let n of t) {
|
|
2311
|
+
de.set(ue(n), n);
|
|
2312
|
+
let t = e.getChildren?.(n);
|
|
2313
|
+
t && fe(t);
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
fe(K.rows);
|
|
2317
|
+
function pe(t) {
|
|
2318
|
+
return Object.keys(t).flatMap((t) => {
|
|
2319
|
+
let n = de.get(t) ?? (e.dataSource ? Z.current.get(t) : void 0);
|
|
2320
|
+
return n ? [n] : [];
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
function me(t) {
|
|
2324
|
+
let n = pe(t);
|
|
2325
|
+
Z.current = new Map(n.map((e) => [ue(e), e])), S(t), e.onSelectionChange?.(n);
|
|
2326
|
+
}
|
|
2327
|
+
let ge = re({
|
|
2328
|
+
features: Me,
|
|
2329
|
+
data: q,
|
|
2330
|
+
columns: le,
|
|
2331
|
+
getRowId: ue,
|
|
2332
|
+
getSubRows: e.getChildren,
|
|
2333
|
+
getRowCanExpand: (t) => !!e.renderExpanded || !!e.getChildren?.(t.original)?.length,
|
|
2334
|
+
manualSorting: !!e.dataSource,
|
|
2335
|
+
manualPagination: !!e.dataSource || !m,
|
|
2336
|
+
rowCount: K.total,
|
|
2337
|
+
state: {
|
|
2338
|
+
sorting: U.sort,
|
|
2339
|
+
pagination: {
|
|
2340
|
+
pageIndex: U.pageIndex,
|
|
2341
|
+
pageSize: U.pageSize
|
|
2342
|
+
},
|
|
2343
|
+
rowSelection: x,
|
|
2344
|
+
expanded: C
|
|
2345
|
+
},
|
|
2346
|
+
onSortingChange: (e) => G({
|
|
2347
|
+
sort: ee(e, U.sort),
|
|
2348
|
+
pageIndex: 0
|
|
2349
|
+
}),
|
|
2350
|
+
onPaginationChange: (e) => G(ee(e, {
|
|
2351
|
+
pageIndex: U.pageIndex,
|
|
2352
|
+
pageSize: U.pageSize
|
|
2353
|
+
})),
|
|
2354
|
+
onRowSelectionChange: (e) => {
|
|
2355
|
+
me(ee(e, x));
|
|
2356
|
+
},
|
|
2357
|
+
onExpandedChange: w,
|
|
2358
|
+
autoResetPageIndex: !1
|
|
2359
|
+
}), Q = ge.getRowModel().rows, _e = f(null), ve = e.virtual !== !1 && !J.some((e) => e.merge), be = e.rowHeight !== void 0 && oe === "normal" ? e.rowHeight : {
|
|
2360
|
+
small: {
|
|
2361
|
+
compact: 26,
|
|
2362
|
+
normal: 32,
|
|
2363
|
+
comfortable: 40
|
|
2364
|
+
},
|
|
2365
|
+
medium: {
|
|
2366
|
+
compact: 30,
|
|
2367
|
+
normal: 40,
|
|
2368
|
+
comfortable: 52
|
|
2369
|
+
},
|
|
2370
|
+
large: {
|
|
2371
|
+
compact: 36,
|
|
2372
|
+
normal: 48,
|
|
2373
|
+
comfortable: 60
|
|
2374
|
+
}
|
|
2375
|
+
}[H]?.[oe] ?? e.rowHeight ?? 40, xe = b({
|
|
2376
|
+
count: Q.length,
|
|
2377
|
+
getScrollElement: () => _e.current,
|
|
2378
|
+
getItemKey: (e) => Q[e].id,
|
|
2379
|
+
estimateSize: () => be,
|
|
2380
|
+
overscan: 5,
|
|
2381
|
+
enabled: ve,
|
|
2382
|
+
initialRect: {
|
|
2383
|
+
height: typeof c == "number" ? c : 0,
|
|
2384
|
+
width: 1e3
|
|
2385
|
+
}
|
|
2386
|
+
}), Se = pe(x), Ce = (e) => e === "selected" ? Se : e === "page" ? Q.map((e) => e.original) : ge.getPrePaginatedRowModel().rows.filter((e) => e.depth === 0).map((e) => e.original), [we, Te] = p(!1), Ee = f(null);
|
|
2387
|
+
s(() => () => Ee.current?.abort(), []);
|
|
2388
|
+
async function De(t, r = $(z.export).scope) {
|
|
2389
|
+
if (Ee.current) return;
|
|
2390
|
+
let i = new AbortController();
|
|
2391
|
+
Ee.current = i, Te(!0);
|
|
2392
|
+
try {
|
|
2393
|
+
let a = $(z.export), s = Ge(e.dataSource && r === "filtered" ? await Ye(e.dataSource, U, i.signal) : Ce(r), L, a.columns), c = a.fileName || o || n("数据导出");
|
|
2394
|
+
if (t === "xlsx") {
|
|
2395
|
+
if (!e.exportXlsx) throw Error(n("请配置 XLSX 导出适配器"));
|
|
2396
|
+
Je(await e.exportXlsx(s, { fileName: c }), `${c}.xlsx`, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
2397
|
+
} else Je(t === "csv" ? Ke(s) : qe(s), `${c}.${t}`, t === "csv" ? "text/csv;charset=utf-8" : "application/json");
|
|
2398
|
+
A(n("导出完成"));
|
|
2399
|
+
} catch (e) {
|
|
2400
|
+
i.signal.aborted || A(n(W(e)));
|
|
2401
|
+
} finally {
|
|
2402
|
+
Ee.current = null, i.signal.aborted || Te(!1);
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
l(e.ref, () => ({
|
|
2406
|
+
refresh: K.refresh,
|
|
2407
|
+
reset() {
|
|
2408
|
+
B(Fe(R)), me({});
|
|
2409
|
+
let t = {
|
|
2410
|
+
...U,
|
|
2411
|
+
pageIndex: 0,
|
|
2412
|
+
sort: [],
|
|
2413
|
+
filter: se
|
|
2414
|
+
};
|
|
2415
|
+
y(t), e.onQueryChange?.(t);
|
|
2416
|
+
},
|
|
2417
|
+
scrollToRow(e) {
|
|
2418
|
+
let t = Q.findIndex((t) => t.id === e);
|
|
2419
|
+
t >= 0 && (ve ? xe.scrollToIndex(t) : _e.current?.querySelector(`[data-row-id="${CSS.escape(e)}"]`)?.scrollIntoView({ block: "nearest" }));
|
|
2420
|
+
},
|
|
2421
|
+
getSelectedRows: () => Se,
|
|
2422
|
+
export: De
|
|
2423
|
+
}));
|
|
2424
|
+
let Oe = (e) => V.widths[e.key] ?? e.width ?? 150;
|
|
2425
|
+
function ke(e) {
|
|
2426
|
+
let t = V.pin[e.key], n = J.filter((e) => V.pin[e.key] === t), r = n.indexOf(e);
|
|
2427
|
+
return {
|
|
2428
|
+
width: Oe(e),
|
|
2429
|
+
minWidth: Oe(e),
|
|
2430
|
+
maxWidth: Oe(e),
|
|
2431
|
+
textAlign: e.align ?? "left",
|
|
2432
|
+
...t ? {
|
|
2433
|
+
position: "sticky",
|
|
2434
|
+
zIndex: 2,
|
|
2435
|
+
[t]: n.slice(t === "left" ? 0 : r + 1, t === "left" ? r : void 0).reduce((e, t) => e + Oe(t), 0) + (t === "left" ? 44 : 0),
|
|
2436
|
+
background: "var(--auto-bg)"
|
|
2437
|
+
} : {}
|
|
2438
|
+
};
|
|
2439
|
+
}
|
|
2440
|
+
let Ae = ve ? xe.getVirtualItems().map((e) => ({
|
|
2441
|
+
row: Q[e.index],
|
|
2442
|
+
index: e.index,
|
|
2443
|
+
virtual: e
|
|
2444
|
+
})) : Q.map((e, t) => ({
|
|
2445
|
+
row: e,
|
|
2446
|
+
index: t,
|
|
2447
|
+
virtual: void 0
|
|
2448
|
+
})), Pe = Ae.map(({ row: e }) => e.id).join("|");
|
|
2449
|
+
s(() => {
|
|
2450
|
+
if (!ve || !e.renderExpanded || !_e.current) return;
|
|
2451
|
+
let t = _e.current, n = Array.from(t.querySelectorAll("tr[data-row-id]")), r = () => {
|
|
2452
|
+
for (let e of n) {
|
|
2453
|
+
let t = e.nextElementSibling, n = t && t.dataset.expandedRowId === e.dataset.rowId ? t.getBoundingClientRect().height : 0;
|
|
2454
|
+
xe.resizeItem(Number(e.dataset.index), e.getBoundingClientRect().height + n);
|
|
2455
|
+
}
|
|
2456
|
+
}, i = new ResizeObserver(r);
|
|
2457
|
+
for (let e of n) i.observe(e), e.nextElementSibling?.dataset.expandedRowId && i.observe(e.nextElementSibling);
|
|
2458
|
+
return r(), () => i.disconnect();
|
|
2459
|
+
}, [
|
|
2460
|
+
ve,
|
|
2461
|
+
e.renderExpanded,
|
|
2462
|
+
Pe,
|
|
2463
|
+
C,
|
|
2464
|
+
be
|
|
2465
|
+
]);
|
|
2466
|
+
let Le = e.dataSource ? K.total : ge.getPrePaginatedRowModel().rows.length, ze = Math.max(1, Math.ceil(Le / U.pageSize));
|
|
2467
|
+
s(() => {
|
|
2468
|
+
if (!m || !K.resolved || K.loading || K.error) return;
|
|
2469
|
+
let e = Math.max(0, Math.min(U.pageIndex, ze - 1));
|
|
2470
|
+
e !== U.pageIndex && G({ pageIndex: e });
|
|
2471
|
+
}, [
|
|
2472
|
+
m,
|
|
2473
|
+
K.resolved,
|
|
2474
|
+
K.loading,
|
|
2475
|
+
K.error,
|
|
2476
|
+
ze,
|
|
2477
|
+
U.pageIndex
|
|
2478
|
+
]);
|
|
2479
|
+
let Be = J.length + 1 + (e.onEdit || e.onDelete ? 1 : 0);
|
|
2480
|
+
return /* @__PURE__ */ _("section", {
|
|
2481
|
+
className: "auto-root auto-table",
|
|
2482
|
+
"data-height": c === "auto" ? "auto" : "fixed",
|
|
2483
|
+
"data-virtual": ve,
|
|
2484
|
+
"data-size": H,
|
|
2485
|
+
"data-density": oe,
|
|
2486
|
+
"aria-label": o ?? i,
|
|
2487
|
+
children: [
|
|
2488
|
+
e.searchFields && /* @__PURE__ */ g(he, {
|
|
2489
|
+
size: H,
|
|
2490
|
+
...e.searchLayout,
|
|
2491
|
+
fields: e.searchFields,
|
|
2492
|
+
onSearch: (e) => G({
|
|
2493
|
+
filter: e,
|
|
2494
|
+
pageIndex: 0
|
|
2495
|
+
})
|
|
2496
|
+
}),
|
|
2497
|
+
/* @__PURE__ */ _("div", {
|
|
2498
|
+
className: "auto-toolbar",
|
|
2499
|
+
children: [/* @__PURE__ */ _("div", {
|
|
2500
|
+
className: "auto-actions",
|
|
2501
|
+
children: [
|
|
2502
|
+
o && /* @__PURE__ */ g("strong", { children: o }),
|
|
2503
|
+
/* @__PURE__ */ g("span", {
|
|
2504
|
+
className: "auto-muted",
|
|
2505
|
+
children: n("{0} 条记录", [Le.toLocaleString()])
|
|
2506
|
+
}),
|
|
2507
|
+
Se.length > 0 && /* @__PURE__ */ g("span", {
|
|
2508
|
+
className: "auto-badge",
|
|
2509
|
+
children: n("已选 {0} 项", [Se.length])
|
|
2510
|
+
}),
|
|
2511
|
+
e.toolbar
|
|
2512
|
+
]
|
|
2513
|
+
}), /* @__PURE__ */ _("div", {
|
|
2514
|
+
className: "auto-actions",
|
|
2515
|
+
children: [
|
|
2516
|
+
e.onAdd && /* @__PURE__ */ g("button", {
|
|
2517
|
+
className: "auto-primary",
|
|
2518
|
+
onClick: () => M({ kind: "add" }),
|
|
2519
|
+
children: n("新增")
|
|
2520
|
+
}),
|
|
2521
|
+
e.onDelete && Se.length > 0 && /* @__PURE__ */ g("button", {
|
|
2522
|
+
onClick: () => P(Se),
|
|
2523
|
+
children: n("删除所选")
|
|
2524
|
+
}),
|
|
2525
|
+
/* @__PURE__ */ g("button", {
|
|
2526
|
+
onClick: K.refresh,
|
|
2527
|
+
disabled: K.loading,
|
|
2528
|
+
children: n("刷新")
|
|
2529
|
+
}),
|
|
2530
|
+
/* @__PURE__ */ g("button", {
|
|
2531
|
+
onClick: () => I(structuredClone(z)),
|
|
2532
|
+
children: n("设置")
|
|
2533
|
+
}),
|
|
2534
|
+
/* @__PURE__ */ g("button", {
|
|
2535
|
+
disabled: we,
|
|
2536
|
+
onClick: () => void De($(z.export).format),
|
|
2537
|
+
children: n(we ? "导出中…" : "导出")
|
|
2538
|
+
}),
|
|
2539
|
+
/* @__PURE__ */ g("button", {
|
|
2540
|
+
onClick: () => O(!D),
|
|
2541
|
+
"aria-pressed": D,
|
|
2542
|
+
children: "JSON"
|
|
2543
|
+
})
|
|
2544
|
+
]
|
|
2545
|
+
})]
|
|
2546
|
+
}),
|
|
2547
|
+
U.sort.length > 0 && /* @__PURE__ */ g("div", {
|
|
2548
|
+
className: "auto-actions auto-sort-tags",
|
|
2549
|
+
children: U.sort.map((e) => /* @__PURE__ */ _("button", {
|
|
2550
|
+
onClick: () => G({
|
|
2551
|
+
sort: U.sort.filter((t) => t.id !== e.id),
|
|
2552
|
+
pageIndex: 0
|
|
2553
|
+
}),
|
|
2554
|
+
children: [
|
|
2555
|
+
L.find((t) => t.key === e.id)?.label ?? e.id,
|
|
2556
|
+
" ",
|
|
2557
|
+
e.desc ? "↓" : "↑",
|
|
2558
|
+
" ×"
|
|
2559
|
+
]
|
|
2560
|
+
}, e.id))
|
|
2561
|
+
}),
|
|
2562
|
+
K.error && /* @__PURE__ */ _("div", {
|
|
2563
|
+
role: "alert",
|
|
2564
|
+
className: "auto-error",
|
|
2565
|
+
children: [
|
|
2566
|
+
K.error,
|
|
2567
|
+
" ",
|
|
2568
|
+
/* @__PURE__ */ g("button", {
|
|
2569
|
+
onClick: K.refresh,
|
|
2570
|
+
children: n("重试")
|
|
2571
|
+
})
|
|
2572
|
+
]
|
|
2573
|
+
}),
|
|
2574
|
+
te && /* @__PURE__ */ _("div", {
|
|
2575
|
+
role: "alert",
|
|
2576
|
+
className: "auto-error",
|
|
2577
|
+
children: [
|
|
2578
|
+
n("配置保存失败:"),
|
|
2579
|
+
te,
|
|
2580
|
+
/* @__PURE__ */ g("button", {
|
|
2581
|
+
onClick: ne,
|
|
2582
|
+
children: n("重试保存")
|
|
2583
|
+
})
|
|
2584
|
+
]
|
|
2585
|
+
}),
|
|
2586
|
+
k && /* @__PURE__ */ _("div", {
|
|
2587
|
+
role: "status",
|
|
2588
|
+
className: "auto-notice",
|
|
2589
|
+
children: [k, /* @__PURE__ */ g("button", {
|
|
2590
|
+
"aria-label": n("关闭消息"),
|
|
2591
|
+
onClick: () => A(""),
|
|
2592
|
+
children: "×"
|
|
2593
|
+
})]
|
|
2594
|
+
}),
|
|
2595
|
+
D ? /* @__PURE__ */ _("div", {
|
|
2596
|
+
className: "auto-json",
|
|
2597
|
+
children: [/* @__PURE__ */ g("button", {
|
|
2598
|
+
onClick: () => void navigator.clipboard.writeText(JSON.stringify(Ce("page"), null, 2)).then(() => A(n("已复制"))).catch((e) => A(n(W(e)))),
|
|
2599
|
+
children: n("复制 JSON")
|
|
2600
|
+
}), /* @__PURE__ */ g("pre", { children: JSON.stringify(Ce("page"), null, 2) })]
|
|
2601
|
+
}) : /* @__PURE__ */ g("div", {
|
|
2602
|
+
ref: _e,
|
|
2603
|
+
className: "auto-table-scroll",
|
|
2604
|
+
style: {
|
|
2605
|
+
height: c === "auto" ? void 0 : c,
|
|
2606
|
+
overflow: "auto"
|
|
2607
|
+
},
|
|
2608
|
+
"aria-busy": K.loading,
|
|
2609
|
+
children: /* @__PURE__ */ _("table", {
|
|
2610
|
+
style: {
|
|
2611
|
+
minWidth: J.reduce((e, t) => e + Oe(t), 44),
|
|
2612
|
+
width: "100%",
|
|
2613
|
+
tableLayout: "fixed"
|
|
2614
|
+
},
|
|
2615
|
+
children: [
|
|
2616
|
+
/* @__PURE__ */ g(je, {
|
|
2617
|
+
columns: J,
|
|
2618
|
+
rows: K.rows,
|
|
2619
|
+
sort: U.sort,
|
|
2620
|
+
filter: U.filter,
|
|
2621
|
+
style: ke,
|
|
2622
|
+
hasActions: !!(e.onEdit || e.onDelete),
|
|
2623
|
+
allSelected: Q.length > 0 && Q.every((e) => x[e.id]),
|
|
2624
|
+
indeterminate: Q.length > 0 && Q.some((e) => x[e.id]) && !Q.every((e) => x[e.id]),
|
|
2625
|
+
onSelectAll: (e) => {
|
|
2626
|
+
let t = { ...x };
|
|
2627
|
+
Q.forEach((n) => {
|
|
2628
|
+
e ? t[n.id] = !0 : delete t[n.id];
|
|
2629
|
+
}), me(t);
|
|
2630
|
+
},
|
|
2631
|
+
onSort: (e) => G({
|
|
2632
|
+
sort: e,
|
|
2633
|
+
pageIndex: 0
|
|
2634
|
+
}),
|
|
2635
|
+
onFilter: (e) => G({
|
|
2636
|
+
filter: e,
|
|
2637
|
+
pageIndex: 0
|
|
2638
|
+
}),
|
|
2639
|
+
onResize: (e, t) => B({
|
|
2640
|
+
...z,
|
|
2641
|
+
layout: Ie(z.layout, {
|
|
2642
|
+
...V,
|
|
2643
|
+
widths: {
|
|
2644
|
+
...V.widths,
|
|
2645
|
+
[e]: t
|
|
2646
|
+
}
|
|
2647
|
+
})
|
|
2648
|
+
})
|
|
2649
|
+
}),
|
|
2650
|
+
/* @__PURE__ */ _("tbody", { children: [
|
|
2651
|
+
ve && Ae[0]?.virtual && Ae[0].virtual.start > 0 && /* @__PURE__ */ g("tr", {
|
|
2652
|
+
"aria-hidden": "true",
|
|
2653
|
+
children: /* @__PURE__ */ g("td", {
|
|
2654
|
+
colSpan: Be,
|
|
2655
|
+
style: {
|
|
2656
|
+
height: Ae[0].virtual.start,
|
|
2657
|
+
padding: 0,
|
|
2658
|
+
border: 0
|
|
2659
|
+
}
|
|
2660
|
+
})
|
|
2661
|
+
}),
|
|
2662
|
+
Ae.map(({ row: r, index: i, virtual: a }) => {
|
|
2663
|
+
let o = /* @__PURE__ */ _("tr", {
|
|
2664
|
+
"data-row-id": r.id,
|
|
2665
|
+
"data-index": i,
|
|
2666
|
+
ref: ve && !e.renderExpanded ? xe.measureElement : void 0,
|
|
2667
|
+
className: `${T === r.id ? "auto-current" : ""} ${e.rowClassName?.(r.original) ?? ""}`,
|
|
2668
|
+
style: {
|
|
2669
|
+
height: be,
|
|
2670
|
+
...e.rowStyle?.(r.original)
|
|
2671
|
+
},
|
|
2672
|
+
onClick: () => E(r.id),
|
|
2673
|
+
children: [
|
|
2674
|
+
/* @__PURE__ */ g("td", {
|
|
2675
|
+
className: "auto-table-cell-selection",
|
|
2676
|
+
children: /* @__PURE__ */ g("input", {
|
|
2677
|
+
type: "checkbox",
|
|
2678
|
+
"aria-label": n("选择行 {0}", [r.id]),
|
|
2679
|
+
checked: !!x[r.id],
|
|
2680
|
+
onChange: r.getToggleSelectedHandler()
|
|
2681
|
+
})
|
|
2682
|
+
}),
|
|
2683
|
+
J.map((t, a) => {
|
|
2684
|
+
let o = 1;
|
|
2685
|
+
if (t.merge) {
|
|
2686
|
+
let n = r.original[t.key];
|
|
2687
|
+
if (i > 0 && !(e.renderExpanded && Q[i - 1].getIsExpanded()) && Object.is(Q[i - 1].original[t.key], n)) return null;
|
|
2688
|
+
for (; i + o < Q.length && !(e.renderExpanded && Q[i + o - 1].getIsExpanded()) && Object.is(Q[i + o].original[t.key], n);) o++;
|
|
2689
|
+
}
|
|
2690
|
+
let s = r.original[t.key];
|
|
2691
|
+
return /* @__PURE__ */ g("td", {
|
|
2692
|
+
rowSpan: o,
|
|
2693
|
+
style: ke(t),
|
|
2694
|
+
tabIndex: 0,
|
|
2695
|
+
onDoubleClick: () => {
|
|
2696
|
+
t.copyable && navigator.clipboard.writeText(String(We(t, r.original))).then(() => A(n("已复制"))).catch((e) => A(n(W(e))));
|
|
2697
|
+
},
|
|
2698
|
+
children: /* @__PURE__ */ _("div", {
|
|
2699
|
+
className: "auto-cell",
|
|
2700
|
+
children: [a === 0 && r.getCanExpand() && /* @__PURE__ */ g("button", {
|
|
2701
|
+
className: "auto-expand",
|
|
2702
|
+
style: { marginLeft: r.depth * 16 },
|
|
2703
|
+
"aria-label": n("展开行 {0}", [r.id]),
|
|
2704
|
+
"aria-expanded": r.getIsExpanded(),
|
|
2705
|
+
onClick: r.getToggleExpandedHandler(),
|
|
2706
|
+
children: r.getIsExpanded() ? "−" : "+"
|
|
2707
|
+
}), e.rowLoading?.(r.original) ? /* @__PURE__ */ g("span", {
|
|
2708
|
+
className: "auto-skeleton",
|
|
2709
|
+
children: n("加载中…")
|
|
2710
|
+
}) : t.render ? t.render(s, r.original, i) : t.type === "progress" ? /* @__PURE__ */ g("progress", {
|
|
2711
|
+
value: Number(s ?? 0),
|
|
2712
|
+
max: 100
|
|
2713
|
+
}) : We(t, r.original)]
|
|
2714
|
+
})
|
|
2715
|
+
}, t.key);
|
|
2716
|
+
}),
|
|
2717
|
+
/* @__PURE__ */ g(h, { children: (e.onEdit || e.onDelete) && /* @__PURE__ */ g("td", { children: /* @__PURE__ */ _("div", {
|
|
2718
|
+
className: "auto-actions auto-row-actions",
|
|
2719
|
+
children: [e.onEdit && /* @__PURE__ */ g("button", {
|
|
2720
|
+
"aria-label": n("编辑行 {0}", [r.id]),
|
|
2721
|
+
onClick: () => M({
|
|
2722
|
+
kind: "edit",
|
|
2723
|
+
row: r.original
|
|
2724
|
+
}),
|
|
2725
|
+
children: n("编辑")
|
|
2726
|
+
}), e.onDelete && /* @__PURE__ */ g("button", {
|
|
2727
|
+
"aria-label": n("删除行 {0}", [r.id]),
|
|
2728
|
+
onClick: () => P([r.original]),
|
|
2729
|
+
children: n("删除")
|
|
2730
|
+
})]
|
|
2731
|
+
}) }) })
|
|
2732
|
+
]
|
|
2733
|
+
}, r.id);
|
|
2734
|
+
return /* @__PURE__ */ _(t, { children: [e.rowActions?.length ? /* @__PURE__ */ _(ie.Root, { children: [/* @__PURE__ */ g(ie.Trigger, {
|
|
2735
|
+
asChild: !0,
|
|
2736
|
+
children: o
|
|
2737
|
+
}), /* @__PURE__ */ g(ie.Portal, { children: /* @__PURE__ */ g(ie.Content, {
|
|
2738
|
+
className: "auto-popover auto-context-menu",
|
|
2739
|
+
children: e.rowActions.filter((e) => !e.hidden?.(r.original)).map((e) => /* @__PURE__ */ g(ie.Item, {
|
|
2740
|
+
disabled: e.disabled?.(r.original),
|
|
2741
|
+
onSelect: () => void Promise.resolve().then(() => e.onClick(r.original)).catch((e) => A(n(W(e)))),
|
|
2742
|
+
children: e.label
|
|
2743
|
+
}, e.id))
|
|
2744
|
+
}) })] }) : o, r.getIsExpanded() && e.renderExpanded && /* @__PURE__ */ g("tr", {
|
|
2745
|
+
"data-expanded-row-id": r.id,
|
|
2746
|
+
children: /* @__PURE__ */ g("td", {
|
|
2747
|
+
colSpan: Be,
|
|
2748
|
+
children: e.renderExpanded(r.original)
|
|
2749
|
+
})
|
|
2750
|
+
})] }, r.id);
|
|
2751
|
+
}),
|
|
2752
|
+
ve && Ae.length > 0 && /* @__PURE__ */ g("tr", {
|
|
2753
|
+
"aria-hidden": "true",
|
|
2754
|
+
children: /* @__PURE__ */ g("td", {
|
|
2755
|
+
colSpan: Be,
|
|
2756
|
+
style: {
|
|
2757
|
+
height: Math.max(0, xe.getTotalSize() - (Ae.at(-1)?.virtual?.end ?? 0)),
|
|
2758
|
+
padding: 0,
|
|
2759
|
+
border: 0
|
|
2760
|
+
}
|
|
2761
|
+
})
|
|
2762
|
+
}),
|
|
2763
|
+
!Q.length && /* @__PURE__ */ g("tr", { children: /* @__PURE__ */ g("td", {
|
|
2764
|
+
colSpan: Be,
|
|
2765
|
+
className: "auto-empty",
|
|
2766
|
+
children: e.empty ?? (K.loading ? n("正在加载…") : n("暂无数据"))
|
|
2767
|
+
}) })
|
|
2768
|
+
] }),
|
|
2769
|
+
J.some((e) => e.summary) && /* @__PURE__ */ g("tfoot", { children: /* @__PURE__ */ _("tr", { children: [
|
|
2770
|
+
/* @__PURE__ */ g("td", {
|
|
2771
|
+
className: "auto-table-cell-selection",
|
|
2772
|
+
children: n("合计")
|
|
2773
|
+
}),
|
|
2774
|
+
J.map((t) => /* @__PURE__ */ g("td", {
|
|
2775
|
+
style: ke(t),
|
|
2776
|
+
children: t.summary && e.dataSource && (e.summaryScope ?? "filtered") === "filtered" ? e.summaryValues?.[t.key] ?? "—" : typeof t.summary == "function" ? t.summary(Ce(e.summaryScope ?? "filtered")) : t.summary ? Ce(e.summaryScope ?? "filtered").reduce((e, n) => e + (Number(n[t.key]) || 0), 0) : ""
|
|
2777
|
+
}, t.key)),
|
|
2778
|
+
(e.onEdit || e.onDelete) && /* @__PURE__ */ g("td", {})
|
|
2779
|
+
] }) })
|
|
2780
|
+
]
|
|
2781
|
+
})
|
|
2782
|
+
}),
|
|
2783
|
+
m && /* @__PURE__ */ _("footer", {
|
|
2784
|
+
className: "auto-pagination",
|
|
2785
|
+
children: [/* @__PURE__ */ g("span", { children: n("第 {0} / {1} 页", [U.pageIndex + 1, ze]) }), /* @__PURE__ */ _("div", {
|
|
2786
|
+
className: "auto-actions",
|
|
2787
|
+
children: [
|
|
2788
|
+
/* @__PURE__ */ g("select", {
|
|
2789
|
+
"aria-label": n("每页条数"),
|
|
2790
|
+
value: U.pageSize,
|
|
2791
|
+
onChange: (e) => G({
|
|
2792
|
+
pageIndex: 0,
|
|
2793
|
+
pageSize: Number(e.target.value)
|
|
2794
|
+
}),
|
|
2795
|
+
children: [.../* @__PURE__ */ new Set([
|
|
2796
|
+
e.pageSize ?? 10,
|
|
2797
|
+
10,
|
|
2798
|
+
20,
|
|
2799
|
+
50,
|
|
2800
|
+
100
|
|
2801
|
+
])].sort((e, t) => e - t).map((e) => /* @__PURE__ */ g("option", {
|
|
2802
|
+
value: e,
|
|
2803
|
+
children: n("{0} 条 / 页", [e])
|
|
2804
|
+
}, e))
|
|
2805
|
+
}),
|
|
2806
|
+
/* @__PURE__ */ g("button", {
|
|
2807
|
+
"aria-label": n("上一页"),
|
|
2808
|
+
disabled: U.pageIndex === 0,
|
|
2809
|
+
onClick: () => G({ pageIndex: U.pageIndex - 1 }),
|
|
2810
|
+
children: "←"
|
|
2811
|
+
}),
|
|
2812
|
+
/* @__PURE__ */ g("button", {
|
|
2813
|
+
"aria-label": n("下一页"),
|
|
2814
|
+
disabled: U.pageIndex + 1 >= ze,
|
|
2815
|
+
onClick: () => G({ pageIndex: U.pageIndex + 1 }),
|
|
2816
|
+
children: "→"
|
|
2817
|
+
})
|
|
2818
|
+
]
|
|
2819
|
+
})]
|
|
2820
|
+
}),
|
|
2821
|
+
/* @__PURE__ */ g(ye, {
|
|
2822
|
+
open: !!F,
|
|
2823
|
+
onOpenChange: (e) => {
|
|
2824
|
+
e || I(null);
|
|
2825
|
+
},
|
|
2826
|
+
title: n("表格设置"),
|
|
2827
|
+
width: 760,
|
|
2828
|
+
content: F && /* @__PURE__ */ g(Ue, {
|
|
2829
|
+
value: F,
|
|
2830
|
+
columns: L,
|
|
2831
|
+
onChange: I
|
|
2832
|
+
}),
|
|
2833
|
+
onSubmit: () => {
|
|
2834
|
+
if (F) {
|
|
2835
|
+
B(F);
|
|
2836
|
+
let t = {
|
|
2837
|
+
...U,
|
|
2838
|
+
pageIndex: 0,
|
|
2839
|
+
sort: $(F.sort),
|
|
2840
|
+
filter: $(F.filter)
|
|
2841
|
+
};
|
|
2842
|
+
y(t), e.onQueryChange?.(t);
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
}),
|
|
2846
|
+
/* @__PURE__ */ g(ye, {
|
|
2847
|
+
open: !!j,
|
|
2848
|
+
onOpenChange: (e) => {
|
|
2849
|
+
e || M(null);
|
|
2850
|
+
},
|
|
2851
|
+
title: j?.kind === "add" ? n("新增记录") : n("编辑记录"),
|
|
2852
|
+
fields: e.formFields ?? L.map((e) => ({
|
|
2853
|
+
name: e.key,
|
|
2854
|
+
label: e.label,
|
|
2855
|
+
type: e.type === "number" ? "integer" : "input"
|
|
2856
|
+
})),
|
|
2857
|
+
defaultValue: j?.row,
|
|
2858
|
+
draftKey: `${i}:${j?.kind}:${j?.row ? ue(j.row) : "new"}`,
|
|
2859
|
+
showReset: !0,
|
|
2860
|
+
onSubmit: async (t) => {
|
|
2861
|
+
j?.kind === "add" ? await e.onAdd?.(t) : j?.row && await e.onEdit?.(j.row, t), K.refresh();
|
|
2862
|
+
}
|
|
2863
|
+
}),
|
|
2864
|
+
/* @__PURE__ */ g(ye, {
|
|
2865
|
+
open: !!N,
|
|
2866
|
+
onOpenChange: (e) => {
|
|
2867
|
+
e || P(null);
|
|
2868
|
+
},
|
|
2869
|
+
title: n("确认删除"),
|
|
2870
|
+
content: /* @__PURE__ */ g("p", { children: n("确定删除这 {0} 条记录?", [N?.length ?? 0]) }),
|
|
2871
|
+
confirmLabel: n("确认删除"),
|
|
2872
|
+
onSubmit: async () => {
|
|
2873
|
+
N && await e.onDelete?.(N), S({}), K.refresh();
|
|
2874
|
+
}
|
|
2875
|
+
})
|
|
2876
|
+
]
|
|
2877
|
+
});
|
|
2878
|
+
}
|
|
2879
|
+
//#endregion
|
|
2880
|
+
//#region src/components/AutoChat/useChatScroll.ts
|
|
2881
|
+
function Ze(t, n) {
|
|
2882
|
+
let r = e(20), i = n !== void 0 && n, a = f(null), o = f(null), s = f(t), c = f(null), [l, d] = p(!1), m;
|
|
2883
|
+
r[0] === i ? m = r[1] : (m = () => {
|
|
2884
|
+
let e = a.current;
|
|
2885
|
+
if (i || !e || !o.current) return;
|
|
2886
|
+
let t = e.getBoundingClientRect().top, n = Array.from(o.current.children).find((e) => e.getBoundingClientRect().bottom > t);
|
|
2887
|
+
c.current = n ? {
|
|
2888
|
+
id: n.dataset.chatId,
|
|
2889
|
+
top: n.getBoundingClientRect().top - t
|
|
2890
|
+
} : null;
|
|
2891
|
+
}, r[0] = i, r[1] = m);
|
|
2892
|
+
let h = m, g;
|
|
2893
|
+
r[2] === h ? g = r[3] : (g = () => {
|
|
2894
|
+
let e = a.current;
|
|
2895
|
+
e && (s.current = !0, e.scrollTop = e.scrollHeight, d(!1), h());
|
|
2896
|
+
}, r[2] = h, r[3] = g);
|
|
2897
|
+
let _ = g, v;
|
|
2898
|
+
r[4] !== t || r[5] !== h || r[6] !== i ? (v = () => {
|
|
2899
|
+
let e = a.current;
|
|
2900
|
+
if (e && e.clientHeight !== 0) {
|
|
2901
|
+
if (t && s.current) e.scrollTop = e.scrollHeight;
|
|
2902
|
+
else if (!i && c.current) {
|
|
2903
|
+
let t = c.current, n = Array.from(o.current?.children ?? []).find((e) => e.dataset.chatId === t.id);
|
|
2904
|
+
n && (e.scrollTop += n.getBoundingClientRect().top - e.getBoundingClientRect().top - t.top);
|
|
2905
|
+
}
|
|
2906
|
+
d(e.scrollHeight - e.scrollTop - e.clientHeight > 48), h();
|
|
2907
|
+
}
|
|
2908
|
+
}, r[4] = t, r[5] = h, r[6] = i, r[7] = v) : v = r[7];
|
|
2909
|
+
let y = v;
|
|
2910
|
+
u(y);
|
|
2911
|
+
let b, x;
|
|
2912
|
+
r[8] === y ? (b = r[9], x = r[10]) : (b = () => {
|
|
2913
|
+
if (typeof ResizeObserver > "u") return;
|
|
2914
|
+
let e = 0, t = new ResizeObserver(() => {
|
|
2915
|
+
cancelAnimationFrame(e), e = requestAnimationFrame(y);
|
|
2916
|
+
});
|
|
2917
|
+
return a.current && t.observe(a.current), o.current && t.observe(o.current), () => {
|
|
2918
|
+
t.disconnect(), cancelAnimationFrame(e);
|
|
2919
|
+
};
|
|
2920
|
+
}, x = [y], r[8] = y, r[9] = b, r[10] = x), u(b, x);
|
|
2921
|
+
let S;
|
|
2922
|
+
r[11] === h ? S = r[12] : (S = () => {
|
|
2923
|
+
let e = a.current;
|
|
2924
|
+
if (!e) return;
|
|
2925
|
+
let t = e.scrollHeight - e.scrollTop - e.clientHeight <= 48;
|
|
2926
|
+
s.current = t, d(!t), h();
|
|
2927
|
+
}, r[11] = h, r[12] = S);
|
|
2928
|
+
let C = S, w;
|
|
2929
|
+
r[13] === h ? w = r[14] : (w = () => {
|
|
2930
|
+
s.current = !1, h();
|
|
2931
|
+
}, r[13] = h, r[14] = w);
|
|
2932
|
+
let T = w, E;
|
|
2933
|
+
return r[15] !== C || r[16] !== T || r[17] !== _ || r[18] !== l ? (E = {
|
|
2934
|
+
viewport: a,
|
|
2935
|
+
content: o,
|
|
2936
|
+
following: s,
|
|
2937
|
+
showLatest: l,
|
|
2938
|
+
scrollToBottom: _,
|
|
2939
|
+
onScroll: C,
|
|
2940
|
+
pause: T
|
|
2941
|
+
}, r[15] = C, r[16] = T, r[17] = _, r[18] = l, r[19] = E) : E = r[19], E;
|
|
2942
|
+
}
|
|
2943
|
+
//#endregion
|
|
2944
|
+
//#region src/components/AutoChat/VirtualChatMessages.tsx
|
|
2945
|
+
function Qe({ messages: e, viewport: t, content: n, following: r, autoFollow: i, estimate: o, overscan: s, renderRow: c, ref: d }) {
|
|
2946
|
+
let [m, h] = p(0), _ = a((t) => e[t].id, [e]), v = b({
|
|
2947
|
+
count: e.length,
|
|
2948
|
+
getScrollElement: () => t.current,
|
|
2949
|
+
getItemKey: _,
|
|
2950
|
+
estimateSize: () => o,
|
|
2951
|
+
overscan: s,
|
|
2952
|
+
useAnimationFrameWithResizeObserver: !0,
|
|
2953
|
+
anchorTo: "end",
|
|
2954
|
+
followOnAppend: !1,
|
|
2955
|
+
scrollEndThreshold: i && r.current ? 1 : -1,
|
|
2956
|
+
scrollMargin: m,
|
|
2957
|
+
initialRect: {
|
|
2958
|
+
width: 800,
|
|
2959
|
+
height: 600
|
|
2960
|
+
},
|
|
2961
|
+
initialOffset: () => i ? Math.max(0, e.length * o - (t.current?.clientHeight || 600)) : 0
|
|
2962
|
+
});
|
|
2963
|
+
l(d, () => ({ scrollToIndex: (e) => v.scrollToIndex(e, { align: "start" }) }));
|
|
2964
|
+
let y = f({
|
|
2965
|
+
count: e.length,
|
|
2966
|
+
following: r.current
|
|
2967
|
+
});
|
|
2968
|
+
return u(() => {
|
|
2969
|
+
let a = t.current, o = n.current;
|
|
2970
|
+
if (a && o) {
|
|
2971
|
+
let e = o.getBoundingClientRect().top - a.getBoundingClientRect().top + a.scrollTop;
|
|
2972
|
+
Math.abs(e - m) > .5 && h(e);
|
|
2973
|
+
}
|
|
2974
|
+
let s = y.current;
|
|
2975
|
+
s.following && !r.current && a && v.scrollToOffset(a.scrollTop), i && r.current && e.length && s.count !== e.length && v.scrollToEnd(), y.current = {
|
|
2976
|
+
count: e.length,
|
|
2977
|
+
following: r.current
|
|
2978
|
+
};
|
|
2979
|
+
}), /* @__PURE__ */ g("div", {
|
|
2980
|
+
ref: n,
|
|
2981
|
+
className: "auto-chat-messages",
|
|
2982
|
+
"data-virtualized": "true",
|
|
2983
|
+
style: {
|
|
2984
|
+
height: v.getTotalSize(),
|
|
2985
|
+
position: "relative",
|
|
2986
|
+
display: "block",
|
|
2987
|
+
overflowAnchor: "none"
|
|
2988
|
+
},
|
|
2989
|
+
children: v.getVirtualItems().map((t) => /* @__PURE__ */ g("div", {
|
|
2990
|
+
"data-index": t.index,
|
|
2991
|
+
ref: v.measureElement,
|
|
2992
|
+
style: {
|
|
2993
|
+
position: "absolute",
|
|
2994
|
+
display: "flex",
|
|
2995
|
+
flexDirection: "column",
|
|
2996
|
+
top: 0,
|
|
2997
|
+
left: 0,
|
|
2998
|
+
width: "100%",
|
|
2999
|
+
transform: `translateY(${t.start - m}px)`,
|
|
3000
|
+
paddingBottom: "var(--auto-chat-gap, 16px)"
|
|
3001
|
+
},
|
|
3002
|
+
children: c(e[t.index], t.index)
|
|
3003
|
+
}, t.key))
|
|
3004
|
+
});
|
|
3005
|
+
}
|
|
3006
|
+
//#endregion
|
|
3007
|
+
//#region src/components/AutoChat/index.tsx
|
|
3008
|
+
var $e = {
|
|
3009
|
+
conversation: "Conversation",
|
|
3010
|
+
empty: "Start a conversation",
|
|
3011
|
+
placeholder: "Write a message…",
|
|
3012
|
+
composer: "Message",
|
|
3013
|
+
send: "Send",
|
|
3014
|
+
stop: "Stop",
|
|
3015
|
+
sending: "Sending…",
|
|
3016
|
+
generating: "Generating…",
|
|
3017
|
+
latest: "Back to latest",
|
|
3018
|
+
loadOlder: "Load earlier messages",
|
|
3019
|
+
loading: "Loading…",
|
|
3020
|
+
sendError: "Message could not be sent. Try again.",
|
|
3021
|
+
loadError: "Earlier messages could not be loaded. Try again.",
|
|
3022
|
+
user: "You",
|
|
3023
|
+
assistant: "Assistant",
|
|
3024
|
+
system: "System",
|
|
3025
|
+
tool: "Tool",
|
|
3026
|
+
error: "Error"
|
|
3027
|
+
};
|
|
3028
|
+
function et(t) {
|
|
3029
|
+
let n = e(3), r = t.conversationKey ?? "default", i;
|
|
3030
|
+
return n[0] !== t || n[1] !== r ? (i = /* @__PURE__ */ g(tt, { ...t }, r), n[0] = t, n[1] = r, n[2] = i) : i = n[2], i;
|
|
3031
|
+
}
|
|
3032
|
+
function tt({ messages: e, renderMessage: t, renderActions: n, header: r, footer: i, empty: a, height: o = "100%", className: u = "", style: d, size: m, density: h, messageLayout: v = "role", labels: y, autoFollow: b = !0, virtual: x = !1, estimatedMessageHeight: S = 120, overscan: C = 6, composer: w = !0, value: T, defaultValue: E = "", onValueChange: D, onSend: O, onSendError: k, onStop: A, generating: j = !1, disabled: M = !1, sendOnEnter: N = !0, composerExtra: P, hasMore: F = !1, loadingOlder: I = !1, onLoadOlder: L, onLoadError: R, ref: ee }) {
|
|
3033
|
+
let z = Y(), B = Object.fromEntries(Object.entries($e).map(([e, t]) => [e, y?.[e] ?? z.t(`chat.${e}`, t)])), [te, ne] = p(E), V = T ?? te, re = f(V);
|
|
3034
|
+
re.current = V;
|
|
3035
|
+
let [ie, H] = p(!1), [ae, oe] = p(!1), [U, W] = p(!1), [G, se] = p(!1), K = f(!1), ce = f(!1), q = f(!0), J = f(!1), le = f(null), ue = c(), X = f(null), Z = Ze(b, x);
|
|
3036
|
+
s(() => (q.current = !0, () => {
|
|
3037
|
+
q.current = !1;
|
|
3038
|
+
}), []), l(ee, () => ({
|
|
3039
|
+
scrollToBottom: Z.scrollToBottom,
|
|
3040
|
+
scrollToMessage: (t) => {
|
|
3041
|
+
let n = e.findIndex((e) => e.id === t);
|
|
3042
|
+
if (n < 0) return !1;
|
|
3043
|
+
if (Z.pause(), x) X.current?.scrollToIndex(n);
|
|
3044
|
+
else {
|
|
3045
|
+
let e = Z.content.current?.children[n], t = Z.viewport.current;
|
|
3046
|
+
e && t && (t.scrollTop += e.getBoundingClientRect().top - t.getBoundingClientRect().top);
|
|
3047
|
+
}
|
|
3048
|
+
return !0;
|
|
3049
|
+
},
|
|
3050
|
+
focusComposer: () => le.current?.focus(),
|
|
3051
|
+
getScrollElement: () => Z.viewport.current
|
|
3052
|
+
}));
|
|
3053
|
+
let de = (e) => {
|
|
3054
|
+
T === void 0 && (re.current = e, ne(e)), D?.(e), W(!1);
|
|
3055
|
+
}, fe = async () => {
|
|
3056
|
+
if (!O || M || j || K.current || !re.current.trim()) return;
|
|
3057
|
+
let e = re.current;
|
|
3058
|
+
K.current = !0, H(!0), W(!1);
|
|
3059
|
+
try {
|
|
3060
|
+
await O(e), q.current && re.current === e && de("");
|
|
3061
|
+
} catch (e) {
|
|
3062
|
+
q.current && (W(!0), k?.(e));
|
|
3063
|
+
} finally {
|
|
3064
|
+
K.current = !1, q.current && H(!1);
|
|
3065
|
+
}
|
|
3066
|
+
}, pe = async () => {
|
|
3067
|
+
if (!(!L || ce.current || I)) {
|
|
3068
|
+
ce.current = !0, oe(!0), se(!1), Z.pause();
|
|
3069
|
+
try {
|
|
3070
|
+
await L();
|
|
3071
|
+
} catch (e) {
|
|
3072
|
+
q.current && (se(!0), R?.(e));
|
|
3073
|
+
} finally {
|
|
3074
|
+
ce.current = !1, q.current && oe(!1);
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
}, me = (e, r) => /* @__PURE__ */ _("article", {
|
|
3078
|
+
"data-chat-id": e.id,
|
|
3079
|
+
className: "auto-chat-message",
|
|
3080
|
+
"data-role": e.role,
|
|
3081
|
+
"aria-busy": e.streaming || void 0,
|
|
3082
|
+
children: [e.avatar != null && /* @__PURE__ */ g("div", {
|
|
3083
|
+
className: "auto-chat-avatar",
|
|
3084
|
+
children: e.avatar
|
|
3085
|
+
}), /* @__PURE__ */ _("div", {
|
|
3086
|
+
className: "auto-chat-message-main",
|
|
3087
|
+
children: [
|
|
3088
|
+
/* @__PURE__ */ _("div", {
|
|
3089
|
+
className: "auto-chat-message-meta",
|
|
3090
|
+
children: [
|
|
3091
|
+
/* @__PURE__ */ g("strong", { children: e.author ?? B[e.role] }),
|
|
3092
|
+
e.meta,
|
|
3093
|
+
e.streaming && /* @__PURE__ */ g("span", {
|
|
3094
|
+
className: "auto-chat-streaming",
|
|
3095
|
+
"aria-label": B.generating,
|
|
3096
|
+
children: "●"
|
|
3097
|
+
})
|
|
3098
|
+
]
|
|
3099
|
+
}),
|
|
3100
|
+
/* @__PURE__ */ g("div", {
|
|
3101
|
+
className: "auto-chat-message-body",
|
|
3102
|
+
children: t ? t(e, { index: r }) : typeof e.content == "string" ? /* @__PURE__ */ g("div", {
|
|
3103
|
+
className: "auto-chat-text",
|
|
3104
|
+
children: e.content
|
|
3105
|
+
}) : e.content
|
|
3106
|
+
}),
|
|
3107
|
+
n && /* @__PURE__ */ g("div", {
|
|
3108
|
+
className: "auto-chat-message-actions",
|
|
3109
|
+
children: n(e, { index: r })
|
|
3110
|
+
})
|
|
3111
|
+
]
|
|
3112
|
+
})]
|
|
3113
|
+
}, e.id);
|
|
3114
|
+
return /* @__PURE__ */ _("section", {
|
|
3115
|
+
className: `auto-root auto-chat ${u}`.trim(),
|
|
3116
|
+
style: {
|
|
3117
|
+
height: o,
|
|
3118
|
+
...d
|
|
3119
|
+
},
|
|
3120
|
+
"data-size": m ?? z.size,
|
|
3121
|
+
"data-density": h ?? z.density,
|
|
3122
|
+
"data-message-layout": v,
|
|
3123
|
+
"aria-label": B.conversation,
|
|
3124
|
+
children: [
|
|
3125
|
+
r != null && /* @__PURE__ */ g("header", {
|
|
3126
|
+
className: "auto-chat-header",
|
|
3127
|
+
children: r
|
|
3128
|
+
}),
|
|
3129
|
+
/* @__PURE__ */ _("div", {
|
|
3130
|
+
className: "auto-chat-history-shell",
|
|
3131
|
+
children: [/* @__PURE__ */ _("div", {
|
|
3132
|
+
ref: Z.viewport,
|
|
3133
|
+
className: "auto-chat-history",
|
|
3134
|
+
role: "log",
|
|
3135
|
+
"aria-label": B.conversation,
|
|
3136
|
+
"aria-live": "off",
|
|
3137
|
+
tabIndex: 0,
|
|
3138
|
+
onScroll: Z.onScroll,
|
|
3139
|
+
onWheel: (e) => {
|
|
3140
|
+
e.deltaY < 0 && Z.pause();
|
|
3141
|
+
},
|
|
3142
|
+
children: [
|
|
3143
|
+
F && L && /* @__PURE__ */ g("div", {
|
|
3144
|
+
className: "auto-chat-history-start",
|
|
3145
|
+
children: /* @__PURE__ */ g("button", {
|
|
3146
|
+
type: "button",
|
|
3147
|
+
onClick: () => {
|
|
3148
|
+
pe();
|
|
3149
|
+
},
|
|
3150
|
+
disabled: ae || I,
|
|
3151
|
+
children: ae || I ? B.loading : B.loadOlder
|
|
3152
|
+
})
|
|
3153
|
+
}),
|
|
3154
|
+
G && /* @__PURE__ */ g("p", {
|
|
3155
|
+
className: "auto-error",
|
|
3156
|
+
role: "alert",
|
|
3157
|
+
children: B.loadError
|
|
3158
|
+
}),
|
|
3159
|
+
!e.length && /* @__PURE__ */ g("div", {
|
|
3160
|
+
className: "auto-chat-empty",
|
|
3161
|
+
children: a ?? B.empty
|
|
3162
|
+
}),
|
|
3163
|
+
x ? /* @__PURE__ */ g(Qe, {
|
|
3164
|
+
ref: X,
|
|
3165
|
+
messages: e,
|
|
3166
|
+
viewport: Z.viewport,
|
|
3167
|
+
content: Z.content,
|
|
3168
|
+
following: Z.following,
|
|
3169
|
+
autoFollow: b,
|
|
3170
|
+
estimate: Math.max(24, S),
|
|
3171
|
+
overscan: Math.max(0, C),
|
|
3172
|
+
renderRow: me
|
|
3173
|
+
}) : /* @__PURE__ */ g("div", {
|
|
3174
|
+
ref: Z.content,
|
|
3175
|
+
className: "auto-chat-messages",
|
|
3176
|
+
children: e.map(me)
|
|
3177
|
+
})
|
|
3178
|
+
]
|
|
3179
|
+
}), Z.showLatest && /* @__PURE__ */ _("button", {
|
|
3180
|
+
type: "button",
|
|
3181
|
+
className: "auto-chat-latest",
|
|
3182
|
+
onClick: Z.scrollToBottom,
|
|
3183
|
+
children: [B.latest, " ↓"]
|
|
3184
|
+
})]
|
|
3185
|
+
}),
|
|
3186
|
+
/* @__PURE__ */ g("div", {
|
|
3187
|
+
className: "auto-chat-status",
|
|
3188
|
+
role: "status",
|
|
3189
|
+
children: j ? B.generating : ie ? B.sending : ""
|
|
3190
|
+
}),
|
|
3191
|
+
w && O && /* @__PURE__ */ _("form", {
|
|
3192
|
+
className: "auto-chat-composer",
|
|
3193
|
+
onSubmit: (e) => {
|
|
3194
|
+
e.preventDefault(), fe();
|
|
3195
|
+
},
|
|
3196
|
+
children: [
|
|
3197
|
+
/* @__PURE__ */ g("textarea", {
|
|
3198
|
+
ref: le,
|
|
3199
|
+
rows: 3,
|
|
3200
|
+
value: V,
|
|
3201
|
+
disabled: M,
|
|
3202
|
+
"aria-label": B.composer,
|
|
3203
|
+
placeholder: B.placeholder,
|
|
3204
|
+
"aria-describedby": U ? ue : void 0,
|
|
3205
|
+
onChange: (e) => de(e.target.value),
|
|
3206
|
+
onCompositionStart: () => {
|
|
3207
|
+
J.current = !0;
|
|
3208
|
+
},
|
|
3209
|
+
onCompositionEnd: () => {
|
|
3210
|
+
J.current = !1;
|
|
3211
|
+
},
|
|
3212
|
+
onKeyDown: (e) => {
|
|
3213
|
+
N && e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey && !J.current && !e.nativeEvent.isComposing && e.keyCode !== 229 && (e.preventDefault(), fe());
|
|
3214
|
+
}
|
|
3215
|
+
}),
|
|
3216
|
+
U && /* @__PURE__ */ g("p", {
|
|
3217
|
+
id: ue,
|
|
3218
|
+
className: "auto-error",
|
|
3219
|
+
role: "alert",
|
|
3220
|
+
children: B.sendError
|
|
3221
|
+
}),
|
|
3222
|
+
/* @__PURE__ */ _("div", {
|
|
3223
|
+
className: "auto-chat-composer-actions",
|
|
3224
|
+
children: [/* @__PURE__ */ g("div", { children: P }), j && A ? /* @__PURE__ */ g("button", {
|
|
3225
|
+
type: "button",
|
|
3226
|
+
onClick: A,
|
|
3227
|
+
disabled: M,
|
|
3228
|
+
children: B.stop
|
|
3229
|
+
}) : /* @__PURE__ */ g("button", {
|
|
3230
|
+
type: "submit",
|
|
3231
|
+
className: "auto-primary",
|
|
3232
|
+
disabled: M || ie || j || !V.trim(),
|
|
3233
|
+
children: ie ? B.sending : B.send
|
|
3234
|
+
})]
|
|
3235
|
+
})
|
|
3236
|
+
]
|
|
3237
|
+
}),
|
|
3238
|
+
i != null && /* @__PURE__ */ g("footer", {
|
|
3239
|
+
className: "auto-chat-footer",
|
|
3240
|
+
children: i
|
|
3241
|
+
})
|
|
3242
|
+
]
|
|
3243
|
+
});
|
|
3244
|
+
}
|
|
3245
|
+
//#endregion
|
|
3246
|
+
export { et as AutoChat, ue as AutoConfigProvider, ye as AutoDialog, _e as AutoDialogProvider, me as AutoForm, Oe as AutoMenu, he as AutoSearchPanel, Xe as AutoTable, xe as AutoTabs, $ as active, K as buildQuery, Ge as collectExport, ae as defaults, se as emptyQuery, G as equal, W as errorMessage, Fe as initialSettings, J as isQueryNode, ce as matchesQuery, oe as normalizeOptions, Le as reconcileSettings, Ie as replaceActive, H as resolve, U as safeStorage, q as serializeRsql, Ke as toCsv, qe as toJson, Y as useAutoConfig, ve as useAutoDialog };
|