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