es-grid-template 1.9.63 → 1.9.65
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/Grid.js +5 -2
- package/es/ali-table/InternalTable.js +499 -49
- package/es/ali-table/base-table/calculations.js +1 -1
- package/es/ali-table/base-table/cell/EditCell.js +14 -6
- package/es/ali-table/base-table/renderFilter.js +1 -1
- package/es/ali-table/interfaces.d.ts +2 -2
- package/es/ali-table/pipeline/features/columnCustom.d.ts +4 -2
- package/es/ali-table/pipeline/features/columnCustom.js +112 -48
- package/es/ali-table/utils/constants.d.ts +1 -0
- package/es/ali-table/utils/constants.js +1 -0
- package/es/ali-table/utils/convertColumnsChoose.d.ts +2 -2
- package/es/ali-table/utils/convertColumnsChoose.js +1 -2
- package/es/ali-table/utils/utility.d.ts +15 -1
- package/es/ali-table/utils/utility.js +399 -1
- package/es/grid-component/type.d.ts +2 -2
- package/es/group-component/hook/utils.d.ts +3 -3
- package/es/table-component/InternalTable.js +11 -3
- package/es/table-component/TableContainerEdit.js +148 -98
- package/es/table-component/body/EditableCell.js +9 -5
- package/es/table-component/body/TableBodyCellEdit.js +14 -8
- package/es/table-component/header/TableHeadCell2.js +2 -2
- package/es/table-component/hook/useColumns.js +1 -1
- package/es/table-component/hook/utils.d.ts +1 -1
- package/es/table-component/hook/utils.js +2 -6
- package/es/table-component/table/Grid.js +23 -17
- package/es/table-component/useContext.d.ts +1 -1
- package/lib/ali-table/Grid.js +5 -2
- package/lib/ali-table/InternalTable.js +490 -45
- package/lib/ali-table/base-table/calculations.js +1 -1
- package/lib/ali-table/base-table/cell/EditCell.js +14 -6
- package/lib/ali-table/base-table/renderFilter.js +1 -1
- package/lib/ali-table/interfaces.d.ts +2 -2
- package/lib/ali-table/pipeline/features/columnCustom.d.ts +4 -2
- package/lib/ali-table/pipeline/features/columnCustom.js +106 -46
- package/lib/ali-table/utils/constants.d.ts +1 -0
- package/lib/ali-table/utils/constants.js +2 -1
- package/lib/ali-table/utils/convertColumnsChoose.d.ts +2 -2
- package/lib/ali-table/utils/convertColumnsChoose.js +1 -2
- package/lib/ali-table/utils/utility.d.ts +15 -1
- package/lib/ali-table/utils/utility.js +410 -2
- package/lib/grid-component/type.d.ts +2 -2
- package/lib/table-component/InternalTable.js +11 -3
- package/lib/table-component/TableContainerEdit.js +148 -98
- package/lib/table-component/body/EditableCell.js +9 -5
- package/lib/table-component/body/TableBodyCellEdit.js +11 -7
- package/lib/table-component/header/TableHeadCell2.js +2 -2
- package/lib/table-component/hook/useColumns.js +1 -1
- package/lib/table-component/hook/utils.d.ts +1 -1
- package/lib/table-component/hook/utils.js +2 -6
- package/lib/table-component/table/Grid.js +22 -16
- package/lib/table-component/useContext.d.ts +1 -1
- package/package.json +1 -1
|
@@ -297,6 +297,20 @@ const TableContainerEdit = props => {
|
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
299
|
}, [onCellPaste, originData, triggerChangeData]);
|
|
300
|
+
const {
|
|
301
|
+
control,
|
|
302
|
+
handleSubmit,
|
|
303
|
+
setValue,
|
|
304
|
+
// trigger,
|
|
305
|
+
getValues,
|
|
306
|
+
reset,
|
|
307
|
+
formState: {
|
|
308
|
+
errors
|
|
309
|
+
}
|
|
310
|
+
} = useForm({
|
|
311
|
+
mode: 'onChange',
|
|
312
|
+
resolver: validate ? yupResolver(validate) : undefined
|
|
313
|
+
});
|
|
300
314
|
|
|
301
315
|
// Copy
|
|
302
316
|
|
|
@@ -333,16 +347,144 @@ const TableContainerEdit = props => {
|
|
|
333
347
|
|
|
334
348
|
copy(tsv).then(() => {}).catch(() => {});
|
|
335
349
|
}, [startCell, endCell, table]);
|
|
350
|
+
const onSubmit = formData => {
|
|
351
|
+
try {
|
|
352
|
+
// const record = (await form.validateFields()) as RecordType;
|
|
353
|
+
const row = {
|
|
354
|
+
...formData
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
// const newData = [...dataSource]
|
|
358
|
+
const newData = [...originData];
|
|
359
|
+
|
|
360
|
+
// @ts-ignore
|
|
361
|
+
const index = flattenData(childrenColumnName, newData).findIndex(item => formData[rowKey] === item[rowKey]);
|
|
362
|
+
const rs = updateArrayByKey(newData, row, rowKey);
|
|
363
|
+
if (index > -1) {
|
|
364
|
+
triggerChangeData?.(rs, {
|
|
365
|
+
type: 'CellChange'
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
} catch (errInfo) {
|
|
369
|
+
console.log('Validate Failed:', errInfo);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
const handleCellChange = args => {
|
|
373
|
+
const {
|
|
374
|
+
record,
|
|
375
|
+
type: changeType,
|
|
376
|
+
newState,
|
|
377
|
+
prevState,
|
|
378
|
+
option,
|
|
379
|
+
field,
|
|
380
|
+
indexCol,
|
|
381
|
+
indexRow,
|
|
382
|
+
key
|
|
383
|
+
} = args;
|
|
384
|
+
if (changeType === 'blur') {
|
|
385
|
+
const handleChangeCallback = callbackData => {
|
|
386
|
+
const callbackRecord = callbackData;
|
|
387
|
+
Object.entries(callbackRecord).forEach(([name, value]) => {
|
|
388
|
+
setValue(name, value);
|
|
389
|
+
});
|
|
390
|
+
onSubmit(callbackRecord);
|
|
391
|
+
};
|
|
392
|
+
if (onCellChange) {
|
|
393
|
+
if (onCellChange.length > 1) {
|
|
394
|
+
onCellChange({
|
|
395
|
+
field,
|
|
396
|
+
indexCol,
|
|
397
|
+
type: 'onChange',
|
|
398
|
+
value: newState,
|
|
399
|
+
option,
|
|
400
|
+
indexRow,
|
|
401
|
+
rowData: record,
|
|
402
|
+
rowId: key,
|
|
403
|
+
// rowsData: [...dataSource],
|
|
404
|
+
rowsData: [...originData],
|
|
405
|
+
sumValue: []
|
|
406
|
+
}, handleChangeCallback);
|
|
407
|
+
} else {
|
|
408
|
+
onCellChange({
|
|
409
|
+
field,
|
|
410
|
+
indexCol,
|
|
411
|
+
type: 'onChange',
|
|
412
|
+
option,
|
|
413
|
+
value: newState,
|
|
414
|
+
indexRow,
|
|
415
|
+
rowData: record,
|
|
416
|
+
rowId: key,
|
|
417
|
+
// rowsData: [...dataSource],
|
|
418
|
+
rowsData: [...originData],
|
|
419
|
+
sumValue: []
|
|
420
|
+
}, handleChangeCallback);
|
|
421
|
+
onSubmit(record);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
if (prevState && newState && prevState !== newState && changeType === 'enter') {
|
|
426
|
+
onSubmit(record);
|
|
427
|
+
}
|
|
428
|
+
};
|
|
336
429
|
React.useEffect(() => {
|
|
337
430
|
const handleKeyDown = e => {
|
|
338
431
|
if (e.ctrlKey && e.key === 'c' && startCell && endCell && !editingKey) {
|
|
339
432
|
e.preventDefault();
|
|
340
433
|
copySelectionToClipboard();
|
|
341
434
|
}
|
|
435
|
+
if (e.ctrlKey && e.key === 'x' && startCell && endCell && !editingKey) {
|
|
436
|
+
e.preventDefault();
|
|
437
|
+
if (startCell && endCell) {
|
|
438
|
+
const tmpData = flattenArray(originData);
|
|
439
|
+
const rs = tmpData.map((row, index) => {
|
|
440
|
+
if (!rangeState?.rowRange.includes(row.rowId)) {
|
|
441
|
+
return row;
|
|
442
|
+
}
|
|
443
|
+
const updatedRow = {
|
|
444
|
+
...row
|
|
445
|
+
};
|
|
446
|
+
for (const colId of rangeState.colRange) {
|
|
447
|
+
const column = table.getVisibleFlatColumns().find(it => it.id === colId)?.columnDef.meta;
|
|
448
|
+
const columnIndex = table.getVisibleFlatColumns().findIndex(it => it.id === colId);
|
|
449
|
+
if (isEditable(column, row)) {
|
|
450
|
+
let newValue = '';
|
|
451
|
+
if (column.type === 'number') {
|
|
452
|
+
newValue = 0;
|
|
453
|
+
}
|
|
454
|
+
if (column.type === 'boolean' || column.type === 'checkbox') {
|
|
455
|
+
newValue = false;
|
|
456
|
+
}
|
|
457
|
+
const cellEditType = getEditType(column, row);
|
|
458
|
+
if (column.type === 'date' || column.type === 'datetime' || column.type === 'time' || column.type === 'month' || column.type === 'week' || column.type === 'year' || column.type === 'quarter' || cellEditType === 'asyncSelect' || cellEditType === 'select' || cellEditType === 'treeSelect' || cellEditType === 'selectTable') {
|
|
459
|
+
newValue = undefined;
|
|
460
|
+
}
|
|
461
|
+
updatedRow[colId] = newValue;
|
|
462
|
+
handleCellChange({
|
|
463
|
+
key: row[rowKey],
|
|
464
|
+
field: column.field ?? column.dataIndex,
|
|
465
|
+
record: updatedRow,
|
|
466
|
+
prevState: row[column.field],
|
|
467
|
+
newState: newValue,
|
|
468
|
+
option: '',
|
|
469
|
+
indexCol: columnIndex,
|
|
470
|
+
indexRow: index,
|
|
471
|
+
type: 'blur'
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return updatedRow;
|
|
476
|
+
});
|
|
477
|
+
const newData = unFlattenData(rs);
|
|
478
|
+
triggerChangeData?.(newData, {
|
|
479
|
+
type: 'DELETE_CONTENT'
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
copySelectionToClipboard();
|
|
483
|
+
}
|
|
342
484
|
};
|
|
343
485
|
document.addEventListener('keydown', handleKeyDown);
|
|
344
486
|
return () => document.removeEventListener('keydown', handleKeyDown);
|
|
345
|
-
}, [startCell, endCell, table, copySelectionToClipboard, editingKey]);
|
|
487
|
+
}, [startCell, endCell, table, copySelectionToClipboard, editingKey, rangeState]);
|
|
346
488
|
|
|
347
489
|
// Paste
|
|
348
490
|
|
|
@@ -752,20 +894,6 @@ const TableContainerEdit = props => {
|
|
|
752
894
|
observer.disconnect();
|
|
753
895
|
};
|
|
754
896
|
}, []);
|
|
755
|
-
const {
|
|
756
|
-
control,
|
|
757
|
-
handleSubmit,
|
|
758
|
-
setValue,
|
|
759
|
-
// trigger,
|
|
760
|
-
getValues,
|
|
761
|
-
reset,
|
|
762
|
-
formState: {
|
|
763
|
-
errors
|
|
764
|
-
}
|
|
765
|
-
} = useForm({
|
|
766
|
-
mode: 'onChange',
|
|
767
|
-
resolver: validate ? yupResolver(validate) : undefined
|
|
768
|
-
});
|
|
769
897
|
const handleAddMulti = React.useCallback((item, n, newId) => {
|
|
770
898
|
if (item.onClick) {
|
|
771
899
|
item.onClick({
|
|
@@ -790,28 +918,6 @@ const TableContainerEdit = props => {
|
|
|
790
918
|
triggerChangeData?.(newData);
|
|
791
919
|
}
|
|
792
920
|
}, [dataSource, defaultValue, mergedFilterKeys, setMergedFilterKeys, triggerChangeData]);
|
|
793
|
-
const onSubmit = formData => {
|
|
794
|
-
try {
|
|
795
|
-
// const record = (await form.validateFields()) as RecordType;
|
|
796
|
-
const row = {
|
|
797
|
-
...formData
|
|
798
|
-
};
|
|
799
|
-
|
|
800
|
-
// const newData = [...dataSource]
|
|
801
|
-
const newData = [...originData];
|
|
802
|
-
|
|
803
|
-
// @ts-ignore
|
|
804
|
-
const index = flattenData(childrenColumnName, newData).findIndex(item => formData[rowKey] === item[rowKey]);
|
|
805
|
-
const rs = updateArrayByKey(newData, row, rowKey);
|
|
806
|
-
if (index > -1) {
|
|
807
|
-
triggerChangeData?.(rs, {
|
|
808
|
-
type: 'CellChange'
|
|
809
|
-
});
|
|
810
|
-
}
|
|
811
|
-
} catch (errInfo) {
|
|
812
|
-
console.log('Validate Failed:', errInfo);
|
|
813
|
-
}
|
|
814
|
-
};
|
|
815
921
|
const onSubmit2 = (formData, newOriginData) => {
|
|
816
922
|
try {
|
|
817
923
|
// const record = (await form.validateFields()) as RecordType;
|
|
@@ -834,63 +940,6 @@ const TableContainerEdit = props => {
|
|
|
834
940
|
console.log('Validate Failed:', errInfo);
|
|
835
941
|
}
|
|
836
942
|
};
|
|
837
|
-
const handleCellChange = args => {
|
|
838
|
-
const {
|
|
839
|
-
record,
|
|
840
|
-
type: changeType,
|
|
841
|
-
newState,
|
|
842
|
-
prevState,
|
|
843
|
-
option,
|
|
844
|
-
field,
|
|
845
|
-
indexCol,
|
|
846
|
-
indexRow,
|
|
847
|
-
key
|
|
848
|
-
} = args;
|
|
849
|
-
if (changeType === 'blur') {
|
|
850
|
-
const handleChangeCallback = callbackData => {
|
|
851
|
-
const callbackRecord = callbackData;
|
|
852
|
-
Object.entries(callbackRecord).forEach(([name, value]) => {
|
|
853
|
-
setValue(name, value);
|
|
854
|
-
});
|
|
855
|
-
onSubmit(callbackRecord);
|
|
856
|
-
};
|
|
857
|
-
if (onCellChange) {
|
|
858
|
-
if (onCellChange.length > 1) {
|
|
859
|
-
onCellChange({
|
|
860
|
-
field,
|
|
861
|
-
indexCol,
|
|
862
|
-
type: 'onChange',
|
|
863
|
-
value: newState,
|
|
864
|
-
option,
|
|
865
|
-
indexRow,
|
|
866
|
-
rowData: record,
|
|
867
|
-
rowId: key,
|
|
868
|
-
// rowsData: [...dataSource],
|
|
869
|
-
rowsData: [...originData],
|
|
870
|
-
sumValue: []
|
|
871
|
-
}, handleChangeCallback);
|
|
872
|
-
} else {
|
|
873
|
-
onCellChange({
|
|
874
|
-
field,
|
|
875
|
-
indexCol,
|
|
876
|
-
type: 'onChange',
|
|
877
|
-
option,
|
|
878
|
-
value: newState,
|
|
879
|
-
indexRow,
|
|
880
|
-
rowData: record,
|
|
881
|
-
rowId: key,
|
|
882
|
-
// rowsData: [...dataSource],
|
|
883
|
-
rowsData: [...originData],
|
|
884
|
-
sumValue: []
|
|
885
|
-
}, handleChangeCallback);
|
|
886
|
-
onSubmit(record);
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
if (prevState && newState && prevState !== newState && changeType === 'enter') {
|
|
891
|
-
onSubmit(record);
|
|
892
|
-
}
|
|
893
|
-
};
|
|
894
943
|
const handleCellChangeAndAddRow = args => {
|
|
895
944
|
const {
|
|
896
945
|
record,
|
|
@@ -1000,7 +1049,7 @@ const TableContainerEdit = props => {
|
|
|
1000
1049
|
// không tính tree
|
|
1001
1050
|
|
|
1002
1051
|
// Cập nhật data mới
|
|
1003
|
-
const newData = flattenArray(
|
|
1052
|
+
const newData = flattenArray(originData);
|
|
1004
1053
|
|
|
1005
1054
|
// const duplicatedItems = rowsFocus.map(index => ({ ...newData[index], rowId: newGuid(), id: undefined, isDuplicate: true }))
|
|
1006
1055
|
|
|
@@ -1025,13 +1074,14 @@ const TableContainerEdit = props => {
|
|
|
1025
1074
|
const rsFilter = [...newData.slice(0, insertAfter + 1), ...duplicatedItems, ...newData.slice(insertAfter + 1)];
|
|
1026
1075
|
|
|
1027
1076
|
// const rs = updateOrInsertInOrder(originData, rsFilter)
|
|
1028
|
-
const rs = updateOrInsert(
|
|
1077
|
+
const rs = updateOrInsert(newData, rsFilter);
|
|
1029
1078
|
// const rs2 = mergeWithFilter(originData, rsFilter)
|
|
1030
1079
|
|
|
1031
|
-
|
|
1080
|
+
const newDaa = unFlattenData(rs);
|
|
1081
|
+
triggerChangeData?.(newDaa, {
|
|
1032
1082
|
type: 'DUPLICATE'
|
|
1033
1083
|
});
|
|
1034
|
-
}, [
|
|
1084
|
+
}, [focusedCell, originData, rowKey, table, triggerChangeData]);
|
|
1035
1085
|
|
|
1036
1086
|
// thêm n dòng bên trên
|
|
1037
1087
|
const handleInsertBefore = React.useCallback((item, n) => {
|
|
@@ -469,7 +469,9 @@ const EditableCell = props => {
|
|
|
469
469
|
align: colSelect.textAlign
|
|
470
470
|
};
|
|
471
471
|
});
|
|
472
|
-
|
|
472
|
+
|
|
473
|
+
// let valueSelectTable = formValues[dataIndex]
|
|
474
|
+
let valueSelectTable = formValues[dataIndex] !== null ? formValues[dataIndex] : undefined;
|
|
473
475
|
if (fieldValue) {
|
|
474
476
|
// @ts-ignore
|
|
475
477
|
valueSelectTable = record[fieldValue] ?? formValues[dataIndex];
|
|
@@ -618,14 +620,15 @@ const EditableCell = props => {
|
|
|
618
620
|
"data-tooltip-id": `${id}-tooltip-error`
|
|
619
621
|
});
|
|
620
622
|
case 'select':
|
|
621
|
-
let valueSelect = formValues[dataIndex]
|
|
623
|
+
// let valueSelect = formValues[dataIndex]
|
|
624
|
+
let valueSelect = formValues[dataIndex] !== null ? formValues[dataIndex] : undefined;
|
|
622
625
|
if (fieldValue) {
|
|
623
626
|
// @ts-ignore
|
|
624
627
|
valueSelect = record[fieldValue] ?? formValues[dataIndex];
|
|
625
628
|
}
|
|
626
629
|
return /*#__PURE__*/React.createElement(Select, {
|
|
627
630
|
options: options,
|
|
628
|
-
value: valueSelect
|
|
631
|
+
value: valueSelect,
|
|
629
632
|
onChange: (val, option) => {
|
|
630
633
|
onChange(val ?? '');
|
|
631
634
|
const formState = getValues();
|
|
@@ -761,7 +764,8 @@ const EditableCell = props => {
|
|
|
761
764
|
"data-tooltip-id": `${id}-tooltip-error`
|
|
762
765
|
});
|
|
763
766
|
case 'asyncSelect':
|
|
764
|
-
let valueAsyncSelect = formValues[dataIndex]
|
|
767
|
+
// let valueAsyncSelect = formValues[dataIndex]
|
|
768
|
+
let valueAsyncSelect = formValues[dataIndex] !== null ? formValues[dataIndex] : undefined;
|
|
765
769
|
if (fieldValue) {
|
|
766
770
|
// @ts-ignore
|
|
767
771
|
valueAsyncSelect = record[fieldValue] ?? formValues[dataIndex];
|
|
@@ -769,7 +773,7 @@ const EditableCell = props => {
|
|
|
769
773
|
return /*#__PURE__*/React.createElement(AsyncSelect, {
|
|
770
774
|
options: options,
|
|
771
775
|
defaultOptions: options,
|
|
772
|
-
value: valueAsyncSelect
|
|
776
|
+
value: valueAsyncSelect,
|
|
773
777
|
onChange: (val, option) => {
|
|
774
778
|
onChange(val ?? '');
|
|
775
779
|
const formState = getValues();
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import Space from "rc-master-ui/es/space";
|
|
2
2
|
import Command from "../components/command/Command";
|
|
3
|
-
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getDragRightData, getEditType, getFormat,
|
|
3
|
+
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getDragRightData, getEditType, getFormat,
|
|
4
|
+
// getKeys,
|
|
5
|
+
getNextEditableColumn, getRowIdsBetween, getSelectedCellMatrix, isEditable, isObjEmpty, isObjEqual, newGuid, unFlattenData, updateOrInsert } from "../hook/utils";
|
|
4
6
|
import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
|
|
5
7
|
import classNames from "classnames";
|
|
6
8
|
import React from "react";
|
|
@@ -251,6 +253,10 @@ const TableBodyCellEdit = props => {
|
|
|
251
253
|
const isPinned = cell.column.getIsPinned();
|
|
252
254
|
const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
253
255
|
const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
256
|
+
|
|
257
|
+
// const rowIds = getKeys(allRows, 'id' as any)
|
|
258
|
+
// const colIds = table.getVisibleLeafColumns().map(c => c.id);
|
|
259
|
+
|
|
254
260
|
const selectRowIds = React.useMemo(() => {
|
|
255
261
|
return startCell && endCell ? getRowIdsBetween(table, startCell.rowId, endCell.rowId) : [];
|
|
256
262
|
}, [endCell, startCell, table]);
|
|
@@ -258,19 +264,19 @@ const TableBodyCellEdit = props => {
|
|
|
258
264
|
if (!startCell || !endCell) return false;
|
|
259
265
|
|
|
260
266
|
// const rowIds = getRowIdsBetween(table, startCell.rowId, endCell.rowId);
|
|
261
|
-
const
|
|
262
|
-
return selectRowIds.includes(cell.row.id) &&
|
|
267
|
+
const colIdss = getColIdsBetween(table, startCell.colId, endCell.colId);
|
|
268
|
+
return selectRowIds.includes(cell.row.id) && colIdss.includes(cell.column.id);
|
|
263
269
|
}, [cell.column.id, cell.row.id, endCell, selectRowIds, startCell, table]);
|
|
264
270
|
const editType = typeof columnMeta.editType === 'function' ? columnMeta.editType(record) : columnMeta.editType;
|
|
265
271
|
const {
|
|
266
272
|
rowRange,
|
|
267
273
|
colRange,
|
|
268
|
-
rowIds,
|
|
269
|
-
colIds,
|
|
270
274
|
startColIndex,
|
|
271
275
|
startRowIndex,
|
|
272
276
|
endColIndex,
|
|
273
|
-
endRowIndex
|
|
277
|
+
endRowIndex,
|
|
278
|
+
rowIds,
|
|
279
|
+
colIds
|
|
274
280
|
} = rangeState ?? {};
|
|
275
281
|
const pasteRangeState = getSelectedCellMatrix(table, startPasteCell, endPasteCell);
|
|
276
282
|
const isInRange = colRange && rowRange && rowRange.includes(cell.row.id) && colRange.includes(cell.column.id);
|
|
@@ -280,8 +286,8 @@ const TableBodyCellEdit = props => {
|
|
|
280
286
|
|
|
281
287
|
const rowIdx = rowIds ? rowIds.indexOf(cell.row.id) : -1;
|
|
282
288
|
const colIdx = colIds ? colIds.indexOf(cell.column.id) : -1;
|
|
283
|
-
const rowIdxPaste = pasteRangeState
|
|
284
|
-
const colIdxPaste = pasteRangeState
|
|
289
|
+
const rowIdxPaste = pasteRangeState?.rowIds ? pasteRangeState?.rowIds.indexOf(cell.row.id) : undefined;
|
|
290
|
+
const colIdxPaste = pasteRangeState?.colIds ? pasteRangeState?.colIds.indexOf(cell.column.id) : undefined;
|
|
285
291
|
const isTop = rowIdx === startRowIndex;
|
|
286
292
|
const isBottom = rowIdx === endRowIndex;
|
|
287
293
|
const isLeft = colIdx === startColIndex;
|
|
@@ -125,9 +125,9 @@ const TableHeadCell2 = props => {
|
|
|
125
125
|
const doFilter = type => {
|
|
126
126
|
if (type) {
|
|
127
127
|
if (fieldOriginal) {
|
|
128
|
-
fieldOriginal.setFilterValue(!originalColumn.typeFilter || originalColumn.typeFilter === 'Text' ? selectedKeys.length === 0 ? [''] : selectedKeys : selectedKeys);
|
|
128
|
+
fieldOriginal.setFilterValue(!originalColumn.typeFilter || originalColumn.typeFilter === 'Text' ? selectedKeys.length === 0 ? [''] : [selectedKeys[0].trim()] : selectedKeys);
|
|
129
129
|
} else {
|
|
130
|
-
column.setFilterValue(!originalColumn.typeFilter || originalColumn.typeFilter === 'Text' ? selectedKeys.length === 0 ? [''] : selectedKeys : selectedKeys);
|
|
130
|
+
column.setFilterValue(!originalColumn.typeFilter || originalColumn.typeFilter === 'Text' ? selectedKeys.length === 0 ? [''] : [selectedKeys[0].trim()] : selectedKeys);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// column.setFilterValue(!originalColumn.typeFilter || originalColumn.typeFilter === 'Text' ? (selectedKeys.length === 0 ? [''] : selectedKeys) : selectedKeys)
|
|
@@ -255,7 +255,7 @@ export const toggleRowSelection = props => {
|
|
|
255
255
|
// đã chọn
|
|
256
256
|
|
|
257
257
|
// xóa row ra list selected
|
|
258
|
-
const newRowsSelected = prevSelected.filter(it => it.
|
|
258
|
+
const newRowsSelected = prevSelected.filter(it => it.rowId !== row.id);
|
|
259
259
|
setIsSelectionChange({
|
|
260
260
|
isChange: true,
|
|
261
261
|
type: 'rowSelected',
|
|
@@ -42,7 +42,7 @@ export declare function getDateValueType(value: unknown): DateValueType;
|
|
|
42
42
|
export declare const convertToDate: (value?: string | Date | null, format?: string) => string;
|
|
43
43
|
export declare const getTypeFilter: (col: any) => TypeFilter;
|
|
44
44
|
export declare const addRowIdArray: (inputArray: any[]) => any[];
|
|
45
|
-
export declare function groupArrayByColumns(arr: any[], columns: string[] | undefined): any;
|
|
45
|
+
export declare function groupArrayByColumns(arr: any[], columns: string[] | undefined): any[];
|
|
46
46
|
export declare const flatColumns2: <RecordType>(columns: ColumnsTable<RecordType>) => ColumnsTable<RecordType>;
|
|
47
47
|
export declare const flatColumnsWithoutParent: (columns: any[]) => any;
|
|
48
48
|
export declare const checkThousandSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
|
|
@@ -1472,15 +1472,13 @@ export const getSelectedCellMatrix2 = (flatData, visibleLeafColumns, startCell,
|
|
|
1472
1472
|
endRowIndex,
|
|
1473
1473
|
startColIndex,
|
|
1474
1474
|
endColIndex,
|
|
1475
|
-
rowIds,
|
|
1476
|
-
colIds,
|
|
1475
|
+
// rowIds,
|
|
1476
|
+
// colIds,
|
|
1477
1477
|
type
|
|
1478
1478
|
};
|
|
1479
1479
|
};
|
|
1480
1480
|
export const getSelectedCellMatrix1 = (flatData, visibleLeafColumns, startCell, endCell, type) => {
|
|
1481
1481
|
if (!startCell || !endCell) return {
|
|
1482
|
-
rowIds: [],
|
|
1483
|
-
colIds: [],
|
|
1484
1482
|
startRowIndex: undefined,
|
|
1485
1483
|
endRowIndex: undefined,
|
|
1486
1484
|
startColIndex: undefined,
|
|
@@ -1526,8 +1524,6 @@ export const getSelectedCellMatrix1 = (flatData, visibleLeafColumns, startCell,
|
|
|
1526
1524
|
endRowIndex: normalizedEndRowIndex,
|
|
1527
1525
|
startColIndex: normalizedStartColIndex,
|
|
1528
1526
|
endColIndex: normalizedEndColIndex,
|
|
1529
|
-
rowIds,
|
|
1530
|
-
colIds,
|
|
1531
1527
|
type
|
|
1532
1528
|
};
|
|
1533
1529
|
};
|
|
@@ -14,7 +14,7 @@ import { arrayMove } from '@dnd-kit/sortable';
|
|
|
14
14
|
import React, { Fragment } from 'react';
|
|
15
15
|
import TableContainer from "../TableContainer";
|
|
16
16
|
import { OperatorFeature } from "../features/operator";
|
|
17
|
-
import { convertFilters, convertToObjTrue, filterByIds, filterDataByColumns,
|
|
17
|
+
import { convertFilters, convertToObjTrue, filterByIds, filterDataByColumns, flattenArray, getAllRowKey, revertConvertFilters } from "../hook/utils";
|
|
18
18
|
import TableContainerEdit from "../TableContainerEdit";
|
|
19
19
|
import classNames from 'classnames';
|
|
20
20
|
import { GridStyle } from "../style";
|
|
@@ -169,6 +169,25 @@ const Grid = props => {
|
|
|
169
169
|
|
|
170
170
|
// debugTable: true
|
|
171
171
|
});
|
|
172
|
+
React.useEffect(() => {
|
|
173
|
+
if (!isSelectionChange.isChange) {
|
|
174
|
+
if (mergedSelectedKeys.length === 0) {
|
|
175
|
+
setIsSelectionChange(prev => ({
|
|
176
|
+
...prev,
|
|
177
|
+
rowsData: []
|
|
178
|
+
}));
|
|
179
|
+
} else {
|
|
180
|
+
const abc = flattenArray(dataSource);
|
|
181
|
+
const selectedKeySet = new Set(mergedSelectedKeys);
|
|
182
|
+
const result = abc.filter(row => selectedKeySet.has(row.id));
|
|
183
|
+
setRowSelection(convertToObjTrue(mergedSelectedKeys));
|
|
184
|
+
setIsSelectionChange(prev => ({
|
|
185
|
+
...prev,
|
|
186
|
+
rowsData: result
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}, [mergedSelectedKeys, dataSource]);
|
|
172
191
|
React.useEffect(() => {
|
|
173
192
|
if (defaultFilter) {
|
|
174
193
|
const a = revertConvertFilters(defaultFilter);
|
|
@@ -198,20 +217,6 @@ const Grid = props => {
|
|
|
198
217
|
}
|
|
199
218
|
}
|
|
200
219
|
}, [columnHidden, columnSizingInfo]);
|
|
201
|
-
React.useEffect(() => {
|
|
202
|
-
const isEqual = isObjEqual(convertToObjTrue(mergedSelectedKeys), rowSelection);
|
|
203
|
-
if (!isEqual) {
|
|
204
|
-
setRowSelection(convertToObjTrue(mergedSelectedKeys));
|
|
205
|
-
// table.setRowSelection(convertToObjTrue(mergedSelectedKeys))
|
|
206
|
-
|
|
207
|
-
if (mergedSelectedKeys.length === 0) {
|
|
208
|
-
setIsSelectionChange(prev => ({
|
|
209
|
-
...prev,
|
|
210
|
-
rowsData: []
|
|
211
|
-
}));
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}, [mergedSelectedKeys]);
|
|
215
220
|
React.useEffect(() => {
|
|
216
221
|
if (isSelectionChange.isChange) {
|
|
217
222
|
const aa = table.getState().rowSelection;
|
|
@@ -220,11 +225,12 @@ const Grid = props => {
|
|
|
220
225
|
// const ssss = dataTable.filter(it => ids.includes(it.id)) // lấy rowsData của trang hiện tại
|
|
221
226
|
const ssss = filterByIds(ids, isSelectionChange.rowsData ?? []); // lấy rowsData của trang hiện tại
|
|
222
227
|
|
|
223
|
-
const rs = ssss.map(it => it.original)
|
|
228
|
+
// const rs = ssss.map(it => it.original)
|
|
229
|
+
|
|
224
230
|
rowSelected?.({
|
|
225
231
|
type: isSelectionChange.type,
|
|
226
232
|
rowData: isSelectionChange.rowData,
|
|
227
|
-
selected:
|
|
233
|
+
selected: ssss
|
|
228
234
|
});
|
|
229
235
|
}
|
|
230
236
|
}, [isSelectionChange, rowSelection, table.getState().rowSelection]);
|
package/lib/ali-table/Grid.js
CHANGED
|
@@ -22,6 +22,7 @@ var _useContext = require("./useContext");
|
|
|
22
22
|
var _styles2 = require("./base-table/styles");
|
|
23
23
|
var _ColumnsConfig = require("../table-component/ColumnsConfig");
|
|
24
24
|
var _utils = require("../table-component/hook/utils");
|
|
25
|
+
var _utility = require("./utils/utility");
|
|
25
26
|
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); }
|
|
26
27
|
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; }
|
|
27
28
|
// import type { TableProps } from "../table-component"
|
|
@@ -65,7 +66,7 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
65
66
|
originColumns,
|
|
66
67
|
// columns,
|
|
67
68
|
groupColumns,
|
|
68
|
-
|
|
69
|
+
setVisibleKeys,
|
|
69
70
|
footerDataSource,
|
|
70
71
|
loading,
|
|
71
72
|
useVirtual,
|
|
@@ -167,12 +168,14 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
167
168
|
};
|
|
168
169
|
}, []);
|
|
169
170
|
const triggerChangeColumns = (cols, keys, type) => {
|
|
171
|
+
const abc = (0, _utility.getVisibleColumnFields)(cols);
|
|
172
|
+
setVisibleKeys(abc);
|
|
170
173
|
if (type === 'cellClick') {
|
|
171
174
|
|
|
172
175
|
// setColumns(cols)
|
|
173
176
|
} else {
|
|
174
177
|
// setColumns(cols)
|
|
175
|
-
pipeline.columns(cols)
|
|
178
|
+
// pipeline.columns(cols)
|
|
176
179
|
|
|
177
180
|
// const aa = flatColumns2(columns).map((it) => it.field)
|
|
178
181
|
|