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