bj-web-components 0.2.28 → 0.2.30

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 +1 -51
  2. package/dist/index.mjs +49 -49
  3. package/dist/style.css +1 -3744
  4. package/dist/web/BasicInput/BInput.js +1 -208
  5. package/dist/web/BasicInput/BInput.mjs +132 -164
  6. package/dist/web/BasicInput/utils.js +1 -47
  7. package/dist/web/BasicInput/utils.mjs +28 -38
  8. package/dist/web/CategoryDropdown/CategoryDropdown.js +1 -307
  9. package/dist/web/CategoryDropdown/CategoryDropdown.mjs +170 -218
  10. package/dist/web/CheckBox/BCheckBox.js +1 -116
  11. package/dist/web/CheckBox/BCheckBox.mjs +70 -86
  12. package/dist/web/CheckBox/Group.js +1 -73
  13. package/dist/web/CheckBox/Group.mjs +56 -63
  14. package/dist/web/CheckBox/context.js +1 -5
  15. package/dist/web/CheckBox/context.mjs +3 -3
  16. package/dist/web/CheckBox/index.js +1 -8
  17. package/dist/web/CheckBox/index.mjs +6 -6
  18. package/dist/web/Dropdown/BDropdown.js +1 -186
  19. package/dist/web/Dropdown/BDropdown.mjs +106 -132
  20. package/dist/web/EmptyInputBox/EmptyInputBox.js +1 -77
  21. package/dist/web/EmptyInputBox/EmptyInputBox.mjs +48 -52
  22. package/dist/web/FileCard/FileCard.js +1 -157
  23. package/dist/web/FileCard/FileCard.mjs +82 -112
  24. package/dist/web/Icon/Icon.js +1 -9
  25. package/dist/web/Icon/Icon.mjs +6 -6
  26. package/dist/web/Input/Input.js +1 -181
  27. package/dist/web/Input/Input.mjs +113 -122
  28. package/dist/web/InputNumber/BInputNumber.js +1 -311
  29. package/dist/web/InputNumber/BInputNumber.mjs +167 -275
  30. package/dist/web/InputNumber/StepHandler.js +1 -69
  31. package/dist/web/InputNumber/StepHandler.mjs +32 -38
  32. package/dist/web/InputNumber/hooks/useCursor.js +1 -40
  33. package/dist/web/InputNumber/hooks/useCursor.mjs +33 -35
  34. package/dist/web/InputNumber/hooks/useFrame.js +1 -12
  35. package/dist/web/InputNumber/hooks/useFrame.mjs +6 -9
  36. package/dist/web/InputNumber/utils/decimal.js +1 -147
  37. package/dist/web/InputNumber/utils/decimal.mjs +81 -109
  38. package/dist/web/Modal/Modal.js +1 -84
  39. package/dist/web/Modal/Modal.mjs +49 -52
  40. package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +1 -232
  41. package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +125 -206
  42. package/dist/web/Pagination/Pagination.js +1 -328
  43. package/dist/web/Pagination/Pagination.mjs +178 -254
  44. package/dist/web/ProductField/ProductField.js +1 -272
  45. package/dist/web/ProductField/ProductField.mjs +143 -190
  46. package/dist/web/ProductField/arrow-up.svg.js +1 -3
  47. package/dist/web/ProductField/arrow-up.svg.mjs +2 -2
  48. package/dist/web/ProductField/checkbox-no.svg.js +1 -3
  49. package/dist/web/ProductField/checkbox-no.svg.mjs +2 -2
  50. package/dist/web/ProductField/checkbox-ok.svg.js +1 -3
  51. package/dist/web/ProductField/checkbox-ok.svg.mjs +2 -2
  52. package/dist/web/ProductField/no_data_light.svg.js +1 -3
  53. package/dist/web/ProductField/no_data_light.svg.mjs +2 -2
  54. package/dist/web/ProductField/search.svg.js +1 -3
  55. package/dist/web/ProductField/search.svg.mjs +2 -2
  56. package/dist/web/ProductField/sort.svg.js +1 -3
  57. package/dist/web/ProductField/sort.svg.mjs +2 -2
  58. package/dist/web/SkuInputCard/SkuInputCard.js +1 -276
  59. package/dist/web/SkuInputCard/SkuInputCard.mjs +149 -188
  60. package/dist/web/SkuInputCard/spin_loading_red.gif.js +1 -3
  61. package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +2 -2
  62. package/dist/web/Switch/Switch.js +1 -70
  63. package/dist/web/Switch/Switch.mjs +37 -47
  64. package/dist/web/Table/BTable.js +1 -950
  65. package/dist/web/Table/BTable.mjs +521 -767
  66. package/dist/web/Table/Column.js +1 -5
  67. package/dist/web/Table/Column.mjs +2 -2
  68. package/dist/web/Table/ColumnGroup.js +1 -5
  69. package/dist/web/Table/ColumnGroup.mjs +2 -2
  70. package/dist/web/Table/utils/columns.js +1 -48
  71. package/dist/web/Table/utils/columns.mjs +30 -35
  72. package/dist/web/Table/utils/sortFilter.js +1 -84
  73. package/dist/web/Table/utils/sortFilter.mjs +52 -73
  74. package/dist/web/Tabs/BTabs.js +1 -150
  75. package/dist/web/Tabs/BTabs.mjs +98 -118
  76. package/dist/web/Tabs/TabPane.js +1 -8
  77. package/dist/web/Tabs/TabPane.mjs +4 -4
  78. package/dist/web/Tooltip/ConfirmTooltip.js +1 -26
  79. package/dist/web/Tooltip/ConfirmTooltip.mjs +19 -20
  80. package/dist/web/Tooltip/ContentTooltip.js +1 -94
  81. package/dist/web/Tooltip/ContentTooltip.mjs +62 -72
  82. package/dist/web/Tooltip/ProgressTooltip.js +1 -36
  83. package/dist/web/Tooltip/ProgressTooltip.mjs +20 -22
  84. package/dist/web/Tooltip/TooltipWrapper.js +1 -12
  85. package/dist/web/Tooltip/TooltipWrapper.mjs +8 -8
  86. package/dist/web/Tooltip/useAutoPlacement.js +1 -41
  87. package/dist/web/Tooltip/useAutoPlacement.mjs +25 -34
  88. package/dist/web.js +1 -51
  89. package/dist/web.mjs +49 -49
  90. package/package.json +1 -1
