es-grid-template 1.7.35 → 1.7.37
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/es/table-component/InternalTable.js +21 -4
- package/es/table-component/TableContainerEdit.js +13 -18
- package/es/table-component/body/TableBodyCellEdit.js +91 -21
- package/es/table-component/hook/utils.d.ts +3 -0
- package/es/table-component/hook/utils.js +11 -1
- package/es/table-component/table/Grid.d.ts +2 -1
- package/es/table-component/table/Grid.js +30 -4
- package/es/table-component/table/TableWrapper.js +1 -1
- package/lib/table-component/InternalTable.js +21 -4
- package/lib/table-component/TableContainerEdit.js +13 -18
- package/lib/table-component/body/TableBodyCellEdit.js +90 -21
- package/lib/table-component/hook/utils.d.ts +3 -0
- package/lib/table-component/hook/utils.js +13 -2
- package/lib/table-component/table/Grid.d.ts +2 -1
- package/lib/table-component/table/Grid.js +29 -3
- package/lib/table-component/table/TableWrapper.js +1 -1
- package/package.json +1 -1
|
@@ -61,6 +61,7 @@ const InternalTable = props => {
|
|
|
61
61
|
groupAble,
|
|
62
62
|
groupSetting,
|
|
63
63
|
groupColumns,
|
|
64
|
+
selectionSettings,
|
|
64
65
|
// infiniteScroll,
|
|
65
66
|
// wrapSettings,
|
|
66
67
|
// onFilter,
|
|
@@ -164,6 +165,16 @@ const InternalTable = props => {
|
|
|
164
165
|
const [mergedFilterKeys, setMergedFilterKeys] = useMergedState(getAllRowKey(convertData), {
|
|
165
166
|
value: undefined
|
|
166
167
|
});
|
|
168
|
+
|
|
169
|
+
// ========================= Keys =========================
|
|
170
|
+
|
|
171
|
+
const {
|
|
172
|
+
selectedRowKeys,
|
|
173
|
+
defaultSelectedRowKeys
|
|
174
|
+
} = selectionSettings ?? {};
|
|
175
|
+
const [mergedSelectedKeys] = useMergedState(selectedRowKeys || defaultSelectedRowKeys || [], {
|
|
176
|
+
value: selectedRowKeys
|
|
177
|
+
});
|
|
167
178
|
const mergedData = React.useMemo(() => {
|
|
168
179
|
return filterDataByColumns(convertData, filterStates, sorterStates, mergedFilterKeys);
|
|
169
180
|
}, [convertData, filterStates, mergedFilterKeys, sorterStates]);
|
|
@@ -290,7 +301,9 @@ const InternalTable = props => {
|
|
|
290
301
|
setIsFullScreen: setIsFullScreen,
|
|
291
302
|
windowSize: windowSize,
|
|
292
303
|
height: height,
|
|
293
|
-
isDataTree: isDataTree
|
|
304
|
+
isDataTree: isDataTree,
|
|
305
|
+
selectionSettings: selectionSettings,
|
|
306
|
+
mergedSelectedKeys: mergedSelectedKeys
|
|
294
307
|
})), /*#__PURE__*/React.createElement(Modal, {
|
|
295
308
|
open: isFullScreen,
|
|
296
309
|
footer: null,
|
|
@@ -322,8 +335,10 @@ const InternalTable = props => {
|
|
|
322
335
|
paddingTop: 40
|
|
323
336
|
}
|
|
324
337
|
}, /*#__PURE__*/React.createElement(Grid, _extends({}, rest, {
|
|
325
|
-
t: t
|
|
326
|
-
id
|
|
338
|
+
t: t
|
|
339
|
+
// id={isFullScreen ? faker.string.alpha(20) : id}
|
|
340
|
+
,
|
|
341
|
+
id: faker.string.alpha(20),
|
|
327
342
|
prefix: prefix,
|
|
328
343
|
originData: convertData,
|
|
329
344
|
dataSource: mergedData,
|
|
@@ -354,7 +369,9 @@ const InternalTable = props => {
|
|
|
354
369
|
setIsFullScreen: setIsFullScreen,
|
|
355
370
|
height: windowSize.innerHeight - 70,
|
|
356
371
|
windowSize: windowSize,
|
|
357
|
-
isDataTree: isDataTree
|
|
372
|
+
isDataTree: isDataTree,
|
|
373
|
+
selectionSettings: selectionSettings,
|
|
374
|
+
mergedSelectedKeys: mergedSelectedKeys
|
|
358
375
|
})))));
|
|
359
376
|
};
|
|
360
377
|
export default InternalTable;
|
|
@@ -664,24 +664,19 @@ const TableContainerEdit = props => {
|
|
|
664
664
|
columnVirtualizer.measure();
|
|
665
665
|
});
|
|
666
666
|
}, [columnSizingState, columnVirtualizer]);
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
//
|
|
680
|
-
// return acc;
|
|
681
|
-
// }, {} as Record<string, number>)
|
|
682
|
-
// );
|
|
683
|
-
// }
|
|
684
|
-
// }, [table.getTotalSize(), windowSize.innerWidth])
|
|
667
|
+
React.useEffect(() => {
|
|
668
|
+
if (!containerRef.current) return;
|
|
669
|
+
const containerWidth = containerRef.current.offsetWidth - 1;
|
|
670
|
+
const totalWidth = table.getTotalSize();
|
|
671
|
+
if (totalWidth && totalWidth < containerWidth) {
|
|
672
|
+
const factor = containerWidth / totalWidth;
|
|
673
|
+
table.setColumnSizing(table.getAllLeafColumns().reduce((acc, col) => {
|
|
674
|
+
acc[col.id] = (col.getSize() || col.columnDef.size || 150) * factor;
|
|
675
|
+
return acc;
|
|
676
|
+
}, {}));
|
|
677
|
+
}
|
|
678
|
+
}, [table.getTotalSize(), windowSize.innerWidth, table.getState().columnSizing]);
|
|
679
|
+
// }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
|
|
685
680
|
|
|
686
681
|
React.useEffect(() => {
|
|
687
682
|
const totalHeight = minHeight ?? height;
|
|
@@ -9,6 +9,7 @@ getColIdsBetween, getCommonPinningStyles, getEditType, getRowIdsBetween, getSele
|
|
|
9
9
|
import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
|
|
10
10
|
import classNames from "classnames";
|
|
11
11
|
// import type { Dispatch, SetStateAction } from "react";
|
|
12
|
+
|
|
12
13
|
import React from "react";
|
|
13
14
|
import { TableContext } from "../useContext";
|
|
14
15
|
import EditableCell from "./EditableCell";
|
|
@@ -69,16 +70,73 @@ const renderSelection = args => {
|
|
|
69
70
|
const {
|
|
70
71
|
row
|
|
71
72
|
} = args.cell;
|
|
73
|
+
const {
|
|
74
|
+
cell,
|
|
75
|
+
expandIconColumnIndex,
|
|
76
|
+
isDataTree,
|
|
77
|
+
expanded,
|
|
78
|
+
setExpanded
|
|
79
|
+
} = args;
|
|
80
|
+
const {
|
|
81
|
+
selectionSettings,
|
|
82
|
+
setIsSelectionChange
|
|
83
|
+
} = args;
|
|
72
84
|
return /*#__PURE__*/React.createElement("div", {
|
|
73
|
-
className: "ui-rc_cell-content",
|
|
74
85
|
style: {
|
|
75
86
|
|
|
76
87
|
// paddingLeft: `${row.depth * 2}rem`,
|
|
77
88
|
}
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
89
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
91
|
+
style: {
|
|
92
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
93
|
+
}
|
|
94
|
+
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
95
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
96
|
+
onClick: () => {
|
|
97
|
+
const keys = Object.keys(expanded);
|
|
98
|
+
// @ts-ignore
|
|
99
|
+
const tmp = {
|
|
100
|
+
...expanded
|
|
101
|
+
};
|
|
102
|
+
if (keys.includes(cell.row.id)) {
|
|
103
|
+
delete tmp[cell.row.id];
|
|
104
|
+
setExpanded(tmp);
|
|
105
|
+
} else {
|
|
106
|
+
setExpanded(old => ({
|
|
107
|
+
...old,
|
|
108
|
+
[cell.row.id]: true
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
style: {
|
|
113
|
+
cursor: "pointer"
|
|
114
|
+
},
|
|
115
|
+
className: "ui-rc-table-row-expand"
|
|
116
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
|
|
117
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
118
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
119
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
120
|
+
})) : /*#__PURE__*/React.createElement("span", {
|
|
121
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
122
|
+
}))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Checkbox, {
|
|
123
|
+
checked: row.getIsSelected() || row.getIsAllSubRowsSelected(),
|
|
124
|
+
indeterminate: row.getIsSomeSelected() && selectionSettings && selectionSettings.mode === 'checkbox' && selectionSettings.type !== 'single'
|
|
125
|
+
// indeterminate={row.getIsSomeSelected() }
|
|
126
|
+
,
|
|
127
|
+
onChange: e => {
|
|
128
|
+
row.getToggleSelectedHandler()(e);
|
|
129
|
+
setIsSelectionChange({
|
|
130
|
+
isChange: true,
|
|
131
|
+
type: 'rowSelected',
|
|
132
|
+
rowData: row.original
|
|
133
|
+
});
|
|
134
|
+
// row.toggleSelected()
|
|
135
|
+
|
|
136
|
+
// table.setRowSelection({
|
|
137
|
+
// [row.id]: true
|
|
138
|
+
// })
|
|
139
|
+
}
|
|
82
140
|
})));
|
|
83
141
|
};
|
|
84
142
|
const TableBodyCellEdit = props => {
|
|
@@ -129,7 +187,9 @@ const TableBodyCellEdit = props => {
|
|
|
129
187
|
setExpanded,
|
|
130
188
|
expandable,
|
|
131
189
|
isDataTree,
|
|
132
|
-
handleCellClick
|
|
190
|
+
handleCellClick,
|
|
191
|
+
setIsSelectionChange,
|
|
192
|
+
selectionSettings
|
|
133
193
|
} = React.useContext(TableContext);
|
|
134
194
|
const expandIconColumnIndex = expandable?.expandIconColumnIndex;
|
|
135
195
|
const record = cell.row.original;
|
|
@@ -412,7 +472,7 @@ const TableBodyCellEdit = props => {
|
|
|
412
472
|
|
|
413
473
|
// setRangePasteState(selectPasteState)
|
|
414
474
|
}
|
|
415
|
-
const handleEdit = e => {
|
|
475
|
+
const handleEdit = (e, isKeyDown) => {
|
|
416
476
|
setEditingKey?.(record[rowKey]);
|
|
417
477
|
// setTooltipContent('')
|
|
418
478
|
|
|
@@ -426,8 +486,10 @@ const TableBodyCellEdit = props => {
|
|
|
426
486
|
setValue?.(name, value);
|
|
427
487
|
});
|
|
428
488
|
}
|
|
429
|
-
if (
|
|
430
|
-
|
|
489
|
+
if (isKeyDown) {
|
|
490
|
+
if (e.key === 'Enter' || editType === 'date' || e.type === 'dblclick') {} else {
|
|
491
|
+
setValue(columnMeta.field, editType === 'numeric' ? !isNaN(Number(e.key)) ? Number(e.key) : '' : e.key);
|
|
492
|
+
}
|
|
431
493
|
}
|
|
432
494
|
if (editType === 'select') {
|
|
433
495
|
|
|
@@ -592,13 +654,13 @@ const TableBodyCellEdit = props => {
|
|
|
592
654
|
return;
|
|
593
655
|
}
|
|
594
656
|
if (e.key === 'Enter') {
|
|
595
|
-
handleEdit(e);
|
|
657
|
+
handleEdit(e, true);
|
|
596
658
|
return;
|
|
597
659
|
}
|
|
598
660
|
if (e.key.length === 1 && !e.ctrlKey) {
|
|
599
661
|
e.preventDefault();
|
|
600
662
|
e.stopPropagation();
|
|
601
|
-
handleEdit(e);
|
|
663
|
+
handleEdit(e, true);
|
|
602
664
|
// setValue(cell.column.id, editType === 'numeric' ? (!isNaN(Number(e.key)) ? Number(e.key) : '') : e.key)
|
|
603
665
|
}
|
|
604
666
|
}
|
|
@@ -665,8 +727,9 @@ const TableBodyCellEdit = props => {
|
|
|
665
727
|
height: '36px',
|
|
666
728
|
userSelect: 'none',
|
|
667
729
|
width: cell.column.getSize(),
|
|
668
|
-
//
|
|
669
|
-
|
|
730
|
+
// flexBasis: cell.column.getSize(),
|
|
731
|
+
minWidth: cell.column.getSize(),
|
|
732
|
+
maxWidth: cell.column.getSize(),
|
|
670
733
|
...getCommonPinningStyles(cell.column)
|
|
671
734
|
},
|
|
672
735
|
onMouseDown: () => {
|
|
@@ -739,8 +802,8 @@ const TableBodyCellEdit = props => {
|
|
|
739
802
|
display: 'flex',
|
|
740
803
|
height: '36px',
|
|
741
804
|
width: cell.column.getSize(),
|
|
742
|
-
|
|
743
|
-
|
|
805
|
+
minWidth: cell.column.getSize(),
|
|
806
|
+
maxWidth: cell.column.getSize(),
|
|
744
807
|
...getCommonPinningStyles(cell.column)
|
|
745
808
|
}
|
|
746
809
|
}, renderCommand({
|
|
@@ -764,8 +827,8 @@ const TableBodyCellEdit = props => {
|
|
|
764
827
|
display: 'flex',
|
|
765
828
|
height: '36px',
|
|
766
829
|
width: cell.column.getSize(),
|
|
767
|
-
|
|
768
|
-
|
|
830
|
+
minWidth: cell.column.getSize(),
|
|
831
|
+
maxWidth: cell.column.getSize(),
|
|
769
832
|
...getCommonPinningStyles(cell.column)
|
|
770
833
|
}
|
|
771
834
|
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
|
|
@@ -801,8 +864,15 @@ const TableBodyCellEdit = props => {
|
|
|
801
864
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
802
865
|
})) : /*#__PURE__*/React.createElement("span", {
|
|
803
866
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
804
|
-
}))), renderSelection({
|
|
805
|
-
cell
|
|
867
|
+
}))), cell.column.id === "selection_column" && renderSelection({
|
|
868
|
+
cell,
|
|
869
|
+
table,
|
|
870
|
+
selectionSettings,
|
|
871
|
+
setIsSelectionChange,
|
|
872
|
+
expanded,
|
|
873
|
+
isDataTree,
|
|
874
|
+
setExpanded,
|
|
875
|
+
expandIconColumnIndex
|
|
806
876
|
}));
|
|
807
877
|
}
|
|
808
878
|
const handleChange = () => {
|
|
@@ -865,8 +935,8 @@ const TableBodyCellEdit = props => {
|
|
|
865
935
|
style: {
|
|
866
936
|
display: 'flex',
|
|
867
937
|
width: cell.column.getSize(),
|
|
868
|
-
|
|
869
|
-
|
|
938
|
+
minWidth: cell.column.getSize(),
|
|
939
|
+
maxWidth: cell.column.getSize(),
|
|
870
940
|
height: '36px',
|
|
871
941
|
...getCommonPinningStyles(cell.column),
|
|
872
942
|
cursor: isPasting ? 'crosshair' : undefined
|
|
@@ -130,5 +130,8 @@ export declare const updateColumns1: (columns: ColumnTable[], includes: string[]
|
|
|
130
130
|
export declare const convertToObj: (arr: any) => {
|
|
131
131
|
[k: string]: any;
|
|
132
132
|
};
|
|
133
|
+
export declare const convertToObjTrue: (arr: any) => {
|
|
134
|
+
[k: string]: any;
|
|
135
|
+
};
|
|
133
136
|
export declare const getDiffent2Array: (a: any[], b: any[]) => any[];
|
|
134
137
|
export declare function isTree(arr: any[]): boolean;
|
|
@@ -42,7 +42,7 @@ export const getCommonPinningStyles = column => {
|
|
|
42
42
|
// opacity: isPinned ? 0.5 : 1,
|
|
43
43
|
opacity: 1,
|
|
44
44
|
position: isPinned ? "sticky" : "relative",
|
|
45
|
-
|
|
45
|
+
width: column.getSize(),
|
|
46
46
|
zIndex: isPinned ? 2 : 0
|
|
47
47
|
// border: '1px solid #e5e7eb',
|
|
48
48
|
// borderTop: 0,
|
|
@@ -1863,6 +1863,16 @@ export const convertToObj = arr => {
|
|
|
1863
1863
|
|
|
1864
1864
|
return Object.fromEntries(arr.map(key => [key, false]));
|
|
1865
1865
|
};
|
|
1866
|
+
export const convertToObjTrue = arr => {
|
|
1867
|
+
// const result = Object.keys(obj).reduce((acc: any, key) => {
|
|
1868
|
+
// acc[key] = false;
|
|
1869
|
+
// return acc;
|
|
1870
|
+
// }, {});
|
|
1871
|
+
|
|
1872
|
+
// return result
|
|
1873
|
+
|
|
1874
|
+
return Object.fromEntries(arr.map(key => [key, true]));
|
|
1875
|
+
};
|
|
1866
1876
|
export const getDiffent2Array = (a, b) => {
|
|
1867
1877
|
return [...a.filter(x => !b.includes(x)), ...b.filter(x => !a.includes(x))];
|
|
1868
1878
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ColumnDef, ColumnPinningState, ExpandedState, VisibilityState } from '@tanstack/react-table';
|
|
2
2
|
import type { ColumnsTable, Sorter, TableProps } from '../type';
|
|
3
|
-
import type { Dispatch, SetStateAction } from 'react';
|
|
3
|
+
import type { Dispatch, Key, SetStateAction } from 'react';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
type Props<T> = Omit<TableProps<T>, 'columns'> & {
|
|
6
6
|
id: string;
|
|
@@ -23,6 +23,7 @@ type Props<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
23
23
|
triggerChangeColumns?: (args: any, keys: any, type: string) => void;
|
|
24
24
|
windowSize: any;
|
|
25
25
|
isDataTree: boolean;
|
|
26
|
+
mergedSelectedKeys: Key[];
|
|
26
27
|
};
|
|
27
28
|
declare const Grid: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
28
29
|
export default Grid;
|
|
@@ -17,7 +17,7 @@ import { arrayMove } from '@dnd-kit/sortable';
|
|
|
17
17
|
import React from 'react';
|
|
18
18
|
import TableContainer from "../TableContainer";
|
|
19
19
|
import { OperatorFeature } from "../features/operator";
|
|
20
|
-
import { convertFilters, filterDataByColumns, getAllRowKey } from "../hook/utils";
|
|
20
|
+
import { convertFilters, convertToObjTrue, filterDataByColumns, getAllRowKey } from "../hook/utils";
|
|
21
21
|
import TableContainerEdit from "../TableContainerEdit";
|
|
22
22
|
const Grid = props => {
|
|
23
23
|
const {
|
|
@@ -48,6 +48,7 @@ const Grid = props => {
|
|
|
48
48
|
editAble,
|
|
49
49
|
triggerChangeColumns,
|
|
50
50
|
infiniteScroll,
|
|
51
|
+
mergedSelectedKeys,
|
|
51
52
|
...rest
|
|
52
53
|
} = props;
|
|
53
54
|
const [columnResizeMode] = React.useState('onChange');
|
|
@@ -56,10 +57,15 @@ const Grid = props => {
|
|
|
56
57
|
pageIndex: pagination && pagination.currentPage ? pagination.currentPage - 1 : 0,
|
|
57
58
|
pageSize: pagination && pagination.pageSize ? pagination.pageSize : 20
|
|
58
59
|
});
|
|
59
|
-
|
|
60
|
+
|
|
61
|
+
// const [rowSelection, setRowSelection] = React.useState<RowSelectionState>({})
|
|
62
|
+
|
|
63
|
+
// const [rowSelection, setRowSelection] = React.useState<RowSelectionState>(convertToObjTrue(selectionSettings?.selectedRowKeys ?? []))
|
|
64
|
+
const [rowSelection, setRowSelection] = React.useState(convertToObjTrue(mergedSelectedKeys));
|
|
60
65
|
const [grouping, setGrouping] = React.useState([]);
|
|
61
66
|
const [columnSizing, setColumnSizing] = React.useState({});
|
|
62
|
-
|
|
67
|
+
const [manualUpdate, setManualUpdate] = React.useState(false);
|
|
68
|
+
// const [manualResize, setManualResize] = React.useState(false)
|
|
63
69
|
|
|
64
70
|
const [columnFilters, setColumnFilters] = React.useState([]);
|
|
65
71
|
const [operator, setOperator] = React.useState([]);
|
|
@@ -97,7 +103,7 @@ const Grid = props => {
|
|
|
97
103
|
getSubRows: row => row.children,
|
|
98
104
|
// RowSelection
|
|
99
105
|
enableSubRowSelection: selectionSettings && selectionSettings.mode === 'checkbox' && selectionSettings.type !== 'single',
|
|
100
|
-
enableMultiRowSelection: selectionSettings && selectionSettings.mode === 'checkbox'
|
|
106
|
+
enableMultiRowSelection: selectionSettings && (selectionSettings.mode === 'checkbox' || selectionSettings.type !== 'single'),
|
|
101
107
|
enableRowSelection: true,
|
|
102
108
|
onRowSelectionChange: setRowSelection,
|
|
103
109
|
// RowSelection
|
|
@@ -132,8 +138,24 @@ const Grid = props => {
|
|
|
132
138
|
|
|
133
139
|
// debugTable: true
|
|
134
140
|
});
|
|
141
|
+
React.useEffect(() => {
|
|
142
|
+
if (columnHidden) {
|
|
143
|
+
const abb = table.getVisibleLeafColumns()?.[0];
|
|
144
|
+
if (abb) {
|
|
145
|
+
setColumnSizing({
|
|
146
|
+
"#": abb.getSize()
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}, [columnHidden, table]);
|
|
151
|
+
React.useEffect(() => {
|
|
152
|
+
if (!manualUpdate) {
|
|
153
|
+
setRowSelection(convertToObjTrue(mergedSelectedKeys));
|
|
154
|
+
}
|
|
155
|
+
}, [manualUpdate, mergedSelectedKeys]);
|
|
135
156
|
React.useEffect(() => {
|
|
136
157
|
if (isSelectionChange.isChange) {
|
|
158
|
+
setManualUpdate(true);
|
|
137
159
|
const aa = table.getState().rowSelection;
|
|
138
160
|
const dataTable = table.getRowModel().flatRows;
|
|
139
161
|
const ids = Object.keys(aa);
|
|
@@ -144,6 +166,10 @@ const Grid = props => {
|
|
|
144
166
|
rowData: isSelectionChange.rowData,
|
|
145
167
|
selected: rs
|
|
146
168
|
});
|
|
169
|
+
setIsSelectionChange(prev => ({
|
|
170
|
+
...prev,
|
|
171
|
+
isChange: false
|
|
172
|
+
}));
|
|
147
173
|
}
|
|
148
174
|
}, [isSelectionChange, rowSelected, rowSelection, table]);
|
|
149
175
|
React.useEffect(() => {
|
|
@@ -173,7 +173,7 @@ const TableWrapper = props => {
|
|
|
173
173
|
'ui-rc-table-ping-left': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) > 0
|
|
174
174
|
})
|
|
175
175
|
}, /*#__PURE__*/React.createElement("div", {
|
|
176
|
-
|
|
176
|
+
// id={id}
|
|
177
177
|
ref: tableContainerRef,
|
|
178
178
|
style: {
|
|
179
179
|
overflow: 'auto',
|
|
@@ -67,6 +67,7 @@ const InternalTable = props => {
|
|
|
67
67
|
groupAble,
|
|
68
68
|
groupSetting,
|
|
69
69
|
groupColumns,
|
|
70
|
+
selectionSettings,
|
|
70
71
|
// infiniteScroll,
|
|
71
72
|
// wrapSettings,
|
|
72
73
|
// onFilter,
|
|
@@ -170,6 +171,16 @@ const InternalTable = props => {
|
|
|
170
171
|
const [mergedFilterKeys, setMergedFilterKeys] = (0, _useMergedState.default)((0, _utils.getAllRowKey)(convertData), {
|
|
171
172
|
value: undefined
|
|
172
173
|
});
|
|
174
|
+
|
|
175
|
+
// ========================= Keys =========================
|
|
176
|
+
|
|
177
|
+
const {
|
|
178
|
+
selectedRowKeys,
|
|
179
|
+
defaultSelectedRowKeys
|
|
180
|
+
} = selectionSettings ?? {};
|
|
181
|
+
const [mergedSelectedKeys] = (0, _useMergedState.default)(selectedRowKeys || defaultSelectedRowKeys || [], {
|
|
182
|
+
value: selectedRowKeys
|
|
183
|
+
});
|
|
173
184
|
const mergedData = _react.default.useMemo(() => {
|
|
174
185
|
return (0, _utils.filterDataByColumns)(convertData, filterStates, sorterStates, mergedFilterKeys);
|
|
175
186
|
}, [convertData, filterStates, mergedFilterKeys, sorterStates]);
|
|
@@ -296,7 +307,9 @@ const InternalTable = props => {
|
|
|
296
307
|
setIsFullScreen: setIsFullScreen,
|
|
297
308
|
windowSize: windowSize,
|
|
298
309
|
height: height,
|
|
299
|
-
isDataTree: isDataTree
|
|
310
|
+
isDataTree: isDataTree,
|
|
311
|
+
selectionSettings: selectionSettings,
|
|
312
|
+
mergedSelectedKeys: mergedSelectedKeys
|
|
300
313
|
})), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
|
|
301
314
|
open: isFullScreen,
|
|
302
315
|
footer: null,
|
|
@@ -328,8 +341,10 @@ const InternalTable = props => {
|
|
|
328
341
|
paddingTop: 40
|
|
329
342
|
}
|
|
330
343
|
}, /*#__PURE__*/_react.default.createElement(_Grid.default, (0, _extends2.default)({}, rest, {
|
|
331
|
-
t: t
|
|
332
|
-
id
|
|
344
|
+
t: t
|
|
345
|
+
// id={isFullScreen ? faker.string.alpha(20) : id}
|
|
346
|
+
,
|
|
347
|
+
id: _faker.faker.string.alpha(20),
|
|
333
348
|
prefix: prefix,
|
|
334
349
|
originData: convertData,
|
|
335
350
|
dataSource: mergedData,
|
|
@@ -360,7 +375,9 @@ const InternalTable = props => {
|
|
|
360
375
|
setIsFullScreen: setIsFullScreen,
|
|
361
376
|
height: windowSize.innerHeight - 70,
|
|
362
377
|
windowSize: windowSize,
|
|
363
|
-
isDataTree: isDataTree
|
|
378
|
+
isDataTree: isDataTree,
|
|
379
|
+
selectionSettings: selectionSettings,
|
|
380
|
+
mergedSelectedKeys: mergedSelectedKeys
|
|
364
381
|
})))));
|
|
365
382
|
};
|
|
366
383
|
var _default = exports.default = InternalTable;
|
|
@@ -671,24 +671,19 @@ const TableContainerEdit = props => {
|
|
|
671
671
|
columnVirtualizer.measure();
|
|
672
672
|
});
|
|
673
673
|
}, [columnSizingState, columnVirtualizer]);
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
//
|
|
687
|
-
// return acc;
|
|
688
|
-
// }, {} as Record<string, number>)
|
|
689
|
-
// );
|
|
690
|
-
// }
|
|
691
|
-
// }, [table.getTotalSize(), windowSize.innerWidth])
|
|
674
|
+
_react.default.useEffect(() => {
|
|
675
|
+
if (!containerRef.current) return;
|
|
676
|
+
const containerWidth = containerRef.current.offsetWidth - 1;
|
|
677
|
+
const totalWidth = table.getTotalSize();
|
|
678
|
+
if (totalWidth && totalWidth < containerWidth) {
|
|
679
|
+
const factor = containerWidth / totalWidth;
|
|
680
|
+
table.setColumnSizing(table.getAllLeafColumns().reduce((acc, col) => {
|
|
681
|
+
acc[col.id] = (col.getSize() || col.columnDef.size || 150) * factor;
|
|
682
|
+
return acc;
|
|
683
|
+
}, {}));
|
|
684
|
+
}
|
|
685
|
+
}, [table.getTotalSize(), windowSize.innerWidth, table.getState().columnSizing]);
|
|
686
|
+
// }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
|
|
692
687
|
|
|
693
688
|
_react.default.useEffect(() => {
|
|
694
689
|
const totalHeight = minHeight ?? height;
|
|
@@ -76,16 +76,73 @@ const renderSelection = args => {
|
|
|
76
76
|
const {
|
|
77
77
|
row
|
|
78
78
|
} = args.cell;
|
|
79
|
+
const {
|
|
80
|
+
cell,
|
|
81
|
+
expandIconColumnIndex,
|
|
82
|
+
isDataTree,
|
|
83
|
+
expanded,
|
|
84
|
+
setExpanded
|
|
85
|
+
} = args;
|
|
86
|
+
const {
|
|
87
|
+
selectionSettings,
|
|
88
|
+
setIsSelectionChange
|
|
89
|
+
} = args;
|
|
79
90
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
80
|
-
className: "ui-rc_cell-content",
|
|
81
91
|
style: {
|
|
82
92
|
|
|
83
93
|
// paddingLeft: `${row.depth * 2}rem`,
|
|
84
94
|
}
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
|
|
96
|
+
className: "ui-rc-table-row-expand-trigger",
|
|
97
|
+
style: {
|
|
98
|
+
paddingLeft: `${cell.row.depth * 25}px`
|
|
99
|
+
}
|
|
100
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
|
|
101
|
+
// onClick: row.getToggleExpandedHandler(),
|
|
102
|
+
onClick: () => {
|
|
103
|
+
const keys = Object.keys(expanded);
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
const tmp = {
|
|
106
|
+
...expanded
|
|
107
|
+
};
|
|
108
|
+
if (keys.includes(cell.row.id)) {
|
|
109
|
+
delete tmp[cell.row.id];
|
|
110
|
+
setExpanded(tmp);
|
|
111
|
+
} else {
|
|
112
|
+
setExpanded(old => ({
|
|
113
|
+
...old,
|
|
114
|
+
[cell.row.id]: true
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
style: {
|
|
119
|
+
cursor: "pointer"
|
|
120
|
+
},
|
|
121
|
+
className: "ui-rc-table-row-expand"
|
|
122
|
+
}, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
|
|
123
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
|
|
124
|
+
}) : /*#__PURE__*/_react.default.createElement("span", {
|
|
125
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
126
|
+
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
127
|
+
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
128
|
+
}))), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
|
|
129
|
+
checked: row.getIsSelected() || row.getIsAllSubRowsSelected(),
|
|
130
|
+
indeterminate: row.getIsSomeSelected() && selectionSettings && selectionSettings.mode === 'checkbox' && selectionSettings.type !== 'single'
|
|
131
|
+
// indeterminate={row.getIsSomeSelected() }
|
|
132
|
+
,
|
|
133
|
+
onChange: e => {
|
|
134
|
+
row.getToggleSelectedHandler()(e);
|
|
135
|
+
setIsSelectionChange({
|
|
136
|
+
isChange: true,
|
|
137
|
+
type: 'rowSelected',
|
|
138
|
+
rowData: row.original
|
|
139
|
+
});
|
|
140
|
+
// row.toggleSelected()
|
|
141
|
+
|
|
142
|
+
// table.setRowSelection({
|
|
143
|
+
// [row.id]: true
|
|
144
|
+
// })
|
|
145
|
+
}
|
|
89
146
|
})));
|
|
90
147
|
};
|
|
91
148
|
const TableBodyCellEdit = props => {
|
|
@@ -136,7 +193,9 @@ const TableBodyCellEdit = props => {
|
|
|
136
193
|
setExpanded,
|
|
137
194
|
expandable,
|
|
138
195
|
isDataTree,
|
|
139
|
-
handleCellClick
|
|
196
|
+
handleCellClick,
|
|
197
|
+
setIsSelectionChange,
|
|
198
|
+
selectionSettings
|
|
140
199
|
} = _react.default.useContext(_useContext.TableContext);
|
|
141
200
|
const expandIconColumnIndex = expandable?.expandIconColumnIndex;
|
|
142
201
|
const record = cell.row.original;
|
|
@@ -419,7 +478,7 @@ const TableBodyCellEdit = props => {
|
|
|
419
478
|
|
|
420
479
|
// setRangePasteState(selectPasteState)
|
|
421
480
|
}
|
|
422
|
-
const handleEdit = e => {
|
|
481
|
+
const handleEdit = (e, isKeyDown) => {
|
|
423
482
|
setEditingKey?.(record[rowKey]);
|
|
424
483
|
// setTooltipContent('')
|
|
425
484
|
|
|
@@ -433,8 +492,10 @@ const TableBodyCellEdit = props => {
|
|
|
433
492
|
setValue?.(name, value);
|
|
434
493
|
});
|
|
435
494
|
}
|
|
436
|
-
if (
|
|
437
|
-
|
|
495
|
+
if (isKeyDown) {
|
|
496
|
+
if (e.key === 'Enter' || editType === 'date' || e.type === 'dblclick') {} else {
|
|
497
|
+
setValue(columnMeta.field, editType === 'numeric' ? !isNaN(Number(e.key)) ? Number(e.key) : '' : e.key);
|
|
498
|
+
}
|
|
438
499
|
}
|
|
439
500
|
if (editType === 'select') {
|
|
440
501
|
|
|
@@ -599,13 +660,13 @@ const TableBodyCellEdit = props => {
|
|
|
599
660
|
return;
|
|
600
661
|
}
|
|
601
662
|
if (e.key === 'Enter') {
|
|
602
|
-
handleEdit(e);
|
|
663
|
+
handleEdit(e, true);
|
|
603
664
|
return;
|
|
604
665
|
}
|
|
605
666
|
if (e.key.length === 1 && !e.ctrlKey) {
|
|
606
667
|
e.preventDefault();
|
|
607
668
|
e.stopPropagation();
|
|
608
|
-
handleEdit(e);
|
|
669
|
+
handleEdit(e, true);
|
|
609
670
|
// setValue(cell.column.id, editType === 'numeric' ? (!isNaN(Number(e.key)) ? Number(e.key) : '') : e.key)
|
|
610
671
|
}
|
|
611
672
|
}
|
|
@@ -672,8 +733,9 @@ const TableBodyCellEdit = props => {
|
|
|
672
733
|
height: '36px',
|
|
673
734
|
userSelect: 'none',
|
|
674
735
|
width: cell.column.getSize(),
|
|
675
|
-
//
|
|
676
|
-
|
|
736
|
+
// flexBasis: cell.column.getSize(),
|
|
737
|
+
minWidth: cell.column.getSize(),
|
|
738
|
+
maxWidth: cell.column.getSize(),
|
|
677
739
|
...(0, _utils.getCommonPinningStyles)(cell.column)
|
|
678
740
|
},
|
|
679
741
|
onMouseDown: () => {
|
|
@@ -746,8 +808,8 @@ const TableBodyCellEdit = props => {
|
|
|
746
808
|
display: 'flex',
|
|
747
809
|
height: '36px',
|
|
748
810
|
width: cell.column.getSize(),
|
|
749
|
-
|
|
750
|
-
|
|
811
|
+
minWidth: cell.column.getSize(),
|
|
812
|
+
maxWidth: cell.column.getSize(),
|
|
751
813
|
...(0, _utils.getCommonPinningStyles)(cell.column)
|
|
752
814
|
}
|
|
753
815
|
}, renderCommand({
|
|
@@ -771,8 +833,8 @@ const TableBodyCellEdit = props => {
|
|
|
771
833
|
display: 'flex',
|
|
772
834
|
height: '36px',
|
|
773
835
|
width: cell.column.getSize(),
|
|
774
|
-
|
|
775
|
-
|
|
836
|
+
minWidth: cell.column.getSize(),
|
|
837
|
+
maxWidth: cell.column.getSize(),
|
|
776
838
|
...(0, _utils.getCommonPinningStyles)(cell.column)
|
|
777
839
|
}
|
|
778
840
|
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -808,8 +870,15 @@ const TableBodyCellEdit = props => {
|
|
|
808
870
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
809
871
|
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
810
872
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
811
|
-
}))), renderSelection({
|
|
812
|
-
cell
|
|
873
|
+
}))), cell.column.id === "selection_column" && renderSelection({
|
|
874
|
+
cell,
|
|
875
|
+
table,
|
|
876
|
+
selectionSettings,
|
|
877
|
+
setIsSelectionChange,
|
|
878
|
+
expanded,
|
|
879
|
+
isDataTree,
|
|
880
|
+
setExpanded,
|
|
881
|
+
expandIconColumnIndex
|
|
813
882
|
}));
|
|
814
883
|
}
|
|
815
884
|
const handleChange = () => {
|
|
@@ -872,8 +941,8 @@ const TableBodyCellEdit = props => {
|
|
|
872
941
|
style: {
|
|
873
942
|
display: 'flex',
|
|
874
943
|
width: cell.column.getSize(),
|
|
875
|
-
|
|
876
|
-
|
|
944
|
+
minWidth: cell.column.getSize(),
|
|
945
|
+
maxWidth: cell.column.getSize(),
|
|
877
946
|
height: '36px',
|
|
878
947
|
...(0, _utils.getCommonPinningStyles)(cell.column),
|
|
879
948
|
cursor: isPasting ? 'crosshair' : undefined
|
|
@@ -130,5 +130,8 @@ export declare const updateColumns1: (columns: ColumnTable[], includes: string[]
|
|
|
130
130
|
export declare const convertToObj: (arr: any) => {
|
|
131
131
|
[k: string]: any;
|
|
132
132
|
};
|
|
133
|
+
export declare const convertToObjTrue: (arr: any) => {
|
|
134
|
+
[k: string]: any;
|
|
135
|
+
};
|
|
133
136
|
export declare const getDiffent2Array: (a: any[], b: any[]) => any[];
|
|
134
137
|
export declare function isTree(arr: any[]): boolean;
|
|
@@ -18,7 +18,7 @@ exports.convertArrayWithIndent = void 0;
|
|
|
18
18
|
exports.convertColumnsToTreeData = convertColumnsToTreeData;
|
|
19
19
|
exports.convertFilters = exports.convertDayjsToDate = exports.convertDateToDayjs = void 0;
|
|
20
20
|
exports.convertFormat = convertFormat;
|
|
21
|
-
exports.extendsObject = exports.detectSeparators = exports.customWeekStartEndFormat = exports.convertToObj = exports.convertLabelToTitle = void 0;
|
|
21
|
+
exports.extendsObject = exports.detectSeparators = exports.customWeekStartEndFormat = exports.convertToObjTrue = exports.convertToObj = exports.convertLabelToTitle = void 0;
|
|
22
22
|
exports.filterDataByColumns = filterDataByColumns;
|
|
23
23
|
exports.getAllVisibleKeys1 = exports.getAllVisibleKeys = exports.getAllRowKey = exports.genPresets = exports.flattenData = exports.flattenArray = exports.flatColumns2 = exports.findItemByKey = void 0;
|
|
24
24
|
exports.getCellsByPosition = getCellsByPosition;
|
|
@@ -88,7 +88,7 @@ const getCommonPinningStyles = column => {
|
|
|
88
88
|
// opacity: isPinned ? 0.5 : 1,
|
|
89
89
|
opacity: 1,
|
|
90
90
|
position: isPinned ? "sticky" : "relative",
|
|
91
|
-
|
|
91
|
+
width: column.getSize(),
|
|
92
92
|
zIndex: isPinned ? 2 : 0
|
|
93
93
|
// border: '1px solid #e5e7eb',
|
|
94
94
|
// borderTop: 0,
|
|
@@ -1961,6 +1961,17 @@ const convertToObj = arr => {
|
|
|
1961
1961
|
return Object.fromEntries(arr.map(key => [key, false]));
|
|
1962
1962
|
};
|
|
1963
1963
|
exports.convertToObj = convertToObj;
|
|
1964
|
+
const convertToObjTrue = arr => {
|
|
1965
|
+
// const result = Object.keys(obj).reduce((acc: any, key) => {
|
|
1966
|
+
// acc[key] = false;
|
|
1967
|
+
// return acc;
|
|
1968
|
+
// }, {});
|
|
1969
|
+
|
|
1970
|
+
// return result
|
|
1971
|
+
|
|
1972
|
+
return Object.fromEntries(arr.map(key => [key, true]));
|
|
1973
|
+
};
|
|
1974
|
+
exports.convertToObjTrue = convertToObjTrue;
|
|
1964
1975
|
const getDiffent2Array = (a, b) => {
|
|
1965
1976
|
return [...a.filter(x => !b.includes(x)), ...b.filter(x => !a.includes(x))];
|
|
1966
1977
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ColumnDef, ColumnPinningState, ExpandedState, VisibilityState } from '@tanstack/react-table';
|
|
2
2
|
import type { ColumnsTable, Sorter, TableProps } from '../type';
|
|
3
|
-
import type { Dispatch, SetStateAction } from 'react';
|
|
3
|
+
import type { Dispatch, Key, SetStateAction } from 'react';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
type Props<T> = Omit<TableProps<T>, 'columns'> & {
|
|
6
6
|
id: string;
|
|
@@ -23,6 +23,7 @@ type Props<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
23
23
|
triggerChangeColumns?: (args: any, keys: any, type: string) => void;
|
|
24
24
|
windowSize: any;
|
|
25
25
|
isDataTree: boolean;
|
|
26
|
+
mergedSelectedKeys: Key[];
|
|
26
27
|
};
|
|
27
28
|
declare const Grid: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
28
29
|
export default Grid;
|
|
@@ -50,6 +50,7 @@ const Grid = props => {
|
|
|
50
50
|
editAble,
|
|
51
51
|
triggerChangeColumns,
|
|
52
52
|
infiniteScroll,
|
|
53
|
+
mergedSelectedKeys,
|
|
53
54
|
...rest
|
|
54
55
|
} = props;
|
|
55
56
|
const [columnResizeMode] = _react.default.useState('onChange');
|
|
@@ -58,10 +59,15 @@ const Grid = props => {
|
|
|
58
59
|
pageIndex: pagination && pagination.currentPage ? pagination.currentPage - 1 : 0,
|
|
59
60
|
pageSize: pagination && pagination.pageSize ? pagination.pageSize : 20
|
|
60
61
|
});
|
|
61
|
-
|
|
62
|
+
|
|
63
|
+
// const [rowSelection, setRowSelection] = React.useState<RowSelectionState>({})
|
|
64
|
+
|
|
65
|
+
// const [rowSelection, setRowSelection] = React.useState<RowSelectionState>(convertToObjTrue(selectionSettings?.selectedRowKeys ?? []))
|
|
66
|
+
const [rowSelection, setRowSelection] = _react.default.useState((0, _utils.convertToObjTrue)(mergedSelectedKeys));
|
|
62
67
|
const [grouping, setGrouping] = _react.default.useState([]);
|
|
63
68
|
const [columnSizing, setColumnSizing] = _react.default.useState({});
|
|
64
|
-
|
|
69
|
+
const [manualUpdate, setManualUpdate] = _react.default.useState(false);
|
|
70
|
+
// const [manualResize, setManualResize] = React.useState(false)
|
|
65
71
|
|
|
66
72
|
const [columnFilters, setColumnFilters] = _react.default.useState([]);
|
|
67
73
|
const [operator, setOperator] = _react.default.useState([]);
|
|
@@ -99,7 +105,7 @@ const Grid = props => {
|
|
|
99
105
|
getSubRows: row => row.children,
|
|
100
106
|
// RowSelection
|
|
101
107
|
enableSubRowSelection: selectionSettings && selectionSettings.mode === 'checkbox' && selectionSettings.type !== 'single',
|
|
102
|
-
enableMultiRowSelection: selectionSettings && selectionSettings.mode === 'checkbox'
|
|
108
|
+
enableMultiRowSelection: selectionSettings && (selectionSettings.mode === 'checkbox' || selectionSettings.type !== 'single'),
|
|
103
109
|
enableRowSelection: true,
|
|
104
110
|
onRowSelectionChange: setRowSelection,
|
|
105
111
|
// RowSelection
|
|
@@ -134,8 +140,24 @@ const Grid = props => {
|
|
|
134
140
|
|
|
135
141
|
// debugTable: true
|
|
136
142
|
});
|
|
143
|
+
_react.default.useEffect(() => {
|
|
144
|
+
if (columnHidden) {
|
|
145
|
+
const abb = table.getVisibleLeafColumns()?.[0];
|
|
146
|
+
if (abb) {
|
|
147
|
+
setColumnSizing({
|
|
148
|
+
"#": abb.getSize()
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}, [columnHidden, table]);
|
|
153
|
+
_react.default.useEffect(() => {
|
|
154
|
+
if (!manualUpdate) {
|
|
155
|
+
setRowSelection((0, _utils.convertToObjTrue)(mergedSelectedKeys));
|
|
156
|
+
}
|
|
157
|
+
}, [manualUpdate, mergedSelectedKeys]);
|
|
137
158
|
_react.default.useEffect(() => {
|
|
138
159
|
if (isSelectionChange.isChange) {
|
|
160
|
+
setManualUpdate(true);
|
|
139
161
|
const aa = table.getState().rowSelection;
|
|
140
162
|
const dataTable = table.getRowModel().flatRows;
|
|
141
163
|
const ids = Object.keys(aa);
|
|
@@ -146,6 +168,10 @@ const Grid = props => {
|
|
|
146
168
|
rowData: isSelectionChange.rowData,
|
|
147
169
|
selected: rs
|
|
148
170
|
});
|
|
171
|
+
setIsSelectionChange(prev => ({
|
|
172
|
+
...prev,
|
|
173
|
+
isChange: false
|
|
174
|
+
}));
|
|
149
175
|
}
|
|
150
176
|
}, [isSelectionChange, rowSelected, rowSelection, table]);
|
|
151
177
|
_react.default.useEffect(() => {
|
|
@@ -182,7 +182,7 @@ const TableWrapper = props => {
|
|
|
182
182
|
'ui-rc-table-ping-left': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) > 0
|
|
183
183
|
})
|
|
184
184
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
185
|
-
|
|
185
|
+
// id={id}
|
|
186
186
|
ref: tableContainerRef,
|
|
187
187
|
style: {
|
|
188
188
|
overflow: 'auto',
|