@arim-aisdc/public-components 2.3.48 → 2.3.50

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 (62) hide show
  1. package/dist/components/BaseInfo/BaseInfo.d.ts +1 -1
  2. package/dist/components/TableMax/TableBody/{Row.d.ts → OriginalRow.d.ts} +2 -2
  3. package/dist/components/TableMax/TableBody/{Row.js → OriginalRow.js} +2 -2
  4. package/dist/components/TableMax/TableBody/OriginalTableBody.d.ts +76 -0
  5. package/dist/components/TableMax/TableBody/OriginalTableBody.js +509 -0
  6. package/dist/components/TableMax/TableBody/TableBody.d.ts +3 -0
  7. package/dist/components/TableMax/TableBody/TableBody.js +15 -0
  8. package/dist/components/TableMax/TableBody/VirtualRow.d.ts +63 -0
  9. package/dist/components/TableMax/TableBody/VirtualRow.js +479 -0
  10. package/dist/components/TableMax/TableBody/VirtualTableBody.d.ts +75 -0
  11. package/dist/components/TableMax/TableBody/VirtualTableBody.js +423 -0
  12. package/dist/components/TableMax/TableBody/components/Total.js +86 -27
  13. package/dist/components/TableMax/TableBody/index.d.ts +3 -75
  14. package/dist/components/TableMax/TableBody/index.js +4 -519
  15. package/dist/components/TableMax/TableBody/index.less +14 -2
  16. package/dist/components/TableMax/TableHeader/OriginalTableHeader.d.ts +21 -0
  17. package/dist/components/TableMax/TableHeader/OriginalTableHeader.js +86 -0
  18. package/dist/components/TableMax/TableHeader/TableHeader.d.ts +2 -0
  19. package/dist/components/TableMax/TableHeader/TableHeader.js +14 -0
  20. package/dist/components/TableMax/TableHeader/VirtualTableHeader/ColGroup.d.ts +11 -0
  21. package/dist/components/TableMax/TableHeader/VirtualTableHeader/ColGroup.js +33 -0
  22. package/dist/components/TableMax/TableHeader/VirtualTableHeader/PinnedColumns.d.ts +19 -0
  23. package/dist/components/TableMax/TableHeader/VirtualTableHeader/PinnedColumns.js +46 -0
  24. package/dist/components/TableMax/TableHeader/VirtualTableHeader/ScrollColumns.d.ts +18 -0
  25. package/dist/components/TableMax/TableHeader/VirtualTableHeader/ScrollColumns.js +47 -0
  26. package/dist/components/TableMax/TableHeader/VirtualTableHeader/VirtualColumns.d.ts +19 -0
  27. package/dist/components/TableMax/TableHeader/VirtualTableHeader/VirtualColumns.js +49 -0
  28. package/dist/components/TableMax/TableHeader/VirtualTableHeader/VirtualPadding.d.ts +7 -0
  29. package/dist/components/TableMax/TableHeader/VirtualTableHeader/VirtualPadding.js +16 -0
  30. package/dist/components/TableMax/TableHeader/VirtualTableHeader/index.d.ts +4 -0
  31. package/dist/components/TableMax/TableHeader/VirtualTableHeader/index.js +79 -0
  32. package/dist/components/TableMax/TableHeader/VirtualTableHeader/index.less +225 -0
  33. package/dist/components/TableMax/TableHeader/index.d.ts +3 -20
  34. package/dist/components/TableMax/TableHeader/index.js +3 -90
  35. package/dist/components/TableMax/TableHeader/utils.d.ts +1 -0
  36. package/dist/components/TableMax/TableHeader/utils.js +17 -10
  37. package/dist/components/TableMax/TableMax.js +169 -123
  38. package/dist/components/TableMax/components/ColumnEdit/index.d.ts +1 -0
  39. package/dist/components/TableMax/components/ColumnEdit/index.js +5 -1
  40. package/dist/components/TableMax/components/ColumnSort/customSortFns.d.ts +8 -8
  41. package/dist/components/TableMax/contexts/VirtualScroll/VirtualScrollContext.d.ts +3 -0
  42. package/dist/components/TableMax/contexts/VirtualScroll/VirtualScrollContext.js +2 -0
  43. package/dist/components/TableMax/contexts/VirtualScroll/VirtualScrollProvider.d.ts +3 -0
  44. package/dist/components/TableMax/contexts/VirtualScroll/VirtualScrollProvider.js +26 -0
  45. package/dist/components/TableMax/contexts/VirtualScroll/index.d.ts +3 -0
  46. package/dist/components/TableMax/contexts/VirtualScroll/index.js +4 -0
  47. package/dist/components/TableMax/contexts/VirtualScroll/types.d.ts +33 -0
  48. package/dist/components/TableMax/contexts/VirtualScroll/types.js +1 -0
  49. package/dist/components/TableMax/contexts/index.d.ts +1 -0
  50. package/dist/components/TableMax/contexts/index.js +1 -0
  51. package/dist/components/TableMax/hooks/useColumnWidth copy.js +15 -6
  52. package/dist/components/TableMax/hooks/useDragDrop.d.ts +27 -0
  53. package/dist/components/TableMax/hooks/useDragDrop.js +167 -0
  54. package/dist/components/TableMax/hooks/useTableComponents.d.ts +6 -0
  55. package/dist/components/TableMax/hooks/useTableComponents.js +19 -0
  56. package/dist/components/TableMax/hooks/useVirtualCalculations.d.ts +25 -0
  57. package/dist/components/TableMax/hooks/useVirtualCalculations.js +113 -0
  58. package/dist/components/TableMax/hooks/useVirtualScroll.d.ts +4 -0
  59. package/dist/components/TableMax/hooks/useVirtualScroll.js +30 -0
  60. package/dist/components/TableMax/tableMax.less +22 -5
  61. package/dist/components/TableMax/type.d.ts +2 -0
  62. package/package.json +2 -1
