bj-web-components 0.2.12 → 0.2.14

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/README.md +38 -0
  2. package/dist/index.d.ts +585 -4
  3. package/dist/index.js +1 -1
  4. package/dist/index.mjs +45 -26
  5. package/dist/style.css +1 -1
  6. package/dist/web/BasicInput/BInput.js +1 -0
  7. package/dist/web/BasicInput/BInput.mjs +177 -0
  8. package/dist/web/BasicInput/utils.js +1 -0
  9. package/dist/web/BasicInput/utils.mjs +37 -0
  10. package/dist/web/CheckBox/BCheckBox.js +1 -0
  11. package/dist/web/CheckBox/BCheckBox.mjs +101 -0
  12. package/dist/web/CheckBox/Group.js +1 -0
  13. package/dist/web/CheckBox/Group.mjs +67 -0
  14. package/dist/web/CheckBox/context.js +1 -0
  15. package/dist/web/CheckBox/context.mjs +5 -0
  16. package/dist/web/CheckBox/index.js +1 -0
  17. package/dist/web/CheckBox/index.mjs +8 -0
  18. package/dist/web/Dropdown/BDropdown.js +1 -0
  19. package/dist/web/Dropdown/BDropdown.mjs +160 -0
  20. package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +1 -0
  21. package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +152 -0
  22. package/dist/web/Pagination/Pagination.js +1 -1
  23. package/dist/web/Pagination/Pagination.mjs +1 -1
  24. package/dist/web/ProductField/ProductField.mjs +12 -12
  25. package/dist/web/SkuInputCard/SkuInputCard.mjs +26 -26
  26. package/dist/web/Table/BTable.js +1 -0
  27. package/dist/web/Table/BTable.mjs +612 -0
  28. package/dist/web/Table/Column.js +1 -0
  29. package/dist/web/Table/Column.mjs +6 -0
  30. package/dist/web/Table/ColumnGroup.js +1 -0
  31. package/dist/web/Table/ColumnGroup.mjs +6 -0
  32. package/dist/web/Table/utils/columns.js +1 -0
  33. package/dist/web/Table/utils/columns.mjs +43 -0
  34. package/dist/web/Table/utils/sortFilter.js +1 -0
  35. package/dist/web/Table/utils/sortFilter.mjs +63 -0
  36. package/dist/web/Tabs/BTabs.js +1 -0
  37. package/dist/web/Tabs/BTabs.mjs +130 -0
  38. package/dist/web/Tabs/TabPane.js +1 -0
  39. package/dist/web/Tabs/TabPane.mjs +7 -0
  40. package/dist/web/Tooltip/ContentTooltip.js +1 -1
  41. package/dist/web/Tooltip/ContentTooltip.mjs +56 -20
  42. package/dist/web.d.ts +585 -4
  43. package/dist/web.js +1 -1
  44. package/dist/web.mjs +45 -26
  45. package/package.json +3 -3
