@arim-aisdc/public-components 2.3.49 → 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 (60) hide show
  1. package/dist/components/TableMax/TableBody/{Row.d.ts → OriginalRow.d.ts} +2 -2
  2. package/dist/components/TableMax/TableBody/{Row.js → OriginalRow.js} +2 -2
  3. package/dist/components/TableMax/TableBody/OriginalTableBody.d.ts +76 -0
  4. package/dist/components/TableMax/TableBody/OriginalTableBody.js +509 -0
  5. package/dist/components/TableMax/TableBody/TableBody.d.ts +3 -0
  6. package/dist/components/TableMax/TableBody/TableBody.js +15 -0
  7. package/dist/components/TableMax/TableBody/VirtualRow.d.ts +63 -0
  8. package/dist/components/TableMax/TableBody/VirtualRow.js +479 -0
  9. package/dist/components/TableMax/TableBody/VirtualTableBody.d.ts +75 -0
  10. package/dist/components/TableMax/TableBody/VirtualTableBody.js +423 -0
  11. package/dist/components/TableMax/TableBody/components/Total.js +86 -27
  12. package/dist/components/TableMax/TableBody/index.d.ts +3 -75
  13. package/dist/components/TableMax/TableBody/index.js +4 -519
  14. package/dist/components/TableMax/TableBody/index.less +14 -2
  15. package/dist/components/TableMax/TableHeader/OriginalTableHeader.d.ts +21 -0
  16. package/dist/components/TableMax/TableHeader/OriginalTableHeader.js +86 -0
  17. package/dist/components/TableMax/TableHeader/TableHeader.d.ts +2 -0
  18. package/dist/components/TableMax/TableHeader/TableHeader.js +14 -0
  19. package/dist/components/TableMax/TableHeader/VirtualTableHeader/ColGroup.d.ts +11 -0
  20. package/dist/components/TableMax/TableHeader/VirtualTableHeader/ColGroup.js +33 -0
  21. package/dist/components/TableMax/TableHeader/VirtualTableHeader/PinnedColumns.d.ts +19 -0
  22. package/dist/components/TableMax/TableHeader/VirtualTableHeader/PinnedColumns.js +46 -0
  23. package/dist/components/TableMax/TableHeader/VirtualTableHeader/ScrollColumns.d.ts +18 -0
  24. package/dist/components/TableMax/TableHeader/VirtualTableHeader/ScrollColumns.js +47 -0
  25. package/dist/components/TableMax/TableHeader/VirtualTableHeader/VirtualColumns.d.ts +19 -0
  26. package/dist/components/TableMax/TableHeader/VirtualTableHeader/VirtualColumns.js +49 -0
  27. package/dist/components/TableMax/TableHeader/VirtualTableHeader/VirtualPadding.d.ts +7 -0
  28. package/dist/components/TableMax/TableHeader/VirtualTableHeader/VirtualPadding.js +16 -0
  29. package/dist/components/TableMax/TableHeader/VirtualTableHeader/index.d.ts +4 -0
  30. package/dist/components/TableMax/TableHeader/VirtualTableHeader/index.js +79 -0
  31. package/dist/components/TableMax/TableHeader/VirtualTableHeader/index.less +225 -0
  32. package/dist/components/TableMax/TableHeader/index.d.ts +3 -20
  33. package/dist/components/TableMax/TableHeader/index.js +3 -90
  34. package/dist/components/TableMax/TableHeader/utils.d.ts +1 -0
  35. package/dist/components/TableMax/TableHeader/utils.js +17 -10
  36. package/dist/components/TableMax/TableMax.js +140 -108
  37. package/dist/components/TableMax/components/ColumnEdit/index.d.ts +1 -0
  38. package/dist/components/TableMax/components/ColumnEdit/index.js +5 -1
  39. package/dist/components/TableMax/contexts/VirtualScroll/VirtualScrollContext.d.ts +3 -0
  40. package/dist/components/TableMax/contexts/VirtualScroll/VirtualScrollContext.js +2 -0
  41. package/dist/components/TableMax/contexts/VirtualScroll/VirtualScrollProvider.d.ts +3 -0
  42. package/dist/components/TableMax/contexts/VirtualScroll/VirtualScrollProvider.js +26 -0
  43. package/dist/components/TableMax/contexts/VirtualScroll/index.d.ts +3 -0
  44. package/dist/components/TableMax/contexts/VirtualScroll/index.js +4 -0
  45. package/dist/components/TableMax/contexts/VirtualScroll/types.d.ts +33 -0
  46. package/dist/components/TableMax/contexts/VirtualScroll/types.js +1 -0
  47. package/dist/components/TableMax/contexts/index.d.ts +1 -0
  48. package/dist/components/TableMax/contexts/index.js +1 -0
  49. package/dist/components/TableMax/hooks/useColumnWidth copy.js +15 -6
  50. package/dist/components/TableMax/hooks/useDragDrop.d.ts +27 -0
  51. package/dist/components/TableMax/hooks/useDragDrop.js +167 -0
  52. package/dist/components/TableMax/hooks/useTableComponents.d.ts +6 -0
  53. package/dist/components/TableMax/hooks/useTableComponents.js +19 -0
  54. package/dist/components/TableMax/hooks/useVirtualCalculations.d.ts +25 -0
  55. package/dist/components/TableMax/hooks/useVirtualCalculations.js +113 -0
  56. package/dist/components/TableMax/hooks/useVirtualScroll.d.ts +4 -0
  57. package/dist/components/TableMax/hooks/useVirtualScroll.js +30 -0
  58. package/dist/components/TableMax/tableMax.less +22 -5
  59. package/dist/components/TableMax/type.d.ts +2 -0
  60. package/package.json +2 -1
