react-table-edit 0.7.3 → 0.7.4
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +36 -19
- package/dist/index.mjs +36 -19
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -3083,7 +3083,7 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3083
3083
|
}
|
|
3084
3084
|
return void 0;
|
|
3085
3085
|
};
|
|
3086
|
-
const pasteDataFromExcel = async (
|
|
3086
|
+
const pasteDataFromExcel = async (currenRowIndex, col, e) => {
|
|
3087
3087
|
const clipboard = (e.clipboardData || window.Clipboard).getData("text");
|
|
3088
3088
|
const rowsClipboard = clipboard.trimEnd().split("\n");
|
|
3089
3089
|
setIndexFocus(void 0);
|
|
@@ -3098,9 +3098,9 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3098
3098
|
});
|
|
3099
3099
|
const column = getColumn(col, index);
|
|
3100
3100
|
if (column) {
|
|
3101
|
-
if ((!column.disabledCondition || !column.disabledCondition(
|
|
3102
|
-
if (column.
|
|
3103
|
-
const rs = await column.
|
|
3101
|
+
if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable) {
|
|
3102
|
+
if (column.onPasteValidate) {
|
|
3103
|
+
const rs = await column.onPasteValidate(stringData.join(","), 0, dataSource[currenRowIndex + 0]);
|
|
3104
3104
|
if (rs) {
|
|
3105
3105
|
column.resultValidate = rs;
|
|
3106
3106
|
}
|
|
@@ -3112,7 +3112,7 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3112
3112
|
for (let indexRow = 0; indexRow < rowsClipboard.length; indexRow++) {
|
|
3113
3113
|
const item = rowsClipboard[indexRow];
|
|
3114
3114
|
const colsClipboard = item.trimEnd().split(" ");
|
|
3115
|
-
let dataRow = dataSource[
|
|
3115
|
+
let dataRow = dataSource[currenRowIndex + indexRow];
|
|
3116
3116
|
if (!dataRow) {
|
|
3117
3117
|
dataRow = { ...defaultValue };
|
|
3118
3118
|
dataSource.push(dataRow);
|
|
@@ -3121,49 +3121,66 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3121
3121
|
const stringData = colsClipboard[index].toString().trim();
|
|
3122
3122
|
const column = columnsDataChange[index];
|
|
3123
3123
|
if (column) {
|
|
3124
|
-
|
|
3125
|
-
|
|
3124
|
+
console.log(!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow]));
|
|
3125
|
+
if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow])) && column.editEnable) {
|
|
3126
|
+
if (column.onPasteValidate && column.resultValidate) {
|
|
3126
3127
|
const rs = column.resultValidate.find((item2) => item2[column.selectSettings?.fieldValue] === stringData);
|
|
3127
3128
|
if (rs) {
|
|
3128
|
-
|
|
3129
|
+
if (column.onPaste) {
|
|
3130
|
+
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
3131
|
+
} else {
|
|
3132
|
+
dataRow[column.field] = stringData;
|
|
3133
|
+
}
|
|
3129
3134
|
if (column.callback) {
|
|
3130
|
-
column.callback(rs,
|
|
3135
|
+
column.callback(rs, currenRowIndex + indexRow);
|
|
3131
3136
|
}
|
|
3132
3137
|
} else {
|
|
3133
|
-
notificationError(t("PasteExcelNotExist", { index:
|
|
3138
|
+
notificationError(t("PasteExcelNotExist", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3134
3139
|
}
|
|
3135
3140
|
} else {
|
|
3136
3141
|
if (column.editType === "date") {
|
|
3137
3142
|
const date = new Date(stringData);
|
|
3138
3143
|
if (!isNaN(date.getTime())) {
|
|
3139
|
-
|
|
3144
|
+
if (column.onPaste) {
|
|
3145
|
+
dataRow[column.field] = column.onPaste(dataRow, date);
|
|
3146
|
+
} else {
|
|
3147
|
+
dataRow[column.field] = date;
|
|
3148
|
+
}
|
|
3140
3149
|
if (column.callback) {
|
|
3141
|
-
column.callback(date,
|
|
3150
|
+
column.callback(date, currenRowIndex + indexRow);
|
|
3142
3151
|
}
|
|
3143
3152
|
} else {
|
|
3144
|
-
notificationError(t("PasteExcelIncorrectFormat", { index:
|
|
3153
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3145
3154
|
}
|
|
3146
3155
|
} else if (column.editType === "numeric") {
|
|
3147
3156
|
const number = Number(stringData);
|
|
3148
3157
|
if (!isNaN(number)) {
|
|
3149
|
-
|
|
3158
|
+
if (column.onPaste) {
|
|
3159
|
+
dataRow[column.field] = column.onPaste(dataRow, number);
|
|
3160
|
+
} else {
|
|
3161
|
+
dataRow[column.field] = number;
|
|
3162
|
+
}
|
|
3150
3163
|
if (column.callback) {
|
|
3151
|
-
column.callback(number,
|
|
3164
|
+
column.callback(number, currenRowIndex + indexRow);
|
|
3152
3165
|
}
|
|
3153
3166
|
} else {
|
|
3154
|
-
notificationError(t("PasteExcelIncorrectFormat", { index:
|
|
3167
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3155
3168
|
}
|
|
3156
3169
|
} else {
|
|
3157
|
-
|
|
3170
|
+
if (column.onPaste) {
|
|
3171
|
+
column.onPaste(dataRow, stringData);
|
|
3172
|
+
} else {
|
|
3173
|
+
dataRow[column.field] = stringData;
|
|
3174
|
+
}
|
|
3158
3175
|
if (column.callback) {
|
|
3159
|
-
column.callback(stringData,
|
|
3176
|
+
column.callback(stringData, currenRowIndex + indexRow);
|
|
3160
3177
|
}
|
|
3161
3178
|
}
|
|
3162
3179
|
}
|
|
3163
3180
|
}
|
|
3164
3181
|
}
|
|
3165
3182
|
}
|
|
3166
|
-
rowChange(dataRow,
|
|
3183
|
+
rowChange(dataRow, currenRowIndex + indexRow, "");
|
|
3167
3184
|
}
|
|
3168
3185
|
}
|
|
3169
3186
|
changeDataSource(dataSource);
|
package/dist/index.mjs
CHANGED
|
@@ -3049,7 +3049,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3049
3049
|
}
|
|
3050
3050
|
return void 0;
|
|
3051
3051
|
};
|
|
3052
|
-
const pasteDataFromExcel = async (
|
|
3052
|
+
const pasteDataFromExcel = async (currenRowIndex, col, e) => {
|
|
3053
3053
|
const clipboard = (e.clipboardData || window.Clipboard).getData("text");
|
|
3054
3054
|
const rowsClipboard = clipboard.trimEnd().split("\n");
|
|
3055
3055
|
setIndexFocus(void 0);
|
|
@@ -3064,9 +3064,9 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3064
3064
|
});
|
|
3065
3065
|
const column = getColumn(col, index);
|
|
3066
3066
|
if (column) {
|
|
3067
|
-
if ((!column.disabledCondition || !column.disabledCondition(
|
|
3068
|
-
if (column.
|
|
3069
|
-
const rs = await column.
|
|
3067
|
+
if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable) {
|
|
3068
|
+
if (column.onPasteValidate) {
|
|
3069
|
+
const rs = await column.onPasteValidate(stringData.join(","), 0, dataSource[currenRowIndex + 0]);
|
|
3070
3070
|
if (rs) {
|
|
3071
3071
|
column.resultValidate = rs;
|
|
3072
3072
|
}
|
|
@@ -3078,7 +3078,7 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3078
3078
|
for (let indexRow = 0; indexRow < rowsClipboard.length; indexRow++) {
|
|
3079
3079
|
const item = rowsClipboard[indexRow];
|
|
3080
3080
|
const colsClipboard = item.trimEnd().split(" ");
|
|
3081
|
-
let dataRow = dataSource[
|
|
3081
|
+
let dataRow = dataSource[currenRowIndex + indexRow];
|
|
3082
3082
|
if (!dataRow) {
|
|
3083
3083
|
dataRow = { ...defaultValue };
|
|
3084
3084
|
dataSource.push(dataRow);
|
|
@@ -3087,49 +3087,66 @@ var TableEdit = forwardRef3((props, ref) => {
|
|
|
3087
3087
|
const stringData = colsClipboard[index].toString().trim();
|
|
3088
3088
|
const column = columnsDataChange[index];
|
|
3089
3089
|
if (column) {
|
|
3090
|
-
|
|
3091
|
-
|
|
3090
|
+
console.log(!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow]));
|
|
3091
|
+
if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow])) && column.editEnable) {
|
|
3092
|
+
if (column.onPasteValidate && column.resultValidate) {
|
|
3092
3093
|
const rs = column.resultValidate.find((item2) => item2[column.selectSettings?.fieldValue] === stringData);
|
|
3093
3094
|
if (rs) {
|
|
3094
|
-
|
|
3095
|
+
if (column.onPaste) {
|
|
3096
|
+
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
3097
|
+
} else {
|
|
3098
|
+
dataRow[column.field] = stringData;
|
|
3099
|
+
}
|
|
3095
3100
|
if (column.callback) {
|
|
3096
|
-
column.callback(rs,
|
|
3101
|
+
column.callback(rs, currenRowIndex + indexRow);
|
|
3097
3102
|
}
|
|
3098
3103
|
} else {
|
|
3099
|
-
notificationError(t("PasteExcelNotExist", { index:
|
|
3104
|
+
notificationError(t("PasteExcelNotExist", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3100
3105
|
}
|
|
3101
3106
|
} else {
|
|
3102
3107
|
if (column.editType === "date") {
|
|
3103
3108
|
const date = new Date(stringData);
|
|
3104
3109
|
if (!isNaN(date.getTime())) {
|
|
3105
|
-
|
|
3110
|
+
if (column.onPaste) {
|
|
3111
|
+
dataRow[column.field] = column.onPaste(dataRow, date);
|
|
3112
|
+
} else {
|
|
3113
|
+
dataRow[column.field] = date;
|
|
3114
|
+
}
|
|
3106
3115
|
if (column.callback) {
|
|
3107
|
-
column.callback(date,
|
|
3116
|
+
column.callback(date, currenRowIndex + indexRow);
|
|
3108
3117
|
}
|
|
3109
3118
|
} else {
|
|
3110
|
-
notificationError(t("PasteExcelIncorrectFormat", { index:
|
|
3119
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3111
3120
|
}
|
|
3112
3121
|
} else if (column.editType === "numeric") {
|
|
3113
3122
|
const number = Number(stringData);
|
|
3114
3123
|
if (!isNaN(number)) {
|
|
3115
|
-
|
|
3124
|
+
if (column.onPaste) {
|
|
3125
|
+
dataRow[column.field] = column.onPaste(dataRow, number);
|
|
3126
|
+
} else {
|
|
3127
|
+
dataRow[column.field] = number;
|
|
3128
|
+
}
|
|
3116
3129
|
if (column.callback) {
|
|
3117
|
-
column.callback(number,
|
|
3130
|
+
column.callback(number, currenRowIndex + indexRow);
|
|
3118
3131
|
}
|
|
3119
3132
|
} else {
|
|
3120
|
-
notificationError(t("PasteExcelIncorrectFormat", { index:
|
|
3133
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
3121
3134
|
}
|
|
3122
3135
|
} else {
|
|
3123
|
-
|
|
3136
|
+
if (column.onPaste) {
|
|
3137
|
+
column.onPaste(dataRow, stringData);
|
|
3138
|
+
} else {
|
|
3139
|
+
dataRow[column.field] = stringData;
|
|
3140
|
+
}
|
|
3124
3141
|
if (column.callback) {
|
|
3125
|
-
column.callback(stringData,
|
|
3142
|
+
column.callback(stringData, currenRowIndex + indexRow);
|
|
3126
3143
|
}
|
|
3127
3144
|
}
|
|
3128
3145
|
}
|
|
3129
3146
|
}
|
|
3130
3147
|
}
|
|
3131
3148
|
}
|
|
3132
|
-
rowChange(dataRow,
|
|
3149
|
+
rowChange(dataRow, currenRowIndex + indexRow, "");
|
|
3133
3150
|
}
|
|
3134
3151
|
}
|
|
3135
3152
|
changeDataSource(dataSource);
|