@arim-aisdc/public-components 0.0.20 → 0.0.22
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/Row.d.ts +3 -3
- package/dist/components/TableMax/TableBody/Row.js +7 -8
- package/dist/components/TableMax/TableBody/index.d.ts +4 -5
- package/dist/components/TableMax/TableBody/index.js +15 -17
- package/dist/components/TableMax/TableHeader/Cell.d.ts +3 -1
- package/dist/components/TableMax/TableHeader/Cell.js +34 -11
- package/dist/components/TableMax/TableHeader/index.d.ts +3 -2
- package/dist/components/TableMax/TableHeader/index.js +7 -29
- package/dist/components/TableMax/TableHeader/index.less +16 -4
- package/dist/components/TableMax/TableMax.js +157 -238
- package/dist/components/TableMax/tableMax.less +2 -2
- package/dist/components/TableMax/utils.d.ts +9 -2
- package/dist/components/TableMax/utils.js +17 -2
- package/package.json +3 -2
|
@@ -2,7 +2,7 @@ import { OnSelectChangeType } from "../type";
|
|
|
2
2
|
import { Table } from '@tanstack/react-table';
|
|
3
3
|
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
|
4
4
|
import './index.less';
|
|
5
|
-
declare const Row: ({ table, tableId, row, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked, reorderRow,
|
|
5
|
+
declare const Row: ({ tableBodyRef, table, tableId, row, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked, reorderRow, canRowDrag, rowClassName, cellClassName, rowStyle, getCellProps, editting, rowEditing, renderSubComponent, selectedRowDragging, setSelectedRowDragging, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, rowHeight, disableDragRowIds, selectRowWhenClick, handleEditRowWhenDClick, canEditRowWhenDClick, theme, pinShadowVisible, dragBeforeStart, }: {
|
|
6
6
|
table: Table<any>;
|
|
7
7
|
tableId: string;
|
|
8
8
|
row: any;
|
|
@@ -10,7 +10,7 @@ declare const Row: ({ table, tableId, row, rowSelectedId, setRowSelectedId, sele
|
|
|
10
10
|
setRowSelectedId?: Dispatch<SetStateAction<string | undefined>>;
|
|
11
11
|
selectedRowChange?: (row: any) => void;
|
|
12
12
|
onSelectChange?: OnSelectChangeType;
|
|
13
|
-
|
|
13
|
+
tableBodyRef: any;
|
|
14
14
|
canSelection?: boolean;
|
|
15
15
|
selectionWithoutChecked?: boolean;
|
|
16
16
|
reorderRow?: (targetRowIndex: any, draggedRowIndex: any) => void;
|
|
@@ -31,7 +31,7 @@ declare const Row: ({ table, tableId, row, rowSelectedId, setRowSelectedId, sele
|
|
|
31
31
|
onRowMouseClick?: (row: any) => void;
|
|
32
32
|
onRowMouseDoubleClick?: (row: any) => void;
|
|
33
33
|
rowHeight: number;
|
|
34
|
-
disableDragRowIds
|
|
34
|
+
disableDragRowIds?: any[];
|
|
35
35
|
selectRowWhenClick: boolean;
|
|
36
36
|
hasVerticalScrollBar: boolean;
|
|
37
37
|
handleEditRowWhenDClick: (row: any) => void;
|
|
@@ -23,8 +23,9 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
23
23
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
var initselectedIndex;
|
|
25
25
|
var Row = function Row(_ref) {
|
|
26
|
-
var _row, _row2;
|
|
27
|
-
var
|
|
26
|
+
var _row, _row2, _tableBodyRef$current, _tableBodyRef$current2;
|
|
27
|
+
var tableBodyRef = _ref.tableBodyRef,
|
|
28
|
+
table = _ref.table,
|
|
28
29
|
tableId = _ref.tableId,
|
|
29
30
|
row = _ref.row,
|
|
30
31
|
rowSelectedId = _ref.rowSelectedId,
|
|
@@ -34,7 +35,6 @@ var Row = function Row(_ref) {
|
|
|
34
35
|
canSelection = _ref.canSelection,
|
|
35
36
|
selectionWithoutChecked = _ref.selectionWithoutChecked,
|
|
36
37
|
reorderRow = _ref.reorderRow,
|
|
37
|
-
tableContainerWidth = _ref.tableContainerWidth,
|
|
38
38
|
canRowDrag = _ref.canRowDrag,
|
|
39
39
|
rowClassName = _ref.rowClassName,
|
|
40
40
|
cellClassName = _ref.cellClassName,
|
|
@@ -52,7 +52,6 @@ var Row = function Row(_ref) {
|
|
|
52
52
|
rowHeight = _ref.rowHeight,
|
|
53
53
|
disableDragRowIds = _ref.disableDragRowIds,
|
|
54
54
|
selectRowWhenClick = _ref.selectRowWhenClick,
|
|
55
|
-
hasVerticalScrollBar = _ref.hasVerticalScrollBar,
|
|
56
55
|
handleEditRowWhenDClick = _ref.handleEditRowWhenDClick,
|
|
57
56
|
canEditRowWhenDClick = _ref.canEditRowWhenDClick,
|
|
58
57
|
theme = _ref.theme,
|
|
@@ -239,11 +238,11 @@ var Row = function Row(_ref) {
|
|
|
239
238
|
id: rowEditing ? "".concat(tableId, "-tbody-tr-editing") : undefined,
|
|
240
239
|
ref: function ref(node) {
|
|
241
240
|
dropRef(node && !editting ? node : null);
|
|
242
|
-
dragRef(node && canRowDrag && !editting && !disableDragRowIds.includes(row.id) ? node : null);
|
|
241
|
+
dragRef(node && canRowDrag && !editting && !(disableDragRowIds !== null && disableDragRowIds !== void 0 && disableDragRowIds.includes(row.id)) ? node : null);
|
|
243
242
|
},
|
|
244
243
|
style: _objectSpread({
|
|
245
244
|
opacity: isDragging || selectedRowDragging && row.getIsSelected() ? 0.5 : 1,
|
|
246
|
-
cursor: canRowDrag && !editting && !disableDragRowIds.includes(row.id) ? 'move' : 'auto'
|
|
245
|
+
cursor: canRowDrag && !editting && !(disableDragRowIds !== null && disableDragRowIds !== void 0 && disableDragRowIds.includes(row.id)) ? 'move' : 'auto'
|
|
247
246
|
}, rowStyle),
|
|
248
247
|
onClick: rowClickOrDoubleClick,
|
|
249
248
|
onMouseEnter: rowMouseEnter,
|
|
@@ -287,13 +286,13 @@ var Row = function Row(_ref) {
|
|
|
287
286
|
style: {
|
|
288
287
|
padding: 0
|
|
289
288
|
},
|
|
290
|
-
children: !!
|
|
289
|
+
children: !!(tableBodyRef !== null && tableBodyRef !== void 0 && (_tableBodyRef$current = tableBodyRef.current) !== null && _tableBodyRef$current !== void 0 && _tableBodyRef$current.clientWidth) && /*#__PURE__*/_jsx("div", {
|
|
291
290
|
id: "".concat(tableId, "_expand-table"),
|
|
292
291
|
className: "subRowWrapper"
|
|
293
292
|
// 减去10,避免被父表滚动条覆盖
|
|
294
293
|
,
|
|
295
294
|
style: {
|
|
296
|
-
width: "".concat(
|
|
295
|
+
width: "".concat(tableBodyRef === null || tableBodyRef === void 0 || (_tableBodyRef$current2 = tableBodyRef.current) === null || _tableBodyRef$current2 === void 0 ? void 0 : _tableBodyRef$current2.clientWidth, "px")
|
|
297
296
|
},
|
|
298
297
|
children: renderSubComponent && renderSubComponent({
|
|
299
298
|
row: row
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Table } from '@tanstack/react-table';
|
|
2
2
|
import { OnSelectChangeType } from "../type";
|
|
3
|
-
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
|
3
|
+
import { Dispatch, MutableRefObject, ReactNode, SetStateAction } from 'react';
|
|
4
4
|
import './index.less';
|
|
5
5
|
type TableBodyPropsType = {
|
|
6
|
+
tableBodyRef: MutableRefObject<HTMLDivElement> | null;
|
|
7
|
+
tableContentRef: MutableRefObject<HTMLDivElement> | null;
|
|
6
8
|
table: Table<any>;
|
|
7
9
|
tableId: string;
|
|
8
10
|
theme: string;
|
|
@@ -14,9 +16,6 @@ type TableBodyPropsType = {
|
|
|
14
16
|
canFilter: boolean;
|
|
15
17
|
canSelection: boolean;
|
|
16
18
|
selectionWithoutChecked?: boolean;
|
|
17
|
-
tableBodyHeight: number;
|
|
18
|
-
bodyContentHeight: number;
|
|
19
|
-
tableContainerWidth: number;
|
|
20
19
|
selectedRowDragging: boolean;
|
|
21
20
|
setSelectedRowDragging: Dispatch<SetStateAction<boolean>>;
|
|
22
21
|
canRowDrag: boolean;
|
|
@@ -53,5 +52,5 @@ type TableBodyPropsType = {
|
|
|
53
52
|
};
|
|
54
53
|
dragBeforeStart: (datas: any) => boolean;
|
|
55
54
|
};
|
|
56
|
-
declare const TableBody: ({ table, tableId, theme, reorderRow, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked,
|
|
55
|
+
declare const TableBody: ({ tableContentRef, tableBodyRef, table, tableId, theme, reorderRow, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked, selectedRowDragging, setSelectedRowDragging, canRowDrag, rowKey, loading, rowClassName, cellClassName, rowStyle, getCellProps, rowHeight, renderSubComponent, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, disableDragRowIds, selectRowWhenClick, hasVerticalScrollBar, datas, emptyDataHeight, canEditRowWhenDClick, editingRowId, handleEditRowWhenDClick, pinShadowVisible, dragBeforeStart, }: TableBodyPropsType) => import("react/jsx-runtime").JSX.Element;
|
|
57
56
|
export default TableBody;
|
|
@@ -12,16 +12,18 @@ import { useDrop } from 'react-dnd';
|
|
|
12
12
|
import { CustomDragLayer } from "../components/CustomDragerLayer";
|
|
13
13
|
// import RowContent from "../components/RowContent";
|
|
14
14
|
|
|
15
|
-
import { useEffect } from 'react';
|
|
16
15
|
import { createPortal } from 'react-dom';
|
|
16
|
+
import { ColumnType } from "../TableMax";
|
|
17
17
|
import Row from "./Row";
|
|
18
18
|
import "./index.less";
|
|
19
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
21
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
22
|
var TableBody = function TableBody(_ref) {
|
|
23
|
-
var _headerGroups;
|
|
24
|
-
var
|
|
23
|
+
var _tableContentRef$curr, _headerGroups;
|
|
24
|
+
var tableContentRef = _ref.tableContentRef,
|
|
25
|
+
tableBodyRef = _ref.tableBodyRef,
|
|
26
|
+
table = _ref.table,
|
|
25
27
|
tableId = _ref.tableId,
|
|
26
28
|
theme = _ref.theme,
|
|
27
29
|
reorderRow = _ref.reorderRow,
|
|
@@ -31,8 +33,6 @@ var TableBody = function TableBody(_ref) {
|
|
|
31
33
|
onSelectChange = _ref.onSelectChange,
|
|
32
34
|
canSelection = _ref.canSelection,
|
|
33
35
|
selectionWithoutChecked = _ref.selectionWithoutChecked,
|
|
34
|
-
tableBodyHeight = _ref.tableBodyHeight,
|
|
35
|
-
tableContainerWidth = _ref.tableContainerWidth,
|
|
36
36
|
selectedRowDragging = _ref.selectedRowDragging,
|
|
37
37
|
setSelectedRowDragging = _ref.setSelectedRowDragging,
|
|
38
38
|
canRowDrag = _ref.canRowDrag,
|
|
@@ -58,12 +58,8 @@ var TableBody = function TableBody(_ref) {
|
|
|
58
58
|
handleEditRowWhenDClick = _ref.handleEditRowWhenDClick,
|
|
59
59
|
pinShadowVisible = _ref.pinShadowVisible,
|
|
60
60
|
dragBeforeStart = _ref.dragBeforeStart;
|
|
61
|
-
// const tbodyRef = useRef<any>(null);
|
|
62
|
-
// const theadRef = useRef<any>(null);
|
|
63
61
|
var headerGroups = table.getHeaderGroups();
|
|
64
62
|
|
|
65
|
-
// const { rows } = table.getRowModel();
|
|
66
|
-
|
|
67
63
|
// useEffect(() => {
|
|
68
64
|
// if (tbodyRef.current) {
|
|
69
65
|
// console.log('tbodyRef.current.scrollHeight', tbodyRef.current.scrollHeight)
|
|
@@ -164,6 +160,7 @@ var TableBody = function TableBody(_ref) {
|
|
|
164
160
|
_useDrop2 = _slicedToArray(_useDrop, 2),
|
|
165
161
|
dropRef = _useDrop2[1];
|
|
166
162
|
var EmptyContent = function EmptyContent() {
|
|
163
|
+
var _tableBodyRef$current;
|
|
167
164
|
return /*#__PURE__*/_jsx("tr", {
|
|
168
165
|
className: "empty-container",
|
|
169
166
|
style: {
|
|
@@ -172,7 +169,7 @@ var TableBody = function TableBody(_ref) {
|
|
|
172
169
|
children: /*#__PURE__*/_jsx("td", {
|
|
173
170
|
className: "empty-wapper",
|
|
174
171
|
style: {
|
|
175
|
-
width: "".concat(
|
|
172
|
+
width: "".concat(tableBodyRef === null || tableBodyRef === void 0 || (_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 ? void 0 : _tableBodyRef$current.clientWidth, "px"),
|
|
176
173
|
height: emptyDataHeight
|
|
177
174
|
},
|
|
178
175
|
children: loading ? /*#__PURE__*/_jsx(_Spin, {}) : /*#__PURE__*/_jsxs("span", {
|
|
@@ -195,9 +192,9 @@ var TableBody = function TableBody(_ref) {
|
|
|
195
192
|
// 当前行是否编辑中
|
|
196
193
|
var rowEditing = row.id === editingRowId;
|
|
197
194
|
return /*#__PURE__*/_jsx(Row, {
|
|
195
|
+
tableBodyRef: tableBodyRef,
|
|
198
196
|
table: table,
|
|
199
197
|
tableId: tableId,
|
|
200
|
-
tableContainerWidth: tableContainerWidth,
|
|
201
198
|
row: row,
|
|
202
199
|
rowKey: rowKey,
|
|
203
200
|
theme: theme,
|
|
@@ -234,14 +231,12 @@ var TableBody = function TableBody(_ref) {
|
|
|
234
231
|
});
|
|
235
232
|
};
|
|
236
233
|
var tbodyRender = function tbodyRender() {
|
|
237
|
-
|
|
234
|
+
var _table$getRowModel$ro;
|
|
235
|
+
if (!loading && datas.length !== 0 && ((_table$getRowModel$ro = table.getRowModel().rows) === null || _table$getRowModel$ro === void 0 ? void 0 : _table$getRowModel$ro.length) !== 0) {
|
|
238
236
|
return TBodyContent();
|
|
239
237
|
}
|
|
240
238
|
return EmptyContent();
|
|
241
239
|
};
|
|
242
|
-
useEffect(function () {
|
|
243
|
-
console.log(tableBodyHeight, 'tableBodyHeight*******************');
|
|
244
|
-
}, [tableBodyHeight]);
|
|
245
240
|
return (
|
|
246
241
|
/*#__PURE__*/
|
|
247
242
|
// 修复筛选数据为空时,滚动条丢失
|
|
@@ -256,11 +251,14 @@ var TableBody = function TableBody(_ref) {
|
|
|
256
251
|
table: table,
|
|
257
252
|
tableId: tableId
|
|
258
253
|
}), document.body), /*#__PURE__*/_jsxs("table", {
|
|
254
|
+
style: {
|
|
255
|
+
width: "".concat(((_tableContentRef$curr = tableContentRef.current) === null || _tableContentRef$curr === void 0 ? void 0 : _tableContentRef$curr.clientWidth) - (hasVerticalScrollBar ? 10 : 0), "px")
|
|
256
|
+
},
|
|
259
257
|
children: [/*#__PURE__*/_jsx("colgroup", {
|
|
260
258
|
children: headerGroups === null || headerGroups === void 0 || (_headerGroups = headerGroups[headerGroups.length - 1]) === null || _headerGroups === void 0 || (_headerGroups = _headerGroups.headers) === null || _headerGroups === void 0 ? void 0 : _headerGroups.map(function (header) {
|
|
261
|
-
var _header$column;
|
|
259
|
+
var _header$column, _header$column2;
|
|
262
260
|
return /*#__PURE__*/_jsx("col", {
|
|
263
|
-
width: (header === null || header === void 0 || (_header$column = header.column) === null || _header$column === void 0 ? void 0 : _header$column.getSize()) || 80
|
|
261
|
+
width: header.id !== ColumnType.PlaceHolder ? (header === null || header === void 0 || (_header$column = header.column) === null || _header$column === void 0 ? void 0 : _header$column.getSize()) || 80 : header === null || header === void 0 || (_header$column2 = header.column) === null || _header$column2 === void 0 ? void 0 : _header$column2.columnDef.size
|
|
264
262
|
}, header.id);
|
|
265
263
|
})
|
|
266
264
|
}), /*#__PURE__*/_jsx("tbody", {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { TableMaxColumnType } from "../type";
|
|
2
2
|
import { ColumnResizeMode, Header, Table } from '@tanstack/react-table';
|
|
3
|
+
import { MutableRefObject } from 'react';
|
|
3
4
|
import './index.less';
|
|
4
5
|
type ICellType = {
|
|
6
|
+
tableContentRef: MutableRefObject<HTMLDivElement> | null;
|
|
5
7
|
header: Header<TableMaxColumnType, unknown>;
|
|
6
8
|
table: Table<TableMaxColumnType>;
|
|
7
9
|
hasGroup?: boolean;
|
|
@@ -9,5 +11,5 @@ type ICellType = {
|
|
|
9
11
|
getHeaderCellProps?: (columns: TableMaxColumnType[]) => object;
|
|
10
12
|
columnResizeMode: ColumnResizeMode;
|
|
11
13
|
};
|
|
12
|
-
declare const Cell: ({ header, table, hasGroup, canSorting, getHeaderCellProps
|
|
14
|
+
declare const Cell: ({ tableContentRef, header, table, hasGroup, canSorting, getHeaderCellProps }: ICellType) => import("react/jsx-runtime").JSX.Element;
|
|
13
15
|
export default Cell;
|
|
@@ -18,8 +18,9 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
|
|
|
18
18
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
19
19
|
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; }
|
|
20
20
|
import { flexRender } from '@tanstack/react-table';
|
|
21
|
-
import { useMemo } from 'react';
|
|
21
|
+
import { useMemo, useState } from 'react';
|
|
22
22
|
import { useDrag, useDrop } from 'react-dnd';
|
|
23
|
+
import { createPortal } from 'react-dom';
|
|
23
24
|
import { ColumnType } from "../TableMax";
|
|
24
25
|
import Sort from "../components/ColumnSort";
|
|
25
26
|
import "./index.less";
|
|
@@ -30,12 +31,13 @@ var reorderColumn = function reorderColumn(draggedColumnId, targetColumnId, colu
|
|
|
30
31
|
return _toConsumableArray(columnOrder);
|
|
31
32
|
};
|
|
32
33
|
var Cell = function Cell(_ref) {
|
|
33
|
-
var
|
|
34
|
+
var _tableContentRef$curr;
|
|
35
|
+
var tableContentRef = _ref.tableContentRef,
|
|
36
|
+
header = _ref.header,
|
|
34
37
|
table = _ref.table,
|
|
35
38
|
hasGroup = _ref.hasGroup,
|
|
36
39
|
canSorting = _ref.canSorting,
|
|
37
|
-
getHeaderCellProps = _ref.getHeaderCellProps
|
|
38
|
-
columnResizeMode = _ref.columnResizeMode;
|
|
40
|
+
getHeaderCellProps = _ref.getHeaderCellProps;
|
|
39
41
|
var cannotDragColumn = [ColumnType.Darg, ColumnType.Selection, ColumnType.Expander, ColumnType.PlaceHolder];
|
|
40
42
|
var getState = table.getState,
|
|
41
43
|
setColumnOrder = table.setColumnOrder;
|
|
@@ -72,14 +74,30 @@ var Cell = function Cell(_ref) {
|
|
|
72
74
|
var columns = useMemo(function () {
|
|
73
75
|
return columnDef.columns;
|
|
74
76
|
}, [header]);
|
|
75
|
-
|
|
77
|
+
var _useState = useState({
|
|
78
|
+
x: 0,
|
|
79
|
+
y: 0
|
|
80
|
+
}),
|
|
81
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
82
|
+
initPosition = _useState2[0],
|
|
83
|
+
setInitPosition = _useState2[1];
|
|
84
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
76
85
|
ref: dropRef,
|
|
77
|
-
children: /*#__PURE__*/_jsxs("div", {
|
|
86
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
78
87
|
className: "cell-wapper ".concat(columns ? 'wapper-top-parent' : '', " table-max-header-cell-wrapper"),
|
|
79
88
|
ref: previewRef,
|
|
80
89
|
style: _objectSpread({
|
|
81
90
|
transform: header.column.parent || columns || !hasGroup ? 'translateY(0px)' : 'translateY(-20px)'
|
|
82
91
|
}, getHeaderCellProps === null || getHeaderCellProps === void 0 ? void 0 : getHeaderCellProps(columns)),
|
|
92
|
+
onMouseDown: function onMouseDown(e) {
|
|
93
|
+
var elem = tableContentRef === null || tableContentRef === void 0 ? void 0 : tableContentRef.current;
|
|
94
|
+
var clientRect = elem === null || elem === void 0 ? void 0 : elem.getBoundingClientRect();
|
|
95
|
+
var y = clientRect === null || clientRect === void 0 ? void 0 : clientRect.top;
|
|
96
|
+
setInitPosition({
|
|
97
|
+
x: e.clientX,
|
|
98
|
+
y: y
|
|
99
|
+
});
|
|
100
|
+
},
|
|
83
101
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
84
102
|
className: "cell-left",
|
|
85
103
|
onClick: header.column.getToggleSortingHandler(),
|
|
@@ -113,12 +131,17 @@ var Cell = function Cell(_ref) {
|
|
|
113
131
|
}), /*#__PURE__*/_jsx("div", {
|
|
114
132
|
className: "cell-resize-handler ".concat(header.column.getIsResizing() ? 'column-is-resizing' : ''),
|
|
115
133
|
onMouseDown: header.getResizeHandler(),
|
|
116
|
-
onTouchStart: header.getResizeHandler()
|
|
117
|
-
style: {
|
|
118
|
-
transform: columnResizeMode === 'onEnd' && header.column.getIsResizing() ? "translateX(".concat(table.getState().columnSizingInfo.deltaOffset, "px)") : ''
|
|
119
|
-
}
|
|
134
|
+
onTouchStart: header.getResizeHandler()
|
|
120
135
|
})]
|
|
121
|
-
})
|
|
136
|
+
}), header.column.getIsResizing() ? /*#__PURE__*/createPortal( /*#__PURE__*/_jsx("div", {
|
|
137
|
+
className: 'column-resizing-divide-line',
|
|
138
|
+
style: {
|
|
139
|
+
left: initPosition.x,
|
|
140
|
+
top: initPosition.y,
|
|
141
|
+
height: (_tableContentRef$curr = tableContentRef.current) === null || _tableContentRef$curr === void 0 ? void 0 : _tableContentRef$curr.clientHeight,
|
|
142
|
+
transform: "translateX(".concat(table.getState().columnSizingInfo.deltaOffset || 0, "px)")
|
|
143
|
+
}
|
|
144
|
+
}), document.body) : null]
|
|
122
145
|
});
|
|
123
146
|
};
|
|
124
147
|
export default Cell;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { ColumnResizeMode } from '@tanstack/react-table';
|
|
2
|
+
import { MutableRefObject } from 'react';
|
|
2
3
|
import { TableMaxColumnType } from '../type';
|
|
3
4
|
import './index.less';
|
|
4
5
|
type TableHeaderProps = {
|
|
5
6
|
table: any;
|
|
7
|
+
tableContentRef: MutableRefObject<HTMLDivElement> | null;
|
|
6
8
|
canFilter?: boolean;
|
|
7
9
|
enableFilters?: boolean;
|
|
8
10
|
canSorting?: boolean;
|
|
9
11
|
rowHeight?: number;
|
|
10
12
|
hasGroup?: boolean;
|
|
11
|
-
headerGroups?: any[];
|
|
12
13
|
hasVerticalScrollBar: boolean;
|
|
13
14
|
getHeaderCellProps?: (columns: TableMaxColumnType[]) => object;
|
|
14
15
|
columnResizeMode: ColumnResizeMode;
|
|
@@ -17,5 +18,5 @@ type TableHeaderProps = {
|
|
|
17
18
|
right: boolean;
|
|
18
19
|
};
|
|
19
20
|
};
|
|
20
|
-
declare const TableHeader: ({
|
|
21
|
+
declare const TableHeader: ({ tableContentRef, table, canFilter, enableFilters, canSorting, hasGroup, hasVerticalScrollBar, getHeaderCellProps, columnResizeMode, pinShadowVisible, }: TableHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
22
|
export default TableHeader;
|
|
@@ -8,6 +8,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
8
8
|
// import { useDrag, useDrop } from 'ahooks';
|
|
9
9
|
|
|
10
10
|
import { useMemo } from 'react';
|
|
11
|
+
import { ColumnType } from "../TableMax";
|
|
11
12
|
import { Filter } from "../components/ColumnFilter";
|
|
12
13
|
import { getShadowInfo } from "../utils";
|
|
13
14
|
import Cell from "./Cell";
|
|
@@ -17,8 +18,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
17
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
19
|
var TableHeader = function TableHeader(_ref) {
|
|
19
20
|
var _headerGroups, _headerGroups2;
|
|
20
|
-
var
|
|
21
|
-
|
|
21
|
+
var tableContentRef = _ref.tableContentRef,
|
|
22
|
+
table = _ref.table,
|
|
22
23
|
canFilter = _ref.canFilter,
|
|
23
24
|
enableFilters = _ref.enableFilters,
|
|
24
25
|
canSorting = _ref.canSorting,
|
|
@@ -31,37 +32,13 @@ var TableHeader = function TableHeader(_ref) {
|
|
|
31
32
|
var columnPinning = table.getState().columnPinning;
|
|
32
33
|
return JSON.stringify(columnPinning.left) !== '[]' || JSON.stringify(columnPinning.right) !== '[]' ? true : false;
|
|
33
34
|
}, [table.getState().columnPinning]);
|
|
34
|
-
|
|
35
|
-
// useEffect(() => {
|
|
36
|
-
// console.log(hasVerticalScrollBar, '********************hasVerticalScrollBar====================');
|
|
37
|
-
// }, [hasVerticalScrollBar]);
|
|
38
|
-
|
|
39
|
-
// const [headerGroups, setHeaderGroups] = useState([])
|
|
40
|
-
|
|
41
|
-
// useEffect(() => {
|
|
42
|
-
// console.log(7777)
|
|
43
|
-
// setHeaderGroups([
|
|
44
|
-
// ...(table.getCenterHeaderGroups() || []),
|
|
45
|
-
// ...(table.getRightHeaderGroups() || [])]
|
|
46
|
-
// )
|
|
47
|
-
// }, [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()])
|
|
48
|
-
|
|
49
|
-
// console.log(666, table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups())
|
|
50
|
-
|
|
51
|
-
// console.log(
|
|
52
|
-
// 'header',
|
|
53
|
-
// table.getLeftHeaderGroups(),
|
|
54
|
-
// table.getCenterHeaderGroups(),
|
|
55
|
-
// table.getRightHeaderGroups(),
|
|
56
|
-
// table.getHeaderGroups(),
|
|
57
|
-
// );
|
|
58
|
-
|
|
35
|
+
var headerGroups = table.getHeaderGroups();
|
|
59
36
|
return /*#__PURE__*/_jsxs("table", {
|
|
60
37
|
children: [/*#__PURE__*/_jsxs("colgroup", {
|
|
61
38
|
children: [headerGroups === null || headerGroups === void 0 || (_headerGroups = headerGroups[headerGroups.length - 1]) === null || _headerGroups === void 0 || (_headerGroups = _headerGroups.headers) === null || _headerGroups === void 0 ? void 0 : _headerGroups.map(function (header) {
|
|
62
|
-
var _header$column;
|
|
39
|
+
var _header$column, _header$column2;
|
|
63
40
|
return /*#__PURE__*/_jsx("col", {
|
|
64
|
-
width: (header === null || header === void 0 || (_header$column = header.column) === null || _header$column === void 0 ? void 0 : _header$column.getSize()) || 80
|
|
41
|
+
width: header.id !== ColumnType.PlaceHolder ? (header === null || header === void 0 || (_header$column = header.column) === null || _header$column === void 0 ? void 0 : _header$column.getSize()) || 80 : header === null || header === void 0 || (_header$column2 = header.column) === null || _header$column2 === void 0 ? void 0 : _header$column2.columnDef.size
|
|
65
42
|
}, header.id);
|
|
66
43
|
}), hasVerticalScrollBar ? /*#__PURE__*/_jsx("col", {
|
|
67
44
|
width: 10
|
|
@@ -84,6 +61,7 @@ var TableHeader = function TableHeader(_ref) {
|
|
|
84
61
|
style: _objectSpread({}, getPinningStyle(header, table, hasVerticalScrollBar)),
|
|
85
62
|
className: "".concat(isLeftLast && pinShadowVisible.left ? 'thead-tr-th-cell-fix-left-last' : '', " ").concat(isRightFirst && pinShadowVisible.right ? 'thead-tr-th-cell-fix-right-first' : ''),
|
|
86
63
|
children: header.isPlaceholder || header.id === 'placeholder-column' ? null : /*#__PURE__*/_jsx(Cell, {
|
|
64
|
+
tableContentRef: tableContentRef,
|
|
87
65
|
header: header,
|
|
88
66
|
table: table,
|
|
89
67
|
hasGroup: hasGroup,
|
|
@@ -10,6 +10,7 @@ table {
|
|
|
10
10
|
padding: 0;
|
|
11
11
|
border: 0;
|
|
12
12
|
background: @globalColor_14;
|
|
13
|
+
z-index: 1;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
.th-scroll {
|
|
@@ -26,7 +27,7 @@ table {
|
|
|
26
27
|
font-weight: 400;
|
|
27
28
|
padding: 0 8px;
|
|
28
29
|
text-align: left;
|
|
29
|
-
border-bottom: 1px solid @tableColor2;
|
|
30
|
+
// border-bottom: 1px solid @tableColor2;
|
|
30
31
|
|
|
31
32
|
.cell-left {
|
|
32
33
|
flex: 1;
|
|
@@ -73,11 +74,13 @@ table {
|
|
|
73
74
|
cursor: ew-resize;
|
|
74
75
|
user-select: none;
|
|
75
76
|
touch-action: none;
|
|
77
|
+
z-index: 99999;
|
|
76
78
|
|
|
77
79
|
&:hover {
|
|
78
|
-
border-right:
|
|
79
|
-
top:
|
|
80
|
-
height:
|
|
80
|
+
border-right: 5px solid @globalColor_15;
|
|
81
|
+
top: 0%;
|
|
82
|
+
height: 100%;
|
|
83
|
+
z-index: 99999;
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
|
|
@@ -185,3 +188,12 @@ table {
|
|
|
185
188
|
}
|
|
186
189
|
}
|
|
187
190
|
}
|
|
191
|
+
|
|
192
|
+
.column-resizing-divide-line {
|
|
193
|
+
height: 300px;
|
|
194
|
+
width: 2px;
|
|
195
|
+
position: fixed;
|
|
196
|
+
z-index: 99999;
|
|
197
|
+
background-color: #000;
|
|
198
|
+
}
|
|
199
|
+
|
|
@@ -29,9 +29,10 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
29
29
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
30
30
|
import { MinusSquareOutlined, PlusSquareOutlined } from '@ant-design/icons';
|
|
31
31
|
import { getCoreRowModel, getExpandedRowModel, getFacetedUniqueValues, getFilteredRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
|
|
32
|
+
import { produce } from 'immer';
|
|
32
33
|
import { cloneDeep } from 'lodash';
|
|
33
34
|
import moment from 'moment';
|
|
34
|
-
import React, { createContext, useCallback, useEffect, useImperativeHandle,
|
|
35
|
+
import React, { createContext, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
35
36
|
import { DndProvider } from 'react-dnd';
|
|
36
37
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
37
38
|
import TableBody from "./TableBody";
|
|
@@ -54,7 +55,7 @@ export var ColumnType = /*#__PURE__*/function (ColumnType) {
|
|
|
54
55
|
}({});
|
|
55
56
|
export var TableContext = /*#__PURE__*/createContext({});
|
|
56
57
|
var TableMax = function TableMax(_ref) {
|
|
57
|
-
var _JSON$parse,
|
|
58
|
+
var _JSON$parse, _tableBodyRef$current3, _tableBodyRef$current4, _tableContentRef$curr2, _tableContentRef$curr3;
|
|
58
59
|
var tableId = _ref.tableId,
|
|
59
60
|
originColumns = _ref.columns,
|
|
60
61
|
_ref$datas = _ref.datas,
|
|
@@ -84,7 +85,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
84
85
|
_ref$defaultScrollY = _ref.defaultScrollY,
|
|
85
86
|
defaultScrollY = _ref$defaultScrollY === void 0 ? 600 : _ref$defaultScrollY,
|
|
86
87
|
_ref$columnResizeMode = _ref.columnResizeMode,
|
|
87
|
-
columnResizeMode = _ref$columnResizeMode === void 0 ? '
|
|
88
|
+
columnResizeMode = _ref$columnResizeMode === void 0 ? 'onEnd' : _ref$columnResizeMode,
|
|
88
89
|
rowKey = _ref.rowKey,
|
|
89
90
|
refreshFun = _ref.refreshFun,
|
|
90
91
|
deleteFun = _ref.deleteFun,
|
|
@@ -156,8 +157,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
156
157
|
_ref$enableVirtualLis = _ref.enableVirtualList,
|
|
157
158
|
enableVirtualList = _ref$enableVirtualLis === void 0 ? false : _ref$enableVirtualLis,
|
|
158
159
|
onRowCheckboxClick = _ref.onRowCheckboxClick,
|
|
159
|
-
|
|
160
|
-
disableDragRowIds = _ref$disableDragRowId === void 0 ? [] : _ref$disableDragRowId,
|
|
160
|
+
disableDragRowIds = _ref.disableDragRowIds,
|
|
161
161
|
_ref$selectRowWhenCli = _ref.selectRowWhenClick,
|
|
162
162
|
selectRowWhenClick = _ref$selectRowWhenCli === void 0 ? true : _ref$selectRowWhenCli,
|
|
163
163
|
_ref$autoHeight = _ref.autoHeight,
|
|
@@ -194,57 +194,61 @@ var TableMax = function TableMax(_ref) {
|
|
|
194
194
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
195
195
|
tableColumns = _useState4[0],
|
|
196
196
|
setTableColumns = _useState4[1];
|
|
197
|
-
|
|
198
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
199
|
-
initTableSizeColumns = _useState6[0],
|
|
200
|
-
setInitTableSizeColumns = _useState6[1];
|
|
197
|
+
// const [initTableSizeColumns, setInitTableSizeColumns] = useState([...columns]);
|
|
201
198
|
/**列显隐 */
|
|
199
|
+
var _useState5 = useState(),
|
|
200
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
201
|
+
columnVisibility = _useState6[0],
|
|
202
|
+
setColumnVisibility = _useState6[1];
|
|
203
|
+
/**列拖动顺序 */
|
|
202
204
|
var _useState7 = useState(),
|
|
203
205
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
/**列拖动顺序 */
|
|
207
|
-
var _useState9 = useState(),
|
|
208
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
209
|
-
columnOrder = _useState10[0],
|
|
210
|
-
setColumnOrder = _useState10[1];
|
|
206
|
+
columnOrder = _useState8[0],
|
|
207
|
+
setColumnOrder = _useState8[1];
|
|
211
208
|
/**列排序 */
|
|
212
|
-
var
|
|
213
|
-
|
|
214
|
-
sorting =
|
|
215
|
-
setSorting =
|
|
209
|
+
var _useState9 = useState([]),
|
|
210
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
211
|
+
sorting = _useState10[0],
|
|
212
|
+
setSorting = _useState10[1];
|
|
216
213
|
/**行选中 */
|
|
217
|
-
var
|
|
218
|
-
|
|
219
|
-
rowSelectedId =
|
|
220
|
-
setRowSelectedId =
|
|
214
|
+
var _useState11 = useState(defaultSelectedRowId),
|
|
215
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
216
|
+
rowSelectedId = _useState12[0],
|
|
217
|
+
setRowSelectedId = _useState12[1];
|
|
221
218
|
/**行勾选 */
|
|
222
|
-
var
|
|
219
|
+
var _useState13 = useState(defaultSelectedRowIds.reduce(function (accumulator, currentValue) {
|
|
223
220
|
accumulator[currentValue] = true;
|
|
224
221
|
return accumulator;
|
|
225
222
|
}, {})),
|
|
226
|
-
|
|
227
|
-
rowSelection =
|
|
228
|
-
setRowSelection =
|
|
223
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
224
|
+
rowSelection = _useState14[0],
|
|
225
|
+
setRowSelection = _useState14[1];
|
|
229
226
|
/**列固定 */
|
|
230
|
-
var
|
|
231
|
-
|
|
232
|
-
columnPinning =
|
|
233
|
-
setColumnPinning =
|
|
227
|
+
var _useState15 = useState(columnPinningConfig),
|
|
228
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
229
|
+
columnPinning = _useState16[0],
|
|
230
|
+
setColumnPinning = _useState16[1];
|
|
234
231
|
/**列宽 */
|
|
235
232
|
// const [columnSizes, setColumnSizes] = useState();
|
|
236
|
-
|
|
233
|
+
var _useState17 = useState({}),
|
|
234
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
235
|
+
columnSizing = _useState18[0],
|
|
236
|
+
setColumnSizing = _useState18[1];
|
|
237
|
+
var _useState19 = useState({}),
|
|
238
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
239
|
+
initColumnsSizing = _useState20[0],
|
|
240
|
+
setInitColumnsSizing = _useState20[1];
|
|
237
241
|
|
|
238
242
|
// const [visibleColumnSizes, setVisibleColumnSizes] = useState([]);
|
|
239
243
|
/**列筛选 */
|
|
240
|
-
var
|
|
241
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
242
|
-
columnFilters = _useState20[0],
|
|
243
|
-
setColumnFilters = _useState20[1];
|
|
244
|
-
var _useState21 = useState(''),
|
|
244
|
+
var _useState21 = useState(defaultColumnFilters),
|
|
245
245
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
columnFilters = _useState22[0],
|
|
247
|
+
setColumnFilters = _useState22[1];
|
|
248
|
+
var _useState23 = useState(''),
|
|
249
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
250
|
+
globalFilter = _useState24[0],
|
|
251
|
+
setGlobalFilter = _useState24[1];
|
|
248
252
|
/**分页 */
|
|
249
253
|
var pagination = useMemo(function () {
|
|
250
254
|
return typeof skipCount === 'number' && pageSize ? {
|
|
@@ -253,43 +257,43 @@ var TableMax = function TableMax(_ref) {
|
|
|
253
257
|
} : undefined;
|
|
254
258
|
}, [skipCount, pageSize]);
|
|
255
259
|
/**是否有分组 */
|
|
256
|
-
var _useState23 = useState(false),
|
|
257
|
-
_useState24 = _slicedToArray(_useState23, 2),
|
|
258
|
-
hasGroup = _useState24[0],
|
|
259
|
-
setHasGroup = _useState24[1];
|
|
260
|
-
|
|
261
|
-
/**是否正在多行拖拽 */
|
|
262
260
|
var _useState25 = useState(false),
|
|
263
261
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
hasGroup = _useState26[0],
|
|
263
|
+
setHasGroup = _useState26[1];
|
|
266
264
|
|
|
267
|
-
|
|
268
|
-
var _useState27 = useState(
|
|
265
|
+
/**是否正在多行拖拽 */
|
|
266
|
+
var _useState27 = useState(false),
|
|
269
267
|
_useState28 = _slicedToArray(_useState27, 2),
|
|
270
|
-
|
|
271
|
-
|
|
268
|
+
selectedRowDragging = _useState28[0],
|
|
269
|
+
setSelectedRowDragging = _useState28[1];
|
|
270
|
+
|
|
271
|
+
/**显示筛选开关状态 */
|
|
272
|
+
var _useState29 = useState(defaultEnableFilters),
|
|
273
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
|
274
|
+
enableFilters = _useState30[0],
|
|
275
|
+
setEnableFilters = _useState30[1];
|
|
272
276
|
var _Form$useForm = _Form.useForm(),
|
|
273
277
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
274
278
|
form = _Form$useForm2[0];
|
|
275
279
|
/**正在编辑的行id*/
|
|
276
|
-
var
|
|
277
|
-
|
|
278
|
-
editingRowId =
|
|
279
|
-
setEditingRowId =
|
|
280
|
+
var _useState31 = useState(''),
|
|
281
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
|
282
|
+
editingRowId = _useState32[0],
|
|
283
|
+
setEditingRowId = _useState32[1];
|
|
280
284
|
var _React$useState = React.useState({}),
|
|
281
285
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
282
286
|
expanded = _React$useState2[0],
|
|
283
287
|
setExpanded = _React$useState2[1];
|
|
284
288
|
|
|
285
289
|
// 固定列是否显示阴影
|
|
286
|
-
var
|
|
290
|
+
var _useState33 = useState({
|
|
287
291
|
left: false,
|
|
288
292
|
right: false
|
|
289
293
|
}),
|
|
290
|
-
|
|
291
|
-
pinShadowVisible =
|
|
292
|
-
setPinShadowVisible =
|
|
294
|
+
_useState34 = _slicedToArray(_useState33, 2),
|
|
295
|
+
pinShadowVisible = _useState34[0],
|
|
296
|
+
setPinShadowVisible = _useState34[1];
|
|
293
297
|
|
|
294
298
|
// table
|
|
295
299
|
var table = useReactTable({
|
|
@@ -313,10 +317,9 @@ var TableMax = function TableMax(_ref) {
|
|
|
313
317
|
columnFilters: columnFilters,
|
|
314
318
|
globalFilter: globalFilter,
|
|
315
319
|
rowSelection: rowSelection,
|
|
316
|
-
expanded: expanded
|
|
317
|
-
|
|
320
|
+
expanded: expanded,
|
|
321
|
+
columnSizing: columnSizing
|
|
318
322
|
},
|
|
319
|
-
|
|
320
323
|
onColumnVisibilityChange: setColumnVisibility,
|
|
321
324
|
onColumnOrderChange: setColumnOrder,
|
|
322
325
|
onColumnPinningChange: setColumnPinning,
|
|
@@ -326,6 +329,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
326
329
|
getFacetedUniqueValues: getFacetedUniqueValues(),
|
|
327
330
|
getFilteredRowModel: getFilteredRowModel(),
|
|
328
331
|
onGlobalFilterChange: setGlobalFilter,
|
|
332
|
+
onColumnSizingChange: setColumnSizing,
|
|
329
333
|
// setColumnSizing,
|
|
330
334
|
manualPagination: true,
|
|
331
335
|
manualSorting: manualSorting,
|
|
@@ -353,44 +357,14 @@ var TableMax = function TableMax(_ref) {
|
|
|
353
357
|
var tableBodyRef = useRef(null);
|
|
354
358
|
|
|
355
359
|
/**表格容器宽度 */
|
|
356
|
-
var
|
|
357
|
-
_useState34 = _slicedToArray(_useState33, 2),
|
|
358
|
-
tableContainerWidth = _useState34[0],
|
|
359
|
-
setTableContainerWidth = _useState34[1];
|
|
360
|
-
var _useState35 = useState(0),
|
|
360
|
+
var _useState35 = useState(),
|
|
361
361
|
_useState36 = _slicedToArray(_useState35, 2),
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
var _useState37 = useState(
|
|
362
|
+
tableContainerWidth = _useState36[0],
|
|
363
|
+
setTableContainerWidth = _useState36[1];
|
|
364
|
+
var _useState37 = useState(false),
|
|
365
365
|
_useState38 = _slicedToArray(_useState37, 2),
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
/**table-head高度 */
|
|
370
|
-
useEffect(function () {
|
|
371
|
-
var _tableHeaderRef$curre;
|
|
372
|
-
setTableHeadHeight(tableHeaderRef === null || tableHeaderRef === void 0 || (_tableHeaderRef$curre = tableHeaderRef.current) === null || _tableHeaderRef$curre === void 0 ? void 0 : _tableHeaderRef$curre.clientHeight);
|
|
373
|
-
}, [tableHeaderRef === null || tableHeaderRef === void 0 || (_tableHeaderRef$curre2 = tableHeaderRef.current) === null || _tableHeaderRef$curre2 === void 0 ? void 0 : _tableHeaderRef$curre2.clientHeight, enableFilters]);
|
|
374
|
-
|
|
375
|
-
/**table-body高度 */
|
|
376
|
-
useEffect(function () {
|
|
377
|
-
var _tableContentRef$curr, _tableContentRef$curr2;
|
|
378
|
-
var horizontalScrollHeight = table.getTotalSize() > (tableContentRef === null || tableContentRef === void 0 || (_tableContentRef$curr = tableContentRef.current) === null || _tableContentRef$curr === void 0 ? void 0 : _tableContentRef$curr.offsetWidth) ? 10 : 0;
|
|
379
|
-
setTableBodyHeight(autoHeight ? (tableContentRef === null || tableContentRef === void 0 || (_tableContentRef$curr2 = tableContentRef.current) === null || _tableContentRef$curr2 === void 0 ? void 0 : _tableContentRef$curr2.clientHeight) - tableHeadHeight - horizontalScrollHeight : defaultScrollY - tableHeadHeight - horizontalScrollHeight);
|
|
380
|
-
}, [table.getTotalSize(), defaultScrollY, autoHeight, tableContentRef === null || tableContentRef === void 0 ? void 0 : tableContentRef.current, tableContentRef === null || tableContentRef === void 0 || (_tableContentRef$curr3 = tableContentRef.current) === null || _tableContentRef$curr3 === void 0 ? void 0 : _tableContentRef$curr3.clientHeight, tableHeadHeight]);
|
|
381
|
-
|
|
382
|
-
/**table-body-content 高度 */
|
|
383
|
-
var bodyContentHeight = useMemo(function () {
|
|
384
|
-
return datas.length * Number(rowHeight);
|
|
385
|
-
}, [datas.length, rowHeight]);
|
|
386
|
-
var hasVerticalScrollBar = useMemo(function () {
|
|
387
|
-
return tableBodyHeight - bodyContentHeight + 10 < 0;
|
|
388
|
-
}, [tableBodyHeight, bodyContentHeight]);
|
|
389
|
-
|
|
390
|
-
// const tableViewWidth = useMemo(
|
|
391
|
-
// () => table.getTotalSize() + (hasVerticalScrollBar ? 10 : 0),
|
|
392
|
-
// [table.getTotalSize(), hasVerticalScrollBar],
|
|
393
|
-
// );
|
|
366
|
+
hasVerticalScrollBar = _useState38[0],
|
|
367
|
+
setHasVerticalScrollBar = _useState38[1];
|
|
394
368
|
|
|
395
369
|
// 暴露给外部的api
|
|
396
370
|
useImperativeHandle(refInstance, function () {
|
|
@@ -435,16 +409,15 @@ var TableMax = function TableMax(_ref) {
|
|
|
435
409
|
cacheColumnPinning = cache.columnPinning,
|
|
436
410
|
cacheColumnFilters = cache.columnFilters,
|
|
437
411
|
cacheColumnSorting = cache.columnSorting,
|
|
438
|
-
cacheEnableFilters = cache.enableFilters
|
|
412
|
+
cacheEnableFilters = cache.enableFilters,
|
|
413
|
+
cacheColumnSizing = cache.columnSizing;
|
|
439
414
|
// if (cacheColumnVisibility) {
|
|
440
415
|
setColumnVisibility(_objectSpread(_objectSpread({}, columnVisibleConfig), cacheColumnVisibility));
|
|
441
416
|
// }
|
|
442
417
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
// });
|
|
447
|
-
// }
|
|
418
|
+
if (cacheColumnSizing) {
|
|
419
|
+
setColumnSizing(_objectSpread({}, cacheColumnSizing));
|
|
420
|
+
}
|
|
448
421
|
|
|
449
422
|
// 筛选项缓存&排序缓存
|
|
450
423
|
var tableColumnIds = tableColumns === null || tableColumns === void 0 ? void 0 : tableColumns.map(function (column) {
|
|
@@ -482,6 +455,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
482
455
|
}
|
|
483
456
|
setColumnOrder(arr);
|
|
484
457
|
};
|
|
458
|
+
|
|
485
459
|
// 初始化columns
|
|
486
460
|
var columnSizeInfo = useMemo(function () {
|
|
487
461
|
var _localStorage$getItem2, _table$getState;
|
|
@@ -550,109 +524,91 @@ var TableMax = function TableMax(_ref) {
|
|
|
550
524
|
var cache = JSON.parse((_localStorage$getItem2 = localStorage.getItem(tableKey)) !== null && _localStorage$getItem2 !== void 0 ? _localStorage$getItem2 : '{}');
|
|
551
525
|
var cacheColumnSizing = cache.columnSizing;
|
|
552
526
|
var newColumnSizes = _objectSpread(_objectSpread({}, cacheColumnSizing), table === null || table === void 0 || (_table$getState = table.getState()) === null || _table$getState === void 0 ? void 0 : _table$getState.columnSizing);
|
|
553
|
-
var
|
|
527
|
+
var _setInitColumnsSize = setInitColumnsSize(columns, newColumnSizes),
|
|
528
|
+
columnsSizeMap = _setInitColumnsSize.columnsSizeMap,
|
|
529
|
+
newColumns = _setInitColumnsSize.tableColumns;
|
|
554
530
|
setHasGroup(newColumns.findIndex(function (column) {
|
|
555
531
|
var _column$columns;
|
|
556
532
|
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;
|
|
557
533
|
}) > -1);
|
|
558
|
-
setInitTableSizeColumns(
|
|
534
|
+
// setInitTableSizeColumns([...newColumns]);
|
|
559
535
|
getCacheColumnInfo(newColumns);
|
|
536
|
+
setInitColumnsSizing(columnsSizeMap);
|
|
537
|
+
setColumnSizing(columnsSizeMap);
|
|
560
538
|
setTableColumns(cloneDeep(newColumns));
|
|
561
539
|
return getSizeInfo(newColumns);
|
|
562
540
|
}, [columns]);
|
|
563
|
-
|
|
564
|
-
// 剩余宽度
|
|
565
|
-
var emptyColumnWidth = useMemo(function () {
|
|
566
|
-
var _document$getElementB;
|
|
567
|
-
var hasSizeAllWidth = columnSizeInfo.hasSizeAllWidth;
|
|
568
|
-
//表格宽度,offsetWidth?下面监听里用的clientWidth
|
|
569
|
-
var tableContainerWidth = ((_document$getElementB = document.getElementById("".concat(tableId, "-TableCore"))) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.offsetWidth) || 1000;
|
|
570
|
-
// 滚动条宽度
|
|
571
|
-
var scrollBarWidth = hasVerticalScrollBar ? 10 : 0;
|
|
572
|
-
var remainWidth = tableContainerWidth - hasSizeAllWidth - scrollBarWidth - table.getLeftTotalSize() - (table === null || table === void 0 ? void 0 : table.getRightTotalSize());
|
|
573
|
-
return remainWidth;
|
|
574
|
-
}, [tableContainerWidth, hasVerticalScrollBar, Math.round(table.getLeftTotalSize()), Math.round(table === null || table === void 0 ? void 0 : table.getRightTotalSize())]);
|
|
575
541
|
useEffect(function () {
|
|
542
|
+
var _tableBodyRef$current, _tableBodyRef$current2;
|
|
543
|
+
setHasVerticalScrollBar((tableBodyRef === null || tableBodyRef === void 0 || (_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 ? void 0 : _tableBodyRef$current.scrollHeight) - (tableBodyRef === null || tableBodyRef === void 0 || (_tableBodyRef$current2 = tableBodyRef.current) === null || _tableBodyRef$current2 === void 0 ? void 0 : _tableBodyRef$current2.clientHeight) > 0);
|
|
544
|
+
}, [tableBodyRef === null || tableBodyRef === void 0 || (_tableBodyRef$current3 = tableBodyRef.current) === null || _tableBodyRef$current3 === void 0 ? void 0 : _tableBodyRef$current3.clientHeight, tableBodyRef === null || tableBodyRef === void 0 || (_tableBodyRef$current4 = tableBodyRef.current) === null || _tableBodyRef$current4 === void 0 ? void 0 : _tableBodyRef$current4.scrollHeight]);
|
|
545
|
+
useEffect(function () {
|
|
546
|
+
var _tableContentRef$curr;
|
|
576
547
|
//默认宽度
|
|
548
|
+
var dom = document.getElementById("".concat(tableId, "-TableCore"));
|
|
549
|
+
if (!dom) return;
|
|
577
550
|
var defaultSize = 60;
|
|
578
551
|
var allCount = columnSizeInfo.allCount,
|
|
579
552
|
hasSizeCount = columnSizeInfo.hasSizeCount,
|
|
580
|
-
columns = columnSizeInfo.columns
|
|
553
|
+
columns = columnSizeInfo.columns,
|
|
554
|
+
hasSizeAllWidth = columnSizeInfo.hasSizeAllWidth;
|
|
581
555
|
//表格宽度,offsetWidth?下面监听里用的clientWidth
|
|
582
556
|
// 空白宽度
|
|
583
|
-
var remainWidth =
|
|
584
|
-
|
|
557
|
+
var remainWidth = (tableContentRef === null || tableContentRef === void 0 || (_tableContentRef$curr = tableContentRef.current) === null || _tableContentRef$curr === void 0 ? void 0 : _tableContentRef$curr.clientWidth) - hasSizeAllWidth - 10 || 0;
|
|
585
558
|
// 没有配置宽度size的列的数量
|
|
586
559
|
var remainCount = allCount - hasSizeCount;
|
|
587
|
-
var
|
|
560
|
+
var aveSize;
|
|
588
561
|
if (remainWidth > 0 && remainCount) {
|
|
589
|
-
|
|
590
|
-
newColumns = setRemainColumnsWidth(newColumns, aveSize);
|
|
562
|
+
aveSize = Math.max(remainWidth / remainCount, defaultSize);
|
|
591
563
|
} else {
|
|
592
|
-
|
|
564
|
+
aveSize = undefined;
|
|
593
565
|
}
|
|
594
|
-
|
|
566
|
+
var _setRemainColumnsWidt = setRemainColumnsWidth(columns, aveSize),
|
|
567
|
+
newColumns = _setRemainColumnsWidt.columns,
|
|
568
|
+
columnsWidthMap = _setRemainColumnsWidt.columnsWidthMap;
|
|
569
|
+
// setInitTableSizeColumns(cloneDeep(newColumns));
|
|
595
570
|
setTableColumns(cloneDeep(newColumns));
|
|
596
|
-
|
|
571
|
+
setInitColumnsSizing(columnsWidthMap);
|
|
572
|
+
setColumnSizing(columnsWidthMap);
|
|
573
|
+
}, [columnSizeInfo]);
|
|
597
574
|
|
|
598
|
-
// 添加空白列
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
var containerWidth = tableContainerWidth;
|
|
602
|
-
var scrollBarWidth = tableBodyHeight < bodyContentHeight ? 10 : 0;
|
|
603
|
-
var centerTableContainerWidth = containerWidth - scrollBarWidth;
|
|
604
|
-
var centerTableRemainWidth = centerTableContainerWidth - centerTableSize;
|
|
575
|
+
// // 添加空白列
|
|
576
|
+
useEffect(function () {
|
|
577
|
+
if ((tableColumns === null || tableColumns === void 0 ? void 0 : tableColumns.length) <= 0 || !tableContainerWidth) return;
|
|
605
578
|
var placeholderColumn = table.getAllColumns().some(function (item) {
|
|
606
579
|
return item.id === ColumnType.PlaceHolder;
|
|
607
580
|
}) ? table.getColumn(ColumnType.PlaceHolder) : null;
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
return true;
|
|
617
|
-
}
|
|
618
|
-
return false;
|
|
619
|
-
});
|
|
620
|
-
//有剩余空间且无空白列
|
|
621
|
-
} else {
|
|
622
|
-
newColumns.push({
|
|
581
|
+
// let newColumns = initTableSizeColumns;
|
|
582
|
+
var scrollBarWidth = hasVerticalScrollBar ? 10 : 0;
|
|
583
|
+
var tableColumnsWidthWithoutEmpty = table.getTotalSize() - ((placeholderColumn === null || placeholderColumn === void 0 ? void 0 : placeholderColumn.getSize()) || 0);
|
|
584
|
+
var newEmptyColumnsWidth = tableContainerWidth - tableColumnsWidthWithoutEmpty - scrollBarWidth;
|
|
585
|
+
setTableColumns(produce(function (draft) {
|
|
586
|
+
if (!placeholderColumn) {
|
|
587
|
+
if (newEmptyColumnsWidth <= 0) return;
|
|
588
|
+
draft.push({
|
|
623
589
|
id: ColumnType.PlaceHolder,
|
|
624
|
-
size:
|
|
625
|
-
accessorKey:
|
|
626
|
-
header:
|
|
627
|
-
|
|
628
|
-
}
|
|
629
|
-
//无剩余空间有空白列
|
|
630
|
-
} else if (placeholderColumn) {
|
|
631
|
-
var placeholderColumnSize = placeholderColumn.getSize();
|
|
632
|
-
// 有空白列
|
|
633
|
-
if (placeholderColumnSize + centerTableRemainWidth > 0) {
|
|
634
|
-
newColumns.some(function (item) {
|
|
635
|
-
if (item.id === ColumnType.PlaceHolder) {
|
|
636
|
-
item.size = centerTableRemainWidth + placeholderColumnSize;
|
|
637
|
-
return true;
|
|
590
|
+
size: newEmptyColumnsWidth,
|
|
591
|
+
accessorKey: null,
|
|
592
|
+
header: function header() {
|
|
593
|
+
return null;
|
|
638
594
|
}
|
|
639
|
-
return false;
|
|
640
595
|
});
|
|
641
|
-
// 删除空白列
|
|
642
596
|
} else {
|
|
643
|
-
|
|
597
|
+
if (newEmptyColumnsWidth === (placeholderColumn === null || placeholderColumn === void 0 ? void 0 : placeholderColumn.getSize())) return;
|
|
598
|
+
draft.some(function (item, index) {
|
|
644
599
|
if (item.id === ColumnType.PlaceHolder) {
|
|
645
|
-
|
|
600
|
+
if (newEmptyColumnsWidth <= 0) {
|
|
601
|
+
draft.splice(index, 1);
|
|
602
|
+
} else {
|
|
603
|
+
item.size = newEmptyColumnsWidth;
|
|
604
|
+
}
|
|
646
605
|
return true;
|
|
647
606
|
}
|
|
648
607
|
return false;
|
|
649
608
|
});
|
|
650
609
|
}
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
}, [table.getTotalSize(),
|
|
654
|
-
// emptyColumnWidth,
|
|
655
|
-
initTableSizeColumns]);
|
|
610
|
+
}));
|
|
611
|
+
}, [tableContainerWidth, hasVerticalScrollBar, table.getState().columnSizing]);
|
|
656
612
|
|
|
657
613
|
// 多选数据变化回调
|
|
658
614
|
useEffect(function () {
|
|
@@ -730,6 +686,12 @@ var TableMax = function TableMax(_ref) {
|
|
|
730
686
|
var tableState = table.getState();
|
|
731
687
|
var cache = JSON.parse((_localStorage$getItem3 = localStorage.getItem(tableKey)) !== null && _localStorage$getItem3 !== void 0 ? _localStorage$getItem3 : '{}');
|
|
732
688
|
var cacheColumnSizing = cache.columnSizing;
|
|
689
|
+
var changedColumnsSizing = {};
|
|
690
|
+
Object.keys(initColumnsSizing).forEach(function (item) {
|
|
691
|
+
if (initColumnsSizing[item] !== tableState.columnSizing[item]) {
|
|
692
|
+
changedColumnsSizing[item] = tableState.columnSizing[item];
|
|
693
|
+
}
|
|
694
|
+
});
|
|
733
695
|
localStorage.setItem(tableKey, JSON.stringify({
|
|
734
696
|
columnVisibility: tableState.columnVisibility,
|
|
735
697
|
columnPinning: tableState.columnPinning,
|
|
@@ -739,55 +701,13 @@ var TableMax = function TableMax(_ref) {
|
|
|
739
701
|
enableFilters: enableFilters,
|
|
740
702
|
// @ts-ignore
|
|
741
703
|
// columnSizes: tableState.columnSizes,
|
|
742
|
-
columnSizing: _objectSpread(_objectSpread({}, cacheColumnSizing),
|
|
704
|
+
columnSizing: _objectSpread(_objectSpread({}, cacheColumnSizing), changedColumnsSizing)
|
|
743
705
|
}));
|
|
744
706
|
}, [table.getState().columnVisibility, table.getState().columnPinning, table.getState().columnOrder, table.getState().columnFilters, table.getState().sorting, enableFilters,
|
|
745
707
|
// @ts-ignore
|
|
746
708
|
// table.getState().columnSizes,
|
|
747
709
|
table.getState().columnSizing]);
|
|
748
|
-
|
|
749
|
-
// const reorderRow = (dragFromRowIndex: number, targetRowIndex: number) => {
|
|
750
|
-
// const draggedRows = table.getSelectedRowModel()?.rows || [];
|
|
751
|
-
// const draggedRowNumber = draggedRows?.length || 0;
|
|
752
|
-
// const draggedRowsIndexList = draggedRows?.map(row => row.index);
|
|
753
|
-
// const draggedDatas: any[] = [];
|
|
754
|
-
// let isDraggedToSourceRow = false,
|
|
755
|
-
// aheadOfTargetRowNumber = 0;
|
|
756
|
-
// let newTableDatas;
|
|
757
|
-
// // 多选行拖动(如果有多选行,且拖拽行属于选中行,则所有选中行跟随拖拽一起移动)
|
|
758
|
-
// if (draggedRowNumber > 1 && draggedRowsIndexList.includes(dragFromRowIndex)) {
|
|
759
|
-
// draggedRows.forEach(item => {
|
|
760
|
-
// //如果目标行等于拖拽行,则取消拖拽操作
|
|
761
|
-
// if (targetRowIndex === item.index) {
|
|
762
|
-
// isDraggedToSourceRow = true;
|
|
763
|
-
// }
|
|
764
|
-
// if (item.index < targetRowIndex) {
|
|
765
|
-
// aheadOfTargetRowNumber++;
|
|
766
|
-
// }
|
|
767
|
-
// if (draggedRowsIndexList.includes(item.index)) {
|
|
768
|
-
// draggedDatas.push(tableDatas[item.index]);
|
|
769
|
-
// }
|
|
770
|
-
// });
|
|
771
|
-
// if (isDraggedToSourceRow) return;
|
|
772
|
-
|
|
773
|
-
// console.log(dragFromRowIndex, draggedRowNumber, draggedRows, draggedDatas);
|
|
774
|
-
// //统一删除选中行
|
|
775
|
-
// newTableDatas = tableDatas.filter((data, idx) => {
|
|
776
|
-
// return !draggedRowsIndexList.includes(idx);
|
|
777
|
-
// });
|
|
778
|
-
// newTableDatas.splice(targetRowIndex - aheadOfTargetRowNumber, 0, ...draggedDatas);
|
|
779
|
-
// setTableDatas([...newTableDatas]);
|
|
780
|
-
// } else {
|
|
781
|
-
// // 单选行拖动
|
|
782
|
-
// newTableDatas = [...tableDatas];
|
|
783
|
-
// newTableDatas.splice(targetRowIndex, 0, newTableDatas.splice(dragFromRowIndex, 1)[0] as any);
|
|
784
|
-
// setTableDatas(newTableDatas);
|
|
785
|
-
// }
|
|
786
|
-
|
|
787
|
-
// rowOrderChange?.(targetRowIndex, newTableDatas);
|
|
788
|
-
// };
|
|
789
|
-
|
|
790
|
-
var reorderRow = function reorderRow(fromDatas, toDatas) {
|
|
710
|
+
var reorderRow = useCallback(function (fromDatas, toDatas) {
|
|
791
711
|
var draggedRow = fromDatas.draggedRow,
|
|
792
712
|
isMultipleDrag = fromDatas.isMultipleDrag,
|
|
793
713
|
draggedRows = fromDatas.draggedRows,
|
|
@@ -859,7 +779,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
859
779
|
draggedRows: draggedRows,
|
|
860
780
|
updatedTableDatas: newTableDatas
|
|
861
781
|
});
|
|
862
|
-
};
|
|
782
|
+
}, [tableDatas]);
|
|
863
783
|
|
|
864
784
|
// 把row数据填充到表单
|
|
865
785
|
var setFormData = function setFormData(rowOriginal) {
|
|
@@ -953,10 +873,10 @@ var TableMax = function TableMax(_ref) {
|
|
|
953
873
|
}, [editingRowId]);
|
|
954
874
|
|
|
955
875
|
// 双击行时,进入行编辑态
|
|
956
|
-
var handleEditRowWhenDClick = function
|
|
876
|
+
var handleEditRowWhenDClick = useCallback(function (row) {
|
|
957
877
|
setFormData(row.original || {});
|
|
958
878
|
setEditingRowId(row.id);
|
|
959
|
-
};
|
|
879
|
+
}, []);
|
|
960
880
|
|
|
961
881
|
// 点击删除按钮
|
|
962
882
|
var handleClickDelete = function handleClickDelete() {
|
|
@@ -977,6 +897,8 @@ var TableMax = function TableMax(_ref) {
|
|
|
977
897
|
}
|
|
978
898
|
};
|
|
979
899
|
var tableBodyProps = {
|
|
900
|
+
tableContentRef: tableContentRef,
|
|
901
|
+
tableBodyRef: tableBodyRef,
|
|
980
902
|
emptyDataHeight: emptyDataHeight,
|
|
981
903
|
table: table,
|
|
982
904
|
tableId: tableId,
|
|
@@ -988,13 +910,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
988
910
|
canFilter: canFilter,
|
|
989
911
|
canSelection: canSelection,
|
|
990
912
|
selectionWithoutChecked: selectionWithoutChecked,
|
|
991
|
-
// scroll,
|
|
992
|
-
// setScroll,
|
|
993
|
-
tableBodyHeight: tableBodyHeight,
|
|
994
|
-
// tableHeadHeight,
|
|
995
|
-
// setTableHeadHeight,
|
|
996
|
-
bodyContentHeight: bodyContentHeight,
|
|
997
|
-
// setBodyContentHeight,
|
|
998
913
|
tableContainerWidth: tableContainerWidth,
|
|
999
914
|
selectedRowDragging: selectedRowDragging,
|
|
1000
915
|
setSelectedRowDragging: setSelectedRowDragging,
|
|
@@ -1013,7 +928,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
1013
928
|
editingRowId: editingRowId,
|
|
1014
929
|
handleEditRowWhenDClick: handleEditRowWhenDClick,
|
|
1015
930
|
renderSubComponent: renderSubComponent,
|
|
1016
|
-
// isAllRowExpanded,
|
|
1017
931
|
onRowMouseEnter: onRowMouseEnter,
|
|
1018
932
|
onRowMouseLeave: onRowMouseLeave,
|
|
1019
933
|
onRowMouseClick: onRowMouseClick,
|
|
@@ -1029,10 +943,10 @@ var TableMax = function TableMax(_ref) {
|
|
|
1029
943
|
hasVerticalScrollBar: hasVerticalScrollBar
|
|
1030
944
|
};
|
|
1031
945
|
var getPinShadowInfo = useCallback(function () {
|
|
1032
|
-
var _tableBodyRef$
|
|
1033
|
-
scrollWidth = _tableBodyRef$
|
|
1034
|
-
clientWidth = _tableBodyRef$
|
|
1035
|
-
scrollLeft = _tableBodyRef$
|
|
946
|
+
var _tableBodyRef$current5 = tableBodyRef === null || tableBodyRef === void 0 ? void 0 : tableBodyRef.current,
|
|
947
|
+
scrollWidth = _tableBodyRef$current5.scrollWidth,
|
|
948
|
+
clientWidth = _tableBodyRef$current5.clientWidth,
|
|
949
|
+
scrollLeft = _tableBodyRef$current5.scrollLeft;
|
|
1036
950
|
var newLeftShadowVisible, newRightShadowVisible;
|
|
1037
951
|
newLeftShadowVisible = scrollLeft > 0;
|
|
1038
952
|
newRightShadowVisible = scrollLeft < scrollWidth - clientWidth;
|
|
@@ -1043,22 +957,20 @@ var TableMax = function TableMax(_ref) {
|
|
|
1043
957
|
});
|
|
1044
958
|
}
|
|
1045
959
|
}, [pinShadowVisible]);
|
|
1046
|
-
|
|
1047
|
-
// useEffect(getPinShadowInfo, [tableContainerWidth]);
|
|
1048
|
-
|
|
1049
960
|
var scrollHandler = useCallback(function (event) {
|
|
1050
961
|
if (!event.currentTarget) return;
|
|
1051
|
-
tableHeaderRef.current.scrollLeft = event.currentTarget.scrollLeft / event.currentTarget.scrollWidth * tableHeaderRef.current.scrollWidth;
|
|
962
|
+
tableHeaderRef.current.scrollLeft = event.currentTarget.scrollLeft / event.currentTarget.scrollWidth * (tableHeaderRef === null || tableHeaderRef === void 0 ? void 0 : tableHeaderRef.current.scrollWidth);
|
|
1052
963
|
getPinShadowInfo();
|
|
1053
964
|
}, [getPinShadowInfo]);
|
|
1054
965
|
var tableHeaderProps = {
|
|
966
|
+
tableId: tableId,
|
|
967
|
+
tableContentRef: tableContentRef,
|
|
1055
968
|
table: table,
|
|
1056
969
|
canFilter: canFilter,
|
|
1057
970
|
enableFilters: enableFilters,
|
|
1058
971
|
canSorting: canSorting,
|
|
1059
972
|
rowHeight: rowHeight,
|
|
1060
973
|
hasGroup: hasGroup,
|
|
1061
|
-
headerGroups: table.getHeaderGroups(),
|
|
1062
974
|
getHeaderCellProps: getHeaderCellProps,
|
|
1063
975
|
columnResizeMode: columnResizeMode,
|
|
1064
976
|
hasVerticalScrollBar: hasVerticalScrollBar,
|
|
@@ -1156,16 +1068,23 @@ var TableMax = function TableMax(_ref) {
|
|
|
1156
1068
|
className: "table-center",
|
|
1157
1069
|
ref: tableContentRef,
|
|
1158
1070
|
style: {
|
|
1159
|
-
|
|
1071
|
+
maxHeight: !autoHeight ? defaultScrollY : 'fit-content'
|
|
1160
1072
|
},
|
|
1161
1073
|
children: [/*#__PURE__*/_jsx("div", {
|
|
1162
1074
|
ref: tableHeaderRef,
|
|
1163
1075
|
className: "table-header",
|
|
1076
|
+
style: {
|
|
1077
|
+
width: "".concat(tableContentRef === null || tableContentRef === void 0 || (_tableContentRef$curr2 = tableContentRef.current) === null || _tableContentRef$curr2 === void 0 ? void 0 : _tableContentRef$curr2.clientWidth, "px"),
|
|
1078
|
+
height: 'fit-content'
|
|
1079
|
+
},
|
|
1164
1080
|
children: /*#__PURE__*/_jsx(TableHeader, _objectSpread({}, tableHeaderProps))
|
|
1165
1081
|
}), /*#__PURE__*/_jsx("div", {
|
|
1166
1082
|
ref: tableBodyRef,
|
|
1167
1083
|
className: "table-body",
|
|
1168
1084
|
onScroll: scrollHandler,
|
|
1085
|
+
style: {
|
|
1086
|
+
width: "".concat(tableContentRef === null || tableContentRef === void 0 || (_tableContentRef$curr3 = tableContentRef.current) === null || _tableContentRef$curr3 === void 0 ? void 0 : _tableContentRef$curr3.clientWidth, "px")
|
|
1087
|
+
},
|
|
1169
1088
|
children: /*#__PURE__*/_jsx(TableBody, _objectSpread({}, tableBodyProps))
|
|
1170
1089
|
})]
|
|
1171
1090
|
})
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
|
|
98
98
|
.table-center {
|
|
99
99
|
flex: 1;
|
|
100
|
-
overflow-x:
|
|
100
|
+
overflow-x: hidden;
|
|
101
101
|
overflow-y: hidden;
|
|
102
102
|
display: flex;
|
|
103
103
|
flex-direction: column;
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
.table-max-footer {
|
|
175
|
-
height: 24px;
|
|
175
|
+
// height: 24px;
|
|
176
176
|
margin-top: 12px;
|
|
177
177
|
}
|
|
178
178
|
|
|
@@ -6,8 +6,15 @@ export declare const getSizeInfo: (columns: TableMaxColumnType[]) => {
|
|
|
6
6
|
columns: TableMaxColumnType[];
|
|
7
7
|
};
|
|
8
8
|
export declare function getTextWidth(text: string, fontSize: number): any;
|
|
9
|
-
export declare const setRemainColumnsWidth: (initColumns: TableMaxColumnType[], defaultSize?: number) =>
|
|
10
|
-
|
|
9
|
+
export declare const setRemainColumnsWidth: (initColumns: TableMaxColumnType[], defaultSize?: number) => {
|
|
10
|
+
columns: any;
|
|
11
|
+
tableColumnsWidth: number;
|
|
12
|
+
columnsWidthMap: {};
|
|
13
|
+
};
|
|
14
|
+
export declare const setInitColumnsSize: (tableColumns: any, columnsMap: any) => {
|
|
15
|
+
columnsSizeMap: {};
|
|
16
|
+
tableColumns: any;
|
|
17
|
+
};
|
|
11
18
|
export declare const getShadowInfo: (column: any, table: any) => {
|
|
12
19
|
isRightFirst: boolean;
|
|
13
20
|
isLeftLast: boolean;
|
|
@@ -37,6 +37,8 @@ export function getTextWidth(text, fontSize) {
|
|
|
37
37
|
}
|
|
38
38
|
export var setRemainColumnsWidth = function setRemainColumnsWidth(initColumns, defaultSize) {
|
|
39
39
|
var columns = cloneDeep(initColumns);
|
|
40
|
+
var columnsWidthMap = {};
|
|
41
|
+
var tableColumnsWidth = 0;
|
|
40
42
|
var fn = function fn(columns) {
|
|
41
43
|
columns.forEach(function (column) {
|
|
42
44
|
var _ref, _column$size;
|
|
@@ -44,27 +46,40 @@ export var setRemainColumnsWidth = function setRemainColumnsWidth(initColumns, d
|
|
|
44
46
|
if (!column.columns) {
|
|
45
47
|
var _ref2, _column$size2;
|
|
46
48
|
column.size = (_ref2 = (_column$size2 = column.size) !== null && _column$size2 !== void 0 ? _column$size2 : defaultSize) !== null && _ref2 !== void 0 ? _ref2 : (column === null || column === void 0 ? void 0 : column.filterType) === FilterType.Date ? 160 : getTextWidth(column.header, 14) + 50;
|
|
49
|
+
tableColumnsWidth += column.size;
|
|
50
|
+
columnsWidthMap[column.id] = column.size;
|
|
47
51
|
} else {
|
|
48
52
|
fn(column.columns);
|
|
49
53
|
}
|
|
50
54
|
});
|
|
51
55
|
};
|
|
52
56
|
fn(columns);
|
|
53
|
-
return
|
|
57
|
+
return {
|
|
58
|
+
columns: columns,
|
|
59
|
+
tableColumnsWidth: tableColumnsWidth,
|
|
60
|
+
columnsWidthMap: columnsWidthMap
|
|
61
|
+
};
|
|
54
62
|
};
|
|
55
63
|
export var setInitColumnsSize = function setInitColumnsSize(tableColumns, columnsMap) {
|
|
64
|
+
var columnsSizeMap = {};
|
|
56
65
|
var fn = function fn(columns) {
|
|
57
66
|
// eslint-disable-next-line array-callback-return
|
|
58
67
|
columns.map(function (column) {
|
|
59
68
|
var _columnsMap$column$id;
|
|
60
69
|
column.size = (_columnsMap$column$id = columnsMap[column.id]) !== null && _columnsMap$column$id !== void 0 ? _columnsMap$column$id : column.size;
|
|
70
|
+
if (column.size) {
|
|
71
|
+
columnsSizeMap[column.id] = column.size;
|
|
72
|
+
}
|
|
61
73
|
if (column.columns) {
|
|
62
74
|
fn(column.columns);
|
|
63
75
|
}
|
|
64
76
|
});
|
|
65
77
|
};
|
|
66
78
|
fn(tableColumns);
|
|
67
|
-
return
|
|
79
|
+
return {
|
|
80
|
+
columnsSizeMap: columnsSizeMap,
|
|
81
|
+
tableColumns: tableColumns
|
|
82
|
+
};
|
|
68
83
|
};
|
|
69
84
|
export var getShadowInfo = function getShadowInfo(column, table) {
|
|
70
85
|
var isLeftLast, isRightFirst;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arim-aisdc/public-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "前端组件库",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"ahooks": "^3.7.8",
|
|
51
51
|
"css-vars-ponyfill": "^2.4.8",
|
|
52
52
|
"fs": "^0.0.1-security",
|
|
53
|
+
"immer": "^10.0.3",
|
|
53
54
|
"lodash": "^4.17.21",
|
|
54
55
|
"path": "^0.12.7",
|
|
55
56
|
"react-dnd": "^16.0.1",
|
|
@@ -91,4 +92,4 @@
|
|
|
91
92
|
"authors": [
|
|
92
93
|
"na.xu2278@foxmail.com"
|
|
93
94
|
]
|
|
94
|
-
}
|
|
95
|
+
}
|