@@ -1,950 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),o=require("react"),Zt=require("react-dom"),Xt=require("../Pagination/Pagination.js"),Me=require("../Icon/Icon.js");;/* empty css */const Yt=require("../Tooltip/ContentTooltip.js"),es=require("../Tooltip/TooltipWrapper.js"),ts=require("../CheckBox/index.js"),ss=require("../Dropdown/BDropdown.js"),ns=require("../OverlayScrollbar/BOverlayScrollbar.js"),rs=require("../SkuInputCard/spin_loading_red.gif.js"),as=require("../ProductField/no_data_light.svg.js"),is=require("./Column.js"),ls=require("./ColumnGroup.js"),m=require("./utils/sortFilter.js"),Oe=require("./utils/columns.js");;/* empty css */const ds=300,ke=1;function z(...g){return g.filter(Boolean).join(" ")}function cs(g,x){return x===void 0?void 0:(Array.isArray(x)?x:[x]).reduce((F,c)=>{if(!(F==null||typeof F!="object"))return F[c]},g)}function V(g,x,v){if(typeof v=="function")return v(g,x);if(v){const F=g[String(v)];if(typeof F=="string"||typeof F=="number")return F}return x}function fs(g,x){return Math.max(1,Math.ceil(g/x))}function bs(g){return!!(g&&typeof g=="object"&&!o.isValidElement(g)&&"props"in g)}function os(g,x){return(typeof x.text=="string"||typeof x.text=="number"?String(x.text):String(x.value)).toLocaleLowerCase().includes(g.toLocaleLowerCase())}function ut({checked:g,disabled:x,label:v,name:F,onChange:c,type:G="checkbox"}){return G==="checkbox"?d.jsx(ts.BCheckBox,{"aria-label":v,checked:g,className:"bj-table__selection-checkbox",disabled:x,name:F,onChange:c,skipGroup:!0}):d.jsxs("label",{className:z("bj-table__selection-control",g&&"bj-table__selection-control--checked",x&&"bj-table__selection-control--disabled"),children:[d.jsx("input",{"aria-label":v,checked:g,className:"bj-table__selection-input",disabled:x,name:F,onChange:c,type:G}),d.jsx("span",{"aria-hidden":"true",className:"bj-table__selection-box",children:g&&d.jsx(Me,{className:"bj-table__selection-check-icon",type:"icon-a-dagouxi"})})]})}function us({columns:g,dataSource:x=[],rowKey:v,preserveSelectedRowKeys:F=!1,rowSelection:c,pagination:G=!1,loading:oe=!1,bordered:ht=!0,size:_t="middle",showHeader:qe=!0,emptyText:ue,emptyImage:he=as,emptyHeight:jt,t:Q=ae=>ae,className:yt,style:xt,rowClassName:_e,sortDirections:gt=["ascend","descend",null],onChange:je,children:ze,title:Te,footer:Le,summary:Ie,tableLayout:ye,components:E,onRow:xe,onHeaderRow:ge,id:vt,scroll:f,locale:Z,groupCollapse:u}){var ct,ft,bt;const ae=o.useRef(null),ve=o.useRef(null),ie=o.useMemo(()=>g??Oe.convertChildrenToColumns(ze),[ze,g]),Y=o.useMemo(()=>Oe.flattenColumns(ie),[ie]),we=o.useMemo(()=>Oe.buildHeaderRows(ie),[ie]),[mt,Ve]=o.useState((c==null?void 0:c.defaultSelectedRowKeys)??[]),[me,le]=o.useState(G?G.defaultCurrent??1:1),[pt,Nt]=o.useState(G?G.defaultPageSize??10:10),[Rt,Et]=o.useState(()=>new Map(Y.flatMap((e,t)=>e.defaultSortOrder?[[m.getColumnKey(e,t),e.defaultSortOrder]]:[]))),[St,Ft]=o.useState(()=>new Map(Y.flatMap((e,t)=>e.defaultFilteredValue===void 0?[]:[[m.getColumnKey(e,t),e.defaultFilteredValue]]))),[Kt,Dt]=o.useState(u!=null&&u.defaultExpandedKeys?[...u.defaultExpandedKeys]:[]),[T,$]=o.useState(null),[Ge,ee]=o.useState(new Map),[Pt,de]=o.useState(null),Ot=o.useRef(`btable-${Math.random().toString(36).slice(2,10)}`).current,[U,pe]=o.useState(null),[Ne,Ae]=o.useState(null),[Re,We]=o.useState(""),[te,He]=o.useState(""),[kt,Ee]=o.useState(),Se=o.useRef(0),Fe=o.useRef(!1),[$e,Ue]=o.useState({start:0,end:0}),[Ce,Je]=o.useState({start:!1,end:!1}),a=G||void 0,A=(a==null?void 0:a.pageSize)??pt,P=(c==null?void 0:c.selectedRowKeys)??mt,y=Y,Mt=`${y.map(e=>`${String(e.fixed??"")}:${String(e.width??"")}`).join("|")}|${c?String(c.columnWidth??""):"-"}|${String((f==null?void 0:f.x)??"")}|${String(ye??"")}`,W=e=>!!(e&&(e.fixed==="left"||e.fixed===!0)),X=e=>!!(e&&e.fixed==="right"),K=new Map(Rt),O=new Map(St);y.forEach((e,t)=>{if("children"in e)return;const s=m.getColumnKey(e,t);e.sortOrder!==void 0&&K.set(s,e.sortOrder),e.filteredValue!==void 0&&O.set(s,e.filteredValue)});const Qe=o.useMemo(()=>m.filterRecords(x,y,O),[y,O,x]),k=o.useMemo(()=>m.sortRecords(Qe,y,K),[y,Qe,K]),Ze=(a==null?void 0:a.total)??k.length,Xe=fs(Ze,A),H=Math.min((a==null?void 0:a.current)??me,Xe),C=(u==null?void 0:u.expandedKeys)??Kt,se=(e,t)=>u!=null&&u.isGroupRow?u.isGroupRow(e,t):!!e.isGroup,ce=(e,t)=>u!=null&&u.groupKey?u.groupKey(e,t):e.groupId,Ye=(e,t)=>u!=null&&u.childrenKeys?u.childrenKeys(e,t):e.childrenIds??[],Bt=(e,t)=>{var r;const s=ce(e,t),i=C.includes(s),l=i?C.filter(n=>n!==s):[...C,s];(u==null?void 0:u.expandedKeys)===void 0&&Dt(l),(r=u==null?void 0:u.onExpandedKeysChange)==null||r.call(u,l,e,!i)};o.useEffect(()=>{H!==me&&(a==null?void 0:a.current)===void 0&&le(H)},[H,a==null?void 0:a.current,me]),o.useEffect(()=>{if(!U||T===null){Ae(null);return}const e=()=>{const t=U.getBoundingClientRect();Ae({left:t.left,top:t.bottom+4})};return e(),document.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{document.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[U,T]),o.useEffect(()=>{if(T===null)return;const e=t=>{const s=t.target;U!=null&&U.contains(s)||s.closest(".bj-table__filter-dropdown")||($(null),pe(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[U,T]),o.useEffect(()=>{const e=window.setTimeout(()=>He(Re.trim()),ds);return()=>window.clearTimeout(e)},[Re]),o.useEffect(()=>{if(T===null)return;const e=Y.find((s,i)=>m.getColumnKey(s,i)===T);if(!e||"children"in e||!e.filterRequest)return;const t=++Se.current;Promise.resolve().then(()=>e.filterRequest(te)).then(s=>{Se.current===t&&Ee(s)},()=>{Se.current===t&&Ee([])})},[te,Y,T]);const L=o.useMemo(()=>{if(!a||a.serverPagination)return k.map((t,s)=>({record:t,index:s})).filter(({record:t,index:s})=>{if(!u||se(t,s))return!0;const i=V(t,s,v);return k.some((l,r)=>se(l,r)&&C.includes(ce(l,r))&&Ye(l,r).includes(i))});const e=(H-1)*A;return k.slice(e,e+A).map((t,s)=>({record:t,index:e+s})).filter(({record:t,index:s})=>{if(!u||se(t,s))return!0;const i=V(t,s,v);return k.some((l,r)=>se(l,r)&&C.includes(ce(l,r))&&Ye(l,r).includes(i))})},[H,C,u,A,a,k,v]),et=o.useMemo(()=>L.map(({record:e,index:t})=>V(e,t,v)),[v,L]),qt=P.map(String).join("|"),zt=et.map(String).join("|");o.useEffect(()=>{var l;if(!c||F||P.length===0)return;const e=new Set(et),t=P.filter(r=>e.has(r));if(t.length===P.length)return;c.selectedRowKeys===void 0&&Ve(t);const s=new Set(t),i=L.filter(({record:r,index:n})=>s.has(V(r,n,v))).map(({record:r})=>r);(l=c.onChange)==null||l.call(c,t,i,{type:"multiple"})},[F,c,v,qt,zt,L]),o.useEffect(()=>{const e=ve.current;if(!e||!(f!=null&&f.x)){Ue(r=>r.start===0&&r.end===0?r:{start:0,end:0}),Je(r=>r.start||r.end?{start:!1,end:!1}:r);return}const t=()=>{const r=e.querySelector(".bj-table__header .bj-table__header-row")??e.querySelector(".bj-table__body .bj-table__row");let n=0,_=0;if(r){Array.from(r.children).forEach(p=>{const j=p.getBoundingClientRect().width;p.classList.contains("bj-table__cell--fixed-right")?_+=j:(p.classList.contains("bj-table__cell--fixed-left")||p.classList.contains("bj-table__selection-cell--fixed"))&&(n+=j)});const h=e.clientLeft;n>0&&(n+=h),_>0&&(_=Math.max(_-h,0))}Ue(h=>h.start===n&&h.end===_?h:{start:n,end:_})},s=()=>{const r=e.scrollWidth-e.clientWidth,n=r>ke,_={start:n&&e.scrollLeft>ke,end:n&&e.scrollLeft<r-ke};Je(h=>h.start===_.start&&h.end===_.end?h:_)},i=()=>{t(),s()};i(),e.addEventListener("scroll",s,{passive:!0});const l=new ResizeObserver(i);return l.observe(e),e.firstElementChild&&l.observe(e.firstElementChild),()=>{e.removeEventListener("scroll",s),l.disconnect()}},[Mt,f==null?void 0:f.x,qe,L.length]);const fe=(e,t=K,s=O,i=H,l=A)=>{const r=Object.fromEntries(s),n=m.filterRecords(x,y,s),_=m.sortRecords(n,y,t);je==null||je({...a,current:i,pageSize:l,total:(a==null?void 0:a.total)??_.length},r,m.getSorterResult(y,t),{action:e,currentDataSource:_})},Tt=(e,t)=>{if(!e.sorter)return;const s=m.getColumnKey(e,t),i=m.getNextSortOrder(K.get(s)??null,e.sortDirections??gt),l=new Map;l.set(s,i),e.sortOrder===void 0&&Et(l),fe("sort",l)},Ke=(e,t,s)=>{const i=m.getColumnKey(e,t),l=new Map(O);l.set(i,s),e.filteredValue===void 0&&Ft(l),$(null),(a==null?void 0:a.current)===void 0&&le(1),fe("filter",K,l,1)},Lt=(e,t)=>{const s=m.getColumnKey(e,t),i=e.filterResetToDefaultFilteredValue?e.defaultFilteredValue??[]:[];ee(l=>new Map(l).set(s,i))},be=(e,t,s)=>{var l,r,n,_;const i=m.getColumnKey(e,t);if(T===i){$(null),pe(null),(l=e.onFilterDropdownOpenChange)==null||l.call(e,!1),(r=e.onFilterDropdownVisibleChange)==null||r.call(e,!1);return}We(""),He(""),Ee(void 0),ee(h=>new Map(h).set(i,O.get(i)??[])),$(i),s&&pe(s),(n=e.onFilterDropdownOpenChange)==null||n.call(e,!0),(_=e.onFilterDropdownVisibleChange)==null||_.call(e,!0)},It=(e,t)=>{var S,B;const s=m.getColumnKey(e,t),i=`bj-table-badge-${Ot}-${String(s).replace(/[^a-zA-Z0-9_-]/g,"-")}`,l=K.get(s)??null,r=O.get(s)??[],n=Ge.get(s)??r,_=e.filterDropdownOpen??e.filterDropdownVisible??T===s,h=e.filtered||r.length>0,p=l==="ascend"?"icon-a-zhengxumian":l==="descend"?"icon-a-daoxumian":"icon-a-weipaixumian",j=m.renderColumnTitle(e.title,{sortOrder:l,sortColumn:l?e:void 0,sortColumns:l?[{column:e,order:l}]:[],filters:Object.fromEntries(O)}),J=typeof e.filterDropdown=="function"?e.filterDropdown({prefixCls:"bj-table",selectedKeys:n.filter(b=>typeof b!="boolean"),setSelectedKeys:b=>ee(R=>new Map(R).set(s,b)),confirm:b=>{Ke(e,t,Ge.get(s)??n),(b==null?void 0:b.closeDropdown)===!1&&$(s)},clearFilters:b=>{const R=e.filterResetToDefaultFilteredValue?e.defaultFilteredValue??[]:[];ee(D=>new Map(D).set(s,R)),(b==null?void 0:b.confirm)===!0&&Ke(e,t,R),((b==null?void 0:b.closeDropdown)===!1||(b==null?void 0:b.confirm)!==!0)&&$(s)},filters:e.filters,close:()=>$(null),visible:_}):e.filterDropdown,w=e.filterRequest?kt??[]:e.filters??[],q=te&&!e.filterRequest?w.filter(b=>typeof e.filterSearch=="function"?e.filterSearch(te,b):os(te,b)):w,N=!!(e.filterSearch||e.filterRequest),M=d.jsxs("div",{className:z("bj-table__column-header",e.sorter&&"bj-table__column-header--sortable"),children:[e.badge!==void 0&&d.jsx("span",{"aria-label":"表头提示",className:"bj-table__column-badge-trigger",id:i,onBlur:()=>de(null),onClick:b=>b.stopPropagation(),onFocus:()=>de(s),onKeyDown:b=>b.stopPropagation(),onMouseEnter:()=>de(s),onMouseLeave:()=>de(null),role:"button",tabIndex:0,children:d.jsx("span",{"aria-hidden":"true",className:"bj-table__column-badge-shape"})}),d.jsxs("div",{className:"bj-table__column-title",children:[d.jsx("span",{className:"bj-table__column-title-content",children:j}),e.sorter&&d.jsx("span",{"aria-hidden":"true",className:"bj-table__column-sorter",children:d.jsx(Me,{className:"bj-table__column-sorter-icon",type:p})})]}),(e.filters||e.filterDropdown)&&d.jsxs("div",{className:"bj-table__filter",children:[d.jsx("button",{"aria-expanded":_,"aria-label":"筛选",className:z("bj-table__filter-trigger",h&&"bj-table__filter-trigger--active"),onClick:b=>{b.stopPropagation(),be(e,t)},type:"button",children:typeof e.filterIcon=="function"?e.filterIcon(h):e.filterIcon??d.jsx(Me,{className:"bj-table__filter-icon",type:h?"icon-shaixuan-daidian":"icon-a-shaixuanxi"})}),_&&Ne&&typeof document<"u"&&Zt.createPortal(d.jsx("div",{className:"bj-table__filter-dropdown",onClick:b=>b.stopPropagation(),role:"dialog",style:{left:Ne.left,top:Ne.top},children:J??d.jsx(ss.BDropdown,{...e.filterDropdownProps,emptyText:(Z==null?void 0:Z.filterEmptyText)??Q("暂无结果"),multiple:e.filterMultiple!==!1,onChange:(b,R)=>{var D,ot;ee(Qt=>new Map(Qt).set(s,b)),(ot=(D=e.filterDropdownProps)==null?void 0:D.onChange)==null||ot.call(D,b,R)},onConfirm:b=>{var R,D;Ke(e,t,b),(D=(R=e.filterDropdownProps)==null?void 0:R.onConfirm)==null||D.call(R,b)},onReset:()=>{var b,R;Lt(e,t),(R=(b=e.filterDropdownProps)==null?void 0:b.onReset)==null||R.call(b)},onSearch:b=>{var R,D;We(b),(D=(R=e.filterDropdownProps)==null?void 0:R.onSearch)==null||D.call(R,b)},options:q.map(b=>({label:b.text,description:b.description,value:b.value})),searchable:((S=e.filterDropdownProps)==null?void 0:S.searchable)??N,searchPlaceholder:((B=e.filterDropdownProps)==null?void 0:B.searchPlaceholder)??(e.filterRequest?Q("请输入搜索内容"):(Z==null?void 0:Z.filterSearchPlaceholder)??Q("搜索")),searchValue:Re,t:Q,value:n})}),document.body)]})]});return e.badge!==void 0?d.jsxs(es,{className:"bj-table__column-tooltip-wrapper",children:[d.jsx("div",{className:"bj-table__column-tooltip-trigger",children:M}),Pt===s&&d.jsx(Yt,{className:"bj-table__column-tooltip",content:e.badge,getAnchorElement:()=>document.getElementById(i),getPopupContainer:()=>document.body,placement:"top"})]}):M},tt=(e,t,s)=>{var r,n;t.selectedRowKeys===void 0&&Ve(e);const i=new Set(e),l=x.filter((_,h)=>i.has(V(_,h,v)));(r=t.onChange)==null||r.call(t,e,l),s&&((n=t.onSelect)==null||n.call(t,s,i.has(V(s,x.indexOf(s),v)),l))},wt=(e,t)=>{if(!c)return;const s=V(e,t,v),i=P.includes(s),l=c.type==="radio"?i?[]:[s]:i?P.filter(r=>r!==s):[...P,s];tt(l,c,e)},st=L.filter(({record:e})=>{var t;return!((t=c==null?void 0:c.getCheckboxProps)!=null&&t.call(c,e).disabled)}),ne=st.map(({record:e,index:t})=>V(e,t,v)),De=ne.length>0&&ne.every(e=>P.includes(e)),Vt=()=>{var s;if(!c||c.type==="radio")return;const e=new Set(ne),t=De?P.filter(i=>!e.has(i)):Array.from(new Set([...P,...ne]));tt(t,c),new Set(t),(s=c.onSelectAll)==null||s.call(c,!De,st.map(({record:i})=>i))},Gt=e=>{var t;!a||e<1||e>Xe||e===H||(a.current===void 0&&le(e),(t=a.onChange)==null||t.call(a,e,A),fe("paginate",K,O,e))},At=e=>{var s,i;if(!a||e===A)return;const t=1;Fe.current=!0,a.pageSize===void 0&&Nt(e),a.current===void 0&&le(t),(s=a.onShowSizeChange)==null||s.call(a,t,e),(i=a.onChange)==null||i.call(a,t,e),fe("paginate",K,O,t,e)},nt=y.length+(c?1:0),re=(c==null?void 0:c.columnWidth)??48,rt=e=>typeof e.width=="number"?e.width:0,at=(e,t)=>{const s=e.fixed===!0?"left":e.fixed;return s==="left"?{position:"sticky",left:y.slice(0,t).reduce((l,r)=>l+rt(r),c&&typeof re=="number"?re:0),zIndex:2}:s==="right"?{position:"sticky",right:y.slice(t+1).reduce((l,r)=>l+rt(r),0),zIndex:2}:{}},Wt=f!=null&&f.x?{width:f.x===!0?"max-content":f.x,minWidth:"100%",tableLayout:ye??"fixed"}:{tableLayout:ye},Ht=(E==null?void 0:E.table)??"table",$t=((ct=E==null?void 0:E.header)==null?void 0:ct.wrapper)??"thead",Ut=((ft=E==null?void 0:E.header)==null?void 0:ft.row)??"tr",it=((bt=E==null?void 0:E.header)==null?void 0:bt.cell)??"th",I=typeof(E==null?void 0:E.body)=="object"?E.body:void 0,Ct=(I==null?void 0:I.wrapper)??"tbody",lt=(I==null?void 0:I.row)??"tr",Pe=(I==null?void 0:I.cell)??"td",Jt=typeof ue=="function"?ue():ue??Q("暂无数据"),dt=typeof he=="string"?d.jsx("img",{alt:"",className:"bj-table__empty-image",src:he}):he;return d.jsxs("div",{id:vt,ref:ae,className:z("bj-table",ht&&"bj-table--bordered",`bj-table--${_t}`,oe&&"bj-table--loading",k.length===0&&"bj-table--empty",Ce.start&&"bj-table--ping-left",Ce.end&&"bj-table--ping-right",yt),style:xt,children:[Te&&d.jsx("div",{className:"bj-table__title",children:Te(k)}),d.jsxs("div",{className:"bj-table__viewport",children:[d.jsx("div",{className:z("bj-table__scroll",!!(f!=null&&f.x||f!=null&&f.y)&&"bj-overlay-scrollbar-hidden"),ref:ve,style:{maxHeight:f==null?void 0:f.y},children:d.jsxs(Ht,{className:"bj-table__native-table",style:Wt,children:[y.some(e=>e.width)&&d.jsxs("colgroup",{children:[c&&d.jsx("col",{className:"bj-table__selection-col",style:{width:re}}),y.map((e,t)=>d.jsx("col",{style:{width:e.width}},e.key??t))]}),qe&&d.jsx($t,{className:"bj-table__header",children:we.map((e,t)=>d.jsxs(Ut,{className:"bj-table__header-row",...ge==null?void 0:ge(y,t),children:[c&&t===0&&d.jsxs(it,{className:z("bj-table__header-cell","bj-table__selection-cell",!!(f!=null&&f.x)&&"bj-table__selection-cell--fixed",!!(f!=null&&f.x)&&!W(y[0])&&"bj-table__cell--fixed-left-last"),rowSpan:we.length,scope:"col",style:{width:re},children:[c.type!=="radio"&&d.jsx(ut,{checked:De,disabled:ne.length===0,onChange:Vt,label:"选择当前页所有行"}),c.columnTitle]}),e.map(({column:s,colSpan:i,rowSpan:l},r)=>{var w,q;const n=s,_=y.indexOf(n),h=_>=0?_:r,p=!("children"in s)&&!!(n.filters||n.filterDropdown),j=!("children"in s)&&!!n.sorter,J=()=>{p?be(n,h):j&&Tt(n,h)};return o.createElement(it,{...(w=n.onHeaderCell)==null?void 0:w.call(n,s,r),"aria-label":typeof n.title=="string"?n.title:void 0,"aria-sort":j?K.get(m.getColumnKey(n,h))==="ascend"?"ascending":K.get(m.getColumnKey(n,h))==="descend"?"descending":"none":void 0,className:z("bj-table__header-cell",((q=y[h+1])==null?void 0:q.fixed)==="right"&&"bj-table__cell--before-fixed-right",n.fixed&&"bj-table__cell--fixed",W(n)&&"bj-table__cell--fixed-left",W(n)&&!W(y[h+1])&&"bj-table__cell--fixed-left-last",X(n)&&"bj-table__cell--fixed-right",X(n)&&!X(y[h-1])&&"bj-table__cell--fixed-right-first",n.sorter&&"bj-table__header-cell--sortable",p&&"bj-table__header-cell--filterable",K.get(m.getColumnKey(n,h))&&"bj-table__header-cell--sorted",n.className),colSpan:i,key:n.key??String(n.dataIndex??r),onClick:N=>{var M,S,B;(B=(S=(M=n.onHeaderCell)==null?void 0:M.call(n,s,r))==null?void 0:S.onClick)==null||B.call(S,N),!N.target.closest(".bj-table__filter-dropdown")&&(p?be(n,h,N.currentTarget):J())},onKeyDown:N=>{var M,S,B;(B=(S=(M=n.onHeaderCell)==null?void 0:M.call(n,s,r))==null?void 0:S.onKeyDown)==null||B.call(S,N),!N.target.closest(".bj-table__filter-dropdown")&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),p?be(n,h,N.currentTarget):J())},rowSpan:l,scope:"col",style:{textAlign:n.align,...at(n,h)},tabIndex:p||j?0:void 0},"children"in s?m.renderColumnTitle(s.title,{filters:Object.fromEntries(O)}):It(n,h))})]},t))}),d.jsx(Ct,{className:"bj-table__body",children:L.length>0?L.map(({record:e,index:t})=>{var _;const s=V(e,t,v),i=se(e,t),l=((_=c==null?void 0:c.getCheckboxProps)==null?void 0:_.call(c,e).disabled)??!1,r=P.includes(s),n=typeof _e=="function"?_e(e,t,0):_e;return o.createElement(lt,{...xe==null?void 0:xe(e,t),className:z("bj-table__row",i&&"bj-table__row--group",r&&"bj-table__row--selected",n),key:s},c&&!i&&d.jsx(Pe,{className:z("bj-table__cell","bj-table__selection-cell",!!(f!=null&&f.x)&&"bj-table__selection-cell--fixed",!!(f!=null&&f.x)&&!W(y[0])&&"bj-table__cell--fixed-left-last"),style:{width:re},children:d.jsx(ut,{checked:r,disabled:l,label:`选择第 ${t+1} 行`,name:c.type==="radio"?"bj-table-row-selection":void 0,onChange:()=>wt(e,t),type:c.type??"checkbox"})}),y.map((h,p)=>{var S,B,b;if(i&&p>0)return null;const j=h,J=cs(e,j.dataIndex),w=j.render?j.render(J,e,t):J,q=bs(w)?w:void 0,N={...(S=j.onCell)==null?void 0:S.call(j,e,t),...q==null?void 0:q.props},M=q?q.children:w;return N.colSpan===0||N.rowSpan===0?null:o.createElement(Pe,{...N,className:z("bj-table__cell",((B=y[p+1])==null?void 0:B.fixed)==="right"&&"bj-table__cell--before-fixed-right",i&&"bj-table__cell--group",j.fixed&&"bj-table__cell--fixed",W(j)&&"bj-table__cell--fixed-left",W(j)&&!W(y[p+1])&&"bj-table__cell--fixed-left-last",X(j)&&"bj-table__cell--fixed-right",X(j)&&!X(y[p-1])&&"bj-table__cell--fixed-right-first",j.ellipsis&&"bj-table__cell--ellipsis",j.className,N.className),key:j.key??String(j.dataIndex??p),colSpan:i?nt:N.colSpan,style:{textAlign:j.align,...at(j,p),...N.style}},i?((b=u==null?void 0:u.render)==null?void 0:b.call(u,{record:e,expanded:C.includes(ce(e,t)),onToggle:()=>Bt(e,t)}))??M??"":d.jsx("div",{className:"bj-table__cell-content",children:M??""}))}))}):d.jsx(lt,{className:"bj-table__empty-row",children:d.jsx(Pe,{className:"bj-table__empty-cell",colSpan:Math.max(nt,1),style:{height:jt}})})}),Ie&&d.jsx("tfoot",{className:"bj-table__summary",children:Ie(k)})]})}),L.length===0&&d.jsx("div",{className:"bj-table__empty-overlay",children:d.jsxs("div",{className:"bj-table__empty-content",children:[dt&&d.jsx("div",{className:"bj-table__empty-image-wrap",children:dt}),d.jsx("div",{className:"bj-table__empty-text",children:Jt})]})})]}),((f==null?void 0:f.x)||(f==null?void 0:f.y))&&d.jsx(ns,{containerRef:ae,direction:f!=null&&f.x&&(f!=null&&f.y)?"both":f!=null&&f.x?"horizontal":"vertical",gap:2,horizontalInsetEnd:$e.end,horizontalInsetStart:$e.start,size:4,targetRef:ve}),Le&&d.jsx("div",{className:"bj-table__footer",children:Le(k)}),oe&&d.jsxs("div",{"aria-live":"polite","aria-busy":"true",className:"bj-table__loading",role:"status",children:[d.jsx("img",{alt:"",className:"bj-table__loading-indicator",src:rs}),d.jsx("span",{className:"bj-table__loading-text",children:"加载中..."})]}),a&&k.length>0&&d.jsx("div",{className:"bj-table__pagination",children:d.jsx(Xt,{align:"end",disabled:oe||a.disabled,current:H,defaultCurrent:a.defaultCurrent,defaultPageSize:a.defaultPageSize,dropdownClassName:a.dropdownClassName,hideOnSinglePage:a.hideOnSinglePage,onChange:e=>{if(Fe.current){Fe.current=!1;return}Gt(e)},onShowSizeChange:(e,t)=>At(t),pageSize:A,pageSizeOptions:a.pageSizeOptions,popupPlacement:a.popupPlacement,resolvePopupPlacement:a.resolvePopupPlacement,showQuickJumper:a.showQuickJumper,showSizeChanger:a.showSizeChanger,showTotal:a.showTotal,simple:a.simple,size:a.size,t:a.t??Q,total:Ze})})]})}const Be=us;Be.Column=is;Be.ColumnGroup=ls;exports.BTable=Be;