react-table-edit 0.0.8 → 0.1.0
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 +17 -23
- package/dist/index.mjs +17 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1506,6 +1506,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
1506
1506
|
}
|
|
1507
1507
|
}
|
|
1508
1508
|
}
|
|
1509
|
+
changeDataSource(dataSource);
|
|
1509
1510
|
if (dataSourceChange) {
|
|
1510
1511
|
dataSourceChange(dataSource);
|
|
1511
1512
|
}
|
|
@@ -1525,6 +1526,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
1525
1526
|
}
|
|
1526
1527
|
}
|
|
1527
1528
|
}
|
|
1529
|
+
changeDataSource(dataSource);
|
|
1528
1530
|
if (dataSourceChange) {
|
|
1529
1531
|
dataSourceChange(dataSource);
|
|
1530
1532
|
}
|
|
@@ -2064,9 +2066,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2064
2066
|
}
|
|
2065
2067
|
if (e.code === "Tab" && indexCol === columnLastEdit) {
|
|
2066
2068
|
if (indexRow === dataSource?.length) {
|
|
2067
|
-
|
|
2068
|
-
setDataSource([...dataSource, defaultValue ? { ...defaultValue } : {}]);
|
|
2069
|
-
}
|
|
2069
|
+
changeDataSource(dataSource, true);
|
|
2070
2070
|
if (tableElement) {
|
|
2071
2071
|
setTimeout(() => {
|
|
2072
2072
|
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
@@ -2141,9 +2141,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2141
2141
|
}
|
|
2142
2142
|
});
|
|
2143
2143
|
const handleAdd = () => {
|
|
2144
|
-
|
|
2145
|
-
setDataSource([...dataSource, defaultValue ? { ...defaultValue, id: generateUUID() } : {}]);
|
|
2146
|
-
}
|
|
2144
|
+
changeDataSource(dataSource, true);
|
|
2147
2145
|
if (tableElement) {
|
|
2148
2146
|
setIndexFocus(dataSource?.length);
|
|
2149
2147
|
setTimeout(() => {
|
|
@@ -2162,9 +2160,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2162
2160
|
const deleteAll = () => {
|
|
2163
2161
|
if (!editDisable && !addDisable) {
|
|
2164
2162
|
setIndexFocus(-1);
|
|
2165
|
-
|
|
2166
|
-
setDataSource([]);
|
|
2167
|
-
}
|
|
2163
|
+
changeDataSource([], false);
|
|
2168
2164
|
}
|
|
2169
2165
|
};
|
|
2170
2166
|
const handleDuplicate = (data, index) => {
|
|
@@ -2179,9 +2175,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2179
2175
|
} else {
|
|
2180
2176
|
dataSource?.splice(index, 0, { ...data });
|
|
2181
2177
|
}
|
|
2182
|
-
|
|
2183
|
-
setDataSource([...dataSource]);
|
|
2184
|
-
}
|
|
2178
|
+
changeDataSource(dataSource);
|
|
2185
2179
|
if (tableElement && index === dataSource?.length) {
|
|
2186
2180
|
setTimeout(() => {
|
|
2187
2181
|
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
@@ -2192,9 +2186,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2192
2186
|
const handleInsertAfter = () => {
|
|
2193
2187
|
if (showBottomToolbar && !editDisable && !addDisable) {
|
|
2194
2188
|
dataSource?.splice((indexFocus ?? -1) + 1, 0, { ...defaultValue });
|
|
2195
|
-
|
|
2196
|
-
setDataSource([...dataSource]);
|
|
2197
|
-
}
|
|
2189
|
+
changeDataSource(dataSource);
|
|
2198
2190
|
if (tableElement && indexFocus === dataSource?.length) {
|
|
2199
2191
|
setTimeout(() => {
|
|
2200
2192
|
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
@@ -2205,9 +2197,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2205
2197
|
const handleInsertBefore = () => {
|
|
2206
2198
|
if (showBottomToolbar && !editDisable && !addDisable) {
|
|
2207
2199
|
dataSource?.splice(indexFocus ?? -1, 0, { ...defaultValue });
|
|
2208
|
-
|
|
2209
|
-
setDataSource([...dataSource]);
|
|
2210
|
-
}
|
|
2200
|
+
changeDataSource(dataSource);
|
|
2211
2201
|
}
|
|
2212
2202
|
};
|
|
2213
2203
|
const handleDeleteAll = () => {
|
|
@@ -2234,9 +2224,15 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2234
2224
|
rowChange(dataRow, row + indexRow, "");
|
|
2235
2225
|
});
|
|
2236
2226
|
handleRefeshRow();
|
|
2237
|
-
|
|
2238
|
-
|
|
2227
|
+
changeDataSource(dataSource);
|
|
2228
|
+
};
|
|
2229
|
+
const changeDataSource = (data, haveNew = false) => {
|
|
2230
|
+
if (!editDisable && !addDisable && setDataSource) {
|
|
2231
|
+
if (haveNew) {
|
|
2232
|
+
data.push(defaultValue ? { ...defaultValue, "fieldKey": generateUUID() } : {});
|
|
2233
|
+
}
|
|
2239
2234
|
}
|
|
2235
|
+
setDataSource([...data]);
|
|
2240
2236
|
};
|
|
2241
2237
|
(0, import_react12.useEffect)(() => {
|
|
2242
2238
|
if (setSelectedItem) {
|
|
@@ -2320,9 +2316,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2320
2316
|
if (fieldKey) {
|
|
2321
2317
|
dataSource[indexRow][fieldKey] = defaultValue[fieldKey];
|
|
2322
2318
|
}
|
|
2323
|
-
|
|
2324
|
-
setDataSource([...dataSource]);
|
|
2325
|
-
}
|
|
2319
|
+
changeDataSource(dataSource);
|
|
2326
2320
|
notificationSuccess(t("PasteSuccessful"));
|
|
2327
2321
|
}).catch((ex) => {
|
|
2328
2322
|
alert(ex);
|
package/dist/index.mjs
CHANGED
|
@@ -1479,6 +1479,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1479
1479
|
}
|
|
1480
1480
|
}
|
|
1481
1481
|
}
|
|
1482
|
+
changeDataSource(dataSource);
|
|
1482
1483
|
if (dataSourceChange) {
|
|
1483
1484
|
dataSourceChange(dataSource);
|
|
1484
1485
|
}
|
|
@@ -1498,6 +1499,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1498
1499
|
}
|
|
1499
1500
|
}
|
|
1500
1501
|
}
|
|
1502
|
+
changeDataSource(dataSource);
|
|
1501
1503
|
if (dataSourceChange) {
|
|
1502
1504
|
dataSourceChange(dataSource);
|
|
1503
1505
|
}
|
|
@@ -2037,9 +2039,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2037
2039
|
}
|
|
2038
2040
|
if (e.code === "Tab" && indexCol === columnLastEdit) {
|
|
2039
2041
|
if (indexRow === dataSource?.length) {
|
|
2040
|
-
|
|
2041
|
-
setDataSource([...dataSource, defaultValue ? { ...defaultValue } : {}]);
|
|
2042
|
-
}
|
|
2042
|
+
changeDataSource(dataSource, true);
|
|
2043
2043
|
if (tableElement) {
|
|
2044
2044
|
setTimeout(() => {
|
|
2045
2045
|
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
@@ -2114,9 +2114,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2114
2114
|
}
|
|
2115
2115
|
});
|
|
2116
2116
|
const handleAdd = () => {
|
|
2117
|
-
|
|
2118
|
-
setDataSource([...dataSource, defaultValue ? { ...defaultValue, id: generateUUID() } : {}]);
|
|
2119
|
-
}
|
|
2117
|
+
changeDataSource(dataSource, true);
|
|
2120
2118
|
if (tableElement) {
|
|
2121
2119
|
setIndexFocus(dataSource?.length);
|
|
2122
2120
|
setTimeout(() => {
|
|
@@ -2135,9 +2133,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2135
2133
|
const deleteAll = () => {
|
|
2136
2134
|
if (!editDisable && !addDisable) {
|
|
2137
2135
|
setIndexFocus(-1);
|
|
2138
|
-
|
|
2139
|
-
setDataSource([]);
|
|
2140
|
-
}
|
|
2136
|
+
changeDataSource([], false);
|
|
2141
2137
|
}
|
|
2142
2138
|
};
|
|
2143
2139
|
const handleDuplicate = (data, index) => {
|
|
@@ -2152,9 +2148,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2152
2148
|
} else {
|
|
2153
2149
|
dataSource?.splice(index, 0, { ...data });
|
|
2154
2150
|
}
|
|
2155
|
-
|
|
2156
|
-
setDataSource([...dataSource]);
|
|
2157
|
-
}
|
|
2151
|
+
changeDataSource(dataSource);
|
|
2158
2152
|
if (tableElement && index === dataSource?.length) {
|
|
2159
2153
|
setTimeout(() => {
|
|
2160
2154
|
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
@@ -2165,9 +2159,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2165
2159
|
const handleInsertAfter = () => {
|
|
2166
2160
|
if (showBottomToolbar && !editDisable && !addDisable) {
|
|
2167
2161
|
dataSource?.splice((indexFocus ?? -1) + 1, 0, { ...defaultValue });
|
|
2168
|
-
|
|
2169
|
-
setDataSource([...dataSource]);
|
|
2170
|
-
}
|
|
2162
|
+
changeDataSource(dataSource);
|
|
2171
2163
|
if (tableElement && indexFocus === dataSource?.length) {
|
|
2172
2164
|
setTimeout(() => {
|
|
2173
2165
|
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
@@ -2178,9 +2170,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2178
2170
|
const handleInsertBefore = () => {
|
|
2179
2171
|
if (showBottomToolbar && !editDisable && !addDisable) {
|
|
2180
2172
|
dataSource?.splice(indexFocus ?? -1, 0, { ...defaultValue });
|
|
2181
|
-
|
|
2182
|
-
setDataSource([...dataSource]);
|
|
2183
|
-
}
|
|
2173
|
+
changeDataSource(dataSource);
|
|
2184
2174
|
}
|
|
2185
2175
|
};
|
|
2186
2176
|
const handleDeleteAll = () => {
|
|
@@ -2207,9 +2197,15 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2207
2197
|
rowChange(dataRow, row + indexRow, "");
|
|
2208
2198
|
});
|
|
2209
2199
|
handleRefeshRow();
|
|
2210
|
-
|
|
2211
|
-
|
|
2200
|
+
changeDataSource(dataSource);
|
|
2201
|
+
};
|
|
2202
|
+
const changeDataSource = (data, haveNew = false) => {
|
|
2203
|
+
if (!editDisable && !addDisable && setDataSource) {
|
|
2204
|
+
if (haveNew) {
|
|
2205
|
+
data.push(defaultValue ? { ...defaultValue, "fieldKey": generateUUID() } : {});
|
|
2206
|
+
}
|
|
2212
2207
|
}
|
|
2208
|
+
setDataSource([...data]);
|
|
2213
2209
|
};
|
|
2214
2210
|
useEffect5(() => {
|
|
2215
2211
|
if (setSelectedItem) {
|
|
@@ -2293,9 +2289,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2293
2289
|
if (fieldKey) {
|
|
2294
2290
|
dataSource[indexRow][fieldKey] = defaultValue[fieldKey];
|
|
2295
2291
|
}
|
|
2296
|
-
|
|
2297
|
-
setDataSource([...dataSource]);
|
|
2298
|
-
}
|
|
2292
|
+
changeDataSource(dataSource);
|
|
2299
2293
|
notificationSuccess(t("PasteSuccessful"));
|
|
2300
2294
|
}).catch((ex) => {
|
|
2301
2295
|
alert(ex);
|