@@ -0,0 +1,423 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ import { Spin } from 'antd';
14
+ import { useDrop } from 'react-dnd';
15
+ import { CustomDragLayer } from "../components/CustomDragerLayer";
16
+ import { DropSide } from "../type";
17
+ import { events, useEventBus } from "../../..";
18
+ import React, { useCallback, useMemo, useState } from 'react';
19
+ import { createPortal } from 'react-dom';
20
+ import { useConfig } from "../../ConfigProvider";
21
+ import Empty from "../../Empty";
22
+ import { VirtualRow } from "./VirtualRow";
23
+ import ContextMenu from "./contextMenu/ContextMenu";
24
+ import "./index.less";
25
+ import { Total } from "./components/Total";
26
+ import { ColGroup } from "../TableHeader/VirtualTableHeader/ColGroup";
27
+ import { useVirtualConfig, useVirtualState } from "../hooks/useVirtualScroll";
28
+ import { jsx as _jsx } from "react/jsx-runtime";
29
+ import { jsxs as _jsxs } from "react/jsx-runtime";
30
+ import { Fragment as _Fragment } from "react/jsx-runtime";
31
+ var VirtualTableBody = function VirtualTableBody(_ref) {
32
+ var _headerGroups, _table$getRowModel$ro2;
33
+ var tableBodyRef = _ref.tableBodyRef,
34
+ tableContentRef = _ref.tableContentRef,
35
+ table = _ref.table,
36
+ tableId = _ref.tableId,
37
+ theme = _ref.theme,
38
+ reorderRow = _ref.reorderRow,
39
+ rowSelectedId = _ref.rowSelectedId,
40
+ setRowSelectedId = _ref.setRowSelectedId,
41
+ rowHighLightId = _ref.rowHighLightId,
42
+ setRowHighLightId = _ref.setRowHighLightId,
43
+ selectedRowChange = _ref.selectedRowChange,
44
+ onSelectChange = _ref.onSelectChange,
45
+ canSelection = _ref.canSelection,
46
+ selectionWithoutChecked = _ref.selectionWithoutChecked,
47
+ tableContainerWidth = _ref.tableContainerWidth,
48
+ selectedRowDragging = _ref.selectedRowDragging,
49
+ setSelectedRowDragging = _ref.setSelectedRowDragging,
50
+ canRowDrag = _ref.canRowDrag,
51
+ rowKey = _ref.rowKey,
52
+ loading = _ref.loading,
53
+ rowClassName = _ref.rowClassName,
54
+ cellClassName = _ref.cellClassName,
55
+ rowStyle = _ref.rowStyle,
56
+ getCellProps = _ref.getCellProps,
57
+ rowHeight = _ref.rowHeight,
58
+ renderSubComponent = _ref.renderSubComponent,
59
+ onRowMouseEnter = _ref.onRowMouseEnter,
60
+ onRowMouseLeave = _ref.onRowMouseLeave,
61
+ onRowMouseClick = _ref.onRowMouseClick,
62
+ onRowMouseDoubleClick = _ref.onRowMouseDoubleClick,
63
+ disableDragRowIds = _ref.disableDragRowIds,
64
+ selectRowWhenClick = _ref.selectRowWhenClick,
65
+ datas = _ref.datas,
66
+ canEditRowWhenDClick = _ref.canEditRowWhenDClick,
67
+ editingRowId = _ref.editingRowId,
68
+ handleEditRowWhenDClick = _ref.handleEditRowWhenDClick,
69
+ dragBeforeStart = _ref.dragBeforeStart,
70
+ getContextMenu = _ref.getContextMenu,
71
+ onClickContextMenu = _ref.onClickContextMenu,
72
+ getRowHoverTipConfig = _ref.getRowHoverTipConfig,
73
+ tableTooltip = _ref.tableTooltip,
74
+ compactMode = _ref.compactMode,
75
+ onEditValueChange = _ref.onEditValueChange,
76
+ hasTotalRow = _ref.hasTotalRow,
77
+ totalDatas = _ref.totalDatas,
78
+ setRowSelection = _ref.setRowSelection,
79
+ openMemo = _ref.openMemo,
80
+ _ref$openVirtualColum = _ref.openVirtualColumns,
81
+ openVirtualColumns = _ref$openVirtualColum === void 0 ? false : _ref$openVirtualColum;
82
+ var _useConfig = useConfig(),
83
+ root = _useConfig.root;
84
+ var headerGroups = table.getHeaderGroups();
85
+ var headers = (headerGroups === null || headerGroups === void 0 || (_headerGroups = headerGroups[headerGroups.length - 1]) === null || _headerGroups === void 0 ? void 0 : _headerGroups.headers) || [];
86
+ var visibleColumns = table.getVisibleLeafColumns();
87
+ var config = useVirtualConfig();
88
+ var state = useVirtualState();
89
+ var openVirtualRows = config.openVirtualRows;
90
+
91
+ // 从 Provider 中获取虚拟化数据
92
+ var leftPinnedColumns = state.leftPinnedColumns,
93
+ rightPinnedColumns = state.rightPinnedColumns,
94
+ scrollableColumns = state.scrollableColumns,
95
+ virtualColumns = state.virtualColumns,
96
+ virtualPaddingLeft = state.virtualPaddingLeft,
97
+ virtualPaddingRight = state.virtualPaddingRight,
98
+ rowVirtualizer = state.rowVirtualizer,
99
+ virtualRows = state.virtualRows;
100
+ var _useState = useState({
101
+ visible: false,
102
+ clientX: 0,
103
+ clientY: 0,
104
+ row: {},
105
+ column: {},
106
+ options: []
107
+ }),
108
+ _useState2 = _slicedToArray(_useState, 2),
109
+ contextMenuData = _useState2[0],
110
+ setContextMenuData = _useState2[1];
111
+
112
+ // 拖动时显示放置的位置
113
+ var _useState3 = useState(undefined),
114
+ _useState4 = _slicedToArray(_useState3, 2),
115
+ hoverRowIndex = _useState4[0],
116
+ setHoverRowIndex = _useState4[1];
117
+ var _useState5 = useState(undefined),
118
+ _useState6 = _slicedToArray(_useState5, 2),
119
+ dropSide = _useState6[0],
120
+ setDropSide = _useState6[1];
121
+
122
+ // 清除hover行信息
123
+ var clearHoverRowIndex = useCallback(function () {
124
+ setHoverRowIndex(undefined);
125
+ }, []);
126
+
127
+ // 当前table在hover时进行广播
128
+ var publishCurTableHoveringEvent = function publishCurTableHoveringEvent() {
129
+ events.emit('TABLE_HOVERING', tableId);
130
+ };
131
+
132
+ // 接收广播:其他table在hover时,取消当前table的hover
133
+ var receiveCurTableHoveringEvent = useCallback(function (hoveringTableId) {
134
+ if (hoveringTableId !== tableId) {
135
+ clearHoverRowIndex();
136
+ }
137
+ }, []);
138
+ useEventBus('TABLE_HOVERING', receiveCurTableHoveringEvent);
139
+
140
+ // 拖动时,即时修改hover信息
141
+ var changeHoverRow = useCallback(function (_ref2) {
142
+ var _origin$draggedRow, _origin$draggedRows;
143
+ var target = _ref2.target,
144
+ origin = _ref2.origin;
145
+ publishCurTableHoveringEvent();
146
+ var targetRowIndex = target === null || target === void 0 ? void 0 : target.index;
147
+ var originRowIndex = origin === null || origin === void 0 || (_origin$draggedRow = origin.draggedRow) === null || _origin$draggedRow === void 0 ? void 0 : _origin$draggedRow.index;
148
+ var originRowIndexList = (origin === null || origin === void 0 || (_origin$draggedRows = origin.draggedRows) === null || _origin$draggedRows === void 0 ? void 0 : _origin$draggedRows.map(function (row) {
149
+ return row.index;
150
+ })) || [];
151
+ if (tableId === origin.sourceTableId && originRowIndexList.includes(targetRowIndex)) {
152
+ clearHoverRowIndex();
153
+ } else if (targetRowIndex !== hoverRowIndex) {
154
+ setHoverRowIndex(targetRowIndex);
155
+ if (tableId !== origin.sourceTableId) {
156
+ setDropSide(DropSide.Top);
157
+ } else {
158
+ setDropSide(targetRowIndex > originRowIndex ? DropSide.Bottom : DropSide.Top);
159
+ }
160
+ }
161
+ }, [hoverRowIndex]);
162
+
163
+ // 拖动到最后一行下面的空白处,在最后一行数据上展示预览位置
164
+ var addToLast = useCallback(function () {
165
+ publishCurTableHoveringEvent();
166
+ var lastIndex = table.getRowModel().rows.length - 1;
167
+ if (lastIndex !== hoverRowIndex || lastIndex === hoverRowIndex && dropSide !== DropSide.Bottom) {
168
+ setHoverRowIndex(lastIndex);
169
+ setDropSide(DropSide.Bottom);
170
+ }
171
+ }, [hoverRowIndex, dropSide]);
172
+
173
+ // cell右键菜单
174
+ var handleCellContextMenu = useCallback(function (e, cell) {
175
+ if (getContextMenu) {
176
+ var options = getContextMenu({
177
+ row: cell.row.original,
178
+ column: cell.column.columnDef
179
+ });
180
+ setContextMenuData({
181
+ visible: options.length > 0,
182
+ clientX: e.clientX,
183
+ clientY: e.clientY,
184
+ row: cell.row.original,
185
+ column: cell.column.columnDef,
186
+ options: options
187
+ });
188
+ e.preventDefault();
189
+ }
190
+ }, [getContextMenu]);
191
+
192
+ // 关闭菜单
193
+ var closeContextMenu = useCallback(function () {
194
+ setContextMenuData(_objectSpread(_objectSpread({}, contextMenuData), {}, {
195
+ visible: false
196
+ }));
197
+ }, []);
198
+ var _useDrop = useDrop({
199
+ accept: 'TABLE_ROW',
200
+ drop: function drop(formDatas) {
201
+ return reorderRow === null || reorderRow === void 0 ? void 0 : reorderRow(formDatas, {
202
+ hoverRow: {
203
+ index: 0
204
+ },
205
+ targetTableId: tableId
206
+ });
207
+ }
208
+ }),
209
+ _useDrop2 = _slicedToArray(_useDrop, 2),
210
+ dropEmptyRef = _useDrop2[1];
211
+ var _useDrop3 = useDrop({
212
+ accept: 'TABLE_ROW',
213
+ drop: function drop(formDatas, monitor) {
214
+ if (monitor.didDrop()) {
215
+ return undefined;
216
+ }
217
+ clearHoverRowIndex();
218
+ return reorderRow === null || reorderRow === void 0 ? void 0 : reorderRow(formDatas, {
219
+ hoverRow: undefined,
220
+ targetTableId: tableId
221
+ });
222
+ },
223
+ hover: function hover(item, monitor) {
224
+ if (monitor.isOver({
225
+ shallow: true
226
+ }) && monitor.canDrop()) {
227
+ addToLast();
228
+ }
229
+ }
230
+ }),
231
+ _useDrop4 = _slicedToArray(_useDrop3, 2),
232
+ dropTableEmptyRef = _useDrop4[1];
233
+
234
+ // 是否有数据
235
+ var showTable = useMemo(function () {
236
+ var _table$getRowModel$ro;
237
+ return !loading && datas.length !== 0 && ((_table$getRowModel$ro = table.getRowModel().rows) === null || _table$getRowModel$ro === void 0 ? void 0 : _table$getRowModel$ro.length) !== 0;
238
+ }, [loading, datas.length, (_table$getRowModel$ro2 = table.getRowModel().rows) === null || _table$getRowModel$ro2 === void 0 ? void 0 : _table$getRowModel$ro2.length]);
239
+
240
+ // 渲染虚拟行
241
+ var renderVirtualRows = function renderVirtualRows() {
242
+ return virtualRows.map(function (virtualRow) {
243
+ var row = table.getRowModel().rows[virtualRow.index];
244
+ var rowEditing = row.id === editingRowId;
245
+ return /*#__PURE__*/_jsx(VirtualRow, {
246
+ tableBodyRef: tableBodyRef,
247
+ table: table,
248
+ tableId: tableId,
249
+ row: row,
250
+ rowKey: rowKey,
251
+ theme: theme,
252
+ reorderRow: reorderRow,
253
+ rowSelectedId: rowSelectedId,
254
+ setRowSelectedId: setRowSelectedId,
255
+ rowHighLightId: rowHighLightId,
256
+ setRowHighLightId: setRowHighLightId,
257
+ selectedRowChange: selectedRowChange,
258
+ onSelectChange: onSelectChange,
259
+ canSelection: canSelection,
260
+ selectionWithoutChecked: selectionWithoutChecked,
261
+ selectedRowDragging: selectedRowDragging,
262
+ setSelectedRowDragging: setSelectedRowDragging,
263
+ canRowDrag: canRowDrag,
264
+ dragBeforeStart: dragBeforeStart,
265
+ rowClassName: rowClassName,
266
+ cellClassName: cellClassName,
267
+ rowStyle: rowStyle,
268
+ getCellProps: getCellProps,
269
+ editting: !!editingRowId,
270
+ rowEditing: rowEditing,
271
+ renderSubComponent: renderSubComponent,
272
+ onRowMouseEnter: onRowMouseEnter,
273
+ onRowMouseLeave: onRowMouseLeave,
274
+ onRowMouseClick: onRowMouseClick,
275
+ onRowMouseDoubleClick: onRowMouseDoubleClick,
276
+ rowHeight: rowHeight,
277
+ disableDragRowIds: disableDragRowIds,
278
+ selectRowWhenClick: selectRowWhenClick,
279
+ handleEditRowWhenDClick: handleEditRowWhenDClick,
280
+ canEditRowWhenDClick: canEditRowWhenDClick,
281
+ onCellContextMenu: handleCellContextMenu,
282
+ getRowHoverTipConfig: getRowHoverTipConfig,
283
+ tableTooltip: tableTooltip,
284
+ changeHoverRow: changeHoverRow,
285
+ clearHoverRowIndex: clearHoverRowIndex,
286
+ hoverRowIndex: hoverRowIndex,
287
+ dropSide: dropSide,
288
+ onEditValueChange: onEditValueChange,
289
+ setRowSelection: setRowSelection,
290
+ openMemo: openMemo
291
+ // virtualColumns={virtualColumns}
292
+ // scrollableColumns={scrollableColumns}
293
+ // virtualPaddingLeft={virtualPaddingLeft}
294
+ // virtualPaddingRight={virtualPaddingRight}
295
+ // leftPinnedColumns={leftPinnedColumns}
296
+ // rightPinnedColumns={rightPinnedColumns}
297
+ ,
298
+ virtualRowStart: virtualRow.start
299
+ }, row.id);
300
+ });
301
+ };
302
+
303
+ // 渲染普通行(非虚拟化)
304
+ var renderNormalRows = function renderNormalRows() {
305
+ return table.getRowModel().rows.map(function (row) {
306
+ var rowEditing = row.id === editingRowId;
307
+ return /*#__PURE__*/_jsx(VirtualRow, {
308
+ tableBodyRef: tableBodyRef,
309
+ table: table,
310
+ tableId: tableId,
311
+ row: row,
312
+ rowKey: rowKey,
313
+ theme: theme,
314
+ reorderRow: reorderRow,
315
+ rowSelectedId: rowSelectedId,
316
+ setRowSelectedId: setRowSelectedId,
317
+ rowHighLightId: rowHighLightId,
318
+ setRowHighLightId: setRowHighLightId,
319
+ selectedRowChange: selectedRowChange,
320
+ onSelectChange: onSelectChange,
321
+ canSelection: canSelection,
322
+ selectionWithoutChecked: selectionWithoutChecked,
323
+ selectedRowDragging: selectedRowDragging,
324
+ setSelectedRowDragging: setSelectedRowDragging,
325
+ canRowDrag: canRowDrag,
326
+ dragBeforeStart: dragBeforeStart,
327
+ rowClassName: rowClassName,
328
+ cellClassName: cellClassName,
329
+ rowStyle: rowStyle,
330
+ getCellProps: getCellProps,
331
+ editting: !!editingRowId,
332
+ rowEditing: rowEditing,
333
+ renderSubComponent: renderSubComponent,
334
+ onRowMouseEnter: onRowMouseEnter,
335
+ onRowMouseLeave: onRowMouseLeave,
336
+ onRowMouseClick: onRowMouseClick,
337
+ onRowMouseDoubleClick: onRowMouseDoubleClick,
338
+ rowHeight: rowHeight,
339
+ disableDragRowIds: disableDragRowIds,
340
+ selectRowWhenClick: selectRowWhenClick,
341
+ handleEditRowWhenDClick: handleEditRowWhenDClick,
342
+ canEditRowWhenDClick: canEditRowWhenDClick,
343
+ onCellContextMenu: handleCellContextMenu,
344
+ getRowHoverTipConfig: getRowHoverTipConfig,
345
+ tableTooltip: tableTooltip,
346
+ changeHoverRow: changeHoverRow,
347
+ clearHoverRowIndex: clearHoverRowIndex,
348
+ hoverRowIndex: hoverRowIndex,
349
+ dropSide: dropSide,
350
+ onEditValueChange: onEditValueChange,
351
+ setRowSelection: setRowSelection,
352
+ openMemo: openMemo
353
+ }, row.id);
354
+ });
355
+ };
356
+ var tBodyHeight = useMemo(function () {
357
+ if (!openVirtualRows || !(rowVirtualizer !== null && rowVirtualizer !== void 0 && rowVirtualizer.getTotalSize())) return 'auto';
358
+ return (rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.getTotalSize()) + (hasTotalRow ? rowHeight : 0);
359
+ }, [openVirtualRows, hasTotalRow, rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.getTotalSize(), rowHeight]);
360
+ return /*#__PURE__*/_jsxs(_Fragment, {
361
+ children: [canRowDrag && !editingRowId && /*#__PURE__*/createPortal( /*#__PURE__*/_jsx(CustomDragLayer, {
362
+ getCellProps: getCellProps,
363
+ rowClassName: rowClassName,
364
+ cellClassName: cellClassName,
365
+ rowStyle: rowStyle,
366
+ theme: theme,
367
+ rowSelectedId: rowSelectedId,
368
+ table: table,
369
+ tableId: tableId,
370
+ compactMode: compactMode
371
+ }), root ? document.querySelector(root) : document.body), showTable ? /*#__PURE__*/_jsx("div", {
372
+ className: "table-max-table-body-table-wrapper",
373
+ ref: dropTableEmptyRef
374
+ // style={{
375
+ // height: `${rowVirtualizer.getTotalSize()}px`,
376
+ // position: 'relative'
377
+ // }}
378
+ ,
379
+ children: /*#__PURE__*/_jsxs("table", {
380
+ children: [/*#__PURE__*/_jsx(ColGroup, {
381
+ leftPinnedColumns: leftPinnedColumns,
382
+ scrollableColumns: scrollableColumns,
383
+ rightPinnedColumns: rightPinnedColumns,
384
+ virtualColumns: virtualColumns,
385
+ virtualPaddingLeft: virtualPaddingLeft,
386
+ virtualPaddingRight: virtualPaddingRight
387
+ }), /*#__PURE__*/_jsxs("tbody", {
388
+ id: "table-max-tableBody-tbody-".concat(tableId),
389
+ style: {
390
+ position: openVirtualRows ? 'relative' : 'static',
391
+ height: tBodyHeight,
392
+ paddingBottom: openVirtualRows && hasTotalRow ? "".concat(rowHeight, "px") : 0
393
+ },
394
+ children: [openVirtualRows ? renderVirtualRows() : renderNormalRows(), hasTotalRow && /*#__PURE__*/_jsx(Total, {
395
+ table: table,
396
+ totalDatas: totalDatas,
397
+ rowHeight: rowHeight
398
+ })]
399
+ })]
400
+ })
401
+ }) : /*#__PURE__*/_jsx("div", {
402
+ className: "empty-container",
403
+ style: {
404
+ width: table.getTotalSize()
405
+ },
406
+ children: /*#__PURE__*/_jsx("div", {
407
+ className: "empty-wrapper",
408
+ style: {
409
+ width: "".concat(tableContainerWidth - 10, "px")
410
+ },
411
+ children: loading ? /*#__PURE__*/_jsx(Spin, {}) : /*#__PURE__*/_jsx("span", {
412
+ className: "empty-content",
413
+ ref: dropEmptyRef,
414
+ children: /*#__PURE__*/_jsx(Empty, {})
415
+ })
416
+ })
417
+ }), /*#__PURE__*/_jsx(ContextMenu, _objectSpread(_objectSpread({}, contextMenuData), {}, {
418
+ onClickContextMenu: onClickContextMenu,
419
+ closeContextMenu: closeContextMenu
420
+ }))]
421
+ });
422
+ };
423
+ export { VirtualTableBody };
@@ -4,23 +4,49 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- import { getPinningStyle } from "../../TableHeader/utils";
7
+ import { findHeaderByColumn, getPinningStyle } from "../../TableHeader/utils";
8
8
  import "../../TableBody/index.less";
