@arim-aisdc/public-components 2.3.57 → 2.3.59
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.
- package/dist/components/TableMax/TableBody/VirtualRow.js +2 -2
- package/dist/components/TableMax/TableBody/VirtualTableBody.d.ts +2 -2
- package/dist/components/TableMax/TableBody/VirtualTableBody.js +41 -46
- package/dist/components/TableMax/TableBody/components/Total.js +2 -4
- package/dist/components/TableMax/TableBody/index.less +27 -10
- package/dist/components/TableMax/TableHeader/OriginalTableHeader.js +13 -13
- package/dist/components/TableMax/TableHeader/index.less +15 -0
- package/dist/components/TableMax/TableMax.js +15 -50
- package/dist/components/TableMax/UnifiedTable.d.ts +13 -0
- package/dist/components/TableMax/UnifiedTable.js +36 -0
- package/dist/components/TableMax/components/CustomDragerLayer/index.less +2 -2
- package/dist/components/TableMax/hooks/useColumnWidth.js +9 -4
- package/dist/components/TableMax/hooks/useTableScrollShadow.js +11 -10
- package/dist/components/TableMax/hooks/useVirtualCalculations.js +3 -1
- package/dist/components/TableMax/tableMax.less +3 -2
- package/dist/components/TableMaxV2.rar +0 -0
- package/package.json +1 -1
|
@@ -225,7 +225,7 @@ var VirtualRow = function VirtualRow(_ref) {
|
|
|
225
225
|
timerRef.current = undefined;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
}, [row, table, canSelection, selectionWithoutChecked, setRowHighLightId, setRowSelectedId, selectedRowChange, onSelectChange, selectRowWhenClick, editting, onRowMouseClick, onRowMouseDoubleClick, canEditRowWhenDClick, handleEditRowWhenDClick]);
|
|
228
|
+
}, [row, table, canSelection, selectionWithoutChecked, setRowHighLightId, setRowSelectedId, selectedRowChange, onSelectChange, selectRowWhenClick, editting, onRowMouseClick, onRowMouseDoubleClick, canEditRowWhenDClick, handleEditRowWhenDClick, table.getState().columnSizing]);
|
|
229
229
|
var handleSingleClick = useCallback(function (evt) {
|
|
230
230
|
onRowMouseClick === null || onRowMouseClick === void 0 || onRowMouseClick(row);
|
|
231
231
|
if (!row.getCanSelect()) {
|
|
@@ -373,7 +373,7 @@ var VirtualRow = function VirtualRow(_ref) {
|
|
|
373
373
|
}
|
|
374
374
|
}, [
|
|
375
375
|
// 依赖项保持不变
|
|
376
|
-
row, row.id, rowEditing, tableId, editting, canRowDrag, disableDragRowIds, isDragging, selectedRowDragging, rowStyle, handleRowClick, rowMouseEnter, rowMouseLeave, rowClassNames, cellClassName, theme, table, handleCellRightClick, getCellProps, tableTooltip, onEditValueChange, dateFormat, row.getVisibleCells(), row.getIsSelected(), rowStyles
|
|
376
|
+
row, row.id, rowEditing, tableId, editting, canRowDrag, disableDragRowIds, isDragging, selectedRowDragging, rowStyle, handleRowClick, rowMouseEnter, rowMouseLeave, rowClassNames, cellClassName, theme, table, handleCellRightClick, getCellProps, tableTooltip, onEditValueChange, dateFormat, row.getVisibleCells(), row.getIsSelected(), rowStyles]);
|
|
377
377
|
var rowCom = function rowCom() {
|
|
378
378
|
var renderCell = function renderCell(cell) {
|
|
379
379
|
var _cellClassName2;
|
|
@@ -16,7 +16,7 @@ type TableBodyPropsType = {
|
|
|
16
16
|
canFilter: boolean;
|
|
17
17
|
canSelection: boolean;
|
|
18
18
|
selectionWithoutChecked?: boolean;
|
|
19
|
-
tableContainerWidth
|
|
19
|
+
tableContainerWidth?: number;
|
|
20
20
|
selectedRowDragging: boolean;
|
|
21
21
|
setSelectedRowDragging: Dispatch<SetStateAction<boolean>>;
|
|
22
22
|
rowHighLightId: string;
|
|
@@ -72,5 +72,5 @@ type TableBodyPropsType = {
|
|
|
72
72
|
openVirtualRows?: boolean;
|
|
73
73
|
tableKey: string;
|
|
74
74
|
};
|
|
75
|
-
declare const VirtualTableBody: ({ tableBodyRef, tableContentRef, table, tableId, theme, reorderRow, rowSelectedId, setRowSelectedId, rowHighLightId, setRowHighLightId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked,
|
|
75
|
+
declare const VirtualTableBody: ({ tableBodyRef, tableContentRef, table, tableId, theme, reorderRow, rowSelectedId, setRowSelectedId, rowHighLightId, setRowHighLightId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked, 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, openVirtualRows, tableKey }: TableBodyPropsType) => import("react/jsx-runtime").JSX.Element;
|
|
76
76
|
export { VirtualTableBody };
|
|
@@ -44,7 +44,6 @@ var VirtualTableBody = function VirtualTableBody(_ref) {
|
|
|
44
44
|
onSelectChange = _ref.onSelectChange,
|
|
45
45
|
canSelection = _ref.canSelection,
|
|
46
46
|
selectionWithoutChecked = _ref.selectionWithoutChecked,
|
|
47
|
-
tableContainerWidth = _ref.tableContainerWidth,
|
|
48
47
|
selectedRowDragging = _ref.selectedRowDragging,
|
|
49
48
|
setSelectedRowDragging = _ref.setSelectedRowDragging,
|
|
50
49
|
canRowDrag = _ref.canRowDrag,
|
|
@@ -92,8 +91,9 @@ var VirtualTableBody = function VirtualTableBody(_ref) {
|
|
|
92
91
|
state = _useVirtualCalculatio.state;
|
|
93
92
|
|
|
94
93
|
// 从 Provider 中获取虚拟化数据
|
|
95
|
-
var rowVirtualizer = state.rowVirtualizer
|
|
96
|
-
|
|
94
|
+
var rowVirtualizer = state.rowVirtualizer;
|
|
95
|
+
var virtualRows = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.getVirtualItems();
|
|
96
|
+
console.log(rowVirtualizer, virtualRows, 'virtualRows');
|
|
97
97
|
var _useState = useState({
|
|
98
98
|
visible: false,
|
|
99
99
|
clientX: 0,
|
|
@@ -349,7 +349,8 @@ var VirtualTableBody = function VirtualTableBody(_ref) {
|
|
|
349
349
|
});
|
|
350
350
|
};
|
|
351
351
|
var tBodyHeight = useMemo(function () {
|
|
352
|
-
if (!openVirtualRows || !
|
|
352
|
+
// if (!openVirtualRows || !rowVirtualizer?.getTotalSize()) return 'auto';
|
|
353
|
+
if (!(rowVirtualizer !== null && rowVirtualizer !== void 0 && rowVirtualizer.getTotalSize())) return 'auto';
|
|
353
354
|
return (rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.getTotalSize()) + (hasTotalRow ? rowHeight : 0);
|
|
354
355
|
}, [openVirtualRows, hasTotalRow, rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.getTotalSize(), rowHeight]);
|
|
355
356
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -363,50 +364,44 @@ var VirtualTableBody = function VirtualTableBody(_ref) {
|
|
|
363
364
|
table: table,
|
|
364
365
|
tableId: tableId,
|
|
365
366
|
compactMode: compactMode
|
|
366
|
-
}), root ? document.querySelector(root) : document.body), showTable ?
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
})
|
|
383
|
-
}), /*#__PURE__*/_jsxs("tbody", {
|
|
384
|
-
id: "table-max-tableBody-tbody-".concat(tableId),
|
|
385
|
-
style: {
|
|
386
|
-
position: openVirtualRows ? 'relative' : 'static',
|
|
387
|
-
height: tBodyHeight,
|
|
388
|
-
paddingBottom: openVirtualRows && hasTotalRow ? "".concat(rowHeight, "px") : 0
|
|
389
|
-
},
|
|
390
|
-
children: [openVirtualRows ? renderVirtualRows() : renderNormalRows(), hasTotalRow && /*#__PURE__*/_jsx(Total, {
|
|
391
|
-
table: table,
|
|
392
|
-
totalDatas: totalDatas
|
|
393
|
-
})]
|
|
394
|
-
})]
|
|
395
|
-
})
|
|
396
|
-
}) : /*#__PURE__*/_jsx("div", {
|
|
397
|
-
className: "empty-container",
|
|
367
|
+
}), root ? document.querySelector(root) : document.body), showTable ?
|
|
368
|
+
/*#__PURE__*/
|
|
369
|
+
// <div
|
|
370
|
+
// className="table-max-table-body-table-wrapper"
|
|
371
|
+
// ref={dropTableEmptyRef}
|
|
372
|
+
// >
|
|
373
|
+
// <table>
|
|
374
|
+
// <colgroup>
|
|
375
|
+
// {headers.map((header: any) => {
|
|
376
|
+
// let size: number = header?.column?.getSize() || 120;
|
|
377
|
+
// return <col key={header.id} width={size}></col>;
|
|
378
|
+
// })}
|
|
379
|
+
// </colgroup>
|
|
380
|
+
_jsxs("tbody", {
|
|
381
|
+
ref: dropTableEmptyRef,
|
|
382
|
+
id: "table-max-tableBody-tbody-".concat(tableId),
|
|
398
383
|
style: {
|
|
399
|
-
|
|
384
|
+
position: openVirtualRows ? 'relative' : 'static',
|
|
385
|
+
height: tBodyHeight,
|
|
386
|
+
paddingBottom: openVirtualRows && hasTotalRow ? "".concat(rowHeight, "px") : 0
|
|
400
387
|
},
|
|
401
|
-
children: /*#__PURE__*/_jsx(
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
388
|
+
children: [openVirtualRows ? renderVirtualRows() : renderNormalRows(), hasTotalRow && /*#__PURE__*/_jsx(Total, {
|
|
389
|
+
table: table,
|
|
390
|
+
totalDatas: totalDatas
|
|
391
|
+
})]
|
|
392
|
+
})
|
|
393
|
+
// // {/* </table> */}
|
|
394
|
+
// </div>
|
|
395
|
+
: /*#__PURE__*/_jsx("tbody", {
|
|
396
|
+
ref: dropEmptyRef,
|
|
397
|
+
children: /*#__PURE__*/_jsx("tr", {
|
|
398
|
+
className: "empty-container",
|
|
399
|
+
children: /*#__PURE__*/_jsx("td", {
|
|
400
|
+
className: "empty-wrapper",
|
|
401
|
+
children: loading ? /*#__PURE__*/_jsx(Spin, {}) : /*#__PURE__*/_jsx("span", {
|
|
402
|
+
className: "empty-content",
|
|
403
|
+
children: /*#__PURE__*/_jsx(Empty, {})
|
|
404
|
+
})
|
|
410
405
|
})
|
|
411
406
|
})
|
|
412
407
|
}), /*#__PURE__*/_jsx(ContextMenu, _objectSpread(_objectSpread({}, contextMenuData), {}, {
|
|
@@ -22,9 +22,7 @@ export var Total = function Total(_ref) {
|
|
|
22
22
|
zIndex: 202
|
|
23
23
|
};
|
|
24
24
|
var cellWrapperStyle = {
|
|
25
|
-
boxSizing: 'border-box'
|
|
26
|
-
borderTop: '1px solid var(--tableColor2)',
|
|
27
|
-
borderBottom: '1px solid var(--tableColor2)'
|
|
25
|
+
boxSizing: 'border-box'
|
|
28
26
|
};
|
|
29
27
|
|
|
30
28
|
// 统一的单元格渲染函数
|
|
@@ -57,7 +55,7 @@ export var Total = function Total(_ref) {
|
|
|
57
55
|
var id = footerGroup.id,
|
|
58
56
|
headers = footerGroup.headers;
|
|
59
57
|
return /*#__PURE__*/_jsx("tr", {
|
|
60
|
-
className: "tbody-tr",
|
|
58
|
+
className: "tbody-tr tbody-tr-total",
|
|
61
59
|
style: rowStyle,
|
|
62
60
|
children: renderNormalColumns(headers)
|
|
63
61
|
}, id);
|
|
@@ -17,17 +17,30 @@ table {
|
|
|
17
17
|
transition-duration: 0.6s;
|
|
18
18
|
background-color: @globalColor0;
|
|
19
19
|
position: relative;
|
|
20
|
-
// border-bottom: 1px solid @tableColor2;
|
|
21
20
|
|
|
22
21
|
&::after {
|
|
23
22
|
content: '';
|
|
23
|
+
display: block;
|
|
24
24
|
position: absolute;
|
|
25
|
+
left: 0;
|
|
25
26
|
bottom: 0;
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 0;
|
|
29
|
+
border-bottom: 1px solid @tableColor2;
|
|
30
|
+
z-index: 999;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.tbody-tr-total {
|
|
35
|
+
&::after {
|
|
36
|
+
content: '';
|
|
37
|
+
position: absolute;
|
|
26
38
|
left: 0;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
top: 0;
|
|
40
|
+
width: 100%;
|
|
41
|
+
height: 0;
|
|
42
|
+
border-bottom: 1px solid @tableColor2;
|
|
43
|
+
z-index: 999;
|
|
31
44
|
}
|
|
32
45
|
}
|
|
33
46
|
.tbody-tr-highlight {
|
|
@@ -52,9 +65,9 @@ table {
|
|
|
52
65
|
.tbody-tr-selected > .tbody-tr-td,
|
|
53
66
|
.tbody-tr-selected > .tbody-tr-td-drag {
|
|
54
67
|
background-color: @globalColor0;
|
|
55
|
-
height: 32px;
|
|
56
|
-
line-height: 32px;
|
|
57
|
-
|
|
68
|
+
// height: 32px;
|
|
69
|
+
// line-height: 32px;
|
|
70
|
+
overflow: hidden;
|
|
58
71
|
text-overflow: ellipsis;
|
|
59
72
|
white-space: nowrap;
|
|
60
73
|
padding: 0;
|
|
@@ -138,10 +151,14 @@ table {
|
|
|
138
151
|
}
|
|
139
152
|
|
|
140
153
|
.empty-container {
|
|
141
|
-
height: 100%;
|
|
154
|
+
// height: 100%;
|
|
155
|
+
// width: var(--table-width);
|
|
142
156
|
|
|
143
157
|
.empty-wrapper {
|
|
144
|
-
|
|
158
|
+
width: var(--table-body-width);
|
|
159
|
+
height: var(--table-body-height);
|
|
160
|
+
|
|
161
|
+
// height: 100%;
|
|
145
162
|
min-height: 120px;
|
|
146
163
|
display: flex;
|
|
147
164
|
flex-direction: column;
|
|
@@ -9,7 +9,6 @@ import "./index.less";
|
|
|
9
9
|
import { getPinningStyle } from "./utils";
|
|
10
10
|
import { useWhyDidYouUpdate } from 'ahooks';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
12
|
var OriginalTableHeader = function OriginalTableHeader(_ref) {
|
|
14
13
|
var _headerGroups;
|
|
15
14
|
var tableContentRef = _ref.tableContentRef,
|
|
@@ -41,16 +40,16 @@ var OriginalTableHeader = function OriginalTableHeader(_ref) {
|
|
|
41
40
|
headerRowNum: headerRowNum,
|
|
42
41
|
manualFiltering: manualFiltering
|
|
43
42
|
});
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
return (
|
|
44
|
+
/*#__PURE__*/
|
|
45
|
+
// <table>
|
|
46
|
+
// <colgroup>
|
|
47
|
+
// {headers.map((header: any) => {
|
|
48
|
+
// let size: number = header?.column?.getSize() || 120;
|
|
49
|
+
// return <col key={header.id} width={size}></col>;
|
|
50
|
+
// })}
|
|
51
|
+
// </colgroup>
|
|
52
|
+
_jsx("thead", {
|
|
54
53
|
children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map(function (headerGroup) {
|
|
55
54
|
return /*#__PURE__*/_jsx("tr", {
|
|
56
55
|
className: "table-thead-tr cus-table-thead-tr",
|
|
@@ -80,7 +79,8 @@ var OriginalTableHeader = function OriginalTableHeader(_ref) {
|
|
|
80
79
|
})
|
|
81
80
|
}, headerGroup.id);
|
|
82
81
|
})
|
|
83
|
-
})
|
|
84
|
-
|
|
82
|
+
})
|
|
83
|
+
// </table>
|
|
84
|
+
);
|
|
85
85
|
};
|
|
86
86
|
export { OriginalTableHeader };
|
|
@@ -222,4 +222,19 @@ table {
|
|
|
222
222
|
transform: translate3d(0, 0, 0);
|
|
223
223
|
contain: strict;
|
|
224
224
|
cursor: ew-resize;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
thead {
|
|
228
|
+
position: sticky;
|
|
229
|
+
top: 0;
|
|
230
|
+
left: 0;
|
|
231
|
+
z-index: 202;
|
|
232
|
+
|
|
233
|
+
.cell-wapper {
|
|
234
|
+
display: flex;
|
|
235
|
+
justify-content: center;
|
|
236
|
+
align-items: center;
|
|
237
|
+
padding: var(--cell-padding);
|
|
238
|
+
height: var(--cell-height);
|
|
239
|
+
}
|
|
225
240
|
}
|
|
@@ -27,8 +27,6 @@ import { cloneDeep, debounce } from 'lodash';
|
|
|
27
27
|
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
28
28
|
import { useTranslation } from "../../hooks/useTranslation";
|
|
29
29
|
import { useConfig } from "../ConfigProvider";
|
|
30
|
-
import TableBody from "./TableBody";
|
|
31
|
-
import TableHeader from "./TableHeader";
|
|
32
30
|
import { InputType } from "./components/ColumnEdit";
|
|
33
31
|
import { setDefaultFilterFn } from "./components/ColumnFilterV2";
|
|
34
32
|
import customFilterFns from "./components/ColumnFilterV2/customFilterFns";
|
|
@@ -40,6 +38,7 @@ import "./tableMax.less";
|
|
|
40
38
|
import { downloadExcel, getFormatFilters, getFormatFiltersV2, getFormatSorting, operationColumnNoTooltips } from "./utils";
|
|
41
39
|
import { useTableScrollShadow } from "./hooks/useTableScrollShadow";
|
|
42
40
|
import { ExportTableData } from "./components/Export";
|
|
41
|
+
import UnifiedTable from "./UnifiedTable";
|
|
43
42
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
44
43
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
45
44
|
export var ColumnType = /*#__PURE__*/function (ColumnType) {
|
|
@@ -340,7 +339,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
340
339
|
columnSizing = _useColumnWidth.columnSizing,
|
|
341
340
|
initializeColumnSizing = _useColumnWidth.initializeColumnSizing,
|
|
342
341
|
onColumnSizingChange = _useColumnWidth.onColumnSizingChange,
|
|
343
|
-
tableContainerWidth = _useColumnWidth.tableContainerWidth,
|
|
344
342
|
handleVisibleConfigChange = _useColumnWidth.handleVisibleConfigChange;
|
|
345
343
|
|
|
346
344
|
/**列筛选 */
|
|
@@ -554,9 +552,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
554
552
|
if (cacheHeaderRowNum) {
|
|
555
553
|
setheaderRowNum(cacheHeaderRowNum);
|
|
556
554
|
}
|
|
557
|
-
|
|
558
|
-
// setCompactMode(cacheCompactMode === true);
|
|
559
|
-
// setRowHeight(cacheCompactMode === true ? compactModeRowHeight : propsRowHeight);
|
|
560
555
|
changeCompactModeStyle(cacheCompactMode === true);
|
|
561
556
|
var newColumnVisibleConfig = _objectSpread(_objectSpread({}, columnVisibleConfig), cacheColumnVisibility);
|
|
562
557
|
setColumnVisibility(newColumnVisibleConfig);
|
|
@@ -598,7 +593,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
598
593
|
setColumnOrder(arr);
|
|
599
594
|
};
|
|
600
595
|
var recentlyCheckedRow = useRef(null);
|
|
601
|
-
var allCheckedRow = useRef(null);
|
|
602
596
|
var setColumnsByProps = useCallback(function () {
|
|
603
597
|
var extraColumns = [];
|
|
604
598
|
if (getRowCanExpand() && columns.findIndex(function (column) {
|
|
@@ -738,26 +732,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
738
732
|
return (column === null || column === void 0 ? void 0 : column.columns) && ((_column$columns = column.columns) === null || _column$columns === void 0 ? void 0 : _column$columns.length) > 0;
|
|
739
733
|
}) > -1);
|
|
740
734
|
}, [columns]);
|
|
741
|
-
|
|
742
|
-
// 列显示隐藏改变,修改初始化列宽Map
|
|
743
|
-
// useUpdateEffect(() => {
|
|
744
|
-
// const visibleColumnsSizeMap = {};
|
|
745
|
-
// const notVisibleColumns = Object.keys(columnVisibleConfig).filter(key => !columnVisibleConfig[key]);
|
|
746
|
-
// allColumnCount = table.getVisibleLeafColumns().length;
|
|
747
|
-
// Object.keys(initColumnsSizing).forEach(key => {
|
|
748
|
-
// if (!notVisibleColumns.includes(key)) {
|
|
749
|
-
// visibleColumnsSizeMap[key] = initColumnsSizing[key];
|
|
750
|
-
// }
|
|
751
|
-
// });
|
|
752
|
-
// visibleColumnsSizing = visibleColumnsSizeMap;
|
|
753
|
-
// }, [columnVisibleConfig]);
|
|
754
|
-
|
|
755
|
-
// 容器宽度改变,重新计算列宽
|
|
756
|
-
// useUpdateEffect(() => {
|
|
757
|
-
// setColumnSizing(changeColumnSizingHandler(visibleColumnsSizing));
|
|
758
|
-
// // changeColumnSizingHandler(visibleColumnsSizing)
|
|
759
|
-
// }, [tableContainerWidth]);
|
|
760
|
-
|
|
761
735
|
var _rowSelectionChange = useCallback(debounce(function (rowOriginal, row) {
|
|
762
736
|
if (rowSelectionChange) {
|
|
763
737
|
// console.log(rowOriginal, row, 'rowSelectionChange1')
|
|
@@ -1084,7 +1058,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
1084
1058
|
getHeaderCellProps: getHeaderCellProps,
|
|
1085
1059
|
columnResizeMode: columnResizeMode,
|
|
1086
1060
|
disableColumnDrag: disableColumnDrag,
|
|
1087
|
-
compactMode: compactMode,
|
|
1088
1061
|
manualFiltering: manualFiltering,
|
|
1089
1062
|
getDynamicFilterOptionsFn: getDynamicFilterOptionsFn,
|
|
1090
1063
|
tableHeaderRef: tableHeaderRef
|
|
@@ -1104,7 +1077,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
1104
1077
|
canFilter: canFilter,
|
|
1105
1078
|
canSelection: canSelection,
|
|
1106
1079
|
selectionWithoutChecked: selectionWithoutChecked,
|
|
1107
|
-
tableContainerWidth: tableContainerWidth,
|
|
1108
1080
|
selectedRowDragging: selectedRowDragging,
|
|
1109
1081
|
setSelectedRowDragging: setSelectedRowDragging,
|
|
1110
1082
|
canRowDrag: canRowDrag,
|
|
@@ -1323,24 +1295,13 @@ var TableMax = function TableMax(_ref) {
|
|
|
1323
1295
|
})]
|
|
1324
1296
|
})]
|
|
1325
1297
|
}), /*#__PURE__*/_jsx("div", {
|
|
1326
|
-
className: "table-max-content cus-table-max-content
|
|
1327
|
-
children: /*#__PURE__*/
|
|
1298
|
+
className: "table-max-content cus-table-max-content",
|
|
1299
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
1328
1300
|
className: "table-center",
|
|
1329
|
-
ref: tableContentRef
|
|
1330
|
-
|
|
1331
|
-
,
|
|
1332
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
1333
|
-
className: "table-header-wrapper",
|
|
1334
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
1335
|
-
ref: tableHeaderRef,
|
|
1336
|
-
className: "table-header",
|
|
1337
|
-
children: /*#__PURE__*/_jsx(TableHeader, _objectSpread({}, tableHeaderProps))
|
|
1338
|
-
})
|
|
1339
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
1301
|
+
ref: tableContentRef,
|
|
1302
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
1340
1303
|
ref: tableBodyRef,
|
|
1341
|
-
className: "table-body"
|
|
1342
|
-
// onScroll={scrollHandler}
|
|
1343
|
-
,
|
|
1304
|
+
className: "table-body",
|
|
1344
1305
|
style: {
|
|
1345
1306
|
width: "100%"
|
|
1346
1307
|
},
|
|
@@ -1354,8 +1315,15 @@ var TableMax = function TableMax(_ref) {
|
|
|
1354
1315
|
// 移除当前元素的hover类
|
|
1355
1316
|
(_tableBodyRef$current2 = tableBodyRef.current) === null || _tableBodyRef$current2 === void 0 || _tableBodyRef$current2.classList.remove('hover-active');
|
|
1356
1317
|
},
|
|
1357
|
-
children: /*#__PURE__*/_jsx(
|
|
1358
|
-
|
|
1318
|
+
children: /*#__PURE__*/_jsx(UnifiedTable, {
|
|
1319
|
+
tableId: tableId,
|
|
1320
|
+
table: table,
|
|
1321
|
+
tableContentRef: tableContentRef,
|
|
1322
|
+
tableBodyRef: tableBodyRef,
|
|
1323
|
+
tableHeaderProps: tableHeaderProps,
|
|
1324
|
+
tableBodyProps: tableBodyProps
|
|
1325
|
+
})
|
|
1326
|
+
})
|
|
1359
1327
|
})
|
|
1360
1328
|
}), pagination && /*#__PURE__*/_jsx("div", {
|
|
1361
1329
|
className: "table-max-footer",
|
|
@@ -1407,9 +1375,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
1407
1375
|
})
|
|
1408
1376
|
});
|
|
1409
1377
|
};
|
|
1410
|
-
|
|
1411
|
-
// export default React.forwardRef((props: TableMaxProps, ref) => <TableMax {...props} refInstance={ref} />);
|
|
1412
|
-
|
|
1413
1378
|
export default /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
1414
1379
|
return /*#__PURE__*/_jsx(TableMax, _objectSpread(_objectSpread({}, props), {}, {
|
|
1415
1380
|
refInstance: ref
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Table } from '@tanstack/react-table';
|
|
3
|
+
import { MutableRefObject } from 'react';
|
|
4
|
+
interface UnifiedTableProps {
|
|
5
|
+
tableId: string;
|
|
6
|
+
table: Table<any>;
|
|
7
|
+
tableContentRef: MutableRefObject<HTMLDivElement> | null;
|
|
8
|
+
tableBodyRef: MutableRefObject<HTMLDivElement> | null;
|
|
9
|
+
tableHeaderProps: any;
|
|
10
|
+
tableBodyProps: any;
|
|
11
|
+
}
|
|
12
|
+
declare const UnifiedTable: React.FC<UnifiedTableProps>;
|
|
13
|
+
export default UnifiedTable;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
// UnifiedTable.tsx
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { OriginalTableHeader } from "./TableHeader";
|
|
10
|
+
import { VirtualTableBody } from "./TableBody";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
var UnifiedTable = function UnifiedTable(_ref) {
|
|
14
|
+
var _headerGroups;
|
|
15
|
+
var tableId = _ref.tableId,
|
|
16
|
+
table = _ref.table,
|
|
17
|
+
tableContentRef = _ref.tableContentRef,
|
|
18
|
+
tableBodyRef = _ref.tableBodyRef,
|
|
19
|
+
tableHeaderProps = _ref.tableHeaderProps,
|
|
20
|
+
tableBodyProps = _ref.tableBodyProps;
|
|
21
|
+
var headerGroups = table.getHeaderGroups();
|
|
22
|
+
var headers = (headerGroups === null || headerGroups === void 0 || (_headerGroups = headerGroups[headerGroups.length - 1]) === null || _headerGroups === void 0 ? void 0 : _headerGroups.headers) || [];
|
|
23
|
+
return /*#__PURE__*/_jsxs("table", {
|
|
24
|
+
className: "unified-table",
|
|
25
|
+
children: [/*#__PURE__*/_jsx("colgroup", {
|
|
26
|
+
children: headers.map(function (header) {
|
|
27
|
+
var _header$column;
|
|
28
|
+
var size = (header === null || header === void 0 || (_header$column = header.column) === null || _header$column === void 0 ? void 0 : _header$column.getSize()) || 120;
|
|
29
|
+
return /*#__PURE__*/_jsx("col", {
|
|
30
|
+
width: size
|
|
31
|
+
}, header.id);
|
|
32
|
+
})
|
|
33
|
+
}), /*#__PURE__*/_jsx(OriginalTableHeader, _objectSpread({}, tableHeaderProps)), /*#__PURE__*/_jsx(VirtualTableBody, _objectSpread({}, tableBodyProps))]
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
export default UnifiedTable;
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
.tbody-tr-selected > .tbody-tr-td-drag {
|
|
20
20
|
background-color: @global-card-effect-background-color;
|
|
21
21
|
// border-bottom: 1px solid @tableColor2;
|
|
22
|
-
height:
|
|
23
|
-
line-height:
|
|
22
|
+
height: 42px;
|
|
23
|
+
line-height: 42px;
|
|
24
24
|
padding: 0 8px;
|
|
25
25
|
overflow: hidden;
|
|
26
26
|
text-overflow: ellipsis;
|
|
@@ -19,8 +19,9 @@ import { getSizeInfo } from "../utils";
|
|
|
19
19
|
var DEFAULT_MIN_SIZE = 120;
|
|
20
20
|
var DEFAULT_MAX_SIZE = 2000;
|
|
21
21
|
var DEFAULT_RESIZE_DEBOUNCE = 200;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
var DEFAULT_TABLE_PADDING = 10;
|
|
23
|
+
// const DEFAULT_TABLE_PADDING = 0;
|
|
24
|
+
|
|
24
25
|
/**
|
|
25
26
|
* 获取表格容器的有效宽度(减去边框)
|
|
26
27
|
*/
|
|
@@ -321,10 +322,14 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
321
322
|
useEffect(function () {
|
|
322
323
|
if (!tableContentRef.current) return;
|
|
323
324
|
var observer = new ResizeObserver(function (entries) {
|
|
324
|
-
var _entries
|
|
325
|
+
var _entries$, _entries$2;
|
|
325
326
|
var newWidth = (_entries$ = entries[0]) === null || _entries$ === void 0 ? void 0 : _entries$.contentRect.width;
|
|
326
|
-
|
|
327
|
+
var height = (_entries$2 = entries[0]) === null || _entries$2 === void 0 ? void 0 : _entries$2.contentRect.height;
|
|
328
|
+
if (newWidth || height) {
|
|
329
|
+
var _tableContentRef$curr, _tableContentRef$curr2;
|
|
327
330
|
debouncedHandleResizeRef.current(newWidth);
|
|
331
|
+
(_tableContentRef$curr = tableContentRef.current) === null || _tableContentRef$curr === void 0 || (_tableContentRef$curr = _tableContentRef$curr.style) === null || _tableContentRef$curr === void 0 || _tableContentRef$curr.setProperty('--table-body-width', "".concat(newWidth - 12, "px"));
|
|
332
|
+
(_tableContentRef$curr2 = tableContentRef.current) === null || _tableContentRef$curr2 === void 0 || (_tableContentRef$curr2 = _tableContentRef$curr2.style) === null || _tableContentRef$curr2 === void 0 || _tableContentRef$curr2.setProperty('--table-body-height', "".concat(height - 60, "px"));
|
|
328
333
|
}
|
|
329
334
|
});
|
|
330
335
|
observer.observe(tableContentRef.current);
|
|
@@ -64,14 +64,15 @@ export var useTableScrollShadow = function useTableScrollShadow(_ref) {
|
|
|
64
64
|
|
|
65
65
|
// 滚动处理函数
|
|
66
66
|
var handleScroll = useCallback(function (event) {
|
|
67
|
-
|
|
68
|
-
if (!target || !tableHeaderRef.current) return;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
// const target = event.currentTarget as HTMLElement;
|
|
68
|
+
// if (!target || !tableHeaderRef.current) return;
|
|
69
|
+
|
|
70
|
+
// const { scrollLeft, scrollWidth } = target;
|
|
71
|
+
// const headerScrollLeft = (scrollLeft / scrollWidth) * tableHeaderRef.current.scrollWidth;
|
|
72
|
+
|
|
73
|
+
// // 实时同步表头滚动
|
|
74
|
+
// tableHeaderRef.current.scrollLeft = headerScrollLeft;
|
|
72
75
|
|
|
73
|
-
// 实时同步表头滚动
|
|
74
|
-
tableHeaderRef.current.scrollLeft = headerScrollLeft;
|
|
75
76
|
changePinShadow();
|
|
76
77
|
}, [tableHeaderRef, changePinShadow]);
|
|
77
78
|
|
|
@@ -79,16 +80,16 @@ export var useTableScrollShadow = function useTableScrollShadow(_ref) {
|
|
|
79
80
|
useEffect(function () {
|
|
80
81
|
var tableBody = tableBodyRef.current;
|
|
81
82
|
if (!tableBody) return;
|
|
82
|
-
tableBody.addEventListener('scroll',
|
|
83
|
+
tableBody.addEventListener('scroll', changePinShadow, supportsPassive ? {
|
|
83
84
|
passive: true
|
|
84
85
|
} : false);
|
|
85
86
|
return function () {
|
|
86
87
|
if (scrollRafId.current) {
|
|
87
88
|
cancelAnimationFrame(scrollRafId.current);
|
|
88
89
|
}
|
|
89
|
-
tableBody.removeEventListener('scroll',
|
|
90
|
+
tableBody.removeEventListener('scroll', changePinShadow);
|
|
90
91
|
};
|
|
91
|
-
}, [tableBodyRef,
|
|
92
|
+
}, [tableBodyRef, changePinShadow, supportsPassive]);
|
|
92
93
|
|
|
93
94
|
// 监听表格宽度和列尺寸变化
|
|
94
95
|
useEffect(function () {
|
|
@@ -51,7 +51,7 @@ export var useVirtualCalculations = function useVirtualCalculations(table, table
|
|
|
51
51
|
overscan: config.rowOverscan || 10,
|
|
52
52
|
key: virtualizerRefreshKey
|
|
53
53
|
};
|
|
54
|
-
}, [config.openVirtualRows, rows
|
|
54
|
+
}, [config.openVirtualRows, rows, config.rowHeight,
|
|
55
55
|
// 关键:包含 rowHeight 依赖
|
|
56
56
|
config.rowOverscan, virtualizerRefreshKey, tableKey]);
|
|
57
57
|
var rowVirtualizer = rowVirtualizerConfig ? useVirtualizer(rowVirtualizerConfig) : null;
|
|
@@ -59,6 +59,8 @@ export var useVirtualCalculations = function useVirtualCalculations(table, table
|
|
|
59
59
|
// 响应 rowHeight 变化
|
|
60
60
|
useEffect(function () {
|
|
61
61
|
if (rowVirtualizer && config.openVirtualRows) {
|
|
62
|
+
var _tableBodyRef$current;
|
|
63
|
+
console.log((_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 ? void 0 : _tableBodyRef$current.offsetHeight, 'tableBodyRef.current?.offsetHeight');
|
|
62
64
|
// 当 rowHeight 变化时,重新测量所有行
|
|
63
65
|
console.log('rowHeight数据变化,重新测量', rows.length);
|
|
64
66
|
rowVirtualizer.measure();
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
position: relative;
|
|
89
89
|
display: flex;
|
|
90
90
|
border-radius: @global-table-max-center-border-radius;
|
|
91
|
-
--cell-height:
|
|
91
|
+
--cell-height: 41px;
|
|
92
92
|
--cell-padding: 0 8px;
|
|
93
93
|
|
|
94
94
|
.cell-wapper {
|
|
@@ -106,7 +106,8 @@
|
|
|
106
106
|
padding:var(--cell-padding)!important;
|
|
107
107
|
display: flex;
|
|
108
108
|
align-items: center;
|
|
109
|
-
|
|
109
|
+
|
|
110
|
+
.ellipsis {
|
|
110
111
|
overflow: hidden;
|
|
111
112
|
text-overflow: ellipsis;
|
|
112
113
|
white-space: nowrap;
|
|
Binary file
|