@arim-aisdc/public-components 2.3.56 → 2.3.58
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/BaseInfo/BaseInfo.d.ts +1 -1
- package/dist/components/TableMax/TableBody/VirtualRow.js +1 -1
- package/dist/components/TableMax/TableBody/VirtualTableBody.d.ts +2 -2
- package/dist/components/TableMax/TableBody/VirtualTableBody.js +40 -46
- package/dist/components/TableMax/TableBody/index.less +6 -2
- package/dist/components/TableMax/TableHeader/OriginalTableHeader.js +13 -13
- package/dist/components/TableMax/TableHeader/index.less +15 -0
- package/dist/components/TableMax/TableMax.js +12 -35
- package/dist/components/TableMax/UnifiedTable.d.ts +13 -0
- package/dist/components/TableMax/UnifiedTable.js +140 -0
- package/dist/components/TableMax/components/ColumnSort/customSortFns.d.ts +8 -8
- 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 +2 -1
- package/dist/components/TableMaxV2.rar +0 -0
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ export declare const foramtBaseInfoField: (data: any, dataField: BaseInfoFieldTy
|
|
|
17
17
|
value: any;
|
|
18
18
|
field: string;
|
|
19
19
|
label?: string;
|
|
20
|
-
text: string | Element |
|
|
20
|
+
text: string | JSX.Element | Element;
|
|
21
21
|
units?: string;
|
|
22
22
|
width?: string;
|
|
23
23
|
labelWidth?: string;
|
|
@@ -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()) {
|
|
@@ -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,7 @@ 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
353
|
return (rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.getTotalSize()) + (hasTotalRow ? rowHeight : 0);
|
|
354
354
|
}, [openVirtualRows, hasTotalRow, rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.getTotalSize(), rowHeight]);
|
|
355
355
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -363,50 +363,44 @@ var VirtualTableBody = function VirtualTableBody(_ref) {
|
|
|
363
363
|
table: table,
|
|
364
364
|
tableId: tableId,
|
|
365
365
|
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",
|
|
366
|
+
}), root ? document.querySelector(root) : document.body), showTable ?
|
|
367
|
+
/*#__PURE__*/
|
|
368
|
+
// <div
|
|
369
|
+
// className="table-max-table-body-table-wrapper"
|
|
370
|
+
// ref={dropTableEmptyRef}
|
|
371
|
+
// >
|
|
372
|
+
// <table>
|
|
373
|
+
// <colgroup>
|
|
374
|
+
// {headers.map((header: any) => {
|
|
375
|
+
// let size: number = header?.column?.getSize() || 120;
|
|
376
|
+
// return <col key={header.id} width={size}></col>;
|
|
377
|
+
// })}
|
|
378
|
+
// </colgroup>
|
|
379
|
+
_jsxs("tbody", {
|
|
380
|
+
ref: dropTableEmptyRef,
|
|
381
|
+
id: "table-max-tableBody-tbody-".concat(tableId),
|
|
398
382
|
style: {
|
|
399
|
-
|
|
383
|
+
position: openVirtualRows ? 'relative' : 'static',
|
|
384
|
+
height: tBodyHeight,
|
|
385
|
+
paddingBottom: openVirtualRows && hasTotalRow ? "".concat(rowHeight, "px") : 0
|
|
400
386
|
},
|
|
401
|
-
children: /*#__PURE__*/_jsx(
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
387
|
+
children: [openVirtualRows ? renderVirtualRows() : renderNormalRows(), hasTotalRow && /*#__PURE__*/_jsx(Total, {
|
|
388
|
+
table: table,
|
|
389
|
+
totalDatas: totalDatas
|
|
390
|
+
})]
|
|
391
|
+
})
|
|
392
|
+
// // {/* </table> */}
|
|
393
|
+
// </div>
|
|
394
|
+
: /*#__PURE__*/_jsx("tbody", {
|
|
395
|
+
ref: dropEmptyRef,
|
|
396
|
+
children: /*#__PURE__*/_jsx("tr", {
|
|
397
|
+
className: "empty-container",
|
|
398
|
+
children: /*#__PURE__*/_jsx("td", {
|
|
399
|
+
className: "empty-wrapper",
|
|
400
|
+
children: loading ? /*#__PURE__*/_jsx(Spin, {}) : /*#__PURE__*/_jsx("span", {
|
|
401
|
+
className: "empty-content",
|
|
402
|
+
children: /*#__PURE__*/_jsx(Empty, {})
|
|
403
|
+
})
|
|
410
404
|
})
|
|
411
405
|
})
|
|
412
406
|
}), /*#__PURE__*/_jsx(ContextMenu, _objectSpread(_objectSpread({}, contextMenuData), {}, {
|
|
@@ -138,10 +138,14 @@ table {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
.empty-container {
|
|
141
|
-
height: 100%;
|
|
141
|
+
// height: 100%;
|
|
142
|
+
// width: var(--table-width);
|
|
142
143
|
|
|
143
144
|
.empty-wrapper {
|
|
144
|
-
|
|
145
|
+
width: var(--table-body-width);
|
|
146
|
+
height: var(--table-body-height);
|
|
147
|
+
|
|
148
|
+
// height: 100%;
|
|
145
149
|
min-height: 120px;
|
|
146
150
|
display: flex;
|
|
147
151
|
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
|
/**列筛选 */
|
|
@@ -738,26 +736,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
738
736
|
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
737
|
}) > -1);
|
|
740
738
|
}, [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
739
|
var _rowSelectionChange = useCallback(debounce(function (rowOriginal, row) {
|
|
762
740
|
if (rowSelectionChange) {
|
|
763
741
|
// console.log(rowOriginal, row, 'rowSelectionChange1')
|
|
@@ -1104,7 +1082,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
1104
1082
|
canFilter: canFilter,
|
|
1105
1083
|
canSelection: canSelection,
|
|
1106
1084
|
selectionWithoutChecked: selectionWithoutChecked,
|
|
1107
|
-
tableContainerWidth: tableContainerWidth,
|
|
1108
1085
|
selectedRowDragging: selectedRowDragging,
|
|
1109
1086
|
setSelectedRowDragging: setSelectedRowDragging,
|
|
1110
1087
|
canRowDrag: canRowDrag,
|
|
@@ -1324,19 +1301,12 @@ var TableMax = function TableMax(_ref) {
|
|
|
1324
1301
|
})]
|
|
1325
1302
|
}), /*#__PURE__*/_jsx("div", {
|
|
1326
1303
|
className: "table-max-content cus-table-max-content ".concat(compactMode ? 'table-max-content-compact' : null),
|
|
1327
|
-
children: /*#__PURE__*/
|
|
1304
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
1328
1305
|
className: "table-center",
|
|
1329
1306
|
ref: tableContentRef
|
|
1330
1307
|
// style={{ maxHeight: !autoHeight ? defaultScrollY : 'fit-content' }}
|
|
1331
1308
|
,
|
|
1332
|
-
children:
|
|
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", {
|
|
1309
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
1340
1310
|
ref: tableBodyRef,
|
|
1341
1311
|
className: "table-body"
|
|
1342
1312
|
// onScroll={scrollHandler}
|
|
@@ -1354,8 +1324,15 @@ var TableMax = function TableMax(_ref) {
|
|
|
1354
1324
|
// 移除当前元素的hover类
|
|
1355
1325
|
(_tableBodyRef$current2 = tableBodyRef.current) === null || _tableBodyRef$current2 === void 0 || _tableBodyRef$current2.classList.remove('hover-active');
|
|
1356
1326
|
},
|
|
1357
|
-
children: /*#__PURE__*/_jsx(
|
|
1358
|
-
|
|
1327
|
+
children: /*#__PURE__*/_jsx(UnifiedTable, {
|
|
1328
|
+
tableId: tableId,
|
|
1329
|
+
table: table,
|
|
1330
|
+
tableContentRef: tableContentRef,
|
|
1331
|
+
tableBodyRef: tableBodyRef,
|
|
1332
|
+
tableHeaderProps: tableHeaderProps,
|
|
1333
|
+
tableBodyProps: tableBodyProps
|
|
1334
|
+
})
|
|
1335
|
+
})
|
|
1359
1336
|
})
|
|
1360
1337
|
}), pagination && /*#__PURE__*/_jsx("div", {
|
|
1361
1338
|
className: "table-max-footer",
|
|
@@ -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,140 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
// UnifiedTable.tsx
|
|
14
|
+
import React, { useRef } from 'react';
|
|
15
|
+
import { useDrop } from 'react-dnd';
|
|
16
|
+
import { OriginalTableHeader } from "./TableHeader";
|
|
17
|
+
import { VirtualTableBody } from "./TableBody";
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
+
var UnifiedTable = function UnifiedTable(_ref) {
|
|
21
|
+
var _headerGroups;
|
|
22
|
+
var tableId = _ref.tableId,
|
|
23
|
+
table = _ref.table,
|
|
24
|
+
tableContentRef = _ref.tableContentRef,
|
|
25
|
+
tableBodyRef = _ref.tableBodyRef,
|
|
26
|
+
tableHeaderProps = _ref.tableHeaderProps,
|
|
27
|
+
tableBodyProps = _ref.tableBodyProps;
|
|
28
|
+
var headerGroups = table.getHeaderGroups();
|
|
29
|
+
var headers = (headerGroups === null || headerGroups === void 0 || (_headerGroups = headerGroups[headerGroups.length - 1]) === null || _headerGroups === void 0 ? void 0 : _headerGroups.headers) || [];
|
|
30
|
+
var rows = table.getRowModel().rows;
|
|
31
|
+
var canFilter = tableHeaderProps.canFilter,
|
|
32
|
+
enableFilters = tableHeaderProps.enableFilters,
|
|
33
|
+
canSorting = tableHeaderProps.canSorting,
|
|
34
|
+
hasGroup = tableHeaderProps.hasGroup,
|
|
35
|
+
getHeaderCellProps = tableHeaderProps.getHeaderCellProps,
|
|
36
|
+
columnResizeMode = tableHeaderProps.columnResizeMode,
|
|
37
|
+
disableColumnDrag = tableHeaderProps.disableColumnDrag,
|
|
38
|
+
rowHeight = tableHeaderProps.rowHeight,
|
|
39
|
+
headerRowNum = tableHeaderProps.headerRowNum,
|
|
40
|
+
manualFiltering = tableHeaderProps.manualFiltering,
|
|
41
|
+
getDynamicFilterOptionsFn = tableHeaderProps.getDynamicFilterOptionsFn;
|
|
42
|
+
var loading = tableBodyProps.loading,
|
|
43
|
+
datas = tableBodyProps.datas,
|
|
44
|
+
hasTotalRow = tableBodyProps.hasTotalRow,
|
|
45
|
+
totalDatas = tableBodyProps.totalDatas,
|
|
46
|
+
theme = tableBodyProps.theme,
|
|
47
|
+
reorderRow = tableBodyProps.reorderRow,
|
|
48
|
+
rowSelectedId = tableBodyProps.rowSelectedId,
|
|
49
|
+
setRowSelectedId = tableBodyProps.setRowSelectedId,
|
|
50
|
+
rowHighLightId = tableBodyProps.rowHighLightId,
|
|
51
|
+
setRowHighLightId = tableBodyProps.setRowHighLightId,
|
|
52
|
+
selectedRowChange = tableBodyProps.selectedRowChange,
|
|
53
|
+
onSelectChange = tableBodyProps.onSelectChange,
|
|
54
|
+
canSelection = tableBodyProps.canSelection,
|
|
55
|
+
selectionWithoutChecked = tableBodyProps.selectionWithoutChecked,
|
|
56
|
+
selectedRowDragging = tableBodyProps.selectedRowDragging,
|
|
57
|
+
setSelectedRowDragging = tableBodyProps.setSelectedRowDragging,
|
|
58
|
+
canRowDrag = tableBodyProps.canRowDrag,
|
|
59
|
+
rowKey = tableBodyProps.rowKey,
|
|
60
|
+
rowClassName = tableBodyProps.rowClassName,
|
|
61
|
+
cellClassName = tableBodyProps.cellClassName,
|
|
62
|
+
rowStyle = tableBodyProps.rowStyle,
|
|
63
|
+
getCellProps = tableBodyProps.getCellProps,
|
|
64
|
+
renderSubComponent = tableBodyProps.renderSubComponent,
|
|
65
|
+
onRowMouseEnter = tableBodyProps.onRowMouseEnter,
|
|
66
|
+
onRowMouseLeave = tableBodyProps.onRowMouseLeave,
|
|
67
|
+
onRowMouseClick = tableBodyProps.onRowMouseClick,
|
|
68
|
+
onRowMouseDoubleClick = tableBodyProps.onRowMouseDoubleClick,
|
|
69
|
+
disableDragRowIds = tableBodyProps.disableDragRowIds,
|
|
70
|
+
selectRowWhenClick = tableBodyProps.selectRowWhenClick,
|
|
71
|
+
canEditRowWhenDClick = tableBodyProps.canEditRowWhenDClick,
|
|
72
|
+
editingRowId = tableBodyProps.editingRowId,
|
|
73
|
+
handleEditRowWhenDClick = tableBodyProps.handleEditRowWhenDClick,
|
|
74
|
+
dragBeforeStart = tableBodyProps.dragBeforeStart,
|
|
75
|
+
getContextMenu = tableBodyProps.getContextMenu,
|
|
76
|
+
onClickContextMenu = tableBodyProps.onClickContextMenu,
|
|
77
|
+
getRowHoverTipConfig = tableBodyProps.getRowHoverTipConfig,
|
|
78
|
+
tableTooltip = tableBodyProps.tableTooltip,
|
|
79
|
+
onEditValueChange = tableBodyProps.onEditValueChange,
|
|
80
|
+
setRowSelection = tableBodyProps.setRowSelection,
|
|
81
|
+
openMemo = tableBodyProps.openMemo;
|
|
82
|
+
|
|
83
|
+
// 空状态相关的 drop 处理
|
|
84
|
+
var _useDrop = useDrop({
|
|
85
|
+
accept: 'TABLE_ROW',
|
|
86
|
+
drop: function drop(formDatas) {
|
|
87
|
+
return reorderRow === null || reorderRow === void 0 ? void 0 : reorderRow(formDatas, {
|
|
88
|
+
hoverRow: {
|
|
89
|
+
index: 0
|
|
90
|
+
},
|
|
91
|
+
targetTableId: tableId
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}),
|
|
95
|
+
_useDrop2 = _slicedToArray(_useDrop, 2),
|
|
96
|
+
dropEmptyRef = _useDrop2[1];
|
|
97
|
+
|
|
98
|
+
// 判断是否显示表格内容
|
|
99
|
+
var showTable = !loading && datas.length !== 0 && rows.length !== 0;
|
|
100
|
+
var tableRef = useRef();
|
|
101
|
+
|
|
102
|
+
// // 监听容器大小变化
|
|
103
|
+
// useEffect(() => {
|
|
104
|
+
// if (!tableRef?.current) return;
|
|
105
|
+
|
|
106
|
+
// const observer = new ResizeObserver(entries => {
|
|
107
|
+
// // const newWidth = entries[0]?.contentRect.width;
|
|
108
|
+
// // const height = entries[0]?.contentRect.height;
|
|
109
|
+
// // console.log(entries[0]?.contentRect, entries[0], 'entries[0]?')
|
|
110
|
+
// const target = entries[0].target;
|
|
111
|
+
|
|
112
|
+
// // 获取不包含滚动条的宽度
|
|
113
|
+
// const widthWithoutScrollbar = target.clientWidth;
|
|
114
|
+
// const heightWithoutScrollbar = target.clientHeight;
|
|
115
|
+
|
|
116
|
+
// if (widthWithoutScrollbar && heightWithoutScrollbar && tableRef?.current) {
|
|
117
|
+
// tableRef?.current?.style?.setProperty('--table-width', `${widthWithoutScrollbar}px`);
|
|
118
|
+
// tableRef?.current?.style?.setProperty('--table-height', `${heightWithoutScrollbar}px`);
|
|
119
|
+
// }
|
|
120
|
+
// });
|
|
121
|
+
|
|
122
|
+
// observer.observe(tableRef.current);
|
|
123
|
+
// return () => observer.disconnect();
|
|
124
|
+
// }, [tableRef]);
|
|
125
|
+
|
|
126
|
+
return /*#__PURE__*/_jsxs("table", {
|
|
127
|
+
className: "unified-table",
|
|
128
|
+
ref: tableRef,
|
|
129
|
+
children: [/*#__PURE__*/_jsx("colgroup", {
|
|
130
|
+
children: headers.map(function (header) {
|
|
131
|
+
var _header$column;
|
|
132
|
+
var size = (header === null || header === void 0 || (_header$column = header.column) === null || _header$column === void 0 ? void 0 : _header$column.getSize()) || 120;
|
|
133
|
+
return /*#__PURE__*/_jsx("col", {
|
|
134
|
+
width: size
|
|
135
|
+
}, header.id);
|
|
136
|
+
})
|
|
137
|
+
}), /*#__PURE__*/_jsx(OriginalTableHeader, _objectSpread({}, tableHeaderProps)), /*#__PURE__*/_jsx(VirtualTableBody, _objectSpread({}, tableBodyProps))]
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
export default UnifiedTable;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { TableMaxColumnType } from "../../type";
|
|
2
|
-
export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
3
|
-
export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
4
|
-
export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
5
|
-
export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
2
|
+
export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
3
|
+
export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
4
|
+
export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
5
|
+
export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
6
6
|
declare const customSortFns: {
|
|
7
|
-
numberSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
8
|
-
stringSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
9
|
-
timeSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
10
|
-
numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
7
|
+
numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
8
|
+
stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
9
|
+
timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
10
|
+
numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
11
11
|
};
|
|
12
12
|
export default customSortFns;
|
|
13
13
|
export type SortFnType = keyof typeof customSortFns | undefined;
|
|
@@ -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();
|
|
Binary file
|