react-table-edit 0.0.7 → 0.0.9
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +43 -26
- package/dist/index.mjs +42 -26
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -138,6 +138,7 @@ type FromItemsField = {
|
|
|
138
138
|
|
|
139
139
|
declare const notificationSuccess: (param: string) => string;
|
|
140
140
|
declare const messageBoxError: (t: TFunction<"translation", undefined>, message: string) => void;
|
|
141
|
+
declare const messageHtmlBoxConfirm: (t: TFunction<"translation", undefined>, message: any[], handle: any, data: any, title?: string) => void;
|
|
141
142
|
declare const messageHtmlBoxError: (t: TFunction<"translation", undefined>, message: any[], title?: string) => void;
|
|
142
143
|
declare const messageBoxConfirmDelete: (t: TFunction<"translation", undefined>, handle: any, data: any) => void;
|
|
143
144
|
declare const messageBoxConfirmApprove: (t: TFunction<"translation", undefined>, handle: any, data: any) => void;
|
|
@@ -145,4 +146,4 @@ declare const messageBoxConfirm: (t: TFunction<"translation", undefined>, handle
|
|
|
145
146
|
declare const notificationError: (param: string) => string;
|
|
146
147
|
declare const messageBoxConfirm2: (t: TFunction<"translation", undefined>, data: any, data2: any, message: string) => Promise<boolean>;
|
|
147
148
|
|
|
148
|
-
export { type FromItemsField, type IColumnTable, type ICommandItem, type IFCurrentPage, type IFCurrentPageConfig, type IFPageSize, type IFTableEditProps, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, TableEdit as default, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmApprove, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxError, notificationError, notificationSuccess };
|
|
149
|
+
export { type FromItemsField, type IColumnTable, type ICommandItem, type IFCurrentPage, type IFCurrentPageConfig, type IFPageSize, type IFTableEditProps, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, TableEdit as default, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmApprove, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess };
|
package/dist/index.d.ts
CHANGED
|
@@ -138,6 +138,7 @@ type FromItemsField = {
|
|
|
138
138
|
|
|
139
139
|
declare const notificationSuccess: (param: string) => string;
|
|
140
140
|
declare const messageBoxError: (t: TFunction<"translation", undefined>, message: string) => void;
|
|
141
|
+
declare const messageHtmlBoxConfirm: (t: TFunction<"translation", undefined>, message: any[], handle: any, data: any, title?: string) => void;
|
|
141
142
|
declare const messageHtmlBoxError: (t: TFunction<"translation", undefined>, message: any[], title?: string) => void;
|
|
142
143
|
declare const messageBoxConfirmDelete: (t: TFunction<"translation", undefined>, handle: any, data: any) => void;
|
|
143
144
|
declare const messageBoxConfirmApprove: (t: TFunction<"translation", undefined>, handle: any, data: any) => void;
|
|
@@ -145,4 +146,4 @@ declare const messageBoxConfirm: (t: TFunction<"translation", undefined>, handle
|
|
|
145
146
|
declare const notificationError: (param: string) => string;
|
|
146
147
|
declare const messageBoxConfirm2: (t: TFunction<"translation", undefined>, data: any, data2: any, message: string) => Promise<boolean>;
|
|
147
148
|
|
|
148
|
-
export { type FromItemsField, type IColumnTable, type ICommandItem, type IFCurrentPage, type IFCurrentPageConfig, type IFPageSize, type IFTableEditProps, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, TableEdit as default, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmApprove, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxError, notificationError, notificationSuccess };
|
|
149
|
+
export { type FromItemsField, type IColumnTable, type ICommandItem, type IFCurrentPage, type IFCurrentPageConfig, type IFPageSize, type IFTableEditProps, type ISettingFormElement, type ISettingNumericElement, type ISettingSelectElement, TableEdit as default, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmApprove, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess };
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __export(Table_edit_exports, {
|
|
|
36
36
|
messageBoxConfirmApprove: () => messageBoxConfirmApprove,
|
|
37
37
|
messageBoxConfirmDelete: () => messageBoxConfirmDelete,
|
|
38
38
|
messageBoxError: () => messageBoxError,
|
|
39
|
+
messageHtmlBoxConfirm: () => messageHtmlBoxConfirm,
|
|
39
40
|
messageHtmlBoxError: () => messageHtmlBoxError,
|
|
40
41
|
notificationError: () => notificationError,
|
|
41
42
|
notificationSuccess: () => notificationSuccess
|
|
@@ -113,6 +114,27 @@ var messageBoxError = (t, message) => {
|
|
|
113
114
|
buttonsStyling: false
|
|
114
115
|
});
|
|
115
116
|
};
|
|
117
|
+
var messageHtmlBoxConfirm = (t, message, handle, data, title) => {
|
|
118
|
+
MySwal.fire({
|
|
119
|
+
title: title ? t(title) : t("Important"),
|
|
120
|
+
html: message.map((item, index) => {
|
|
121
|
+
return `<div style="min-width: 448px padding: 7px width:100% border: 1px solid #e0e0e0${index !== 0 ? " border-top-width: 0px" : ""}">${item}</div>`;
|
|
122
|
+
}).join(""),
|
|
123
|
+
allowOutsideClick: false,
|
|
124
|
+
showCancelButton: true,
|
|
125
|
+
confirmButtonText: t("Ok"),
|
|
126
|
+
cancelButtonText: t("Cancel"),
|
|
127
|
+
customClass: {
|
|
128
|
+
confirmButton: "btn btn-primary",
|
|
129
|
+
cancelButton: "btn btn-danger ms-1"
|
|
130
|
+
},
|
|
131
|
+
buttonsStyling: false
|
|
132
|
+
}).then(async (result) => {
|
|
133
|
+
if (result.value) {
|
|
134
|
+
handle(data);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
};
|
|
116
138
|
var messageHtmlBoxError = (t, message, title) => {
|
|
117
139
|
MySwal.fire({
|
|
118
140
|
title: title ? t(title) : t("Important"),
|
|
@@ -1484,6 +1506,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
1484
1506
|
}
|
|
1485
1507
|
}
|
|
1486
1508
|
}
|
|
1509
|
+
changeDataSource(dataSource);
|
|
1487
1510
|
if (dataSourceChange) {
|
|
1488
1511
|
dataSourceChange(dataSource);
|
|
1489
1512
|
}
|
|
@@ -1503,9 +1526,10 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
1503
1526
|
}
|
|
1504
1527
|
}
|
|
1505
1528
|
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1529
|
+
changeDataSource(dataSource);
|
|
1530
|
+
if (dataSourceChange) {
|
|
1531
|
+
dataSourceChange(dataSource);
|
|
1532
|
+
}
|
|
1509
1533
|
}
|
|
1510
1534
|
}
|
|
1511
1535
|
};
|
|
@@ -2042,9 +2066,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2042
2066
|
}
|
|
2043
2067
|
if (e.code === "Tab" && indexCol === columnLastEdit) {
|
|
2044
2068
|
if (indexRow === dataSource?.length) {
|
|
2045
|
-
|
|
2046
|
-
setDataSource([...dataSource, defaultValue ? { ...defaultValue } : {}]);
|
|
2047
|
-
}
|
|
2069
|
+
changeDataSource(dataSource, true);
|
|
2048
2070
|
if (tableElement) {
|
|
2049
2071
|
setTimeout(() => {
|
|
2050
2072
|
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
@@ -2119,9 +2141,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2119
2141
|
}
|
|
2120
2142
|
});
|
|
2121
2143
|
const handleAdd = () => {
|
|
2122
|
-
|
|
2123
|
-
setDataSource([...dataSource, defaultValue ? { ...defaultValue, id: generateUUID() } : {}]);
|
|
2124
|
-
}
|
|
2144
|
+
changeDataSource(dataSource, true);
|
|
2125
2145
|
if (tableElement) {
|
|
2126
2146
|
setIndexFocus(dataSource?.length);
|
|
2127
2147
|
setTimeout(() => {
|
|
@@ -2140,9 +2160,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2140
2160
|
const deleteAll = () => {
|
|
2141
2161
|
if (!editDisable && !addDisable) {
|
|
2142
2162
|
setIndexFocus(-1);
|
|
2143
|
-
|
|
2144
|
-
setDataSource([]);
|
|
2145
|
-
}
|
|
2163
|
+
changeDataSource([], false);
|
|
2146
2164
|
}
|
|
2147
2165
|
};
|
|
2148
2166
|
const handleDuplicate = (data, index) => {
|
|
@@ -2157,9 +2175,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2157
2175
|
} else {
|
|
2158
2176
|
dataSource?.splice(index, 0, { ...data });
|
|
2159
2177
|
}
|
|
2160
|
-
|
|
2161
|
-
setDataSource([...dataSource]);
|
|
2162
|
-
}
|
|
2178
|
+
changeDataSource(dataSource);
|
|
2163
2179
|
if (tableElement && index === dataSource?.length) {
|
|
2164
2180
|
setTimeout(() => {
|
|
2165
2181
|
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
@@ -2170,9 +2186,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2170
2186
|
const handleInsertAfter = () => {
|
|
2171
2187
|
if (showBottomToolbar && !editDisable && !addDisable) {
|
|
2172
2188
|
dataSource?.splice((indexFocus ?? -1) + 1, 0, { ...defaultValue });
|
|
2173
|
-
|
|
2174
|
-
setDataSource([...dataSource]);
|
|
2175
|
-
}
|
|
2189
|
+
changeDataSource(dataSource);
|
|
2176
2190
|
if (tableElement && indexFocus === dataSource?.length) {
|
|
2177
2191
|
setTimeout(() => {
|
|
2178
2192
|
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
@@ -2183,9 +2197,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2183
2197
|
const handleInsertBefore = () => {
|
|
2184
2198
|
if (showBottomToolbar && !editDisable && !addDisable) {
|
|
2185
2199
|
dataSource?.splice(indexFocus ?? -1, 0, { ...defaultValue });
|
|
2186
|
-
|
|
2187
|
-
setDataSource([...dataSource]);
|
|
2188
|
-
}
|
|
2200
|
+
changeDataSource(dataSource);
|
|
2189
2201
|
}
|
|
2190
2202
|
};
|
|
2191
2203
|
const handleDeleteAll = () => {
|
|
@@ -2212,8 +2224,14 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2212
2224
|
rowChange(dataRow, row + indexRow, "");
|
|
2213
2225
|
});
|
|
2214
2226
|
handleRefeshRow();
|
|
2215
|
-
|
|
2216
|
-
|
|
2227
|
+
changeDataSource(dataSource);
|
|
2228
|
+
};
|
|
2229
|
+
const changeDataSource = (data, haveNew = false) => {
|
|
2230
|
+
if (!addDisable && setDataSource) {
|
|
2231
|
+
if (haveNew) {
|
|
2232
|
+
data.push(defaultValue ? { ...defaultValue, id: generateUUID() } : {});
|
|
2233
|
+
}
|
|
2234
|
+
setDataSource([...data]);
|
|
2217
2235
|
}
|
|
2218
2236
|
};
|
|
2219
2237
|
(0, import_react12.useEffect)(() => {
|
|
@@ -2298,9 +2316,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
2298
2316
|
if (fieldKey) {
|
|
2299
2317
|
dataSource[indexRow][fieldKey] = defaultValue[fieldKey];
|
|
2300
2318
|
}
|
|
2301
|
-
|
|
2302
|
-
setDataSource([...dataSource]);
|
|
2303
|
-
}
|
|
2319
|
+
changeDataSource(dataSource);
|
|
2304
2320
|
notificationSuccess(t("PasteSuccessful"));
|
|
2305
2321
|
}).catch((ex) => {
|
|
2306
2322
|
alert(ex);
|
|
@@ -2713,6 +2729,7 @@ var Table_edit_default = table_default;
|
|
|
2713
2729
|
messageBoxConfirmApprove,
|
|
2714
2730
|
messageBoxConfirmDelete,
|
|
2715
2731
|
messageBoxError,
|
|
2732
|
+
messageHtmlBoxConfirm,
|
|
2716
2733
|
messageHtmlBoxError,
|
|
2717
2734
|
notificationError,
|
|
2718
2735
|
notificationSuccess
|
package/dist/index.mjs
CHANGED
|
@@ -69,6 +69,27 @@ var messageBoxError = (t, message) => {
|
|
|
69
69
|
buttonsStyling: false
|
|
70
70
|
});
|
|
71
71
|
};
|
|
72
|
+
var messageHtmlBoxConfirm = (t, message, handle, data, title) => {
|
|
73
|
+
MySwal.fire({
|
|
74
|
+
title: title ? t(title) : t("Important"),
|
|
75
|
+
html: message.map((item, index) => {
|
|
76
|
+
return `<div style="min-width: 448px padding: 7px width:100% border: 1px solid #e0e0e0${index !== 0 ? " border-top-width: 0px" : ""}">${item}</div>`;
|
|
77
|
+
}).join(""),
|
|
78
|
+
allowOutsideClick: false,
|
|
79
|
+
showCancelButton: true,
|
|
80
|
+
confirmButtonText: t("Ok"),
|
|
81
|
+
cancelButtonText: t("Cancel"),
|
|
82
|
+
customClass: {
|
|
83
|
+
confirmButton: "btn btn-primary",
|
|
84
|
+
cancelButton: "btn btn-danger ms-1"
|
|
85
|
+
},
|
|
86
|
+
buttonsStyling: false
|
|
87
|
+
}).then(async (result) => {
|
|
88
|
+
if (result.value) {
|
|
89
|
+
handle(data);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
72
93
|
var messageHtmlBoxError = (t, message, title) => {
|
|
73
94
|
MySwal.fire({
|
|
74
95
|
title: title ? t(title) : t("Important"),
|
|
@@ -1458,6 +1479,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1458
1479
|
}
|
|
1459
1480
|
}
|
|
1460
1481
|
}
|
|
1482
|
+
changeDataSource(dataSource);
|
|
1461
1483
|
if (dataSourceChange) {
|
|
1462
1484
|
dataSourceChange(dataSource);
|
|
1463
1485
|
}
|
|
@@ -1477,9 +1499,10 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
1477
1499
|
}
|
|
1478
1500
|
}
|
|
1479
1501
|
}
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1502
|
+
changeDataSource(dataSource);
|
|
1503
|
+
if (dataSourceChange) {
|
|
1504
|
+
dataSourceChange(dataSource);
|
|
1505
|
+
}
|
|
1483
1506
|
}
|
|
1484
1507
|
}
|
|
1485
1508
|
};
|
|
@@ -2016,9 +2039,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2016
2039
|
}
|
|
2017
2040
|
if (e.code === "Tab" && indexCol === columnLastEdit) {
|
|
2018
2041
|
if (indexRow === dataSource?.length) {
|
|
2019
|
-
|
|
2020
|
-
setDataSource([...dataSource, defaultValue ? { ...defaultValue } : {}]);
|
|
2021
|
-
}
|
|
2042
|
+
changeDataSource(dataSource, true);
|
|
2022
2043
|
if (tableElement) {
|
|
2023
2044
|
setTimeout(() => {
|
|
2024
2045
|
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
@@ -2093,9 +2114,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2093
2114
|
}
|
|
2094
2115
|
});
|
|
2095
2116
|
const handleAdd = () => {
|
|
2096
|
-
|
|
2097
|
-
setDataSource([...dataSource, defaultValue ? { ...defaultValue, id: generateUUID() } : {}]);
|
|
2098
|
-
}
|
|
2117
|
+
changeDataSource(dataSource, true);
|
|
2099
2118
|
if (tableElement) {
|
|
2100
2119
|
setIndexFocus(dataSource?.length);
|
|
2101
2120
|
setTimeout(() => {
|
|
@@ -2114,9 +2133,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2114
2133
|
const deleteAll = () => {
|
|
2115
2134
|
if (!editDisable && !addDisable) {
|
|
2116
2135
|
setIndexFocus(-1);
|
|
2117
|
-
|
|
2118
|
-
setDataSource([]);
|
|
2119
|
-
}
|
|
2136
|
+
changeDataSource([], false);
|
|
2120
2137
|
}
|
|
2121
2138
|
};
|
|
2122
2139
|
const handleDuplicate = (data, index) => {
|
|
@@ -2131,9 +2148,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2131
2148
|
} else {
|
|
2132
2149
|
dataSource?.splice(index, 0, { ...data });
|
|
2133
2150
|
}
|
|
2134
|
-
|
|
2135
|
-
setDataSource([...dataSource]);
|
|
2136
|
-
}
|
|
2151
|
+
changeDataSource(dataSource);
|
|
2137
2152
|
if (tableElement && index === dataSource?.length) {
|
|
2138
2153
|
setTimeout(() => {
|
|
2139
2154
|
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
@@ -2144,9 +2159,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2144
2159
|
const handleInsertAfter = () => {
|
|
2145
2160
|
if (showBottomToolbar && !editDisable && !addDisable) {
|
|
2146
2161
|
dataSource?.splice((indexFocus ?? -1) + 1, 0, { ...defaultValue });
|
|
2147
|
-
|
|
2148
|
-
setDataSource([...dataSource]);
|
|
2149
|
-
}
|
|
2162
|
+
changeDataSource(dataSource);
|
|
2150
2163
|
if (tableElement && indexFocus === dataSource?.length) {
|
|
2151
2164
|
setTimeout(() => {
|
|
2152
2165
|
tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
|
|
@@ -2157,9 +2170,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2157
2170
|
const handleInsertBefore = () => {
|
|
2158
2171
|
if (showBottomToolbar && !editDisable && !addDisable) {
|
|
2159
2172
|
dataSource?.splice(indexFocus ?? -1, 0, { ...defaultValue });
|
|
2160
|
-
|
|
2161
|
-
setDataSource([...dataSource]);
|
|
2162
|
-
}
|
|
2173
|
+
changeDataSource(dataSource);
|
|
2163
2174
|
}
|
|
2164
2175
|
};
|
|
2165
2176
|
const handleDeleteAll = () => {
|
|
@@ -2186,8 +2197,14 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2186
2197
|
rowChange(dataRow, row + indexRow, "");
|
|
2187
2198
|
});
|
|
2188
2199
|
handleRefeshRow();
|
|
2189
|
-
|
|
2190
|
-
|
|
2200
|
+
changeDataSource(dataSource);
|
|
2201
|
+
};
|
|
2202
|
+
const changeDataSource = (data, haveNew = false) => {
|
|
2203
|
+
if (!addDisable && setDataSource) {
|
|
2204
|
+
if (haveNew) {
|
|
2205
|
+
data.push(defaultValue ? { ...defaultValue, id: generateUUID() } : {});
|
|
2206
|
+
}
|
|
2207
|
+
setDataSource([...data]);
|
|
2191
2208
|
}
|
|
2192
2209
|
};
|
|
2193
2210
|
useEffect5(() => {
|
|
@@ -2272,9 +2289,7 @@ var TableEdit = forwardRef2((props, ref) => {
|
|
|
2272
2289
|
if (fieldKey) {
|
|
2273
2290
|
dataSource[indexRow][fieldKey] = defaultValue[fieldKey];
|
|
2274
2291
|
}
|
|
2275
|
-
|
|
2276
|
-
setDataSource([...dataSource]);
|
|
2277
|
-
}
|
|
2292
|
+
changeDataSource(dataSource);
|
|
2278
2293
|
notificationSuccess(t("PasteSuccessful"));
|
|
2279
2294
|
}).catch((ex) => {
|
|
2280
2295
|
alert(ex);
|
|
@@ -2687,6 +2702,7 @@ export {
|
|
|
2687
2702
|
messageBoxConfirmApprove,
|
|
2688
2703
|
messageBoxConfirmDelete,
|
|
2689
2704
|
messageBoxError,
|
|
2705
|
+
messageHtmlBoxConfirm,
|
|
2690
2706
|
messageHtmlBoxError,
|
|
2691
2707
|
notificationError,
|
|
2692
2708
|
notificationSuccess
|