@@ -0,0 +1,612 @@
1
+ import { jsxs as F, jsx as o } from "react/jsx-runtime";
2
+ import { useRef as ne, useMemo as W, useState as x, useEffect as J, createElement as De, isValidElement as wt } from "react";
3
+ import { createPortal as At } from "react-dom";
4
+ import qt from "../Pagination/Pagination.mjs";
5
+ import Ce from "../Icon/Icon.mjs";
6
+ /* empty css */
7
+ import Ht from "../Tooltip/ContentTooltip.mjs";
8
+ import Wt from "../Tooltip/TooltipWrapper.mjs";
9
+ import { BCheckBox as Ut } from "../CheckBox/index.mjs";
10
+ import { BDropdown as $t } from "../Dropdown/BDropdown.mjs";
11
+ import Gt from "../OverlayScrollbar/BOverlayScrollbar.mjs";
12
+ import Jt from "../SkuInputCard/spin_loading_red.gif.mjs";
13
+ import Qt from "../ProductField/no_data_light.png.mjs";
14
+ import Zt from "./Column.mjs";
15
+ import Xt from "./ColumnGroup.mjs";
16
+ import { getColumnKey as C, filterRecords as et, sortRecords as tt, renderColumnTitle as rt, getNextSortOrder as Yt, getSorterResult as er } from "./utils/sortFilter.mjs";
17
+ import { convertChildrenToColumns as tr, flattenColumns as rr, buildHeaderRows as ar } from "./utils/columns.mjs";
18
+ /* empty css */
19
+ const lr = 300;
20
+ function E(...u) {
21
+ return u.filter(Boolean).join(" ");
22
+ }
23
+ function sr(u, f) {
24
+ return f === void 0 ? void 0 : (Array.isArray(f) ? f : [f]).reduce((a, R) => {
25
+ if (!(a == null || typeof a != "object"))
26
+ return a[R];
27
+ }, u);
28
+ }
29
+ function U(u, f, p) {
30
+ if (typeof p == "function")
31
+ return p(u, f);
32
+ if (p) {
33
+ const a = u[String(p)];
34
+ if (typeof a == "string" || typeof a == "number")
35
+ return a;
36
+ }
37
+ return f;
38
+ }
39
+ function at(u, f) {
40
+ return Math.max(1, Math.ceil(u / f));
41
+ }
42
+ function ir(u) {
43
+ return !!(u && typeof u == "object" && !wt(u) && "props" in u);
44
+ }
45
+ function nr(u, f) {
46
+ return (typeof f.text == "string" || typeof f.text == "number" ? String(f.text) : String(f.value)).toLocaleLowerCase().includes(u.toLocaleLowerCase());
47
+ }
48
+ function lt({
49
+ checked: u,
50
+ disabled: f,
51
+ label: p,
52
+ name: a,
53
+ onChange: R,
54
+ type: $ = "checkbox"
55
+ }) {
56
+ return $ === "checkbox" ? /* @__PURE__ */ o(
57
+ Ut,
58
+ {
59
+ "aria-label": p,
60
+ checked: u,
61
+ className: "bj-table__selection-checkbox",
62
+ disabled: f,
63
+ name: a,
64
+ onChange: R,
65
+ skipGroup: !0
66
+ }
67
+ ) : /* @__PURE__ */ F("label", { className: E("bj-table__selection-control", u && "bj-table__selection-control--checked", f && "bj-table__selection-control--disabled"), children: [
68
+ /* @__PURE__ */ o(
69
+ "input",
70
+ {
71
+ "aria-label": p,
72
+ checked: u,
73
+ className: "bj-table__selection-input",
74
+ disabled: f,
75
+ name: a,
76
+ onChange: R,
77
+ type: $
78
+ }
79
+ ),
80
+ /* @__PURE__ */ o("span", { "aria-hidden": "true", className: "bj-table__selection-box", children: u && /* @__PURE__ */ o(Ce, { className: "bj-table__selection-check-icon", type: "icon-a-dagouxi" }) })
81
+ ] });
82
+ }
83
+ function dr({
84
+ columns: u,
85
+ dataSource: f = [],
86
+ rowKey: p,
87
+ rowSelection: a,
88
+ pagination: R = !1,
89
+ loading: $ = !1,
90
+ bordered: it = !0,
91
+ size: nt = "middle",
92
+ showHeader: dt = !0,
93
+ emptyText: de,
94
+ emptyImage: oe = Qt,
95
+ emptyHeight: ot,
96
+ t: Q = (re) => re,
97
+ className: ct,
98
+ style: bt,
99
+ rowClassName: ce,
100
+ sortDirections: ft = ["ascend", "descend", null],
101
+ onChange: be,
102
+ children: ke,
103
+ title: Pe,
104
+ footer: Oe,
105
+ summary: Re,
106
+ tableLayout: Be,
107
+ components: j,
108
+ onRow: fe,
109
+ onHeaderRow: he,
110
+ id: ht,
111
+ scroll: c,
112
+ locale: G
113
+ }) {
114
+ var Je, Qe, Ze;
115
+ const re = ne(null), Ee = ne(null), ae = W(
116
+ () => u ?? tr(ke),
117
+ [ke, u]
118
+ ), Z = W(() => rr(ae), [ae]), Me = W(() => ar(ae), [ae]), [ut, Ie] = x(
119
+ (a == null ? void 0 : a.defaultSelectedRowKeys) ?? []
120
+ ), [ue, le] = x(
121
+ R ? R.defaultCurrent ?? 1 : 1
122
+ ), [pt, _t] = x(
123
+ R ? R.defaultPageSize ?? 10 : 10
124
+ ), [gt, yt] = x(
125
+ () => new Map(Z.flatMap((e, t) => e.defaultSortOrder ? [[C(e, t), e.defaultSortOrder]] : []))
126
+ ), [jt, mt] = x(
127
+ () => new Map(Z.flatMap((e, t) => e.defaultFilteredValue === void 0 ? [] : [[C(e, t), e.defaultFilteredValue]]))
128
+ ), [M, q] = x(null), [ze, X] = x(/* @__PURE__ */ new Map()), [vt, se] = x(null), Nt = ne(`btable-${Math.random().toString(36).slice(2, 10)}`).current, [H, pe] = x(null), [_e, Te] = x(null), [ge, Ke] = x(""), [Y, Se] = x(""), [xt, ye] = x(), je = ne(0), l = R || void 0, K = (l == null ? void 0 : l.pageSize) ?? pt, k = (a == null ? void 0 : a.selectedRowKeys) ?? ut, m = Z, P = new Map(gt), B = new Map(jt);
129
+ m.forEach((e, t) => {
130
+ if ("children" in e) return;
131
+ const r = C(e, t);
132
+ e.sortOrder !== void 0 && P.set(r, e.sortOrder), e.filteredValue !== void 0 && B.set(r, e.filteredValue);
133
+ });
134
+ const Ve = W(
135
+ () => et(f, m, B),
136
+ [m, B, f]
137
+ ), S = W(
138
+ () => tt(Ve, m, P),
139
+ [m, Ve, P]
140
+ ), me = (l == null ? void 0 : l.total) ?? S.length, Le = at(me, K), I = Math.min((l == null ? void 0 : l.current) ?? ue, Le);
141
+ J(() => {
142
+ I !== ue && (l == null ? void 0 : l.current) === void 0 && le(I);
143
+ }, [I, l == null ? void 0 : l.current, ue]), J(() => {
144
+ if (!H || M === null) {
145
+ Te(null);
146
+ return;
147
+ }
148
+ const e = () => {
149
+ const t = H.getBoundingClientRect();
150
+ Te({ left: t.left, top: t.bottom + 8 });
151
+ };
152
+ return e(), document.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
153
+ document.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
154
+ };
155
+ }, [H, M]), J(() => {
156
+ if (M === null) return;
157
+ const e = (t) => {
158
+ const r = t.target;
159
+ H != null && H.contains(r) || r.closest(".bj-table__filter-dropdown") || (q(null), pe(null));
160
+ };
161
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
162
+ }, [H, M]), J(() => {
163
+ const e = window.setTimeout(
164
+ () => Se(ge.trim()),
165
+ lr
166
+ );
167
+ return () => window.clearTimeout(e);
168
+ }, [ge]), J(() => {
169
+ if (M === null) return;
170
+ const e = Z.find((r, n) => C(r, n) === M);
171
+ if (!e || "children" in e || !e.filterRequest) return;
172
+ const t = ++je.current;
173
+ Promise.resolve().then(() => e.filterRequest(Y)).then(
174
+ (r) => {
175
+ je.current === t && ye(r);
176
+ },
177
+ () => {
178
+ je.current === t && ye([]);
179
+ }
180
+ );
181
+ }, [Y, Z, M]);
182
+ const V = W(() => {
183
+ if (!l)
184
+ return S.map((t, r) => ({ record: t, index: r }));
185
+ const e = (I - 1) * K;
186
+ return S.slice(e, e + K).map((t, r) => ({
187
+ record: t,
188
+ index: e + r
189
+ }));
190
+ }, [I, K, l, S]), we = W(
191
+ () => V.map(({ record: e, index: t }) => U(e, t, p)),
192
+ [p, V]
193
+ ), Ft = k.map(String).join("|"), Dt = we.map(String).join("|");
194
+ J(() => {
195
+ var d;
196
+ if (!a || k.length === 0) return;
197
+ const e = new Set(we), t = k.filter((b) => e.has(b));
198
+ if (t.length === k.length) return;
199
+ a.selectedRowKeys === void 0 && Ie(t);
200
+ const r = new Set(t), n = V.filter(({ record: b, index: s }) => r.has(U(b, s, p))).map(({ record: b }) => b);
201
+ (d = a.onChange) == null || d.call(a, t, n, { type: "multiple" });
202
+ }, [a, p, Ft, Dt, V]);
203
+ const ve = (e, t = P, r = B, n = I) => {
204
+ const d = Object.fromEntries(r), b = et(f, m, r), s = tt(b, m, t);
205
+ be == null || be(
206
+ { ...l, current: n, pageSize: K, total: (l == null ? void 0 : l.total) ?? s.length },
207
+ d,
208
+ er(m, t),
209
+ { action: e, currentDataSource: s }
210
+ );
211
+ }, Ct = (e, t) => {
212
+ if (!e.sorter) return;
213
+ const r = C(e, t), n = Yt(P.get(r) ?? null, e.sortDirections ?? ft), d = /* @__PURE__ */ new Map();
214
+ d.set(r, n), e.sortOrder === void 0 && yt(d), ve("sort", d);
215
+ }, Ne = (e, t, r) => {
216
+ const n = C(e, t), d = new Map(B);
217
+ d.set(n, r), e.filteredValue === void 0 && mt(d), q(null), (l == null ? void 0 : l.current) === void 0 && le(1), ve("filter", P, d, 1);
218
+ }, kt = (e, t) => {
219
+ const r = C(e, t), n = e.filterResetToDefaultFilteredValue ? e.defaultFilteredValue ?? [] : [];
220
+ X((d) => new Map(d).set(r, n));
221
+ }, ie = (e, t, r) => {
222
+ var d, b, s, N;
223
+ const n = C(e, t);
224
+ if (M === n) {
225
+ q(null), pe(null), (d = e.onFilterDropdownOpenChange) == null || d.call(e, !1), (b = e.onFilterDropdownVisibleChange) == null || b.call(e, !1);
226
+ return;
227
+ }
228
+ Ke(""), Se(""), ye(void 0), X((_) => new Map(_).set(n, B.get(n) ?? [])), q(n), r && pe(r), (s = e.onFilterDropdownOpenChange) == null || s.call(e, !0), (N = e.onFilterDropdownVisibleChange) == null || N.call(e, !0);
229
+ }, Pt = (e, t) => {
230
+ var A, Xe;
231
+ const r = C(e, t), n = `bj-table-badge-${Nt}-${String(r).replace(/[^a-zA-Z0-9_-]/g, "-")}`, d = P.get(r) ?? null, b = B.get(r) ?? [], s = ze.get(r) ?? b, N = e.filterDropdownOpen ?? e.filterDropdownVisible ?? M === r, _ = e.filtered || b.length > 0, h = d === "ascend" ? "icon-a-zhengxumian" : d === "descend" ? "icon-a-daoxumian" : "icon-a-weipaixumian", L = rt(e.title, {
232
+ sortOrder: d,
233
+ sortColumn: d ? e : void 0,
234
+ sortColumns: d ? [{ column: e, order: d }] : [],
235
+ filters: Object.fromEntries(B)
236
+ }), w = typeof e.filterDropdown == "function" ? e.filterDropdown({
237
+ prefixCls: "bj-table",
238
+ selectedKeys: s.filter((i) => typeof i != "boolean"),
239
+ setSelectedKeys: (i) => X((g) => new Map(g).set(r, i)),
240
+ confirm: (i) => {
241
+ Ne(e, t, ze.get(r) ?? s), (i == null ? void 0 : i.closeDropdown) === !1 && q(r);
242
+ },
243
+ clearFilters: (i) => {
244
+ const g = e.filterResetToDefaultFilteredValue ? e.defaultFilteredValue ?? [] : [];
245
+ X((D) => new Map(D).set(r, g)), (i == null ? void 0 : i.confirm) === !0 && Ne(e, t, g), ((i == null ? void 0 : i.closeDropdown) === !1 || (i == null ? void 0 : i.confirm) !== !0) && q(r);
246
+ },
247
+ filters: e.filters,
248
+ close: () => q(null),
249
+ visible: N
250
+ }) : e.filterDropdown, O = e.filterRequest ? xt ?? [] : e.filters ?? [], y = Y && !e.filterRequest ? O.filter((i) => typeof e.filterSearch == "function" ? e.filterSearch(Y, i) : nr(Y, i)) : O, T = !!(e.filterSearch || e.filterRequest), v = /* @__PURE__ */ F("div", { className: E("bj-table__column-header", e.sorter && "bj-table__column-header--sortable"), children: [
251
+ e.badge !== void 0 && /* @__PURE__ */ o(
252
+ "span",
253
+ {
254
+ "aria-label": "表头提示",
255
+ className: "bj-table__column-badge-trigger",
256
+ id: n,
257
+ onBlur: () => se(null),
258
+ onClick: (i) => i.stopPropagation(),
259
+ onFocus: () => se(r),
260
+ onKeyDown: (i) => i.stopPropagation(),
261
+ onMouseEnter: () => se(r),
262
+ onMouseLeave: () => se(null),
263
+ role: "button",
264
+ tabIndex: 0,
265
+ children: /* @__PURE__ */ o("span", { "aria-hidden": "true", className: "bj-table__column-badge-shape" })
266
+ }
267
+ ),
268
+ /* @__PURE__ */ F("div", { className: "bj-table__column-title", children: [
269
+ /* @__PURE__ */ o("span", { className: "bj-table__column-title-content", children: L }),
270
+ e.sorter && /* @__PURE__ */ o("span", { "aria-hidden": "true", className: "bj-table__column-sorter", children: /* @__PURE__ */ o(Ce, { className: "bj-table__column-sorter-icon", type: h }) })
271
+ ] }),
272
+ (e.filters || e.filterDropdown) && /* @__PURE__ */ F("div", { className: "bj-table__filter", children: [
273
+ /* @__PURE__ */ o(
274
+ "button",
275
+ {
276
+ "aria-expanded": N,
277
+ "aria-label": "筛选",
278
+ className: E("bj-table__filter-trigger", _ && "bj-table__filter-trigger--active"),
279
+ onClick: (i) => {
280
+ i.stopPropagation(), ie(e, t);
281
+ },
282
+ type: "button",
283
+ children: typeof e.filterIcon == "function" ? e.filterIcon(_) : e.filterIcon ?? /* @__PURE__ */ o(Ce, { className: "bj-table__filter-icon", type: "icon-a-shaixuanxi" })
284
+ }
285
+ ),
286
+ N && _e && typeof document < "u" && At(
287
+ /* @__PURE__ */ o(
288
+ "div",
289
+ {
290
+ className: "bj-table__filter-dropdown",
291
+ onClick: (i) => i.stopPropagation(),
292
+ role: "dialog",
293
+ style: { left: _e.left, top: _e.top },
294
+ children: w ?? /* @__PURE__ */ o(
295
+ $t,
296
+ {
297
+ ...e.filterDropdownProps,
298
+ emptyText: (G == null ? void 0 : G.filterEmptyText) ?? Q("暂无筛选项"),
299
+ multiple: e.filterMultiple !== !1,
300
+ onChange: (i, g) => {
301
+ var D, Ye;
302
+ X((Lt) => new Map(Lt).set(r, i)), (Ye = (D = e.filterDropdownProps) == null ? void 0 : D.onChange) == null || Ye.call(D, i, g);
303
+ },
304
+ onConfirm: (i) => {
305
+ var g, D;
306
+ Ne(e, t, i), (D = (g = e.filterDropdownProps) == null ? void 0 : g.onConfirm) == null || D.call(g, i);
307
+ },
308
+ onReset: () => {
309
+ var i, g;
310
+ kt(e, t), (g = (i = e.filterDropdownProps) == null ? void 0 : i.onReset) == null || g.call(i);
311
+ },
312
+ onSearch: (i) => {
313
+ var g, D;
314
+ Ke(i), (D = (g = e.filterDropdownProps) == null ? void 0 : g.onSearch) == null || D.call(g, i);
315
+ },
316
+ options: y.map((i) => ({
317
+ label: i.text,
318
+ description: i.description,
319
+ value: i.value
320
+ })),
321
+ searchable: ((A = e.filterDropdownProps) == null ? void 0 : A.searchable) ?? T,
322
+ searchPlaceholder: ((Xe = e.filterDropdownProps) == null ? void 0 : Xe.searchPlaceholder) ?? (e.filterRequest ? Q("请输入搜索内容") : (G == null ? void 0 : G.filterSearchPlaceholder) ?? Q("搜索")),
323
+ searchValue: ge,
324
+ value: s
325
+ }
326
+ )
327
+ }
328
+ ),
329
+ document.body
330
+ )
331
+ ] })
332
+ ] });
333
+ return e.badge !== void 0 ? /* @__PURE__ */ F(
334
+ Wt,
335
+ {
336
+ className: "bj-table__column-tooltip-wrapper",
337
+ children: [
338
+ /* @__PURE__ */ o("div", { className: "bj-table__column-tooltip-trigger", children: v }),
339
+ vt === r && /* @__PURE__ */ o(
340
+ Ht,
341
+ {
342
+ className: "bj-table__column-tooltip",
343
+ content: e.badge,
344
+ getAnchorElement: () => document.getElementById(n),
345
+ getPopupContainer: () => document.body,
346
+ placement: "top"
347
+ }
348
+ )
349
+ ]
350
+ }
351
+ ) : v;
352
+ }, Ae = (e, t, r) => {
353
+ var b, s;
354
+ t.selectedRowKeys === void 0 && Ie(e);
355
+ const n = new Set(e), d = f.filter(
356
+ (N, _) => n.has(U(N, _, p))
357
+ );
358
+ (b = t.onChange) == null || b.call(t, e, d), r && ((s = t.onSelect) == null || s.call(
359
+ t,
360
+ r,
361
+ n.has(U(r, f.indexOf(r), p)),
362
+ d
363
+ ));
364
+ }, Ot = (e, t) => {
365
+ if (!a)
366
+ return;
367
+ const r = U(e, t, p), n = k.includes(r), d = a.type === "radio" ? n ? [] : [r] : n ? k.filter((b) => b !== r) : [...k, r];
368
+ Ae(d, a, e);
369
+ }, qe = V.filter(
370
+ ({ record: e }) => {
371
+ var t;
372
+ return !((t = a == null ? void 0 : a.getCheckboxProps) != null && t.call(a, e).disabled);
373
+ }
374
+ ), ee = qe.map(
375
+ ({ record: e, index: t }) => U(e, t, p)
376
+ ), xe = ee.length > 0 && ee.every((e) => k.includes(e)), Rt = () => {
377
+ var r;
378
+ if (!a || a.type === "radio")
379
+ return;
380
+ const e = new Set(ee), t = xe ? k.filter((n) => !e.has(n)) : Array.from(/* @__PURE__ */ new Set([...k, ...ee]));
381
+ Ae(t, a), new Set(t), (r = a.onSelectAll) == null || r.call(
382
+ a,
383
+ !xe,
384
+ qe.map(({ record: n }) => n)
385
+ );
386
+ }, Bt = (e) => {
387
+ var t;
388
+ !l || e < 1 || e > Le || e === I || (l.current === void 0 && le(e), (t = l.onChange) == null || t.call(l, e, K), ve("paginate", P, B, e));
389
+ }, Et = (e) => {
390
+ var r, n;
391
+ if (!l || e === K)
392
+ return;
393
+ const t = Math.min(I, at(me, e));
394
+ l.pageSize === void 0 && _t(e), l.current === void 0 && le(t), (r = l.onShowSizeChange) == null || r.call(l, t, e), (n = l.onChange) == null || n.call(l, t, e);
395
+ }, Mt = m.length + (a ? 1 : 0), te = (a == null ? void 0 : a.columnWidth) ?? 48, He = (e) => typeof e.width == "number" ? e.width : 0, We = (e, t) => {
396
+ const r = e.fixed === !0 ? "left" : e.fixed;
397
+ return r === "left" ? { position: "sticky", left: m.slice(0, t).reduce((d, b) => d + He(b), a && typeof te == "number" ? te : 0), zIndex: 2 } : r === "right" ? { position: "sticky", right: m.slice(t + 1).reduce((d, b) => d + He(b), 0), zIndex: 2 } : {};
398
+ }, It = c != null && c.x ? {
399
+ width: c.x === !0 ? "max-content" : c.x,
400
+ minWidth: "100%",
401
+ tableLayout: Be ?? "fixed"
402
+ } : { tableLayout: Be }, zt = (j == null ? void 0 : j.table) ?? "table", Tt = ((Je = j == null ? void 0 : j.header) == null ? void 0 : Je.wrapper) ?? "thead", Kt = ((Qe = j == null ? void 0 : j.header) == null ? void 0 : Qe.row) ?? "tr", Ue = ((Ze = j == null ? void 0 : j.header) == null ? void 0 : Ze.cell) ?? "th", z = typeof (j == null ? void 0 : j.body) == "object" ? j.body : void 0, St = (z == null ? void 0 : z.wrapper) ?? "tbody", $e = (z == null ? void 0 : z.row) ?? "tr", Fe = (z == null ? void 0 : z.cell) ?? "td", Vt = typeof de == "function" ? de() : de ?? Q("暂无数据"), Ge = typeof oe == "string" ? /* @__PURE__ */ o("img", { alt: "", className: "bj-table__empty-image", src: oe }) : oe;
403
+ return /* @__PURE__ */ F(
404
+ "div",
405
+ {
406
+ id: ht,
407
+ ref: re,
408
+ className: E(
409
+ "bj-table",
410
+ it && "bj-table--bordered",
411
+ `bj-table--${nt}`,
412
+ $ && "bj-table--loading",
413
+ S.length === 0 && "bj-table--empty",
414
+ ct
415
+ ),
416
+ style: bt,
417
+ children: [
418
+ Pe && /* @__PURE__ */ o("div", { className: "bj-table__title", children: Pe(S) }),
419
+ /* @__PURE__ */ F("div", { className: "bj-table__viewport", children: [
420
+ /* @__PURE__ */ o(
421
+ "div",
422
+ {
423
+ className: E("bj-table__scroll", !!(c != null && c.x || c != null && c.y) && "bj-overlay-scrollbar-hidden"),
424
+ ref: Ee,
425
+ style: { maxHeight: c == null ? void 0 : c.y },
426
+ children: /* @__PURE__ */ F(zt, { className: "bj-table__native-table", style: It, children: [
427
+ m.some((e) => e.width) && /* @__PURE__ */ F("colgroup", { children: [
428
+ a && /* @__PURE__ */ o("col", { className: "bj-table__selection-col", style: { width: te } }),
429
+ m.map((e, t) => /* @__PURE__ */ o("col", { style: { width: e.width } }, e.key ?? t))
430
+ ] }),
431
+ dt && /* @__PURE__ */ o(Tt, { className: "bj-table__header", children: Me.map((e, t) => /* @__PURE__ */ F(Kt, { className: "bj-table__header-row", ...he == null ? void 0 : he(m, t), children: [
432
+ a && t === 0 && /* @__PURE__ */ F(
433
+ Ue,
434
+ {
435
+ className: E("bj-table__header-cell", "bj-table__selection-cell", !!(c != null && c.x) && "bj-table__selection-cell--fixed"),
436
+ rowSpan: Me.length,
437
+ scope: "col",
438
+ style: { width: te },
439
+ children: [
440
+ a.type !== "radio" && /* @__PURE__ */ o(
441
+ lt,
442
+ {
443
+ checked: xe,
444
+ disabled: ee.length === 0,
445
+ onChange: Rt,
446
+ label: "选择当前页所有行"
447
+ }
448
+ ),
449
+ a.columnTitle
450
+ ]
451
+ }
452
+ ),
453
+ e.map(({ column: r, colSpan: n, rowSpan: d }, b) => {
454
+ var O;
455
+ const s = r, N = m.indexOf(s), _ = N >= 0 ? N : b, h = !("children" in r) && !!(s.filters || s.filterDropdown), L = !("children" in r) && !!s.sorter, w = () => {
456
+ h ? ie(s, _) : L && Ct(s, _);
457
+ };
458
+ return /* @__PURE__ */ De(
459
+ Ue,
460
+ {
461
+ ...(O = s.onHeaderCell) == null ? void 0 : O.call(s, r, b),
462
+ "aria-label": typeof s.title == "string" ? s.title : void 0,
463
+ "aria-sort": L ? P.get(C(s, _)) === "ascend" ? "ascending" : P.get(C(s, _)) === "descend" ? "descending" : "none" : void 0,
464
+ className: E(
465
+ "bj-table__header-cell",
466
+ s.fixed && "bj-table__cell--fixed",
467
+ (s.fixed === "left" || s.fixed === !0) && "bj-table__cell--fixed-left",
468
+ s.fixed === "right" && "bj-table__cell--fixed-right",
469
+ s.sorter && "bj-table__header-cell--sortable",
470
+ h && "bj-table__header-cell--filterable",
471
+ P.get(C(s, _)) && "bj-table__header-cell--sorted",
472
+ s.className
473
+ ),
474
+ colSpan: n,
475
+ key: s.key ?? String(s.dataIndex ?? b),
476
+ onClick: (y) => {
477
+ var T, v, A;
478
+ (A = (v = (T = s.onHeaderCell) == null ? void 0 : T.call(s, r, b)) == null ? void 0 : v.onClick) == null || A.call(v, y), !y.target.closest(".bj-table__filter-dropdown") && (h ? ie(s, _, y.currentTarget) : w());
479
+ },
480
+ onKeyDown: (y) => {
481
+ var T, v, A;
482
+ (A = (v = (T = s.onHeaderCell) == null ? void 0 : T.call(s, r, b)) == null ? void 0 : v.onKeyDown) == null || A.call(v, y), !y.target.closest(".bj-table__filter-dropdown") && (y.key === "Enter" || y.key === " ") && (y.preventDefault(), h ? ie(s, _, y.currentTarget) : w());
483
+ },
484
+ rowSpan: d,
485
+ scope: "col",
486
+ style: { textAlign: s.align, ...We(s, _) },
487
+ tabIndex: h || L ? 0 : void 0
488
+ },
489
+ "children" in r ? rt(r.title, { filters: Object.fromEntries(B) }) : Pt(s, _)
490
+ );
491
+ })
492
+ ] }, t)) }),
493
+ /* @__PURE__ */ o(St, { className: "bj-table__body", children: V.length > 0 ? V.map(({ record: e, index: t }) => {
494
+ var s;
495
+ const r = U(e, t, p), n = ((s = a == null ? void 0 : a.getCheckboxProps) == null ? void 0 : s.call(a, e).disabled) ?? !1, d = k.includes(r), b = typeof ce == "function" ? ce(e, t, 0) : ce;
496
+ return /* @__PURE__ */ De(
497
+ $e,
498
+ {
499
+ ...fe == null ? void 0 : fe(e, t),
500
+ className: E("bj-table__row", d && "bj-table__row--selected", b),
501
+ key: r
502
+ },
503
+ a && /* @__PURE__ */ o(
504
+ Fe,
505
+ {
506
+ className: E("bj-table__cell", "bj-table__selection-cell", !!(c != null && c.x) && "bj-table__selection-cell--fixed"),
507
+ style: { width: te },
508
+ children: /* @__PURE__ */ o(
509
+ lt,
510
+ {
511
+ checked: d,
512
+ disabled: n,
513
+ label: `选择第 ${t + 1} 行`,
514
+ name: a.type === "radio" ? "bj-table-row-selection" : void 0,
515
+ onChange: () => Ot(e, t),
516
+ type: a.type ?? "checkbox"
517
+ }
518
+ )
519
+ }
520
+ ),
521
+ m.map((N, _) => {
522
+ var v;
523
+ const h = N, L = sr(e, h.dataIndex), w = h.render ? h.render(L, e, t) : L, O = ir(w) ? w : void 0, y = { ...(v = h.onCell) == null ? void 0 : v.call(h, e, t), ...O == null ? void 0 : O.props }, T = O ? O.children : w;
524
+ return y.colSpan === 0 || y.rowSpan === 0 ? null : /* @__PURE__ */ De(
525
+ Fe,
526
+ {
527
+ ...y,
528
+ className: E(
529
+ "bj-table__cell",
530
+ h.fixed && "bj-table__cell--fixed",
531
+ (h.fixed === "left" || h.fixed === !0) && "bj-table__cell--fixed-left",
532
+ h.fixed === "right" && "bj-table__cell--fixed-right",
533
+ h.ellipsis && "bj-table__cell--ellipsis",
534
+ h.className,
535
+ y.className
536
+ ),
537
+ key: h.key ?? String(h.dataIndex ?? _),
538
+ style: { textAlign: h.align, ...We(h, _), ...y.style }
539
+ },
540
+ /* @__PURE__ */ o("div", { className: "bj-table__cell-content", children: T ?? "" })
541
+ );
542
+ })
543
+ );
544
+ }) : /* @__PURE__ */ o($e, { className: "bj-table__empty-row", children: /* @__PURE__ */ o(
545
+ Fe,
546
+ {
547
+ className: "bj-table__empty-cell",
548
+ colSpan: Math.max(Mt, 1),
549
+ style: { height: ot }
550
+ }
551
+ ) }) }),
552
+ Re && /* @__PURE__ */ o("tfoot", { className: "bj-table__summary", children: Re(S) })
553
+ ] })
554
+ }
555
+ ),
556
+ V.length === 0 && /* @__PURE__ */ o("div", { className: "bj-table__empty-overlay", children: /* @__PURE__ */ F("div", { className: "bj-table__empty-content", children: [
557
+ Ge && /* @__PURE__ */ o("div", { className: "bj-table__empty-image-wrap", children: Ge }),
558
+ /* @__PURE__ */ o("div", { className: "bj-table__empty-text", children: Vt })
559
+ ] }) })
560
+ ] }),
561
+ ((c == null ? void 0 : c.x) || (c == null ? void 0 : c.y)) && /* @__PURE__ */ o(
562
+ Gt,
563
+ {
564
+ containerRef: re,
565
+ direction: c != null && c.x && (c != null && c.y) ? "both" : c != null && c.x ? "horizontal" : "vertical",
566
+ gap: 2,
567
+ horizontalInsetEnd: 0,
568
+ horizontalInsetStart: 0,
569
+ size: 4,
570
+ targetRef: Ee
571
+ }
572
+ ),
573
+ Oe && /* @__PURE__ */ o("div", { className: "bj-table__footer", children: Oe(S) }),
574
+ $ && /* @__PURE__ */ F("div", { "aria-live": "polite", "aria-busy": "true", className: "bj-table__loading", role: "status", children: [
575
+ /* @__PURE__ */ o("img", { alt: "", className: "bj-table__loading-indicator", src: Jt }),
576
+ /* @__PURE__ */ o("span", { className: "bj-table__loading-text", children: "加载中..." })
577
+ ] }),
578
+ l && /* @__PURE__ */ o("div", { className: "bj-table__pagination", children: /* @__PURE__ */ o(
579
+ qt,
580
+ {
581
+ align: "end",
582
+ disabled: $ || l.disabled,
583
+ current: I,
584
+ defaultCurrent: l.defaultCurrent,
585
+ defaultPageSize: l.defaultPageSize,
586
+ dropdownClassName: l.dropdownClassName,
587
+ hideOnSinglePage: l.hideOnSinglePage,
588
+ onChange: Bt,
589
+ onShowSizeChange: (e, t) => Et(t),
590
+ pageSize: K,
591
+ pageSizeOptions: l.pageSizeOptions,
592
+ popupPlacement: l.popupPlacement,
593
+ resolvePopupPlacement: l.resolvePopupPlacement,
594
+ showQuickJumper: l.showQuickJumper,
595
+ showSizeChanger: l.showSizeChanger,
596
+ showTotal: l.showTotal,
597
+ simple: l.simple,
598
+ size: l.size,
599
+ t: l.t ?? Q,
600
+ total: me
601
+ }
602
+ ) })
603
+ ]
604
+ }
605
+ );
606
+ }
607
+ const st = dr;
608
+ st.Column = Zt;
609
+ st.ColumnGroup = Xt;
610
+ export {
611
+ st as BTable
612
+ };
@@ -0,0 +1 @@
1
+ "use strict";function n(t){return null}module.exports=n;
@@ -0,0 +1,6 @@
1
+ function u(n) {
2
+ return null;
3
+ }
4
+ export {
5
+ u as default
6
+ };
@@ -0,0 +1 @@
1
+ "use strict";function u(n){return null}module.exports=u;
@@ -0,0 +1,6 @@
1
+ function n(u) {
2
+ return null;
3
+ }
4
+ export {
5
+ n as default
6
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react");function c(r){return s.Children.toArray(r).flatMap((e,n)=>{if(!s.isValidElement(e))return[];const o=e.props,{children:l,...t}=o;return[{...t,key:e.key??t.key??n,...l?{children:c(l)}:{}}]})}function d(r){return r.flatMap(e=>"children"in e?d(e.children):[e])}function h(r){return r.reduce((e,n)=>Math.max(e,"children"in n?1+h(n.children):1),1)}function u(r){return"children"in r?r.children.reduce((e,n)=>e+u(n),0):1}function f(r){const e=h(r),n=Array.from({length:e},()=>[]),o=(l,t)=>{l.forEach(i=>{const a="children"in i&&i.children.length>0;n[t].push({column:i,colSpan:i.colSpan??(a?u(i):1),rowSpan:a?1:e-t,depth:t}),a&&o(i.children,t+1)})};return o(r,0),n}exports.buildHeaderRows=f;exports.convertChildrenToColumns=c;exports.flattenColumns=d;
@@ -0,0 +1,43 @@
1
+ import { Children as d, isValidElement as l } from "react";
2
+ function f(n) {
3
+ return d.toArray(n).flatMap((r, e) => {
4
+ if (!l(r)) return [];
5
+ const o = r.props, { children: a, ...t } = o;
6
+ return [{
7
+ ...t,
8
+ key: r.key ?? t.key ?? e,
9
+ ...a ? { children: f(a) } : {}
10
+ }];
11
+ });
12
+ }
13
+ function p(n) {
14
+ return n.flatMap((r) => "children" in r ? p(r.children) : [r]);
15
+ }
16
+ function c(n) {
17
+ return n.reduce((r, e) => Math.max(
18
+ r,
19
+ "children" in e ? 1 + c(e.children) : 1
20
+ ), 1);
21
+ }
22
+ function s(n) {
23
+ return "children" in n ? n.children.reduce((r, e) => r + s(e), 0) : 1;
24
+ }
25
+ function C(n) {
26
+ const r = c(n), e = Array.from({ length: r }, () => []), o = (a, t) => {
27
+ a.forEach((i) => {
28
+ const h = "children" in i && i.children.length > 0;
29
+ e[t].push({
30
+ column: i,
31
+ colSpan: i.colSpan ?? (h ? s(i) : 1),
32
+ rowSpan: h ? 1 : r - t,
33
+ depth: t
34
+ }), h && o(i.children, t + 1);
35
+ });
36
+ };
37
+ return o(n, 0), e;
38
+ }
39
+ export {
40
+ C as buildHeaderRows,
41
+ f as convertChildrenToColumns,
42
+ p as flattenColumns
43
+ };