bj-web-components 0.2.27 → 0.2.28

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 (90) hide show
  1. package/dist/index.js +51 -1
  2. package/dist/index.mjs +49 -49
  3. package/dist/style.css +3744 -1
  4. package/dist/web/BasicInput/BInput.js +208 -1
  5. package/dist/web/BasicInput/BInput.mjs +164 -132
  6. package/dist/web/BasicInput/utils.js +47 -1
  7. package/dist/web/BasicInput/utils.mjs +38 -28
  8. package/dist/web/CategoryDropdown/CategoryDropdown.js +307 -1
  9. package/dist/web/CategoryDropdown/CategoryDropdown.mjs +218 -170
  10. package/dist/web/CheckBox/BCheckBox.js +116 -1
  11. package/dist/web/CheckBox/BCheckBox.mjs +86 -70
  12. package/dist/web/CheckBox/Group.js +73 -1
  13. package/dist/web/CheckBox/Group.mjs +63 -56
  14. package/dist/web/CheckBox/context.js +5 -1
  15. package/dist/web/CheckBox/context.mjs +3 -3
  16. package/dist/web/CheckBox/index.js +8 -1
  17. package/dist/web/CheckBox/index.mjs +6 -6
  18. package/dist/web/Dropdown/BDropdown.js +186 -1
  19. package/dist/web/Dropdown/BDropdown.mjs +132 -106
  20. package/dist/web/EmptyInputBox/EmptyInputBox.js +77 -1
  21. package/dist/web/EmptyInputBox/EmptyInputBox.mjs +52 -48
  22. package/dist/web/FileCard/FileCard.js +157 -1
  23. package/dist/web/FileCard/FileCard.mjs +112 -82
  24. package/dist/web/Icon/Icon.js +9 -1
  25. package/dist/web/Icon/Icon.mjs +6 -6
  26. package/dist/web/Input/Input.js +181 -1
  27. package/dist/web/Input/Input.mjs +122 -113
  28. package/dist/web/InputNumber/BInputNumber.js +311 -1
  29. package/dist/web/InputNumber/BInputNumber.mjs +275 -167
  30. package/dist/web/InputNumber/StepHandler.js +69 -1
  31. package/dist/web/InputNumber/StepHandler.mjs +38 -32
  32. package/dist/web/InputNumber/hooks/useCursor.js +40 -1
  33. package/dist/web/InputNumber/hooks/useCursor.mjs +35 -33
  34. package/dist/web/InputNumber/hooks/useFrame.js +12 -1
  35. package/dist/web/InputNumber/hooks/useFrame.mjs +9 -6
  36. package/dist/web/InputNumber/utils/decimal.js +147 -1
  37. package/dist/web/InputNumber/utils/decimal.mjs +109 -81
  38. package/dist/web/Modal/Modal.js +84 -1
  39. package/dist/web/Modal/Modal.mjs +52 -49
  40. package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +232 -1
  41. package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +206 -125
  42. package/dist/web/Pagination/Pagination.js +328 -1
  43. package/dist/web/Pagination/Pagination.mjs +254 -178
  44. package/dist/web/ProductField/ProductField.js +272 -1
  45. package/dist/web/ProductField/ProductField.mjs +190 -143
  46. package/dist/web/ProductField/arrow-up.svg.js +3 -1
  47. package/dist/web/ProductField/arrow-up.svg.mjs +2 -2
  48. package/dist/web/ProductField/checkbox-no.svg.js +3 -1
  49. package/dist/web/ProductField/checkbox-no.svg.mjs +2 -2
  50. package/dist/web/ProductField/checkbox-ok.svg.js +3 -1
  51. package/dist/web/ProductField/checkbox-ok.svg.mjs +2 -2
  52. package/dist/web/ProductField/no_data_light.svg.js +3 -1
  53. package/dist/web/ProductField/no_data_light.svg.mjs +2 -2
  54. package/dist/web/ProductField/search.svg.js +3 -1
  55. package/dist/web/ProductField/search.svg.mjs +2 -2
  56. package/dist/web/ProductField/sort.svg.js +3 -1
  57. package/dist/web/ProductField/sort.svg.mjs +2 -2
  58. package/dist/web/SkuInputCard/SkuInputCard.js +276 -1
  59. package/dist/web/SkuInputCard/SkuInputCard.mjs +188 -149
  60. package/dist/web/SkuInputCard/spin_loading_red.gif.js +3 -1
  61. package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +2 -2
  62. package/dist/web/Switch/Switch.js +70 -1
  63. package/dist/web/Switch/Switch.mjs +47 -37
  64. package/dist/web/Table/BTable.js +950 -1
  65. package/dist/web/Table/BTable.mjs +771 -519
  66. package/dist/web/Table/Column.js +5 -1
  67. package/dist/web/Table/Column.mjs +2 -2
  68. package/dist/web/Table/ColumnGroup.js +5 -1
  69. package/dist/web/Table/ColumnGroup.mjs +2 -2
  70. package/dist/web/Table/utils/columns.js +48 -1
  71. package/dist/web/Table/utils/columns.mjs +35 -30
  72. package/dist/web/Table/utils/sortFilter.js +84 -1
  73. package/dist/web/Table/utils/sortFilter.mjs +73 -52
  74. package/dist/web/Tabs/BTabs.js +150 -1
  75. package/dist/web/Tabs/BTabs.mjs +118 -98
  76. package/dist/web/Tabs/TabPane.js +8 -1
  77. package/dist/web/Tabs/TabPane.mjs +4 -4
  78. package/dist/web/Tooltip/ConfirmTooltip.js +26 -1
  79. package/dist/web/Tooltip/ConfirmTooltip.mjs +20 -19
  80. package/dist/web/Tooltip/ContentTooltip.js +94 -1
  81. package/dist/web/Tooltip/ContentTooltip.mjs +72 -62
  82. package/dist/web/Tooltip/ProgressTooltip.js +36 -1
  83. package/dist/web/Tooltip/ProgressTooltip.mjs +22 -20
  84. package/dist/web/Tooltip/TooltipWrapper.js +12 -1
  85. package/dist/web/Tooltip/TooltipWrapper.mjs +8 -8
  86. package/dist/web/Tooltip/useAutoPlacement.js +41 -1
  87. package/dist/web/Tooltip/useAutoPlacement.mjs +34 -25
  88. package/dist/web.js +51 -1
  89. package/dist/web.mjs +49 -49
  90. package/package.json +1 -1
@@ -1,380 +1,537 @@
1
- import { jsxs as E, jsx as b } from "react/jsx-runtime";
2
- import { useRef as de, useMemo as X, useState as R, useEffect as Y, createElement as Me, isValidElement as ar } from "react";
3
- import { createPortal as nr } from "react-dom";
4
- import sr from "../Pagination/Pagination.mjs";
5
- import Le from "../Icon/Icon.mjs";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useRef, useMemo, useState, useEffect, createElement, isValidElement } from "react";
3
+ import { createPortal } from "react-dom";
4
+ import Pagination from "../Pagination/Pagination.mjs";
5
+ import BuIcon from "../Icon/Icon.mjs";
6
6
  /* empty css */
7
- import lr from "../Tooltip/ContentTooltip.mjs";
8
- import dr from "../Tooltip/TooltipWrapper.mjs";
9
- import { BCheckBox as fr } from "../CheckBox/index.mjs";
10
- import { BDropdown as cr } from "../Dropdown/BDropdown.mjs";
11
- import br from "../OverlayScrollbar/BOverlayScrollbar.mjs";
12
- import hr from "../SkuInputCard/spin_loading_red.gif.mjs";
13
- import or from "../ProductField/no_data_light.svg.mjs";
14
- import _r from "./Column.mjs";
15
- import ur from "./ColumnGroup.mjs";
16
- import { getColumnKey as O, filterRecords as yt, sortRecords as jt, renderColumnTitle as mt, getNextSortOrder as yr, getSorterResult as jr } from "./utils/sortFilter.mjs";
17
- import { convertChildrenToColumns as mr, flattenColumns as gr, buildHeaderRows as pr } from "./utils/columns.mjs";
7
+ import BTooltip from "../Tooltip/ContentTooltip.mjs";
8
+ import TooltipWrapper from "../Tooltip/TooltipWrapper.mjs";
9
+ import { BCheckBox as CompoundBCheckBox } from "../CheckBox/index.mjs";
10
+ import { BDropdown } from "../Dropdown/BDropdown.mjs";
11
+ import BOverlayScrollbar from "../OverlayScrollbar/BOverlayScrollbar.mjs";
12
+ import loadingIndicator from "../SkuInputCard/spin_loading_red.gif.mjs";
13
+ import defaultEmptyImage from "../ProductField/no_data_light.svg.mjs";
14
+ import Column from "./Column.mjs";
15
+ import ColumnGroup from "./ColumnGroup.mjs";
16
+ import { getColumnKey, filterRecords, sortRecords, renderColumnTitle, getNextSortOrder, getSorterResult } from "./utils/sortFilter.mjs";
17
+ import { convertChildrenToColumns, flattenColumns, buildHeaderRows } from "./utils/columns.mjs";
18
18
  /* empty css */