9
+ import { useVirtualConfig, useVirtualState } from "../../hooks/useVirtualScroll";
10
+
11
+ // 虚拟填充组件
9
12
  import { jsx as _jsx } from "react/jsx-runtime";
10
13
  import { Fragment as _Fragment } from "react/jsx-runtime";
11
- export var Total = function Total(_ref) {
12
- var table = _ref.table,
13
- totalDatas = _ref.totalDatas,
14
- rowHeight = _ref.rowHeight;
14
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ var VirtualPadding = function VirtualPadding(_ref) {
16
+ var width = _ref.width,
17
+ type = _ref.type;
18
+ if (!width) return null;
19
+ return /*#__PURE__*/_jsx("td", {
20
+ style: {
21
+ width: "".concat(width, "px"),
22
+ // height: '100%',
23
+ padding: 0,
24
+ border: 'none'
25
+ },
26
+ className: "virtual-padding virtual-padding-".concat(type)
27
+ });
28
+ };
29
+ export var Total = function Total(_ref2) {
30
+ var table = _ref2.table,
31
+ totalDatas = _ref2.totalDatas,
32
+ rowHeight = _ref2.rowHeight;
15
33
  var footerGroups = table.getFooterGroups();
34
+ var state = useVirtualState();
35
+ var config = useVirtualConfig();
36
+ var leftPinnedColumns = state.leftPinnedColumns,
37
+ rightPinnedColumns = state.rightPinnedColumns,
38
+ scrollableColumns = state.scrollableColumns,
39
+ virtualColumns = state.virtualColumns,
40
+ virtualPaddingLeft = state.virtualPaddingLeft,
41
+ virtualPaddingRight = state.virtualPaddingRight;
16
42
 
17
- // 公共样式对象,避免重复创建
43
+ // 公共样式对象
18
44
  var rowStyle = {
19
45
  width: '100%',
20
46
  position: 'sticky',
21
- bottom: '-0.5px',
47
+ bottom: '0px',
22
48
  left: '0px',
23
- zIndex: 200
49
+ zIndex: 202
24
50
  };
25
51
  var cellWrapperStyle = {
26
52
  boxSizing: 'border-box',
@@ -28,6 +54,57 @@ export var Total = function Total(_ref) {
28
54
  borderBottom: '1px solid var(--tableColor2)',
29
55
  height: "100%"
30
56
  };
57
+
58
+ // 统一的单元格渲染函数
59
+ var renderCell = function renderCell(header) {
60
+ var keySuffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
61
+ var headerId = header.id,
62
+ colSpan = header.colSpan;
63
+ var pinningStyle = getPinningStyle(header, table);
64
+ var cellStyle = _objectSpread(_objectSpread({}, pinningStyle), {}, {
65
+ height: "".concat(rowHeight - 1, "px")
66
+ });
67
+ return /*#__PURE__*/_jsx("td", {
68
+ colSpan: colSpan,
69
+ style: cellStyle,
70
+ className: "tbody-tr-td",
71
+ children: /*#__PURE__*/_jsx("div", {
72
+ className: "table-max-cell-wrapper",
73
+ style: cellWrapperStyle,
74
+ children: totalDatas === null || totalDatas === void 0 ? void 0 : totalDatas[headerId]
75
+ })
76
+ }, "".concat(headerId).concat(keySuffix));
77
+ };
78
+
79
+ // 渲染普通列(非虚拟滚动)
80
+ var renderNormalColumns = function renderNormalColumns(headers) {
81
+ return headers.map(function (header) {
82
+ return renderCell(header);
83
+ });
84
+ };
85
+
86
+ // 渲染虚拟滚动列
87
+ var renderVirtualColumns = function renderVirtualColumns(footerGroup) {
88
+ return /*#__PURE__*/_jsxs(_Fragment, {
89
+ children: [leftPinnedColumns.map(function (column, index) {
90
+ var header = findHeaderByColumn(footerGroup, column);
91
+ return header ? renderCell(header, "-left-".concat(index)) : null;
92
+ }), /*#__PURE__*/_jsx(VirtualPadding, {
93
+ type: "left",
94
+ width: virtualPaddingLeft
95
+ }), virtualColumns.map(function (virtualColumn, index) {
96
+ var column = scrollableColumns[virtualColumn.index];
97
+ var header = findHeaderByColumn(footerGroup, column);
98
+ return header ? renderCell(header, "-virtual-".concat(index)) : null;
99
+ }), /*#__PURE__*/_jsx(VirtualPadding, {
100
+ type: "right",
101
+ width: virtualPaddingRight
102
+ }), rightPinnedColumns.map(function (column, index) {
103
+ var header = findHeaderByColumn(footerGroup, column);
104
+ return header ? renderCell(header, "-right-".concat(index)) : null;
105
+ })]
106
+ });
107
+ };
31
108
  return /*#__PURE__*/_jsx(_Fragment, {
32
109
  children: footerGroups.map(function (footerGroup) {
33
110
  var id = footerGroup.id,
@@ -35,25 +112,7 @@ export var Total = function Total(_ref) {
35
112
  return /*#__PURE__*/_jsx("tr", {
36
113
  className: "tbody-tr",
37
114
  style: rowStyle,
38
- children: headers.map(function (header) {
39
- var headerId = header.id,
40
- colSpan = header.colSpan;
41
- var pinningStyle = getPinningStyle(header, table);
42
- var cellStyle = _objectSpread(_objectSpread({}, pinningStyle), {}, {
43
- height: "".concat(rowHeight - 1, "px")
44
- });
45
- var cellClassNames = ['tbody-tr-td'].filter(Boolean).join(' ');
46
- return /*#__PURE__*/_jsx("td", {
47
- colSpan: colSpan,
48
- style: cellStyle,
49
- className: cellClassNames,
50
- children: /*#__PURE__*/_jsx("div", {
51
- className: "table-max-cell-wrapper",
52
- style: cellWrapperStyle,
53
- children: totalDatas === null || totalDatas === void 0 ? void 0 : totalDatas[headerId]
54
- })
55
- }, headerId);
56
- })
115
+ children: config.openVirtualColumns ? renderVirtualColumns(footerGroup) : renderNormalColumns(headers)
57
116
  }, id);
58
117
  })
59
118
  });
@@ -1,76 +1,4 @@
1
- import { Table } from '@tanstack/react-table';
2
- import { IMenuOptionsType, OnSelectChangeType } from "../type";
3
- import { Dispatch, MutableRefObject, ReactNode, SetStateAction } from 'react';
4
- import './index.less';
5
- type TableBodyPropsType = {
6
- tableBodyRef: MutableRefObject<HTMLDivElement> | null;
7
- tableContentRef: MutableRefObject<HTMLDivElement> | null;
8
- table: Table<any>;
9
- tableId: string;
10
- theme: string;
11
- reorderRow: any;
12
- rowSelectedId: string;
13
- setRowSelectedId: Dispatch<SetStateAction<string | undefined>>;
14
- selectedRowChange: (row: any) => void;
15
- onSelectChange: OnSelectChangeType;
16
- canFilter: boolean;
17
- canSelection: boolean;
18
- selectionWithoutChecked?: boolean;
19
- tableContainerWidth: number;
20
- selectedRowDragging: boolean;
21
- setSelectedRowDragging: Dispatch<SetStateAction<boolean>>;
22
- rowHighLightId: string;
23
- setRowHighLightId?: Dispatch<SetStateAction<string | undefined>>;
24
- canRowDrag: boolean;
25
- rowKey: string;
26
- hasGroup: boolean;
27
- tableDatas: any[];
28
- canSorting: boolean;
29
- loading: boolean;
30
- rowClassName: (row: any) => string[];
31
- cellClassName: (cell: any) => string[];
32
- rowStyle: object;
33
- getCellProps: (ctx: any) => object;
34
- rowHeight: number;
35
- renderSubComponent: (value: {
36
- row: any;
37
- }) => ReactNode;
38
- onRowMouseEnter: (row: any) => void;
39
- onRowMouseLeave: (row: any) => void;
40
- onRowMouseClick: (row: any) => void;
41
- onRowMouseDoubleClick: (row: any) => void;
42
- enableFilters: boolean;
43
- enableVirtualList: boolean;
44
- disableDragRowIds: any[];
45
- selectRowWhenClick: boolean;
46
- datas: any[];
47
- canEditRowWhenDClick: boolean;
48
- editingRowId: string;
49
- handleEditRowWhenDClick: (row: any) => void;
50
- dragBeforeStart: (datas: any) => boolean;
51
- /**右键菜单,配置后,开启右键菜单功能:点击右键时,获取菜单可选项 */
52
- getContextMenu?: (params: {
53
- row: any;
54
- column: any;
55
- }) => IMenuOptionsType;
56
- /**点击菜单选项 */
57
- onClickContextMenu?: (params: {
58
- row: any;
59
- column: any;
60
- clickedMenuValue: any;
61
- }) => void;
62
- /**获取行hover时的tip信息 */
63
- getRowHoverTipConfig?: (row: any) => {
64
- title: string;
65
- color: string;
66
- };
67
- tableTooltip: boolean;
68
- compactMode: boolean;
69
- onEditValueChange?: (field: string, value: any, extra?: any) => void;
70
- hasTotalRow?: boolean;
71
- totalDatas?: any[];
72
- setRowSelection: Function;
73
- openMemo?: boolean;
74
- };
75
- declare const TableBody: ({ tableBodyRef, table, tableId, theme, reorderRow, rowSelectedId, setRowSelectedId, rowHighLightId, setRowHighLightId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked, tableContainerWidth, selectedRowDragging, setSelectedRowDragging, canRowDrag, rowKey, loading, rowClassName, cellClassName, rowStyle, getCellProps, rowHeight, renderSubComponent, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, disableDragRowIds, selectRowWhenClick, datas, canEditRowWhenDClick, editingRowId, handleEditRowWhenDClick, dragBeforeStart, getContextMenu, onClickContextMenu, getRowHoverTipConfig, tableTooltip, compactMode, onEditValueChange, hasTotalRow, totalDatas, setRowSelection, openMemo }: TableBodyPropsType) => import("react/jsx-runtime").JSX.Element;
1
+ import { TableBody } from './TableBody';
2
+ export { VirtualTableBody } from './VirtualTableBody';
3
+ export { OriginalTableBody } from './OriginalTableBody';
76
4
  export default TableBody;