@baishuyun/ui-base 6.28.2 → 6.29.1

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.
Files changed (45) hide show
  1. package/dist/Amap/index.js +1 -1
  2. package/dist/Calendar/{Calendar-DPF0ecD9.js → Calendar-cXOw65UG.js} +1 -1
  3. package/dist/Calendar/index.js +3 -3
  4. package/dist/Card/index.js +1 -1
  5. package/dist/CheckBox/index.js +1 -1
  6. package/dist/ColorPicker/index.js +1 -1
  7. package/dist/ConfigProvider/index.js +1 -1
  8. package/dist/DatePicker/{DatePicker-Hn_P6uYt.js → DatePicker-TimXurVT.js} +1 -1
  9. package/dist/DatePicker/{DatePickerPanel-Bl83l0FK.js → DatePickerPanel-CfnP7Cpa.js} +1 -1
  10. package/dist/DatePicker/index.js +2 -2
  11. package/dist/DropDown/index.js +1 -1
  12. package/dist/Editor/index.js +1 -1
  13. package/dist/FieldCard/index.js +1 -1
  14. package/dist/Gantt/index.js +2 -2
  15. package/dist/Icon/index.js +1 -1
  16. package/dist/InputTag/index.js +1 -1
  17. package/dist/Kanban/index.js +1 -1
  18. package/dist/Loading/index.js +1 -1
  19. package/dist/Modal/index.js +1 -1
  20. package/dist/NotFoundContent/index.js +1 -1
  21. package/dist/Overlay/index.js +1 -1
  22. package/dist/Radio/index.js +1 -1
  23. package/dist/ScrollBar/index.js +1 -1
  24. package/dist/Segmented/index.js +1 -1
  25. package/dist/Select/index.js +1 -1
  26. package/dist/Table/Table-BMqJZqBK.js +1169 -0
  27. package/dist/Table/index.js +4 -3
  28. package/dist/Tabs/index.js +1 -1
  29. package/dist/Tooltip/index.js +1 -1
  30. package/dist/Tree/index.js +1 -1
  31. package/dist/components/Table/HierarchyCell/HierarchyCell.d.ts +3 -0
  32. package/dist/components/Table/HierarchyCell/hierarchyTreeLayout.d.ts +27 -0
  33. package/dist/components/Table/HierarchyCell/index.d.ts +4 -0
  34. package/dist/components/Table/HierarchyCell/interface.d.ts +46 -0
  35. package/dist/components/Table/components/TableBody.d.ts +1 -40
  36. package/dist/components/Table/hooks/useTableVirtual.d.ts +5 -1
  37. package/dist/components/Table/index.d.ts +3 -2
  38. package/dist/components/Table/interface.d.ts +39 -0
  39. package/dist/components/Table/utils/tableUtils.d.ts +1 -1
  40. package/dist/components/index.d.ts +2 -1
  41. package/dist/index.js +6 -6
  42. package/dist/style.css +1 -1
  43. package/dist/vendors/{version-C6z7Jrt6.js → version-Foao691n.js} +1 -1
  44. package/package.json +1 -1
  45. package/dist/Table/Table-Cfj7bTb2.js +0 -881
