@arim-aisdc/public-components 0.0.16 → 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.
|
@@ -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, _tableBodyRef$
|
|
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,
|
|
@@ -543,16 +543,16 @@ var TableMax = function TableMax(_ref) {
|
|
|
543
543
|
emptyColumnWidth = _useState40[0],
|
|
544
544
|
setEmptyColumnWidth = _useState40[1];
|
|
545
545
|
useEffect(function () {
|
|
546
|
-
var _tableBodyRef$current, _tableBodyRef$current2;
|
|
546
|
+
var _tableBodyRef$current, _tableBodyRef$current2, _tableBodyRef$current3, _tableBodyRef$current4, _tableBodyRef$current5;
|
|
547
547
|
var hasSizeAllWidth = columnSizeInfo.hasSizeAllWidth;
|
|
548
548
|
//表格宽度,offsetWidth?下面监听里用的clientWidth
|
|
549
549
|
var tableContainerWidth = (_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 ? void 0 : _tableBodyRef$current.clientWidth;
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
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
553
|
setEmptyColumnWidth(remainWidth);
|
|
554
|
-
}, [(_tableBodyRef$
|
|
555
|
-
|
|
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 () {
|
|
556
556
|
//默认宽度
|
|
557
557
|
var defaultSize = 60;
|
|
558
558
|
var allCount = columnSizeInfo.allCount,
|
|
@@ -561,23 +561,22 @@ var TableMax = function TableMax(_ref) {
|
|
|
561
561
|
//表格宽度,offsetWidth?下面监听里用的clientWidth
|
|
562
562
|
// 空白宽度
|
|
563
563
|
var remainWidth = emptyColumnWidth;
|
|
564
|
-
|
|
565
564
|
// 没有配置宽度size的列的数量
|
|
566
565
|
var remainCount = allCount - hasSizeCount;
|
|
567
|
-
var
|
|
566
|
+
var aveSize;
|
|
568
567
|
if (remainWidth > 0 && remainCount) {
|
|
569
|
-
|
|
570
|
-
newColumns = setRemainColumnsWidth(newColumns, aveSize);
|
|
568
|
+
aveSize = Math.max(remainWidth / remainCount, defaultSize);
|
|
571
569
|
} else {
|
|
572
|
-
|
|
570
|
+
aveSize = undefined;
|
|
573
571
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
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))
|
|
577
578
|
|
|
578
|
-
|
|
579
|
-
useLayoutEffect(function () {
|
|
580
|
-
var centerTableSize = table.getTotalSize();
|
|
579
|
+
var centerTableSize = newInitTableColumnsWidth;
|
|
581
580
|
var containerWidth = tableBodyRef.current.clientWidth;
|
|
582
581
|
// const scrollBarWidth = tableBodyRef.current.clientWidth - tableBodyRef.current.scrollHeight < 0 ? 10 : 0;
|
|
583
582
|
var centerTableContainerWidth = containerWidth;
|
|
@@ -585,7 +584,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
585
584
|
var placeholderColumn = table.getAllColumns().some(function (item) {
|
|
586
585
|
return item.id === ColumnType.PlaceHolder;
|
|
587
586
|
}) ? table.getColumn(ColumnType.PlaceHolder) : null;
|
|
588
|
-
|
|
587
|
+
// let newColumns = initTableSizeColumns;
|
|
589
588
|
//有剩余空间时
|
|
590
589
|
if (centerTableRemainWidth > 0) {
|
|
591
590
|
// 有剩余空间且有空白列
|
|
@@ -630,9 +629,67 @@ var TableMax = function TableMax(_ref) {
|
|
|
630
629
|
}
|
|
631
630
|
}
|
|
632
631
|
setTableColumns(cloneDeep(newColumns));
|
|
633
|
-
}, [
|
|
634
|
-
|
|
635
|
-
|
|
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
|
+
// ]);
|
|
636
693
|
|
|
637
694
|
// 多选数据变化回调
|
|
638
695
|
useEffect(function () {
|
|
@@ -991,10 +1048,10 @@ var TableMax = function TableMax(_ref) {
|
|
|
991
1048
|
hasVerticalScrollBar: hasVerticalScrollBar
|
|
992
1049
|
};
|
|
993
1050
|
var getPinShadowInfo = useCallback(function () {
|
|
994
|
-
var _tableBodyRef$
|
|
995
|
-
scrollWidth = _tableBodyRef$
|
|
996
|
-
clientWidth = _tableBodyRef$
|
|
997
|
-
scrollLeft = _tableBodyRef$
|
|
1051
|
+
var _tableBodyRef$current10 = tableBodyRef.current,
|
|
1052
|
+
scrollWidth = _tableBodyRef$current10.scrollWidth,
|
|
1053
|
+
clientWidth = _tableBodyRef$current10.clientWidth,
|
|
1054
|
+
scrollLeft = _tableBodyRef$current10.scrollLeft;
|
|
998
1055
|
var newLeftShadowVisible, newRightShadowVisible;
|
|
999
1056
|
newLeftShadowVisible = scrollLeft > 0;
|
|
1000
1057
|
newRightShadowVisible = scrollLeft < scrollWidth - clientWidth;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
2
|
-
export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
3
|
-
export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
1
|
+
export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
2
|
+
export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
3
|
+
export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
4
4
|
declare const customSortFns: {
|
|
5
|
-
numberSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
6
|
-
stringSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
7
|
-
timeSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
5
|
+
numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
6
|
+
stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
7
|
+
timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
8
8
|
};
|
|
9
9
|
export default customSortFns;
|
|
10
10
|
export type SortFnType = keyof typeof customSortFns | undefined;
|
|
@@ -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) {
|