react-table-edit 1.4.22 → 1.4.23
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/dist/component/input/input-date/index.d.ts +2 -0
- package/dist/index.js +43 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -39883,13 +39883,18 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
39883
39883
|
var InputMask = reactInputMask.exports;
|
|
39884
39884
|
|
|
39885
39885
|
const DateInput = (props) => {
|
|
39886
|
-
const { id, onKeyDown, dateFormat, className, onChange, value } = props;
|
|
39886
|
+
const { id, onKeyDown, dateFormat, className, onChange, value, onPaste } = props;
|
|
39887
39887
|
const [open, setOpen] = useState(false);
|
|
39888
39888
|
return (jsx(DatePicker, { id: id, open: open, className: className, selected: value, onChange: (date) => {
|
|
39889
39889
|
if (onChange) {
|
|
39890
39890
|
onChange(date);
|
|
39891
39891
|
}
|
|
39892
|
-
}, dateFormat: dateFormat, locale: "vi", showMonthDropdown: true, showYearDropdown: true, dropdownMode: "select", isClearable: true, onCalendarClose: () => setOpen(false), onCalendarOpen: () => setOpen(true), customInput: jsx(InputMask, { mask: "99/99/9999", placeholder: dateFormat
|
|
39892
|
+
}, dateFormat: dateFormat, locale: "vi", showMonthDropdown: true, showYearDropdown: true, dropdownMode: "select", isClearable: true, onCalendarClose: () => setOpen(false), onCalendarOpen: () => setOpen(true), customInput: jsx(InputMask, { mask: "99/99/9999", placeholder: dateFormat, onPaste: (e) => {
|
|
39893
|
+
if (onPaste) {
|
|
39894
|
+
onPaste(e);
|
|
39895
|
+
setOpen(false);
|
|
39896
|
+
}
|
|
39897
|
+
} }), onKeyDown: (e) => {
|
|
39893
39898
|
if (e.code === 'Space') {
|
|
39894
39899
|
setOpen(!open);
|
|
39895
39900
|
setTimeout(() => {
|
|
@@ -39899,12 +39904,10 @@ const DateInput = (props) => {
|
|
|
39899
39904
|
}
|
|
39900
39905
|
}, 100);
|
|
39901
39906
|
}
|
|
39902
|
-
else {
|
|
39903
|
-
|
|
39904
|
-
|
|
39905
|
-
|
|
39906
|
-
setOpen(false);
|
|
39907
|
-
}
|
|
39907
|
+
else if (onKeyDown && (!open || ((e.ctrlKey || e.metaKey || e.altKey) && e.shiftKey))) {
|
|
39908
|
+
const rs = onKeyDown(e);
|
|
39909
|
+
if (rs) {
|
|
39910
|
+
setOpen(false);
|
|
39908
39911
|
}
|
|
39909
39912
|
}
|
|
39910
39913
|
} }));
|
|
@@ -42763,6 +42766,11 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42763
42766
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
|
|
42764
42767
|
return true;
|
|
42765
42768
|
}
|
|
42769
|
+
}, onPaste: (e) => {
|
|
42770
|
+
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable) {
|
|
42771
|
+
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42772
|
+
e.preventDefault();
|
|
42773
|
+
}
|
|
42766
42774
|
} }));
|
|
42767
42775
|
case 'datetime':
|
|
42768
42776
|
return (jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$1('form-control border-0 rounded-0 input-numeric', { 'is-invalid': col.validate && col.validate(row[col.field], row) }), value: row[col.field], onChange: (date) => {
|
|
@@ -42773,6 +42781,11 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42773
42781
|
handleDataChange(row, col, indexRow);
|
|
42774
42782
|
}, dateFormat: "dd/MM/yyyy HH:mm", onKeyDown: (e) => {
|
|
42775
42783
|
checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42784
|
+
}, onPaste: (e) => {
|
|
42785
|
+
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable) {
|
|
42786
|
+
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42787
|
+
e.preventDefault();
|
|
42788
|
+
}
|
|
42776
42789
|
} }));
|
|
42777
42790
|
case 'select':
|
|
42778
42791
|
let valueSelect;
|
|
@@ -43155,7 +43168,28 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43155
43168
|
}
|
|
43156
43169
|
else {
|
|
43157
43170
|
if (column.editType === 'date') {
|
|
43158
|
-
const
|
|
43171
|
+
const [day, month, year] = stringData.split('/');
|
|
43172
|
+
const date = new Date(`${year}-${month}-${day}`);
|
|
43173
|
+
if (!isNaN(date.getTime())) {
|
|
43174
|
+
if (column.onPaste) {
|
|
43175
|
+
dataRow[column.field] = column.onPaste(dataRow, date);
|
|
43176
|
+
}
|
|
43177
|
+
else {
|
|
43178
|
+
dataRow[column.field] = date;
|
|
43179
|
+
}
|
|
43180
|
+
if (column.callback) {
|
|
43181
|
+
column.callback(date, currenRowIndex + indexRow, dataRow);
|
|
43182
|
+
}
|
|
43183
|
+
}
|
|
43184
|
+
else {
|
|
43185
|
+
notificationError(t('PasteExcelIncorrectFormat', { index: (currenRowIndex + indexRow + 1), field: t(column.headerText ?? ''), value: stringData }));
|
|
43186
|
+
}
|
|
43187
|
+
}
|
|
43188
|
+
else if (column.editType === 'datetime') {
|
|
43189
|
+
const [datePart, timePart] = stringData.split(' ');
|
|
43190
|
+
const [day, month, year] = datePart.split('/');
|
|
43191
|
+
const [hour, minute] = timePart.split(':');
|
|
43192
|
+
const date = new Date(year, month - 1, day, hour, minute);
|
|
43159
43193
|
if (!isNaN(date.getTime())) {
|
|
43160
43194
|
if (column.onPaste) {
|
|
43161
43195
|
dataRow[column.field] = column.onPaste(dataRow, date);
|