@@ -1,881 +0,0 @@
1
- import { t as e } from "../vendors/useLocale-3oUjPb-k.js";
2
- import { t } from "../vendors/cssVars-UpriQzph.js";
3
- import { clamp as n, groupBy as r, sumBy as i } from "lodash-es";
4
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
5
- import s, { forwardRef as c, memo as l, useCallback as u, useEffect as d, useImperativeHandle as f, useLayoutEffect as p, useMemo as m, useRef as h, useState as g } from "react";
6
- import _ from "clsx";
7
- import { useEventListener as v, useLatest as y, useMemoizedFn as b, useSize as x } from "ahooks";
8
- import { useOverlayScrollbars as S } from "overlayscrollbars-react";
9
- import { useVirtualizer as C } from "@tanstack/react-virtual";
10
- //#region src/components/Table/constants.ts
11
- var w = {
12
- ROW_HEIGHT: 34,
13
- HEADER_HEIGHT: 34,
14
- EMPTY_TEXT_KEY: "table.empty"
15
- }, T = {
16
- MIN_HEIGHT: 34,
17
- MAX_HEIGHT: 200
18
- }, E = {
19
- DEFAULT_OVERSCAN: 10,
20
- ENABLE_AUTO_SIZE: 40
21
- }, D = {
22
- DEFAULT_WIDTH: 120,
23
- MIN_WIDTH: 60,
24
- MAX_WIDTH: 1e3
25
- }, O = {
26
- low: {
27
- className: "bsy-row-height-low",
28
- height: 34
29
- },
30
- middle: {
31
- className: "bsy-row-height-middle",
32
- height: 68
33
- },
34
- high: {
35
- className: "bsy-row-height-high",
36
- height: 106
37
- },
38
- auto: {
39
- className: "bsy-row-height-auto",
40
- height: "auto"
41
- }
42
- }, k = {
43
- ASC: "asc",
44
- DESC: "desc",
45
- NONE: null
46
- }, A = {
47
- wrapper: "custom-table-wrapper",
48
- body: "custom-table-body"
49
- }, j = (e = []) => e.flatMap((e) => e.children?.length ? e.children : [e]), M = (e, t) => t.findIndex((t) => e.isParent ? t.parentKey === e.key : t.key === e.key), N = (e, t, n, r = D.DEFAULT_WIDTH) => i(n === "left" ? t.slice(0, e) : t.slice(e + 1), (e) => e.width || r), P = (e, t, n) => n !== "left" && n !== "right" ? null : {
50
- position: "sticky",
51
- [n]: N(e, t, n),
52
- zIndex: 2
53
- }, F = (e, t, n, r) => {
54
- if (!t || !n) return e;
55
- let i = n === k.DESC ? -1 : 1;
56
- return [...e].sort((e, n) => {
57
- let a = e[t], o = n[t];
58
- return r ? r(a, o, e, n) * i : a === o ? 0 : a == null ? 1 : o == null ? -1 : typeof a == "string" && typeof o == "string" ? a.localeCompare(o) * i : (a < o ? -1 : 1) * i;
59
- });
60
- }, I = (e, t, n) => {
61
- let r = e[t];
62
- return typeof r == "string" || typeof r == "number" ? r : n;
63
- }, L = (e) => {
64
- let t = [], n = [], r = [];
65
- return e.forEach((e, i) => {
66
- let a = {
67
- ...e,
68
- index: i
69
- };
70
- e.fixed === "left" ? t.push(a) : e.fixed === "right" ? r.push(a) : n.push(a);
71
- }), {
72
- leftFixedColumns: t,
73
- normalColumns: n,
74
- rightFixedColumns: r
75
- };
76
- }, R = (e, t = D.DEFAULT_WIDTH) => i(e, (e) => e.children?.length ? i(e.children, (e) => e.width || t) : e.width || t), ee = (e, t) => {
77
- if (Object.keys(t).length === 0) return e;
78
- let n = (e) => {
79
- let r = !1, i = e.map((e) => {
80
- let i = e.children?.length ? n(e.children) : e.children, a = t[e.key];
81
- return i === e.children && (a === void 0 || a === e.width) ? e : (r = !0, {
82
- ...e,
83
- ...i === e.children ? null : { children: i },
84
- ...a === void 0 ? null : { width: a }
85
- });
86
- });
87
- return r ? i : e;
88
- };
89
- return n(e);
90
- }, te = (e, t) => {
91
- let n = L(e), r = R(e);
92
- return {
93
- ...n,
94
- fixedLeftWidth: R(n.leftFixedColumns),
95
- fixedRightWidth: R(n.rightFixedColumns),
96
- totalColumnsWidth: r,
97
- needSpacer: r < t
98
- };
99
- }, z = l(({ column: e, style: t = {}, className: n = "", onResizeStart: r, isResizing: i = !1, resizable: s = !0, colSpan: c = 1, rowSpan: l = 1 }) => {
100
- let d = h(null), f = u((e) => {
101
- d.current?.triggerClick?.(e);
102
- }, []), p = u((t) => {
103
- if (!s || !r) return;
104
- t.preventDefault(), t.stopPropagation();
105
- let n = (e) => {
106
- e.preventDefault(), e.stopPropagation();
107
- };
108
- document.addEventListener("click", n, !0), document.addEventListener("mouseup", () => {
109
- setTimeout(() => document.removeEventListener("click", n, !0), 0);
110
- }, { once: !0 }), r(e.key, e.width || D.DEFAULT_WIDTH, t.clientX);
111
- }, [
112
- e.key,
113
- e.width,
114
- s,
115
- r
116
- ]), m = typeof e.header == "function" ? e.header(e, { menuRef: d }) : e.title;
117
- return /* @__PURE__ */ o("th", {
118
- className: `custom-table-header-cell ${n} `,
119
- style: t,
120
- colSpan: c > 1 ? c : void 0,
121
- rowSpan: l > 1 ? l : void 0,
122
- onClick: f,
123
- children: [/* @__PURE__ */ a("div", {
124
- className: "header-cell-content",
125
- children: m
126
- }), s ? /* @__PURE__ */ a("div", {
127
- className: `resize-handle ${i ? "resizing" : ""}`,
128
- onMouseDown: p
129
- }) : null]
130
- });
131
- });
132
- z.displayName = "HeaderCell";
133
- //#endregion
134
- //#region src/components/Table/utils/flattenColumns.ts
135
- var B = (e) => {
136
- let t = [], n = [], r = (e, i = 0, a = null) => {
137
- t[i] || (t[i] = []), e.forEach((e) => {
138
- let o = e.children, s = e.fixed || a || void 0;
139
- if (o && o.length > 0) t[i].push({
140
- ...e,
141
- colSpan: o.length,
142
- rowSpan: 1,
143
- isParent: !0,
144
- fixed: s
145
- }), r(o, i + 1, s || null);
146
- else {
147
- let r = i + 1, a = {
148
- ...e,
149
- colSpan: 1,
150
- rowSpan: r,
151
- isLeaf: !0,
152
- fixed: s
153
- };
154
- t[i].push(a), n.push(a);
155
- }
156
- });
157
- };
158
- r(e);
159
- let i = [], a = t.length;
160
- for (let t = 0; t < a; t++) {
161
- let n = [], r = (e, i = 0, o = null) => {
162
- e.forEach((e) => {
163
- let s = e.children, c = e.fixed || o || void 0;
164
- s && s.length > 0 ? i === t ? n.push({
165
- ...e,
166
- colSpan: s.length,
167
- rowSpan: 1,
168
- isParent: !0,
169
- fixed: c
170
- }) : i < t && r(s, i + 1, c || null) : i === t && n.push({
171
- ...e,
172
- colSpan: 1,
173
- rowSpan: a - i,
174
- isLeaf: !0,
175
- fixed: c
176
- });
177
- });
178
- };
179
- r(e), i.push(n);
180
- }
181
- return {
182
- flatColumns: n,
183
- headerRows: i
184
- };
185
- }, V = c(({ columns: e = [], enableFixed: t = !1, height: n = w.HEADER_HEIGHT, resizingColumn: r = null, onResizeStart: i, resizable: s = !0, disabledResizeColumns: c = [], totalColumnsWidth: l = 0, needSpacer: u = !1, headerRowSpan: d = 1 }, f) => {
186
- let p = m(() => e.some((e) => e.children && e.children.length > 0), [e]), { flatColumns: h, headerRows: g } = m(() => {
187
- if (p) return B(e);
188
- let t = Math.max(1, d || 1);
189
- if (t > 1) {
190
- let n = [e.map((e) => ({
191
- ...e,
192
- colSpan: 1,
193
- rowSpan: t,
194
- isLeaf: !0
195
- }))];
196
- for (let e = 1; e < t; e++) n.push([]);
197
- return {
198
- flatColumns: e,
199
- headerRows: n
200
- };
201
- }
202
- return {
203
- flatColumns: e,
204
- headerRows: [e]
205
- };
206
- }, [
207
- e,
208
- p,
209
- d
210
- ]), _ = (e) => {
211
- let t = M(e, h), n = e.align || "left", o = c.includes(e.key), l = {
212
- textAlign: n,
213
- ...P(t, h, e.fixed)
214
- }, u = `custom-table-header-cell ${e.className || ""}`.trim();
215
- return e.fixed === "left" && (u += " fixed-left"), e.fixed === "right" && (u += " fixed-right"), t === 0 && (u += " first"), t === h.length - 1 && (u += " last"), /* @__PURE__ */ a(z, {
216
- column: e,
217
- style: l,
218
- className: u,
219
- onResizeStart: i,
220
- isResizing: r === e.key,
221
- resizable: s && !e.children && !o,
222
- colSpan: e.colSpan,
223
- rowSpan: e.rowSpan
224
- }, e.key);
225
- };
226
- return /* @__PURE__ */ a("div", {
227
- ref: f,
228
- className: "custom-table-header",
229
- style: m(() => {
230
- let e = { minWidth: l };
231
- return t && (e.position = "sticky", e.top = 0, e.zIndex = 11), e;
232
- }, [t, l]),
233
- children: /* @__PURE__ */ o("table", {
234
- style: {
235
- tableLayout: "fixed",
236
- minWidth: l
237
- },
238
- children: [/* @__PURE__ */ o("colgroup", { children: [h.map((e) => /* @__PURE__ */ a("col", { style: { width: e.width || D.DEFAULT_WIDTH } }, e.key)), u ? /* @__PURE__ */ a("col", {
239
- className: "spacer-col",
240
- style: { width: "auto" }
241
- }) : null] }), /* @__PURE__ */ a("thead", { children: g.map((e, t) => e.length === 0 ? /* @__PURE__ */ a("tr", { style: { height: n } }, t) : /* @__PURE__ */ o("tr", {
242
- style: { height: p || d > 1 ? n : "auto" },
243
- children: [e.map((e) => _(e)), u && t === 0 ? /* @__PURE__ */ a("th", {
244
- className: "custom-table-header-cell spacer-cell",
245
- rowSpan: g.length
246
- }) : null]
247
- }, t)) })]
248
- })
249
- });
250
- });
251
- V.displayName = "TableHeader";
252
- var ne = l(V), re = (e, t) => {
253
- let n = t.name, r = t.children || [], i = 0;
254
- for (let t = 0; t < e.length; t++) {
255
- let a = e[t], o = Object.keys(a);
256
- r.some((e) => {
257
- let t = `${n}.${e.subformField || e.key}.`;
258
- return o.some((e) => e.startsWith(t) && a[e] !== void 0 && a[e] !== "");
259
- }) && (i = t + 1);
260
- }
261
- return i;
262
- }, ie = (e, t, n = "_id") => {
263
- if (!e || e.length === 0) return [];
264
- let i = t.filter((e) => !!(e.children && e.children.length > 0));
265
- if (i.length === 0) return e.map((e) => ({
266
- ...e,
267
- _rowspan: {},
268
- _showMainFields: !0
269
- }));
270
- let a = r(e, (e) => String(e[n] || e._id || e.id)), o = {};
271
- Object.entries(a).forEach(([e, t]) => {
272
- let n = {};
273
- i.forEach((e) => {
274
- n[e.name] = re(t, e);
275
- }), o[e] = {
276
- groupSize: t.length,
277
- subformRowCounts: n
278
- };
279
- });
280
- let s = [], c = {};
281
- return e.forEach((e) => {
282
- let t = String(e[n] || e._id || e.id), r = o[t], a = c[t] ?? 0;
283
- c[t] = a + 1;
284
- let l = a === 0, u = {};
285
- i.forEach((e) => {
286
- u[e.key] = l ? r.groupSize : 0;
287
- }), u._mainFields = l ? r.groupSize : 0, s.push({
288
- ...e,
289
- _rowspan: u,
290
- _showMainFields: l,
291
- _groupIndex: a,
292
- _groupSize: r.groupSize,
293
- _subformRowCounts: r.subformRowCounts
294
- });
295
- }), s;
296
- }, H = (e, t) => {
297
- if (t.parentKey) return 1;
298
- if (e._rowspan && e._rowspan[t.key] !== void 0) {
299
- let n = e._rowspan[t.key];
300
- return n > 0 ? n : 0;
301
- }
302
- if (e._rowspan && e._rowspan._mainFields !== void 0) {
303
- let t = e._rowspan._mainFields;
304
- return t > 0 ? t : 0;
305
- }
306
- return 1;
307
- }, U = (e, t) => H(e, t) > 0, W = (e, t, n) => {
308
- let r = M(e, t), i = e.align || "left", a = P(r, t, n);
309
- return {
310
- column: e,
311
- className: _("custom-table-cell", {
312
- first: r === 0,
313
- fixed: !!n
314
- }, e.className, e?.type || "", e?.colorEnable ? "color-enable" : "", e?.regex === "barcode" ? "bar-code" : "", e?.regex === "qrcode" ? "qr-code" : ""),
315
- style: {
316
- textAlign: i,
317
- ...a
318
- }
319
- };
320
- }, G = ({ leftFixedColumns: e = [], normalColumns: t = [], rightFixedColumns: n = [], dataSource: r = [], rowKey: i = "id", rowHeight: s = w.ROW_HEIGHT, emptyText: c, onRowClick: l, onRow: d, onCell: f, totalColumnsWidth: p = 0, needSpacer: h = !1, rowRefCallback: g, isDynamicHeight: v = !1, emptyRowContent: y, showEmptyRow: b = !0, startVirtualIndex: x, hideWhenEmpty: S = !1, wrapperClassName: C, forceRowHeight: T = !1 }) => {
321
- let E = m(() => j(e), [e]), O = m(() => j(t), [t]), k = m(() => j(n), [n]), A = m(() => [
322
- ...E,
323
- ...O,
324
- ...k
325
- ], [
326
- E,
327
- O,
328
- k
329
- ]), M = m(() => {
330
- let e = E.map((e) => W(e, A, "left")), t = O.map((e) => W(e, A, void 0)), n = k.map((e) => W(e, A, "right"));
331
- return [
332
- ...e,
333
- ...t,
334
- ...n
335
- ];
336
- }, [
337
- A,
338
- E,
339
- O,
340
- k
341
- ]), N = u((e) => {
342
- e && g && g(e);
343
- }, [g]), P = (e, t, n) => {
344
- let { column: r, className: i, style: o } = e;
345
- if (!U(t, r)) return null;
346
- let s = H(t, r), c = r.dataIndex ? t[r.dataIndex] : void 0, l = r.render && typeof r.render == "function" ? r.render(c, t, n) : c, u = {
347
- className: i,
348
- style: o
349
- };
350
- return f && typeof f == "function" && (u = f(c, t, r, n, {
351
- className: i,
352
- style: o
353
- }) || {}), /* @__PURE__ */ a("td", {
354
- className: `${i} ${u.className || ""}`.trim(),
355
- style: { ...o },
356
- rowSpan: s > 1 ? s : void 0,
357
- ...u,
358
- children: /* @__PURE__ */ a("div", {
359
- className: _("cell-content", r.align),
360
- children: l
361
- })
362
- }, r.key);
363
- };
364
- if (S && r.length === 0) return null;
365
- let F = () => y ?? /* @__PURE__ */ a("tr", {
366
- className: "custom-table-empty-row",
367
- children: /* @__PURE__ */ a("td", {
368
- colSpan: A.length + (h ? 1 : 0),
369
- style: {
370
- textAlign: "center",
371
- padding: "20px",
372
- color: "#999"
373
- },
374
- children: c
375
- })
376
- }), L = T || !v;
377
- return /* @__PURE__ */ a("div", {
378
- className: _("custom-table-body", C),
379
- style: { minWidth: p },
380
- children: /* @__PURE__ */ o("table", {
381
- style: {
382
- tableLayout: "fixed",
383
- minWidth: p
384
- },
385
- children: [/* @__PURE__ */ o("colgroup", { children: [A.map((e) => /* @__PURE__ */ a("col", { style: { width: e.width || D.DEFAULT_WIDTH } }, e.key)), h ? /* @__PURE__ */ a("col", {
386
- className: "spacer-col",
387
- style: { width: "auto" }
388
- }) : null] }), /* @__PURE__ */ a("tbody", { children: r.length === 0 ? b ? F() : null : r.map((e, t) => {
389
- let n = {};
390
- if (d && typeof d == "function") {
391
- let r = d(e, t, {
392
- className: "",
393
- style: {}
394
- }) || {};
395
- n = {
396
- className: r.className,
397
- style: r.style,
398
- ...r
399
- };
400
- }
401
- let r = typeof x == "number" ? x + t : typeof e.dataIndex == "number" ? e.dataIndex : t;
402
- return /* @__PURE__ */ o("tr", {
403
- ref: v ? N : void 0,
404
- style: {
405
- height: L ? s : "auto",
406
- ...n.style
407
- },
408
- className: _("custom-table-row", n.className),
409
- onClick: (n) => l?.(e, t, n),
410
- "data-index": v ? r : void 0,
411
- ...n,
412
- children: [M.map((n) => P(n, e, t)), h ? /* @__PURE__ */ a("td", { className: "spacer-cell" }) : null]
413
- }, I(e, i, t));
414
- }) })]
415
- })
416
- });
417
- };
418
- G.displayName = "TableBody";
419
- var ae = l(G), K = ({ leftFixedColumns: e = [], normalColumns: t = [], rightFixedColumns: n = [], footerData: r = {}, summary: i, render: s, enableFixed: c = !0, totalColumnsWidth: l = 0, needSpacer: u = !1 }) => {
420
- let d = m(() => j(e), [e]), f = m(() => j(t), [t]), p = m(() => j(n), [n]), h = m(() => [
421
- ...d,
422
- ...f,
423
- ...p
424
- ], [
425
- d,
426
- f,
427
- p
428
- ]), g = (e) => {
429
- let t = (e.dataIndex ? r?.[e.dataIndex] : void 0) ?? i?.[e.key], { renderFooter: n } = e, o = n && typeof n == "function" ? n(t, e) : s && typeof s == "function" ? s(t, e) : t, l = { textAlign: e.align || "left" }, u = "custom-table-footer-cell";
430
- if (c && e.fixed) {
431
- let t = P(M(e, h), h, e.fixed);
432
- t && (l = {
433
- ...l,
434
- ...t
435
- }, u += e.fixed === "left" ? " fixed-left" : " fixed-right");
436
- }
437
- return /* @__PURE__ */ a("td", {
438
- className: u,
439
- style: l,
440
- children: /* @__PURE__ */ a("div", {
441
- className: "cell-content",
442
- children: o
443
- })
444
- }, e.key);
445
- };
446
- return /* @__PURE__ */ a("div", {
447
- className: "custom-table-footer",
448
- style: m(() => {
449
- let e = { minWidth: l };
450
- return c && (e.position = "sticky", e.bottom = 0, e.zIndex = 10), e;
451
- }, [c, l]),
452
- children: /* @__PURE__ */ o("table", {
453
- style: {
454
- tableLayout: "fixed",
455
- minWidth: l
456
- },
457
- children: [/* @__PURE__ */ o("colgroup", { children: [h.map((e) => /* @__PURE__ */ a("col", { style: { width: e.width || D.DEFAULT_WIDTH } }, e.key)), u ? /* @__PURE__ */ a("col", {
458
- className: "spacer-col",
459
- style: { width: "auto" }
460
- }) : null] }), /* @__PURE__ */ a("tfoot", { children: /* @__PURE__ */ o("tr", { children: [
461
- d.map((e) => g(e)),
462
- f.map((e) => g(e)),
463
- p.map((e) => g(e)),
464
- u ? /* @__PURE__ */ a("td", { className: "spacer-cell" }) : null
465
- ] }) })]
466
- })
467
- });
468
- };
469
- K.displayName = "TableFooter";
470
- var oe = l(K), se = [];
471
- function ce(e, t, r) {
472
- let i = y(e), a = y(t.estimateSize), o = t.rowHeight, s = t.minRowHeight || T.MIN_HEIGHT, c = t.maxRowHeight || T.MAX_HEIGHT, l = u((e) => {
473
- let t = i.current ?? [], r = a.current;
474
- if (typeof r == "function") return r(e, t[e]);
475
- let l = t[e];
476
- return l && typeof l.rowHeight == "number" ? n(l.rowHeight, s, c) : typeof o == "string" ? T.MIN_HEIGHT : n(typeof o == "function" ? o(e) : o || T.MIN_HEIGHT, s, c);
477
- }, [
478
- o,
479
- s,
480
- c,
481
- a,
482
- i
483
- ]), f = m(() => t.enabled === !0 ? !0 : t.enabled === !1 ? !1 : e.length > E.ENABLE_AUTO_SIZE, [t.enabled, e.length]), p = typeof o == "string", g = h(/* @__PURE__ */ new Map()), _ = h(null), v = m(() => {
484
- if (e.length === 0) return null;
485
- let t = e[0]?.uniqueId || e[0]?._id || e[0]?.id, n = e[e.length - 1]?.uniqueId || e[e.length - 1]?._id || e[e.length - 1]?.id;
486
- return `${String(t)}-${String(n)}-${e.length}`;
487
- }, [e]);
488
- d(() => {
489
- _.current !== null && _.current !== v && g.current.clear(), _.current = v;
490
- }, [v]), d(() => {
491
- let e = g.current;
492
- return () => {
493
- e.clear();
494
- };
495
- }, []);
496
- let x = u((e) => {
497
- let t = i.current ?? [];
498
- return t[e]?.uniqueId || t[e]?._id || t[e]?.id || `table-row-${e}`;
499
- }, [i]), S = C({
500
- count: f ? e.length : 0,
501
- getScrollElement: () => r.current,
502
- estimateSize: l,
503
- overscan: t.overscan ?? E.DEFAULT_OVERSCAN,
504
- enabled: f,
505
- measureElement: p ? (e) => {
506
- let t = e.getAttribute("data-index");
507
- if (!t) return T.MIN_HEIGHT;
508
- let n = g.current, r = n.get(t);
509
- if (r !== void 0) return r;
510
- let i = e.getBoundingClientRect().height, a = Math.max(T.MIN_HEIGHT, i);
511
- return n.set(t, a), a;
512
- } : void 0,
513
- getItemKey: x
514
- }), w = f ? S.getTotalSize() : 0, D = f ? S.getVirtualItems() : se, O = f && D.length > 0 && D[0].start || 0, k = f && D.length > 0 ? w - (D[D.length - 1].end || 0) : 0, A = b(() => {
515
- g.current.clear(), typeof S.measure == "function" && S.measure();
516
- }), j = b((e) => {
517
- if (e === void 0) {
518
- g.current.clear();
519
- return;
520
- }
521
- let t = Array.isArray(e) ? e : [e], n = g.current, r = i.current ?? [];
522
- t.forEach((e) => {
523
- if (typeof e == "number") n.delete(String(e));
524
- else {
525
- let t = r.findIndex((t) => t.uniqueId === e || t._id === e || t.id === e);
526
- t !== -1 && n.delete(String(t));
527
- }
528
- });
529
- });
530
- return {
531
- enabled: f,
532
- virtualRows: D,
533
- rowRefCallback: S.measureElement,
534
- totalHeight: w,
535
- paddingTop: O,
536
- paddingBottom: k,
537
- remeasure: A,
538
- clearRowHeightCache: j,
539
- isDynamicHeight: p
540
- };
541
- }
542
- function le(e, t, n, r) {
543
- let i = n ? t.map((t) => {
544
- let n = e[t.index];
545
- return n && {
546
- ...n,
547
- dataIndex: t.index
548
- };
549
- }) : e.map((e, t) => ({
550
- ...e,
551
- dataIndex: t
552
- }));
553
- return r ? r(i) : i;
554
- }
555
- //#endregion
556
- //#region src/components/Table/hooks/useColumnResize.ts
557
- function q(e = {}) {
558
- let { minColumnWidth: t = D.MIN_WIDTH, maxColumnWidth: r = D.MAX_WIDTH, onColumnResize: i, onColumnResizeEnd: a } = e, [o, s] = g(null), c = y(o), l = y(i), u = y(a), d = b((e, t, n) => {
559
- s({
560
- columnKey: e,
561
- startWidth: t,
562
- startX: n
563
- });
564
- }), f = (e, i) => n(i.startWidth + e - i.startX, t, r);
565
- return v("mousemove", (e) => {
566
- let t = c.current;
567
- t && l.current?.(e, t.columnKey, f(e.clientX, t));
568
- }, {
569
- target: document,
570
- enable: !!o
571
- }), v("mouseup", (e) => {
572
- let t = c.current;
573
- t && (u.current?.(t.columnKey, f(e.clientX, t)), s(null));
574
- }, {
575
- target: document,
576
- enable: !!o
577
- }), {
578
- isResizing: !!o,
579
- resizingColumn: o?.columnKey,
580
- startResize: d
581
- };
582
- }
583
- //#endregion
584
- //#region src/components/Table/hooks/useTableColumnWidths.ts
585
- var J = {};
586
- function ue({ columns: e, scrollRef: t, minColumnWidth: n, maxColumnWidth: r, onColumnResize: a, onColumnResizeEnd: o }) {
587
- let s = h(null), c = h(/* @__PURE__ */ new Map()), l = h(/* @__PURE__ */ new Map()), [u, f] = g(J), p = m(() => j(e), [e]), _ = m(() => ee(e, u), [e, u]), v = m(() => j(_), [_]);
588
- d(() => {
589
- let e = l.current, t = /* @__PURE__ */ new Map();
590
- for (let e of p) t.set(e.key, e.width || D.DEFAULT_WIDTH);
591
- f((n) => {
592
- let r = Object.keys(n);
593
- if (r.length === 0) return n;
594
- let i = !1, a = { ...n };
595
- for (let o of r) {
596
- let r = t.get(o);
597
- if (r === void 0) {
598
- delete a[o], i = !0;
599
- continue;
600
- }
601
- let s = e.get(o), c = s !== void 0 && s !== r;
602
- (r === n[o] || c) && (delete a[o], i = !0);
603
- }
604
- return i ? a : n;
605
- });
606
- for (let [n, r] of t) {
607
- let t = e.get(n), i = c.current.get(n);
608
- (i === void 0 || t !== void 0 && t !== r || i === r) && c.current.set(n, r);
609
- }
610
- l.current = t;
611
- }, [p]);
612
- let y = b((e) => c.current.get(e.key) || e.width || D.DEFAULT_WIDTH), x = b((e) => {
613
- let n = v.findIndex((t) => t.key === e);
614
- if (n === -1) return 0;
615
- let r = v[n], a = i(v.slice(0, n + 1), (e) => y(e));
616
- return r.fixed === "left" ? a : a - (t.current?.scrollLeft || 0);
617
- }), S = b((e) => {
618
- s.current && (s.current.style.display = "block", s.current.style.left = `${x(e)}px`);
619
- }), C = b((e, t) => {
620
- c.current.set(e, t), f((n) => n[e] === t ? n : {
621
- ...n,
622
- [e]: t
623
- });
624
- }), { isResizing: w, resizingColumn: T, startResize: E } = q({
625
- minColumnWidth: n || D.MIN_WIDTH,
626
- maxColumnWidth: r || D.MAX_WIDTH,
627
- onColumnResizeEnd: b((e, t) => {
628
- C(e, t), o?.(e, t, c.current), s.current && (s.current.style.display = "none");
629
- }),
630
- onColumnResize: b((e, t, n) => {
631
- C(t, n), a?.(t, n, c.current), S(t);
632
- })
633
- });
634
- return {
635
- sizedColumns: _,
636
- flatColumns: v,
637
- isResizing: w,
638
- resizingColumn: T,
639
- handleResizeStart: b((e, t, n) => {
640
- S(e), E(e, t, n);
641
- }),
642
- resizeHandleRef: s
643
- };
644
- }
645
- //#endregion
646
- //#region src/components/Table/hooks/useTableViewport.ts
647
- function de({ scrollRef: e, tableHeaderRef: t, bordered: n, hasFooter: r, headerRowSpan: i, dataSourceLength: a, overlayScrollbarOptions: o }) {
648
- let s = x(e), c = s?.width ?? 0, l = s?.height ?? 0, [u, d] = g(0), [f, h] = g(!1), [_, v] = g({
649
- left: 0,
650
- top: 0
651
- }), [y, b] = g(w.HEADER_HEIGHT), [C] = S({ options: {
652
- overflow: {
653
- x: o?.overflowX ?? "scroll",
654
- y: o?.overflowY ?? "scroll"
655
- },
656
- scrollbars: {
657
- theme: o?.theme ?? "os-theme-bsy",
658
- autoHide: o?.autoHide ?? "move",
659
- autoHideDelay: 400
660
- }
661
- } });
662
- return p(() => {
663
- if (!e.current) return;
664
- let t = e.current, n = t.parentElement;
665
- n && C({
666
- target: n,
667
- elements: { viewport: t }
668
- });
669
- }, [C]), p(() => {
670
- let n = e.current;
671
- n && (d(n.clientHeight), v({
672
- left: n.offsetLeft,
673
- top: n.offsetTop
674
- }), b(t.current?.clientHeight || w.HEADER_HEIGHT), h(n.scrollHeight > n.clientHeight));
675
- }, [
676
- s?.width,
677
- s?.height,
678
- a,
679
- r,
680
- i,
681
- e,
682
- t
683
- ]), {
684
- elementWidth: c,
685
- hasYScroll: f,
686
- scrollOffset: _,
687
- headerHeight: y,
688
- bodyMinHeight: m(() => {
689
- if (!l || !u) return;
690
- let e = n ? 2 : 0, t = u - y - (r ? w.HEADER_HEIGHT : 0) - e;
691
- return Math.max(0, t);
692
- }, [
693
- l,
694
- u,
695
- y,
696
- r,
697
- n
698
- ])
699
- };
700
- }
701
- //#endregion
702
- //#region src/components/Table/style/resolveTableThemeVars.ts
703
- var fe = (e) => {
704
- if (!e) return {};
705
- let n = {};
706
- return t(n, "--bsy-table-color-border", e.colorBorder), t(n, "--bsy-table-color-bg-header", e.colorBgHeader), t(n, "--bsy-table-color-bg-container", e.colorBgContainer), t(n, "--bsy-table-color-text", e.colorText), t(n, "--bsy-table-color-text-heading", e.colorTextHeading), t(n, "--bsy-table-color-bg-row-hover", e.colorBgRowHover), n;
707
- }, pe = [], me = {
708
- left: !0,
709
- right: !0
710
- }, Y = c(({ columns: t = [], dataSource: n = [], rowKey: r = "id", height: i, bordered: c = !0, emptyText: l, onRowClick: u, scroll: p, footerData: g, footerSummary: _, renderFooter: v, hasFooter: y = !1, onRow: b, onCell: x, rowHeightStyle: S = "low", resizable: C = !0, disabledResizeColumns: T = pe, minColumnWidth: D, maxColumnWidth: k, onColumnResize: A, onColumnResizeEnd: j, renderBody: M, estimateSize: N, virtualEnabled: P, dataProcessor: F, headerRowSpan: I, fixedShadowMask: L = me, onRenderEmpty: R, overlayScrollbarOptions: ee, wrapperStyle: z, theme: B }, V) => {
711
- let { t: re } = e(), ie = m(() => fe(B), [B]), H = h(null), U = h(null), { elementWidth: W, hasYScroll: G, scrollOffset: K, headerHeight: se, bodyMinHeight: q } = de({
712
- scrollRef: H,
713
- tableHeaderRef: U,
714
- bordered: c,
715
- hasFooter: y,
716
- headerRowSpan: I,
717
- dataSourceLength: n.length,
718
- overlayScrollbarOptions: ee
719
- }), { sizedColumns: J, flatColumns: Y, isResizing: he, resizingColumn: ge, handleResizeStart: _e, resizeHandleRef: ve } = ue({
720
- columns: t,
721
- scrollRef: H,
722
- minColumnWidth: D,
723
- maxColumnWidth: k,
724
- onColumnResize: A,
725
- onColumnResizeEnd: j
726
- }), { className: ye, height: X } = O[S] || O.auto, { virtualRows: be, totalHeight: xe, paddingTop: Se, paddingBottom: Ce, remeasure: Z, rowRefCallback: we, isDynamicHeight: Te, clearRowHeightCache: Ee, enabled: De } = ce(n, m(() => ({
727
- rowHeight: X,
728
- overscan: E.DEFAULT_OVERSCAN,
729
- estimateSize: N,
730
- ...P === void 0 ? {} : { enabled: P }
731
- }), [
732
- X,
733
- N,
734
- P
735
- ]), H);
736
- f(V, () => ({
737
- clearRowHeightCache: Ee,
738
- remeasure: Z
739
- }), [Ee, Z]);
740
- let Oe = l || re(w.EMPTY_TEXT_KEY);
741
- d(() => {
742
- Z?.();
743
- }, [X, Z]);
744
- let { leftFixedColumns: ke, normalColumns: Ae, rightFixedColumns: je, fixedLeftWidth: Me, fixedRightWidth: Ne, totalColumnsWidth: Q, needSpacer: $ } = m(() => te(J, W), [J, W]), Pe = m(() => le(n, be, De, F), [
745
- De,
746
- be,
747
- n,
748
- F
749
- ]), Fe = m(() => {
750
- let e = {};
751
- return c ? e.border = "1px solid var(--bsy-table-color-border, var(--bsy-base-border-color, #e0e0e0))" : e.border = "none", (i || p?.y) && (e.maxHeight = i || p?.y), e;
752
- }, [
753
- c,
754
- i,
755
- p
756
- ]), Ie = !!(i || p?.y), Le, Re, ze = !0;
757
- if (!M && n.length === 0 && typeof R == "function") {
758
- let e = R();
759
- s.isValidElement(e) && e.type === "tr" ? Le = e : e && (Re = e, ze = !1);
760
- }
761
- return /* @__PURE__ */ o("div", {
762
- className: `custom-table ${G ? "has-y-scroll" : ""}`,
763
- style: {
764
- position: "relative",
765
- height: "100%",
766
- ...ie
767
- },
768
- "data-overlayscrollbars-initialize": "",
769
- children: [
770
- /* @__PURE__ */ o("div", {
771
- ref: H,
772
- className: `custom-table-wrapper ${he ? "resizing" : ""} ${ye} os-enabled`,
773
- style: {
774
- ...Fe,
775
- ...z
776
- },
777
- children: [
778
- /* @__PURE__ */ a(ne, {
779
- ref: U,
780
- columns: J,
781
- enableFixed: Ie,
782
- height: w.HEADER_HEIGHT,
783
- resizingColumn: ge,
784
- onResizeStart: C ? _e : void 0,
785
- resizable: C,
786
- disabledResizeColumns: T,
787
- totalColumnsWidth: Q,
788
- needSpacer: $,
789
- headerRowSpan: I
790
- }),
791
- /* @__PURE__ */ a("div", {
792
- className: "custom-table-body-wrapper",
793
- style: { position: "relative" },
794
- children: /* @__PURE__ */ a("div", {
795
- style: {
796
- minHeight: q,
797
- height: xe,
798
- paddingBottom: Ce > 0 ? `${Ce}px` : void 0,
799
- paddingTop: Se > 0 ? `${Se}px` : void 0,
800
- position: "relative"
801
- },
802
- children: M ? M({
803
- columns: J,
804
- flatColumns: Y,
805
- leftFixedColumns: ke,
806
- normalColumns: Ae,
807
- rightFixedColumns: je,
808
- totalColumnsWidth: Q,
809
- needSpacer: $,
810
- rowRefCallback: we,
811
- isDynamicHeight: Te,
812
- rowHeight: X,
813
- onRowClick: u,
814
- scrollRef: H,
815
- virtualRows: be,
816
- virtualEnabled: De
817
- }) : /* @__PURE__ */ a(ae, {
818
- leftFixedColumns: ke,
819
- normalColumns: Ae,
820
- rightFixedColumns: je,
821
- dataSource: Pe,
822
- rowKey: r,
823
- rowHeight: X,
824
- emptyText: Oe,
825
- emptyRowContent: Le,
826
- showEmptyRow: ze,
827
- onRowClick: u,
828
- onRow: b,
829
- onCell: x,
830
- totalColumnsWidth: Q,
831
- needSpacer: $,
832
- rowRefCallback: we,
833
- isDynamicHeight: Te
834
- })
835
- })
836
- }),
837
- y && (g || _ || v) ? /* @__PURE__ */ a(oe, {
838
- leftFixedColumns: ke,
839
- normalColumns: Ae,
840
- rightFixedColumns: je,
841
- footerData: g,
842
- summary: _,
843
- render: v,
844
- enableFixed: Ie,
845
- totalColumnsWidth: Q,
846
- needSpacer: $
847
- }) : null
848
- ]
849
- }),
850
- Re ? /* @__PURE__ */ a("div", {
851
- className: "custom-table-empty-overlay",
852
- style: {
853
- height: q,
854
- left: K.left,
855
- top: K.top + se + (c ? 1 : 0),
856
- width: W || void 0
857
- },
858
- children: /* @__PURE__ */ a("div", {
859
- className: "custom-table-empty-overlay-inner",
860
- children: Re
861
- })
862
- }) : null,
863
- C ? /* @__PURE__ */ a("div", {
864
- className: "custom-table-resize-handle",
865
- ref: ve
866
- }) : null,
867
- L.left !== !1 && Me > 0 ? /* @__PURE__ */ a("div", {
868
- className: "fixed-shadow-mask left",
869
- style: { width: Me }
870
- }) : null,
871
- !$ && L.right !== !1 && Ne > 0 ? /* @__PURE__ */ a("div", {
872
- className: "fixed-shadow-mask right",
873
- style: { width: Ne }
874
- }) : null
875
- ]
876
- });
877
- });
878
- Y.displayName = "Table";
879
- var he = s.memo(Y);
880
- //#endregion
881
- export { A as _, ae as a, U as c, R as d, I as f, w as g, D as h, ce as i, N as l, L as m, fe as n, H as o, F as p, q as r, ie as s, he as t, j as u };