@arim-aisdc/public-components 0.0.15 → 0.0.17
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 +2 -2
- package/dist/components/TableMax/TableBody/Row.js +5 -5
- package/dist/components/TableMax/TableBody/index.d.ts +2 -4
- package/dist/components/TableMax/TableBody/index.js +13 -10
- package/dist/components/TableMax/TableHeader/index.js +4 -5
- package/dist/components/TableMax/TableHeader/index.less +1 -1
- package/dist/components/TableMax/TableMax.js +103 -61
- package/dist/components/TableMax/tableMax.less +1 -1
- package/dist/components/TableMax/utils.d.ts +4 -1
- package/dist/components/TableMax/utils.js +6 -1
- package/package.json +2 -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, hasVerticalScrollBar, 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;
|
|
@@ -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,
|
|
@@ -287,13 +287,13 @@ var Row = function Row(_ref) {
|
|
|
287
287
|
style: {
|
|
288
288
|
padding: 0
|
|
289
289
|
},
|
|
290
|
-
children:
|
|
290
|
+
children: (tableBodyRef === null || tableBodyRef === void 0 || (_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 ? void 0 : _tableBodyRef$current.clientWidth) && /*#__PURE__*/_jsx("div", {
|
|
291
291
|
id: "".concat(tableId, "_expand-table"),
|
|
292
292
|
className: "subRowWrapper"
|
|
293
293
|
// 减去10,避免被父表滚动条覆盖
|
|
294
294
|
,
|
|
295
295
|
style: {
|
|
296
|
-
width: "".concat(
|
|
296
|
+
width: "".concat(tableBodyRef === null || tableBodyRef === void 0 || (_tableBodyRef$current2 = tableBodyRef.current) === null || _tableBodyRef$current2 === void 0 ? void 0 : _tableBodyRef$current2.clientWidth, "px")
|
|
297
297
|
},
|
|
298
298
|
children: renderSubComponent && renderSubComponent({
|
|
299
299
|
row: row
|
|
@@ -3,6 +3,7 @@ import { OnSelectChangeType } from "../type";
|
|
|
3
3
|
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
|
4
4
|
import './index.less';
|
|
5
5
|
type TableBodyPropsType = {
|
|
6
|
+
tableBodyRef?: any;
|
|
6
7
|
table: Table<any>;
|
|
7
8
|
tableId: string;
|
|
8
9
|
theme: string;
|
|
@@ -14,9 +15,6 @@ type TableBodyPropsType = {
|
|
|
14
15
|
canFilter: boolean;
|
|
15
16
|
canSelection: boolean;
|
|
16
17
|
selectionWithoutChecked?: boolean;
|
|
17
|
-
tableBodyHeight: number;
|
|
18
|
-
bodyContentHeight: number;
|
|
19
|
-
tableContainerWidth: number;
|
|
20
18
|
selectedRowDragging: boolean;
|
|
21
19
|
setSelectedRowDragging: Dispatch<SetStateAction<boolean>>;
|
|
22
20
|
canRowDrag: boolean;
|
|
@@ -53,5 +51,5 @@ type TableBodyPropsType = {
|
|
|
53
51
|
};
|
|
54
52
|
dragBeforeStart: (datas: any) => boolean;
|
|
55
53
|
};
|
|
56
|
-
declare const TableBody: ({ table, tableId, theme, reorderRow, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, selectionWithoutChecked,
|
|
54
|
+
declare const TableBody: ({ 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
55
|
export default TableBody;
|
|
@@ -12,7 +12,6 @@ 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';
|
|
17
16
|
import Row from "./Row";
|
|
18
17
|
import "./index.less";
|
|
@@ -21,7 +20,8 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
21
20
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
21
|
var TableBody = function TableBody(_ref) {
|
|
23
22
|
var _headerGroups;
|
|
24
|
-
var
|
|
23
|
+
var tableBodyRef = _ref.tableBodyRef,
|
|
24
|
+
table = _ref.table,
|
|
25
25
|
tableId = _ref.tableId,
|
|
26
26
|
theme = _ref.theme,
|
|
27
27
|
reorderRow = _ref.reorderRow,
|
|
@@ -31,8 +31,6 @@ var TableBody = function TableBody(_ref) {
|
|
|
31
31
|
onSelectChange = _ref.onSelectChange,
|
|
32
32
|
canSelection = _ref.canSelection,
|
|
33
33
|
selectionWithoutChecked = _ref.selectionWithoutChecked,
|
|
34
|
-
tableBodyHeight = _ref.tableBodyHeight,
|
|
35
|
-
tableContainerWidth = _ref.tableContainerWidth,
|
|
36
34
|
selectedRowDragging = _ref.selectedRowDragging,
|
|
37
35
|
setSelectedRowDragging = _ref.setSelectedRowDragging,
|
|
38
36
|
canRowDrag = _ref.canRowDrag,
|
|
@@ -164,6 +162,7 @@ var TableBody = function TableBody(_ref) {
|
|
|
164
162
|
_useDrop2 = _slicedToArray(_useDrop, 2),
|
|
165
163
|
dropRef = _useDrop2[1];
|
|
166
164
|
var EmptyContent = function EmptyContent() {
|
|
165
|
+
var _tableBodyRef$current;
|
|
167
166
|
return /*#__PURE__*/_jsx("tr", {
|
|
168
167
|
className: "empty-container",
|
|
169
168
|
style: {
|
|
@@ -172,7 +171,7 @@ var TableBody = function TableBody(_ref) {
|
|
|
172
171
|
children: /*#__PURE__*/_jsx("td", {
|
|
173
172
|
className: "empty-wapper",
|
|
174
173
|
style: {
|
|
175
|
-
width: "".concat(
|
|
174
|
+
width: "".concat(tableBodyRef === null || tableBodyRef === void 0 || (_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 ? void 0 : _tableBodyRef$current.clientWidth, "px"),
|
|
176
175
|
height: emptyDataHeight
|
|
177
176
|
},
|
|
178
177
|
children: loading ? /*#__PURE__*/_jsx(_Spin, {}) : /*#__PURE__*/_jsxs("span", {
|
|
@@ -195,9 +194,11 @@ var TableBody = function TableBody(_ref) {
|
|
|
195
194
|
// 当前行是否编辑中
|
|
196
195
|
var rowEditing = row.id === editingRowId;
|
|
197
196
|
return /*#__PURE__*/_jsx(Row, {
|
|
197
|
+
tableBodyRef: tableBodyRef,
|
|
198
198
|
table: table,
|
|
199
|
-
tableId: tableId
|
|
200
|
-
|
|
199
|
+
tableId: tableId
|
|
200
|
+
// tableContainerWidth={tableContainerWidth}
|
|
201
|
+
,
|
|
201
202
|
row: row,
|
|
202
203
|
rowKey: rowKey,
|
|
203
204
|
theme: theme,
|
|
@@ -239,9 +240,11 @@ var TableBody = function TableBody(_ref) {
|
|
|
239
240
|
}
|
|
240
241
|
return EmptyContent();
|
|
241
242
|
};
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
|
|
244
|
+
// useEffect(() => {
|
|
245
|
+
// console.log(tableBodyHeight, 'tableBodyHeight*******************');
|
|
246
|
+
// }, [tableBodyHeight]);
|
|
247
|
+
|
|
245
248
|
return (
|
|
246
249
|
/*#__PURE__*/
|
|
247
250
|
// 修复筛选数据为空时,滚动条丢失
|
|
@@ -7,7 +7,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
7
7
|
// import { Column, flexRender } from '@tanstack/react-table';
|
|
8
8
|
// import { useDrag, useDrop } from 'ahooks';
|
|
9
9
|
|
|
10
|
-
import { useMemo } from 'react';
|
|
10
|
+
import { useEffect, useMemo } from 'react';
|
|
11
11
|
import { Filter } from "../components/ColumnFilter";
|
|
12
12
|
import { getShadowInfo } from "../utils";
|
|
13
13
|
import Cell from "./Cell";
|
|
@@ -31,10 +31,9 @@ var TableHeader = function TableHeader(_ref) {
|
|
|
31
31
|
var columnPinning = table.getState().columnPinning;
|
|
32
32
|
return JSON.stringify(columnPinning.left) !== '[]' || JSON.stringify(columnPinning.right) !== '[]' ? true : false;
|
|
33
33
|
}, [table.getState().columnPinning]);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// }, [hasVerticalScrollBar]);
|
|
34
|
+
useEffect(function () {
|
|
35
|
+
console.log(hasVerticalScrollBar, '********************hasVerticalScrollBar====================');
|
|
36
|
+
}, [hasVerticalScrollBar]);
|
|
38
37
|
|
|
39
38
|
// const [headerGroups, setHeaderGroups] = useState([])
|
|
40
39
|
|
|
@@ -54,7 +54,7 @@ export var ColumnType = /*#__PURE__*/function (ColumnType) {
|
|
|
54
54
|
}({});
|
|
55
55
|
export var TableContext = /*#__PURE__*/createContext({});
|
|
56
56
|
var TableMax = function TableMax(_ref) {
|
|
57
|
-
var _JSON$parse, _tableHeaderRef$curre2,
|
|
57
|
+
var _JSON$parse, _tableHeaderRef$curre2, _tableBodyRef$current6, _tableBodyRef$current7, _tableBodyRef$current8, _tableBodyRef$current9;
|
|
58
58
|
var tableId = _ref.tableId,
|
|
59
59
|
originColumns = _ref.columns,
|
|
60
60
|
_ref$datas = _ref.datas,
|
|
@@ -357,36 +357,18 @@ var TableMax = function TableMax(_ref) {
|
|
|
357
357
|
_useState36 = _slicedToArray(_useState35, 2),
|
|
358
358
|
tableHeadHeight = _useState36[0],
|
|
359
359
|
setTableHeadHeight = _useState36[1];
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
tableBodyHeight = _useState38[0],
|
|
363
|
-
setTableBodyHeight = _useState38[1];
|
|
360
|
+
|
|
361
|
+
// const [tableBodyHeight, setTableBodyHeight] = useState(0);
|
|
364
362
|
|
|
365
363
|
/**table-head高度 */
|
|
366
364
|
useEffect(function () {
|
|
367
365
|
var _tableHeaderRef$curre;
|
|
368
366
|
setTableHeadHeight(tableHeaderRef === null || tableHeaderRef === void 0 || (_tableHeaderRef$curre = tableHeaderRef.current) === null || _tableHeaderRef$curre === void 0 ? void 0 : _tableHeaderRef$curre.clientHeight);
|
|
369
367
|
}, [tableHeaderRef === null || tableHeaderRef === void 0 || (_tableHeaderRef$curre2 = tableHeaderRef.current) === null || _tableHeaderRef$curre2 === void 0 ? void 0 : _tableHeaderRef$curre2.clientHeight, enableFilters]);
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
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;
|
|
375
|
-
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);
|
|
376
|
-
}, [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]);
|
|
377
|
-
|
|
378
|
-
/**table-body-content 高度 */
|
|
379
|
-
var bodyContentHeight = useMemo(function () {
|
|
380
|
-
return datas.length * Number(rowHeight);
|
|
381
|
-
}, [datas.length, rowHeight]);
|
|
382
|
-
var hasVerticalScrollBar = useMemo(function () {
|
|
383
|
-
return tableBodyHeight - bodyContentHeight + 10 < 0;
|
|
384
|
-
}, [tableBodyHeight, bodyContentHeight]);
|
|
385
|
-
|
|
386
|
-
// const tableViewWidth = useMemo(
|
|
387
|
-
// () => table.getTotalSize() + (hasVerticalScrollBar ? 10 : 0),
|
|
388
|
-
// [table.getTotalSize(), hasVerticalScrollBar],
|
|
389
|
-
// );
|
|
368
|
+
var _useState37 = useState(false),
|
|
369
|
+
_useState38 = _slicedToArray(_useState37, 2),
|
|
370
|
+
hasVerticalScrollBar = _useState38[0],
|
|
371
|
+
setHasVerticalScrollBar = _useState38[1];
|
|
390
372
|
|
|
391
373
|
// 暴露给外部的api
|
|
392
374
|
useImperativeHandle(refInstance, function () {
|
|
@@ -556,19 +538,21 @@ var TableMax = function TableMax(_ref) {
|
|
|
556
538
|
setTableColumns(cloneDeep(newColumns));
|
|
557
539
|
return getSizeInfo(newColumns);
|
|
558
540
|
}, [columns]);
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
541
|
+
var _useState39 = useState(),
|
|
542
|
+
_useState40 = _slicedToArray(_useState39, 2),
|
|
543
|
+
emptyColumnWidth = _useState40[0],
|
|
544
|
+
setEmptyColumnWidth = _useState40[1];
|
|
545
|
+
useEffect(function () {
|
|
546
|
+
var _tableBodyRef$current, _tableBodyRef$current2, _tableBodyRef$current3, _tableBodyRef$current4, _tableBodyRef$current5;
|
|
563
547
|
var hasSizeAllWidth = columnSizeInfo.hasSizeAllWidth;
|
|
564
548
|
//表格宽度,offsetWidth?下面监听里用的clientWidth
|
|
565
|
-
var tableContainerWidth = (
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}, [
|
|
571
|
-
|
|
549
|
+
var tableContainerWidth = (_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 ? void 0 : _tableBodyRef$current.clientWidth;
|
|
550
|
+
var remainWidth = tableContainerWidth - hasSizeAllWidth || 0;
|
|
551
|
+
setHasVerticalScrollBar(((_tableBodyRef$current2 = tableBodyRef.current) === null || _tableBodyRef$current2 === void 0 ? void 0 : _tableBodyRef$current2.scrollHeight) - ((_tableBodyRef$current3 = tableBodyRef.current) === null || _tableBodyRef$current3 === void 0 ? void 0 : _tableBodyRef$current3.clientHeight) > 0);
|
|
552
|
+
console.log(datas.length * rowHeight, (_tableBodyRef$current4 = tableBodyRef.current) === null || _tableBodyRef$current4 === void 0 ? void 0 : _tableBodyRef$current4.scrollHeight, (_tableBodyRef$current5 = tableBodyRef.current) === null || _tableBodyRef$current5 === void 0 ? void 0 : _tableBodyRef$current5.clientHeight, 'setHasVerticalScrollBar');
|
|
553
|
+
setEmptyColumnWidth(remainWidth);
|
|
554
|
+
}, [(_tableBodyRef$current6 = tableBodyRef.current) === null || _tableBodyRef$current6 === void 0 ? void 0 : _tableBodyRef$current6.clientWidth, (_tableBodyRef$current7 = tableBodyRef.current) === null || _tableBodyRef$current7 === void 0 ? void 0 : _tableBodyRef$current7.clientHeight, (_tableBodyRef$current8 = tableBodyRef.current) === null || _tableBodyRef$current8 === void 0 ? void 0 : _tableBodyRef$current8.scrollWidth, (_tableBodyRef$current9 = tableBodyRef.current) === null || _tableBodyRef$current9 === void 0 ? void 0 : _tableBodyRef$current9.scrollHeight, tableBodyRef.current]);
|
|
555
|
+
useLayoutEffect(function () {
|
|
572
556
|
//默认宽度
|
|
573
557
|
var defaultSize = 60;
|
|
574
558
|
var allCount = columnSizeInfo.allCount,
|
|
@@ -577,31 +561,30 @@ var TableMax = function TableMax(_ref) {
|
|
|
577
561
|
//表格宽度,offsetWidth?下面监听里用的clientWidth
|
|
578
562
|
// 空白宽度
|
|
579
563
|
var remainWidth = emptyColumnWidth;
|
|
580
|
-
|
|
581
564
|
// 没有配置宽度size的列的数量
|
|
582
565
|
var remainCount = allCount - hasSizeCount;
|
|
583
|
-
var
|
|
566
|
+
var aveSize;
|
|
584
567
|
if (remainWidth > 0 && remainCount) {
|
|
585
|
-
|
|
586
|
-
newColumns = setRemainColumnsWidth(newColumns, aveSize);
|
|
568
|
+
aveSize = Math.max(remainWidth / remainCount, defaultSize);
|
|
587
569
|
} else {
|
|
588
|
-
|
|
570
|
+
aveSize = undefined;
|
|
589
571
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
572
|
+
var _setRemainColumnsWidt = setRemainColumnsWidth(columns, aveSize),
|
|
573
|
+
newColumns = _setRemainColumnsWidt.columns,
|
|
574
|
+
newInitTableColumnsWidth = _setRemainColumnsWidt.tableColumnsWidth;
|
|
575
|
+
// setInitTableSizeColumns(cloneDeep(newColumns))
|
|
576
|
+
// setInitTableColumnsSize(newInitTableColumnsWidth)
|
|
577
|
+
// setTableColumns(cloneDeep(newColumns))
|
|
593
578
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
var
|
|
598
|
-
var scrollBarWidth = tableBodyHeight < bodyContentHeight ? 10 : 0;
|
|
599
|
-
var centerTableContainerWidth = containerWidth - scrollBarWidth;
|
|
579
|
+
var centerTableSize = newInitTableColumnsWidth;
|
|
580
|
+
var containerWidth = tableBodyRef.current.clientWidth;
|
|
581
|
+
// const scrollBarWidth = tableBodyRef.current.clientWidth - tableBodyRef.current.scrollHeight < 0 ? 10 : 0;
|
|
582
|
+
var centerTableContainerWidth = containerWidth;
|
|
600
583
|
var centerTableRemainWidth = centerTableContainerWidth - centerTableSize;
|
|
601
584
|
var placeholderColumn = table.getAllColumns().some(function (item) {
|
|
602
585
|
return item.id === ColumnType.PlaceHolder;
|
|
603
586
|
}) ? table.getColumn(ColumnType.PlaceHolder) : null;
|
|
604
|
-
|
|
587
|
+
// let newColumns = initTableSizeColumns;
|
|
605
588
|
//有剩余空间时
|
|
606
589
|
if (centerTableRemainWidth > 0) {
|
|
607
590
|
// 有剩余空间且有空白列
|
|
@@ -646,9 +629,67 @@ var TableMax = function TableMax(_ref) {
|
|
|
646
629
|
}
|
|
647
630
|
}
|
|
648
631
|
setTableColumns(cloneDeep(newColumns));
|
|
649
|
-
}, [
|
|
650
|
-
|
|
651
|
-
|
|
632
|
+
}, [columnSizeInfo, emptyColumnWidth]);
|
|
633
|
+
|
|
634
|
+
// // 添加空白列
|
|
635
|
+
// useLayoutEffect(() => {
|
|
636
|
+
// const centerTableSize = initTableColumnsWidth;
|
|
637
|
+
// const containerWidth = tableBodyRef.current.clientWidth;
|
|
638
|
+
// // const scrollBarWidth = tableBodyRef.current.clientWidth - tableBodyRef.current.scrollHeight < 0 ? 10 : 0;
|
|
639
|
+
// const centerTableContainerWidth = containerWidth;
|
|
640
|
+
// const centerTableRemainWidth = centerTableContainerWidth - centerTableSize;
|
|
641
|
+
// const placeholderColumn = table.getAllColumns().some(item => item.id === ColumnType.PlaceHolder)
|
|
642
|
+
// ? table.getColumn(ColumnType.PlaceHolder)
|
|
643
|
+
// : null;
|
|
644
|
+
// let newColumns = initTableSizeColumns;
|
|
645
|
+
// //有剩余空间时
|
|
646
|
+
// if (centerTableRemainWidth > 0) {
|
|
647
|
+
// // 有剩余空间且有空白列
|
|
648
|
+
// if (placeholderColumn) {
|
|
649
|
+
// newColumns.some(item => {
|
|
650
|
+
// if (item.id === ColumnType.PlaceHolder) {
|
|
651
|
+
// item.size = centerTableRemainWidth + (placeholderColumn.columnDef.size || 0);
|
|
652
|
+
// return true;
|
|
653
|
+
// }
|
|
654
|
+
// return false;
|
|
655
|
+
// });
|
|
656
|
+
// //有剩余空间且无空白列
|
|
657
|
+
// } else {
|
|
658
|
+
// newColumns.push({
|
|
659
|
+
// id: ColumnType.PlaceHolder,
|
|
660
|
+
// size: centerTableRemainWidth,
|
|
661
|
+
// accessorKey: '',
|
|
662
|
+
// header: '',
|
|
663
|
+
// });
|
|
664
|
+
// }
|
|
665
|
+
// //无剩余空间有空白列
|
|
666
|
+
// } else if (placeholderColumn) {
|
|
667
|
+
// const placeholderColumnSize = placeholderColumn.getSize();
|
|
668
|
+
// // 有空白列
|
|
669
|
+
// if (placeholderColumnSize + centerTableRemainWidth > 0) {
|
|
670
|
+
// newColumns.some(item => {
|
|
671
|
+
// if (item.id === ColumnType.PlaceHolder) {
|
|
672
|
+
// item.size = centerTableRemainWidth + placeholderColumnSize;
|
|
673
|
+
// return true;
|
|
674
|
+
// }
|
|
675
|
+
// return false;
|
|
676
|
+
// });
|
|
677
|
+
// // 删除空白列
|
|
678
|
+
// } else {
|
|
679
|
+
// newColumns.some((item, index) => {
|
|
680
|
+
// if (item.id === ColumnType.PlaceHolder) {
|
|
681
|
+
// newColumns.splice(index, 1);
|
|
682
|
+
// return true;
|
|
683
|
+
// }
|
|
684
|
+
// return false;
|
|
685
|
+
// });
|
|
686
|
+
// }
|
|
687
|
+
// }
|
|
688
|
+
// setTableColumns(cloneDeep(newColumns));
|
|
689
|
+
// }, [
|
|
690
|
+
// initTableColumnsWidth,
|
|
691
|
+
// initTableSizeColumns,
|
|
692
|
+
// ]);
|
|
652
693
|
|
|
653
694
|
// 多选数据变化回调
|
|
654
695
|
useEffect(function () {
|
|
@@ -954,6 +995,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
954
995
|
setEditingRowId(row.id);
|
|
955
996
|
};
|
|
956
997
|
var tableBodyProps = {
|
|
998
|
+
tableBodyRef: tableBodyRef,
|
|
957
999
|
emptyDataHeight: emptyDataHeight,
|
|
958
1000
|
table: table,
|
|
959
1001
|
tableId: tableId,
|
|
@@ -967,10 +1009,10 @@ var TableMax = function TableMax(_ref) {
|
|
|
967
1009
|
selectionWithoutChecked: selectionWithoutChecked,
|
|
968
1010
|
// scroll,
|
|
969
1011
|
// setScroll,
|
|
970
|
-
|
|
1012
|
+
// tableBodyHeight,
|
|
971
1013
|
// tableHeadHeight,
|
|
972
1014
|
// setTableHeadHeight,
|
|
973
|
-
|
|
1015
|
+
// bodyContentHeight,
|
|
974
1016
|
// setBodyContentHeight,
|
|
975
1017
|
tableContainerWidth: tableContainerWidth,
|
|
976
1018
|
selectedRowDragging: selectedRowDragging,
|
|
@@ -1006,10 +1048,10 @@ var TableMax = function TableMax(_ref) {
|
|
|
1006
1048
|
hasVerticalScrollBar: hasVerticalScrollBar
|
|
1007
1049
|
};
|
|
1008
1050
|
var getPinShadowInfo = useCallback(function () {
|
|
1009
|
-
var _tableBodyRef$
|
|
1010
|
-
scrollWidth = _tableBodyRef$
|
|
1011
|
-
clientWidth = _tableBodyRef$
|
|
1012
|
-
scrollLeft = _tableBodyRef$
|
|
1051
|
+
var _tableBodyRef$current10 = tableBodyRef.current,
|
|
1052
|
+
scrollWidth = _tableBodyRef$current10.scrollWidth,
|
|
1053
|
+
clientWidth = _tableBodyRef$current10.clientWidth,
|
|
1054
|
+
scrollLeft = _tableBodyRef$current10.scrollLeft;
|
|
1013
1055
|
var newLeftShadowVisible, newRightShadowVisible;
|
|
1014
1056
|
newLeftShadowVisible = scrollLeft > 0;
|
|
1015
1057
|
newRightShadowVisible = scrollLeft < scrollWidth - clientWidth;
|
|
@@ -1126,7 +1168,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
1126
1168
|
className: "table-center",
|
|
1127
1169
|
ref: tableContentRef,
|
|
1128
1170
|
style: {
|
|
1129
|
-
|
|
1171
|
+
maxHeight: !autoHeight ? defaultScrollY : 'fix-content'
|
|
1130
1172
|
},
|
|
1131
1173
|
children: [/*#__PURE__*/_jsx("div", {
|
|
1132
1174
|
ref: tableHeaderRef,
|
|
@@ -6,7 +6,10 @@ 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) =>
|
|
9
|
+
export declare const setRemainColumnsWidth: (initColumns: TableMaxColumnType[], defaultSize?: number) => {
|
|
10
|
+
columns: any;
|
|
11
|
+
tableColumnsWidth: number;
|
|
12
|
+
};
|
|
10
13
|
export declare const setInitColumnsSize: (tableColumns: any, columnsMap: any) => any;
|
|
11
14
|
export declare const getShadowInfo: (column: any, table: any) => {
|
|
12
15
|
isRightFirst: boolean;
|
|
@@ -37,6 +37,7 @@ export function getTextWidth(text, fontSize) {
|
|
|
37
37
|
}
|
|
38
38
|
export var setRemainColumnsWidth = function setRemainColumnsWidth(initColumns, defaultSize) {
|
|
39
39
|
var columns = cloneDeep(initColumns);
|
|
40
|
+
var tableColumnsWidth = 0;
|
|
40
41
|
var fn = function fn(columns) {
|
|
41
42
|
columns.forEach(function (column) {
|
|
42
43
|
var _ref, _column$size;
|
|
@@ -44,13 +45,17 @@ export var setRemainColumnsWidth = function setRemainColumnsWidth(initColumns, d
|
|
|
44
45
|
if (!column.columns) {
|
|
45
46
|
var _ref2, _column$size2;
|
|
46
47
|
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;
|
|
48
|
+
tableColumnsWidth += column.size;
|
|
47
49
|
} else {
|
|
48
50
|
fn(column.columns);
|
|
49
51
|
}
|
|
50
52
|
});
|
|
51
53
|
};
|
|
52
54
|
fn(columns);
|
|
53
|
-
return
|
|
55
|
+
return {
|
|
56
|
+
columns: columns,
|
|
57
|
+
tableColumnsWidth: tableColumnsWidth
|
|
58
|
+
};
|
|
54
59
|
};
|
|
55
60
|
export var setInitColumnsSize = function setInitColumnsSize(tableColumns, columnsMap) {
|
|
56
61
|
var fn = function fn(columns) {
|
package/package.json
CHANGED