@@ -1,91 +1,4 @@
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
- // import { Column, flexRender } from '@tanstack/react-table';
8
- // import { useDrag, useDrop } from 'ahooks';
9
-
10
- // import { Filter } from '../components/ColumnFilter';
11
-
12
- import Cell from "./Cell";
13
- import "./index.less";
14
- import { getPinningStyle } from "./utils";
15
- import { useWhyDidYouUpdate } from 'ahooks';
16
- import { jsx as _jsx } from "react/jsx-runtime";
17
- import { jsxs as _jsxs } from "react/jsx-runtime";
18
- var TableHeader = function TableHeader(_ref) {
19
- var _headerGroups;
20
- var tableContentRef = _ref.tableContentRef,
21
- table = _ref.table,
22
- canFilter = _ref.canFilter,
23
- enableFilters = _ref.enableFilters,
24
- canSorting = _ref.canSorting,
25
- hasGroup = _ref.hasGroup,
26
- getHeaderCellProps = _ref.getHeaderCellProps,
27
- columnResizeMode = _ref.columnResizeMode,
28
- disableColumnDrag = _ref.disableColumnDrag,
29
- rowHeight = _ref.rowHeight,
30
- headerRowNum = _ref.headerRowNum,
31
- manualFiltering = _ref.manualFiltering,
32
- getDynamicFilterOptionsFn = _ref.getDynamicFilterOptionsFn;
33
- var headerGroups = table.getHeaderGroups();
34
- var headers = (headerGroups === null || headerGroups === void 0 || (_headerGroups = headerGroups[headerGroups.length - 1]) === null || _headerGroups === void 0 ? void 0 : _headerGroups.headers) || [];
35
- useWhyDidYouUpdate('useWhyDidYouUpdate', {
36
- tableContentRef: tableContentRef,
37
- table: table,
38
- canFilter: canFilter,
39
- enableFilters: enableFilters,
40
- canSorting: canSorting,
41
- hasGroup: hasGroup,
42
- getHeaderCellProps: getHeaderCellProps,
43
- columnResizeMode: columnResizeMode,
44
- disableColumnDrag: disableColumnDrag,
45
- rowHeight: rowHeight,
46
- headerRowNum: headerRowNum,
47
- manualFiltering: manualFiltering
48
- });
49
- return /*#__PURE__*/_jsxs("table", {
50
- children: [/*#__PURE__*/_jsx("colgroup", {
51
- children: headers.map(function (header) {
52
- var _header$column;
53
- var size = (header === null || header === void 0 || (_header$column = header.column) === null || _header$column === void 0 ? void 0 : _header$column.getSize()) || 120;
54
- return /*#__PURE__*/_jsx("col", {
55
- width: size
56
- }, header.id);
57
- })
58
- }), /*#__PURE__*/_jsx("thead", {
59
- children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map(function (headerGroup) {
60
- return /*#__PURE__*/_jsx("tr", {
61
- className: "table-thead-tr cus-table-thead-tr",
62
- style: {
63
- height: hasGroup && headerGroup.depth === 0 ? "".concat(rowHeight, "px") : 'auto',
64
- width: '100%'
65
- },
66
- children: headerGroup.headers.map(function (header) {
67
- return /*#__PURE__*/_jsx("th", {
68
- colSpan: header.colSpan,
69
- style: _objectSpread({}, getPinningStyle(header, table, true)),
70
- children: header.isPlaceholder || header.id === 'placeholder-column' ? null : /*#__PURE__*/_jsx(Cell, {
71
- tableContentRef: tableContentRef,
72
- header: header,
73
- table: table,
74
- hasGroup: hasGroup,
75
- canSorting: canSorting,
76
- getHeaderCellProps: getHeaderCellProps,
77
- columnResizeMode: columnResizeMode,
78
- disableColumnDrag: disableColumnDrag,
79
- headerRowNum: headerRowNum,
80
- canFilter: canFilter,
81
- manualFiltering: manualFiltering,
82
- getDynamicFilterOptionsFn: getDynamicFilterOptionsFn
83
- }, header.id)
84
- }, header.id);
85
- })
86
- }, headerGroup.id);
87
- })
88
- })]
89
- });
90
- };
1
+ import { TableHeader } from "./TableHeader";
2
+ export { VirtualTableHeader } from "./VirtualTableHeader";
3
+ export { OriginalTableHeader } from "./OriginalTableHeader";
91
4
  export default TableHeader;
