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