es-grid-template 1.9.65 → 1.9.67
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/ali-table/ColumnsConfig.js +1 -0
- package/es/ali-table/Grid.d.ts +4 -0
- package/es/ali-table/Grid.js +1 -0
- package/es/ali-table/InternalTable.js +131 -33
- package/es/ali-table/base-table/cell/EditCell.d.ts +0 -2
- package/es/ali-table/base-table/cell/EditCell.js +45 -40
- package/es/ali-table/base-table/styles.js +2 -2
- package/es/ali-table/base-table/styles.scss +14 -0
- package/es/ali-table/pipeline/features/columnCustom.d.ts +3 -0
- package/es/ali-table/pipeline/features/columnCustom.js +139 -140
- package/es/ali-table/pipeline/features/treeSelect.js +10 -3
- package/es/grid-component/type.d.ts +0 -3
- package/es/group-component/hook/utils.d.ts +3 -3
- package/es/table-component/TableContainerEdit.js +8 -7
- package/es/table-component/body/TableBodyCellEdit.js +5 -2
- package/es/table-component/hook/useColumns.js +1 -1
- package/es/table-component/style.js +2 -2
- package/es/table-component/style.scss +1 -24
- package/es/table-component/table/Grid.js +7 -1
- package/es/table-component/useContext.d.ts +1 -0
- package/es/table-virtuoso/InternalTable.js +0 -2
- package/es/table-virtuoso/body/TableBodyCell.js +7 -4
- package/es/table-virtuoso/style.js +1 -1
- package/lib/ali-table/ColumnsConfig.js +2 -0
- package/lib/ali-table/Grid.d.ts +4 -0
- package/lib/ali-table/InternalTable.js +131 -33
- package/lib/ali-table/base-table/cell/EditCell.d.ts +0 -2
- package/lib/ali-table/base-table/cell/EditCell.js +45 -40
- package/lib/ali-table/base-table/styles.js +2 -2
- package/lib/ali-table/base-table/styles.scss +14 -0
- package/lib/ali-table/pipeline/features/columnCustom.d.ts +3 -0
- package/lib/ali-table/pipeline/features/columnCustom.js +136 -139
- package/lib/ali-table/pipeline/features/treeSelect.js +10 -3
- package/lib/grid-component/type.d.ts +0 -3
- package/lib/table-component/TableContainerEdit.js +8 -7
- package/lib/table-component/body/TableBodyCellEdit.js +5 -2
- package/lib/table-component/hook/useColumns.js +1 -1
- package/lib/table-component/style.js +2 -2
- package/lib/table-component/style.scss +1 -24
- package/lib/table-component/table/Grid.js +7 -1
- package/lib/table-component/useContext.d.ts +1 -0
- package/lib/table-virtuoso/InternalTable.js +0 -2
- package/lib/table-virtuoso/body/TableBodyCell.js +7 -4
- package/lib/table-virtuoso/style.js +1 -1
- package/package.json +1 -1
|
@@ -8,7 +8,9 @@ import { booleanOperator, findItemPath, isEditable, isObjEmpty, nonActionColumn,
|
|
|
8
8
|
} from "../../../grid-component/hooks";
|
|
9
9
|
import classNames from 'classnames';
|
|
10
10
|
import { Dropdown, Select, Space, Button } from 'rc-master-ui';
|
|
11
|
-
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, convertFilters, extendsObject,
|
|
11
|
+
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, convertFilters, extendsObject,
|
|
12
|
+
// flattenArray,
|
|
13
|
+
flattenData, getColIdsBetween1, getDefaultOperator, getDragRightData, getEditType, getKeys, getNextColumn, getNextColumn1, getPrevColumn, getRowIdsBetween3,
|
|
12
14
|
// getRowIndexMap,
|
|
13
15
|
getSelectedCellMatrix1, getTypeFilter,
|
|
14
16
|
// isObjEqual,
|
|
@@ -51,7 +53,10 @@ export function columnCustom(opts) {
|
|
|
51
53
|
isDataTree,
|
|
52
54
|
defaultSorter,
|
|
53
55
|
defaultFilter,
|
|
56
|
+
rowIndexMap,
|
|
57
|
+
// Edit
|
|
54
58
|
editAble,
|
|
59
|
+
isAddAble,
|
|
55
60
|
rowEditable,
|
|
56
61
|
setValue,
|
|
57
62
|
reset,
|
|
@@ -64,11 +69,12 @@ export function columnCustom(opts) {
|
|
|
64
69
|
handleSubmit,
|
|
65
70
|
onSubmit,
|
|
66
71
|
handleCellChange,
|
|
72
|
+
handleCellChangeAndAddRow,
|
|
67
73
|
handleHeaderCellChange,
|
|
74
|
+
handleAddMulti,
|
|
68
75
|
dataErrors,
|
|
69
76
|
headerData,
|
|
70
77
|
headerEditAble,
|
|
71
|
-
rowIndexMap,
|
|
72
78
|
onCellClick
|
|
73
79
|
// originData
|
|
74
80
|
|
|
@@ -83,7 +89,6 @@ export function columnCustom(opts) {
|
|
|
83
89
|
const rowKey = 'rowId';
|
|
84
90
|
return function columnResizeFeature(pipeline) {
|
|
85
91
|
// State table
|
|
86
|
-
|
|
87
92
|
const sizes = opts.sizes ?? pipeline.getStateAtKey(stateKeyResize) ?? opts.defaultSizes ?? [];
|
|
88
93
|
const filterState = pipeline.getStateAtKey(stateKeyFilter) ?? defaultFilter ?? [];
|
|
89
94
|
const visible = pipeline.getStateAtKey(stateKeyVisible) ?? '';
|
|
@@ -107,11 +112,16 @@ export function columnCustom(opts) {
|
|
|
107
112
|
// const rowIdsHeader = Array.from({ length: deppthCols }, (_, index) => `field-${index}`)
|
|
108
113
|
|
|
109
114
|
const allCols = [...leafColumns];
|
|
115
|
+
const defaultCellEditing = {
|
|
116
|
+
editing: false,
|
|
117
|
+
element: null,
|
|
118
|
+
rect: null
|
|
119
|
+
};
|
|
110
120
|
|
|
111
121
|
// State for Edit
|
|
112
122
|
|
|
113
123
|
const focusedCell = pipeline.getStateAtKey(stateKeyFocusedCell) ?? {};
|
|
114
|
-
const isEditing = pipeline.getStateAtKey(stateKeyIsEditing) ??
|
|
124
|
+
const isEditing = pipeline.getStateAtKey(stateKeyIsEditing) ?? defaultCellEditing;
|
|
115
125
|
const editCellSettings = pipeline.getStateAtKey(stateKeyEditCellSettings);
|
|
116
126
|
const isSelecting = pipeline.getStateAtKey(stateKeyIsSelecting) ?? false;
|
|
117
127
|
const isPasting = pipeline.getStateAtKey(stateKeyIsPasting) ?? false;
|
|
@@ -121,7 +131,7 @@ export function columnCustom(opts) {
|
|
|
121
131
|
const endPasteCell = pipeline.getStateAtKey(stateKeyEndPasteCell) ?? undefined;
|
|
122
132
|
const typePaste = pipeline.getStateAtKey(stateKeyTypePaste) ?? undefined;
|
|
123
133
|
const rangeState = startCell && endCell ? getSelectedCellMatrix1(allRows, leafColumns, startCell, endCell) : undefined;
|
|
124
|
-
const rangePasteState = startPasteCell && endPasteCell ? getSelectedCellMatrix1(allRows, leafColumns, startPasteCell, endPasteCell, typePaste) : undefined;
|
|
134
|
+
const rangePasteState = startPasteCell && endPasteCell && typePaste ? getSelectedCellMatrix1(allRows, leafColumns, startPasteCell, endPasteCell, typePaste) : undefined;
|
|
125
135
|
const nextColumn = focusedCell?.colId ? getNextColumn1(leafColumns, focusedCell?.colId) : undefined;
|
|
126
136
|
const {
|
|
127
137
|
rowRange,
|
|
@@ -131,6 +141,15 @@ export function columnCustom(opts) {
|
|
|
131
141
|
endColIndex,
|
|
132
142
|
endRowIndex
|
|
133
143
|
} = rangeState ?? {};
|
|
144
|
+
const {
|
|
145
|
+
rowRange: rowPasteRange,
|
|
146
|
+
colRange: colPasteRange,
|
|
147
|
+
startColIndex: startPasteColIndex,
|
|
148
|
+
startRowIndex: startPasteRowIndex,
|
|
149
|
+
endColIndex: endPasteColIndex,
|
|
150
|
+
endRowIndex: endPasteRowIndex,
|
|
151
|
+
type: pasteType
|
|
152
|
+
} = rangePasteState ?? {};
|
|
134
153
|
const rowPasteIds = getRowIdsBetween3(allRows, rowIndexMap, startPasteCell?.rowId ?? '', endPasteCell?.rowId ?? '');
|
|
135
154
|
const colPasteds = getColIdsBetween1(leafColumns, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
|
|
136
155
|
const rowSelectIds = getRowIdsBetween3(allRows, rowIndexMap, startCell?.rowId ?? '', endCell?.rowId ?? '');
|
|
@@ -306,8 +325,31 @@ export function columnCustom(opts) {
|
|
|
306
325
|
// Chức năng edit
|
|
307
326
|
|
|
308
327
|
const handleEdit = (e, record, col, editType, isKeyDown, isHeader) => {
|
|
309
|
-
pipeline.setStateAtKey(stateKeyIsEditing, true);
|
|
310
328
|
reset?.();
|
|
329
|
+
const cell = e.currentTarget;
|
|
330
|
+
pipeline.setStateAtKey(stateKeyIsEditing, {
|
|
331
|
+
editing: true,
|
|
332
|
+
element: cell,
|
|
333
|
+
rect: cell.getBoundingClientRect()
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// editor = document.createElement('div')
|
|
337
|
+
|
|
338
|
+
// editor.className = 'cell-editor'
|
|
339
|
+
|
|
340
|
+
// editor.contentEditable = 'true'
|
|
341
|
+
|
|
342
|
+
// editor.style.left = `${rect.left}px`
|
|
343
|
+
// editor.style.top = `${rect.top}px`
|
|
344
|
+
// editor.style.width = `${rect.width}px`
|
|
345
|
+
// editor.style.height = `${rect.height}px`
|
|
346
|
+
|
|
347
|
+
// editor.innerText = cell.innerText
|
|
348
|
+
|
|
349
|
+
// document.body.appendChild(editor)
|
|
350
|
+
|
|
351
|
+
// editor.focus()
|
|
352
|
+
|
|
311
353
|
if (!isObjEmpty(record)) {
|
|
312
354
|
Object.entries(record).forEach(([name, value]) => {
|
|
313
355
|
setValue?.(name, value);
|
|
@@ -351,7 +393,9 @@ export function columnCustom(opts) {
|
|
|
351
393
|
});
|
|
352
394
|
dataSelected.push(rowData);
|
|
353
395
|
});
|
|
354
|
-
|
|
396
|
+
|
|
397
|
+
// const copyRows = flattenData('children', dataSource).filter((it) => rowSelectIds.includes(it[rowKey]))
|
|
398
|
+
const copyRows = allRows.filter(it => rowSelectIds.includes(it[rowKey]));
|
|
355
399
|
let newRange;
|
|
356
400
|
if (pasteState.type === 'down') {
|
|
357
401
|
// kéo xuóng
|
|
@@ -388,7 +432,7 @@ export function columnCustom(opts) {
|
|
|
388
432
|
}
|
|
389
433
|
|
|
390
434
|
// Cập nhật data mới
|
|
391
|
-
const newData =
|
|
435
|
+
const newData = allRows;
|
|
392
436
|
const pastedRows = [];
|
|
393
437
|
if (pasteState.type === 'down' || pasteState.type === 'up') {
|
|
394
438
|
newRange.addedRows.forEach((rowValues, rowIndex1) => {
|
|
@@ -455,8 +499,8 @@ export function columnCustom(opts) {
|
|
|
455
499
|
});
|
|
456
500
|
}
|
|
457
501
|
|
|
458
|
-
// const rsFilterData = updateOrInsert(
|
|
459
|
-
const rsFilterData = updateOrInsert(
|
|
502
|
+
// const rsFilterData = updateOrInsert(dataSource, newData)
|
|
503
|
+
const rsFilterData = updateOrInsert(allRows, newData);
|
|
460
504
|
const rs = unFlattenData(rsFilterData);
|
|
461
505
|
triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
|
|
462
506
|
pipeline.setStateAtKey(stateKeyEndCell, endPasteCell);
|
|
@@ -483,7 +527,7 @@ export function columnCustom(opts) {
|
|
|
483
527
|
const newRange = ctrlKey ? addRowsDownWithCtrl(dataSelected, rowsPasteId.length) : addRowsDown(dataSelected, rowsPasteId.length);
|
|
484
528
|
|
|
485
529
|
// Cập nhật data mới
|
|
486
|
-
const newData =
|
|
530
|
+
const newData = allRows;
|
|
487
531
|
const pastedRows = [];
|
|
488
532
|
newRange.addedRows.forEach((rowValues, rowIndex1) => {
|
|
489
533
|
const targetRow = pasteState?.startRowIndex + rowIndex1;
|
|
@@ -503,6 +547,8 @@ export function columnCustom(opts) {
|
|
|
503
547
|
// Lưu dòng được paste
|
|
504
548
|
pastedRows.push(newData[targetRow]);
|
|
505
549
|
});
|
|
550
|
+
|
|
551
|
+
// const rsFilterData = updateOrInsert(dataSource, newData)
|
|
506
552
|
const rsFilterData = updateOrInsert(dataSource, newData);
|
|
507
553
|
const rs = unFlattenData(rsFilterData);
|
|
508
554
|
triggerPaste?.(pastedRows, colsPastedId, rs, copyRows);
|
|
@@ -525,7 +571,7 @@ export function columnCustom(opts) {
|
|
|
525
571
|
rowId,
|
|
526
572
|
colId
|
|
527
573
|
});
|
|
528
|
-
pipeline.setStateAtKey(stateKeyIsEditing,
|
|
574
|
+
pipeline.setStateAtKey(stateKeyIsEditing, defaultCellEditing);
|
|
529
575
|
});
|
|
530
576
|
} else {}
|
|
531
577
|
};
|
|
@@ -777,7 +823,7 @@ export function columnCustom(opts) {
|
|
|
777
823
|
// handleDeleteContent?.()
|
|
778
824
|
|
|
779
825
|
if (startCell && endCell) {
|
|
780
|
-
const tmpData =
|
|
826
|
+
const tmpData = allRows;
|
|
781
827
|
const rs = tmpData.map((row, index) => {
|
|
782
828
|
if (!rangeState?.rowRange.includes(row.rowId)) {
|
|
783
829
|
return row;
|
|
@@ -888,98 +934,6 @@ export function columnCustom(opts) {
|
|
|
888
934
|
return;
|
|
889
935
|
}
|
|
890
936
|
|
|
891
|
-
// if (e.key === 'ArrowRight') {
|
|
892
|
-
|
|
893
|
-
// // e.preventDefault();
|
|
894
|
-
// // e.stopPropagation()
|
|
895
|
-
|
|
896
|
-
// const nextCol = getNextColumn(leafColumns, column.field)
|
|
897
|
-
|
|
898
|
-
// if (nextCol.column && !nextCol.isWrapped) {
|
|
899
|
-
|
|
900
|
-
// const nextCellPosition = { rowId, colId: nextCol.column.field }
|
|
901
|
-
|
|
902
|
-
// pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
|
|
903
|
-
// pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
|
|
904
|
-
// pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
|
|
905
|
-
|
|
906
|
-
// }
|
|
907
|
-
|
|
908
|
-
// return
|
|
909
|
-
// }
|
|
910
|
-
|
|
911
|
-
// if (e.key === 'ArrowLeft') {
|
|
912
|
-
|
|
913
|
-
// // e.preventDefault()
|
|
914
|
-
// // e.stopPropagation()
|
|
915
|
-
|
|
916
|
-
// const prevCol = getPrevColumn(leafColumns, column.field)
|
|
917
|
-
|
|
918
|
-
// if (prevCol) {
|
|
919
|
-
|
|
920
|
-
// const nextCellPosition = { rowId, colId: prevCol.field }
|
|
921
|
-
// pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
|
|
922
|
-
// pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
|
|
923
|
-
// pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
|
|
924
|
-
|
|
925
|
-
// }
|
|
926
|
-
// return
|
|
927
|
-
// }
|
|
928
|
-
|
|
929
|
-
// if (e.key === 'ArrowDown') {
|
|
930
|
-
|
|
931
|
-
// // e.preventDefault()
|
|
932
|
-
// // e.stopPropagation()
|
|
933
|
-
|
|
934
|
-
// const nextRow = allRows[rowIndex + 1]
|
|
935
|
-
|
|
936
|
-
// if (nextRow) {
|
|
937
|
-
// const nextRowId = nextRow.rowId
|
|
938
|
-
|
|
939
|
-
// const nextCellPosition = { rowId: nextRowId, colId }
|
|
940
|
-
// // setFocusedCell?.({ rowId: nextRowId, colId });
|
|
941
|
-
// // setStartCell?.({ rowId: nextRowId, colId });
|
|
942
|
-
// // setEndCell?.({ rowId: nextRowId, colId });
|
|
943
|
-
|
|
944
|
-
// // setRangeState?.(getSelectedCellMatrix(table, { rowId: nextRowId, colId }, { rowId: nextRowId, colId }))
|
|
945
|
-
|
|
946
|
-
// // columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
|
|
947
|
-
// // rowVirtualizer.scrollToIndex(nextRow.index, { align: 'center' })
|
|
948
|
-
|
|
949
|
-
// pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
|
|
950
|
-
// pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
|
|
951
|
-
// pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
|
|
952
|
-
|
|
953
|
-
// // const rowElement: any = document.querySelector(`.ui-rc-grid-table-row[data-row-key="${nextRowId}"]`)
|
|
954
|
-
|
|
955
|
-
// // const cellFocus = rowElement?.querySelector('.ui-rc-grid-cell')
|
|
956
|
-
|
|
957
|
-
// }
|
|
958
|
-
|
|
959
|
-
// return
|
|
960
|
-
// }
|
|
961
|
-
|
|
962
|
-
// if (e.key === 'ArrowUp') {
|
|
963
|
-
|
|
964
|
-
// // e.preventDefault()
|
|
965
|
-
// // e.stopPropagation()
|
|
966
|
-
|
|
967
|
-
// const nextRow = allRows[rowIndex - 1]
|
|
968
|
-
|
|
969
|
-
// if (nextRow) {
|
|
970
|
-
// const nextRowId = nextRow.rowId
|
|
971
|
-
|
|
972
|
-
// const nextCellPosition = { rowId: nextRowId, colId }
|
|
973
|
-
|
|
974
|
-
// pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
|
|
975
|
-
// pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
|
|
976
|
-
// pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
|
|
977
|
-
|
|
978
|
-
// }
|
|
979
|
-
|
|
980
|
-
// return
|
|
981
|
-
// }
|
|
982
|
-
|
|
983
937
|
// if (e.key === 'Delete') {
|
|
984
938
|
// handleDeleteContent?.()
|
|
985
939
|
// return
|
|
@@ -997,7 +951,7 @@ export function columnCustom(opts) {
|
|
|
997
951
|
handleEdit(e, record, column, editType, true, true);
|
|
998
952
|
}
|
|
999
953
|
};
|
|
1000
|
-
const handleChange = (record, column, indexCol) => {
|
|
954
|
+
const handleChange = (record, column, indexCol, type) => {
|
|
1001
955
|
const currentRowIndex = allRows.findIndex(r => r.rowId === record.rowId);
|
|
1002
956
|
const formState = getValues();
|
|
1003
957
|
const itemState = getValues(column.field);
|
|
@@ -1013,10 +967,54 @@ export function columnCustom(opts) {
|
|
|
1013
967
|
option: newState,
|
|
1014
968
|
indexCol: indexCol,
|
|
1015
969
|
indexRow: currentRowIndex,
|
|
1016
|
-
type: 'blur'
|
|
970
|
+
type: type ?? 'blur'
|
|
1017
971
|
});
|
|
1018
972
|
} else {}
|
|
1019
973
|
};
|
|
974
|
+
const handleChangeAndCreateRow = (record, column, indexCol) => {
|
|
975
|
+
const currentRowIndex = allRows.findIndex(r => r.rowId === record.rowId);
|
|
976
|
+
const formState = getValues();
|
|
977
|
+
const itemState = getValues(column.field);
|
|
978
|
+
const prevState = record[column.field];
|
|
979
|
+
const newState = itemState;
|
|
980
|
+
if (newState !== prevState) {
|
|
981
|
+
// vừa cell change + add new row
|
|
982
|
+
handleCellChangeAndAddRow?.({
|
|
983
|
+
key: record.rowId,
|
|
984
|
+
field: column.field,
|
|
985
|
+
record: formState,
|
|
986
|
+
prevState,
|
|
987
|
+
newState,
|
|
988
|
+
option: newState,
|
|
989
|
+
indexCol: indexCol,
|
|
990
|
+
indexRow: currentRowIndex,
|
|
991
|
+
type: 'blur'
|
|
992
|
+
});
|
|
993
|
+
} else {
|
|
994
|
+
// chỉ add new row
|
|
995
|
+
|
|
996
|
+
const newRowId = newGuid();
|
|
997
|
+
handleAddMulti?.({}, 1, newRowId);
|
|
998
|
+
const nextCellPosition = {
|
|
999
|
+
rowId: newRowId,
|
|
1000
|
+
colId: column.field
|
|
1001
|
+
};
|
|
1002
|
+
pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition);
|
|
1003
|
+
pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition);
|
|
1004
|
+
pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition);
|
|
1005
|
+
setTimeout(() => {
|
|
1006
|
+
const row = document.querySelector(`.ui-rc-grid-table-row[data-row-key="${newRowId}"]`);
|
|
1007
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
1008
|
+
if (cellFocus) {
|
|
1009
|
+
cellFocus.scrollIntoView({
|
|
1010
|
+
behavior: "smooth",
|
|
1011
|
+
block: "start"
|
|
1012
|
+
});
|
|
1013
|
+
cellFocus.focus();
|
|
1014
|
+
}
|
|
1015
|
+
}, 100);
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1020
1018
|
const handleHeaderChange = (record, column, indexCol) => {
|
|
1021
1019
|
const currentRowIndex = allRows.findIndex(r => r.rowId === record.rowId);
|
|
1022
1020
|
const formState = getValues();
|
|
@@ -1282,7 +1280,7 @@ export function columnCustom(opts) {
|
|
|
1282
1280
|
[col.field]: headerData?.[col.field] ?? ''
|
|
1283
1281
|
};
|
|
1284
1282
|
const headerValue = headerData?.[col.field] ?? '';
|
|
1285
|
-
const cellHeaderEditing = isEditing && headerRowId === focusedCell.rowId && col.field === focusedCell.colId;
|
|
1283
|
+
const cellHeaderEditing = isEditing.editing && headerRowId === focusedCell.rowId && col.field === focusedCell.colId;
|
|
1286
1284
|
const isCellSelect = headerRowId === focusedCell.rowId && startCell?.colId === col.field;
|
|
1287
1285
|
const aa = getColumnsAtLevel(originCols, headerRowIndex);
|
|
1288
1286
|
const aaEditAble = aa ? aa.filter(it => it.headerEditEnable) : undefined;
|
|
@@ -1387,7 +1385,7 @@ export function columnCustom(opts) {
|
|
|
1387
1385
|
// @ts-ignore
|
|
1388
1386
|
'data-col-key': col.field,
|
|
1389
1387
|
ref: el => {
|
|
1390
|
-
if (focusedCell?.rowId === headerRowId && focusedCell?.colId === col.field && !isEditing) {
|
|
1388
|
+
if (focusedCell?.rowId === headerRowId && focusedCell?.colId === col.field && !isEditing.editing) {
|
|
1391
1389
|
el?.focus({
|
|
1392
1390
|
preventScroll: true
|
|
1393
1391
|
});
|
|
@@ -1432,7 +1430,7 @@ export function columnCustom(opts) {
|
|
|
1432
1430
|
// chưa editing
|
|
1433
1431
|
|
|
1434
1432
|
if (headerEditAble) {
|
|
1435
|
-
if (!isEditing) {
|
|
1433
|
+
if (!isEditing.editing) {
|
|
1436
1434
|
handleHeaderKeyDown(e, headerRowId, col.field, headerRowIndex, col, headerRecord, headerEditType ?? 'text');
|
|
1437
1435
|
} else {
|
|
1438
1436
|
if (e.shiftKey && e.key === 'Enter') {
|
|
@@ -1454,7 +1452,7 @@ export function columnCustom(opts) {
|
|
|
1454
1452
|
// pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
|
|
1455
1453
|
|
|
1456
1454
|
handleHeaderChange(headerRecord, col, startIndex);
|
|
1457
|
-
pipeline.setStateAtKey(stateKeyIsEditing,
|
|
1455
|
+
pipeline.setStateAtKey(stateKeyIsEditing, defaultCellEditing);
|
|
1458
1456
|
|
|
1459
1457
|
// }
|
|
1460
1458
|
}
|
|
@@ -1497,7 +1495,7 @@ export function columnCustom(opts) {
|
|
|
1497
1495
|
// }
|
|
1498
1496
|
}
|
|
1499
1497
|
handleHeaderChange(headerRecord, col, startIndex);
|
|
1500
|
-
pipeline.setStateAtKey(stateKeyIsEditing,
|
|
1498
|
+
pipeline.setStateAtKey(stateKeyIsEditing, defaultCellEditing);
|
|
1501
1499
|
}
|
|
1502
1500
|
}
|
|
1503
1501
|
}
|
|
@@ -1517,21 +1515,23 @@ export function columnCustom(opts) {
|
|
|
1517
1515
|
const canEdit = isEditable(col, record) && isRowEditable !== false;
|
|
1518
1516
|
const editType = typeof col.editType === 'function' ? col.editType(record) : col.editType;
|
|
1519
1517
|
const isInRange = colRange && rowRange && rowRange.includes(record.rowId) && colRange.includes(col.field);
|
|
1520
|
-
const isInRangePaste =
|
|
1518
|
+
const isInRangePaste = colPasteRange && rowPasteRange && rowPasteRange?.includes(record.rowId) && colPasteRange.includes(col.field);
|
|
1521
1519
|
const rowIdx = rowIds ? rowIds.indexOf(record.rowId) : -1;
|
|
1522
1520
|
const colIdx = colIds ? colIds.indexOf(col.field) : -1;
|
|
1523
|
-
const rowIdxPaste = rowIds?.indexOf(record.rowId);
|
|
1524
|
-
const colIdxPaste = colIds?.indexOf(col.field);
|
|
1521
|
+
const rowIdxPaste = rowIds ? rowIds?.indexOf(record.rowId) : -1;
|
|
1522
|
+
const colIdxPaste = colIds ? colIds?.indexOf(col.field) : -1;
|
|
1523
|
+
// const colIdsPaste = rangePasteState?.colRange?.includes(col.field)
|
|
1524
|
+
|
|
1525
1525
|
const isCellSelected = !startCell || !endCell ? false : selectRowIds.includes(record.rowId) && cols.includes(col.field);
|
|
1526
1526
|
const isTop = rowIdx === startRowIndex;
|
|
1527
1527
|
const isBottom = rowIdx === endRowIndex;
|
|
1528
1528
|
const isLeft = colIdx === startColIndex;
|
|
1529
1529
|
const isRight = colIdx === endColIndex;
|
|
1530
|
-
const isTopPaste = rowIdxPaste ===
|
|
1531
|
-
const isBottomPaste = rowIdxPaste ===
|
|
1532
|
-
const isLeftPaste = colIdxPaste ===
|
|
1533
|
-
const isRightPaste = colIdxPaste ===
|
|
1534
|
-
const cellEditing = isEditing && record.rowId === focusedCell.rowId && col.field === focusedCell.colId;
|
|
1530
|
+
const isTopPaste = rowIdxPaste === startPasteRowIndex;
|
|
1531
|
+
const isBottomPaste = rowIdxPaste === endPasteRowIndex;
|
|
1532
|
+
const isLeftPaste = colIdxPaste === startPasteColIndex;
|
|
1533
|
+
const isRightPaste = colIdxPaste === endPasteColIndex;
|
|
1534
|
+
const cellEditing = isEditing.editing && record.rowId === focusedCell.rowId && col.field === focusedCell.colId;
|
|
1535
1535
|
|
|
1536
1536
|
// content display
|
|
1537
1537
|
|
|
@@ -1557,7 +1557,7 @@ export function columnCustom(opts) {
|
|
|
1557
1557
|
'data-tooltip-id': `${id}-tooltip-content`,
|
|
1558
1558
|
'data-tooltip-content': message ?? tooltipContent,
|
|
1559
1559
|
ref: el => {
|
|
1560
|
-
if (focusedCell?.rowId === record.rowId && focusedCell?.colId === col.field && !isEditing) {
|
|
1560
|
+
if (focusedCell?.rowId === record.rowId && focusedCell?.colId === col.field && !isEditing.editing) {
|
|
1561
1561
|
el?.focus({
|
|
1562
1562
|
preventScroll: true
|
|
1563
1563
|
});
|
|
@@ -1580,14 +1580,14 @@ export function columnCustom(opts) {
|
|
|
1580
1580
|
disable: !canEdit,
|
|
1581
1581
|
// isValid: !isEditing && rowError && rowError[col.field]?.field === col.field,
|
|
1582
1582
|
[`${prefix}-grid-cell-selected`]: isCellSelected,
|
|
1583
|
-
'cell-border-bottom': !isEditing && isInRange && isBottom,
|
|
1584
|
-
'cell-border-right': !isEditing && isInRange && isRight,
|
|
1585
|
-
'cell-border-top': !isEditing && isInRange && isTop,
|
|
1586
|
-
'cell-border-left': !isEditing && isInRange && isLeft,
|
|
1587
|
-
'cell-paste-border-bottom': isInRangePaste && isBottomPaste && (
|
|
1588
|
-
'cell-paste-border-right': isInRangePaste && isRightPaste,
|
|
1589
|
-
'cell-paste-border-top': isInRangePaste && isTopPaste && (
|
|
1590
|
-
'cell-paste-border-left': isInRangePaste && isLeftPaste
|
|
1583
|
+
'cell-border-bottom': !isEditing.editing && isInRange && isBottom,
|
|
1584
|
+
'cell-border-right': !isEditing.editing && isInRange && isRight,
|
|
1585
|
+
'cell-border-top': !isEditing.editing && isInRange && isTop,
|
|
1586
|
+
'cell-border-left': !isEditing.editing && isInRange && isLeft,
|
|
1587
|
+
'cell-paste-border-bottom': isInRangePaste && isBottomPaste && (pasteType === 'down' || pasteType === 'right' || pasteType === 'left'),
|
|
1588
|
+
'cell-paste-border-right': isInRangePaste && isRightPaste && (pasteType === 'down' || pasteType === 'right' || pasteType === 'up'),
|
|
1589
|
+
'cell-paste-border-top': isInRangePaste && isTopPaste && (pasteType === 'up' || pasteType === 'left' || pasteType === 'right'),
|
|
1590
|
+
'cell-paste-border-left': isInRangePaste && isLeftPaste && (pasteType === 'down' || pasteType === 'left' || pasteType === 'up')
|
|
1591
1591
|
}),
|
|
1592
1592
|
onMouseDown: e => {
|
|
1593
1593
|
prevCellProps?.onMouseDown?.(e);
|
|
@@ -1684,7 +1684,7 @@ export function columnCustom(opts) {
|
|
|
1684
1684
|
prevCellProps?.onKeyDown?.(e);
|
|
1685
1685
|
|
|
1686
1686
|
// chưa editing
|
|
1687
|
-
if (!isEditing) {
|
|
1687
|
+
if (!isEditing.editing) {
|
|
1688
1688
|
handleKeyDown(e, record.rowId, col.field, rowIndex, col, record, editType ?? 'text');
|
|
1689
1689
|
} else {
|
|
1690
1690
|
if (e.shiftKey && e.key === 'Enter') {
|
|
@@ -1704,14 +1704,15 @@ export function columnCustom(opts) {
|
|
|
1704
1704
|
pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition);
|
|
1705
1705
|
pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition);
|
|
1706
1706
|
pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition);
|
|
1707
|
-
|
|
1708
|
-
// rowVirtualizer.scrollToIndex(nextRow.index, { align: 'center' })
|
|
1709
|
-
|
|
1710
1707
|
handleChange(record, col, startIndex);
|
|
1711
|
-
pipeline.setStateAtKey(stateKeyIsEditing,
|
|
1708
|
+
pipeline.setStateAtKey(stateKeyIsEditing, defaultCellEditing);
|
|
1712
1709
|
} else {
|
|
1713
|
-
|
|
1714
|
-
|
|
1710
|
+
if (isAddAble) {
|
|
1711
|
+
handleChangeAndCreateRow(record, col, startIndex);
|
|
1712
|
+
} else {
|
|
1713
|
+
handleChange(record, col, startIndex, 'blur');
|
|
1714
|
+
pipeline.setStateAtKey(stateKeyIsEditing, defaultCellEditing);
|
|
1715
|
+
}
|
|
1715
1716
|
}
|
|
1716
1717
|
}
|
|
1717
1718
|
if (e.key === 'Tab') {
|
|
@@ -1748,7 +1749,7 @@ export function columnCustom(opts) {
|
|
|
1748
1749
|
}
|
|
1749
1750
|
}
|
|
1750
1751
|
handleChange(record, col, startIndex);
|
|
1751
|
-
pipeline.setStateAtKey(stateKeyIsEditing,
|
|
1752
|
+
pipeline.setStateAtKey(stateKeyIsEditing, defaultCellEditing);
|
|
1752
1753
|
}
|
|
1753
1754
|
}
|
|
1754
1755
|
}
|
|
@@ -1768,11 +1769,9 @@ export function columnCustom(opts) {
|
|
|
1768
1769
|
format: format,
|
|
1769
1770
|
errors: errors,
|
|
1770
1771
|
handleCellChange: handleCellChange,
|
|
1771
|
-
handleNextCell: () => {},
|
|
1772
1772
|
getValues: getValues,
|
|
1773
1773
|
rowKey: 'rowId',
|
|
1774
1774
|
control: control,
|
|
1775
|
-
startCell: startCell,
|
|
1776
1775
|
handleSubmit: handleSubmit,
|
|
1777
1776
|
onSubmit: onSubmit
|
|
1778
1777
|
}) : editAble ? /*#__PURE__*/React.createElement(React.Fragment, null, cellContent, !isSelecting && !cellEditing && rowRange &&
|
|
@@ -1793,7 +1792,7 @@ export function columnCustom(opts) {
|
|
|
1793
1792
|
}
|
|
1794
1793
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1795
1794
|
className: 'dot-point'
|
|
1796
|
-
})), !isEditing && rowError && rowError[col.field]?.field === col.field && /*#__PURE__*/React.createElement("span", {
|
|
1795
|
+
})), !isEditing.editing && rowError && rowError[col.field]?.field === col.field && /*#__PURE__*/React.createElement("span", {
|
|
1797
1796
|
className: "isValid"
|
|
1798
1797
|
})) : undefined
|
|
1799
1798
|
});
|
|
@@ -224,7 +224,12 @@ export function treeSelect(opts) {
|
|
|
224
224
|
// const isChecked = isRowChecked(rowKey, value, treeIndex, checkedStrategy, isDisabled)
|
|
225
225
|
const isChecked = treeDataHelper.isChecked(rowKey);
|
|
226
226
|
if (clickArea !== 'cell') {
|
|
227
|
-
return {
|
|
227
|
+
return {
|
|
228
|
+
style: {
|
|
229
|
+
// cursor: 'not-allowed',
|
|
230
|
+
padding: 0
|
|
231
|
+
}
|
|
232
|
+
};
|
|
228
233
|
}
|
|
229
234
|
|
|
230
235
|
// const disabled = isNodeOrAncestorDisabled(rowKey, treeIndex, isDisabled)
|
|
@@ -232,13 +237,15 @@ export function treeSelect(opts) {
|
|
|
232
237
|
if (disabled) {
|
|
233
238
|
return {
|
|
234
239
|
style: {
|
|
235
|
-
cursor: 'not-allowed'
|
|
240
|
+
cursor: 'not-allowed',
|
|
241
|
+
padding: 0
|
|
236
242
|
}
|
|
237
243
|
};
|
|
238
244
|
}
|
|
239
245
|
return mergeCellProps(prevCellProps, {
|
|
240
246
|
style: {
|
|
241
|
-
cursor: 'pointer'
|
|
247
|
+
cursor: 'pointer',
|
|
248
|
+
padding: 0
|
|
242
249
|
},
|
|
243
250
|
onClick(e) {
|
|
244
251
|
if (opts.stopClickEventPropagation) {
|
|
@@ -537,9 +537,6 @@ export type TableProps<RecordType = AnyObject> = {
|
|
|
537
537
|
*/
|
|
538
538
|
validate?: any;
|
|
539
539
|
onBlur?: (data: RecordType[]) => void;
|
|
540
|
-
toolbarItemTopRight?: ToolbarItem[];
|
|
541
|
-
toolbarItemsTop?: ToolbarItem[];
|
|
542
|
-
toolbarItemsBottom?: ToolbarItem[];
|
|
543
540
|
};
|
|
544
541
|
export type ExpandableConfig<RecordType> = {
|
|
545
542
|
expandedRowKeys?: readonly Key[];
|
|
@@ -196,10 +196,10 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
|
|
|
196
196
|
value: any;
|
|
197
197
|
rowData: RecordType;
|
|
198
198
|
}) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
199
|
-
onCellStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "
|
|
200
|
-
onCellHeaderStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "
|
|
199
|
+
onCellStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "display" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "display" | "position">);
|
|
200
|
+
onCellHeaderStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "display" | "position"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "display" | "position">);
|
|
201
201
|
onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
|
|
202
|
-
onCellFooterStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "
|
|
202
|
+
onCellFooterStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "display" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "display" | "position">);
|
|
203
203
|
getValue?: (row: any, rowIndex: number) => any;
|
|
204
204
|
getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
|
|
205
205
|
headerCellProps?: import("./../../grid-component/type").CellProps;
|
|
@@ -254,6 +254,12 @@ const TableContainerEdit = props => {
|
|
|
254
254
|
|
|
255
255
|
// const [isAddNewRow, setIsAddNewRow] = React.useState(false)
|
|
256
256
|
|
|
257
|
+
const isAddAble = React.useMemo(() => {
|
|
258
|
+
if (!toolbarItems) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
return toolbarItems.find(it => it.key === 'ADD') ? true : false;
|
|
262
|
+
}, [toolbarItems]);
|
|
257
263
|
const rowsFocus = React.useMemo(() => {
|
|
258
264
|
return startCell && endCell ? getRowIdsBetween(table, startCell.rowId, endCell.rowId) : [];
|
|
259
265
|
}, [endCell, startCell, table]);
|
|
@@ -1038,12 +1044,6 @@ const TableContainerEdit = props => {
|
|
|
1038
1044
|
}
|
|
1039
1045
|
}
|
|
1040
1046
|
}
|
|
1041
|
-
|
|
1042
|
-
// if (prevState && newState && prevState !== newState && changeType === 'enter') {
|
|
1043
|
-
|
|
1044
|
-
// onSubmit(record)
|
|
1045
|
-
|
|
1046
|
-
// }
|
|
1047
1047
|
};
|
|
1048
1048
|
const handleDuplicate = React.useCallback(() => {
|
|
1049
1049
|
// không tính tree
|
|
@@ -2254,7 +2254,8 @@ const TableContainerEdit = props => {
|
|
|
2254
2254
|
rowEditable,
|
|
2255
2255
|
onRowStyles,
|
|
2256
2256
|
dataSourceFilter,
|
|
2257
|
-
setIsExpandClick
|
|
2257
|
+
setIsExpandClick,
|
|
2258
|
+
isAddAble
|
|
2258
2259
|
}
|
|
2259
2260
|
}, /*#__PURE__*/React.createElement(TableWrapper, _extends({}, rest, {
|
|
2260
2261
|
contextMenuItems: contextMenuItems,
|
|
@@ -233,7 +233,8 @@ const TableBodyCellEdit = props => {
|
|
|
233
233
|
pagination,
|
|
234
234
|
handleAddMulti,
|
|
235
235
|
setIsExpandClick,
|
|
236
|
-
format
|
|
236
|
+
format,
|
|
237
|
+
isAddAble
|
|
237
238
|
} = React.useContext(TableContext);
|
|
238
239
|
const expandIconColumnIndex = expandable?.expandIconColumnIndex;
|
|
239
240
|
const visibleColumns = table.getVisibleLeafColumns();
|
|
@@ -1391,7 +1392,9 @@ const TableBodyCellEdit = props => {
|
|
|
1391
1392
|
});
|
|
1392
1393
|
handleChange();
|
|
1393
1394
|
} else {
|
|
1394
|
-
|
|
1395
|
+
if (isAddAble) {
|
|
1396
|
+
handleChangeAndCreateRow();
|
|
1397
|
+
}
|
|
1395
1398
|
}
|
|
1396
1399
|
setEditingKey?.('');
|
|
1397
1400
|
reset?.();
|
|
@@ -265,7 +265,7 @@ export const toggleRowSelection = props => {
|
|
|
265
265
|
} else {
|
|
266
266
|
// chưa selected
|
|
267
267
|
|
|
268
|
-
const checkedRows = [...prevSelected, row];
|
|
268
|
+
const checkedRows = [...prevSelected, row.original];
|
|
269
269
|
setIsSelectionChange({
|
|
270
270
|
isChange: true,
|
|
271
271
|
type: 'rowSelected',
|