es-grid-template 1.8.48 → 1.8.51
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/table-component/TableContainerEdit.js +3 -3
- package/es/table-component/body/TableBodyCell.js +4 -0
- package/es/table-component/body/TableBodyCellEdit.js +72 -0
- package/es/table-component/hook/utils.js +5 -5
- package/lib/table-component/TableContainerEdit.js +3 -3
- package/lib/table-component/body/TableBodyCell.js +4 -0
- package/lib/table-component/body/TableBodyCellEdit.js +72 -0
- package/lib/table-component/hook/utils.js +5 -5
- package/package.json +1 -1
|
@@ -483,12 +483,12 @@ const TableContainerEdit = props => {
|
|
|
483
483
|
[columnKey]: null
|
|
484
484
|
};
|
|
485
485
|
}
|
|
486
|
-
if (isFormattedNumber(cellValue.trim())) {
|
|
486
|
+
if (isFormattedNumber(cellValue.trim()) || !isNaN(Number(cellValue.trim()))) {
|
|
487
487
|
const colFormat = typeof columnOri.format === 'function' ? columnOri.format(record) : columnOri.format;
|
|
488
488
|
const valuePasteFormat = detectSeparators(cellValue.trim());
|
|
489
489
|
const cellFormat = getFormat(colFormat, format);
|
|
490
|
-
const thousandSeparator = valuePasteFormat?.thousandSeparator
|
|
491
|
-
const decimalSeparator = valuePasteFormat?.decimalSeparator
|
|
490
|
+
const thousandSeparator = valuePasteFormat?.thousandSeparator;
|
|
491
|
+
const decimalSeparator = valuePasteFormat?.decimalSeparator;
|
|
492
492
|
const dec = cellFormat?.decimalScale;
|
|
493
493
|
const numericFormatProps = {
|
|
494
494
|
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
@@ -697,6 +697,78 @@ const TableBodyCellEdit = props => {
|
|
|
697
697
|
}
|
|
698
698
|
return;
|
|
699
699
|
}
|
|
700
|
+
if (e.key === 'ArrowDown') {
|
|
701
|
+
// e.preventDefault()
|
|
702
|
+
// e.stopPropagation()
|
|
703
|
+
|
|
704
|
+
const nextRow = table.getRowModel().rows[rowNumber + 1];
|
|
705
|
+
if (nextRow) {
|
|
706
|
+
const nextRowId = nextRow.id;
|
|
707
|
+
setFocusedCell?.({
|
|
708
|
+
rowId: nextRowId,
|
|
709
|
+
colId
|
|
710
|
+
});
|
|
711
|
+
setStartCell?.({
|
|
712
|
+
rowId: nextRowId,
|
|
713
|
+
colId
|
|
714
|
+
});
|
|
715
|
+
setEndCell?.({
|
|
716
|
+
rowId: nextRowId,
|
|
717
|
+
colId
|
|
718
|
+
});
|
|
719
|
+
setRangeState?.(getSelectedCellMatrix(table, {
|
|
720
|
+
rowId: nextRowId,
|
|
721
|
+
colId
|
|
722
|
+
}, {
|
|
723
|
+
rowId: nextRowId,
|
|
724
|
+
colId
|
|
725
|
+
}));
|
|
726
|
+
|
|
727
|
+
// columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
|
|
728
|
+
// rowVirtualizer.scrollToIndex(nextRow.index, { align: 'center' })
|
|
729
|
+
|
|
730
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextRowId}"]`);
|
|
731
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
732
|
+
if (cellFocus) {
|
|
733
|
+
cellFocus.focus();
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
if (e.key === 'ArrowUp') {
|
|
739
|
+
// e.preventDefault()
|
|
740
|
+
// e.stopPropagation()
|
|
741
|
+
|
|
742
|
+
const nextRow = table.getRowModel().rows[rowNumber - 1];
|
|
743
|
+
if (nextRow) {
|
|
744
|
+
const nextRowId = nextRow.id;
|
|
745
|
+
setFocusedCell?.({
|
|
746
|
+
rowId: nextRowId,
|
|
747
|
+
colId
|
|
748
|
+
});
|
|
749
|
+
setStartCell?.({
|
|
750
|
+
rowId: nextRowId,
|
|
751
|
+
colId
|
|
752
|
+
});
|
|
753
|
+
setEndCell?.({
|
|
754
|
+
rowId: nextRowId,
|
|
755
|
+
colId
|
|
756
|
+
});
|
|
757
|
+
setRangeState?.(getSelectedCellMatrix(table, {
|
|
758
|
+
rowId: nextRowId,
|
|
759
|
+
colId
|
|
760
|
+
}, {
|
|
761
|
+
rowId: nextRowId,
|
|
762
|
+
colId
|
|
763
|
+
}));
|
|
764
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextRowId}"]`);
|
|
765
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
766
|
+
if (cellFocus) {
|
|
767
|
+
cellFocus.focus();
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
700
772
|
if (e.key === 'Delete') {
|
|
701
773
|
handleDeleteContent?.();
|
|
702
774
|
return;
|
|
@@ -677,7 +677,7 @@ export const isFormattedNumber = str => {
|
|
|
677
677
|
const regexEU = /^\d{1,3}(\.\d{3})*(,\d+)?$/; // 100.000,111
|
|
678
678
|
|
|
679
679
|
// Không có dấu hàng nghìn, chỉ dấu thập phân: 100000.1 hoặc 100000,01
|
|
680
|
-
const regexDecimalOnly =
|
|
680
|
+
const regexDecimalOnly = /^-?\d+([.,]\d{1,})$/;
|
|
681
681
|
return regexUS.test(str) || regexEU.test(str) || regexDecimalOnly.test(str);
|
|
682
682
|
};
|
|
683
683
|
export const detectSeparators = str => {
|
|
@@ -704,9 +704,9 @@ export const detectSeparators = str => {
|
|
|
704
704
|
if (parts.length === 2) {
|
|
705
705
|
return parts[1].length === 3 ? {
|
|
706
706
|
thousandSeparator: ',',
|
|
707
|
-
decimalSeparator:
|
|
707
|
+
decimalSeparator: undefined
|
|
708
708
|
} : {
|
|
709
|
-
thousandSeparator:
|
|
709
|
+
thousandSeparator: undefined,
|
|
710
710
|
decimalSeparator: ','
|
|
711
711
|
};
|
|
712
712
|
}
|
|
@@ -718,9 +718,9 @@ export const detectSeparators = str => {
|
|
|
718
718
|
if (parts.length === 2) {
|
|
719
719
|
return parts[1].length === 3 ? {
|
|
720
720
|
thousandSeparator: '.',
|
|
721
|
-
decimalSeparator:
|
|
721
|
+
decimalSeparator: undefined
|
|
722
722
|
} : {
|
|
723
|
-
thousandSeparator:
|
|
723
|
+
thousandSeparator: undefined,
|
|
724
724
|
decimalSeparator: '.'
|
|
725
725
|
};
|
|
726
726
|
}
|
|
@@ -490,12 +490,12 @@ const TableContainerEdit = props => {
|
|
|
490
490
|
[columnKey]: null
|
|
491
491
|
};
|
|
492
492
|
}
|
|
493
|
-
if ((0, _utils.isFormattedNumber)(cellValue.trim())) {
|
|
493
|
+
if ((0, _utils.isFormattedNumber)(cellValue.trim()) || !isNaN(Number(cellValue.trim()))) {
|
|
494
494
|
const colFormat = typeof columnOri.format === 'function' ? columnOri.format(record) : columnOri.format;
|
|
495
495
|
const valuePasteFormat = (0, _utils.detectSeparators)(cellValue.trim());
|
|
496
496
|
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
497
|
-
const thousandSeparator = valuePasteFormat?.thousandSeparator
|
|
498
|
-
const decimalSeparator = valuePasteFormat?.decimalSeparator
|
|
497
|
+
const thousandSeparator = valuePasteFormat?.thousandSeparator;
|
|
498
|
+
const decimalSeparator = valuePasteFormat?.decimalSeparator;
|
|
499
499
|
const dec = cellFormat?.decimalScale;
|
|
500
500
|
const numericFormatProps = {
|
|
501
501
|
thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
@@ -703,6 +703,78 @@ const TableBodyCellEdit = props => {
|
|
|
703
703
|
}
|
|
704
704
|
return;
|
|
705
705
|
}
|
|
706
|
+
if (e.key === 'ArrowDown') {
|
|
707
|
+
// e.preventDefault()
|
|
708
|
+
// e.stopPropagation()
|
|
709
|
+
|
|
710
|
+
const nextRow = table.getRowModel().rows[rowNumber + 1];
|
|
711
|
+
if (nextRow) {
|
|
712
|
+
const nextRowId = nextRow.id;
|
|
713
|
+
setFocusedCell?.({
|
|
714
|
+
rowId: nextRowId,
|
|
715
|
+
colId
|
|
716
|
+
});
|
|
717
|
+
setStartCell?.({
|
|
718
|
+
rowId: nextRowId,
|
|
719
|
+
colId
|
|
720
|
+
});
|
|
721
|
+
setEndCell?.({
|
|
722
|
+
rowId: nextRowId,
|
|
723
|
+
colId
|
|
724
|
+
});
|
|
725
|
+
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
|
|
726
|
+
rowId: nextRowId,
|
|
727
|
+
colId
|
|
728
|
+
}, {
|
|
729
|
+
rowId: nextRowId,
|
|
730
|
+
colId
|
|
731
|
+
}));
|
|
732
|
+
|
|
733
|
+
// columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
|
|
734
|
+
// rowVirtualizer.scrollToIndex(nextRow.index, { align: 'center' })
|
|
735
|
+
|
|
736
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextRowId}"]`);
|
|
737
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
738
|
+
if (cellFocus) {
|
|
739
|
+
cellFocus.focus();
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
if (e.key === 'ArrowUp') {
|
|
745
|
+
// e.preventDefault()
|
|
746
|
+
// e.stopPropagation()
|
|
747
|
+
|
|
748
|
+
const nextRow = table.getRowModel().rows[rowNumber - 1];
|
|
749
|
+
if (nextRow) {
|
|
750
|
+
const nextRowId = nextRow.id;
|
|
751
|
+
setFocusedCell?.({
|
|
752
|
+
rowId: nextRowId,
|
|
753
|
+
colId
|
|
754
|
+
});
|
|
755
|
+
setStartCell?.({
|
|
756
|
+
rowId: nextRowId,
|
|
757
|
+
colId
|
|
758
|
+
});
|
|
759
|
+
setEndCell?.({
|
|
760
|
+
rowId: nextRowId,
|
|
761
|
+
colId
|
|
762
|
+
});
|
|
763
|
+
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
|
|
764
|
+
rowId: nextRowId,
|
|
765
|
+
colId
|
|
766
|
+
}, {
|
|
767
|
+
rowId: nextRowId,
|
|
768
|
+
colId
|
|
769
|
+
}));
|
|
770
|
+
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextRowId}"]`);
|
|
771
|
+
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
772
|
+
if (cellFocus) {
|
|
773
|
+
cellFocus.focus();
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
706
778
|
if (e.key === 'Delete') {
|
|
707
779
|
handleDeleteContent?.();
|
|
708
780
|
return;
|
|
@@ -769,7 +769,7 @@ const isFormattedNumber = str => {
|
|
|
769
769
|
const regexEU = /^\d{1,3}(\.\d{3})*(,\d+)?$/; // 100.000,111
|
|
770
770
|
|
|
771
771
|
// Không có dấu hàng nghìn, chỉ dấu thập phân: 100000.1 hoặc 100000,01
|
|
772
|
-
const regexDecimalOnly =
|
|
772
|
+
const regexDecimalOnly = /^-?\d+([.,]\d{1,})$/;
|
|
773
773
|
return regexUS.test(str) || regexEU.test(str) || regexDecimalOnly.test(str);
|
|
774
774
|
};
|
|
775
775
|
exports.isFormattedNumber = isFormattedNumber;
|
|
@@ -797,9 +797,9 @@ const detectSeparators = str => {
|
|
|
797
797
|
if (parts.length === 2) {
|
|
798
798
|
return parts[1].length === 3 ? {
|
|
799
799
|
thousandSeparator: ',',
|
|
800
|
-
decimalSeparator:
|
|
800
|
+
decimalSeparator: undefined
|
|
801
801
|
} : {
|
|
802
|
-
thousandSeparator:
|
|
802
|
+
thousandSeparator: undefined,
|
|
803
803
|
decimalSeparator: ','
|
|
804
804
|
};
|
|
805
805
|
}
|
|
@@ -811,9 +811,9 @@ const detectSeparators = str => {
|
|
|
811
811
|
if (parts.length === 2) {
|
|
812
812
|
return parts[1].length === 3 ? {
|
|
813
813
|
thousandSeparator: '.',
|
|
814
|
-
decimalSeparator:
|
|
814
|
+
decimalSeparator: undefined
|
|
815
815
|
} : {
|
|
816
|
-
thousandSeparator:
|
|
816
|
+
thousandSeparator: undefined,
|
|
817
817
|
decimalSeparator: '.'
|
|
818
818
|
};
|
|
819
819
|
}
|