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,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _TableHead = _interopRequireDefault(require("../header/TableHead"));
|
|
10
|
+
var _TableBody = _interopRequireDefault(require("../body/TableBody"));
|
|
11
|
+
var _TableFooter = _interopRequireDefault(require("../footer/TableFooter"));
|
|
12
|
+
var _LoadingSpinner = _interopRequireDefault(require("../../grid-component/LoadingSpinner"));
|
|
13
|
+
var _reactTooltip = require("react-tooltip");
|
|
14
|
+
var _ContextMenu = _interopRequireDefault(require("../ContextMenu"));
|
|
15
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
16
|
+
var _useContext = require("../useContext");
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
|
+
const TableWrapper = props => {
|
|
20
|
+
const {
|
|
21
|
+
id,
|
|
22
|
+
prefix,
|
|
23
|
+
tableContainerRef,
|
|
24
|
+
height,
|
|
25
|
+
minHeight,
|
|
26
|
+
summary,
|
|
27
|
+
table,
|
|
28
|
+
loading,
|
|
29
|
+
commandClick,
|
|
30
|
+
editAble,
|
|
31
|
+
contextMenuItems: propContextMenuItems,
|
|
32
|
+
contextMenuHidden,
|
|
33
|
+
showEmptyText,
|
|
34
|
+
contextMenuClick,
|
|
35
|
+
contextMenuOpen,
|
|
36
|
+
next,
|
|
37
|
+
dataSource,
|
|
38
|
+
pagination,
|
|
39
|
+
infiniteScroll,
|
|
40
|
+
columnVirtualizer,
|
|
41
|
+
fixedLeftColumns,
|
|
42
|
+
fixedRightColumns,
|
|
43
|
+
virtualPaddingLeft,
|
|
44
|
+
virtualPaddingRight
|
|
45
|
+
} = props;
|
|
46
|
+
const menuRef = _react.default.useRef(null);
|
|
47
|
+
const loadingRef = _react.default.useRef(false);
|
|
48
|
+
const hasMoreRef = _react.default.useRef(true);
|
|
49
|
+
const {
|
|
50
|
+
windowSize
|
|
51
|
+
} = (0, _react.useContext)(_useContext.TableContext);
|
|
52
|
+
const {
|
|
53
|
+
currentPage,
|
|
54
|
+
pageSize,
|
|
55
|
+
total
|
|
56
|
+
} = pagination ?? {};
|
|
57
|
+
const [menuVisible, setMenuVisible] = _react.default.useState(false);
|
|
58
|
+
const [selectedRowData, setSelectedRowData] = _react.default.useState(null);
|
|
59
|
+
const [position, setPosition] = _react.default.useState({
|
|
60
|
+
x: 0,
|
|
61
|
+
y: 0,
|
|
62
|
+
viewportWidth: windowSize.innerWidth,
|
|
63
|
+
viewportHeight: windowSize.innerHeight
|
|
64
|
+
});
|
|
65
|
+
const contextMenuItems = _react.default.useMemo(() => {
|
|
66
|
+
if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
67
|
+
const hiddenItems = contextMenuHidden({
|
|
68
|
+
rowInfo: {
|
|
69
|
+
rowData: selectedRowData
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
|
|
73
|
+
}
|
|
74
|
+
if (contextMenuHidden && typeof contextMenuHidden !== 'function' && propContextMenuItems) {
|
|
75
|
+
return propContextMenuItems.filter(item => !contextMenuHidden.includes(item?.key));
|
|
76
|
+
}
|
|
77
|
+
return propContextMenuItems;
|
|
78
|
+
}, [propContextMenuItems, contextMenuHidden, selectedRowData]);
|
|
79
|
+
const loadData = page => {
|
|
80
|
+
if (!hasMoreRef.current || loadingRef.current || loading) return;
|
|
81
|
+
loadingRef.current = true;
|
|
82
|
+
setTimeout(() => {
|
|
83
|
+
next?.();
|
|
84
|
+
if (page * pageSize >= total) {
|
|
85
|
+
hasMoreRef.current = false;
|
|
86
|
+
}
|
|
87
|
+
loadingRef.current = false;
|
|
88
|
+
}, 10);
|
|
89
|
+
};
|
|
90
|
+
const handleNext = () => {
|
|
91
|
+
loadData(currentPage + 1);
|
|
92
|
+
};
|
|
93
|
+
const handleScroll = e => {
|
|
94
|
+
if (infiniteScroll) {
|
|
95
|
+
if (loadingRef.current || loading || dataSource?.length === 0) {
|
|
96
|
+
e.stopPropagation();
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const {
|
|
101
|
+
scrollHeight: tbScrollHeight,
|
|
102
|
+
scrollTop,
|
|
103
|
+
clientHeight
|
|
104
|
+
} = e.currentTarget;
|
|
105
|
+
const isEnd = scrollTop + clientHeight >= tbScrollHeight - 50;
|
|
106
|
+
if (isEnd && !loadingRef.current && hasMoreRef.current && dataSource?.length > 0) {
|
|
107
|
+
handleNext();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (e.target.scrollLeft >= 0 && e.target.scrollLeft + e.target.clientWidth < e.target.scrollWidth) {
|
|
111
|
+
e.target.classList.add('ui-rc-table-ping-right');
|
|
112
|
+
} else {
|
|
113
|
+
e.target.classList.remove('ui-rc-table-ping-right');
|
|
114
|
+
}
|
|
115
|
+
if ((e.target.scrollLeft ?? 0) > 0) {
|
|
116
|
+
e.target.classList.add('ui-rc-table-ping-left');
|
|
117
|
+
} else {
|
|
118
|
+
e.target.classList.remove('ui-rc-table-ping-left');
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const onContextMenu = data => event => {
|
|
122
|
+
event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
|
|
123
|
+
|
|
124
|
+
setSelectedRowData(data);
|
|
125
|
+
contextMenuOpen?.({
|
|
126
|
+
rowInfo: {
|
|
127
|
+
rowData: data
|
|
128
|
+
},
|
|
129
|
+
event
|
|
130
|
+
});
|
|
131
|
+
setMenuVisible(true);
|
|
132
|
+
|
|
133
|
+
// Đợi DOM cập nhật và lấy kích thước menu
|
|
134
|
+
setTimeout(() => {
|
|
135
|
+
const menuElement = menuRef.current; // Lấy menu từ DOM
|
|
136
|
+
const menuWidth = menuElement?.offsetWidth || 200; // Mặc định 200px nếu chưa render
|
|
137
|
+
const menuHeight = menuElement?.offsetHeight; // Mặc định 450px nếu chưa render
|
|
138
|
+
|
|
139
|
+
// Điều chỉnh vị trí menu
|
|
140
|
+
let x = event.clientX;
|
|
141
|
+
let y = event.clientY;
|
|
142
|
+
if (x + menuWidth > windowSize.innerWidth) {
|
|
143
|
+
x = x - menuWidth - 10; // Cách cạnh phải 10px
|
|
144
|
+
}
|
|
145
|
+
if (y + menuHeight > windowSize.innerHeight) {
|
|
146
|
+
if (y < menuHeight) {
|
|
147
|
+
y = 10;
|
|
148
|
+
} else {
|
|
149
|
+
y = y - 10 - menuHeight; // Cách cạnh dưới 10px
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
setPosition(prevState => ({
|
|
153
|
+
...prevState,
|
|
154
|
+
x,
|
|
155
|
+
y
|
|
156
|
+
}));
|
|
157
|
+
}, 100);
|
|
158
|
+
if (!menuVisible) {
|
|
159
|
+
document.addEventListener(`click`, function onClickOutside(e) {
|
|
160
|
+
const element = e.target;
|
|
161
|
+
const menuContainer = document.querySelector('.popup-context-menu');
|
|
162
|
+
const isInsideContainer = element.closest('.popup-context-menu') && menuContainer;
|
|
163
|
+
if (isInsideContainer) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
setMenuVisible(false);
|
|
167
|
+
setPosition(prevState => ({
|
|
168
|
+
...prevState,
|
|
169
|
+
x: undefined,
|
|
170
|
+
y: undefined
|
|
171
|
+
}));
|
|
172
|
+
document.removeEventListener(`click`, onClickOutside);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
177
|
+
style: {
|
|
178
|
+
position: 'relative'
|
|
179
|
+
},
|
|
180
|
+
className: (0, _classnames.default)(`${prefix}-grid-container`, {
|
|
181
|
+
'ui-rc-table-ping-right': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) >= 0 && (tableContainerRef.current?.scrollLeft ?? 0) + (tableContainerRef.current?.clientWidth ?? 0) < (tableContainerRef.current?.scrollWidth ?? 0),
|
|
182
|
+
'ui-rc-table-ping-left': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) > 0
|
|
183
|
+
})
|
|
184
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
185
|
+
// id={id}
|
|
186
|
+
ref: tableContainerRef,
|
|
187
|
+
style: {
|
|
188
|
+
overflow: 'auto',
|
|
189
|
+
//our scrollable table container
|
|
190
|
+
position: 'relative',
|
|
191
|
+
//needed for sticky header
|
|
192
|
+
maxHeight: height,
|
|
193
|
+
//should be a fixed height
|
|
194
|
+
minHeight: minHeight ? height : undefined //should be a fixed height
|
|
195
|
+
}
|
|
196
|
+
// onScroll={infiniteScroll ? handleScroll : undefined}
|
|
197
|
+
,
|
|
198
|
+
onScroll: handleScroll
|
|
199
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
200
|
+
style: {
|
|
201
|
+
display: 'grid',
|
|
202
|
+
minWidth: table.getTotalSize()
|
|
203
|
+
}
|
|
204
|
+
}, /*#__PURE__*/_react.default.createElement(_TableHead.default, {
|
|
205
|
+
tableContainerRef: tableContainerRef,
|
|
206
|
+
table: table,
|
|
207
|
+
columnVirtualizer: columnVirtualizer,
|
|
208
|
+
virtualPaddingLeft: virtualPaddingLeft,
|
|
209
|
+
virtualPaddingRight: virtualPaddingRight,
|
|
210
|
+
fixedLeftColumns: fixedLeftColumns,
|
|
211
|
+
fixedRightColumns: fixedRightColumns
|
|
212
|
+
}), /*#__PURE__*/_react.default.createElement(_TableBody.default, {
|
|
213
|
+
tableId: id,
|
|
214
|
+
table: table,
|
|
215
|
+
tableContainerRef: tableContainerRef,
|
|
216
|
+
commandClick: commandClick,
|
|
217
|
+
editAble: editAble,
|
|
218
|
+
contextMenuItems: contextMenuItems,
|
|
219
|
+
showEmptyText: showEmptyText,
|
|
220
|
+
onContextMenu: onContextMenu,
|
|
221
|
+
columnVirtualizer: columnVirtualizer,
|
|
222
|
+
virtualPaddingLeft: virtualPaddingLeft,
|
|
223
|
+
virtualPaddingRight: virtualPaddingRight,
|
|
224
|
+
fixedLeftColumns: fixedLeftColumns,
|
|
225
|
+
fixedRightColumns: fixedRightColumns
|
|
226
|
+
}), summary && /*#__PURE__*/_react.default.createElement(_TableFooter.default
|
|
227
|
+
// columnVirtualizer={columnVirtualizer}
|
|
228
|
+
, {
|
|
229
|
+
table: table
|
|
230
|
+
// virtualPaddingLeft={virtualPaddingLeft}
|
|
231
|
+
// virtualPaddingRight={virtualPaddingRight}
|
|
232
|
+
// fixedLeftColumns={fixedLeftColumns}
|
|
233
|
+
// fixedRightColumns={fixedRightColumns}
|
|
234
|
+
}))), loading && /*#__PURE__*/_react.default.createElement("div", {
|
|
235
|
+
className: "spinner-loading"
|
|
236
|
+
}, /*#__PURE__*/_react.default.createElement(_LoadingSpinner.default, null)), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
|
|
237
|
+
id: `${id}-tooltip-content`,
|
|
238
|
+
style: {
|
|
239
|
+
zIndex: 1999,
|
|
240
|
+
maxWidth: 450
|
|
241
|
+
},
|
|
242
|
+
delayShow: 100
|
|
243
|
+
}), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
|
|
244
|
+
id: `${id}-tooltip-error`,
|
|
245
|
+
style: {
|
|
246
|
+
zIndex: 1999,
|
|
247
|
+
maxWidth: 450
|
|
248
|
+
}
|
|
249
|
+
}), menuVisible && /*#__PURE__*/_react.default.createElement(_ContextMenu.default, {
|
|
250
|
+
open: menuVisible,
|
|
251
|
+
pos: position,
|
|
252
|
+
setOpen: setMenuVisible,
|
|
253
|
+
menuRef: menuRef,
|
|
254
|
+
contextMenuItems: contextMenuItems,
|
|
255
|
+
contextMenuClick: contextMenuClick,
|
|
256
|
+
rowData: selectedRowData
|
|
257
|
+
}));
|
|
258
|
+
};
|
|
259
|
+
var _default = exports.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,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TableContext = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
const TableContext = exports.TableContext = /*#__PURE__*/(0, _react.createContext)({
|
|
9
|
+
prefix: 'ui-rc',
|
|
10
|
+
id: '',
|
|
11
|
+
isDataTree: false,
|
|
12
|
+
rowKey: 'rowId',
|
|
13
|
+
dataSource: [],
|
|
14
|
+
originData: [],
|
|
15
|
+
expanded: {},
|
|
16
|
+
windowSize: {
|
|
17
|
+
innerHeight: 0,
|
|
18
|
+
innerWidth: 0
|
|
19
|
+
},
|
|
20
|
+
// triggerFilter: () => { },
|
|
21
|
+
|
|
22
|
+
setIsSelectionChange: () => {},
|
|
23
|
+
setSorterChange: () => {},
|
|
24
|
+
setFilterChange: () => {},
|
|
25
|
+
setExpanded: () => {},
|
|
26
|
+
handleCellClick: () => {}
|
|
27
|
+
});
|
|
@@ -39,6 +39,7 @@ const InternalTable = props => {
|
|
|
39
39
|
selectionSettings,
|
|
40
40
|
expandable,
|
|
41
41
|
onChooseColumns,
|
|
42
|
+
onExpandClick,
|
|
42
43
|
// contextMenuClick,
|
|
43
44
|
// contextMenuOpen,
|
|
44
45
|
height,
|
|
@@ -77,6 +78,7 @@ const InternalTable = props => {
|
|
|
77
78
|
const [sorterStates, setSorterStates] = _react.default.useState([]);
|
|
78
79
|
const [isFullScreen, setIsFullScreen] = _react.default.useState(false);
|
|
79
80
|
const [columns, setColumns] = _react.default.useState([]);
|
|
81
|
+
const [isExpandClick, setIsExpandClick] = _react.default.useState(false);
|
|
80
82
|
_react.default.useEffect(() => {
|
|
81
83
|
// setColumns(propsColumns as any)
|
|
82
84
|
|
|
@@ -114,6 +116,9 @@ const InternalTable = props => {
|
|
|
114
116
|
value: undefined
|
|
115
117
|
});
|
|
116
118
|
_react.default.useEffect(() => {
|
|
119
|
+
if (onExpandClick || isExpandClick) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
117
122
|
if (defaultExpandAllRows) {
|
|
118
123
|
const allKeys = (0, _utils.findAllChildrenKeys2)(convertData, rowKey, 'children');
|
|
119
124
|
setExpanded((0, _utils.convertToObjTrue)(allKeys));
|
|
@@ -122,7 +127,7 @@ const InternalTable = props => {
|
|
|
122
127
|
setExpanded((0, _utils.convertToObjTrue)(defaultExpandedRowKeys ?? []));
|
|
123
128
|
}
|
|
124
129
|
}
|
|
125
|
-
}, [defaultExpandAllRows, convertData, defaultExpandedRowKeys]);
|
|
130
|
+
}, [defaultExpandAllRows, convertData, defaultExpandedRowKeys, onExpandClick, isExpandClick]);
|
|
126
131
|
|
|
127
132
|
// ========================= Keys =========================
|
|
128
133
|
|
|
@@ -190,7 +195,9 @@ const InternalTable = props => {
|
|
|
190
195
|
selectionSettings: selectionSettings,
|
|
191
196
|
mergedSelectedKeys: mergedSelectedKeys,
|
|
192
197
|
expandable: expandable,
|
|
193
|
-
|
|
198
|
+
onExpandClick: onExpandClick,
|
|
199
|
+
setColumns: setColumns,
|
|
200
|
+
setIsExpandClick: setIsExpandClick
|
|
194
201
|
})));
|
|
195
202
|
};
|
|
196
203
|
var _default = exports.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
|
};
|
|
@@ -76,7 +76,9 @@ const TableContainer = props => {
|
|
|
76
76
|
onRowFooterStyles,
|
|
77
77
|
onRowHeaderStyles,
|
|
78
78
|
title,
|
|
79
|
-
dataSourceFilter
|
|
79
|
+
dataSourceFilter,
|
|
80
|
+
onExpandClick,
|
|
81
|
+
setIsExpandClick
|
|
80
82
|
} = props;
|
|
81
83
|
const tableContainerRef = _react.default.useRef(null);
|
|
82
84
|
const containerRef = _react.default.useRef(null);
|
|
@@ -279,7 +281,9 @@ const TableContainer = props => {
|
|
|
279
281
|
onRowHeaderStyles,
|
|
280
282
|
table,
|
|
281
283
|
pagination,
|
|
282
|
-
dataSourceFilter
|
|
284
|
+
dataSourceFilter,
|
|
285
|
+
onExpandClick,
|
|
286
|
+
setIsExpandClick
|
|
283
287
|
}
|
|
284
288
|
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, {
|
|
285
289
|
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;
|
|
@@ -133,7 +133,8 @@ const TableContainerEdit = props => {
|
|
|
133
133
|
columnSizingInfo,
|
|
134
134
|
rowClassName,
|
|
135
135
|
onRowStyles,
|
|
136
|
-
dataSourceFilter
|
|
136
|
+
dataSourceFilter,
|
|
137
|
+
setIsExpandClick
|
|
137
138
|
} = props;
|
|
138
139
|
const containerRef = _react.default.useRef(null);
|
|
139
140
|
const bottomToolbarRef = _react.default.useRef(null);
|
|
@@ -1910,7 +1911,8 @@ const TableContainerEdit = props => {
|
|
|
1910
1911
|
rowClassName,
|
|
1911
1912
|
rowEditable,
|
|
1912
1913
|
onRowStyles,
|
|
1913
|
-
dataSourceFilter
|
|
1914
|
+
dataSourceFilter,
|
|
1915
|
+
setIsExpandClick
|
|
1914
1916
|
}
|
|
1915
1917
|
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, {
|
|
1916
1918
|
contextMenuItems: contextMenuItems,
|
|
@@ -85,7 +85,8 @@ const renderSelection = args => {
|
|
|
85
85
|
expandIconColumnIndex,
|
|
86
86
|
isDataTree,
|
|
87
87
|
expanded,
|
|
88
|
-
setExpanded
|
|
88
|
+
setExpanded,
|
|
89
|
+
onExpandClick
|
|
89
90
|
} = args;
|
|
90
91
|
const {
|
|
91
92
|
selectionSettings,
|
|
@@ -103,20 +104,33 @@ const renderSelection = args => {
|
|
|
103
104
|
}
|
|
104
105
|
}, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
|
|
105
106
|
// onClick: row.getToggleExpandedHandler(),
|
|
106
|
-
onClick:
|
|
107
|
+
onClick: e => {
|
|
108
|
+
e.stopPropagation();
|
|
107
109
|
const keys = Object.keys(expanded);
|
|
108
110
|
// @ts-ignore
|
|
109
111
|
const tmp = {
|
|
110
112
|
...expanded
|
|
111
113
|
};
|
|
114
|
+
|
|
115
|
+
// collapse
|
|
112
116
|
if (keys.includes(cell.row.id)) {
|
|
113
117
|
delete tmp[cell.row.id];
|
|
114
118
|
setExpanded(tmp);
|
|
115
119
|
} else {
|
|
120
|
+
// collapse
|
|
116
121
|
setExpanded(old => ({
|
|
117
122
|
...old,
|
|
118
123
|
[cell.row.id]: true
|
|
119
124
|
}));
|
|
125
|
+
const expandedKeys = {
|
|
126
|
+
...tmp,
|
|
127
|
+
[cell.row.id]: true
|
|
128
|
+
};
|
|
129
|
+
onExpandClick?.({
|
|
130
|
+
expandedKeys: Object.keys(expandedKeys),
|
|
131
|
+
key: cell.row.id,
|
|
132
|
+
rowData: cell.row.original
|
|
133
|
+
});
|
|
120
134
|
}
|
|
121
135
|
},
|
|
122
136
|
style: {
|
|
@@ -168,7 +182,8 @@ const TableBodyCell = props => {
|
|
|
168
182
|
isSelectionChange,
|
|
169
183
|
selectionSettings,
|
|
170
184
|
wrapSettings,
|
|
171
|
-
pagination
|
|
185
|
+
pagination,
|
|
186
|
+
onExpandClick
|
|
172
187
|
// dataSource
|
|
173
188
|
} = _react.default.useContext(_useContext.TableContext);
|
|
174
189
|
const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
|
|
@@ -233,20 +248,33 @@ const TableBodyCell = props => {
|
|
|
233
248
|
}
|
|
234
249
|
}, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
|
|
235
250
|
// onClick: row.getToggleExpandedHandler(),
|
|
236
|
-
onClick:
|
|
251
|
+
onClick: e => {
|
|
252
|
+
e.stopPropagation();
|
|
237
253
|
const keys = Object.keys(expanded);
|
|
238
254
|
// @ts-ignore
|
|
239
255
|
const tmp = {
|
|
240
256
|
...expanded
|
|
241
257
|
};
|
|
258
|
+
|
|
259
|
+
// collapse
|
|
242
260
|
if (keys.includes(cell.row.id)) {
|
|
243
261
|
delete tmp[cell.row.id];
|
|
244
262
|
setExpanded(tmp);
|
|
245
263
|
} else {
|
|
264
|
+
// expand
|
|
246
265
|
setExpanded(old => ({
|
|
247
266
|
...old,
|
|
248
267
|
[cell.row.id]: true
|
|
249
268
|
}));
|
|
269
|
+
const expandedKeys = {
|
|
270
|
+
...tmp,
|
|
271
|
+
[cell.row.id]: true
|
|
272
|
+
};
|
|
273
|
+
onExpandClick?.({
|
|
274
|
+
expandedKeys: Object.keys(expandedKeys),
|
|
275
|
+
key: cell.row.id,
|
|
276
|
+
rowData: record
|
|
277
|
+
});
|
|
250
278
|
}
|
|
251
279
|
},
|
|
252
280
|
style: {
|
|
@@ -318,7 +346,8 @@ const TableBodyCell = props => {
|
|
|
318
346
|
isDataTree,
|
|
319
347
|
setExpanded,
|
|
320
348
|
expandIconColumnIndex,
|
|
321
|
-
isSelectionChange
|
|
349
|
+
isSelectionChange,
|
|
350
|
+
onExpandClick
|
|
322
351
|
})));
|
|
323
352
|
}
|
|
324
353
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -403,41 +432,8 @@ const TableBodyCell = props => {
|
|
|
403
432
|
selectionSettings
|
|
404
433
|
});
|
|
405
434
|
cell.row.getToggleSelectedHandler()(e);
|
|
406
|
-
|
|
407
|
-
// if (cell.row.getIsSelected()) { // nếu đã chọn
|
|
408
|
-
|
|
409
|
-
// const aaa = isSelectionChange?.rowsData.filter((it) => it.id !== cell.row.id)
|
|
410
|
-
|
|
411
|
-
// setIsSelectionChange({
|
|
412
|
-
// isChange: true,
|
|
413
|
-
// type: 'rowSelected',
|
|
414
|
-
// rowData: cell.row.original,
|
|
415
|
-
// rowsData: aaa ?? []
|
|
416
|
-
// })
|
|
417
|
-
|
|
418
|
-
// } else {
|
|
419
|
-
|
|
420
|
-
// const { rowsData } = isSelectionChange ?? {}
|
|
421
|
-
|
|
422
|
-
// const abc = rowsData && rowsData.length > 0 ? [...rowsData] : []
|
|
423
|
-
|
|
424
|
-
// abc.push(cell.row)
|
|
425
|
-
|
|
426
|
-
// setIsSelectionChange({
|
|
427
|
-
// isChange: true,
|
|
428
|
-
// type: 'rowSelected',
|
|
429
|
-
// rowData: cell.row.original,
|
|
430
|
-
// rowsData: abc
|
|
431
|
-
// })
|
|
432
|
-
// }
|
|
433
435
|
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// onKeyUp={() => {
|
|
437
|
-
|
|
438
|
-
// }}
|
|
439
|
-
,
|
|
440
|
-
|
|
436
|
+
},
|
|
441
437
|
onClick: e => {
|
|
442
438
|
const selection = window.getSelection();
|
|
443
439
|
const text = selection ? selection.toString() : "";
|
|
@@ -466,20 +462,33 @@ const TableBodyCell = props => {
|
|
|
466
462
|
}
|
|
467
463
|
}, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
|
|
468
464
|
// onClick: row.getToggleExpandedHandler(),
|
|
469
|
-
onClick:
|
|
465
|
+
onClick: e => {
|
|
466
|
+
e.stopPropagation();
|
|
470
467
|
const keys = Object.keys(expanded);
|
|
471
468
|
// @ts-ignore
|
|
472
469
|
const tmp = {
|
|
473
470
|
...expanded
|
|
474
471
|
};
|
|
472
|
+
|
|
473
|
+
// collapse
|
|
475
474
|
if (keys.includes(cell.row.id)) {
|
|
476
475
|
delete tmp[cell.row.id];
|
|
477
476
|
setExpanded(tmp);
|
|
478
477
|
} else {
|
|
478
|
+
// expand
|
|
479
479
|
setExpanded(old => ({
|
|
480
480
|
...old,
|
|
481
481
|
[cell.row.id]: true
|
|
482
482
|
}));
|
|
483
|
+
const expandedKeys = {
|
|
484
|
+
...tmp,
|
|
485
|
+
[cell.row.id]: true
|
|
486
|
+
};
|
|
487
|
+
onExpandClick?.({
|
|
488
|
+
expandedKeys: Object.keys(expandedKeys),
|
|
489
|
+
key: cell.row.id,
|
|
490
|
+
rowData: record
|
|
491
|
+
});
|
|
483
492
|
}
|
|
484
493
|
},
|
|
485
494
|
style: {
|