bj-web-components 0.2.12 → 0.2.13
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/README.md +38 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +45 -26
- package/dist/style.css +1 -1
- package/dist/web/BasicInput/BInput.js +1 -0
- package/dist/web/BasicInput/BInput.mjs +177 -0
- package/dist/web/BasicInput/utils.js +1 -0
- package/dist/web/BasicInput/utils.mjs +37 -0
- package/dist/web/CheckBox/BCheckBox.js +1 -0
- package/dist/web/CheckBox/BCheckBox.mjs +101 -0
- package/dist/web/CheckBox/Group.js +1 -0
- package/dist/web/CheckBox/Group.mjs +67 -0
- package/dist/web/CheckBox/context.js +1 -0
- package/dist/web/CheckBox/context.mjs +5 -0
- package/dist/web/CheckBox/index.js +1 -0
- package/dist/web/CheckBox/index.mjs +8 -0
- package/dist/web/Dropdown/BDropdown.js +1 -0
- package/dist/web/Dropdown/BDropdown.mjs +160 -0
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +1 -0
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +152 -0
- package/dist/web/Pagination/Pagination.js +1 -1
- package/dist/web/Pagination/Pagination.mjs +1 -1
- package/dist/web/ProductField/ProductField.mjs +12 -12
- package/dist/web/SkuInputCard/SkuInputCard.mjs +26 -26
- package/dist/web/Table/BTable.js +1 -0
- package/dist/web/Table/BTable.mjs +608 -0
- package/dist/web/Table/Column.js +1 -0
- package/dist/web/Table/Column.mjs +6 -0
- package/dist/web/Table/ColumnGroup.js +1 -0
- package/dist/web/Table/ColumnGroup.mjs +6 -0
- package/dist/web/Table/utils/columns.js +1 -0
- package/dist/web/Table/utils/columns.mjs +43 -0
- package/dist/web/Table/utils/sortFilter.js +1 -0
- package/dist/web/Table/utils/sortFilter.mjs +63 -0
- package/dist/web/Tabs/BTabs.js +1 -0
- package/dist/web/Tabs/BTabs.mjs +130 -0
- package/dist/web/Tabs/TabPane.js +1 -0
- package/dist/web/Tabs/TabPane.mjs +7 -0
- package/dist/web/Tooltip/ContentTooltip.js +1 -1
- package/dist/web/Tooltip/ContentTooltip.mjs +56 -20
- package/dist/web.js +1 -1
- package/dist/web.mjs +45 -26
- package/package.json +3 -3
- package/dist/index.d.ts +0 -534
- package/dist/miniapp.d.ts +0 -1
- package/dist/mobile.d.ts +0 -1
- package/dist/react.d.ts +0 -1
- package/dist/shared.d.ts +0 -1
- package/dist/web.d.ts +0 -534
|
@@ -0,0 +1,608 @@
|
|
|
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 G, 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: J = "checkbox"
|
|
55
|
+
}) {
|
|
56
|
+
return J === "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: J
|
|
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: J = !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: $
|
|
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
|
+
G(() => {
|
|
142
|
+
I !== ue && (l == null ? void 0 : l.current) === void 0 && le(I);
|
|
143
|
+
}, [I, l == null ? void 0 : l.current, ue]), G(() => {
|
|
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]), G(() => {
|
|
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]), G(() => {
|
|
163
|
+
const e = window.setTimeout(
|
|
164
|
+
() => Se(ge.trim()),
|
|
165
|
+
lr
|
|
166
|
+
);
|
|
167
|
+
return () => window.clearTimeout(e);
|
|
168
|
+
}, [ge]), G(() => {
|
|
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
|
+
G(() => {
|
|
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: ($ == null ? void 0 : $.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) => ({ label: i.text, value: i.value })),
|
|
317
|
+
searchable: ((A = e.filterDropdownProps) == null ? void 0 : A.searchable) ?? T,
|
|
318
|
+
searchPlaceholder: ((Xe = e.filterDropdownProps) == null ? void 0 : Xe.searchPlaceholder) ?? (e.filterRequest ? Q("请输入搜索内容") : ($ == null ? void 0 : $.filterSearchPlaceholder) ?? Q("搜索")),
|
|
319
|
+
searchValue: ge,
|
|
320
|
+
value: s
|
|
321
|
+
}
|
|
322
|
+
)
|
|
323
|
+
}
|
|
324
|
+
),
|
|
325
|
+
document.body
|
|
326
|
+
)
|
|
327
|
+
] })
|
|
328
|
+
] });
|
|
329
|
+
return e.badge !== void 0 ? /* @__PURE__ */ F(
|
|
330
|
+
Wt,
|
|
331
|
+
{
|
|
332
|
+
className: "bj-table__column-tooltip-wrapper",
|
|
333
|
+
children: [
|
|
334
|
+
/* @__PURE__ */ o("div", { className: "bj-table__column-tooltip-trigger", children: v }),
|
|
335
|
+
vt === r && /* @__PURE__ */ o(
|
|
336
|
+
Ht,
|
|
337
|
+
{
|
|
338
|
+
className: "bj-table__column-tooltip",
|
|
339
|
+
content: e.badge,
|
|
340
|
+
getAnchorElement: () => document.getElementById(n),
|
|
341
|
+
getPopupContainer: () => document.body,
|
|
342
|
+
placement: "top"
|
|
343
|
+
}
|
|
344
|
+
)
|
|
345
|
+
]
|
|
346
|
+
}
|
|
347
|
+
) : v;
|
|
348
|
+
}, Ae = (e, t, r) => {
|
|
349
|
+
var b, s;
|
|
350
|
+
t.selectedRowKeys === void 0 && Ie(e);
|
|
351
|
+
const n = new Set(e), d = f.filter(
|
|
352
|
+
(N, _) => n.has(U(N, _, p))
|
|
353
|
+
);
|
|
354
|
+
(b = t.onChange) == null || b.call(t, e, d), r && ((s = t.onSelect) == null || s.call(
|
|
355
|
+
t,
|
|
356
|
+
r,
|
|
357
|
+
n.has(U(r, f.indexOf(r), p)),
|
|
358
|
+
d
|
|
359
|
+
));
|
|
360
|
+
}, Ot = (e, t) => {
|
|
361
|
+
if (!a)
|
|
362
|
+
return;
|
|
363
|
+
const r = U(e, t, p), n = k.includes(r), d = a.type === "radio" ? n ? [] : [r] : n ? k.filter((b) => b !== r) : [...k, r];
|
|
364
|
+
Ae(d, a, e);
|
|
365
|
+
}, qe = V.filter(
|
|
366
|
+
({ record: e }) => {
|
|
367
|
+
var t;
|
|
368
|
+
return !((t = a == null ? void 0 : a.getCheckboxProps) != null && t.call(a, e).disabled);
|
|
369
|
+
}
|
|
370
|
+
), ee = qe.map(
|
|
371
|
+
({ record: e, index: t }) => U(e, t, p)
|
|
372
|
+
), xe = ee.length > 0 && ee.every((e) => k.includes(e)), Rt = () => {
|
|
373
|
+
var r;
|
|
374
|
+
if (!a || a.type === "radio")
|
|
375
|
+
return;
|
|
376
|
+
const e = new Set(ee), t = xe ? k.filter((n) => !e.has(n)) : Array.from(/* @__PURE__ */ new Set([...k, ...ee]));
|
|
377
|
+
Ae(t, a), new Set(t), (r = a.onSelectAll) == null || r.call(
|
|
378
|
+
a,
|
|
379
|
+
!xe,
|
|
380
|
+
qe.map(({ record: n }) => n)
|
|
381
|
+
);
|
|
382
|
+
}, Bt = (e) => {
|
|
383
|
+
var t;
|
|
384
|
+
!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));
|
|
385
|
+
}, Et = (e) => {
|
|
386
|
+
var r, n;
|
|
387
|
+
if (!l || e === K)
|
|
388
|
+
return;
|
|
389
|
+
const t = Math.min(I, at(me, e));
|
|
390
|
+
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);
|
|
391
|
+
}, 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) => {
|
|
392
|
+
const r = e.fixed === !0 ? "left" : e.fixed;
|
|
393
|
+
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 } : {};
|
|
394
|
+
}, It = c != null && c.x ? {
|
|
395
|
+
width: c.x === !0 ? "max-content" : c.x,
|
|
396
|
+
minWidth: "100%",
|
|
397
|
+
tableLayout: Be ?? "fixed"
|
|
398
|
+
} : { 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;
|
|
399
|
+
return /* @__PURE__ */ F(
|
|
400
|
+
"div",
|
|
401
|
+
{
|
|
402
|
+
id: ht,
|
|
403
|
+
ref: re,
|
|
404
|
+
className: E(
|
|
405
|
+
"bj-table",
|
|
406
|
+
it && "bj-table--bordered",
|
|
407
|
+
`bj-table--${nt}`,
|
|
408
|
+
J && "bj-table--loading",
|
|
409
|
+
S.length === 0 && "bj-table--empty",
|
|
410
|
+
ct
|
|
411
|
+
),
|
|
412
|
+
style: bt,
|
|
413
|
+
children: [
|
|
414
|
+
Pe && /* @__PURE__ */ o("div", { className: "bj-table__title", children: Pe(S) }),
|
|
415
|
+
/* @__PURE__ */ F("div", { className: "bj-table__viewport", children: [
|
|
416
|
+
/* @__PURE__ */ o(
|
|
417
|
+
"div",
|
|
418
|
+
{
|
|
419
|
+
className: E("bj-table__scroll", !!(c != null && c.x || c != null && c.y) && "bj-overlay-scrollbar-hidden"),
|
|
420
|
+
ref: Ee,
|
|
421
|
+
style: { maxHeight: c == null ? void 0 : c.y },
|
|
422
|
+
children: /* @__PURE__ */ F(zt, { className: "bj-table__native-table", style: It, children: [
|
|
423
|
+
m.some((e) => e.width) && /* @__PURE__ */ F("colgroup", { children: [
|
|
424
|
+
a && /* @__PURE__ */ o("col", { className: "bj-table__selection-col", style: { width: te } }),
|
|
425
|
+
m.map((e, t) => /* @__PURE__ */ o("col", { style: { width: e.width } }, e.key ?? t))
|
|
426
|
+
] }),
|
|
427
|
+
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: [
|
|
428
|
+
a && t === 0 && /* @__PURE__ */ F(
|
|
429
|
+
Ue,
|
|
430
|
+
{
|
|
431
|
+
className: E("bj-table__header-cell", "bj-table__selection-cell", !!(c != null && c.x) && "bj-table__selection-cell--fixed"),
|
|
432
|
+
rowSpan: Me.length,
|
|
433
|
+
scope: "col",
|
|
434
|
+
style: { width: te },
|
|
435
|
+
children: [
|
|
436
|
+
a.type !== "radio" && /* @__PURE__ */ o(
|
|
437
|
+
lt,
|
|
438
|
+
{
|
|
439
|
+
checked: xe,
|
|
440
|
+
disabled: ee.length === 0,
|
|
441
|
+
onChange: Rt,
|
|
442
|
+
label: "选择当前页所有行"
|
|
443
|
+
}
|
|
444
|
+
),
|
|
445
|
+
a.columnTitle
|
|
446
|
+
]
|
|
447
|
+
}
|
|
448
|
+
),
|
|
449
|
+
e.map(({ column: r, colSpan: n, rowSpan: d }, b) => {
|
|
450
|
+
var O;
|
|
451
|
+
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 = () => {
|
|
452
|
+
h ? ie(s, _) : L && Ct(s, _);
|
|
453
|
+
};
|
|
454
|
+
return /* @__PURE__ */ De(
|
|
455
|
+
Ue,
|
|
456
|
+
{
|
|
457
|
+
...(O = s.onHeaderCell) == null ? void 0 : O.call(s, r, b),
|
|
458
|
+
"aria-label": typeof s.title == "string" ? s.title : void 0,
|
|
459
|
+
"aria-sort": L ? P.get(C(s, _)) === "ascend" ? "ascending" : P.get(C(s, _)) === "descend" ? "descending" : "none" : void 0,
|
|
460
|
+
className: E(
|
|
461
|
+
"bj-table__header-cell",
|
|
462
|
+
s.fixed && "bj-table__cell--fixed",
|
|
463
|
+
(s.fixed === "left" || s.fixed === !0) && "bj-table__cell--fixed-left",
|
|
464
|
+
s.fixed === "right" && "bj-table__cell--fixed-right",
|
|
465
|
+
s.sorter && "bj-table__header-cell--sortable",
|
|
466
|
+
h && "bj-table__header-cell--filterable",
|
|
467
|
+
P.get(C(s, _)) && "bj-table__header-cell--sorted",
|
|
468
|
+
s.className
|
|
469
|
+
),
|
|
470
|
+
colSpan: n,
|
|
471
|
+
key: s.key ?? String(s.dataIndex ?? b),
|
|
472
|
+
onClick: (y) => {
|
|
473
|
+
var T, v, A;
|
|
474
|
+
(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());
|
|
475
|
+
},
|
|
476
|
+
onKeyDown: (y) => {
|
|
477
|
+
var T, v, A;
|
|
478
|
+
(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());
|
|
479
|
+
},
|
|
480
|
+
rowSpan: d,
|
|
481
|
+
scope: "col",
|
|
482
|
+
style: { textAlign: s.align, ...We(s, _) },
|
|
483
|
+
tabIndex: h || L ? 0 : void 0
|
|
484
|
+
},
|
|
485
|
+
"children" in r ? rt(r.title, { filters: Object.fromEntries(B) }) : Pt(s, _)
|
|
486
|
+
);
|
|
487
|
+
})
|
|
488
|
+
] }, t)) }),
|
|
489
|
+
/* @__PURE__ */ o(St, { className: "bj-table__body", children: V.length > 0 ? V.map(({ record: e, index: t }) => {
|
|
490
|
+
var s;
|
|
491
|
+
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;
|
|
492
|
+
return /* @__PURE__ */ De(
|
|
493
|
+
$e,
|
|
494
|
+
{
|
|
495
|
+
...fe == null ? void 0 : fe(e, t),
|
|
496
|
+
className: E("bj-table__row", d && "bj-table__row--selected", b),
|
|
497
|
+
key: r
|
|
498
|
+
},
|
|
499
|
+
a && /* @__PURE__ */ o(
|
|
500
|
+
Fe,
|
|
501
|
+
{
|
|
502
|
+
className: E("bj-table__cell", "bj-table__selection-cell", !!(c != null && c.x) && "bj-table__selection-cell--fixed"),
|
|
503
|
+
style: { width: te },
|
|
504
|
+
children: /* @__PURE__ */ o(
|
|
505
|
+
lt,
|
|
506
|
+
{
|
|
507
|
+
checked: d,
|
|
508
|
+
disabled: n,
|
|
509
|
+
label: `选择第 ${t + 1} 行`,
|
|
510
|
+
name: a.type === "radio" ? "bj-table-row-selection" : void 0,
|
|
511
|
+
onChange: () => Ot(e, t),
|
|
512
|
+
type: a.type ?? "checkbox"
|
|
513
|
+
}
|
|
514
|
+
)
|
|
515
|
+
}
|
|
516
|
+
),
|
|
517
|
+
m.map((N, _) => {
|
|
518
|
+
var v;
|
|
519
|
+
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;
|
|
520
|
+
return y.colSpan === 0 || y.rowSpan === 0 ? null : /* @__PURE__ */ De(
|
|
521
|
+
Fe,
|
|
522
|
+
{
|
|
523
|
+
...y,
|
|
524
|
+
className: E(
|
|
525
|
+
"bj-table__cell",
|
|
526
|
+
h.fixed && "bj-table__cell--fixed",
|
|
527
|
+
(h.fixed === "left" || h.fixed === !0) && "bj-table__cell--fixed-left",
|
|
528
|
+
h.fixed === "right" && "bj-table__cell--fixed-right",
|
|
529
|
+
h.ellipsis && "bj-table__cell--ellipsis",
|
|
530
|
+
h.className,
|
|
531
|
+
y.className
|
|
532
|
+
),
|
|
533
|
+
key: h.key ?? String(h.dataIndex ?? _),
|
|
534
|
+
style: { textAlign: h.align, ...We(h, _), ...y.style }
|
|
535
|
+
},
|
|
536
|
+
/* @__PURE__ */ o("div", { className: "bj-table__cell-content", children: T ?? "" })
|
|
537
|
+
);
|
|
538
|
+
})
|
|
539
|
+
);
|
|
540
|
+
}) : /* @__PURE__ */ o($e, { className: "bj-table__empty-row", children: /* @__PURE__ */ o(
|
|
541
|
+
Fe,
|
|
542
|
+
{
|
|
543
|
+
className: "bj-table__empty-cell",
|
|
544
|
+
colSpan: Math.max(Mt, 1),
|
|
545
|
+
style: { height: ot }
|
|
546
|
+
}
|
|
547
|
+
) }) }),
|
|
548
|
+
Re && /* @__PURE__ */ o("tfoot", { className: "bj-table__summary", children: Re(S) })
|
|
549
|
+
] })
|
|
550
|
+
}
|
|
551
|
+
),
|
|
552
|
+
V.length === 0 && /* @__PURE__ */ o("div", { className: "bj-table__empty-overlay", children: /* @__PURE__ */ F("div", { className: "bj-table__empty-content", children: [
|
|
553
|
+
Ge && /* @__PURE__ */ o("div", { className: "bj-table__empty-image-wrap", children: Ge }),
|
|
554
|
+
/* @__PURE__ */ o("div", { className: "bj-table__empty-text", children: Vt })
|
|
555
|
+
] }) })
|
|
556
|
+
] }),
|
|
557
|
+
((c == null ? void 0 : c.x) || (c == null ? void 0 : c.y)) && /* @__PURE__ */ o(
|
|
558
|
+
Gt,
|
|
559
|
+
{
|
|
560
|
+
containerRef: re,
|
|
561
|
+
direction: c != null && c.x && (c != null && c.y) ? "both" : c != null && c.x ? "horizontal" : "vertical",
|
|
562
|
+
gap: 2,
|
|
563
|
+
horizontalInsetEnd: 0,
|
|
564
|
+
horizontalInsetStart: 0,
|
|
565
|
+
size: 4,
|
|
566
|
+
targetRef: Ee
|
|
567
|
+
}
|
|
568
|
+
),
|
|
569
|
+
Oe && /* @__PURE__ */ o("div", { className: "bj-table__footer", children: Oe(S) }),
|
|
570
|
+
J && /* @__PURE__ */ F("div", { "aria-live": "polite", "aria-busy": "true", className: "bj-table__loading", role: "status", children: [
|
|
571
|
+
/* @__PURE__ */ o("img", { alt: "", className: "bj-table__loading-indicator", src: Jt }),
|
|
572
|
+
/* @__PURE__ */ o("span", { className: "bj-table__loading-text", children: "加载中..." })
|
|
573
|
+
] }),
|
|
574
|
+
l && /* @__PURE__ */ o("div", { className: "bj-table__pagination", children: /* @__PURE__ */ o(
|
|
575
|
+
qt,
|
|
576
|
+
{
|
|
577
|
+
align: "end",
|
|
578
|
+
disabled: l.disabled,
|
|
579
|
+
current: I,
|
|
580
|
+
defaultCurrent: l.defaultCurrent,
|
|
581
|
+
defaultPageSize: l.defaultPageSize,
|
|
582
|
+
dropdownClassName: l.dropdownClassName,
|
|
583
|
+
hideOnSinglePage: l.hideOnSinglePage,
|
|
584
|
+
onChange: Bt,
|
|
585
|
+
onShowSizeChange: (e, t) => Et(t),
|
|
586
|
+
pageSize: K,
|
|
587
|
+
pageSizeOptions: l.pageSizeOptions,
|
|
588
|
+
popupPlacement: l.popupPlacement,
|
|
589
|
+
resolvePopupPlacement: l.resolvePopupPlacement,
|
|
590
|
+
showQuickJumper: l.showQuickJumper,
|
|
591
|
+
showSizeChanger: l.showSizeChanger,
|
|
592
|
+
showTotal: l.showTotal,
|
|
593
|
+
simple: l.simple,
|
|
594
|
+
size: l.size,
|
|
595
|
+
t: l.t ?? Q,
|
|
596
|
+
total: me
|
|
597
|
+
}
|
|
598
|
+
) })
|
|
599
|
+
]
|
|
600
|
+
}
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
const st = dr;
|
|
604
|
+
st.Column = Zt;
|
|
605
|
+
st.ColumnGroup = Xt;
|
|
606
|
+
export {
|
|
607
|
+
st as BTable
|
|
608
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function n(t){return null}module.exports=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function u(n){return null}module.exports=u;
|
|
@@ -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
|
+
};
|