19
- const vr = 300, Te = 1;
20
- function L(...m) {
21
- return m.filter(Boolean).join(" ");
19
+ const FILTER_SEARCH_DEBOUNCE_MS = 300;
20
+ const SCROLL_EDGE_THRESHOLD = 1;
21
+ function classNames(...values) {
22
+ return values.filter(Boolean).join(" ");
22
23
  }
23
- function xr(m, j) {
24
- return j === void 0 ? void 0 : (Array.isArray(j) ? j : [j]).reduce((D, d) => {
25
- if (!(D == null || typeof D != "object"))
26
- return D[d];
27
- }, m);
24
+ function getValue(record, dataIndex) {
25
+ if (dataIndex === void 0) {
26
+ return void 0;
27
+ }
28
+ const path = Array.isArray(dataIndex) ? dataIndex : [dataIndex];
29
+ return path.reduce((value, key) => {
30
+ if (value === null || value === void 0 || typeof value !== "object") {
31
+ return void 0;
32
+ }
33
+ return value[key];
34
+ }, record);
28
35
  }
29
- function q(m, j, g) {
30
- if (typeof g == "function")
31
- return g(m, j);
32
- if (g) {
33
- const D = m[String(g)];
34
- if (typeof D == "string" || typeof D == "number")
35
- return D;
36
+ function getRowKey(record, index, rowKey) {
37
+ if (typeof rowKey === "function") {
38
+ return rowKey(record, index);
39
+ }
40
+ if (rowKey) {
41
+ const value = record[String(rowKey)];
42
+ if (typeof value === "string" || typeof value === "number") {
43
+ return value;
44
+ }
36
45
  }
37
- return j;
46
+ return index;
38
47
  }
39
- function Nr(m, j) {
40
- return Math.max(1, Math.ceil(m / j));
48
+ function getPageCount(total, pageSize) {
49
+ return Math.max(1, Math.ceil(total / pageSize));
41
50
  }
42
- function Rr(m) {
43
- return !!(m && typeof m == "object" && !ar(m) && "props" in m);
51
+ function isRenderedCell(value) {
52
+ return Boolean(value && typeof value === "object" && !isValidElement(value) && "props" in value);
44
53
  }
45
- function Fr(m, j) {
46
- return (typeof j.text == "string" || typeof j.text == "number" ? String(j.text) : String(j.value)).toLocaleLowerCase().includes(m.toLocaleLowerCase());
54
+ function defaultFilterSearch(input, item) {
55
+ const searchableText = typeof item.text === "string" || typeof item.text === "number" ? String(item.text) : String(item.value);
56
+ return searchableText.toLocaleLowerCase().includes(input.toLocaleLowerCase());
47
57
  }
48
- function gt({
49
- checked: m,
50
- disabled: j,
51
- label: g,
52
- name: D,
53
- onChange: d,
54
- type: A = "checkbox"
58
+ function SelectionControl({
59
+ checked,
60
+ disabled,
61
+ label,
62
+ name,
63
+ onChange,
64
+ type = "checkbox"
55
65
  }) {
56
- return A === "checkbox" ? /* @__PURE__ */ b(
57
- fr,
58
- {
59
- "aria-label": g,
60
- checked: m,
61
- className: "bj-table__selection-checkbox",
62
- disabled: j,
63
- name: D,
64
- onChange: d,
65
- skipGroup: !0
66
- }
67
- ) : /* @__PURE__ */ E("label", { className: L("bj-table__selection-control", m && "bj-table__selection-control--checked", j && "bj-table__selection-control--disabled"), children: [
68
- /* @__PURE__ */ b(
66
+ if (type === "checkbox") {
67
+ return /* @__PURE__ */ jsx(
68
+ CompoundBCheckBox,
69
+ {
70
+ "aria-label": label,
71
+ checked,
72
+ className: "bj-table__selection-checkbox",
73
+ disabled,
74
+ name,
75
+ onChange,
76
+ skipGroup: true
77
+ }
78
+ );
79
+ }
80
+ return /* @__PURE__ */ jsxs("label", { className: classNames("bj-table__selection-control", checked && "bj-table__selection-control--checked", disabled && "bj-table__selection-control--disabled"), children: [
81
+ /* @__PURE__ */ jsx(
69
82
  "input",
70
83
  {
71
- "aria-label": g,
72
- checked: m,
84
+ "aria-label": label,
85
+ checked,
73
86
  className: "bj-table__selection-input",
74
- disabled: j,
75
- name: D,
76
- onChange: d,
77
- type: A
87
+ disabled,
88
+ name,
89
+ onChange,
90
+ type
78
91
  }
79
92
  ),
80
- /* @__PURE__ */ b("span", { "aria-hidden": "true", className: "bj-table__selection-box", children: m && /* @__PURE__ */ b(Le, { className: "bj-table__selection-check-icon", type: "icon-a-dagouxi" }) })
93
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "bj-table__selection-box", children: checked && /* @__PURE__ */ jsx(BuIcon, { className: "bj-table__selection-check-icon", type: "icon-a-dagouxi" }) })
81
94
  ] });
82
95
  }
83
- function Dr({
84
- columns: m,
85
- dataSource: j = [],
86
- rowKey: g,
87
- preserveSelectedRowKeys: D = !1,
88
- rowSelection: d,
89
- pagination: A = !1,
90
- loading: ye = !1,
91
- bordered: vt = !0,
92
- size: xt = "middle",
93
- showHeader: Ie = !0,
94
- emptyText: je,
95
- emptyImage: me = or,
96
- emptyHeight: Nt,
97
- t: C = (fe) => fe,
98
- className: Rt,
99
- style: Ft,
100
- rowClassName: ge,
101
- sortDirections: Dt = ["ascend", "descend", null],
102
- onChange: pe,
103
- children: Ve,
104
- title: we,
105
- footer: Ge,
106
- summary: qe,
107
- tableLayout: ve,
108
- components: N,
109
- onRow: xe,
110
- onHeaderRow: Ne,
111
- id: Et,
112
- scroll: f,
113
- locale: ee,
114
- groupCollapse: h
96
+ function BTable({
97
+ columns,
98
+ dataSource = [],
99
+ rowKey,
100
+ preserveSelectedRowKeys = false,
101
+ rowSelection,
102
+ pagination = false,
103
+ loading = false,
104
+ bordered = true,
105
+ size = "middle",
106
+ showHeader = true,
107
+ emptyText,
108
+ emptyImage = defaultEmptyImage,
109
+ emptyHeight,
110
+ t = (text) => text,
111
+ className,
112
+ style,
113
+ rowClassName,
114
+ sortDirections = ["ascend", "descend", null],
115
+ onChange,
116
+ children,
117
+ title,
118
+ footer,
119
+ summary,
120
+ tableLayout,
121
+ components,
122
+ onRow,
123
+ onHeaderRow,
124
+ id,
125
+ scroll,
126
+ locale,
127
+ groupCollapse
115
128
  }) {
116
- var ht, ot, _t;
117
- const fe = de(null), Re = de(null), ce = X(
118
- () => m ?? mr(Ve),
119
- [Ve, m]
120
- ), re = X(() => gr(ce), [ce]), Ae = X(() => pr(ce), [ce]), [Pt, We] = R(
121
- (d == null ? void 0 : d.defaultSelectedRowKeys) ?? []
122
- ), [Fe, be] = R(
123
- A ? A.defaultCurrent ?? 1 : 1
124
- ), [kt, Ot] = R(
125
- A ? A.defaultPageSize ?? 10 : 10
126
- ), [Bt, Kt] = R(
127
- () => new Map(re.flatMap((e, t) => e.defaultSortOrder ? [[O(e, t), e.defaultSortOrder]] : []))
128
- ), [St, zt] = R(
129
- () => new Map(re.flatMap((e, t) => e.defaultFilteredValue === void 0 ? [] : [[O(e, t), e.defaultFilteredValue]]))
130
- ), [Mt, Tt] = R(
131
- h != null && h.defaultExpandedKeys ? [...h.defaultExpandedKeys] : []
132
- ), [I, U] = R(null), [$e, ie] = R(/* @__PURE__ */ new Map()), [Lt, he] = R(null), It = de(`btable-${Math.random().toString(36).slice(2, 10)}`).current, [J, De] = R(null), [Ee, He] = R(null), [Pe, Ue] = R(""), [ae, Je] = R(""), [Vt, ke] = R(), Oe = de(0), Be = de(!1), [Qe, Ze] = R({ start: 0, end: 0 }), [Xe, Ye] = R({ start: !1, end: !1 }), n = A || void 0, W = (n == null ? void 0 : n.pageSize) ?? kt, B = (d == null ? void 0 : d.selectedRowKeys) ?? Pt, y = re, wt = `${y.map((e) => `${String(e.fixed ?? "")}:${String(e.width ?? "")}`).join("|")}|${d ? String(d.columnWidth ?? "") : "-"}|${String((f == null ? void 0 : f.x) ?? "")}|${String(ve ?? "")}`, $ = (e) => !!(e && (e.fixed === "left" || e.fixed === !0)), te = (e) => !!(e && e.fixed === "right"), P = new Map(Bt), K = new Map(St);
133
- y.forEach((e, t) => {
134
- if ("children" in e) return;
135
- const r = O(e, t);
136
- e.sortOrder !== void 0 && P.set(r, e.sortOrder), e.filteredValue !== void 0 && K.set(r, e.filteredValue);
129
+ var _a, _b, _c;
130
+ const tableRootRef = useRef(null);
131
+ const tableScrollRef = useRef(null);
132
+ const mergedColumns = useMemo(
133
+ () => columns ?? convertChildrenToColumns(children),
134
+ [children, columns]
135
+ );
136
+ const leafColumns = useMemo(() => flattenColumns(mergedColumns), [mergedColumns]);
137
+ const headerRows = useMemo(() => buildHeaderRows(mergedColumns), [mergedColumns]);
138
+ const [uncontrolledSelectedKeys, setUncontrolledSelectedKeys] = useState(
139
+ (rowSelection == null ? void 0 : rowSelection.defaultSelectedRowKeys) ?? []
140
+ );
141
+ const [uncontrolledCurrent, setUncontrolledCurrent] = useState(
142
+ pagination ? pagination.defaultCurrent ?? 1 : 1
143
+ );
144
+ const [uncontrolledPageSize, setUncontrolledPageSize] = useState(
145
+ pagination ? pagination.defaultPageSize ?? 10 : 10
146
+ );
147
+ const [uncontrolledSortOrders, setUncontrolledSortOrders] = useState(
148
+ () => new Map(leafColumns.flatMap((column, index) => {
149
+ if (!column.defaultSortOrder) return [];
150
+ return [[getColumnKey(column, index), column.defaultSortOrder]];
151
+ }))
152
+ );
153
+ const [uncontrolledFilters, setUncontrolledFilters] = useState(
154
+ () => new Map(leafColumns.flatMap((column, index) => {
155
+ if (column.defaultFilteredValue === void 0) return [];
156
+ return [[getColumnKey(column, index), column.defaultFilteredValue]];
157
+ }))
158
+ );
159
+ const [uncontrolledExpandedGroupKeys, setUncontrolledExpandedGroupKeys] = useState(
160
+ (groupCollapse == null ? void 0 : groupCollapse.defaultExpandedKeys) ? [...groupCollapse.defaultExpandedKeys] : []
161
+ );
162
+ const [openFilterKey, setOpenFilterKey] = useState(null);
163
+ const [draftFilters, setDraftFilters] = useState(/* @__PURE__ */ new Map());
164
+ const [hoveredBadgeKey, setHoveredBadgeKey] = useState(null);
165
+ const tableInstanceIdRef = useRef(`btable-${Math.random().toString(36).slice(2, 10)}`);
166
+ const tableInstanceId = tableInstanceIdRef.current;
167
+ const [filterAnchor, setFilterAnchor] = useState(null);
168
+ const [filterPopupPosition, setFilterPopupPosition] = useState(null);
169
+ const [filterSearchInput, setFilterSearchInput] = useState("");
170
+ const [debouncedFilterSearch, setDebouncedFilterSearch] = useState("");
171
+ const [requestedFilterOptions, setRequestedFilterOptions] = useState();
172
+ const filterRequestIdRef = useRef(0);
173
+ const ignoreNextPaginationChangeRef = useRef(false);
174
+ const [horizontalInsets, setHorizontalInsets] = useState({ start: 0, end: 0 });
175
+ const [scrollPing, setScrollPing] = useState({ start: false, end: false });
176
+ const paginationConfig = pagination || void 0;
177
+ const pageSize = (paginationConfig == null ? void 0 : paginationConfig.pageSize) ?? uncontrolledPageSize;
178
+ const selectedKeys = (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) ?? uncontrolledSelectedKeys;
179
+ const activeColumns = leafColumns;
180
+ const fixedLayoutSignature = `${activeColumns.map((column) => `${String(column.fixed ?? "")}:${String(column.width ?? "")}`).join("|")}|${rowSelection ? String(rowSelection.columnWidth ?? "") : "-"}|${String((scroll == null ? void 0 : scroll.x) ?? "")}|${String(tableLayout ?? "")}`;
181
+ const isFixedLeftColumn = (column) => Boolean(column && (column.fixed === "left" || column.fixed === true));
182
+ const isFixedRightColumn = (column) => Boolean(column && column.fixed === "right");
183
+ const sortOrders = new Map(uncontrolledSortOrders);
184
+ const activeFilters = new Map(uncontrolledFilters);
185
+ activeColumns.forEach((rawColumn, index) => {
186
+ if ("children" in rawColumn) return;
187
+ const key = getColumnKey(rawColumn, index);
188
+ if (rawColumn.sortOrder !== void 0) sortOrders.set(key, rawColumn.sortOrder);
189
+ if (rawColumn.filteredValue !== void 0) activeFilters.set(key, rawColumn.filteredValue);
137
190
  });
138
- const Ce = X(
139
- () => yt(j, y, K),
140
- [y, K, j]
141
- ), S = X(
142
- () => jt(Ce, y, P),
143
- [y, Ce, P]
144
- ), et = (n == null ? void 0 : n.total) ?? S.length, tt = Nr(et, W), H = Math.min((n == null ? void 0 : n.current) ?? Fe, tt), Q = (h == null ? void 0 : h.expandedKeys) ?? Mt, ne = (e, t) => h != null && h.isGroupRow ? h.isGroupRow(e, t) : !!e.isGroup, oe = (e, t) => h != null && h.groupKey ? h.groupKey(e, t) : e.groupId, rt = (e, t) => h != null && h.childrenKeys ? h.childrenKeys(e, t) : e.childrenIds ?? [], Gt = (e, t) => {
145
- var a;
146
- const r = oe(e, t), s = Q.includes(r), l = s ? Q.filter((i) => i !== r) : [...Q, r];
147
- (h == null ? void 0 : h.expandedKeys) === void 0 && Tt(l), (a = h == null ? void 0 : h.onExpandedKeysChange) == null || a.call(h, l, e, !s);
191
+ const filteredData = useMemo(
192
+ () => filterRecords(dataSource, activeColumns, activeFilters),
193
+ [activeColumns, activeFilters, dataSource]
194
+ );
195
+ const processedData = useMemo(
196
+ () => sortRecords(filteredData, activeColumns, sortOrders),
197
+ [activeColumns, filteredData, sortOrders]
198
+ );
199
+ const total = (paginationConfig == null ? void 0 : paginationConfig.total) ?? processedData.length;
200
+ const pageCount = getPageCount(total, pageSize);
201
+ const current = Math.min((paginationConfig == null ? void 0 : paginationConfig.current) ?? uncontrolledCurrent, pageCount);
202
+ const expandedGroupKeys = (groupCollapse == null ? void 0 : groupCollapse.expandedKeys) ?? uncontrolledExpandedGroupKeys;
203
+ const isGroupRow = (record, index) => (groupCollapse == null ? void 0 : groupCollapse.isGroupRow) ? groupCollapse.isGroupRow(record, index) : Boolean(record.isGroup);
204
+ const getGroupKey = (record, index) => (groupCollapse == null ? void 0 : groupCollapse.groupKey) ? groupCollapse.groupKey(record, index) : record.groupId;
205
+ const getChildrenKeys = (record, index) => (groupCollapse == null ? void 0 : groupCollapse.childrenKeys) ? groupCollapse.childrenKeys(record, index) : record.childrenIds ?? [];
206
+ const toggleGroup = (record, index) => {
207
+ var _a2;
208
+ const key = getGroupKey(record, index);
209
+ const expanded = expandedGroupKeys.includes(key);
210
+ const nextKeys = expanded ? expandedGroupKeys.filter((expandedKey) => expandedKey !== key) : [...expandedGroupKeys, key];
211
+ if ((groupCollapse == null ? void 0 : groupCollapse.expandedKeys) === void 0) setUncontrolledExpandedGroupKeys(nextKeys);
212
+ (_a2 = groupCollapse == null ? void 0 : groupCollapse.onExpandedKeysChange) == null ? void 0 : _a2.call(groupCollapse, nextKeys, record, !expanded);
148
213
  };
149
- Y(() => {
150
- H !== Fe && (n == null ? void 0 : n.current) === void 0 && be(H);
151
- }, [H, n == null ? void 0 : n.current, Fe]), Y(() => {
152
- if (!J || I === null) {
153
- He(null);
214
+ useEffect(() => {
215
+ if (current !== uncontrolledCurrent && (paginationConfig == null ? void 0 : paginationConfig.current) === void 0) {
216
+ setUncontrolledCurrent(current);
217
+ }
218
+ }, [current, paginationConfig == null ? void 0 : paginationConfig.current, uncontrolledCurrent]);
219
+ useEffect(() => {
220
+ if (!filterAnchor || openFilterKey === null) {
221
+ setFilterPopupPosition(null);
154
222
  return;
155
223
  }
156
- const e = () => {
157
- const t = J.getBoundingClientRect();
158
- He({ left: t.left, top: t.bottom + 4 });
224
+ const updatePosition = () => {
225
+ const rect = filterAnchor.getBoundingClientRect();
226
+ setFilterPopupPosition({ left: rect.left, top: rect.bottom + 4 });
159
227
  };
160
- return e(), document.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
161
- document.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
228
+ updatePosition();
229
+ document.addEventListener("scroll", updatePosition, true);
230
+ window.addEventListener("resize", updatePosition);
231
+ return () => {
232
+ document.removeEventListener("scroll", updatePosition, true);
233
+ window.removeEventListener("resize", updatePosition);
162
234
  };
163
- }, [J, I]), Y(() => {
164
- if (I === null) return;
165
- const e = (t) => {
166
- const r = t.target;
167
- J != null && J.contains(r) || r.closest(".bj-table__filter-dropdown") || (U(null), De(null));
235
+ }, [filterAnchor, openFilterKey]);
236
+ useEffect(() => {
237
+ if (openFilterKey === null) return;
238
+ const handleOutsideClick = (event) => {
239
+ const target = event.target;
240
+ if ((filterAnchor == null ? void 0 : filterAnchor.contains(target)) || target.closest(".bj-table__filter-dropdown")) return;
241
+ setOpenFilterKey(null);
242
+ setFilterAnchor(null);
168
243
  };
169
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
170
- }, [J, I]), Y(() => {
171
- const e = window.setTimeout(
172
- () => Je(Pe.trim()),
173
- vr
244
+ document.addEventListener("mousedown", handleOutsideClick);
245
+ return () => document.removeEventListener("mousedown", handleOutsideClick);
246
+ }, [filterAnchor, openFilterKey]);
247
+ useEffect(() => {
248
+ const timer = window.setTimeout(
249
+ () => setDebouncedFilterSearch(filterSearchInput.trim()),
250
+ FILTER_SEARCH_DEBOUNCE_MS
174
251
  );
175
- return () => window.clearTimeout(e);
176
- }, [Pe]), Y(() => {
177
- if (I === null) return;
178
- const e = re.find((r, s) => O(r, s) === I);
179
- if (!e || "children" in e || !e.filterRequest) return;
180
- const t = ++Oe.current;
181
- Promise.resolve().then(() => e.filterRequest(ae)).then(
182
- (r) => {
183
- Oe.current === t && ke(r);
252
+ return () => window.clearTimeout(timer);
253
+ }, [filterSearchInput]);
254
+ useEffect(() => {
255
+ if (openFilterKey === null) return;
256
+ const openColumn = leafColumns.find((column, index) => getColumnKey(column, index) === openFilterKey);
257
+ if (!openColumn || "children" in openColumn || !openColumn.filterRequest) return;
258
+ const requestId = ++filterRequestIdRef.current;
259
+ Promise.resolve().then(() => openColumn.filterRequest(debouncedFilterSearch)).then(
260
+ (options) => {
261
+ if (filterRequestIdRef.current === requestId) setRequestedFilterOptions(options);
184
262
  },
185
263
  () => {
186
- Oe.current === t && ke([]);
264
+ if (filterRequestIdRef.current === requestId) setRequestedFilterOptions([]);
187
265
  }
188
266
  );
189
- }, [ae, re, I]);
190
- const V = X(() => {
191
- if (!n || n.serverPagination)
192
- return S.map((t, r) => ({ record: t, index: r })).filter(({ record: t, index: r }) => {
193
- if (!h || ne(t, r)) return !0;
194
- const s = q(t, r, g);
195
- return S.some(
196
- (l, a) => ne(l, a) && Q.includes(oe(l, a)) && rt(l, a).includes(s)
267
+ }, [debouncedFilterSearch, leafColumns, openFilterKey]);
268
+ const visibleRecords = useMemo(() => {
269
+ if (!paginationConfig || paginationConfig.serverPagination) {
270
+ return processedData.map((record, index) => ({ record, index })).filter(({ record, index }) => {
271
+ if (!groupCollapse || isGroupRow(record, index)) return true;
272
+ const childKey = getRowKey(record, index, rowKey);
273
+ return processedData.some(
274
+ (group, groupIndex) => isGroupRow(group, groupIndex) && expandedGroupKeys.includes(getGroupKey(group, groupIndex)) && getChildrenKeys(group, groupIndex).includes(childKey)
197
275
  );
198
276
  });
199
- const e = (H - 1) * W;
200
- return S.slice(e, e + W).map((t, r) => ({
201
- record: t,
202
- index: e + r
203
- })).filter(({ record: t, index: r }) => {
204
- if (!h || ne(t, r)) return !0;
205
- const s = q(t, r, g);
206
- return S.some(
207
- (l, a) => ne(l, a) && Q.includes(oe(l, a)) && rt(l, a).includes(s)
277
+ }
278
+ const start = (current - 1) * pageSize;
279
+ return processedData.slice(start, start + pageSize).map((record, index) => ({
280
+ record,
281
+ index: start + index
282
+ })).filter(({ record, index }) => {
283
+ if (!groupCollapse || isGroupRow(record, index)) return true;
284
+ const childKey = getRowKey(record, index, rowKey);
285
+ return processedData.some(
286
+ (group, groupIndex) => isGroupRow(group, groupIndex) && expandedGroupKeys.includes(getGroupKey(group, groupIndex)) && getChildrenKeys(group, groupIndex).includes(childKey)
208
287
  );
209
288
  });
210
- }, [H, Q, h, W, n, S, g]), it = X(
211
- () => V.map(({ record: e, index: t }) => q(e, t, g)),
212
- [g, V]
213
- ), qt = B.map(String).join("|"), At = it.map(String).join("|");
214
- Y(() => {
215
- var l;
216
- if (!d || D || B.length === 0) return;
217
- const e = new Set(it), t = B.filter((a) => e.has(a));
218
- if (t.length === B.length) return;
219
- d.selectedRowKeys === void 0 && We(t);
220
- const r = new Set(t), s = V.filter(({ record: a, index: i }) => r.has(q(a, i, g))).map(({ record: a }) => a);
221
- (l = d.onChange) == null || l.call(d, t, s, { type: "multiple" });
222
- }, [D, d, g, qt, At, V]), Y(() => {
223
- const e = Re.current;
224
- if (!e || !(f != null && f.x)) {
225
- Ze((a) => a.start === 0 && a.end === 0 ? a : { start: 0, end: 0 }), Ye((a) => a.start || a.end ? { start: !1, end: !1 } : a);
289
+ }, [current, expandedGroupKeys, groupCollapse, pageSize, paginationConfig, processedData, rowKey]);
290
+ const visibleSelectionKeys = useMemo(
291
+ () => visibleRecords.map(({ record, index }) => getRowKey(record, index, rowKey)),
292
+ [rowKey, visibleRecords]
293
+ );
294
+ const selectedKeySignature = selectedKeys.map(String).join("|");
295
+ const visibleKeySignature = visibleSelectionKeys.map(String).join("|");
296
+ useEffect(() => {
297
+ var _a2;
298
+ if (!rowSelection || preserveSelectedRowKeys || selectedKeys.length === 0) return;
299
+ const visibleKeySet = new Set(visibleSelectionKeys);
300
+ const nextSelectedKeys = selectedKeys.filter((key) => visibleKeySet.has(key));
301
+ if (nextSelectedKeys.length === selectedKeys.length) return;
302
+ if (rowSelection.selectedRowKeys === void 0) {
303
+ setUncontrolledSelectedKeys(nextSelectedKeys);
304
+ }
305
+ const nextSelectedKeySet = new Set(nextSelectedKeys);
306
+ const nextSelectedRows = visibleRecords.filter(({ record, index }) => nextSelectedKeySet.has(getRowKey(record, index, rowKey))).map(({ record }) => record);
307
+ (_a2 = rowSelection.onChange) == null ? void 0 : _a2.call(rowSelection, nextSelectedKeys, nextSelectedRows, { type: "multiple" });
308
+ }, [preserveSelectedRowKeys, rowSelection, rowKey, selectedKeySignature, visibleKeySignature, visibleRecords]);
309
+ useEffect(() => {
310
+ const element = tableScrollRef.current;
311
+ if (!element || !(scroll == null ? void 0 : scroll.x)) {
312
+ setHorizontalInsets((previous) => previous.start === 0 && previous.end === 0 ? previous : { start: 0, end: 0 });
313
+ setScrollPing((previous) => previous.start || previous.end ? { start: false, end: false } : previous);
226
314
  return;
227
315
  }
228
- const t = () => {
229
- const a = e.querySelector(".bj-table__header .bj-table__header-row") ?? e.querySelector(".bj-table__body .bj-table__row");
230
- let i = 0, _ = 0;
231
- if (a) {
232
- Array.from(a.children).forEach((p) => {
233
- const u = p.getBoundingClientRect().width;
234
- p.classList.contains("bj-table__cell--fixed-right") ? _ += u : (p.classList.contains("bj-table__cell--fixed-left") || p.classList.contains("bj-table__selection-cell--fixed")) && (i += u);
316
+ const measure = () => {
317
+ const layoutRow = element.querySelector(".bj-table__header .bj-table__header-row") ?? element.querySelector(".bj-table__body .bj-table__row");
318
+ let start = 0;
319
+ let end = 0;
320
+ if (layoutRow) {
321
+ Array.from(layoutRow.children).forEach((cell) => {
322
+ const width = cell.getBoundingClientRect().width;
323
+ if (cell.classList.contains("bj-table__cell--fixed-right")) {
324
+ end += width;
325
+ } else if (cell.classList.contains("bj-table__cell--fixed-left") || cell.classList.contains("bj-table__selection-cell--fixed")) {
326
+ start += width;
327
+ }
235
328
  });
236
- const o = e.clientLeft;
237
- i > 0 && (i += o), _ > 0 && (_ = Math.max(_ - o, 0));
329
+ const borderWidth = element.clientLeft;
330
+ if (start > 0) start += borderWidth;
331
+ if (end > 0) end = Math.max(end - borderWidth, 0);
238
332
  }
239
- Ze((o) => o.start === i && o.end === _ ? o : { start: i, end: _ });
240
- }, r = () => {
241
- const a = e.scrollWidth - e.clientWidth, i = a > Te, _ = {
242
- start: i && e.scrollLeft > Te,
243
- end: i && e.scrollLeft < a - Te
333
+ setHorizontalInsets((previous) => previous.start === start && previous.end === end ? previous : { start, end });
334
+ };
335
+ const syncPing = () => {
336
+ const maxScroll = element.scrollWidth - element.clientWidth;
337
+ const scrollable = maxScroll > SCROLL_EDGE_THRESHOLD;
338
+ const next = {
339
+ start: scrollable && element.scrollLeft > SCROLL_EDGE_THRESHOLD,
340
+ end: scrollable && element.scrollLeft < maxScroll - SCROLL_EDGE_THRESHOLD
244
341
  };
245
- Ye((o) => o.start === _.start && o.end === _.end ? o : _);
246
- }, s = () => {
247
- t(), r();
342
+ setScrollPing((previous) => previous.start === next.start && previous.end === next.end ? previous : next);
343
+ };
344
+ const sync = () => {
345
+ measure();
346
+ syncPing();
248
347
  };
249
- s(), e.addEventListener("scroll", r, { passive: !0 });
250
- const l = new ResizeObserver(s);
251
- return l.observe(e), e.firstElementChild && l.observe(e.firstElementChild), () => {
252
- e.removeEventListener("scroll", r), l.disconnect();
348
+ sync();
349
+ element.addEventListener("scroll", syncPing, { passive: true });
350
+ const observer = new ResizeObserver(sync);
351
+ observer.observe(element);
352
+ if (element.firstElementChild) observer.observe(element.firstElementChild);
353
+ return () => {
354
+ element.removeEventListener("scroll", syncPing);
355
+ observer.disconnect();
253
356
  };
254
- }, [wt, f == null ? void 0 : f.x, Ie, V.length]);
255
- const _e = (e, t = P, r = K, s = H, l = W) => {
256
- const a = Object.fromEntries(r), i = yt(j, y, r), _ = jt(i, y, t);
257
- pe == null || pe(
258
- { ...n, current: s, pageSize: l, total: (n == null ? void 0 : n.total) ?? _.length },
259
- a,
260
- jr(y, t),
261
- { action: e, currentDataSource: _ }
357
+ }, [fixedLayoutSignature, scroll == null ? void 0 : scroll.x, showHeader, visibleRecords.length]);
358
+ const emitChange = (action, nextSortOrders = sortOrders, nextFilters = activeFilters, nextCurrent = current, nextPageSize = pageSize) => {
359
+ const filterInfo = Object.fromEntries(nextFilters);
360
+ const nextFilteredData = filterRecords(dataSource, activeColumns, nextFilters);
361
+ const nextProcessedData = sortRecords(nextFilteredData, activeColumns, nextSortOrders);
362
+ onChange == null ? void 0 : onChange(
363
+ { ...paginationConfig, current: nextCurrent, pageSize: nextPageSize, total: (paginationConfig == null ? void 0 : paginationConfig.total) ?? nextProcessedData.length },
364
+ filterInfo,
365
+ getSorterResult(activeColumns, nextSortOrders),
366
+ { action, currentDataSource: nextProcessedData }
262
367
  );
263
- }, Wt = (e, t) => {
264
- if (!e.sorter) return;
265
- const r = O(e, t), s = yr(P.get(r) ?? null, e.sortDirections ?? Dt), l = /* @__PURE__ */ new Map();
266
- l.set(r, s), e.sortOrder === void 0 && Kt(l), _e("sort", l);
267
- }, Ke = (e, t, r) => {
268
- const s = O(e, t), l = new Map(K);
269
- l.set(s, r), e.filteredValue === void 0 && zt(l), U(null), (n == null ? void 0 : n.current) === void 0 && be(1), _e("filter", P, l, 1);
270
- }, $t = (e, t) => {
271
- const r = O(e, t), s = e.filterResetToDefaultFilteredValue ? e.defaultFilteredValue ?? [] : [];
272
- ie((l) => new Map(l).set(r, s));
273
- }, ue = (e, t, r) => {
274
- var l, a, i, _;
275
- const s = O(e, t);
276
- if (I === s) {
277
- U(null), De(null), (l = e.onFilterDropdownOpenChange) == null || l.call(e, !1), (a = e.onFilterDropdownVisibleChange) == null || a.call(e, !1);
368
+ };
369
+ const changeSorter = (column, index) => {
370
+ if (!column.sorter) return;
371
+ const key = getColumnKey(column, index);
372
+ const nextOrder = getNextSortOrder(sortOrders.get(key) ?? null, column.sortDirections ?? sortDirections);
373
+ const nextOrders = /* @__PURE__ */ new Map();
374
+ nextOrders.set(key, nextOrder);
375
+ if (column.sortOrder === void 0) setUncontrolledSortOrders(nextOrders);
376
+ emitChange("sort", nextOrders);
377
+ };
378
+ const confirmFilter = (column, index, selectedKeys2) => {
379
+ const key = getColumnKey(column, index);
380
+ const nextFilters = new Map(activeFilters);
381
+ nextFilters.set(key, selectedKeys2);
382
+ if (column.filteredValue === void 0) setUncontrolledFilters(nextFilters);
383
+ setOpenFilterKey(null);
384
+ if ((paginationConfig == null ? void 0 : paginationConfig.current) === void 0) setUncontrolledCurrent(1);
385
+ emitChange("filter", sortOrders, nextFilters, 1);
386
+ };
387
+ const resetFilter = (column, index) => {
388
+ const key = getColumnKey(column, index);
389
+ const nextKeys = column.filterResetToDefaultFilteredValue ? column.defaultFilteredValue ?? [] : [];
390
+ setDraftFilters((filters) => new Map(filters).set(key, nextKeys));
391
+ };
392
+ const toggleFilter = (column, index, anchor) => {
393
+ var _a2, _b2, _c2, _d;
394
+ const key = getColumnKey(column, index);
395
+ if (openFilterKey === key) {
396
+ setOpenFilterKey(null);
397
+ setFilterAnchor(null);
398
+ (_a2 = column.onFilterDropdownOpenChange) == null ? void 0 : _a2.call(column, false);
399
+ (_b2 = column.onFilterDropdownVisibleChange) == null ? void 0 : _b2.call(column, false);
278
400
  return;
279
401
  }
280
- Ue(""), Je(""), ke(void 0), ie((o) => new Map(o).set(s, K.get(s) ?? [])), U(s), r && De(r), (i = e.onFilterDropdownOpenChange) == null || i.call(e, !0), (_ = e.onFilterDropdownVisibleChange) == null || _.call(e, !0);
281
- }, Ht = (e, t) => {
282
- var F, M;
283
- const r = O(e, t), s = `bj-table-badge-${It}-${String(r).replace(/[^a-zA-Z0-9_-]/g, "-")}`, l = P.get(r) ?? null, a = K.get(r) ?? [], i = $e.get(r) ?? a, _ = e.filterDropdownOpen ?? e.filterDropdownVisible ?? I === r, o = e.filtered || a.length > 0, p = l === "ascend" ? "icon-a-zhengxumian" : l === "descend" ? "icon-a-daoxumian" : "icon-a-weipaixumian", u = mt(e.title, {
284
- sortOrder: l,
285
- sortColumn: l ? e : void 0,
286
- sortColumns: l ? [{ column: e, order: l }] : [],
287
- filters: Object.fromEntries(K)
288
- }), Z = typeof e.filterDropdown == "function" ? e.filterDropdown({
402
+ setFilterSearchInput("");
403
+ setDebouncedFilterSearch("");
404
+ setRequestedFilterOptions(void 0);
405
+ setDraftFilters((filters) => new Map(filters).set(key, activeFilters.get(key) ?? []));
406
+ setOpenFilterKey(key);
407
+ if (anchor) setFilterAnchor(anchor);
408
+ (_c2 = column.onFilterDropdownOpenChange) == null ? void 0 : _c2.call(column, true);
409
+ (_d = column.onFilterDropdownVisibleChange) == null ? void 0 : _d.call(column, true);
410
+ };
411
+ const renderHeaderCell = (column, index) => {
412
+ var _a2, _b2;
413
+ const key = getColumnKey(column, index);
414
+ const badgeId = `bj-table-badge-${tableInstanceId}-${String(key).replace(/[^a-zA-Z0-9_-]/g, "-")}`;
415
+ const sortOrder = sortOrders.get(key) ?? null;
416
+ const filteredKeys = activeFilters.get(key) ?? [];
417
+ const draftKeys = draftFilters.get(key) ?? filteredKeys;
418
+ const isFilterOpen = column.filterDropdownOpen ?? column.filterDropdownVisible ?? openFilterKey === key;
419
+ const isFiltered = column.filtered || filteredKeys.length > 0;
420
+ const sortIconType = sortOrder === "ascend" ? "icon-a-zhengxumian" : sortOrder === "descend" ? "icon-a-daoxumian" : "icon-a-weipaixumian";
421
+ const title2 = renderColumnTitle(column.title, {
422
+ sortOrder,
423
+ sortColumn: sortOrder ? column : void 0,
424
+ sortColumns: sortOrder ? [{ column, order: sortOrder }] : [],
425
+ filters: Object.fromEntries(activeFilters)
426
+ });
427
+ const customFilterContent = typeof column.filterDropdown === "function" ? column.filterDropdown({
289
428
  prefixCls: "bj-table",
290
- selectedKeys: i.filter((c) => typeof c != "boolean"),
291
- setSelectedKeys: (c) => ie((x) => new Map(x).set(r, c)),
292
- confirm: (c) => {
293
- Ke(e, t, $e.get(r) ?? i), (c == null ? void 0 : c.closeDropdown) === !1 && U(r);
429
+ selectedKeys: draftKeys.filter((value) => typeof value !== "boolean"),
430
+ setSelectedKeys: (keys) => setDraftFilters((filters) => new Map(filters).set(key, keys)),
431
+ confirm: (options) => {
432
+ confirmFilter(column, index, draftFilters.get(key) ?? draftKeys);
433
+ if ((options == null ? void 0 : options.closeDropdown) === false) setOpenFilterKey(key);
294
434
  },
295
- clearFilters: (c) => {
296
- const x = e.filterResetToDefaultFilteredValue ? e.defaultFilteredValue ?? [] : [];
297
- ie((k) => new Map(k).set(r, x)), (c == null ? void 0 : c.confirm) === !0 && Ke(e, t, x), ((c == null ? void 0 : c.closeDropdown) === !1 || (c == null ? void 0 : c.confirm) !== !0) && U(r);
435
+ clearFilters: (options) => {
436
+ const nextKeys = column.filterResetToDefaultFilteredValue ? column.defaultFilteredValue ?? [] : [];
437
+ setDraftFilters((filters) => new Map(filters).set(key, nextKeys));
438
+ if ((options == null ? void 0 : options.confirm) === true) confirmFilter(column, index, nextKeys);
439
+ if ((options == null ? void 0 : options.closeDropdown) === false || (options == null ? void 0 : options.confirm) !== true) setOpenFilterKey(key);
298
440
  },
299
- filters: e.filters,
300
- close: () => U(null),
301
- visible: _
302
- }) : e.filterDropdown, G = e.filterRequest ? Vt ?? [] : e.filters ?? [], T = ae && !e.filterRequest ? G.filter((c) => typeof e.filterSearch == "function" ? e.filterSearch(ae, c) : Fr(ae, c)) : G, v = !!(e.filterSearch || e.filterRequest), z = /* @__PURE__ */ E("div", { className: L("bj-table__column-header", e.sorter && "bj-table__column-header--sortable"), children: [
303
- e.badge !== void 0 && /* @__PURE__ */ b(
441
+ filters: column.filters,
442
+ close: () => setOpenFilterKey(null),
443
+ visible: isFilterOpen
444
+ }) : column.filterDropdown;
445
+ const filterOptions = column.filterRequest ? requestedFilterOptions ?? [] : column.filters ?? [];
446
+ const visibleFilterOptions = debouncedFilterSearch && !column.filterRequest ? filterOptions.filter((option) => typeof column.filterSearch === "function" ? column.filterSearch(debouncedFilterSearch, option) : defaultFilterSearch(debouncedFilterSearch, option)) : filterOptions;
447
+ const showFilterSearch = Boolean(column.filterSearch || column.filterRequest);
448
+ const headerContent = /* @__PURE__ */ jsxs("div", { className: classNames("bj-table__column-header", column.sorter && "bj-table__column-header--sortable"), children: [
449
+ column.badge !== void 0 && /* @__PURE__ */ jsx(
304
450
  "span",
305
451
  {
306
452
  "aria-label": "表头提示",
307
453
  className: "bj-table__column-badge-trigger",
308
- id: s,
309
- onBlur: () => he(null),
310
- onClick: (c) => c.stopPropagation(),
311
- onFocus: () => he(r),
312
- onKeyDown: (c) => c.stopPropagation(),
313
- onMouseEnter: () => he(r),
314
- onMouseLeave: () => he(null),
454
+ id: badgeId,
455
+ onBlur: () => setHoveredBadgeKey(null),
456
+ onClick: (event) => event.stopPropagation(),
457
+ onFocus: () => setHoveredBadgeKey(key),
458
+ onKeyDown: (event) => event.stopPropagation(),
459
+ onMouseEnter: () => setHoveredBadgeKey(key),
460
+ onMouseLeave: () => setHoveredBadgeKey(null),
315
461
  role: "button",
316
462
  tabIndex: 0,
317
- children: /* @__PURE__ */ b("span", { "aria-hidden": "true", className: "bj-table__column-badge-shape" })
463
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "bj-table__column-badge-shape" })
318
464
  }
319
465
  ),
320
- /* @__PURE__ */ E("div", { className: "bj-table__column-title", children: [
321
- /* @__PURE__ */ b("span", { className: "bj-table__column-title-content", children: u }),
322
- e.sorter && /* @__PURE__ */ b("span", { "aria-hidden": "true", className: "bj-table__column-sorter", children: /* @__PURE__ */ b(Le, { className: "bj-table__column-sorter-icon", type: p }) })
466
+ /* @__PURE__ */ jsxs("div", { className: "bj-table__column-title", children: [
467
+ /* @__PURE__ */ jsx("span", { className: "bj-table__column-title-content", children: title2 }),
468
+ column.sorter && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "bj-table__column-sorter", children: /* @__PURE__ */ jsx(BuIcon, { className: "bj-table__column-sorter-icon", type: sortIconType }) })
323
469
  ] }),
324
- (e.filters || e.filterDropdown) && /* @__PURE__ */ E("div", { className: "bj-table__filter", children: [
325
- /* @__PURE__ */ b(
470
+ (column.filters || column.filterDropdown) && /* @__PURE__ */ jsxs("div", { className: "bj-table__filter", children: [
471
+ /* @__PURE__ */ jsx(
326
472
  "button",
327
473
  {
328
- "aria-expanded": _,
474
+ "aria-expanded": isFilterOpen,
329
475
  "aria-label": "筛选",
330
- className: L("bj-table__filter-trigger", o && "bj-table__filter-trigger--active"),
331
- onClick: (c) => {
332
- c.stopPropagation(), ue(e, t);
476
+ className: classNames("bj-table__filter-trigger", isFiltered && "bj-table__filter-trigger--active"),
477
+ onClick: (event) => {
478
+ event.stopPropagation();
479
+ toggleFilter(column, index);
333
480
  },
334
481
  type: "button",
335
- children: typeof e.filterIcon == "function" ? e.filterIcon(o) : e.filterIcon ?? /* @__PURE__ */ b(Le, { className: "bj-table__filter-icon", type: "icon-a-shaixuanxi" })
482
+ children: typeof column.filterIcon === "function" ? column.filterIcon(isFiltered) : column.filterIcon ?? /* @__PURE__ */ jsx(
483
+ BuIcon,
484
+ {
485
+ className: "bj-table__filter-icon",
486
+ type: isFiltered ? "icon-shaixuan-daidian" : "icon-a-shaixuanxi"
487
+ }
488
+ )
336
489
  }
337
490
  ),
338
- _ && Ee && typeof document < "u" && nr(
339
- /* @__PURE__ */ b(
491
+ isFilterOpen && filterPopupPosition && typeof document !== "undefined" && createPortal(
492
+ /* @__PURE__ */ jsx(
340
493
  "div",
341
494
  {
342
495
  className: "bj-table__filter-dropdown",
343
- onClick: (c) => c.stopPropagation(),
496
+ onClick: (event) => event.stopPropagation(),
344
497
  role: "dialog",
345
- style: { left: Ee.left, top: Ee.top },
346
- children: Z ?? /* @__PURE__ */ b(
347
- cr,
498
+ style: { left: filterPopupPosition.left, top: filterPopupPosition.top },
499
+ children: customFilterContent ?? /* @__PURE__ */ jsx(
500
+ BDropdown,
348
501
  {
349
- ...e.filterDropdownProps,
350
- emptyText: (ee == null ? void 0 : ee.filterEmptyText) ?? C("暂无结果"),
351
- multiple: e.filterMultiple !== !1,
352
- onChange: (c, x) => {
353
- var k, ut;
354
- ie((ir) => new Map(ir).set(r, c)), (ut = (k = e.filterDropdownProps) == null ? void 0 : k.onChange) == null || ut.call(k, c, x);
502
+ ...column.filterDropdownProps,
503
+ emptyText: (locale == null ? void 0 : locale.filterEmptyText) ?? t("暂无结果"),
504
+ multiple: column.filterMultiple !== false,
505
+ onChange: (nextKeys, option) => {
506
+ var _a3, _b3;
507
+ setDraftFilters((filters) => new Map(filters).set(key, nextKeys));
508
+ (_b3 = (_a3 = column.filterDropdownProps) == null ? void 0 : _a3.onChange) == null ? void 0 : _b3.call(_a3, nextKeys, option);
355
509
  },
356
- onConfirm: (c) => {
357
- var x, k;
358
- Ke(e, t, c), (k = (x = e.filterDropdownProps) == null ? void 0 : x.onConfirm) == null || k.call(x, c);
510
+ onConfirm: (nextKeys) => {
511
+ var _a3, _b3;
512
+ confirmFilter(column, index, nextKeys);
513
+ (_b3 = (_a3 = column.filterDropdownProps) == null ? void 0 : _a3.onConfirm) == null ? void 0 : _b3.call(_a3, nextKeys);
359
514
  },
360
515
  onReset: () => {
361
- var c, x;
362
- $t(e, t), (x = (c = e.filterDropdownProps) == null ? void 0 : c.onReset) == null || x.call(c);
516
+ var _a3, _b3;
517
+ resetFilter(column, index);
518
+ (_b3 = (_a3 = column.filterDropdownProps) == null ? void 0 : _a3.onReset) == null ? void 0 : _b3.call(_a3);
363
519
  },
364
- onSearch: (c) => {
365
- var x, k;
366
- Ue(c), (k = (x = e.filterDropdownProps) == null ? void 0 : x.onSearch) == null || k.call(x, c);
520
+ onSearch: (nextSearchValue) => {
521
+ var _a3, _b3;
522
+ setFilterSearchInput(nextSearchValue);
523
+ (_b3 = (_a3 = column.filterDropdownProps) == null ? void 0 : _a3.onSearch) == null ? void 0 : _b3.call(_a3, nextSearchValue);
367
524
  },
368
- options: T.map((c) => ({
369
- label: c.text,
370
- description: c.description,
371
- value: c.value
525
+ options: visibleFilterOptions.map((option) => ({
526
+ label: option.text,
527
+ description: option.description,
528
+ value: option.value
372
529
  })),
373
- searchable: ((F = e.filterDropdownProps) == null ? void 0 : F.searchable) ?? v,
374
- searchPlaceholder: ((M = e.filterDropdownProps) == null ? void 0 : M.searchPlaceholder) ?? (e.filterRequest ? C("请输入搜索内容") : (ee == null ? void 0 : ee.filterSearchPlaceholder) ?? C("搜索")),
375
- searchValue: Pe,
376
- t: C,
377
- value: i
530
+ searchable: ((_a2 = column.filterDropdownProps) == null ? void 0 : _a2.searchable) ?? showFilterSearch,
531
+ searchPlaceholder: ((_b2 = column.filterDropdownProps) == null ? void 0 : _b2.searchPlaceholder) ?? (column.filterRequest ? t("请输入搜索内容") : (locale == null ? void 0 : locale.filterSearchPlaceholder) ?? t("搜索")),
532
+ searchValue: filterSearchInput,
533
+ t,
534
+ value: draftKeys
378
535
  }
379
536
  )
380
537
  }
@@ -383,316 +540,411 @@ function Dr({
383
540
  )
384
541
  ] })
385
542
  ] });
386
- return e.badge !== void 0 ? /* @__PURE__ */ E(
387
- dr,
543
+ return column.badge !== void 0 ? /* @__PURE__ */ jsxs(
544
+ TooltipWrapper,
388
545
  {
389
546
  className: "bj-table__column-tooltip-wrapper",
390
547
  children: [
391
- /* @__PURE__ */ b("div", { className: "bj-table__column-tooltip-trigger", children: z }),
392
- Lt === r && /* @__PURE__ */ b(
393
- lr,
548
+ /* @__PURE__ */ jsx("div", { className: "bj-table__column-tooltip-trigger", children: headerContent }),
549
+ hoveredBadgeKey === key && /* @__PURE__ */ jsx(
550
+ BTooltip,
394
551
  {
395
552
  className: "bj-table__column-tooltip",
396
- content: e.badge,
397
- getAnchorElement: () => document.getElementById(s),
553
+ content: column.badge,
554
+ getAnchorElement: () => document.getElementById(badgeId),
398
555
  getPopupContainer: () => document.body,
399
556
  placement: "top"
400
557
  }
401
558
  )
402
559
  ]
403
560
  }
404
- ) : z;
405
- }, at = (e, t, r) => {
406
- var a, i;
407
- t.selectedRowKeys === void 0 && We(e);
408
- const s = new Set(e), l = j.filter(
409
- (_, o) => s.has(q(_, o, g))
561
+ ) : headerContent;
562
+ };
563
+ const updateSelection = (nextSelectedKeys, selection, selectedRecord) => {
564
+ var _a2, _b2;
565
+ if (selection.selectedRowKeys === void 0) {
566
+ setUncontrolledSelectedKeys(nextSelectedKeys);
567
+ }
568
+ const selectedKeySet = new Set(nextSelectedKeys);
569
+ const selectedRows = dataSource.filter(
570
+ (record, index) => selectedKeySet.has(getRowKey(record, index, rowKey))
410
571
  );
411
- (a = t.onChange) == null || a.call(t, e, l), r && ((i = t.onSelect) == null || i.call(
412
- t,
413
- r,
414
- s.has(q(r, j.indexOf(r), g)),
415
- l
416
- ));
417
- }, Ut = (e, t) => {
418
- if (!d)
572
+ (_a2 = selection.onChange) == null ? void 0 : _a2.call(selection, nextSelectedKeys, selectedRows);
573
+ if (selectedRecord) {
574
+ (_b2 = selection.onSelect) == null ? void 0 : _b2.call(
575
+ selection,
576
+ selectedRecord,
577
+ selectedKeySet.has(getRowKey(selectedRecord, dataSource.indexOf(selectedRecord), rowKey)),
578
+ selectedRows
579
+ );
580
+ }
581
+ };
582
+ const toggleRow = (record, index) => {
583
+ if (!rowSelection) {
419
584
  return;
420
- const r = q(e, t, g), s = B.includes(r), l = d.type === "radio" ? s ? [] : [r] : s ? B.filter((a) => a !== r) : [...B, r];
421
- at(l, d, e);
422
- }, nt = V.filter(
423
- ({ record: e }) => {
424
- var t;
425
- return !((t = d == null ? void 0 : d.getCheckboxProps) != null && t.call(d, e).disabled);
426
585
  }
427
- ), se = nt.map(
428
- ({ record: e, index: t }) => q(e, t, g)
429
- ), Se = se.length > 0 && se.every((e) => B.includes(e)), Jt = () => {
430
- var r;
431
- if (!d || d.type === "radio")
586
+ const key = getRowKey(record, index, rowKey);
587
+ const selected = selectedKeys.includes(key);
588
+ const nextSelectedKeys = rowSelection.type === "radio" ? selected ? [] : [key] : selected ? selectedKeys.filter((selectedKey) => selectedKey !== key) : [...selectedKeys, key];
589
+ updateSelection(nextSelectedKeys, rowSelection, record);
590
+ };
591
+ const selectableVisibleRecords = visibleRecords.filter(
592
+ ({ record }) => {
593
+ var _a2;
594
+ return !((_a2 = rowSelection == null ? void 0 : rowSelection.getCheckboxProps) == null ? void 0 : _a2.call(rowSelection, record).disabled);
595
+ }
596
+ );
597
+ const selectableVisibleKeys = selectableVisibleRecords.map(
598
+ ({ record, index }) => getRowKey(record, index, rowKey)
599
+ );
600
+ const allVisibleSelected = selectableVisibleKeys.length > 0 && selectableVisibleKeys.every((key) => selectedKeys.includes(key));
601
+ const toggleAll = () => {
602
+ var _a2;
603
+ if (!rowSelection || rowSelection.type === "radio") {
432
604
  return;
433
- const e = new Set(se), t = Se ? B.filter((s) => !e.has(s)) : Array.from(/* @__PURE__ */ new Set([...B, ...se]));
434
- at(t, d), new Set(t), (r = d.onSelectAll) == null || r.call(
435
- d,
436
- !Se,
437
- nt.map(({ record: s }) => s)
605
+ }
606
+ const visibleKeySet = new Set(selectableVisibleKeys);
607
+ const nextSelectedKeys = allVisibleSelected ? selectedKeys.filter((key) => !visibleKeySet.has(key)) : Array.from(/* @__PURE__ */ new Set([...selectedKeys, ...selectableVisibleKeys]));
608
+ updateSelection(nextSelectedKeys, rowSelection);
609
+ new Set(nextSelectedKeys);
610
+ (_a2 = rowSelection.onSelectAll) == null ? void 0 : _a2.call(
611
+ rowSelection,
612
+ !allVisibleSelected,
613
+ selectableVisibleRecords.map(({ record }) => record)
438
614
  );
439
- }, Qt = (e) => {
440
- var t;
441
- !n || e < 1 || e > tt || e === H || (n.current === void 0 && be(e), (t = n.onChange) == null || t.call(n, e, W), _e("paginate", P, K, e));
442
- }, Zt = (e) => {
443
- var r, s;
444
- if (!n || e === W)
615
+ };
616
+ const changePage = (nextPage) => {
617
+ var _a2;
618
+ if (!paginationConfig || nextPage < 1 || nextPage > pageCount || nextPage === current) {
445
619
  return;
446
- const t = 1;
447
- Be.current = !0, n.pageSize === void 0 && Ot(e), n.current === void 0 && be(t), (r = n.onShowSizeChange) == null || r.call(n, t, e), (s = n.onChange) == null || s.call(n, t, e), _e("paginate", P, K, t, e);
448
- }, st = y.length + (d ? 1 : 0), le = (d == null ? void 0 : d.columnWidth) ?? 48, lt = (e) => typeof e.width == "number" ? e.width : 0, dt = (e, t) => {
449
- const r = e.fixed === !0 ? "left" : e.fixed;
450
- return r === "left" ? { position: "sticky", left: y.slice(0, t).reduce((l, a) => l + lt(a), d && typeof le == "number" ? le : 0), zIndex: 2 } : r === "right" ? { position: "sticky", right: y.slice(t + 1).reduce((l, a) => l + lt(a), 0), zIndex: 2 } : {};
451
- }, Xt = f != null && f.x ? {
452
- width: f.x === !0 ? "max-content" : f.x,
620
+ }
621
+ if (paginationConfig.current === void 0) {
622
+ setUncontrolledCurrent(nextPage);
623
+ }
624
+ (_a2 = paginationConfig.onChange) == null ? void 0 : _a2.call(paginationConfig, nextPage, pageSize);
625
+ emitChange("paginate", sortOrders, activeFilters, nextPage);
626
+ };
627
+ const changePageSize = (nextPageSize) => {
628
+ var _a2, _b2;
629
+ if (!paginationConfig || nextPageSize === pageSize) {
630
+ return;
631
+ }
632
+ const nextCurrent = 1;
633
+ ignoreNextPaginationChangeRef.current = true;
634
+ if (paginationConfig.pageSize === void 0) {
635
+ setUncontrolledPageSize(nextPageSize);
636
+ }
637
+ if (paginationConfig.current === void 0) {
638
+ setUncontrolledCurrent(nextCurrent);
639
+ }
640
+ (_a2 = paginationConfig.onShowSizeChange) == null ? void 0 : _a2.call(paginationConfig, nextCurrent, nextPageSize);
641
+ (_b2 = paginationConfig.onChange) == null ? void 0 : _b2.call(paginationConfig, nextCurrent, nextPageSize);
642
+ emitChange("paginate", sortOrders, activeFilters, nextCurrent, nextPageSize);
643
+ };
644
+ const columnCount = activeColumns.length + (rowSelection ? 1 : 0);
645
+ const selectionColumnWidth = (rowSelection == null ? void 0 : rowSelection.columnWidth) ?? 48;
646
+ const getColumnWidth = (column) => typeof column.width === "number" ? column.width : 0;
647
+ const getFixedStyle = (column, columnIndex) => {
648
+ const fixed = column.fixed === true ? "left" : column.fixed;
649
+ if (fixed === "left") {
650
+ const left = activeColumns.slice(0, columnIndex).reduce((offset, current2) => offset + getColumnWidth(current2), rowSelection && typeof selectionColumnWidth === "number" ? selectionColumnWidth : 0);
651
+ return { position: "sticky", left, zIndex: 2 };
652
+ }
653
+ if (fixed === "right") {
654
+ const right = activeColumns.slice(columnIndex + 1).reduce((offset, current2) => offset + getColumnWidth(current2), 0);
655
+ return { position: "sticky", right, zIndex: 2 };
656
+ }
657
+ return {};
658
+ };
659
+ const scrollTableStyle = (scroll == null ? void 0 : scroll.x) ? {
660
+ width: scroll.x === true ? "max-content" : scroll.x,
453
661
  minWidth: "100%",
454
- tableLayout: ve ?? "fixed"
455
- } : { tableLayout: ve }, Yt = (N == null ? void 0 : N.table) ?? "table", Ct = ((ht = N == null ? void 0 : N.header) == null ? void 0 : ht.wrapper) ?? "thead", er = ((ot = N == null ? void 0 : N.header) == null ? void 0 : ot.row) ?? "tr", ft = ((_t = N == null ? void 0 : N.header) == null ? void 0 : _t.cell) ?? "th", w = typeof (N == null ? void 0 : N.body) == "object" ? N.body : void 0, tr = (w == null ? void 0 : w.wrapper) ?? "tbody", ct = (w == null ? void 0 : w.row) ?? "tr", ze = (w == null ? void 0 : w.cell) ?? "td", rr = typeof je == "function" ? je() : je ?? C("暂无数据"), bt = typeof me == "string" ? /* @__PURE__ */ b("img", { alt: "", className: "bj-table__empty-image", src: me }) : me;
456
- return /* @__PURE__ */ E(
662
+ tableLayout: tableLayout ?? "fixed"
663
+ } : { tableLayout };
664
+ const TableComponent = (components == null ? void 0 : components.table) ?? "table";
665
+ const HeaderWrapper = ((_a = components == null ? void 0 : components.header) == null ? void 0 : _a.wrapper) ?? "thead";
666
+ const HeaderRow = ((_b = components == null ? void 0 : components.header) == null ? void 0 : _b.row) ?? "tr";
667
+ const HeaderCell = ((_c = components == null ? void 0 : components.header) == null ? void 0 : _c.cell) ?? "th";
668
+ const bodyComponents = typeof (components == null ? void 0 : components.body) === "object" ? components.body : void 0;
669
+ const BodyWrapper = (bodyComponents == null ? void 0 : bodyComponents.wrapper) ?? "tbody";
670
+ const BodyRow = (bodyComponents == null ? void 0 : bodyComponents.row) ?? "tr";
671
+ const BodyCell = (bodyComponents == null ? void 0 : bodyComponents.cell) ?? "td";
672
+ const resolvedEmptyText = typeof emptyText === "function" ? emptyText() : emptyText ?? t("暂无数据");
673
+ const resolvedEmptyImage = typeof emptyImage === "string" ? /* @__PURE__ */ jsx("img", { alt: "", className: "bj-table__empty-image", src: emptyImage }) : emptyImage;
674
+ return /* @__PURE__ */ jsxs(
457
675
  "div",
458
676
  {
459
- id: Et,
460
- ref: fe,
461
- className: L(
677
+ id,
678
+ ref: tableRootRef,
679
+ className: classNames(
462
680
  "bj-table",
463
- vt && "bj-table--bordered",
464
- `bj-table--${xt}`,
465
- ye && "bj-table--loading",
466
- S.length === 0 && "bj-table--empty",
467
- Xe.start && "bj-table--ping-left",
468
- Xe.end && "bj-table--ping-right",
469
- Rt
681
+ bordered && "bj-table--bordered",
682
+ `bj-table--${size}`,
683
+ loading && "bj-table--loading",
684
+ processedData.length === 0 && "bj-table--empty",
685
+ scrollPing.start && "bj-table--ping-left",
686
+ scrollPing.end && "bj-table--ping-right",
687
+ className
470
688
  ),
471
- style: Ft,
689
+ style,
472
690
  children: [
473
- we && /* @__PURE__ */ b("div", { className: "bj-table__title", children: we(S) }),
474
- /* @__PURE__ */ E("div", { className: "bj-table__viewport", children: [
475
- /* @__PURE__ */ b(
691
+ title && /* @__PURE__ */ jsx("div", { className: "bj-table__title", children: title(processedData) }),
692
+ /* @__PURE__ */ jsxs("div", { className: "bj-table__viewport", children: [
693
+ /* @__PURE__ */ jsx(
476
694
  "div",
477
695
  {
478
- className: L("bj-table__scroll", !!(f != null && f.x || f != null && f.y) && "bj-overlay-scrollbar-hidden"),
479
- ref: Re,
480
- style: { maxHeight: f == null ? void 0 : f.y },
481
- children: /* @__PURE__ */ E(Yt, { className: "bj-table__native-table", style: Xt, children: [
482
- y.some((e) => e.width) && /* @__PURE__ */ E("colgroup", { children: [
483
- d && /* @__PURE__ */ b("col", { className: "bj-table__selection-col", style: { width: le } }),
484
- y.map((e, t) => /* @__PURE__ */ b("col", { style: { width: e.width } }, e.key ?? t))
696
+ className: classNames("bj-table__scroll", Boolean((scroll == null ? void 0 : scroll.x) || (scroll == null ? void 0 : scroll.y)) && "bj-overlay-scrollbar-hidden"),
697
+ ref: tableScrollRef,
698
+ style: { maxHeight: scroll == null ? void 0 : scroll.y },
699
+ children: /* @__PURE__ */ jsxs(TableComponent, { className: "bj-table__native-table", style: scrollTableStyle, children: [
700
+ activeColumns.some((column) => column.width) && /* @__PURE__ */ jsxs("colgroup", { children: [
701
+ rowSelection && /* @__PURE__ */ jsx("col", { className: "bj-table__selection-col", style: { width: selectionColumnWidth } }),
702
+ activeColumns.map((column, index) => /* @__PURE__ */ jsx("col", { style: { width: column.width } }, column.key ?? index))
485
703
  ] }),
486
- Ie && /* @__PURE__ */ b(Ct, { className: "bj-table__header", children: Ae.map((e, t) => /* @__PURE__ */ E(er, { className: "bj-table__header-row", ...Ne == null ? void 0 : Ne(y, t), children: [
487
- d && t === 0 && /* @__PURE__ */ E(
488
- ft,
704
+ showHeader && /* @__PURE__ */ jsx(HeaderWrapper, { className: "bj-table__header", children: headerRows.map((headerRow, rowIndex) => /* @__PURE__ */ jsxs(HeaderRow, { className: "bj-table__header-row", ...onHeaderRow == null ? void 0 : onHeaderRow(activeColumns, rowIndex), children: [
705
+ rowSelection && rowIndex === 0 && /* @__PURE__ */ jsxs(
706
+ HeaderCell,
489
707
  {
490
- className: L(
708
+ className: classNames(
491
709
  "bj-table__header-cell",
492
710
  "bj-table__selection-cell",
493
- !!(f != null && f.x) && "bj-table__selection-cell--fixed",
711
+ Boolean(scroll == null ? void 0 : scroll.x) && "bj-table__selection-cell--fixed",
494
712
  // 选择列就是最后一个左固定区域时,由它承担左侧渐变阴影
495
- !!(f != null && f.x) && !$(y[0]) && "bj-table__cell--fixed-left-last"
713
+ Boolean(scroll == null ? void 0 : scroll.x) && !isFixedLeftColumn(activeColumns[0]) && "bj-table__cell--fixed-left-last"
496
714
  ),
497
- rowSpan: Ae.length,
715
+ rowSpan: headerRows.length,
498
716
  scope: "col",
499
- style: { width: le },
717
+ style: { width: selectionColumnWidth },
500
718
  children: [
501
- d.type !== "radio" && /* @__PURE__ */ b(
502
- gt,
719
+ rowSelection.type !== "radio" && /* @__PURE__ */ jsx(
720
+ SelectionControl,
503
721
  {
504
- checked: Se,
505
- disabled: se.length === 0,
506
- onChange: Jt,
722
+ checked: allVisibleSelected,
723
+ disabled: selectableVisibleKeys.length === 0,
724
+ onChange: toggleAll,
507
725
  label: "选择当前页所有行"
508
726
  }
509
727
  ),
510
- d.columnTitle
728
+ rowSelection.columnTitle
511
729
  ]
512
730
  }
513
731
  ),
514
- e.map(({ column: r, colSpan: s, rowSpan: l }, a) => {
515
- var G, T;
516
- const i = r, _ = y.indexOf(i), o = _ >= 0 ? _ : a, p = !("children" in r) && !!(i.filters || i.filterDropdown), u = !("children" in r) && !!i.sorter, Z = () => {
517
- p ? ue(i, o) : u && Wt(i, o);
732
+ headerRow.map(({ column: rawColumn, colSpan, rowSpan }, index) => {
733
+ var _a2, _b2;
734
+ const column = rawColumn;
735
+ const leafIndex = activeColumns.indexOf(column);
736
+ const interactionIndex = leafIndex >= 0 ? leafIndex : index;
737
+ const isFilterable = !("children" in rawColumn) && Boolean(column.filters || column.filterDropdown);
738
+ const isSortable = !("children" in rawColumn) && Boolean(column.sorter);
739
+ const triggerHeaderAction = () => {
740
+ if (isFilterable) {
741
+ toggleFilter(column, interactionIndex);
742
+ } else if (isSortable) {
743
+ changeSorter(column, interactionIndex);
744
+ }
518
745
  };
519
- return /* @__PURE__ */ Me(
520
- ft,
746
+ return /* @__PURE__ */ createElement(
747
+ HeaderCell,
521
748
  {
522
- ...(G = i.onHeaderCell) == null ? void 0 : G.call(i, r, a),
523
- "aria-label": typeof i.title == "string" ? i.title : void 0,
524
- "aria-sort": u ? P.get(O(i, o)) === "ascend" ? "ascending" : P.get(O(i, o)) === "descend" ? "descending" : "none" : void 0,
525
- className: L(
749
+ ...(_a2 = column.onHeaderCell) == null ? void 0 : _a2.call(column, rawColumn, index),
750
+ "aria-label": typeof column.title === "string" ? column.title : void 0,
751
+ "aria-sort": isSortable ? sortOrders.get(getColumnKey(column, interactionIndex)) === "ascend" ? "ascending" : sortOrders.get(getColumnKey(column, interactionIndex)) === "descend" ? "descending" : "none" : void 0,
752
+ className: classNames(
526
753
  "bj-table__header-cell",
527
- ((T = y[o + 1]) == null ? void 0 : T.fixed) === "right" && "bj-table__cell--before-fixed-right",
528
- i.fixed && "bj-table__cell--fixed",
529
- $(i) && "bj-table__cell--fixed-left",
530
- $(i) && !$(y[o + 1]) && "bj-table__cell--fixed-left-last",
531
- te(i) && "bj-table__cell--fixed-right",
532
- te(i) && !te(y[o - 1]) && "bj-table__cell--fixed-right-first",
533
- i.sorter && "bj-table__header-cell--sortable",
534
- p && "bj-table__header-cell--filterable",
535
- P.get(O(i, o)) && "bj-table__header-cell--sorted",
536
- i.className
754
+ ((_b2 = activeColumns[interactionIndex + 1]) == null ? void 0 : _b2.fixed) === "right" && "bj-table__cell--before-fixed-right",
755
+ column.fixed && "bj-table__cell--fixed",
756
+ isFixedLeftColumn(column) && "bj-table__cell--fixed-left",
757
+ isFixedLeftColumn(column) && !isFixedLeftColumn(activeColumns[interactionIndex + 1]) && "bj-table__cell--fixed-left-last",
758
+ isFixedRightColumn(column) && "bj-table__cell--fixed-right",
759
+ isFixedRightColumn(column) && !isFixedRightColumn(activeColumns[interactionIndex - 1]) && "bj-table__cell--fixed-right-first",
760
+ column.sorter && "bj-table__header-cell--sortable",
761
+ isFilterable && "bj-table__header-cell--filterable",
762
+ sortOrders.get(getColumnKey(column, interactionIndex)) && "bj-table__header-cell--sorted",
763
+ column.className
537
764
  ),
538
- colSpan: s,
539
- key: i.key ?? String(i.dataIndex ?? a),
540
- onClick: (v) => {
541
- var z, F, M;
542
- (M = (F = (z = i.onHeaderCell) == null ? void 0 : z.call(i, r, a)) == null ? void 0 : F.onClick) == null || M.call(F, v), !v.target.closest(".bj-table__filter-dropdown") && (p ? ue(i, o, v.currentTarget) : Z());
765
+ colSpan,
766
+ key: column.key ?? String(column.dataIndex ?? index),
767
+ onClick: (event) => {
768
+ var _a3, _b3, _c2;
769
+ (_c2 = (_b3 = (_a3 = column.onHeaderCell) == null ? void 0 : _a3.call(column, rawColumn, index)) == null ? void 0 : _b3.onClick) == null ? void 0 : _c2.call(_b3, event);
770
+ if (event.target.closest(".bj-table__filter-dropdown")) return;
771
+ if (isFilterable) {
772
+ toggleFilter(column, interactionIndex, event.currentTarget);
773
+ } else {
774
+ triggerHeaderAction();
775
+ }
543
776
  },
544
- onKeyDown: (v) => {
545
- var z, F, M;
546
- (M = (F = (z = i.onHeaderCell) == null ? void 0 : z.call(i, r, a)) == null ? void 0 : F.onKeyDown) == null || M.call(F, v), !v.target.closest(".bj-table__filter-dropdown") && (v.key === "Enter" || v.key === " ") && (v.preventDefault(), p ? ue(i, o, v.currentTarget) : Z());
777
+ onKeyDown: (event) => {
778
+ var _a3, _b3, _c2;
779
+ (_c2 = (_b3 = (_a3 = column.onHeaderCell) == null ? void 0 : _a3.call(column, rawColumn, index)) == null ? void 0 : _b3.onKeyDown) == null ? void 0 : _c2.call(_b3, event);
780
+ if (event.target.closest(".bj-table__filter-dropdown")) return;
781
+ if (event.key === "Enter" || event.key === " ") {
782
+ event.preventDefault();
783
+ if (isFilterable) {
784
+ toggleFilter(column, interactionIndex, event.currentTarget);
785
+ } else {
786
+ triggerHeaderAction();
787
+ }
788
+ }
547
789
  },
548
- rowSpan: l,
790
+ rowSpan,
549
791
  scope: "col",
550
- style: { textAlign: i.align, ...dt(i, o) },
551
- tabIndex: p || u ? 0 : void 0
792
+ style: { textAlign: column.align, ...getFixedStyle(column, interactionIndex) },
793
+ tabIndex: isFilterable || isSortable ? 0 : void 0
552
794
  },
553
- "children" in r ? mt(r.title, { filters: Object.fromEntries(K) }) : Ht(i, o)
795
+ "children" in rawColumn ? renderColumnTitle(rawColumn.title, { filters: Object.fromEntries(activeFilters) }) : renderHeaderCell(column, interactionIndex)
554
796
  );
555
797
  })
556
- ] }, t)) }),
557
- /* @__PURE__ */ b(tr, { className: "bj-table__body", children: V.length > 0 ? V.map(({ record: e, index: t }) => {
558
- var _;
559
- const r = q(e, t, g), s = ne(e, t), l = ((_ = d == null ? void 0 : d.getCheckboxProps) == null ? void 0 : _.call(d, e).disabled) ?? !1, a = B.includes(r), i = typeof ge == "function" ? ge(e, t, 0) : ge;
560
- return /* @__PURE__ */ Me(
561
- ct,
798
+ ] }, rowIndex)) }),
799
+ /* @__PURE__ */ jsx(BodyWrapper, { className: "bj-table__body", children: visibleRecords.length > 0 ? visibleRecords.map(({ record, index }) => {
800
+ var _a2;
801
+ const key = getRowKey(record, index, rowKey);
802
+ const groupRow = isGroupRow(record, index);
803
+ const isDisabled = ((_a2 = rowSelection == null ? void 0 : rowSelection.getCheckboxProps) == null ? void 0 : _a2.call(rowSelection, record).disabled) ?? false;
804
+ const isSelected = selectedKeys.includes(key);
805
+ const resolvedRowClassName = typeof rowClassName === "function" ? rowClassName(record, index, 0) : rowClassName;
806
+ return /* @__PURE__ */ createElement(
807
+ BodyRow,
562
808
  {
563
- ...xe == null ? void 0 : xe(e, t),
564
- className: L("bj-table__row", s && "bj-table__row--group", a && "bj-table__row--selected", i),
565
- key: r
809
+ ...onRow == null ? void 0 : onRow(record, index),
810
+ className: classNames("bj-table__row", groupRow && "bj-table__row--group", isSelected && "bj-table__row--selected", resolvedRowClassName),
811
+ key
566
812
  },
567
- d && !s && /* @__PURE__ */ b(
568
- ze,
813
+ rowSelection && !groupRow && /* @__PURE__ */ jsx(
814
+ BodyCell,
569
815
  {
570
- className: L(
816
+ className: classNames(
571
817
  "bj-table__cell",
572
818
  "bj-table__selection-cell",
573
- !!(f != null && f.x) && "bj-table__selection-cell--fixed",
819
+ Boolean(scroll == null ? void 0 : scroll.x) && "bj-table__selection-cell--fixed",
574
820
  // 选择列就是最后一个左固定区域时,由它承担左侧渐变阴影
575
- !!(f != null && f.x) && !$(y[0]) && "bj-table__cell--fixed-left-last"
821
+ Boolean(scroll == null ? void 0 : scroll.x) && !isFixedLeftColumn(activeColumns[0]) && "bj-table__cell--fixed-left-last"
576
822
  ),
577
- style: { width: le },
578
- children: /* @__PURE__ */ b(
579
- gt,
823
+ style: { width: selectionColumnWidth },
824
+ children: /* @__PURE__ */ jsx(
825
+ SelectionControl,
580
826
  {
581
- checked: a,
582
- disabled: l,
583
- label: `选择第 ${t + 1} 行`,
584
- name: d.type === "radio" ? "bj-table-row-selection" : void 0,
585
- onChange: () => Ut(e, t),
586
- type: d.type ?? "checkbox"
827
+ checked: isSelected,
828
+ disabled: isDisabled,
829
+ label: `选择第 ${index + 1} 行`,
830
+ name: rowSelection.type === "radio" ? "bj-table-row-selection" : void 0,
831
+ onChange: () => toggleRow(record, index),
832
+ type: rowSelection.type ?? "checkbox"
587
833
  }
588
834
  )
589
835
  }
590
836
  ),
591
- y.map((o, p) => {
592
- var F, M, c;
593
- if (s && p > 0) return null;
594
- const u = o, Z = xr(e, u.dataIndex), G = u.render ? u.render(Z, e, t) : Z, T = Rr(G) ? G : void 0, v = { ...(F = u.onCell) == null ? void 0 : F.call(u, e, t), ...T == null ? void 0 : T.props }, z = T ? T.children : G;
595
- return v.colSpan === 0 || v.rowSpan === 0 ? null : /* @__PURE__ */ Me(
596
- ze,
837
+ activeColumns.map((rawColumn, columnIndex) => {
838
+ var _a3, _b2, _c2;
839
+ if (groupRow && columnIndex > 0) return null;
840
+ const column = rawColumn;
841
+ const value = getValue(record, column.dataIndex);
842
+ const rendered = column.render ? column.render(value, record, index) : value;
843
+ const renderedCell = isRenderedCell(rendered) ? rendered : void 0;
844
+ const cellProps = { ...(_a3 = column.onCell) == null ? void 0 : _a3.call(column, record, index), ...renderedCell == null ? void 0 : renderedCell.props };
845
+ const content = renderedCell ? renderedCell.children : rendered;
846
+ if (cellProps.colSpan === 0 || cellProps.rowSpan === 0) return null;
847
+ return /* @__PURE__ */ createElement(
848
+ BodyCell,
597
849
  {
598
- ...v,
599
- className: L(
850
+ ...cellProps,
851
+ className: classNames(
600
852
  "bj-table__cell",
601
- ((M = y[p + 1]) == null ? void 0 : M.fixed) === "right" && "bj-table__cell--before-fixed-right",
602
- s && "bj-table__cell--group",
603
- u.fixed && "bj-table__cell--fixed",
604
- $(u) && "bj-table__cell--fixed-left",
605
- $(u) && !$(y[p + 1]) && "bj-table__cell--fixed-left-last",
606
- te(u) && "bj-table__cell--fixed-right",
607
- te(u) && !te(y[p - 1]) && "bj-table__cell--fixed-right-first",
608
- u.ellipsis && "bj-table__cell--ellipsis",
609
- u.className,
610
- v.className
853
+ ((_b2 = activeColumns[columnIndex + 1]) == null ? void 0 : _b2.fixed) === "right" && "bj-table__cell--before-fixed-right",
854
+ groupRow && "bj-table__cell--group",
855
+ column.fixed && "bj-table__cell--fixed",
856
+ isFixedLeftColumn(column) && "bj-table__cell--fixed-left",
857
+ isFixedLeftColumn(column) && !isFixedLeftColumn(activeColumns[columnIndex + 1]) && "bj-table__cell--fixed-left-last",
858
+ isFixedRightColumn(column) && "bj-table__cell--fixed-right",
859
+ isFixedRightColumn(column) && !isFixedRightColumn(activeColumns[columnIndex - 1]) && "bj-table__cell--fixed-right-first",
860
+ column.ellipsis && "bj-table__cell--ellipsis",
861
+ column.className,
862
+ cellProps.className
611
863
  ),
612
- key: u.key ?? String(u.dataIndex ?? p),
613
- colSpan: s ? st : v.colSpan,
614
- style: { textAlign: u.align, ...dt(u, p), ...v.style }
864
+ key: column.key ?? String(column.dataIndex ?? columnIndex),
865
+ colSpan: groupRow ? columnCount : cellProps.colSpan,
866
+ style: { textAlign: column.align, ...getFixedStyle(column, columnIndex), ...cellProps.style }
615
867
  },
616
- s ? ((c = h == null ? void 0 : h.render) == null ? void 0 : c.call(h, {
617
- record: e,
618
- expanded: Q.includes(oe(e, t)),
619
- onToggle: () => Gt(e, t)
620
- })) ?? z ?? "" : /* @__PURE__ */ b("div", { className: "bj-table__cell-content", children: z ?? "" })
868
+ groupRow ? ((_c2 = groupCollapse == null ? void 0 : groupCollapse.render) == null ? void 0 : _c2.call(groupCollapse, {
869
+ record,
870
+ expanded: expandedGroupKeys.includes(getGroupKey(record, index)),
871
+ onToggle: () => toggleGroup(record, index)
872
+ })) ?? content ?? "" : /* @__PURE__ */ jsx("div", { className: "bj-table__cell-content", children: content ?? "" })
621
873
  );
622
874
  })
623
875
  );
624
- }) : /* @__PURE__ */ b(ct, { className: "bj-table__empty-row", children: /* @__PURE__ */ b(
625
- ze,
876
+ }) : /* @__PURE__ */ jsx(BodyRow, { className: "bj-table__empty-row", children: /* @__PURE__ */ jsx(
877
+ BodyCell,
626
878
  {
627
879
  className: "bj-table__empty-cell",
628
- colSpan: Math.max(st, 1),
629
- style: { height: Nt }
880
+ colSpan: Math.max(columnCount, 1),
881
+ style: { height: emptyHeight }
630
882
  }
631
883
  ) }) }),
632
- qe && /* @__PURE__ */ b("tfoot", { className: "bj-table__summary", children: qe(S) })
884
+ summary && /* @__PURE__ */ jsx("tfoot", { className: "bj-table__summary", children: summary(processedData) })
633
885
  ] })
634
886
  }
635
887
  ),
636
- V.length === 0 && /* @__PURE__ */ b("div", { className: "bj-table__empty-overlay", children: /* @__PURE__ */ E("div", { className: "bj-table__empty-content", children: [
637
- bt && /* @__PURE__ */ b("div", { className: "bj-table__empty-image-wrap", children: bt }),
638
- /* @__PURE__ */ b("div", { className: "bj-table__empty-text", children: rr })
888
+ visibleRecords.length === 0 && /* @__PURE__ */ jsx("div", { className: "bj-table__empty-overlay", children: /* @__PURE__ */ jsxs("div", { className: "bj-table__empty-content", children: [
889
+ resolvedEmptyImage && /* @__PURE__ */ jsx("div", { className: "bj-table__empty-image-wrap", children: resolvedEmptyImage }),
890
+ /* @__PURE__ */ jsx("div", { className: "bj-table__empty-text", children: resolvedEmptyText })
639
891
  ] }) })
640
892
  ] }),
641
- ((f == null ? void 0 : f.x) || (f == null ? void 0 : f.y)) && /* @__PURE__ */ b(
642
- br,
893
+ ((scroll == null ? void 0 : scroll.x) || (scroll == null ? void 0 : scroll.y)) && /* @__PURE__ */ jsx(
894
+ BOverlayScrollbar,
643
895
  {
644
- containerRef: fe,
645
- direction: f != null && f.x && (f != null && f.y) ? "both" : f != null && f.x ? "horizontal" : "vertical",
896
+ containerRef: tableRootRef,
897
+ direction: (scroll == null ? void 0 : scroll.x) && (scroll == null ? void 0 : scroll.y) ? "both" : (scroll == null ? void 0 : scroll.x) ? "horizontal" : "vertical",
646
898
  gap: 2,
647
- horizontalInsetEnd: Qe.end,
648
- horizontalInsetStart: Qe.start,
899
+ horizontalInsetEnd: horizontalInsets.end,
900
+ horizontalInsetStart: horizontalInsets.start,
649
901
  size: 4,
650
- targetRef: Re
902
+ targetRef: tableScrollRef
651
903
  }
652
904
  ),
653
- Ge && /* @__PURE__ */ b("div", { className: "bj-table__footer", children: Ge(S) }),
654
- ye && /* @__PURE__ */ E("div", { "aria-live": "polite", "aria-busy": "true", className: "bj-table__loading", role: "status", children: [
655
- /* @__PURE__ */ b("img", { alt: "", className: "bj-table__loading-indicator", src: hr }),
656
- /* @__PURE__ */ b("span", { className: "bj-table__loading-text", children: "加载中..." })
905
+ footer && /* @__PURE__ */ jsx("div", { className: "bj-table__footer", children: footer(processedData) }),
906
+ loading && /* @__PURE__ */ jsxs("div", { "aria-live": "polite", "aria-busy": "true", className: "bj-table__loading", role: "status", children: [
907
+ /* @__PURE__ */ jsx("img", { alt: "", className: "bj-table__loading-indicator", src: loadingIndicator }),
908
+ /* @__PURE__ */ jsx("span", { className: "bj-table__loading-text", children: "加载中..." })
657
909
  ] }),
658
- n && S.length > 0 && /* @__PURE__ */ b("div", { className: "bj-table__pagination", children: /* @__PURE__ */ b(
659
- sr,
910
+ paginationConfig && processedData.length > 0 && /* @__PURE__ */ jsx("div", { className: "bj-table__pagination", children: /* @__PURE__ */ jsx(
911
+ Pagination,
660
912
  {
661
913
  align: "end",
662
- disabled: ye || n.disabled,
663
- current: H,
664
- defaultCurrent: n.defaultCurrent,
665
- defaultPageSize: n.defaultPageSize,
666
- dropdownClassName: n.dropdownClassName,
667
- hideOnSinglePage: n.hideOnSinglePage,
668
- onChange: (e) => {
669
- if (Be.current) {
670
- Be.current = !1;
914
+ disabled: loading || paginationConfig.disabled,
915
+ current,
916
+ defaultCurrent: paginationConfig.defaultCurrent,
917
+ defaultPageSize: paginationConfig.defaultPageSize,
918
+ dropdownClassName: paginationConfig.dropdownClassName,
919
+ hideOnSinglePage: paginationConfig.hideOnSinglePage,
920
+ onChange: (nextPage) => {
921
+ if (ignoreNextPaginationChangeRef.current) {
922
+ ignoreNextPaginationChangeRef.current = false;
671
923
  return;
672
924
  }
673
- Qt(e);
925
+ changePage(nextPage);
674
926
  },
675
- onShowSizeChange: (e, t) => Zt(t),
676
- pageSize: W,
677
- pageSizeOptions: n.pageSizeOptions,
678
- popupPlacement: n.popupPlacement,
679
- resolvePopupPlacement: n.resolvePopupPlacement,
680
- showQuickJumper: n.showQuickJumper,
681
- showSizeChanger: n.showSizeChanger,
682
- showTotal: n.showTotal,
683
- simple: n.simple,
684
- size: n.size,
685
- t: n.t ?? C,
686
- total: et
927
+ onShowSizeChange: (_, nextPageSize) => changePageSize(nextPageSize),
928
+ pageSize,
929
+ pageSizeOptions: paginationConfig.pageSizeOptions,
930
+ popupPlacement: paginationConfig.popupPlacement,
931
+ resolvePopupPlacement: paginationConfig.resolvePopupPlacement,
932
+ showQuickJumper: paginationConfig.showQuickJumper,
933
+ showSizeChanger: paginationConfig.showSizeChanger,
934
+ showTotal: paginationConfig.showTotal,
935
+ simple: paginationConfig.simple,
936
+ size: paginationConfig.size,
937
+ t: paginationConfig.t ?? t,
938
+ total
687
939
  }
688
940
  ) })
689
941
  ]
690
942
  }
691
943
  );
692
944
  }
693
- const pt = Dr;
694
- pt.Column = _r;
695
- pt.ColumnGroup = ur;
945
+ const CompoundBTable = BTable;
946
+ CompoundBTable.Column = Column;
947
+ CompoundBTable.ColumnGroup = ColumnGroup;
696
948
  export {
697
- pt as BTable
949
+ CompoundBTable as BTable
698
950
  };