es-grid-template 1.5.0 → 1.5.2
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/ColumnsChoose.js +1 -1
- package/es/grid-component/EditableCell.js +14 -12
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +15 -4
- package/es/grid-component/TableGrid.js +1 -1
- package/es/grid-component/async-select/index.d.ts +4 -2
- package/es/grid-component/async-select/index.js +3 -0
- package/es/grid-component/async-table-select/index.d.ts +4 -2
- package/es/grid-component/async-table-select/index.js +4 -1
- package/es/grid-component/hooks/columns/index.d.ts +1 -1
- package/es/grid-component/hooks/columns/index.js +19 -31
- package/es/grid-component/hooks/utils.d.ts +3 -0
- package/es/grid-component/hooks/utils.js +85 -2
- package/es/grid-component/styles.scss +4 -0
- package/es/grid-component/table/GridEdit.js +93 -76
- package/es/grid-component/table/Group.js +11 -1
- package/es/grid-component/type.d.ts +9 -0
- package/es/grid-component/useContext.d.ts +1 -0
- package/es/grid-component/useContext.js +2 -1
- package/lib/grid-component/ColumnsChoose.js +1 -1
- package/lib/grid-component/EditableCell.js +14 -12
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +14 -3
- package/lib/grid-component/TableGrid.js +1 -1
- package/lib/grid-component/async-select/index.d.ts +4 -2
- package/lib/grid-component/async-select/index.js +3 -0
- package/lib/grid-component/async-table-select/index.d.ts +4 -2
- package/lib/grid-component/async-table-select/index.js +4 -1
- package/lib/grid-component/hooks/columns/index.d.ts +1 -1
- package/lib/grid-component/hooks/columns/index.js +17 -29
- package/lib/grid-component/hooks/utils.d.ts +3 -0
- package/lib/grid-component/hooks/utils.js +96 -7
- package/lib/grid-component/styles.scss +4 -0
- package/lib/grid-component/table/GridEdit.js +93 -76
- package/lib/grid-component/table/Group.js +11 -1
- package/lib/grid-component/type.d.ts +9 -0
- package/lib/grid-component/useContext.d.ts +1 -0
- package/lib/grid-component/useContext.js +2 -1
- package/package.json +110 -110
|
@@ -211,6 +211,7 @@ const GridEdit = props => {
|
|
|
211
211
|
showDefaultContext,
|
|
212
212
|
validate,
|
|
213
213
|
setTooltipContent,
|
|
214
|
+
onBlur,
|
|
214
215
|
...rest
|
|
215
216
|
} = props;
|
|
216
217
|
const ref = (0, _react.useRef)(null);
|
|
@@ -227,6 +228,8 @@ const GridEdit = props => {
|
|
|
227
228
|
// quét vùng chọn
|
|
228
229
|
const isDragMouse = (0, _react.useRef)(false);
|
|
229
230
|
const isMouseDown = (0, _react.useRef)(false);
|
|
231
|
+
const editingKey = (0, _react.useRef)('');
|
|
232
|
+
const cellEditing = (0, _react.useRef)({});
|
|
230
233
|
|
|
231
234
|
// quét vùng được paste - tiếp tục hiển thị con trỏ crosshair
|
|
232
235
|
// const isPasteDragging = useRef(false);
|
|
@@ -372,7 +375,9 @@ const GridEdit = props => {
|
|
|
372
375
|
// }, [])
|
|
373
376
|
|
|
374
377
|
const [form] = _antd.Form.useForm();
|
|
375
|
-
|
|
378
|
+
|
|
379
|
+
// const [editingKey, setEditingKey] = useState<string | number>('')
|
|
380
|
+
|
|
376
381
|
const [dataErrors, setDataErrors] = (0, _react.useState)([]);
|
|
377
382
|
const [isFilter, setIsFilter] = _react.default.useState(false);
|
|
378
383
|
const [rangeCells, setRangeCells] = (0, _react.useState)(new Set());
|
|
@@ -381,7 +386,9 @@ const GridEdit = props => {
|
|
|
381
386
|
type: ''
|
|
382
387
|
});
|
|
383
388
|
const [rowsAdd, setRowsAdd] = (0, _react.useState)(1);
|
|
384
|
-
|
|
389
|
+
|
|
390
|
+
// const [cellEditing, setCellEditing] = useState<any>(null)
|
|
391
|
+
|
|
385
392
|
const [isPasteDragging, setIsPasteDragging] = (0, _react.useState)(false); // isPasteDragging == tiếp tục hiển thị con trỏ crosshair
|
|
386
393
|
|
|
387
394
|
const [innerExpandedKeys, setInnerExpandedKeys] = _react.default.useState(() => {
|
|
@@ -494,10 +501,11 @@ const GridEdit = props => {
|
|
|
494
501
|
// onRemoveBorderSelectedCell(selectedCells.current, id)
|
|
495
502
|
//
|
|
496
503
|
|
|
497
|
-
setTimeout(() => {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}, 10)
|
|
504
|
+
// setTimeout(() => {
|
|
505
|
+
// onAddBgSelectedCell(selectedCells.current, id)
|
|
506
|
+
// onAddBorderSelectedCell(selectedCells.current, id)
|
|
507
|
+
// }, 10)
|
|
508
|
+
|
|
501
509
|
const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
|
|
502
510
|
// const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
|
|
503
511
|
|
|
@@ -685,10 +693,11 @@ const GridEdit = props => {
|
|
|
685
693
|
}
|
|
686
694
|
}, [dataSource, defaultValue, getRowKey, mergedExpandedKeys, rowKey, rowsFocus, triggerChangeData]);
|
|
687
695
|
const handleDeleteRows = _react.default.useCallback(item => {
|
|
688
|
-
setTimeout(() => {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
})
|
|
696
|
+
// setTimeout(() => {
|
|
697
|
+
// onAddBgSelectedCell(selectedCells.current, id)
|
|
698
|
+
// onAddBorderSelectedCell(selectedCells.current, id)
|
|
699
|
+
// })
|
|
700
|
+
|
|
692
701
|
if (item.onClick) {
|
|
693
702
|
item.onClick({
|
|
694
703
|
toolbar: item
|
|
@@ -720,7 +729,9 @@ const GridEdit = props => {
|
|
|
720
729
|
const rowIndex = Number(rowIndexStr);
|
|
721
730
|
const colIndex = Number(colIndexStr);
|
|
722
731
|
const field = colIndexToField[colIndex];
|
|
723
|
-
|
|
732
|
+
const column = (0, _columns.flatColumns2)(visibleCols)[colIndex];
|
|
733
|
+
const rowData = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowIndex];
|
|
734
|
+
if (newData[rowIndex] && field && field in newData[rowIndex] && (0, _hooks.isEditable)(column, rowData)) {
|
|
724
735
|
// @ts-ignore
|
|
725
736
|
newData[rowIndex][field] = '';
|
|
726
737
|
}
|
|
@@ -951,9 +962,13 @@ const GridEdit = props => {
|
|
|
951
962
|
mode: 'onChange',
|
|
952
963
|
resolver: validate ? (0, _yup.yupResolver)(validate) : undefined
|
|
953
964
|
});
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
965
|
+
|
|
966
|
+
// const isEditing = React.useCallback((record: RecordType) => {
|
|
967
|
+
// return record[rowKey as any] === editingKey.current
|
|
968
|
+
// }, [editingKey, rowKey])
|
|
969
|
+
|
|
970
|
+
// console.log('isEditing', isEditing)
|
|
971
|
+
|
|
957
972
|
_react.default.useEffect(() => {
|
|
958
973
|
const handleClickOutside = event => {
|
|
959
974
|
const element = event.target;
|
|
@@ -980,9 +995,12 @@ const GridEdit = props => {
|
|
|
980
995
|
// if (ref.current && tableId && !tableId.contains(event.target as Node)) {
|
|
981
996
|
|
|
982
997
|
if (ref.current && tableBody && !tableBody.contains(event.target)) {
|
|
983
|
-
|
|
998
|
+
if (editingKey.current) {
|
|
999
|
+
onBlur?.(dataSource);
|
|
1000
|
+
}
|
|
984
1001
|
setTimeout(() => {
|
|
985
|
-
setEditingKey('')
|
|
1002
|
+
// setEditingKey('')
|
|
1003
|
+
editingKey.current = '';
|
|
986
1004
|
});
|
|
987
1005
|
isSelecting.current = false;
|
|
988
1006
|
startCell.current = null;
|
|
@@ -1000,13 +1018,14 @@ const GridEdit = props => {
|
|
|
1000
1018
|
|
|
1001
1019
|
// document.addEventListener('click', handleClickOutside)
|
|
1002
1020
|
document.addEventListener('mousedown', handleClickOutside);
|
|
1003
|
-
document.addEventListener('touchstart', handleClickOutside)
|
|
1021
|
+
// document.addEventListener('touchstart', handleClickOutside)
|
|
1022
|
+
|
|
1004
1023
|
return () => {
|
|
1005
1024
|
// document.removeEventListener('click', handleClickOutside)
|
|
1006
1025
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
1007
|
-
document.removeEventListener('touchstart', handleClickOutside)
|
|
1026
|
+
// document.removeEventListener('touchstart', handleClickOutside)
|
|
1008
1027
|
};
|
|
1009
|
-
}, [id]);
|
|
1028
|
+
}, [dataSource, id, onBlur]);
|
|
1010
1029
|
const triggerDragPaste = pastesArray => {
|
|
1011
1030
|
const mergedSet = new Set([...selectedCells.current, ...pastesArray]);
|
|
1012
1031
|
const tmpCols = {
|
|
@@ -1416,12 +1435,14 @@ const GridEdit = props => {
|
|
|
1416
1435
|
e.stopPropagation();
|
|
1417
1436
|
return;
|
|
1418
1437
|
}
|
|
1419
|
-
if (editingKey && editingKey === record[rowKey]) {
|
|
1438
|
+
if (editingKey && editingKey.current === record[rowKey]) {
|
|
1420
1439
|
return;
|
|
1421
1440
|
}
|
|
1422
|
-
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1441
|
+
if (record[rowKey] !== editingKey.current && editingKey.current !== '') {
|
|
1423
1442
|
setTimeout(() => {
|
|
1424
|
-
setEditingKey('')
|
|
1443
|
+
// setEditingKey('')
|
|
1444
|
+
editingKey.current = '';
|
|
1445
|
+
onBlur?.(dataSource);
|
|
1425
1446
|
});
|
|
1426
1447
|
}
|
|
1427
1448
|
|
|
@@ -1657,8 +1678,9 @@ const GridEdit = props => {
|
|
|
1657
1678
|
e.stopPropagation();
|
|
1658
1679
|
return;
|
|
1659
1680
|
}
|
|
1660
|
-
if (editingKey) {
|
|
1661
|
-
|
|
1681
|
+
if (editingKey.current) {
|
|
1682
|
+
editingKey.current = '';
|
|
1683
|
+
// setEditingKey('')
|
|
1662
1684
|
}
|
|
1663
1685
|
isSelectingRow.current = true;
|
|
1664
1686
|
rowStart.current = {
|
|
@@ -1874,12 +1896,20 @@ const GridEdit = props => {
|
|
|
1874
1896
|
const handleEdit = (record, col, editType, e) => {
|
|
1875
1897
|
(0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
|
|
1876
1898
|
setTooltipContent('');
|
|
1899
|
+
|
|
1877
1900
|
// @ts-ignore
|
|
1878
|
-
setEditingKey(record[rowKey])
|
|
1879
|
-
|
|
1901
|
+
// setEditingKey(record[rowKey])
|
|
1902
|
+
editingKey.current = record[rowKey];
|
|
1903
|
+
|
|
1904
|
+
// setCellEditing({
|
|
1905
|
+
// row: record,
|
|
1906
|
+
// column: col
|
|
1907
|
+
// })
|
|
1908
|
+
|
|
1909
|
+
cellEditing.current = {
|
|
1880
1910
|
row: record,
|
|
1881
1911
|
column: col
|
|
1882
|
-
}
|
|
1912
|
+
};
|
|
1883
1913
|
reset();
|
|
1884
1914
|
|
|
1885
1915
|
// const formattedRecord = { ...record };
|
|
@@ -1953,7 +1983,7 @@ const GridEdit = props => {
|
|
|
1953
1983
|
}
|
|
1954
1984
|
};
|
|
1955
1985
|
const handleFocusCell = (rowIndex, colIndex, col, scrollType, e, isTimeout) => {
|
|
1956
|
-
const isEdit = editingKey !== '';
|
|
1986
|
+
const isEdit = editingKey.current !== '';
|
|
1957
1987
|
const cellEdit = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${rowIndex}"].cell-editing[data-col-index="${colIndex}"]`);
|
|
1958
1988
|
const cell = document.querySelector(`.ui-rc-table-row .cell-editable[data-row-index="${rowIndex}"].cell-editable[data-col-index="${colIndex}"]`);
|
|
1959
1989
|
const updateSelection = () => {
|
|
@@ -1997,7 +2027,8 @@ const GridEdit = props => {
|
|
|
1997
2027
|
scrollToCell(rowIndex, colIndex, editingCell, 'horizontal');
|
|
1998
2028
|
}
|
|
1999
2029
|
if (scrollType === 'vertical' && cellEditable) {
|
|
2000
|
-
setEditingKey('')
|
|
2030
|
+
// setEditingKey('')
|
|
2031
|
+
editingKey.current = '';
|
|
2001
2032
|
updateSelection();
|
|
2002
2033
|
scrollToCell(rowIndex, colIndex, cellEdit, 'vertical');
|
|
2003
2034
|
if (e?.key !== 'Tab') {
|
|
@@ -2046,13 +2077,13 @@ const GridEdit = props => {
|
|
|
2046
2077
|
return {
|
|
2047
2078
|
'data-row-index': rowNumber,
|
|
2048
2079
|
onPaste: event => {
|
|
2049
|
-
if (editingKey === '') {
|
|
2080
|
+
if (editingKey.current === '') {
|
|
2050
2081
|
handlePaste(record, colIndex + 1, rowNumber, event);
|
|
2051
2082
|
event.preventDefault();
|
|
2052
2083
|
}
|
|
2053
2084
|
},
|
|
2054
2085
|
onCopy: e => {
|
|
2055
|
-
if (editingKey === '') {
|
|
2086
|
+
if (editingKey.current === '') {
|
|
2056
2087
|
handleCopy(e);
|
|
2057
2088
|
e.preventDefault();
|
|
2058
2089
|
}
|
|
@@ -2093,7 +2124,7 @@ const GridEdit = props => {
|
|
|
2093
2124
|
const key = getRowKey(record, dataSource.indexOf(record));
|
|
2094
2125
|
if (event.key === 'Control' && event.ctrlKey) {} else {
|
|
2095
2126
|
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
|
|
2096
|
-
if (record[rowKey] !== editingKey && (0, _hooks.isEditable)(column, record)) {
|
|
2127
|
+
if (record[rowKey] !== editingKey.current && (0, _hooks.isEditable)(column, record)) {
|
|
2097
2128
|
// ~~ khi editingKey = ''
|
|
2098
2129
|
event.preventDefault();
|
|
2099
2130
|
event.stopPropagation();
|
|
@@ -2116,7 +2147,7 @@ const GridEdit = props => {
|
|
|
2116
2147
|
if (event.key === 'Enter') {
|
|
2117
2148
|
event.preventDefault();
|
|
2118
2149
|
event.stopPropagation();
|
|
2119
|
-
if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < (0, _hooks.flattenArray)(dataSource).length && event.key === 'Enter') {
|
|
2150
|
+
if (editingKey && editingKey.current !== '' && (rowNumber ?? 0) + 1 < (0, _hooks.flattenArray)(dataSource).length && event.key === 'Enter') {
|
|
2120
2151
|
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
2121
2152
|
} else {
|
|
2122
2153
|
// // focus cell hiện tại và tắt edit
|
|
@@ -2132,7 +2163,7 @@ const GridEdit = props => {
|
|
|
2132
2163
|
}
|
|
2133
2164
|
}
|
|
2134
2165
|
if (event.key === 'Tab') {
|
|
2135
|
-
if (editingKey) {} else {
|
|
2166
|
+
if (editingKey.current) {} else {
|
|
2136
2167
|
if (colIndex + 1 !== visibleCols.length) {
|
|
2137
2168
|
handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
|
|
2138
2169
|
} else {
|
|
@@ -2142,7 +2173,7 @@ const GridEdit = props => {
|
|
|
2142
2173
|
}
|
|
2143
2174
|
}
|
|
2144
2175
|
if (event.key === 'ArrowRight' && colIndex + 1 !== visibleCols.length) {
|
|
2145
|
-
if (editingKey !== '') {} else {
|
|
2176
|
+
if (editingKey.current !== '') {} else {
|
|
2146
2177
|
handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
|
|
2147
2178
|
}
|
|
2148
2179
|
}
|
|
@@ -2151,47 +2182,51 @@ const GridEdit = props => {
|
|
|
2151
2182
|
event.stopPropagation();
|
|
2152
2183
|
event.preventDefault();
|
|
2153
2184
|
} else {
|
|
2154
|
-
if (editingKey !== '') {} else {
|
|
2185
|
+
if (editingKey.current !== '') {} else {
|
|
2155
2186
|
handleFocusCell(rowNumber, colIndex - 1, column, 'horizontal', event);
|
|
2156
2187
|
}
|
|
2157
2188
|
}
|
|
2158
2189
|
}
|
|
2159
2190
|
if (event.key === 'ArrowDown' && (rowNumber ?? 0) + 1 < (0, _hooks.flattenArray)(dataSource).length) {
|
|
2160
|
-
if (isEditing(record) && (
|
|
2191
|
+
// if (isEditing(record) && (
|
|
2192
|
+
if (record[rowKey] === editingKey.current && ((0, _hooks.getEditType)(column, record) === 'treeSelect' || (0, _hooks.getEditType)(column, record) === 'select' || (0, _hooks.getEditType)(column, record) === 'selectTable' || (0, _hooks.getEditType)(column, record) === 'asyncSelect')) {
|
|
2161
2193
|
event.stopPropagation();
|
|
2162
2194
|
} else {
|
|
2163
2195
|
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
2164
2196
|
}
|
|
2165
2197
|
}
|
|
2166
2198
|
if (event.key === 'ArrowUp' && (rowNumber ?? 0) > 0) {
|
|
2167
|
-
if (
|
|
2199
|
+
if (record[rowKey] === editingKey.current && ((0, _hooks.getEditType)(column, record) === 'asyncSelect' || (0, _hooks.getEditType)(column, record) === 'select' || (0, _hooks.getEditType)(column, record) === 'selectTable' || (0, _hooks.getEditType)(column, record) === 'treeSelect')) {
|
|
2168
2200
|
event.stopPropagation();
|
|
2169
2201
|
} else {
|
|
2170
2202
|
handleFocusCell((rowNumber ?? 0) - 1, colIndex, column, 'vertical', event);
|
|
2171
2203
|
}
|
|
2172
2204
|
}
|
|
2173
2205
|
if (event.key === 'Delete') {
|
|
2206
|
+
if (!(0, _hooks.isEditable)(column, record)) {}
|
|
2174
2207
|
handleDeleteContent();
|
|
2175
2208
|
}
|
|
2176
2209
|
if (event.key === 'Escape') {
|
|
2177
|
-
setEditingKey('')
|
|
2210
|
+
// setEditingKey('')
|
|
2211
|
+
editingKey.current = '';
|
|
2178
2212
|
}
|
|
2179
2213
|
}
|
|
2180
2214
|
},
|
|
2181
2215
|
onPaste: event => {
|
|
2182
|
-
if (editingKey === '') {
|
|
2216
|
+
if (editingKey.current === '') {
|
|
2183
2217
|
handlePaste(record, colIndex, rowNumber, event);
|
|
2184
2218
|
event.preventDefault();
|
|
2185
2219
|
}
|
|
2186
2220
|
},
|
|
2187
2221
|
onCopy: e => {
|
|
2188
|
-
if (editingKey === '') {
|
|
2222
|
+
if (editingKey.current === '') {
|
|
2189
2223
|
handleCopy(e);
|
|
2190
2224
|
e.preventDefault();
|
|
2191
2225
|
}
|
|
2192
2226
|
},
|
|
2193
2227
|
onDoubleClick: event => {
|
|
2194
|
-
if (!isEditing(record) && record[rowKey] !== editingKey &&
|
|
2228
|
+
// if (!isEditing(record) && record[rowKey] !== editingKey.current && isEditable(column as any, record)) {
|
|
2229
|
+
if (!(record[rowKey] === editingKey.current) && record[rowKey] !== editingKey.current && (0, _hooks.isEditable)(column, record)) {
|
|
2195
2230
|
handleEdit(record, column, (0, _hooks.getEditType)(column, record), event);
|
|
2196
2231
|
|
|
2197
2232
|
// onRemoveBgSelectedCell(selectedCells.current, id)
|
|
@@ -2216,26 +2251,21 @@ const GridEdit = props => {
|
|
|
2216
2251
|
}
|
|
2217
2252
|
},
|
|
2218
2253
|
onClick: () => {
|
|
2219
|
-
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
2254
|
+
if (record[rowKey] !== editingKey.current && editingKey.current !== '') {
|
|
2220
2255
|
// setEditingKey('')
|
|
2221
2256
|
} else {
|
|
2222
|
-
if (record[rowKey] !== editingKey) {
|
|
2257
|
+
if (record[rowKey] !== editingKey.current) {
|
|
2223
2258
|
(0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
|
|
2224
2259
|
}
|
|
2225
|
-
if (editingKey) {
|
|
2260
|
+
if (editingKey.current) {
|
|
2226
2261
|
handleCellClick(rowNumber, record, column);
|
|
2227
2262
|
}
|
|
2228
2263
|
}
|
|
2229
2264
|
},
|
|
2230
2265
|
// className: isEditing(record) ? `rc-ui-cell-editable cell-editing ${!isEditable(column as any, record) ? 'disable' : ''}` : `rc-ui-cell-editable cell-editable ${!isEditable(column as any, record) ? 'disable' : ''}`,
|
|
2231
2266
|
className: (0, _classnames.default)('rc-ui-cell-editable', {
|
|
2232
|
-
'cell-editing':
|
|
2233
|
-
'cell-editable': !
|
|
2234
|
-
// selected: isSelectedCell(rangeCells,rowIndex, colIndex),
|
|
2235
|
-
// 'cell-border-bottom': isRangeCell(rangeCells, 'bottom',rowIndex, colIndex),
|
|
2236
|
-
// 'cell-border-right': isRangeCell(rangeCells, 'right',rowIndex, colIndex),
|
|
2237
|
-
// 'cell-border-top': isRangeCell(rangeCells, 'top',rowIndex, colIndex),
|
|
2238
|
-
// 'cell-border-left': isRangeCell(rangeCells, 'left',rowIndex, colIndex),
|
|
2267
|
+
'cell-editing': record[rowKey] === editingKey.current,
|
|
2268
|
+
'cell-editable': !(record[rowKey] === editingKey.current),
|
|
2239
2269
|
disable: !(0, _hooks.isEditable)(column, record)
|
|
2240
2270
|
}),
|
|
2241
2271
|
record,
|
|
@@ -2247,9 +2277,11 @@ const GridEdit = props => {
|
|
|
2247
2277
|
title: (0, _columns.getValueCell)(column, record[column.field], format),
|
|
2248
2278
|
'data-col-index': colIndex,
|
|
2249
2279
|
'data-row-index': rowNumber,
|
|
2250
|
-
'data-tooltip-id': "tooltip-cell-content",
|
|
2251
|
-
|
|
2252
|
-
|
|
2280
|
+
// 'data-tooltip-id': "tooltip-cell-content",
|
|
2281
|
+
'data-tooltip-id': `${id}-tooltip-cell-content`,
|
|
2282
|
+
// editing: isEditing(record) && rowEditable?.(record) !== false && isEditable(column as any, record),
|
|
2283
|
+
editing: record.rowId === editingKey.current && rowEditable?.(record) !== false && (0, _hooks.isEditable)(column, record),
|
|
2284
|
+
cellEditing: cellEditing.current,
|
|
2253
2285
|
t,
|
|
2254
2286
|
tabIndex: (rowIndex ?? 0) * visibleCols.length + colIndex,
|
|
2255
2287
|
style: isPasteDragging ? {
|
|
@@ -2264,13 +2296,13 @@ const GridEdit = props => {
|
|
|
2264
2296
|
handleClickColHeader(column, colIndex);
|
|
2265
2297
|
},
|
|
2266
2298
|
onCopy: e => {
|
|
2267
|
-
if (editingKey === '') {
|
|
2299
|
+
if (editingKey.current === '') {
|
|
2268
2300
|
handleCopy(e);
|
|
2269
2301
|
e.preventDefault();
|
|
2270
2302
|
}
|
|
2271
2303
|
},
|
|
2272
2304
|
onPaste: event => {
|
|
2273
|
-
if (editingKey === '') {
|
|
2305
|
+
if (editingKey.current === '') {
|
|
2274
2306
|
handlePaste(dataSource[0], colIndex, 0, event);
|
|
2275
2307
|
event.preventDefault();
|
|
2276
2308
|
}
|
|
@@ -2286,18 +2318,12 @@ const GridEdit = props => {
|
|
|
2286
2318
|
const cellFormat = (0, _hooks.getFormat)(colFormat, format);
|
|
2287
2319
|
const rowError = dataErrors.find(it => it.index === rowNumber);
|
|
2288
2320
|
const cellError = rowError && column.field && rowError[column.field]?.field === column.field ? rowError[column.field] : null;
|
|
2289
|
-
|
|
2290
|
-
// const aaa = dataErrors.find((it) => column?.field && it[column.field].field === column.field && it.index === rowNumber)
|
|
2291
|
-
// const aaa = column.field && rowError && rowError[column.field]?.field === column?.field
|
|
2292
|
-
|
|
2293
2321
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
2294
2322
|
className: (0, _classnames.default)('ui-rc_cell-content', {
|
|
2295
|
-
// disable: !isEditable(column as any, record)
|
|
2296
2323
|
isValid: column.field && rowError && rowError[column.field]?.field === column?.field
|
|
2297
2324
|
}),
|
|
2298
2325
|
onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
|
|
2299
2326
|
onMouseEnter: event => {
|
|
2300
|
-
// setTooltipContent(cellError ? cellError.message : renderContent(column as any, value, record, rowIndex, cellFormat))
|
|
2301
2327
|
setTooltipContent(cellError ? cellError.message : '');
|
|
2302
2328
|
handleMouseEnter(rowNumber, colIndex, event);
|
|
2303
2329
|
},
|
|
@@ -2308,20 +2334,9 @@ const GridEdit = props => {
|
|
|
2308
2334
|
isDragMouse.current = true;
|
|
2309
2335
|
}
|
|
2310
2336
|
}
|
|
2311
|
-
|
|
2312
|
-
// onClick={(event) => {
|
|
2313
|
-
//
|
|
2314
|
-
// handleClickCell(event)
|
|
2315
|
-
//
|
|
2316
|
-
// }}
|
|
2317
2337
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
2318
2338
|
className: 'ui-rc_content'
|
|
2319
|
-
}, (0, _columns.renderContent)(column, value, record, rowIndex, cellFormat)),
|
|
2320
|
-
// selectedCells.current && selectedCells.current.size > 0 && getLastSelectCell(selectedCells.current).row === rowNumber &&
|
|
2321
|
-
// getLastSelectCell(selectedCells.current).col === colIndex &&
|
|
2322
|
-
// isEditable(column as any, record) &&
|
|
2323
|
-
|
|
2324
|
-
!isDragMouse.current && /*#__PURE__*/_react.default.createElement("div", {
|
|
2339
|
+
}, (0, _columns.renderContent)(column, value, record, rowIndex, cellFormat)), !isDragMouse.current && /*#__PURE__*/_react.default.createElement("div", {
|
|
2325
2340
|
className: 'dragging-point hidden',
|
|
2326
2341
|
onMouseDown: e => {
|
|
2327
2342
|
// e.stopPropagation()
|
|
@@ -2412,7 +2427,8 @@ const GridEdit = props => {
|
|
|
2412
2427
|
items: toolbarItemsBottom ?? [],
|
|
2413
2428
|
mode: 'scroll',
|
|
2414
2429
|
onClick: ({}) => {
|
|
2415
|
-
|
|
2430
|
+
editingKey.current = '';
|
|
2431
|
+
// setEditingKey('')
|
|
2416
2432
|
}
|
|
2417
2433
|
}));
|
|
2418
2434
|
};
|
|
@@ -2485,6 +2501,7 @@ const GridEdit = props => {
|
|
|
2485
2501
|
id: id
|
|
2486
2502
|
}, /*#__PURE__*/_react.default.createElement(_useContext.TableContext.Provider, {
|
|
2487
2503
|
value: {
|
|
2504
|
+
id: id ?? '',
|
|
2488
2505
|
rowKey,
|
|
2489
2506
|
form,
|
|
2490
2507
|
format,
|
|
@@ -29,10 +29,12 @@ const Group = props => {
|
|
|
29
29
|
groupAble,
|
|
30
30
|
expandable,
|
|
31
31
|
dataSource,
|
|
32
|
+
rowKey,
|
|
32
33
|
getRowKey,
|
|
33
34
|
groupSetting,
|
|
34
35
|
groupColumns,
|
|
35
36
|
triggerGroupColumns,
|
|
37
|
+
onExpandClick,
|
|
36
38
|
...rest
|
|
37
39
|
} = props;
|
|
38
40
|
const {
|
|
@@ -67,9 +69,16 @@ const Group = props => {
|
|
|
67
69
|
newExpandedKeys = [...mergedExpandedKeys];
|
|
68
70
|
} else {
|
|
69
71
|
newExpandedKeys = [...mergedExpandedKeys, key];
|
|
72
|
+
// gọi sự kiện expand
|
|
73
|
+
|
|
74
|
+
onExpandClick?.({
|
|
75
|
+
expandedKeys: newExpandedKeys,
|
|
76
|
+
key: key,
|
|
77
|
+
rowData: record
|
|
78
|
+
});
|
|
70
79
|
}
|
|
71
80
|
setInnerExpandedKeys(newExpandedKeys);
|
|
72
|
-
}, [getRowKey, mergedExpandedKeys,
|
|
81
|
+
}, [getRowKey, dataSource, mergedExpandedKeys, onExpandClick]);
|
|
73
82
|
const handleExpandAllGroup = () => {
|
|
74
83
|
setInnerExpandedKeys((0, _hooks.findAllChildrenKeys)(dataSource, getRowKey, childrenColumnName) ?? []);
|
|
75
84
|
};
|
|
@@ -116,6 +125,7 @@ const Group = props => {
|
|
|
116
125
|
}, /*#__PURE__*/_react.default.createElement(_TableGrid.default, (0, _extends2.default)({}, rest, {
|
|
117
126
|
t: t,
|
|
118
127
|
id: id,
|
|
128
|
+
rowKey: rowKey,
|
|
119
129
|
columns: columns,
|
|
120
130
|
style: {
|
|
121
131
|
...style,
|
|
@@ -84,6 +84,9 @@ export type ToolbarClick = {
|
|
|
84
84
|
item: any;
|
|
85
85
|
column: any;
|
|
86
86
|
};
|
|
87
|
+
export type LoadOptionsArgs = {
|
|
88
|
+
rowData?: any;
|
|
89
|
+
};
|
|
87
90
|
export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>, 'headerTemplate' | 'title' | 'format' | 'commandItems'> & {
|
|
88
91
|
field?: string;
|
|
89
92
|
key?: any;
|
|
@@ -195,6 +198,12 @@ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<Re
|
|
|
195
198
|
onCellClick?: (args: ICellClick, callback?: any) => void;
|
|
196
199
|
rowEditable?: (rowData: RecordType) => boolean;
|
|
197
200
|
validate?: any;
|
|
201
|
+
onBlur?: (data: RecordType[]) => void;
|
|
202
|
+
onExpandClick?: (args: {
|
|
203
|
+
expandedKeys: string[];
|
|
204
|
+
key: string;
|
|
205
|
+
rowData: any;
|
|
206
|
+
}) => void;
|
|
198
207
|
}
|
|
199
208
|
export type PaginationConfig = TablePaginationConfig & {
|
|
200
209
|
currentPage?: number;
|
|
@@ -19,6 +19,7 @@ export interface IContext<RecordType> {
|
|
|
19
19
|
getValues?: any;
|
|
20
20
|
handleCellChange?: (args: ContextCellChange<RecordType>) => void;
|
|
21
21
|
getRowKey?: GetRowKey<RecordType>;
|
|
22
|
+
id: string;
|
|
22
23
|
}
|
|
23
24
|
export type ContextCellChange<RecordType = AnyObject> = {
|
|
24
25
|
key: string | keyof RecordType | GetRowKey<RecordType>;
|