@@ -1 +1,2 @@
1
1
  export declare const getPinningStyle: any;
2
+ export declare const findHeaderByColumn: (headerGroup: any, column: any) => any;
@@ -2,10 +2,10 @@ var getOffsetLeft = function getOffsetLeft(list, column, visibleColumnSizesMap)
2
2
  var x = 0;
3
3
  for (var i = 0; i < list.length; i++) {
4
4
  var curr = list[i];
5
- if (curr === column.id) {
5
+ if (curr.id === column.id) {
6
6
  return x;
7
7
  }
8
- x += visibleColumnSizesMap[curr] || 0;
8
+ x += visibleColumnSizesMap[curr.id] || 0;
9
9
  }
10
10
  return x;
11
11
  };
@@ -14,10 +14,10 @@ var getOffsetRight = function getOffsetRight(list, column, visibleColumnSizesMap
14
14
  // console.log(list, 'list')
15
15
  for (var i = list.length - 1; i > 0; i--) {
16
16
  var curr = list[i];
17
- if (curr === column.id) {
17
+ if (curr.id === column.id) {
18
18
  return x;
19
19
  }
20
- x += visibleColumnSizesMap[curr] || 120;
20
+ x += visibleColumnSizesMap[curr.id] || 120;
21
21
  }
22
22
  return x;
23
23
  };
@@ -30,7 +30,9 @@ export var getPinningStyle = function getPinningStyle(header, table, isHeader) {
30
30
  size: item.getSize()
31
31
  };
32
32
  });
33
- var columnPinning = table.getState().columnPinning;
33
+ // const columnPinning = table.getState().columnPinning;
34
+ var leftPinnedColumns = table.getLeftVisibleLeafColumns();
35
+ var rightPinnedColumns = table.getRightVisibleLeafColumns();
34
36
  var visibleColumnSizesMap = {};
