@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,63 @@
1
+ import { DropSide, OnSelectChangeType } from "../type";
2
+ import { Table } from '@tanstack/react-table';
3
+ import React, { Dispatch, ReactNode, SetStateAction } from 'react';
4
+ import './index.less';
5
+ type IRowProps = {
6
+ table: Table<any>;
7
+ tableId: string;
8
+ row: any;
9
+ rowSelectedId?: string;
10
+ setRowSelectedId?: Dispatch<SetStateAction<string | undefined>>;
11
+ rowHighLightId: string;
12
+ setRowHighLightId?: Dispatch<SetStateAction<string | undefined>>;
13
+ selectedRowChange?: (row: any) => void;
14
+ onSelectChange?: OnSelectChangeType;
15
+ tableBodyRef: any;
16
+ canSelection?: boolean;
17
+ selectionWithoutChecked?: boolean;
18
+ reorderRow?: (targetRowIndex: any, draggedRowIndex: any) => void;
19
+ canRowDrag?: boolean;
20
+ rowClassName?: (row: any) => string[];
21
+ cellClassName?: (cell: any) => string[];
22
+ rowStyle?: object;
23
+ getCellProps?: (ctx: any) => object;
24
+ editting?: boolean;
25
+ rowEditing?: boolean;
26
+ renderSubComponent?: (value: {
27
+ row: any;
28
+ }) => ReactNode;
29
+ selectedRowDragging?: boolean;
30
+ setSelectedRowDragging?: Dispatch<SetStateAction<boolean>>;
31
+ onRowMouseEnter?: (row: any) => void;
32
+ onRowMouseLeave?: (row: any) => void;
33
+ onRowMouseClick?: (row: any) => void;
34
+ onRowMouseDoubleClick?: (row: any) => void;
35
+ rowHeight: number;
36
+ disableDragRowIds?: any[];
37
+ selectRowWhenClick: boolean;
38
+ handleEditRowWhenDClick: (row: any) => void;
39
+ canEditRowWhenDClick: boolean;
40
+ theme: string;
41
+ dragBeforeStart?: (datas: any) => boolean;
42
+ rowKey?: string;
43
+ onCellContextMenu: (e: React.MouseEvent, cell: any) => void;
44
+ /**获取行hover时的tip信息 */
45
+ getRowHoverTipConfig?: (row: any) => {
46
+ title: string;
47
+ color: string;
48
+ };
49
+ tableTooltip: boolean;
50
+ changeHoverRow: (params: {
51
+ target?: any;
52
+ origin?: any;
53
+ }) => void;
54
+ clearHoverRowIndex: () => void;
55
+ hoverRowIndex: number;
56
+ dropSide: DropSide;
57
+ onEditValueChange?: (field: string, value: any, extra?: any) => void;
58
+ setRowSelection?: Function;
59
+ openMemo?: boolean;
60
+ virtualRowStart?: number;
61
+ };
62
+ declare const VirtualRow: ({ tableBodyRef, table, tableId, row, rowSelectedId, setRowSelectedId, rowHighLightId, setRowHighLightId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked, reorderRow, canRowDrag, rowClassName, cellClassName, rowStyle, getCellProps, editting, rowEditing, renderSubComponent, selectedRowDragging, setSelectedRowDragging, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, rowHeight, disableDragRowIds, selectRowWhenClick, handleEditRowWhenDClick, canEditRowWhenDClick, theme, dragBeforeStart, onCellContextMenu, getRowHoverTipConfig, tableTooltip, changeHoverRow, clearHoverRowIndex, hoverRowIndex, dropSide, onEditValueChange, setRowSelection, openMemo, virtualRowStart }: IRowProps) => import("react/jsx-runtime").JSX.Element;
63
+ export { VirtualRow };
@@ -0,0 +1,479 @@
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ 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; }
7
+ 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; }
8
+ 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; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ 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); }
11
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
+ 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."); }
13
+ 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); }
14
+ 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; }
15
+ 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; } }
16
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
+ import { DropSide } from "../type";
18
+ import { flexRender } from '@tanstack/react-table';
19
+ import { useUpdateEffect } from 'ahooks';
20
+ import { Tooltip } from 'antd';
21
+ import React, { useEffect, useMemo, useRef, useState, useCallback } from 'react';
22
+ import { useDrag, useDrop } from 'react-dnd';
23
+ import { getEmptyImage } from 'react-dnd-html5-backend';
24
+ import { getPinningStyle } from "../TableHeader/utils";
25
+ import { EditableCell } from "../components/ColumnEdit";
26
+ import "./index.less";
27
+ import dayjs from 'dayjs';
28
+ import { useConfig } from "../../ConfigProvider";
29
+ import { useVirtualConfig, useVirtualState } from "../hooks/useVirtualScroll";
30
+ import { jsx as _jsx } from "react/jsx-runtime";
31
+ import { Fragment as _Fragment } from "react/jsx-runtime";
32
+ import { jsxs as _jsxs } from "react/jsx-runtime";
33
+ var initselectedIndex;
34
+ var VirtualRow = function VirtualRow(_ref) {
35
+ var _tableBodyRef$current, _tableBodyRef$current2;
36
+ var tableBodyRef = _ref.tableBodyRef,
37
+ table = _ref.table,
38
+ tableId = _ref.tableId,
39
+ row = _ref.row,
40
+ rowSelectedId = _ref.rowSelectedId,
41
+ setRowSelectedId = _ref.setRowSelectedId,
42
+ rowHighLightId = _ref.rowHighLightId,
43
+ setRowHighLightId = _ref.setRowHighLightId,
44
+ selectedRowChange = _ref.selectedRowChange,
45
+ onSelectChange = _ref.onSelectChange,
46
+ canSelection = _ref.canSelection,
47
+ selectionWithoutChecked = _ref.selectionWithoutChecked,
48
+ reorderRow = _ref.reorderRow,
49
+ canRowDrag = _ref.canRowDrag,
50
+ rowClassName = _ref.rowClassName,
51
+ cellClassName = _ref.cellClassName,
52
+ rowStyle = _ref.rowStyle,
53
+ getCellProps = _ref.getCellProps,
54
+ editting = _ref.editting,
55
+ rowEditing = _ref.rowEditing,
56
+ renderSubComponent = _ref.renderSubComponent,
57
+ selectedRowDragging = _ref.selectedRowDragging,
58
+ setSelectedRowDragging = _ref.setSelectedRowDragging,
59
+ onRowMouseEnter = _ref.onRowMouseEnter,
60
+ onRowMouseLeave = _ref.onRowMouseLeave,
61
+ onRowMouseClick = _ref.onRowMouseClick,
62
+ onRowMouseDoubleClick = _ref.onRowMouseDoubleClick,
63
+ rowHeight = _ref.rowHeight,
64
+ disableDragRowIds = _ref.disableDragRowIds,
65
+ selectRowWhenClick = _ref.selectRowWhenClick,
66
+ handleEditRowWhenDClick = _ref.handleEditRowWhenDClick,
67
+ canEditRowWhenDClick = _ref.canEditRowWhenDClick,
68
+ theme = _ref.theme,
69
+ dragBeforeStart = _ref.dragBeforeStart,
70
+ onCellContextMenu = _ref.onCellContextMenu,
71
+ getRowHoverTipConfig = _ref.getRowHoverTipConfig,
72
+ tableTooltip = _ref.tableTooltip,
73
+ changeHoverRow = _ref.changeHoverRow,
74
+ clearHoverRowIndex = _ref.clearHoverRowIndex,
75
+ hoverRowIndex = _ref.hoverRowIndex,
76
+ dropSide = _ref.dropSide,
77
+ onEditValueChange = _ref.onEditValueChange,
78
+ setRowSelection = _ref.setRowSelection,
79
+ openMemo = _ref.openMemo,
80
+ virtualRowStart = _ref.virtualRowStart;
81
+ var _useConfig = useConfig(),
82
+ dateFormat = _useConfig.dateFormat;
83
+ var timerRef = useRef();
84
+ var clickCountRef = useRef(0);
85
+
86
+ // 使用 Provider 中的虚拟化数据
87
+ var config = useVirtualConfig();
88
+ var state = useVirtualState();
89
+
90
+ // 从 Provider 中获取虚拟化数据
91
+ var virtualColumns = state.virtualColumns,
92
+ virtualPaddingLeft = state.virtualPaddingLeft,
93
+ virtualPaddingRight = state.virtualPaddingRight;
94
+
95
+ // 优化:使用useMemo缓存计算结果
96
+ var dropPreviewLineClassName = useMemo(function () {
97
+ if (hoverRowIndex === row.index) {
98
+ return dropSide === DropSide.Top ? 'showTopBorder' : 'showBottomBorder';
99
+ }
100
+ return '';
101
+ }, [hoverRowIndex, dropSide, row.index]);
102
+ var highLightClassName = useMemo(function () {
103
+ if (!canSelection && String(row.id) === String(rowSelectedId)) {
104
+ return 'tbody-tr-highlight';
105
+ } else if (canSelection) {
106
+ if (String(row.id) === String(rowHighLightId)) {
107
+ return 'tbody-tr-highlight';
108
+ } else if (row.getIsSelected()) {
109
+ return 'tbody-tr-selected';
110
+ }
111
+ }
112
+ return '';
113
+ }, [row.id, row.getIsSelected(), rowSelectedId, rowHighLightId, canSelection]);
114
+ var rowClassNames = useMemo(function () {
115
+ var _rowClassName;
116
+ var baseClass = "tbody-tr ".concat(highLightClassName, " ").concat(dropPreviewLineClassName);
117
+ var customClasses = (rowClassName === null || rowClassName === void 0 || (_rowClassName = rowClassName(row)) === null || _rowClassName === void 0 ? void 0 : _rowClassName.map(function (item) {
118
+ return "".concat(item, "-").concat(theme);
119
+ }).join(' ')) || '';
120
+ return "".concat(baseClass, " ").concat(customClasses).trim();
121
+ }, [highLightClassName, dropPreviewLineClassName, rowClassName, row, theme]);
122
+
123
+ // 获取所有可见单元格
124
+ var visibleCells = useMemo(function () {
125
+ return row.getVisibleCells();
126
+ }, [row, table.getState().columnVisibility]);
127
+
128
+ // 分离固定列和可滚动列的单元格
129
+ var _useMemo = useMemo(function () {
130
+ var leftPinned = row.getLeftVisibleCells();
131
+ var rightPinned = row.getRightVisibleCells();
132
+ var scrollable = row.getCenterVisibleCells();
133
+ return {
134
+ leftPinnedCells: leftPinned,
135
+ rightPinnedCells: rightPinned,
136
+ scrollableCells: scrollable
137
+ };
138
+ }, [row, table.getState().columnPinning, table.getState().columnVisibility]),
139
+ leftPinnedCells = _useMemo.leftPinnedCells,
140
+ rightPinnedCells = _useMemo.rightPinnedCells,
141
+ scrollableCells = _useMemo.scrollableCells;
142
+
143
+ // 拖拽相关逻辑保持不变
144
+ var _useDrop = useDrop({
145
+ accept: 'TABLE_ROW',
146
+ drop: function drop(formDatas) {
147
+ clearHoverRowIndex();
148
+ return reorderRow === null || reorderRow === void 0 ? void 0 : reorderRow(formDatas, {
149
+ hoverRow: row,
150
+ targetTableId: tableId
151
+ });
152
+ },
153
+ hover: function hover(item, monitor) {
154
+ if (monitor.isOver() && monitor.canDrop()) {
155
+ changeHoverRow({
156
+ target: row,
157
+ origin: item
158
+ });
159
+ }
160
+ }
161
+ }),
162
+ _useDrop2 = _slicedToArray(_useDrop, 2),
163
+ dropRef = _useDrop2[1];
164
+ var _useDrag = useDrag({
165
+ collect: function collect(monitor) {
166
+ return {
167
+ isDragging: monitor !== null && monitor !== void 0 && monitor.getItem() ? dragBeforeStart === null || dragBeforeStart === void 0 ? void 0 : dragBeforeStart(monitor === null || monitor === void 0 ? void 0 : monitor.getItem()) : monitor.isDragging()
168
+ };
169
+ },
170
+ item: function item() {
171
+ var _table$getSelectedRow;
172
+ var selectedRows = ((_table$getSelectedRow = table.getSelectedRowModel()) === null || _table$getSelectedRow === void 0 ? void 0 : _table$getSelectedRow.rows) || [];
173
+ var selectedRowsNumber = (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) || 0;
174
+ var selectedRowsIndexList = selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.map(function (row) {
175
+ return row.index;
176
+ });
177
+ var isMultipleDrag = selectedRowsNumber > 1 && selectedRowsIndexList.includes(row.index);
178
+ return {
179
+ draggedRow: row,
180
+ isMultipleDrag: isMultipleDrag,
181
+ draggedRows: isMultipleDrag ? selectedRows : [row],
182
+ sourceTableId: tableId
183
+ };
184
+ },
185
+ type: 'TABLE_ROW'
186
+ }),
187
+ _useDrag2 = _slicedToArray(_useDrag, 3),
188
+ isDragging = _useDrag2[0].isDragging,
189
+ dragRef = _useDrag2[1],
190
+ preview = _useDrag2[2];
191
+ useEffect(function () {
192
+ if (canRowDrag) {
193
+ preview(getEmptyImage(), {
194
+ captureDraggingState: true
195
+ });
196
+ }
197
+ }, [canRowDrag]);
198
+ useEffect(function () {
199
+ if (setSelectedRowDragging && row.getIsSelected()) {
200
+ setSelectedRowDragging(isDragging);
201
+ }
202
+ }, [isDragging, row.getIsSelected()]);
203
+ useUpdateEffect(function () {
204
+ if (!isDragging) {
205
+ clearHoverRowIndex();
206
+ }
207
+ }, [isDragging]);
208
+ var handleCellRightClick = useCallback(function (e, cell) {
209
+ onCellContextMenu(e, cell);
210
+ }, [onCellContextMenu]);
211
+
212
+ // 渲染单个单元格
213
+ var renderCell = useCallback(function (cell) {
214
+ var _cell$column, _cell$getValue, _cell$getValue2, _cellClassName;
215
+ // 确保 cell.column.columnDef 存在
216
+ if (!(cell !== null && cell !== void 0 && (_cell$column = cell.column) !== null && _cell$column !== void 0 && _cell$column.columnDef)) {
217
+ console.warn('Cell column definition missing', cell);
218
+ return null;
219
+ }
220
+ var _cell$column$columnDe = cell.column.columnDef,
221
+ columnEditable = _cell$column$columnDe.editable,
222
+ accessorKey = _cell$column$columnDe.accessorKey,
223
+ header = _cell$column$columnDe.header,
224
+ columnClassName = _cell$column$columnDe.columnClassName,
225
+ columnId = _cell$column$columnDe.id,
226
+ filterType = _cell$column$columnDe.filterType;
227
+ var columnEditing = rowEditing && columnEditable;
228
+ var rawValue = (_cell$getValue = (_cell$getValue2 = cell.getValue) === null || _cell$getValue2 === void 0 ? void 0 : _cell$getValue2.call(cell)) !== null && _cell$getValue !== void 0 ? _cell$getValue : '';
229
+
230
+ // 检查必要的函数是否存在
231
+ if (typeof cell.getContext !== 'function') {
232
+ console.warn('cell.getContext is not a function', cell);
233
+ return null;
234
+ }
235
+ var originalContext = cell.getContext();
236
+ var enhancedContext = _objectSpread(_objectSpread({}, originalContext), {}, {
237
+ getValue: function getValue() {
238
+ return rawValue;
239
+ },
240
+ getFormattedValue: function getFormattedValue() {
241
+ var _cell$column$columnDe2;
242
+ return isDateColumn(cell.column.columnDef) ? formatDate(rawValue, ((_cell$column$columnDe2 = cell.column.columnDef) === null || _cell$column$columnDe2 === void 0 || (_cell$column$columnDe2 = _cell$column$columnDe2.meta) === null || _cell$column$columnDe2 === void 0 ? void 0 : _cell$column$columnDe2.dateFormat) || dateFormat) : rawValue;
243
+ },
244
+ renderValue: function renderValue() {
245
+ return enhancedContext.getFormattedValue();
246
+ }
247
+ });
248
+ var cellClassNames = [columnEditing ? 'tbody-tr-td-editting' : '', columnClassName ? columnClassName.join(' ') : ''].concat(_toConsumableArray((cellClassName === null || cellClassName === void 0 || (_cellClassName = cellClassName(cell)) === null || _cellClassName === void 0 ? void 0 : _cellClassName.map(function (item) {
249
+ return "".concat(item, "-").concat(theme);
250
+ })) || []), ['tbody-tr-td']).filter(Boolean).join(' ');
251
+ return /*#__PURE__*/_jsx("td", _objectSpread(_objectSpread({
252
+ className: cellClassNames,
253
+ style: _objectSpread(_objectSpread({
254
+ height: rowHeight - 1,
255
+ width: "".concat(cell.column.getSize(), "px")
256
+ }, getPinningStyle(cell, table, false)), {}, {
257
+ boxSizing: 'border-box'
258
+ }),
259
+ onContextMenu: function onContextMenu(e) {
260
+ return handleCellRightClick(e, cell);
261
+ }
262
+ }, getCellProps === null || getCellProps === void 0 ? void 0 : getCellProps(cell.getContext())), {}, {
263
+ children: EditableCell(_objectSpread(_objectSpread({}, cell.column.columnDef), {}, {
264
+ width: cell.column.getSize(),
265
+ tableTooltip: tableTooltip,
266
+ editing: columnEditing,
267
+ dataIndex: accessorKey,
268
+ title: header,
269
+ onEditValueChange: onEditValueChange,
270
+ children: flexRender(cell.column.columnDef.cell, enhancedContext)
271
+ }))
272
+ }), cell.id);
273
+ }, [rowEditing, cellClassName, theme, rowHeight, table, handleCellRightClick, getCellProps, tableTooltip, onEditValueChange, dateFormat]);
274
+
275
+ // 渲染左侧固定列
276
+ var renderLeftPinnedCells = useCallback(function () {
277
+ return leftPinnedCells.map(function (cell) {
278
+ return renderCell(cell);
279
+ });
280
+ }, [leftPinnedCells, renderCell]);
281
+
282
+ // 渲染右侧固定列
283
+ var renderRightPinnedCells = useCallback(function () {
284
+ return rightPinnedCells.map(function (cell) {
285
+ return renderCell(cell);
286
+ });
287
+ }, [rightPinnedCells, renderCell]);
288
+
289
+ // 渲染虚拟滚动列
290
+ var renderVirtualScrollCells = useCallback(function () {
291
+ if (!config.openVirtualColumns) {
292
+ return scrollableCells.map(function (cell) {
293
+ return renderCell(cell);
294
+ });
295
+ }
296
+ return /*#__PURE__*/_jsxs(_Fragment, {
297
+ children: [virtualPaddingLeft > 0 && /*#__PURE__*/_jsx("td", {
298
+ style: {
299
+ width: "".concat(virtualPaddingLeft, "px"),
300
+ padding: 0,
301
+ border: 'none'
302
+ }
303
+ }, "virtual-padding-left"), virtualColumns.map(function (virtualColumn) {
304
+ var cell = scrollableCells[virtualColumn.index];
305
+ return cell ? renderCell(cell) : null;
306
+ }), virtualPaddingRight > 0 && /*#__PURE__*/_jsx("td", {
307
+ style: {
308
+ width: "".concat(virtualPaddingRight, "px"),
309
+ padding: 0,
310
+ border: 'none'
311
+ }
312
+ }, "virtual-padding-right")]
313
+ });
314
+ }, [config.openVirtualColumns, virtualColumns, scrollableCells, virtualPaddingLeft, virtualPaddingRight, renderCell]);
315
+
316
+ // 行样式(支持虚拟行定位)
317
+ var rowStyles = useMemo(function () {
318
+ var baseStyle = _objectSpread({
319
+ opacity: isDragging || selectedRowDragging && row.getIsSelected() ? 0.5 : 1,
320
+ cursor: canRowDrag && !editting && !(disableDragRowIds !== null && disableDragRowIds !== void 0 && disableDragRowIds.includes(row.id)) ? 'move' : 'auto'
321
+ }, rowStyle);
322
+
323
+ // 如果是虚拟行,添加定位样式
324
+ if (config.openVirtualRows && virtualRowStart !== undefined) {
325
+ return _objectSpread(_objectSpread({}, baseStyle), {}, {
326
+ position: 'absolute',
327
+ top: 0,
328
+ left: 0,
329
+ width: '100%',
330
+ transform: "translateY(".concat(virtualRowStart, "px)")
331
+ });
332
+ }
333
+ return baseStyle;
334
+ }, [isDragging, selectedRowDragging, row.getIsSelected(), canRowDrag, editting, disableDragRowIds, row.id, rowStyle, config.openVirtualRows, virtualRowStart]);
335
+
336
+ // 点击事件处理逻辑保持不变
337
+ var handleRowClick = useCallback(function (evt) {
338
+ clickCountRef.current++;
339
+ if (clickCountRef.current === 1) {
340
+ timerRef.current = setTimeout(function () {
341
+ if (clickCountRef.current === 1) {
342
+ handleSingleClick(evt);
343
+ }
344
+ clickCountRef.current = 0;
345
+ if (timerRef.current) {
346
+ clearTimeout(timerRef.current);
347
+ timerRef.current = undefined;
348
+ }
349
+ }, 200);
350
+ } else if (clickCountRef.current === 2) {
351
+ handleDoubleClick(evt);
352
+ clickCountRef.current = 0;
353
+ if (timerRef.current) {
354
+ clearTimeout(timerRef.current);
355
+ timerRef.current = undefined;
356
+ }
357
+ }
358
+ }, [row, table, canSelection, selectionWithoutChecked, setRowHighLightId, setRowSelectedId, selectedRowChange, onSelectChange, selectRowWhenClick, editting, onRowMouseClick, onRowMouseDoubleClick, canEditRowWhenDClick, handleEditRowWhenDClick]);
359
+ var handleSingleClick = useCallback(function (evt) {
360
+ onRowMouseClick === null || onRowMouseClick === void 0 || onRowMouseClick(row);
361
+ if (!row.getCanSelect()) {
362
+ return;
363
+ }
364
+ if (canSelection && !selectRowWhenClick) {
365
+ setRowHighLightId === null || setRowHighLightId === void 0 || setRowHighLightId(row.id);
366
+ return;
367
+ }
368
+ if (canSelection) {
369
+ handleSelectionClick(evt);
370
+ } else {
371
+ handleSingleSelection(evt);
372
+ }
373
+ }, [row, canSelection, selectRowWhenClick, setRowHighLightId]);
374
+ var handleDoubleClick = useCallback(function (evt) {
375
+ onRowMouseDoubleClick === null || onRowMouseDoubleClick === void 0 || onRowMouseDoubleClick(row);
376
+ if (canEditRowWhenDClick) {
377
+ handleEditRowWhenDClick(row);
378
+ }
379
+ }, [row, onRowMouseDoubleClick, canEditRowWhenDClick, handleEditRowWhenDClick]);
380
+
381
+ // 其他事件处理函数保持不变...
382
+ var handleSelectionClick = useCallback(function (evt) {
383
+ // ... 选择逻辑保持不变
384
+ }, [row, table, selectionWithoutChecked]);
385
+ var handleSingleSelection = useCallback(function (evt) {
386
+ setRowSelectedId === null || setRowSelectedId === void 0 || setRowSelectedId(row === null || row === void 0 ? void 0 : row.id);
387
+ selectedRowChange === null || selectedRowChange === void 0 || selectedRowChange(row);
388
+ onSelectChange === null || onSelectChange === void 0 || onSelectChange(row, row === null || row === void 0 ? void 0 : row.original, true, evt);
389
+ }, [row, setRowSelectedId, selectedRowChange, onSelectChange]);
390
+ var rowMouseEnter = useCallback(function () {
391
+ onRowMouseEnter === null || onRowMouseEnter === void 0 || onRowMouseEnter(row);
392
+ }, [row, onRowMouseEnter]);
393
+ var rowMouseLeave = useCallback(function () {
394
+ onRowMouseLeave === null || onRowMouseLeave === void 0 || onRowMouseLeave(row);
395
+ }, [row, onRowMouseLeave]);
396
+ var _useState = useState({
397
+ title: ' ',
398
+ color: ''
399
+ }),
400
+ _useState2 = _slicedToArray(_useState, 2),
401
+ tooltipConfig = _useState2[0],
402
+ setTooltipConfig = _useState2[1];
403
+ var onOpenChange = useCallback(function (open) {
404
+ if (open) {
405
+ setTooltipConfig((getRowHoverTipConfig === null || getRowHoverTipConfig === void 0 ? void 0 : getRowHoverTipConfig(row.original)) || {
406
+ title: ' ',
407
+ color: ''
408
+ });
409
+ }
410
+ }, [getRowHoverTipConfig, row.original]);
411
+
412
+ // 清理定时器
413
+ useEffect(function () {
414
+ return function () {
415
+ if (timerRef.current) {
416
+ clearTimeout(timerRef.current);
417
+ }
418
+ };
419
+ }, []);
420
+
421
+ // 渲染行的主要内容
422
+ var renderRowContent = useCallback(function () {
423
+ return /*#__PURE__*/_jsxs("tr", {
424
+ id: rowEditing ? "".concat(tableId, "-tbody-tr-editing") : undefined,
425
+ ref: function ref(node) {
426
+ dropRef(node && !editting ? node : null);
427
+ dragRef(node && canRowDrag && !editting && !(disableDragRowIds !== null && disableDragRowIds !== void 0 && disableDragRowIds.includes(row.id)) ? node : null);
428
+ },
429
+ style: rowStyles,
430
+ onClick: handleRowClick,
431
+ onMouseEnter: rowMouseEnter,
432
+ onMouseLeave: rowMouseLeave,
433
+ className: rowClassNames,
434
+ children: [renderLeftPinnedCells(), renderVirtualScrollCells(), renderRightPinnedCells()]
435
+ });
436
+ }, [rowEditing, tableId, editting, canRowDrag, disableDragRowIds, row.id, rowStyles, handleRowClick, rowMouseEnter, rowMouseLeave, rowClassNames, renderLeftPinnedCells, renderVirtualScrollCells, renderRightPinnedCells, virtualRowStart]);
437
+ return /*#__PURE__*/_jsxs(_Fragment, {
438
+ children: [!!getRowHoverTipConfig ? /*#__PURE__*/_jsx(Tooltip, _objectSpread(_objectSpread({}, tooltipConfig), {}, {
439
+ onOpenChange: onOpenChange,
440
+ destroyTooltipOnHide: {
441
+ keepParent: false
442
+ },
443
+ overlayClassName: "table-max-row-tooltip-wrapper",
444
+ getPopupContainer: function getPopupContainer() {
445
+ return tableBodyRef.current || document.body;
446
+ },
447
+ children: renderRowContent()
448
+ })) : renderRowContent(), row.getIsExpanded() && /*#__PURE__*/_jsx("tr", {
449
+ className: "tbody-tr-subrow",
450
+ children: /*#__PURE__*/_jsx("td", {
451
+ colSpan: visibleCells.length,
452
+ style: {
453
+ padding: 0
454
+ },
455
+ children: !!(tableBodyRef !== null && tableBodyRef !== void 0 && (_tableBodyRef$current = tableBodyRef.current) !== null && _tableBodyRef$current !== void 0 && _tableBodyRef$current.clientWidth) && /*#__PURE__*/_jsx("div", {
456
+ id: "".concat(tableId, "_expand-table"),
457
+ className: "subRowWrapper",
458
+ style: {
459
+ width: "".concat(tableBodyRef === null || tableBodyRef === void 0 || (_tableBodyRef$current2 = tableBodyRef.current) === null || _tableBodyRef$current2 === void 0 ? void 0 : _tableBodyRef$current2.clientWidth, "px")
460
+ },
461
+ children: renderSubComponent && renderSubComponent({
462
+ row: row
463
+ })
464
+ })
465
+ })
466
+ })]
467
+ });
468
+ };
469
+ function formatDate(dateValue) {
470
+ var pattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "YYYY-MM-DD HH:mm";
471
+ if (!dateValue) return '';
472
+ var date = dayjs(dateValue);
473
+ return date.isValid() ? date.format(pattern) : 'Invalid Date';
474
+ }
475
+ function isDateColumn(column) {
476
+ var _column$meta;
477
+ return (column === null || column === void 0 || (_column$meta = column.meta) === null || _column$meta === void 0 ? void 0 : _column$meta.isDate) || false;
478
+ }
479
+ export { VirtualRow };
@@ -0,0 +1,75 @@
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
+ getContextMenu?: (params: {
52
+ row: any;
53
+ column: any;
54
+ }) => IMenuOptionsType;
55
+ onClickContextMenu?: (params: {
56
+ row: any;
57
+ column: any;
58
+ clickedMenuValue: any;
59
+ }) => void;
60
+ getRowHoverTipConfig?: (row: any) => {
61
+ title: string;
62
+ color: string;
63
+ };
64
+ tableTooltip: boolean;
65
+ compactMode: boolean;
66
+ onEditValueChange?: (field: string, value: any, extra?: any) => void;
67
+ hasTotalRow?: boolean;
68
+ totalDatas?: any[];
69
+ setRowSelection: Function;
70
+ openMemo?: boolean;
71
+ openVirtualColumns?: boolean;
72
+ openVirtualRows?: boolean;
73
+ };
74
+ declare const VirtualTableBody: ({ tableBodyRef, tableContentRef, 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, openVirtualColumns, }: TableBodyPropsType) => import("react/jsx-runtime").JSX.Element;
75
+ export { VirtualTableBody };