react-table-edit 0.7.2 → 0.7.3
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/index.js +62 -40
- package/dist/index.mjs +62 -40
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3076,7 +3076,7 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3076
3076
|
const column = contentColumns[col + index];
|
|
3077
3077
|
if (column) {
|
|
3078
3078
|
if (column.visible !== false) {
|
|
3079
|
-
return column;
|
|
3079
|
+
return { ...column };
|
|
3080
3080
|
} else {
|
|
3081
3081
|
return getColumn(col, index + 1);
|
|
3082
3082
|
}
|
|
@@ -3085,64 +3085,86 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3085
3085
|
};
|
|
3086
3086
|
const pasteDataFromExcel = async (row, col, e) => {
|
|
3087
3087
|
const clipboard = (e.clipboardData || window.Clipboard).getData("text");
|
|
3088
|
-
const
|
|
3088
|
+
const rowsClipboard = clipboard.trimEnd().split("\n");
|
|
3089
3089
|
setIndexFocus(void 0);
|
|
3090
|
-
|
|
3091
|
-
const
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
const stringData = arrayCol[index].toString().trim();
|
|
3090
|
+
if (rowsClipboard.length > 0) {
|
|
3091
|
+
const columnsDataChange = [];
|
|
3092
|
+
for (let index = 0; index < rowsClipboard[0].trimEnd().split(" ").length; index++) {
|
|
3093
|
+
const stringData = [];
|
|
3094
|
+
rowsClipboard.forEach((element) => {
|
|
3095
|
+
if (element.trimEnd().split(" ")[index]) {
|
|
3096
|
+
stringData.push(element.trimEnd().split(" ")[index].toString().trim());
|
|
3097
|
+
}
|
|
3098
|
+
});
|
|
3100
3099
|
const column = getColumn(col, index);
|
|
3101
3100
|
if (column) {
|
|
3102
3101
|
if ((!column.disabledCondition || !column.disabledCondition(row)) && column.editEnable) {
|
|
3103
3102
|
if (column.onPaste) {
|
|
3104
|
-
const rs = await column.onPaste(stringData,
|
|
3103
|
+
const rs = await column.onPaste(stringData.join(","), 0, row);
|
|
3105
3104
|
if (rs) {
|
|
3106
|
-
|
|
3107
|
-
dataRow[column.field] = stringData;
|
|
3108
|
-
if (column.callback) {
|
|
3109
|
-
column.callback(rs.value, indexRow);
|
|
3110
|
-
}
|
|
3111
|
-
} else {
|
|
3112
|
-
notificationError(t("PasteExcelNotExist", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3105
|
+
column.resultValidate = rs;
|
|
3113
3106
|
}
|
|
3114
|
-
}
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
columnsDataChange.push(column);
|
|
3111
|
+
}
|
|
3112
|
+
for (let indexRow = 0; indexRow < rowsClipboard.length; indexRow++) {
|
|
3113
|
+
const item = rowsClipboard[indexRow];
|
|
3114
|
+
const colsClipboard = item.trimEnd().split(" ");
|
|
3115
|
+
let dataRow = dataSource[row + indexRow];
|
|
3116
|
+
if (!dataRow) {
|
|
3117
|
+
dataRow = { ...defaultValue };
|
|
3118
|
+
dataSource.push(dataRow);
|
|
3119
|
+
}
|
|
3120
|
+
for (let index = 0; index < colsClipboard.length; index++) {
|
|
3121
|
+
const stringData = colsClipboard[index].toString().trim();
|
|
3122
|
+
const column = columnsDataChange[index];
|
|
3123
|
+
if (column) {
|
|
3124
|
+
if ((!column.disabledCondition || !column.disabledCondition(row)) && column.editEnable) {
|
|
3125
|
+
if (column.onPaste && column.resultValidate) {
|
|
3126
|
+
const rs = column.resultValidate.find((item2) => item2[column.selectSettings?.fieldValue] === stringData);
|
|
3127
|
+
if (rs) {
|
|
3128
|
+
dataRow[column.field] = stringData;
|
|
3119
3129
|
if (column.callback) {
|
|
3120
|
-
column.callback(
|
|
3130
|
+
column.callback(rs, row + indexRow);
|
|
3121
3131
|
}
|
|
3122
3132
|
} else {
|
|
3123
|
-
notificationError(t("
|
|
3133
|
+
notificationError(t("PasteExcelNotExist", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3124
3134
|
}
|
|
3125
|
-
} else
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
column.callback
|
|
3135
|
+
} else {
|
|
3136
|
+
if (column.editType === "date") {
|
|
3137
|
+
const date = new Date(stringData);
|
|
3138
|
+
if (!isNaN(date.getTime())) {
|
|
3139
|
+
dataRow[column.field] = date;
|
|
3140
|
+
if (column.callback) {
|
|
3141
|
+
column.callback(date, row + indexRow);
|
|
3142
|
+
}
|
|
3143
|
+
} else {
|
|
3144
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3145
|
+
}
|
|
3146
|
+
} else if (column.editType === "numeric") {
|
|
3147
|
+
const number = Number(stringData);
|
|
3148
|
+
if (!isNaN(number)) {
|
|
3149
|
+
dataRow[column.field] = number;
|
|
3150
|
+
if (column.callback) {
|
|
3151
|
+
column.callback(number, row + indexRow);
|
|
3152
|
+
}
|
|
3153
|
+
} else {
|
|
3154
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3131
3155
|
}
|
|
3132
3156
|
} else {
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
if (column.callback) {
|
|
3138
|
-
column.callback(stringData, indexRow);
|
|
3157
|
+
dataRow[column.field] = stringData;
|
|
3158
|
+
if (column.callback) {
|
|
3159
|
+
column.callback(stringData, row + indexRow);
|
|
3160
|
+
}
|
|
3139
3161
|
}
|
|
3140
3162
|
}
|
|
3141
3163
|
}
|
|
3142
3164
|
}
|
|
3143
3165
|
}
|
|
3166
|
+
rowChange(dataRow, row + indexRow, "");
|
|
3144
3167
|
}
|
|
3145
|
-
rowChange(dataRow, row + indexRow, "");
|
|
3146
3168
|
}
|
|
3147
3169
|
changeDataSource(dataSource);
|
|
3148
3170
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -3042,7 +3042,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3042
3042
|
const column = contentColumns[col + index];
|
|
3043
3043
|
if (column) {
|
|
3044
3044
|
if (column.visible !== false) {
|
|
3045
|
-
return column;
|
|
3045
|
+
return { ...column };
|
|
3046
3046
|
} else {
|
|
3047
3047
|
return getColumn(col, index + 1);
|
|
3048
3048
|
}
|
|
@@ -3051,64 +3051,86 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3051
3051
|
};
|
|
3052
3052
|
const pasteDataFromExcel = async (row, col, e) => {
|
|
3053
3053
|
const clipboard = (e.clipboardData || window.Clipboard).getData("text");
|
|
3054
|
-
const
|
|
3054
|
+
const rowsClipboard = clipboard.trimEnd().split("\n");
|
|
3055
3055
|
setIndexFocus(void 0);
|
|
3056
|
-
|
|
3057
|
-
const
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
const stringData = arrayCol[index].toString().trim();
|
|
3056
|
+
if (rowsClipboard.length > 0) {
|
|
3057
|
+
const columnsDataChange = [];
|
|
3058
|
+
for (let index = 0; index < rowsClipboard[0].trimEnd().split(" ").length; index++) {
|
|
3059
|
+
const stringData = [];
|
|
3060
|
+
rowsClipboard.forEach((element) => {
|
|
3061
|
+
if (element.trimEnd().split(" ")[index]) {
|
|
3062
|
+
stringData.push(element.trimEnd().split(" ")[index].toString().trim());
|
|
3063
|
+
}
|
|
3064
|
+
});
|
|
3066
3065
|
const column = getColumn(col, index);
|
|
3067
3066
|
if (column) {
|
|
3068
3067
|
if ((!column.disabledCondition || !column.disabledCondition(row)) && column.editEnable) {
|
|
3069
3068
|
if (column.onPaste) {
|
|
3070
|
-
const rs = await column.onPaste(stringData,
|
|
3069
|
+
const rs = await column.onPaste(stringData.join(","), 0, row);
|
|
3071
3070
|
if (rs) {
|
|
3072
|
-
|
|
3073
|
-
dataRow[column.field] = stringData;
|
|
3074
|
-
if (column.callback) {
|
|
3075
|
-
column.callback(rs.value, indexRow);
|
|
3076
|
-
}
|
|
3077
|
-
} else {
|
|
3078
|
-
notificationError(t("PasteExcelNotExist", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3071
|
+
column.resultValidate = rs;
|
|
3079
3072
|
}
|
|
3080
|
-
}
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3073
|
+
}
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
columnsDataChange.push(column);
|
|
3077
|
+
}
|
|
3078
|
+
for (let indexRow = 0; indexRow < rowsClipboard.length; indexRow++) {
|
|
3079
|
+
const item = rowsClipboard[indexRow];
|
|
3080
|
+
const colsClipboard = item.trimEnd().split(" ");
|
|
3081
|
+
let dataRow = dataSource[row + indexRow];
|
|
3082
|
+
if (!dataRow) {
|
|
3083
|
+
dataRow = { ...defaultValue };
|
|
3084
|
+
dataSource.push(dataRow);
|
|
3085
|
+
}
|
|
3086
|
+
for (let index = 0; index < colsClipboard.length; index++) {
|
|
3087
|
+
const stringData = colsClipboard[index].toString().trim();
|
|
3088
|
+
const column = columnsDataChange[index];
|
|
3089
|
+
if (column) {
|
|
3090
|
+
if ((!column.disabledCondition || !column.disabledCondition(row)) && column.editEnable) {
|
|
3091
|
+
if (column.onPaste && column.resultValidate) {
|
|
3092
|
+
const rs = column.resultValidate.find((item2) => item2[column.selectSettings?.fieldValue] === stringData);
|
|
3093
|
+
if (rs) {
|
|
3094
|
+
dataRow[column.field] = stringData;
|
|
3085
3095
|
if (column.callback) {
|
|
3086
|
-
column.callback(
|
|
3096
|
+
column.callback(rs, row + indexRow);
|
|
3087
3097
|
}
|
|
3088
3098
|
} else {
|
|
3089
|
-
notificationError(t("
|
|
3099
|
+
notificationError(t("PasteExcelNotExist", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3090
3100
|
}
|
|
3091
|
-
} else
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
column.callback
|
|
3101
|
+
} else {
|
|
3102
|
+
if (column.editType === "date") {
|
|
3103
|
+
const date = new Date(stringData);
|
|
3104
|
+
if (!isNaN(date.getTime())) {
|
|
3105
|
+
dataRow[column.field] = date;
|
|
3106
|
+
if (column.callback) {
|
|
3107
|
+
column.callback(date, row + indexRow);
|
|
3108
|
+
}
|
|
3109
|
+
} else {
|
|
3110
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3111
|
+
}
|
|
3112
|
+
} else if (column.editType === "numeric") {
|
|
3113
|
+
const number = Number(stringData);
|
|
3114
|
+
if (!isNaN(number)) {
|
|
3115
|
+
dataRow[column.field] = number;
|
|
3116
|
+
if (column.callback) {
|
|
3117
|
+
column.callback(number, row + indexRow);
|
|
3118
|
+
}
|
|
3119
|
+
} else {
|
|
3120
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: row + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3097
3121
|
}
|
|
3098
3122
|
} else {
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
if (column.callback) {
|
|
3104
|
-
column.callback(stringData, indexRow);
|
|
3123
|
+
dataRow[column.field] = stringData;
|
|
3124
|
+
if (column.callback) {
|
|
3125
|
+
column.callback(stringData, row + indexRow);
|
|
3126
|
+
}
|
|
3105
3127
|
}
|
|
3106
3128
|
}
|
|
3107
3129
|
}
|
|
3108
3130
|
}
|
|
3109
3131
|
}
|
|
3132
|
+
rowChange(dataRow, row + indexRow, "");
|
|
3110
3133
|
}
|
|
3111
|
-
rowChange(dataRow, row + indexRow, "");
|
|
3112
3134
|
}
|
|
3113
3135
|
changeDataSource(dataSource);
|
|
3114
3136
|
};
|