es-grid-template 1.8.71 → 1.8.73
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/grid-component/TempTable.js +2 -1
- package/es/grid-component/type.d.ts +1 -3
- package/es/group-component/ColumnsChoose.d.ts +13 -0
- package/es/group-component/ColumnsChoose.js +211 -0
- package/es/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/es/group-component/ColumnsGroup/ColumnsGroup.js +230 -0
- package/es/group-component/ColumnsGroup/index.d.ts +1 -0
- package/es/group-component/ColumnsGroup/index.js +1 -0
- package/es/group-component/ContextMenu.d.ts +19 -0
- package/es/group-component/ContextMenu.js +74 -0
- package/es/group-component/InternalTable.d.ts +8 -0
- package/es/group-component/InternalTable.js +224 -0
- package/es/group-component/TableContainer.d.ts +49 -0
- package/es/group-component/TableContainer.js +375 -0
- package/es/group-component/TableContainerEdit.d.ts +48 -0
- package/es/group-component/TableContainerEdit.js +2068 -0
- package/es/group-component/body/EditableCell.d.ts +16 -0
- package/es/group-component/body/EditableCell.js +1066 -0
- package/es/group-component/body/TableBody.d.ts +14 -0
- package/es/group-component/body/TableBody.js +82 -0
- package/es/group-component/body/TableBodyCell.d.ts +12 -0
- package/es/group-component/body/TableBodyCell.js +587 -0
- package/es/group-component/body/TableBodyCellEdit.d.ts +17 -0
- package/es/group-component/body/TableBodyCellEdit.js +1398 -0
- package/es/group-component/body/TableBodyCellEmpty.d.ts +12 -0
- package/es/group-component/body/TableBodyCellEmpty.js +149 -0
- package/es/group-component/body/TableBodyRow.d.ts +21 -0
- package/es/group-component/body/TableBodyRow.js +199 -0
- package/es/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
- package/es/group-component/body/TableBodyRowGroupCell.js +567 -0
- package/es/group-component/components/ControlCheckbox.d.ts +13 -0
- package/es/group-component/components/ControlCheckbox.js +84 -0
- package/es/group-component/components/EditForm/EditForm.d.ts +27 -0
- package/es/group-component/components/EditForm/EditForm.js +394 -0
- package/es/group-component/components/EditForm/index.d.ts +1 -0
- package/es/group-component/components/EditForm/index.js +1 -0
- package/es/group-component/components/InputControl/InputControl.d.ts +27 -0
- package/es/group-component/components/InputControl/InputControl.js +118 -0
- package/es/group-component/components/InputControl/index.d.ts +1 -0
- package/es/group-component/components/InputControl/index.js +1 -0
- package/es/group-component/components/async-select/index.d.ts +11 -0
- package/es/group-component/components/async-select/index.js +38 -0
- package/es/group-component/components/async-table-select/index.d.ts +11 -0
- package/es/group-component/components/async-table-select/index.js +40 -0
- package/es/group-component/components/checkbox-control/index.d.ts +13 -0
- package/es/group-component/components/checkbox-control/index.js +40 -0
- package/es/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/es/group-component/components/checkbox-filter/CheckboxFilter.js +258 -0
- package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/es/group-component/components/checkbox-filter/FilterSearch.js +36 -0
- package/es/group-component/components/command/Command.d.ts +10 -0
- package/es/group-component/components/command/Command.js +35 -0
- package/es/group-component/components/number/index.d.ts +12 -0
- package/es/group-component/components/number/index.js +42 -0
- package/es/group-component/components/number-range/index.d.ts +13 -0
- package/es/group-component/components/number-range/index.js +79 -0
- package/es/group-component/features/operator.d.ts +24 -0
- package/es/group-component/features/operator.js +62 -0
- package/es/group-component/footer/TableFooter.d.ts +7 -0
- package/es/group-component/footer/TableFooter.js +34 -0
- package/es/group-component/footer/TableFooterCell.d.ts +7 -0
- package/es/group-component/footer/TableFooterCell.js +66 -0
- package/es/group-component/footer/TableFooterRow.d.ts +8 -0
- package/es/group-component/footer/TableFooterRow.js +30 -0
- package/es/group-component/header/TableHead.d.ts +15 -0
- package/es/group-component/header/TableHead.js +98 -0
- package/es/group-component/header/TableHeadCell.d.ts +15 -0
- package/es/group-component/header/TableHeadCell.js +310 -0
- package/es/group-component/header/TableHeadCell2.d.ts +17 -0
- package/es/group-component/header/TableHeadCell2.js +321 -0
- package/es/group-component/header/TableHeadGroupCell.d.ts +17 -0
- package/es/group-component/header/TableHeadGroupCell.js +94 -0
- package/es/group-component/header/TableHeadRow.d.ts +15 -0
- package/es/group-component/header/TableHeadRow.js +52 -0
- package/es/group-component/header/renderFilter.d.ts +20 -0
- package/es/group-component/header/renderFilter.js +291 -0
- package/es/group-component/hook/convert.d.ts +1 -0
- package/es/group-component/hook/convert.js +28 -0
- package/es/group-component/hook/useColumns.d.ts +28 -0
- package/es/group-component/hook/useColumns.js +306 -0
- package/es/group-component/hook/useFilterOperator.d.ts +7 -0
- package/es/group-component/hook/useFilterOperator.js +33 -0
- package/es/group-component/hook/utils.d.ts +220 -0
- package/es/group-component/hook/utils.js +2340 -0
- package/es/group-component/index.d.ts +2 -0
- package/es/group-component/index.js +2 -0
- package/es/group-component/style.d.ts +22 -0
- package/es/group-component/style.js +48 -0
- package/es/group-component/style.scss +1438 -0
- package/es/group-component/table/Grid.d.ts +33 -0
- package/es/group-component/table/Grid.js +439 -0
- package/es/group-component/table/TableWrapper.d.ts +33 -0
- package/es/group-component/table/TableWrapper.js +250 -0
- package/es/group-component/useContext.d.ts +100 -0
- package/es/group-component/useContext.js +21 -0
- package/es/table-component/InternalTable.js +9 -2
- package/es/table-component/TableContainer.d.ts +1 -0
- package/es/table-component/TableContainer.js +6 -2
- package/es/table-component/TableContainerEdit.d.ts +1 -0
- package/es/table-component/TableContainerEdit.js +4 -2
- package/es/table-component/body/TableBodyCell.js +49 -40
- package/es/table-component/body/TableBodyCellEdit.js +9 -6
- package/es/table-component/body/TableBodyRow.js +4 -1
- package/es/table-component/header/TableHeadCell2.js +39 -3
- package/es/table-component/hook/utils.d.ts +1 -0
- package/es/table-component/hook/utils.js +15 -7
- package/es/table-component/style.js +1 -1
- package/es/table-component/table/Grid.d.ts +1 -0
- package/es/table-component/table/Grid.js +10 -3
- package/es/table-component/useContext.d.ts +6 -0
- package/es/table-component/useContext.js +2 -1
- package/es/table-virtuoso/InternalTable.js +2 -2
- package/es/table-virtuoso/body/TableBodyCell.js +2 -7
- package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
- package/es/table-virtuoso/body/TableBodyCellRowGroup.js +196 -0
- package/es/table-virtuoso/body/TableBodyRow.d.ts +1 -1
- package/es/table-virtuoso/body/TableBodyRow.js +43 -1
- package/es/table-virtuoso/hook/utils.d.ts +1 -0
- package/es/table-virtuoso/hook/utils.js +29 -0
- package/es/table-virtuoso/style.js +3 -1
- package/es/table-virtuoso/table/Grid.js +2 -2
- package/es/table-virtuoso/table/TableWrapper.d.ts +7 -1
- package/es/table-virtuoso/table/TableWrapper.js +24 -5
- package/es/table-virtuoso/useContext.d.ts +6 -3
- package/es/table-virtuoso/useContext.js +18 -0
- package/lib/grid-component/TempTable.js +2 -1
- package/lib/grid-component/type.d.ts +1 -3
- package/lib/group-component/ColumnsChoose.d.ts +13 -0
- package/lib/group-component/ColumnsChoose.js +221 -0
- package/lib/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/lib/group-component/ColumnsGroup/ColumnsGroup.js +241 -0
- package/lib/group-component/ColumnsGroup/index.d.ts +1 -0
- package/lib/group-component/ColumnsGroup/index.js +16 -0
- package/lib/group-component/ContextMenu.d.ts +19 -0
- package/lib/group-component/ContextMenu.js +83 -0
- package/lib/group-component/InternalTable.d.ts +8 -0
- package/lib/group-component/InternalTable.js +233 -0
- package/lib/group-component/TableContainer.d.ts +49 -0
- package/lib/group-component/TableContainer.js +382 -0
- package/lib/group-component/TableContainerEdit.d.ts +48 -0
- package/lib/group-component/TableContainerEdit.js +2075 -0
- package/lib/group-component/body/EditableCell.d.ts +16 -0
- package/lib/group-component/body/EditableCell.js +1075 -0
- package/lib/group-component/body/TableBody.d.ts +14 -0
- package/lib/group-component/body/TableBody.js +91 -0
- package/lib/group-component/body/TableBodyCell.d.ts +12 -0
- package/lib/group-component/body/TableBodyCell.js +595 -0
- package/lib/group-component/body/TableBodyCellEdit.d.ts +17 -0
- package/lib/group-component/body/TableBodyCellEdit.js +1405 -0
- package/lib/group-component/body/TableBodyCellEmpty.d.ts +12 -0
- package/lib/group-component/body/TableBodyCellEmpty.js +156 -0
- package/lib/group-component/body/TableBodyRow.d.ts +21 -0
- package/lib/group-component/body/TableBodyRow.js +206 -0
- package/lib/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
- package/lib/group-component/body/TableBodyRowGroupCell.js +575 -0
- package/lib/group-component/components/ControlCheckbox.d.ts +13 -0
- package/lib/group-component/components/ControlCheckbox.js +92 -0
- package/lib/group-component/components/EditForm/EditForm.d.ts +27 -0
- package/lib/group-component/components/EditForm/EditForm.js +404 -0
- package/lib/group-component/components/EditForm/index.d.ts +1 -0
- package/lib/group-component/components/EditForm/index.js +16 -0
- package/lib/group-component/components/InputControl/InputControl.d.ts +27 -0
- package/lib/group-component/components/InputControl/InputControl.js +127 -0
- package/lib/group-component/components/InputControl/index.d.ts +1 -0
- package/lib/group-component/components/InputControl/index.js +16 -0
- package/lib/group-component/components/async-select/index.d.ts +11 -0
- package/lib/group-component/components/async-select/index.js +47 -0
- package/lib/group-component/components/async-table-select/index.d.ts +11 -0
- package/lib/group-component/components/async-table-select/index.js +49 -0
- package/lib/group-component/components/checkbox-control/index.d.ts +13 -0
- package/lib/group-component/components/checkbox-control/index.js +48 -0
- package/lib/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +267 -0
- package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/lib/group-component/components/checkbox-filter/FilterSearch.js +44 -0
- package/lib/group-component/components/command/Command.d.ts +10 -0
- package/lib/group-component/components/command/Command.js +44 -0
- package/lib/group-component/components/number/index.d.ts +12 -0
- package/lib/group-component/components/number/index.js +50 -0
- package/lib/group-component/components/number-range/index.d.ts +13 -0
- package/lib/group-component/components/number-range/index.js +87 -0
- package/lib/group-component/features/operator.d.ts +24 -0
- package/lib/group-component/features/operator.js +67 -0
- package/lib/group-component/footer/TableFooter.d.ts +7 -0
- package/lib/group-component/footer/TableFooter.js +44 -0
- package/lib/group-component/footer/TableFooterCell.d.ts +7 -0
- package/lib/group-component/footer/TableFooterCell.js +75 -0
- package/lib/group-component/footer/TableFooterRow.d.ts +8 -0
- package/lib/group-component/footer/TableFooterRow.js +37 -0
- package/lib/group-component/header/TableHead.d.ts +15 -0
- package/lib/group-component/header/TableHead.js +107 -0
- package/lib/group-component/header/TableHeadCell.d.ts +15 -0
- package/lib/group-component/header/TableHeadCell.js +319 -0
- package/lib/group-component/header/TableHeadCell2.d.ts +17 -0
- package/lib/group-component/header/TableHeadCell2.js +330 -0
- package/lib/group-component/header/TableHeadGroupCell.d.ts +17 -0
- package/lib/group-component/header/TableHeadGroupCell.js +103 -0
- package/lib/group-component/header/TableHeadRow.d.ts +15 -0
- package/lib/group-component/header/TableHeadRow.js +59 -0
- package/lib/group-component/header/renderFilter.d.ts +20 -0
- package/lib/group-component/header/renderFilter.js +301 -0
- package/lib/group-component/hook/convert.d.ts +1 -0
- package/lib/group-component/hook/convert.js +34 -0
- package/lib/group-component/hook/useColumns.d.ts +28 -0
- package/lib/group-component/hook/useColumns.js +318 -0
- package/lib/group-component/hook/useFilterOperator.d.ts +7 -0
- package/lib/group-component/hook/useFilterOperator.js +40 -0
- package/lib/group-component/hook/utils.d.ts +220 -0
- package/lib/group-component/hook/utils.js +2468 -0
- package/lib/group-component/index.d.ts +2 -0
- package/lib/group-component/index.js +9 -0
- package/lib/group-component/style.d.ts +22 -0
- package/lib/group-component/style.js +55 -0
- package/lib/group-component/style.scss +1438 -0
- package/lib/group-component/table/Grid.d.ts +33 -0
- package/lib/group-component/table/Grid.js +444 -0
- package/lib/group-component/table/TableWrapper.d.ts +33 -0
- package/lib/group-component/table/TableWrapper.js +259 -0
- package/lib/group-component/useContext.d.ts +100 -0
- package/lib/group-component/useContext.js +27 -0
- package/lib/table-component/InternalTable.js +9 -2
- package/lib/table-component/TableContainer.d.ts +1 -0
- package/lib/table-component/TableContainer.js +6 -2
- package/lib/table-component/TableContainerEdit.d.ts +1 -0
- package/lib/table-component/TableContainerEdit.js +4 -2
- package/lib/table-component/body/TableBodyCell.js +49 -40
- package/lib/table-component/body/TableBodyCellEdit.js +9 -6
- package/lib/table-component/body/TableBodyRow.js +4 -1
- package/lib/table-component/header/TableHeadCell2.js +38 -2
- package/lib/table-component/hook/utils.d.ts +1 -0
- package/lib/table-component/hook/utils.js +16 -7
- package/lib/table-component/style.js +1 -1
- package/lib/table-component/table/Grid.d.ts +1 -0
- package/lib/table-component/table/Grid.js +10 -3
- package/lib/table-component/useContext.d.ts +6 -0
- package/lib/table-component/useContext.js +2 -1
- package/lib/table-virtuoso/InternalTable.js +2 -2
- package/lib/table-virtuoso/body/TableBodyCell.js +2 -7
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +203 -0
- package/lib/table-virtuoso/body/TableBodyRow.d.ts +1 -1
- package/lib/table-virtuoso/body/TableBodyRow.js +43 -1
- package/lib/table-virtuoso/hook/utils.d.ts +1 -0
- package/lib/table-virtuoso/hook/utils.js +32 -1
- package/lib/table-virtuoso/style.js +3 -1
- package/lib/table-virtuoso/table/Grid.js +2 -2
- package/lib/table-virtuoso/table/TableWrapper.d.ts +7 -1
- package/lib/table-virtuoso/table/TableWrapper.js +24 -5
- package/lib/table-virtuoso/useContext.d.ts +6 -3
- package/lib/table-virtuoso/useContext.js +18 -0
- package/package.json +1 -1
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
import TableHead from "../header/TableHead";
|
|
3
|
+
import TableBody from "../body/TableBody";
|
|
4
|
+
import TableFooter from "../footer/TableFooter";
|
|
5
|
+
import ComponentSpinner from "../../grid-component/LoadingSpinner";
|
|
6
|
+
import { Tooltip } from "react-tooltip";
|
|
7
|
+
import ContextMenu from "../ContextMenu";
|
|
8
|
+
import React, { useContext } from "react";
|
|
9
|
+
import { TableContext } from "../useContext";
|
|
10
|
+
const TableWrapper = props => {
|
|
11
|
+
const {
|
|
12
|
+
id,
|
|
13
|
+
prefix,
|
|
14
|
+
tableContainerRef,
|
|
15
|
+
height,
|
|
16
|
+
minHeight,
|
|
17
|
+
summary,
|
|
18
|
+
table,
|
|
19
|
+
loading,
|
|
20
|
+
commandClick,
|
|
21
|
+
editAble,
|
|
22
|
+
contextMenuItems: propContextMenuItems,
|
|
23
|
+
contextMenuHidden,
|
|
24
|
+
showEmptyText,
|
|
25
|
+
contextMenuClick,
|
|
26
|
+
contextMenuOpen,
|
|
27
|
+
next,
|
|
28
|
+
dataSource,
|
|
29
|
+
pagination,
|
|
30
|
+
infiniteScroll,
|
|
31
|
+
columnVirtualizer,
|
|
32
|
+
fixedLeftColumns,
|
|
33
|
+
fixedRightColumns,
|
|
34
|
+
virtualPaddingLeft,
|
|
35
|
+
virtualPaddingRight
|
|
36
|
+
} = props;
|
|
37
|
+
const menuRef = React.useRef(null);
|
|
38
|
+
const loadingRef = React.useRef(false);
|
|
39
|
+
const hasMoreRef = React.useRef(true);
|
|
40
|
+
const {
|
|
41
|
+
windowSize
|
|
42
|
+
} = useContext(TableContext);
|
|
43
|
+
const {
|
|
44
|
+
currentPage,
|
|
45
|
+
pageSize,
|
|
46
|
+
total
|
|
47
|
+
} = pagination ?? {};
|
|
48
|
+
const [menuVisible, setMenuVisible] = React.useState(false);
|
|
49
|
+
const [selectedRowData, setSelectedRowData] = React.useState(null);
|
|
50
|
+
const [position, setPosition] = React.useState({
|
|
51
|
+
x: 0,
|
|
52
|
+
y: 0,
|
|
53
|
+
viewportWidth: windowSize.innerWidth,
|
|
54
|
+
viewportHeight: windowSize.innerHeight
|
|
55
|
+
});
|
|
56
|
+
const contextMenuItems = React.useMemo(() => {
|
|
57
|
+
if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
58
|
+
const hiddenItems = contextMenuHidden({
|
|
59
|
+
rowInfo: {
|
|
60
|
+
rowData: selectedRowData
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
|
|
64
|
+
}
|
|
65
|
+
if (contextMenuHidden && typeof contextMenuHidden !== 'function' && propContextMenuItems) {
|
|
66
|
+
return propContextMenuItems.filter(item => !contextMenuHidden.includes(item?.key));
|
|
67
|
+
}
|
|
68
|
+
return propContextMenuItems;
|
|
69
|
+
}, [propContextMenuItems, contextMenuHidden, selectedRowData]);
|
|
70
|
+
const loadData = page => {
|
|
71
|
+
if (!hasMoreRef.current || loadingRef.current || loading) return;
|
|
72
|
+
loadingRef.current = true;
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
next?.();
|
|
75
|
+
if (page * pageSize >= total) {
|
|
76
|
+
hasMoreRef.current = false;
|
|
77
|
+
}
|
|
78
|
+
loadingRef.current = false;
|
|
79
|
+
}, 10);
|
|
80
|
+
};
|
|
81
|
+
const handleNext = () => {
|
|
82
|
+
loadData(currentPage + 1);
|
|
83
|
+
};
|
|
84
|
+
const handleScroll = e => {
|
|
85
|
+
if (infiniteScroll) {
|
|
86
|
+
if (loadingRef.current || loading || dataSource?.length === 0) {
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const {
|
|
92
|
+
scrollHeight: tbScrollHeight,
|
|
93
|
+
scrollTop,
|
|
94
|
+
clientHeight
|
|
95
|
+
} = e.currentTarget;
|
|
96
|
+
const isEnd = scrollTop + clientHeight >= tbScrollHeight - 50;
|
|
97
|
+
if (isEnd && !loadingRef.current && hasMoreRef.current && dataSource?.length > 0) {
|
|
98
|
+
handleNext();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (e.target.scrollLeft >= 0 && e.target.scrollLeft + e.target.clientWidth < e.target.scrollWidth) {
|
|
102
|
+
e.target.classList.add('ui-rc-table-ping-right');
|
|
103
|
+
} else {
|
|
104
|
+
e.target.classList.remove('ui-rc-table-ping-right');
|
|
105
|
+
}
|
|
106
|
+
if ((e.target.scrollLeft ?? 0) > 0) {
|
|
107
|
+
e.target.classList.add('ui-rc-table-ping-left');
|
|
108
|
+
} else {
|
|
109
|
+
e.target.classList.remove('ui-rc-table-ping-left');
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const onContextMenu = data => event => {
|
|
113
|
+
event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
|
|
114
|
+
|
|
115
|
+
setSelectedRowData(data);
|
|
116
|
+
contextMenuOpen?.({
|
|
117
|
+
rowInfo: {
|
|
118
|
+
rowData: data
|
|
119
|
+
},
|
|
120
|
+
event
|
|
121
|
+
});
|
|
122
|
+
setMenuVisible(true);
|
|
123
|
+
|
|
124
|
+
// Đợi DOM cập nhật và lấy kích thước menu
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
const menuElement = menuRef.current; // Lấy menu từ DOM
|
|
127
|
+
const menuWidth = menuElement?.offsetWidth || 200; // Mặc định 200px nếu chưa render
|
|
128
|
+
const menuHeight = menuElement?.offsetHeight; // Mặc định 450px nếu chưa render
|
|
129
|
+
|
|
130
|
+
// Điều chỉnh vị trí menu
|
|
131
|
+
let x = event.clientX;
|
|
132
|
+
let y = event.clientY;
|
|
133
|
+
if (x + menuWidth > windowSize.innerWidth) {
|
|
134
|
+
x = x - menuWidth - 10; // Cách cạnh phải 10px
|
|
135
|
+
}
|
|
136
|
+
if (y + menuHeight > windowSize.innerHeight) {
|
|
137
|
+
if (y < menuHeight) {
|
|
138
|
+
y = 10;
|
|
139
|
+
} else {
|
|
140
|
+
y = y - 10 - menuHeight; // Cách cạnh dưới 10px
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
setPosition(prevState => ({
|
|
144
|
+
...prevState,
|
|
145
|
+
x,
|
|
146
|
+
y
|
|
147
|
+
}));
|
|
148
|
+
}, 100);
|
|
149
|
+
if (!menuVisible) {
|
|
150
|
+
document.addEventListener(`click`, function onClickOutside(e) {
|
|
151
|
+
const element = e.target;
|
|
152
|
+
const menuContainer = document.querySelector('.popup-context-menu');
|
|
153
|
+
const isInsideContainer = element.closest('.popup-context-menu') && menuContainer;
|
|
154
|
+
if (isInsideContainer) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
setMenuVisible(false);
|
|
158
|
+
setPosition(prevState => ({
|
|
159
|
+
...prevState,
|
|
160
|
+
x: undefined,
|
|
161
|
+
y: undefined
|
|
162
|
+
}));
|
|
163
|
+
document.removeEventListener(`click`, onClickOutside);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
168
|
+
style: {
|
|
169
|
+
position: 'relative'
|
|
170
|
+
},
|
|
171
|
+
className: classNames(`${prefix}-grid-container`, {
|
|
172
|
+
'ui-rc-table-ping-right': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) >= 0 && (tableContainerRef.current?.scrollLeft ?? 0) + (tableContainerRef.current?.clientWidth ?? 0) < (tableContainerRef.current?.scrollWidth ?? 0),
|
|
173
|
+
'ui-rc-table-ping-left': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) > 0
|
|
174
|
+
})
|
|
175
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
176
|
+
// id={id}
|
|
177
|
+
ref: tableContainerRef,
|
|
178
|
+
style: {
|
|
179
|
+
overflow: 'auto',
|
|
180
|
+
//our scrollable table container
|
|
181
|
+
position: 'relative',
|
|
182
|
+
//needed for sticky header
|
|
183
|
+
maxHeight: height,
|
|
184
|
+
//should be a fixed height
|
|
185
|
+
minHeight: minHeight ? height : undefined //should be a fixed height
|
|
186
|
+
}
|
|
187
|
+
// onScroll={infiniteScroll ? handleScroll : undefined}
|
|
188
|
+
,
|
|
189
|
+
onScroll: handleScroll
|
|
190
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
191
|
+
style: {
|
|
192
|
+
display: 'grid',
|
|
193
|
+
minWidth: table.getTotalSize()
|
|
194
|
+
}
|
|
195
|
+
}, /*#__PURE__*/React.createElement(TableHead, {
|
|
196
|
+
tableContainerRef: tableContainerRef,
|
|
197
|
+
table: table,
|
|
198
|
+
columnVirtualizer: columnVirtualizer,
|
|
199
|
+
virtualPaddingLeft: virtualPaddingLeft,
|
|
200
|
+
virtualPaddingRight: virtualPaddingRight,
|
|
201
|
+
fixedLeftColumns: fixedLeftColumns,
|
|
202
|
+
fixedRightColumns: fixedRightColumns
|
|
203
|
+
}), /*#__PURE__*/React.createElement(TableBody, {
|
|
204
|
+
tableId: id,
|
|
205
|
+
table: table,
|
|
206
|
+
tableContainerRef: tableContainerRef,
|
|
207
|
+
commandClick: commandClick,
|
|
208
|
+
editAble: editAble,
|
|
209
|
+
contextMenuItems: contextMenuItems,
|
|
210
|
+
showEmptyText: showEmptyText,
|
|
211
|
+
onContextMenu: onContextMenu,
|
|
212
|
+
columnVirtualizer: columnVirtualizer,
|
|
213
|
+
virtualPaddingLeft: virtualPaddingLeft,
|
|
214
|
+
virtualPaddingRight: virtualPaddingRight,
|
|
215
|
+
fixedLeftColumns: fixedLeftColumns,
|
|
216
|
+
fixedRightColumns: fixedRightColumns
|
|
217
|
+
}), summary && /*#__PURE__*/React.createElement(TableFooter
|
|
218
|
+
// columnVirtualizer={columnVirtualizer}
|
|
219
|
+
, {
|
|
220
|
+
table: table
|
|
221
|
+
// virtualPaddingLeft={virtualPaddingLeft}
|
|
222
|
+
// virtualPaddingRight={virtualPaddingRight}
|
|
223
|
+
// fixedLeftColumns={fixedLeftColumns}
|
|
224
|
+
// fixedRightColumns={fixedRightColumns}
|
|
225
|
+
}))), loading && /*#__PURE__*/React.createElement("div", {
|
|
226
|
+
className: "spinner-loading"
|
|
227
|
+
}, /*#__PURE__*/React.createElement(ComponentSpinner, null)), /*#__PURE__*/React.createElement(Tooltip, {
|
|
228
|
+
id: `${id}-tooltip-content`,
|
|
229
|
+
style: {
|
|
230
|
+
zIndex: 1999,
|
|
231
|
+
maxWidth: 450
|
|
232
|
+
},
|
|
233
|
+
delayShow: 100
|
|
234
|
+
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
235
|
+
id: `${id}-tooltip-error`,
|
|
236
|
+
style: {
|
|
237
|
+
zIndex: 1999,
|
|
238
|
+
maxWidth: 450
|
|
239
|
+
}
|
|
240
|
+
}), menuVisible && /*#__PURE__*/React.createElement(ContextMenu, {
|
|
241
|
+
open: menuVisible,
|
|
242
|
+
pos: position,
|
|
243
|
+
setOpen: setMenuVisible,
|
|
244
|
+
menuRef: menuRef,
|
|
245
|
+
contextMenuItems: contextMenuItems,
|
|
246
|
+
contextMenuClick: contextMenuClick,
|
|
247
|
+
rowData: selectedRowData
|
|
248
|
+
}));
|
|
249
|
+
};
|
|
250
|
+
export default TableWrapper;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import type { ColumnTable, ExpandableConfig, IFormat, IWrapSettings, Locale, PaginationConfig, RangeState, RecordDoubleClickEventArgs, RowClassName, SelectionSettings, SourceFilter } from "./../grid-component/type";
|
|
3
|
+
import type { SubmitHandler } from "react-hook-form";
|
|
4
|
+
import type { ExpandedState, Row, Table } from '@tanstack/react-table';
|
|
5
|
+
export type IPositionCell = {
|
|
6
|
+
rowId: string;
|
|
7
|
+
colId: string;
|
|
8
|
+
} | undefined;
|
|
9
|
+
export interface IContext<T> {
|
|
10
|
+
t?: any;
|
|
11
|
+
prefix: string;
|
|
12
|
+
id: string;
|
|
13
|
+
rowKey: string;
|
|
14
|
+
originData: any[];
|
|
15
|
+
dataSource: any[];
|
|
16
|
+
format?: IFormat;
|
|
17
|
+
expandable?: ExpandableConfig<T>;
|
|
18
|
+
wrapSettings?: IWrapSettings;
|
|
19
|
+
setExpanded: Dispatch<SetStateAction<ExpandedState>>;
|
|
20
|
+
expanded: ExpandedState;
|
|
21
|
+
recordDoubleClick?: (args: RecordDoubleClickEventArgs<T>) => void;
|
|
22
|
+
selectionSettings?: SelectionSettings;
|
|
23
|
+
isSelectionChange?: {
|
|
24
|
+
isChange: boolean;
|
|
25
|
+
type: string;
|
|
26
|
+
rowData: T;
|
|
27
|
+
rowsData: T[];
|
|
28
|
+
};
|
|
29
|
+
setIsSelectionChange: Dispatch<SetStateAction<{
|
|
30
|
+
isChange: boolean;
|
|
31
|
+
type: string;
|
|
32
|
+
rowData: T;
|
|
33
|
+
rowsData: T[];
|
|
34
|
+
}>>;
|
|
35
|
+
setSorterChange: Dispatch<SetStateAction<boolean>>;
|
|
36
|
+
setFilterChange: Dispatch<SetStateAction<boolean>>;
|
|
37
|
+
onContextMenu?: (data: T) => (event: any) => void;
|
|
38
|
+
locale?: Locale;
|
|
39
|
+
windowSize: {
|
|
40
|
+
innerHeight: number;
|
|
41
|
+
innerWidth: number;
|
|
42
|
+
};
|
|
43
|
+
control?: any;
|
|
44
|
+
errors?: any;
|
|
45
|
+
handleSubmit?: any;
|
|
46
|
+
onSubmit?: SubmitHandler<any>;
|
|
47
|
+
getValues?: any;
|
|
48
|
+
reset?: any;
|
|
49
|
+
setValue?: any;
|
|
50
|
+
handleCellChange?: (args: ContextCellChange) => void;
|
|
51
|
+
handleCellChangeAndAddRow?: (args: ContextCellChange) => void;
|
|
52
|
+
editingKey?: string;
|
|
53
|
+
setEditingKey?: Dispatch<SetStateAction<string>>;
|
|
54
|
+
rangeState?: RangeState;
|
|
55
|
+
setRangeState?: Dispatch<SetStateAction<RangeState | undefined>>;
|
|
56
|
+
rangePasteState?: RangeState;
|
|
57
|
+
setRangePasteState?: Dispatch<SetStateAction<RangeState | undefined>>;
|
|
58
|
+
startCell?: IPositionCell;
|
|
59
|
+
setStartCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
|
|
60
|
+
endCell?: IPositionCell;
|
|
61
|
+
setEndCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
|
|
62
|
+
startPasteCell?: IPositionCell;
|
|
63
|
+
setStartPasteCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
|
|
64
|
+
endPasteCell?: IPositionCell;
|
|
65
|
+
setEndPasteCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
|
|
66
|
+
isSelecting?: boolean;
|
|
67
|
+
setIsSelecting?: Dispatch<SetStateAction<boolean>>;
|
|
68
|
+
isPasting?: boolean;
|
|
69
|
+
setIsPasting?: Dispatch<SetStateAction<boolean>>;
|
|
70
|
+
focusedCell?: IPositionCell;
|
|
71
|
+
setFocusedCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
|
|
72
|
+
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
|
|
73
|
+
handleDeleteContent?: () => void;
|
|
74
|
+
handleAddMulti?: (item: any, n: number, id?: string) => void;
|
|
75
|
+
dataErrors?: any[];
|
|
76
|
+
isDataTree: boolean;
|
|
77
|
+
handleCellClick?: (rowNumber: number, record: T, column: ColumnTable, rowId: string, cellValue: any) => void;
|
|
78
|
+
pagination?: false | PaginationConfig;
|
|
79
|
+
rowClassName?: string | RowClassName<T>;
|
|
80
|
+
table?: Table<T>;
|
|
81
|
+
rowEditable?: (rowData: T) => boolean;
|
|
82
|
+
onRowStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | ((data: T, row: Row<T>) => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
|
|
83
|
+
onRowHeaderStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
|
|
84
|
+
onRowFooterStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
|
|
85
|
+
dataSourceFilter?: SourceFilter[];
|
|
86
|
+
groupColumns?: string[];
|
|
87
|
+
}
|
|
88
|
+
export declare const TableContext: import("react").Context<IContext<any>>;
|
|
89
|
+
export type ContextCellChange = {
|
|
90
|
+
key: string;
|
|
91
|
+
record: any;
|
|
92
|
+
field: string;
|
|
93
|
+
option: any;
|
|
94
|
+
indexRow: number;
|
|
95
|
+
indexCol: number;
|
|
96
|
+
newState?: any;
|
|
97
|
+
prevState?: any;
|
|
98
|
+
type: 'enter' | 'blur' | 'outClick';
|
|
99
|
+
addNewRow?: boolean;
|
|
100
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
export const TableContext = /*#__PURE__*/createContext({
|
|
3
|
+
prefix: 'ui-rc',
|
|
4
|
+
id: '',
|
|
5
|
+
isDataTree: false,
|
|
6
|
+
rowKey: 'rowId',
|
|
7
|
+
dataSource: [],
|
|
8
|
+
originData: [],
|
|
9
|
+
expanded: {},
|
|
10
|
+
windowSize: {
|
|
11
|
+
innerHeight: 0,
|
|
12
|
+
innerWidth: 0
|
|
13
|
+
},
|
|
14
|
+
// triggerFilter: () => { },
|
|
15
|
+
|
|
16
|
+
setIsSelectionChange: () => {},
|
|
17
|
+
setSorterChange: () => {},
|
|
18
|
+
setFilterChange: () => {},
|
|
19
|
+
setExpanded: () => {},
|
|
20
|
+
handleCellClick: () => {}
|
|
21
|
+
});
|
|
@@ -30,6 +30,7 @@ const InternalTable = props => {
|
|
|
30
30
|
selectionSettings,
|
|
31
31
|
expandable,
|
|
32
32
|
onChooseColumns,
|
|
33
|
+
onExpandClick,
|
|
33
34
|
// contextMenuClick,
|
|
34
35
|
// contextMenuOpen,
|
|
35
36
|
height,
|
|
@@ -68,6 +69,7 @@ const InternalTable = props => {
|
|
|
68
69
|
const [sorterStates, setSorterStates] = React.useState([]);
|
|
69
70
|
const [isFullScreen, setIsFullScreen] = React.useState(false);
|
|
70
71
|
const [columns, setColumns] = React.useState([]);
|
|
72
|
+
const [isExpandClick, setIsExpandClick] = React.useState(false);
|
|
71
73
|
React.useEffect(() => {
|
|
72
74
|
// setColumns(propsColumns as any)
|
|
73
75
|
|
|
@@ -105,6 +107,9 @@ const InternalTable = props => {
|
|
|
105
107
|
value: undefined
|
|
106
108
|
});
|
|
107
109
|
React.useEffect(() => {
|
|
110
|
+
if (onExpandClick || isExpandClick) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
108
113
|
if (defaultExpandAllRows) {
|
|
109
114
|
const allKeys = findAllChildrenKeys2(convertData, rowKey, 'children');
|
|
110
115
|
setExpanded(convertToObjTrue(allKeys));
|
|
@@ -113,7 +118,7 @@ const InternalTable = props => {
|
|
|
113
118
|
setExpanded(convertToObjTrue(defaultExpandedRowKeys ?? []));
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
|
-
}, [defaultExpandAllRows, convertData, defaultExpandedRowKeys]);
|
|
121
|
+
}, [defaultExpandAllRows, convertData, defaultExpandedRowKeys, onExpandClick, isExpandClick]);
|
|
117
122
|
|
|
118
123
|
// ========================= Keys =========================
|
|
119
124
|
|
|
@@ -181,7 +186,9 @@ const InternalTable = props => {
|
|
|
181
186
|
selectionSettings: selectionSettings,
|
|
182
187
|
mergedSelectedKeys: mergedSelectedKeys,
|
|
183
188
|
expandable: expandable,
|
|
184
|
-
|
|
189
|
+
onExpandClick: onExpandClick,
|
|
190
|
+
setColumns: setColumns,
|
|
191
|
+
setIsExpandClick: setIsExpandClick
|
|
185
192
|
})));
|
|
186
193
|
};
|
|
187
194
|
export default InternalTable;
|
|
@@ -41,6 +41,7 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
41
41
|
isDataTree: boolean;
|
|
42
42
|
setColumnSizing: Dispatch<SetStateAction<any>>;
|
|
43
43
|
setColumns: Dispatch<SetStateAction<any>>;
|
|
44
|
+
setIsExpandClick: Dispatch<SetStateAction<boolean>>;
|
|
44
45
|
columnSizingInfo: ColumnSizingInfoState;
|
|
45
46
|
columnSizing: ColumnSizingState;
|
|
46
47
|
};
|
|
@@ -69,7 +69,9 @@ const TableContainer = props => {
|
|
|
69
69
|
onRowFooterStyles,
|
|
70
70
|
onRowHeaderStyles,
|
|
71
71
|
title,
|
|
72
|
-
dataSourceFilter
|
|
72
|
+
dataSourceFilter,
|
|
73
|
+
onExpandClick,
|
|
74
|
+
setIsExpandClick
|
|
73
75
|
} = props;
|
|
74
76
|
const tableContainerRef = React.useRef(null);
|
|
75
77
|
const containerRef = React.useRef(null);
|
|
@@ -272,7 +274,9 @@ const TableContainer = props => {
|
|
|
272
274
|
onRowHeaderStyles,
|
|
273
275
|
table,
|
|
274
276
|
pagination,
|
|
275
|
-
dataSourceFilter
|
|
277
|
+
dataSourceFilter,
|
|
278
|
+
onExpandClick,
|
|
279
|
+
setIsExpandClick
|
|
276
280
|
}
|
|
277
281
|
}, /*#__PURE__*/React.createElement(TableWrapper, {
|
|
278
282
|
contextMenuItems: contextMenuItems,
|
|
@@ -42,6 +42,7 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
42
42
|
setColumns: Dispatch<SetStateAction<any>>;
|
|
43
43
|
columnSizingInfo: ColumnSizingInfoState;
|
|
44
44
|
columnSizing: ColumnSizingState;
|
|
45
|
+
setIsExpandClick: Dispatch<SetStateAction<boolean>>;
|
|
45
46
|
};
|
|
46
47
|
declare const TableContainerEdit: <RecordType extends object>(props: TableContainerProps<RecordType>) => React.JSX.Element;
|
|
47
48
|
export default TableContainerEdit;
|
|
@@ -126,7 +126,8 @@ const TableContainerEdit = props => {
|
|
|
126
126
|
columnSizingInfo,
|
|
127
127
|
rowClassName,
|
|
128
128
|
onRowStyles,
|
|
129
|
-
dataSourceFilter
|
|
129
|
+
dataSourceFilter,
|
|
130
|
+
setIsExpandClick
|
|
130
131
|
} = props;
|
|
131
132
|
const containerRef = React.useRef(null);
|
|
132
133
|
const bottomToolbarRef = React.useRef(null);
|
|
@@ -1903,7 +1904,8 @@ const TableContainerEdit = props => {
|
|
|
1903
1904
|
rowClassName,
|
|
1904
1905
|
rowEditable,
|
|
1905
1906
|
onRowStyles,
|
|
1906
|
-
dataSourceFilter
|
|
1907
|
+
dataSourceFilter,
|
|
1908
|
+
setIsExpandClick
|
|
1907
1909
|
}
|
|
1908
1910
|
}, /*#__PURE__*/React.createElement(TableWrapper, {
|
|
1909
1911
|
contextMenuItems: contextMenuItems,
|
|
@@ -78,7 +78,8 @@ const renderSelection = args => {
|
|
|
78
78
|
expandIconColumnIndex,
|
|
79
79
|
isDataTree,
|
|
80
80
|
expanded,
|
|
81
|
-
setExpanded
|
|
81
|
+
setExpanded,
|
|
82
|
+
onExpandClick
|
|
82
83
|
} = args;
|
|
83
84
|
const {
|
|
84
85
|
selectionSettings,
|
|
@@ -96,20 +97,33 @@ const renderSelection = args => {
|
|
|
96
97
|
}
|
|
97
98
|
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
98
99
|
// onClick: row.getToggleExpandedHandler(),
|
|
99
|
-
onClick:
|
|
100
|
+
onClick: e => {
|
|
101
|
+
e.stopPropagation();
|
|
100
102
|
const keys = Object.keys(expanded);
|
|
101
103
|
// @ts-ignore
|
|
102
104
|
const tmp = {
|
|
103
105
|
...expanded
|
|
104
106
|
};
|
|
107
|
+
|
|
108
|
+
// collapse
|
|
105
109
|
if (keys.includes(cell.row.id)) {
|
|
106
110
|
delete tmp[cell.row.id];
|
|
107
111
|
setExpanded(tmp);
|
|
108
112
|
} else {
|
|
113
|
+
// collapse
|
|
109
114
|
setExpanded(old => ({
|
|
110
115
|
...old,
|
|
111
116
|
[cell.row.id]: true
|
|
112
117
|
}));
|
|
118
|
+
const expandedKeys = {
|
|
119
|
+
...tmp,
|
|
120
|
+
[cell.row.id]: true
|
|
121
|
+
};
|
|
122
|
+
onExpandClick?.({
|
|
123
|
+
expandedKeys: Object.keys(expandedKeys),
|
|
124
|
+
key: cell.row.id,
|
|
125
|
+
rowData: cell.row.original
|
|
126
|
+
});
|
|
113
127
|
}
|
|
114
128
|
},
|
|
115
129
|
style: {
|
|
@@ -161,7 +175,8 @@ const TableBodyCell = props => {
|
|
|
161
175
|
isSelectionChange,
|
|
162
176
|
selectionSettings,
|
|
163
177
|
wrapSettings,
|
|
164
|
-
pagination
|
|
178
|
+
pagination,
|
|
179
|
+
onExpandClick
|
|
165
180
|
// dataSource
|
|
166
181
|
} = React.useContext(TableContext);
|
|
167
182
|
const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
|
|
@@ -226,20 +241,33 @@ const TableBodyCell = props => {
|
|
|
226
241
|
}
|
|
227
242
|
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
228
243
|
// onClick: row.getToggleExpandedHandler(),
|
|
229
|
-
onClick:
|
|
244
|
+
onClick: e => {
|
|
245
|
+
e.stopPropagation();
|
|
230
246
|
const keys = Object.keys(expanded);
|
|
231
247
|
// @ts-ignore
|
|
232
248
|
const tmp = {
|
|
233
249
|
...expanded
|
|
234
250
|
};
|
|
251
|
+
|
|
252
|
+
// collapse
|
|
235
253
|
if (keys.includes(cell.row.id)) {
|
|
236
254
|
delete tmp[cell.row.id];
|
|
237
255
|
setExpanded(tmp);
|
|
238
256
|
} else {
|
|
257
|
+
// expand
|
|
239
258
|
setExpanded(old => ({
|
|
240
259
|
...old,
|
|
241
260
|
[cell.row.id]: true
|
|
242
261
|
}));
|
|
262
|
+
const expandedKeys = {
|
|
263
|
+
...tmp,
|
|
264
|
+
[cell.row.id]: true
|
|
265
|
+
};
|
|
266
|
+
onExpandClick?.({
|
|
267
|
+
expandedKeys: Object.keys(expandedKeys),
|
|
268
|
+
key: cell.row.id,
|
|
269
|
+
rowData: record
|
|
270
|
+
});
|
|
243
271
|
}
|
|
244
272
|
},
|
|
245
273
|
style: {
|
|
@@ -311,7 +339,8 @@ const TableBodyCell = props => {
|
|
|
311
339
|
isDataTree,
|
|
312
340
|
setExpanded,
|
|
313
341
|
expandIconColumnIndex,
|
|
314
|
-
isSelectionChange
|
|
342
|
+
isSelectionChange,
|
|
343
|
+
onExpandClick
|
|
315
344
|
})));
|
|
316
345
|
}
|
|
317
346
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -396,41 +425,8 @@ const TableBodyCell = props => {
|
|
|
396
425
|
selectionSettings
|
|
397
426
|
});
|
|
398
427
|
cell.row.getToggleSelectedHandler()(e);
|
|
399
|
-
|
|
400
|
-
// if (cell.row.getIsSelected()) { // nếu đã chọn
|
|
401
|
-
|
|
402
|
-
// const aaa = isSelectionChange?.rowsData.filter((it) => it.id !== cell.row.id)
|
|
403
|
-
|
|
404
|
-
// setIsSelectionChange({
|
|
405
|
-
// isChange: true,
|
|
406
|
-
// type: 'rowSelected',
|
|
407
|
-
// rowData: cell.row.original,
|
|
408
|
-
// rowsData: aaa ?? []
|
|
409
|
-
// })
|
|
410
|
-
|
|
411
|
-
// } else {
|
|
412
|
-
|
|
413
|
-
// const { rowsData } = isSelectionChange ?? {}
|
|
414
|
-
|
|
415
|
-
// const abc = rowsData && rowsData.length > 0 ? [...rowsData] : []
|
|
416
|
-
|
|
417
|
-
// abc.push(cell.row)
|
|
418
|
-
|
|
419
|
-
// setIsSelectionChange({
|
|
420
|
-
// isChange: true,
|
|
421
|
-
// type: 'rowSelected',
|
|
422
|
-
// rowData: cell.row.original,
|
|
423
|
-
// rowsData: abc
|
|
424
|
-
// })
|
|
425
|
-
// }
|
|
426
428
|
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// onKeyUp={() => {
|
|
430
|
-
|
|
431
|
-
// }}
|
|
432
|
-
,
|
|
433
|
-
|
|
429
|
+
},
|
|
434
430
|
onClick: e => {
|
|
435
431
|
const selection = window.getSelection();
|
|
436
432
|
const text = selection ? selection.toString() : "";
|
|
@@ -459,20 +455,33 @@ const TableBodyCell = props => {
|
|
|
459
455
|
}
|
|
460
456
|
}, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
|
|
461
457
|
// onClick: row.getToggleExpandedHandler(),
|
|
462
|
-
onClick:
|
|
458
|
+
onClick: e => {
|
|
459
|
+
e.stopPropagation();
|
|
463
460
|
const keys = Object.keys(expanded);
|
|
464
461
|
// @ts-ignore
|
|
465
462
|
const tmp = {
|
|
466
463
|
...expanded
|
|
467
464
|
};
|
|
465
|
+
|
|
466
|
+
// collapse
|
|
468
467
|
if (keys.includes(cell.row.id)) {
|
|
469
468
|
delete tmp[cell.row.id];
|
|
470
469
|
setExpanded(tmp);
|
|
471
470
|
} else {
|
|
471
|
+
// expand
|
|
472
472
|
setExpanded(old => ({
|
|
473
473
|
...old,
|
|
474
474
|
[cell.row.id]: true
|
|
475
475
|
}));
|
|
476
|
+
const expandedKeys = {
|
|
477
|
+
...tmp,
|
|
478
|
+
[cell.row.id]: true
|
|
479
|
+
};
|
|
480
|
+
onExpandClick?.({
|
|
481
|
+
expandedKeys: Object.keys(expandedKeys),
|
|
482
|
+
key: cell.row.id,
|
|
483
|
+
rowData: record
|
|
484
|
+
});
|
|
476
485
|
}
|
|
477
486
|
},
|
|
478
487
|
style: {
|