35
37
  visibleColumnSizes.forEach(function (item) {
36
38
  visibleColumnSizesMap[item === null || item === void 0 ? void 0 : item.id] = item.size;
@@ -39,11 +41,11 @@ export var getPinningStyle = function getPinningStyle(header, table, isHeader) {
39
41
  case 'left':
40
42
  {
41
43
  var offsetLeft = 0;
42
- offsetLeft += getOffsetLeft(columnPinning.left, column, visibleColumnSizesMap);
44
+ offsetLeft += getOffsetLeft(leftPinnedColumns, column, visibleColumnSizesMap);
43
45
  return {
44
46
  position: 'sticky',
45
47
  left: offsetLeft,
46
- zIndex: 100,
48
+ zIndex: 150,
47
49
  transform: 'translateZ(0)',
48
50
  backfaceVisibility: 'hidden' /* 修复渲染抖动 */
49
51
 
@@ -53,12 +55,12 @@ export var getPinningStyle = function getPinningStyle(header, table, isHeader) {
53
55
  case 'right':
54
56
  {
55
57
  var offsetRight = 0;
56
- offsetRight += getOffsetRight(columnPinning.right, column, visibleColumnSizesMap);
58
+ offsetRight += getOffsetRight(rightPinnedColumns, column, visibleColumnSizesMap);
57
59
  // console.log(offsetRight, 'offsetRight')
58
60
  return {
59
61
  position: 'sticky',
60
- right: offsetRight - 0.5,
61
- zIndex: 100,
62
+ right: offsetRight,
63
+ zIndex: 150,
62
64
  backfaceVisibility: 'hidden',
63
65
  /* 修复渲染抖动 */
64
66
  transform: 'translateZ(0)'
@@ -70,4 +72,9 @@ export var getPinningStyle = function getPinningStyle(header, table, isHeader) {
70
72
  // width: column.getSize(),
71
73
  };
72
74
  }
75
+ };
76
+ export var findHeaderByColumn = function findHeaderByColumn(headerGroup, column) {
77
+ return headerGroup.headers.find(function (h) {
78
+ return h.column.id === column.id;
79
+ });
73
80
  };
@@ -40,6 +40,7 @@ import "./tableMax.less";
40
40
  import { downloadExcel, getFormatFilters, getFormatFiltersV2, getFormatSorting, operationColumnNoTooltips } from "./utils";
41
41
  import { useTableScrollShadow } from "./hooks/useTableScrollShadow";
42
42
  import { ExportTableData } from "./components/Export";
43
+ import { VirtualScrollProvider } from "./contexts";
43
44
  import { jsx as _jsx } from "react/jsx-runtime";
44
45
  import { jsxs as _jsxs } from "react/jsx-runtime";
45
46
  export var ColumnType = /*#__PURE__*/function (ColumnType) {
@@ -53,6 +54,7 @@ export var CACHE_MAX_AGE = 1 * 60 * 60 * 1000;
53
54
  var getCurrentRouterName = function getCurrentRouterName() {
54
55
  return window.location.pathname.slice(1);
55
56
  };
57
+ var compactModeRowHeight = 30;
56
58
 
57
59
  /**将空默认值提升为组件外部的常量,避免引发不必要的渲染 */
58
60
  var defaultData = [];
@@ -149,7 +151,7 @@ var TableMax = function TableMax(_ref) {
149
151
  getCellProps = _ref.getCellProps,
150
152
  getHeaderCellProps = _ref.getHeaderCellProps,
151
153
  _ref$rowHeight = _ref.rowHeight,
152
- rowHeight = _ref$rowHeight === void 0 ? 42 : _ref$rowHeight,
154
+ propsRowHeight = _ref$rowHeight === void 0 ? 42 : _ref$rowHeight,
153
155
  _ref$defaultColumnFil = _ref.defaultColumnFilters,
154
156
  defaultColumnFilters = _ref$defaultColumnFil === void 0 ? initColumnFilters : _ref$defaultColumnFil,
155
157
  getColumnFiltersData = _ref.getColumnFiltersData,
@@ -200,7 +202,11 @@ var TableMax = function TableMax(_ref) {
200
202
  pageSizeOptions = _ref.pageSizeOptions,
201
203
  openMemo = _ref.openMemo,
202
204
  getDynamicFilterOptionsFn = _ref.getDynamicFilterOptionsFn,
203
- exportConfig = _ref.exportConfig;
205
+ exportConfig = _ref.exportConfig,
206
+ _ref$openVirtualColum = _ref.openVirtualColumns,
207
+ openVirtualColumns = _ref$openVirtualColum === void 0 ? false : _ref$openVirtualColum,
208
+ _ref$openVirtualRows = _ref.openVirtualRows,
209
+ openVirtualRows = _ref$openVirtualRows === void 0 ? true : _ref$openVirtualRows;
204
210
  var tableMaxRef = useRef(null);
205
211
  // 表格元素
206
212
  var tableContentRef = useRef(null);
@@ -243,60 +249,64 @@ var TableMax = function TableMax(_ref) {
243
249
  /**表格配置信息缓存 */
244
250
  var currentUserId = userId || ((_JSON$parse = JSON.parse(localStorage.getItem('poi-permission') || '{}')) === null || _JSON$parse === void 0 || (_JSON$parse = _JSON$parse.currentUser) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.id);
245
251
  var tableKey = "".concat(tableKeyPrefixCls, "-").concat(getCurrentRouterName(), "-").concat(tableId, "-").concat(currentUserId);
252
+ var _useState = useState(propsRowHeight),
253
+ _useState2 = _slicedToArray(_useState, 2),
254
+ rowHeight = _useState2[0],
255
+ setRowHeight = _useState2[1];
246
256
 
247
257
  /**表格数据 */
248
258
  var initColumnOrder = columns === null || columns === void 0 ? void 0 : columns.map(function (column) {
249
259
  return column.id;
250
260
  });
251
- var _useState = useState(function () {
261
+ var _useState3 = useState(function () {
252
262
  return datas;
253
263
  }),
254
- _useState2 = _slicedToArray(_useState, 2),
255
- tableDatas = _useState2[0],
256
- setTableDatas = _useState2[1];
257
- // 下载按钮的loading
258
- var _useState3 = useState(false),
259
264
  _useState4 = _slicedToArray(_useState3, 2),
260
- downLoading = _useState4[0],
261
- setDownLoading = _useState4[1];
262
- /**表格列 */
263
- var _useState5 = useState(columns),
265
+ tableDatas = _useState4[0],
266
+ setTableDatas = _useState4[1];
267
+ // 下载按钮的loading
268
+ var _useState5 = useState(false),
264
269
  _useState6 = _slicedToArray(_useState5, 2),
265
- tableColumns = _useState6[0],
266
- setTableColumns = _useState6[1];
267
- /**列显隐 */
268
- var _useState7 = useState(),
270
+ downLoading = _useState6[0],
271
+ setDownLoading = _useState6[1];
272
+ /**表格列 */
273
+ var _useState7 = useState(columns),
269
274
  _useState8 = _slicedToArray(_useState7, 2),
270
- columnVisibility = _useState8[0],
271
- setColumnVisibility = _useState8[1];
272
- /**列拖动顺序 */
275
+ tableColumns = _useState8[0],
276
+ setTableColumns = _useState8[1];
277
+ /**列显隐 */
273
278
  var _useState9 = useState(),
274
279
  _useState10 = _slicedToArray(_useState9, 2),
275
- columnOrder = _useState10[0],
276
- setColumnOrder = _useState10[1];
277
- /**列排序 */
278
- var _useState11 = useState([]),
280
+ columnVisibility = _useState10[0],
281
+ setColumnVisibility = _useState10[1];
282
+ /**列拖动顺序 */
283
+ var _useState11 = useState(),
279
284
  _useState12 = _slicedToArray(_useState11, 2),
280
- sorting = _useState12[0],
281
- setSorting = _useState12[1];
282
- /**行选中 */
283
- var _useState13 = useState(defaultSelectedRowId),
285
+ columnOrder = _useState12[0],
286
+ setColumnOrder = _useState12[1];
287
+ /**列排序 */
288
+ var _useState13 = useState([]),
284
289
  _useState14 = _slicedToArray(_useState13, 2),
285
- rowSelectedId = _useState14[0],
286
- setRowSelectedId = _useState14[1];
290
+ sorting = _useState14[0],
291
+ setSorting = _useState14[1];
292
+ /**行选中 */
293
+ var _useState15 = useState(defaultSelectedRowId),
294
+ _useState16 = _slicedToArray(_useState15, 2),
295
+ rowSelectedId = _useState16[0],
296
+ setRowSelectedId = _useState16[1];
287
297
  /**行勾选 */
288
- var _useState15 = useState(defaultSelectedRowIds.reduce(function (accumulator, currentValue) {
298
+ var _useState17 = useState(defaultSelectedRowIds.reduce(function (accumulator, currentValue) {
289
299
  accumulator[currentValue] = true;
290
300
  return accumulator;
291
301
  }, {})),
292
- _useState16 = _slicedToArray(_useState15, 2),
293
- rowSelection = _useState16[0],
294
- setRowSelection = _useState16[1];
295
- // 高亮行的id:多选场景并且点击行不勾选时,高亮点击的行
296
- var _useState17 = useState(defaultHighLightRowId),
297
302
  _useState18 = _slicedToArray(_useState17, 2),
298
- rowHighLightId = _useState18[0],
299
- setRowHighLightId = _useState18[1];
303
+ rowSelection = _useState18[0],
304
+ setRowSelection = _useState18[1];
305
+ // 高亮行的id:多选场景并且点击行不勾选时,高亮点击的行
306
+ var _useState19 = useState(defaultHighLightRowId),
307
+ _useState20 = _slicedToArray(_useState19, 2),
308
+ rowHighLightId = _useState20[0],
309
+ setRowHighLightId = _useState20[1];
300
310
  useEffect(function () {
301
311
  setRowHighLightId(defaultHighLightRowId);
302
312
  }, [defaultHighLightRowId]);
@@ -314,10 +324,10 @@ var TableMax = function TableMax(_ref) {
314
324
  right: columnPinningConfig.right || []
315
325
  };
316
326
  }, [JSON.stringify(columnPinningConfig)]);
317
- var _useState19 = useState(initColumnPinning),
318
- _useState20 = _slicedToArray(_useState19, 2),
319
- columnPinning = _useState20[0],
320
- setColumnPinning = _useState20[1];
327
+ var _useState21 = useState(initColumnPinning),
328
+ _useState22 = _slicedToArray(_useState21, 2),
329
+ columnPinning = _useState22[0],
330
+ setColumnPinning = _useState22[1];
321
331
  var _useColumnWidth = useColumnWidth({
322
332
  tableContentRef: tableContentRef,
323
333
  tableId: tableId,
@@ -333,14 +343,14 @@ var TableMax = function TableMax(_ref) {
333
343
  handleVisibleConfigChange = _useColumnWidth.handleVisibleConfigChange;
334
344
 
335
345
  /**列筛选 */
336
- var _useState21 = useState(defaultColumnFilters),
337
- _useState22 = _slicedToArray(_useState21, 2),
338
- columnFilters = _useState22[0],
339
- setColumnFilters = _useState22[1];
340
- var _useState23 = useState(''),
346
+ var _useState23 = useState(defaultColumnFilters),
341
347
  _useState24 = _slicedToArray(_useState23, 2),
342
- globalFilter = _useState24[0],
343
- setGlobalFilter = _useState24[1];
348
+ columnFilters = _useState24[0],
349
+ setColumnFilters = _useState24[1];
350
+ var _useState25 = useState(''),
351
+ _useState26 = _slicedToArray(_useState25, 2),
352
+ globalFilter = _useState26[0],
353
+ setGlobalFilter = _useState26[1];
344
354
  /**分页 */
345
355
  var pagination = useMemo(function () {
346
356
  return typeof skipCount === 'number' && pageSize ? {
@@ -349,37 +359,37 @@ var TableMax = function TableMax(_ref) {
349
359
  } : undefined;
350
360
  }, [skipCount, pageSize]);
351
361
  /**是否有分组 */
352
- var _useState25 = useState(false),
353
- _useState26 = _slicedToArray(_useState25, 2),
354
- hasGroup = _useState26[0],
355
- setHasGroup = _useState26[1];
356
-
357
- /**是否正在多行拖拽 */
358
362
  var _useState27 = useState(false),
359
363
  _useState28 = _slicedToArray(_useState27, 2),
360
- selectedRowDragging = _useState28[0],
361
- setSelectedRowDragging = _useState28[1];
364
+ hasGroup = _useState28[0],
365
+ setHasGroup = _useState28[1];
362
366
 
363
- /**显示筛选开关状态 */
364
- var _useState29 = useState(defaultEnableFilters),
367
+ /**是否正在多行拖拽 */
368
+ var _useState29 = useState(false),
365
369
  _useState30 = _slicedToArray(_useState29, 2),
366
- enableFilters = _useState30[0],
367
- setEnableFilters = _useState30[1];
370
+ selectedRowDragging = _useState30[0],
371
+ setSelectedRowDragging = _useState30[1];
368
372
 
369
- /**表头最多显示几行文字 */
370
- var _useState31 = useState(defaultHeaderRowNum),
373
+ /**显示筛选开关状态 */
374
+ var _useState31 = useState(defaultEnableFilters),
371
375
  _useState32 = _slicedToArray(_useState31, 2),
372
- headerRowNum = _useState32[0],
373
- setheaderRowNum = _useState32[1];
376
+ enableFilters = _useState32[0],
377
+ setEnableFilters = _useState32[1];
378
+
379
+ /**表头最多显示几行文字 */
380
+ var _useState33 = useState(defaultHeaderRowNum),
381
+ _useState34 = _slicedToArray(_useState33, 2),
382
+ headerRowNum = _useState34[0],
383
+ setheaderRowNum = _useState34[1];
374
384
  var _Form$useForm = Form.useForm(),
375
385
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
376
386
  form = _Form$useForm2[0];
377
387
 
378
388
  /**正在编辑的行id*/
379
- var _useState33 = useState(''),
380
- _useState34 = _slicedToArray(_useState33, 2),
381
- editingRowId = _useState34[0],
382
- setEditingRowId = _useState34[1];
389
+ var _useState35 = useState(''),
390
+ _useState36 = _slicedToArray(_useState35, 2),
391
+ editingRowId = _useState36[0],
392
+ setEditingRowId = _useState36[1];
383
393
  var _React$useState = React.useState({}),
384
394
  _React$useState2 = _slicedToArray(_React$useState, 2),
385
395
  expanded = _React$useState2[0],
@@ -387,10 +397,10 @@ var TableMax = function TableMax(_ref) {
387
397
 
388
398
  // 固定列是否显示阴影
389
399
  var scrollRafId = useRef(null);
390
- var _useState35 = useState(defaultCompactMode),
391
- _useState36 = _slicedToArray(_useState35, 2),
392
- compactMode = _useState36[0],
393
- setCompactMode = _useState36[1];
400
+ var _useState37 = useState(defaultCompactMode),
401
+ _useState38 = _slicedToArray(_useState37, 2),
402
+ compactMode = _useState38[0],
403
+ setCompactMode = _useState38[1];
394
404
  var onColumnVisibilityChange = function onColumnVisibilityChange(data) {
395
405
  if (typeof data === 'function') {
396
406
  var _Object$values, _Object$keys;
@@ -718,7 +728,7 @@ var TableMax = function TableMax(_ref) {
718
728
 
719
729
  var _rowSelectionChange = useCallback(debounce(function (rowOriginal, row) {
720
730
  if (rowSelectionChange) {
721
- console.log(rowOriginal, row, 'rowSelectionChange1');
731
+ // console.log(rowOriginal, row, 'rowSelectionChange1')
722
732
  rowSelectionChange(rowOriginal, row);
723
733
  }
724
734
  }, 100), [rowSelectionChange]);
@@ -1044,7 +1054,8 @@ var TableMax = function TableMax(_ref) {
1044
1054
  disableColumnDrag: disableColumnDrag,
1045
1055
  compactMode: compactMode,
1046
1056
  manualFiltering: manualFiltering,
1047
- getDynamicFilterOptionsFn: getDynamicFilterOptionsFn
1057
+ getDynamicFilterOptionsFn: getDynamicFilterOptionsFn,
1058
+ tableHeaderRef: tableHeaderRef
1048
1059
  };
1049
1060
  var tableBodyProps = {
1050
1061
  tableContentRef: tableContentRef,
@@ -1104,6 +1115,21 @@ var TableMax = function TableMax(_ref) {
1104
1115
  var changeCompactMode = function changeCompactMode() {
1105
1116
  setCompactMode(!compactMode);
1106
1117
  };
1118
+ useUpdateEffect(function () {
1119
+ setRowHeight(compactMode ? compactModeRowHeight : propsRowHeight);
1120
+ }, [propsRowHeight, compactMode]);
1121
+ var virtualConfig = useMemo(function () {
1122
+ return {
1123
+ openVirtualColumns: openVirtualColumns,
1124
+ openVirtualRows: openVirtualRows,
1125
+ rowHeight: rowHeight,
1126
+ columnOverscan: 3,
1127
+ rowOverscan: 10
1128
+ };
1129
+ }, [openVirtualColumns, openVirtualRows, rowHeight]);
1130
+
1131
+ // const components = useTableComponents();
1132
+
1107
1133
  return /*#__PURE__*/_jsx(Form, {
1108
1134
  form: form,
1109
1135
  component: false,
@@ -1268,42 +1294,48 @@ var TableMax = function TableMax(_ref) {
1268
1294
  setColumnVisibility: setColumnVisibility
1269
1295
  })]
1270
1296
  })]
1271
- }), /*#__PURE__*/_jsx("div", {
1272
- className: "table-max-content cus-table-max-content ".concat(compactMode ? 'table-max-content-compact' : null),
1273
- children: /*#__PURE__*/_jsxs("div", {
1274
- className: "table-center",
1275
- ref: tableContentRef
1276
- // style={{ maxHeight: !autoHeight ? defaultScrollY : 'fit-content' }}
1277
- ,
1278
- children: [/*#__PURE__*/_jsxs("div", {
1279
- className: "table-header-wrapper",
1280
- children: [/*#__PURE__*/_jsx("div", {
1281
- ref: tableHeaderRef,
1282
- className: "table-header",
1283
- children: /*#__PURE__*/_jsx(TableHeader, _objectSpread({}, tableHeaderProps))
1297
+ }), /*#__PURE__*/_jsx(VirtualScrollProvider, {
1298
+ config: virtualConfig,
1299
+ table: table,
1300
+ tableHeaderRef: tableHeaderRef,
1301
+ tableBodyRef: tableBodyRef,
1302
+ children: /*#__PURE__*/_jsx("div", {
1303
+ className: "table-max-content cus-table-max-content ".concat(compactMode ? 'table-max-content-compact' : null),
1304
+ children: /*#__PURE__*/_jsxs("div", {
1305
+ className: "table-center",
1306
+ ref: tableContentRef
1307
+ // style={{ maxHeight: !autoHeight ? defaultScrollY : 'fit-content' }}
1308
+ ,
1309
+ children: [/*#__PURE__*/_jsxs("div", {
1310
+ className: "table-header-wrapper",
1311
+ children: [/*#__PURE__*/_jsx("div", {
1312
+ ref: tableHeaderRef,
1313
+ className: "table-header",
1314
+ children: /*#__PURE__*/_jsx(TableHeader, _objectSpread({}, tableHeaderProps))
1315
+ }), /*#__PURE__*/_jsx("div", {
1316
+ className: "table-header-scroll"
1317
+ })]
1284
1318
  }), /*#__PURE__*/_jsx("div", {
1285
- className: "table-header-scroll"
1319
+ ref: tableBodyRef,
1320
+ className: "table-body"
1321
+ // onScroll={scrollHandler}
1322
+ ,
1323
+ style: {
1324
+ width: "100%"
1325
+ },
1326
+ onMouseEnter: function onMouseEnter() {
1327
+ var _tableBodyRef$current;
1328
+ // 给当前元素添加hover类
1329
+ (_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 || _tableBodyRef$current.classList.add('hover-active');
1330
+ },
1331
+ onMouseLeave: function onMouseLeave() {
1332
+ var _tableBodyRef$current2;
1333
+ // 移除当前元素的hover类
1334
+ (_tableBodyRef$current2 = tableBodyRef.current) === null || _tableBodyRef$current2 === void 0 || _tableBodyRef$current2.classList.remove('hover-active');
1335
+ },
1336
+ children: /*#__PURE__*/_jsx(TableBody, _objectSpread({}, tableBodyProps))
1286
1337
  })]
1287
- }), /*#__PURE__*/_jsx("div", {
1288
- ref: tableBodyRef,
1289
- className: "table-body"
1290
- // onScroll={scrollHandler}
1291
- ,
1292
- style: {
1293
- width: "100%"
1294
- },
1295
- onMouseEnter: function onMouseEnter() {
1296
- var _tableBodyRef$current;
1297
- // 给当前元素添加hover类
1298
- (_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 || _tableBodyRef$current.classList.add('hover-active');
1299
- },
1300
- onMouseLeave: function onMouseLeave() {
1301
- var _tableBodyRef$current2;
1302
- // 移除当前元素的hover类
1303
- (_tableBodyRef$current2 = tableBodyRef.current) === null || _tableBodyRef$current2 === void 0 || _tableBodyRef$current2.classList.remove('hover-active');
1304
- },
1305
- children: /*#__PURE__*/_jsx(TableBody, _objectSpread({}, tableBodyProps))
1306
- })]
1338
+ })
1307
1339
  })
1308
1340
  }), pagination && /*#__PURE__*/_jsx("div", {
1309
1341
  className: "table-max-footer",
@@ -29,6 +29,7 @@ interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
29
29
  getEditOptionsFn: IGetOptionType;
30
30
  editComDisabled?: boolean;
31
31
  onEditValueChange?: (field: string, value: any, extra?: any) => void;
32
+ width?: number;
32
33
  }
33
34
  export declare const EditableCell: React.FC<EditableCellProps>;
34
35
  export {};
@@ -31,7 +31,8 @@ export var EditableCell = function EditableCell(_ref) {
31
31
  getEditOptionsFn = _ref.getEditOptionsFn,
32
32
  _ref$editComDisabled = _ref.editComDisabled,
33
33
  editComDisabled = _ref$editComDisabled === void 0 ? false : _ref$editComDisabled,
34
- onEditValueChange = _ref.onEditValueChange;
34
+ onEditValueChange = _ref.onEditValueChange,
35
+ width = _ref.width;
35
36
  var getEditComponent = function getEditComponent(dataIndex) {
36
37
  switch (editComType) {
37
38
  case InputType.InputNumber:
@@ -92,6 +93,9 @@ export var EditableCell = function EditableCell(_ref) {
92
93
  };
93
94
  return /*#__PURE__*/_jsx("div", {
94
95
  className: "table-max-cell-wrapper",
96
+ style: {
97
+ width: "".concat(width, "px")
98
+ },
95
99
  children: editing ? /*#__PURE__*/_jsx(Form.Item, {
96
100
  name: dataIndex,
97
101
  style: {
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { VirtualScrollContextType } from './types';
3
+ export declare const VirtualScrollContext: React.Context<VirtualScrollContextType>;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export var VirtualScrollContext = /*#__PURE__*/React.createContext(undefined);
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { VirtualScrollProviderProps } from './types';
3
+ export declare const VirtualScrollProvider: React.FC<VirtualScrollProviderProps>;
@@ -0,0 +1,26 @@
1
+ // contexts/VirtualScrollProvider.tsx
2
+ import React from 'react';
3
+ import { VirtualScrollContext } from "./VirtualScrollContext";
4
+ import { useVirtualCalculations } from "../../hooks/useVirtualCalculations";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export var VirtualScrollProvider = function VirtualScrollProvider(_ref) {
7
+ var children = _ref.children,
8
+ table = _ref.table,
9
+ config = _ref.config,
10
+ tableHeaderRef = _ref.tableHeaderRef,
11
+ tableBodyRef = _ref.tableBodyRef;
12
+ var _useVirtualCalculatio = useVirtualCalculations(table, config, tableHeaderRef, tableBodyRef),
13
+ state = _useVirtualCalculatio.state,
14
+ isVirtualEnabled = _useVirtualCalculatio.isVirtualEnabled;
15
+ var contextValue = React.useMemo(function () {
16
+ return {
17
+ config: config,
18
+ state: state,
19
+ isVirtualEnabled: isVirtualEnabled
20
+ };
21
+ }, [config, state, isVirtualEnabled]);
22
+ return /*#__PURE__*/_jsx(VirtualScrollContext.Provider, {
23
+ value: contextValue,
24
+ children: children
25
+ });
26
+ };
@@ -0,0 +1,3 @@
1
+ export * from './VirtualScrollContext';
2
+ export * from './VirtualScrollProvider';
3
+ export * from './types';
@@ -0,0 +1,4 @@
1
+ export * from "./VirtualScrollContext";
2
+ export * from "./VirtualScrollProvider";
3
+ export * from "./types";
4
+ ;
@@ -0,0 +1,33 @@
1
+ /// <reference types="react" />
2
+ import { Table } from '@tanstack/react-table';
3
+ import { Virtualizer } from '@tanstack/react-virtual';
4
+ export interface VirtualScrollConfig {
5
+ openVirtualColumns?: boolean;
6
+ openVirtualRows?: boolean;
7
+ rowHeight?: number;
8
+ columnOverscan?: number;
9
+ rowOverscan?: number;
10
+ }
11
+ export interface VirtualScrollState {
12
+ columnVirtualizer: Virtualizer<HTMLDivElement, Element> | null;
13
+ virtualColumns: any[];
14
+ virtualPaddingLeft: number;
15
+ virtualPaddingRight: number;
16
+ rowVirtualizer: Virtualizer<HTMLDivElement, Element> | null;
17
+ virtualRows: any[];
18
+ leftPinnedColumns: any[];
19
+ rightPinnedColumns: any[];
20
+ scrollableColumns: any[];
21
+ }
22
+ export interface VirtualScrollContextType {
23
+ config: VirtualScrollConfig;
24
+ state: VirtualScrollState;
25
+ isVirtualEnabled: boolean;
26
+ }
27
+ export interface VirtualScrollProviderProps {
28
+ children: React.ReactNode;
29
+ table: Table<any>;
30
+ config: VirtualScrollConfig;
31
+ tableHeaderRef: React.RefObject<HTMLDivElement>;
32
+ tableBodyRef: React.RefObject<HTMLDivElement>;
33
+ }