react-table-edit 0.1.3 → 0.1.5

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 CHANGED
@@ -80,6 +80,7 @@ type IFTableEditProps = {
80
80
  setDataSource?: any;
81
81
  commandClick?: any;
82
82
  rowChange?: any;
83
+ handleSelect?: any;
83
84
  dataSourceChange?: any;
84
85
  allowPaging?: boolean;
85
86
  pageSize?: number;
@@ -136,14 +137,13 @@ type FromItemsField = {
136
137
  options?: any[];
137
138
  };
138
139
 
139
- declare const notificationSuccess: (param: string) => string;
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;
142
- declare const messageHtmlBoxError: (t: TFunction<"translation", undefined>, message: any[], title?: string) => void;
140
+ declare const messageHtmlBoxConfirm: (t: TFunction<"translation", undefined>, message: any[], handle: any, data: any, title?: string, btnOk?: string, btnCancel?: string) => void;
141
+ declare const messageHtmlBoxError: (t: TFunction<"translation", undefined>, message: any[], title?: string, btnCancel?: string) => void;
143
142
  declare const messageBoxConfirmDelete: (t: TFunction<"translation", undefined>, handle: any, data: any) => void;
144
- declare const messageBoxConfirmApprove: (t: TFunction<"translation", undefined>, handle: any, data: any) => void;
145
- declare const messageBoxConfirm: (t: TFunction<"translation", undefined>, handle: any, data: any, message: string) => void;
143
+ declare const messageBoxConfirm: (t: TFunction<"translation", undefined>, handle: any, data: any, message: string, title?: string, btnOk?: string, btnCancel?: string) => void;
144
+ declare const messageBoxError: (t: TFunction<"translation", undefined>, message: string, title?: string, btnCancel?: string) => void;
146
145
  declare const notificationError: (param: string) => string;
146
+ declare const notificationSuccess: (param: string) => string;
147
147
  declare const messageBoxConfirm2: (t: TFunction<"translation", undefined>, data: any, data2: any, message: string) => Promise<boolean>;
148
148
 
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 };
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, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess };
package/dist/index.d.ts CHANGED
@@ -80,6 +80,7 @@ type IFTableEditProps = {
80
80
  setDataSource?: any;
81
81
  commandClick?: any;
82
82
  rowChange?: any;
83
+ handleSelect?: any;
83
84
  dataSourceChange?: any;
84
85
  allowPaging?: boolean;
85
86
  pageSize?: number;
@@ -136,14 +137,13 @@ type FromItemsField = {
136
137
  options?: any[];
137
138
  };
138
139
 
139
- declare const notificationSuccess: (param: string) => string;
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;
142
- declare const messageHtmlBoxError: (t: TFunction<"translation", undefined>, message: any[], title?: string) => void;
140
+ declare const messageHtmlBoxConfirm: (t: TFunction<"translation", undefined>, message: any[], handle: any, data: any, title?: string, btnOk?: string, btnCancel?: string) => void;
141
+ declare const messageHtmlBoxError: (t: TFunction<"translation", undefined>, message: any[], title?: string, btnCancel?: string) => void;
143
142
  declare const messageBoxConfirmDelete: (t: TFunction<"translation", undefined>, handle: any, data: any) => void;
144
- declare const messageBoxConfirmApprove: (t: TFunction<"translation", undefined>, handle: any, data: any) => void;
145
- declare const messageBoxConfirm: (t: TFunction<"translation", undefined>, handle: any, data: any, message: string) => void;
143
+ declare const messageBoxConfirm: (t: TFunction<"translation", undefined>, handle: any, data: any, message: string, title?: string, btnOk?: string, btnCancel?: string) => void;
144
+ declare const messageBoxError: (t: TFunction<"translation", undefined>, message: string, title?: string, btnCancel?: string) => void;
146
145
  declare const notificationError: (param: string) => string;
146
+ declare const notificationSuccess: (param: string) => string;
147
147
  declare const messageBoxConfirm2: (t: TFunction<"translation", undefined>, data: any, data2: any, message: string) => Promise<boolean>;
148
148
 
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 };
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, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess };
package/dist/index.js CHANGED
@@ -33,7 +33,6 @@ __export(Table_edit_exports, {
33
33
  default: () => Table_edit_default,
34
34
  messageBoxConfirm: () => messageBoxConfirm,
35
35
  messageBoxConfirm2: () => messageBoxConfirm2,
36
- messageBoxConfirmApprove: () => messageBoxConfirmApprove,
37
36
  messageBoxConfirmDelete: () => messageBoxConfirmDelete,
38
37
  messageBoxError: () => messageBoxError,
39
38
  messageHtmlBoxConfirm: () => messageHtmlBoxConfirm,
@@ -92,38 +91,16 @@ var import_sweetalert2_react_content = __toESM(require("sweetalert2-react-conten
92
91
  var import_react_hot_toast = __toESM(require("react-hot-toast"));
93
92
  var import_jsx_runtime2 = require("react/jsx-runtime");
94
93
  var MySwal = (0, import_sweetalert2_react_content.default)(import_sweetalert2.default);
95
- var notificationSuccess = (param) => {
96
- return import_react_hot_toast.default.success(
97
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react2.Fragment, { children: [
98
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "toastify-header", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "title-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h6", { className: "toast-title", children: param }) }) }),
99
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "toastify-body", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { className: "list-unstyled mb-0", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", {}) }) })
100
- ] })
101
- );
102
- };
103
- var messageBoxError = (t, message) => {
94
+ var messageHtmlBoxConfirm = (t, message, handle, data, title = "Important", btnOk = "Ok", btnCancel = "Cancel") => {
104
95
  MySwal.fire({
105
- title: t("Important"),
106
- text: t(message),
107
- allowOutsideClick: false,
108
- showCancelButton: true,
109
- showConfirmButton: false,
110
- cancelButtonText: t("Ok"),
111
- customClass: {
112
- cancelButton: "btn btn-danger ms-1"
113
- },
114
- buttonsStyling: false
115
- });
116
- };
117
- var messageHtmlBoxConfirm = (t, message, handle, data, title) => {
118
- MySwal.fire({
119
- title: title ? t(title) : t("Important"),
96
+ title: t(title),
120
97
  html: message.map((item, index) => {
121
98
  return `<div style="min-width: 448px padding: 7px width:100% border: 1px solid #e0e0e0${index !== 0 ? " border-top-width: 0px" : ""}">${item}</div>`;
122
99
  }).join(""),
123
100
  allowOutsideClick: false,
124
101
  showCancelButton: true,
125
- confirmButtonText: t("Ok"),
126
- cancelButtonText: t("Cancel"),
102
+ confirmButtonText: t(btnOk),
103
+ cancelButtonText: t(btnCancel),
127
104
  customClass: {
128
105
  confirmButton: "btn btn-primary",
129
106
  cancelButton: "btn btn-danger ms-1"
@@ -135,16 +112,16 @@ var messageHtmlBoxConfirm = (t, message, handle, data, title) => {
135
112
  }
136
113
  });
137
114
  };
138
- var messageHtmlBoxError = (t, message, title) => {
115
+ var messageHtmlBoxError = (t, message, title = "Important", btnCancel = "Ok") => {
139
116
  MySwal.fire({
140
- title: title ? t(title) : t("Important"),
117
+ title: t(title),
141
118
  html: message.map((item, index) => {
142
119
  return `<div style="min-width: 448px padding: 7px width:100% border: 1px solid #e0e0e0${index !== 0 ? " border-top-width: 0px" : ""}">${item}</div>`;
143
120
  }).join(""),
144
121
  allowOutsideClick: false,
145
122
  showCancelButton: true,
146
123
  showConfirmButton: false,
147
- cancelButtonText: t("Ok"),
124
+ cancelButtonText: t(btnCancel),
148
125
  width: "auto",
149
126
  customClass: {
150
127
  cancelButton: "btn btn-danger ms-1"
@@ -171,14 +148,14 @@ var messageBoxConfirmDelete = (t, handle, data) => {
171
148
  }
172
149
  });
173
150
  };
174
- var messageBoxConfirmApprove = (t, handle, data) => {
151
+ var messageBoxConfirm = (t, handle, data, message, title = "Important", btnOk = "Ok", btnCancel = "Cancel") => {
175
152
  MySwal.fire({
176
- title: t("Confirm"),
177
- text: t("Do you want to approve item?"),
153
+ title: t(title),
154
+ text: t(message),
178
155
  allowOutsideClick: false,
179
156
  showCancelButton: true,
180
- confirmButtonText: t("Approve"),
181
- cancelButtonText: t("Cancel"),
157
+ confirmButtonText: t(btnOk),
158
+ cancelButtonText: t(btnCancel),
182
159
  customClass: {
183
160
  confirmButton: "btn btn-primary",
184
161
  cancelButton: "btn btn-danger ms-1"
@@ -190,23 +167,18 @@ var messageBoxConfirmApprove = (t, handle, data) => {
190
167
  }
191
168
  });
192
169
  };
193
- var messageBoxConfirm = (t, handle, data, message) => {
170
+ var messageBoxError = (t, message, title = "Important", btnCancel = "Ok") => {
194
171
  MySwal.fire({
195
- title: t("Confirm"),
172
+ title: t(title),
196
173
  text: t(message),
197
174
  allowOutsideClick: false,
198
175
  showCancelButton: true,
199
- confirmButtonText: t("Ok"),
200
- cancelButtonText: t("Cancel"),
176
+ showConfirmButton: false,
177
+ cancelButtonText: t(btnCancel),
201
178
  customClass: {
202
- confirmButton: "btn btn-primary",
203
179
  cancelButton: "btn btn-danger ms-1"
204
180
  },
205
181
  buttonsStyling: false
206
- }).then(async (result) => {
207
- if (result.value) {
208
- handle(data);
209
- }
210
182
  });
211
183
  };
212
184
  var notificationError = (param) => {
@@ -217,6 +189,14 @@ var notificationError = (param) => {
217
189
  ] })
218
190
  );
219
191
  };
192
+ var notificationSuccess = (param) => {
193
+ return import_react_hot_toast.default.success(
194
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react2.Fragment, { children: [
195
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "toastify-header", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "title-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h6", { className: "toast-title", children: param }) }) }),
196
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "toastify-body", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { className: "list-unstyled mb-0", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", {}) }) })
197
+ ] })
198
+ );
199
+ };
220
200
  var messageBoxConfirm2 = async (t, data, data2, message) => {
221
201
  return new Promise((resolve) => {
222
202
  MySwal.fire({
@@ -1437,6 +1417,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1437
1417
  duplicateDisable,
1438
1418
  decimalSeparator = ",",
1439
1419
  thousandSeparator = ".",
1420
+ handleSelect,
1440
1421
  isMulti
1441
1422
  } = props;
1442
1423
  (0, import_react12.useImperativeHandle)(ref, () => {
@@ -2248,14 +2229,23 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2248
2229
  if (isMulti) {
2249
2230
  if (dataSource && selectedRows && selectedRows?.length !== selectedItem?.length) {
2250
2231
  setSelectedItem([...selectedRows]);
2232
+ if (handleSelect) {
2233
+ handleSelect([...selectedRows]);
2234
+ }
2251
2235
  }
2252
2236
  } else {
2253
2237
  if (dataSource && selectedRows?.length > 0) {
2254
2238
  if (!selectedItem || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
2255
2239
  setSelectedItem({ ...selectedRows[0] });
2240
+ if (handleSelect) {
2241
+ handleSelect({ ...selectedRows[0] });
2242
+ }
2256
2243
  }
2257
2244
  } else {
2258
2245
  setSelectedItem(void 0);
2246
+ if (handleSelect) {
2247
+ handleSelect(void 0);
2248
+ }
2259
2249
  }
2260
2250
  }
2261
2251
  }
@@ -2735,7 +2725,6 @@ var Table_edit_default = table_default;
2735
2725
  0 && (module.exports = {
2736
2726
  messageBoxConfirm,
2737
2727
  messageBoxConfirm2,
2738
- messageBoxConfirmApprove,
2739
2728
  messageBoxConfirmDelete,
2740
2729
  messageBoxError,
2741
2730
  messageHtmlBoxConfirm,
package/dist/index.mjs CHANGED
@@ -47,38 +47,16 @@ import withReactContent from "sweetalert2-react-content";
47
47
  import toast from "react-hot-toast";
48
48
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
49
49
  var MySwal = withReactContent(Swal);
50
- var notificationSuccess = (param) => {
51
- return toast.success(
52
- /* @__PURE__ */ jsxs2(Fragment2, { children: [
53
- /* @__PURE__ */ jsx2("div", { className: "toastify-header", children: /* @__PURE__ */ jsx2("div", { className: "title-wrapper", children: /* @__PURE__ */ jsx2("h6", { className: "toast-title", children: param }) }) }),
54
- /* @__PURE__ */ jsx2("div", { className: "toastify-body", children: /* @__PURE__ */ jsx2("ul", { className: "list-unstyled mb-0", children: /* @__PURE__ */ jsx2("li", {}) }) })
55
- ] })
56
- );
57
- };
58
- var messageBoxError = (t, message) => {
50
+ var messageHtmlBoxConfirm = (t, message, handle, data, title = "Important", btnOk = "Ok", btnCancel = "Cancel") => {
59
51
  MySwal.fire({
60
- title: t("Important"),
61
- text: t(message),
62
- allowOutsideClick: false,
63
- showCancelButton: true,
64
- showConfirmButton: false,
65
- cancelButtonText: t("Ok"),
66
- customClass: {
67
- cancelButton: "btn btn-danger ms-1"
68
- },
69
- buttonsStyling: false
70
- });
71
- };
72
- var messageHtmlBoxConfirm = (t, message, handle, data, title) => {
73
- MySwal.fire({
74
- title: title ? t(title) : t("Important"),
52
+ title: t(title),
75
53
  html: message.map((item, index) => {
76
54
  return `<div style="min-width: 448px padding: 7px width:100% border: 1px solid #e0e0e0${index !== 0 ? " border-top-width: 0px" : ""}">${item}</div>`;
77
55
  }).join(""),
78
56
  allowOutsideClick: false,
79
57
  showCancelButton: true,
80
- confirmButtonText: t("Ok"),
81
- cancelButtonText: t("Cancel"),
58
+ confirmButtonText: t(btnOk),
59
+ cancelButtonText: t(btnCancel),
82
60
  customClass: {
83
61
  confirmButton: "btn btn-primary",
84
62
  cancelButton: "btn btn-danger ms-1"
@@ -90,16 +68,16 @@ var messageHtmlBoxConfirm = (t, message, handle, data, title) => {
90
68
  }
91
69
  });
92
70
  };
93
- var messageHtmlBoxError = (t, message, title) => {
71
+ var messageHtmlBoxError = (t, message, title = "Important", btnCancel = "Ok") => {
94
72
  MySwal.fire({
95
- title: title ? t(title) : t("Important"),
73
+ title: t(title),
96
74
  html: message.map((item, index) => {
97
75
  return `<div style="min-width: 448px padding: 7px width:100% border: 1px solid #e0e0e0${index !== 0 ? " border-top-width: 0px" : ""}">${item}</div>`;
98
76
  }).join(""),
99
77
  allowOutsideClick: false,
100
78
  showCancelButton: true,
101
79
  showConfirmButton: false,
102
- cancelButtonText: t("Ok"),
80
+ cancelButtonText: t(btnCancel),
103
81
  width: "auto",
104
82
  customClass: {
105
83
  cancelButton: "btn btn-danger ms-1"
@@ -126,14 +104,14 @@ var messageBoxConfirmDelete = (t, handle, data) => {
126
104
  }
127
105
  });
128
106
  };
129
- var messageBoxConfirmApprove = (t, handle, data) => {
107
+ var messageBoxConfirm = (t, handle, data, message, title = "Important", btnOk = "Ok", btnCancel = "Cancel") => {
130
108
  MySwal.fire({
131
- title: t("Confirm"),
132
- text: t("Do you want to approve item?"),
109
+ title: t(title),
110
+ text: t(message),
133
111
  allowOutsideClick: false,
134
112
  showCancelButton: true,
135
- confirmButtonText: t("Approve"),
136
- cancelButtonText: t("Cancel"),
113
+ confirmButtonText: t(btnOk),
114
+ cancelButtonText: t(btnCancel),
137
115
  customClass: {
138
116
  confirmButton: "btn btn-primary",
139
117
  cancelButton: "btn btn-danger ms-1"
@@ -145,23 +123,18 @@ var messageBoxConfirmApprove = (t, handle, data) => {
145
123
  }
146
124
  });
147
125
  };
148
- var messageBoxConfirm = (t, handle, data, message) => {
126
+ var messageBoxError = (t, message, title = "Important", btnCancel = "Ok") => {
149
127
  MySwal.fire({
150
- title: t("Confirm"),
128
+ title: t(title),
151
129
  text: t(message),
152
130
  allowOutsideClick: false,
153
131
  showCancelButton: true,
154
- confirmButtonText: t("Ok"),
155
- cancelButtonText: t("Cancel"),
132
+ showConfirmButton: false,
133
+ cancelButtonText: t(btnCancel),
156
134
  customClass: {
157
- confirmButton: "btn btn-primary",
158
135
  cancelButton: "btn btn-danger ms-1"
159
136
  },
160
137
  buttonsStyling: false
161
- }).then(async (result) => {
162
- if (result.value) {
163
- handle(data);
164
- }
165
138
  });
166
139
  };
167
140
  var notificationError = (param) => {
@@ -172,6 +145,14 @@ var notificationError = (param) => {
172
145
  ] })
173
146
  );
174
147
  };
148
+ var notificationSuccess = (param) => {
149
+ return toast.success(
150
+ /* @__PURE__ */ jsxs2(Fragment2, { children: [
151
+ /* @__PURE__ */ jsx2("div", { className: "toastify-header", children: /* @__PURE__ */ jsx2("div", { className: "title-wrapper", children: /* @__PURE__ */ jsx2("h6", { className: "toast-title", children: param }) }) }),
152
+ /* @__PURE__ */ jsx2("div", { className: "toastify-body", children: /* @__PURE__ */ jsx2("ul", { className: "list-unstyled mb-0", children: /* @__PURE__ */ jsx2("li", {}) }) })
153
+ ] })
154
+ );
155
+ };
175
156
  var messageBoxConfirm2 = async (t, data, data2, message) => {
176
157
  return new Promise((resolve) => {
177
158
  MySwal.fire({
@@ -1410,6 +1391,7 @@ var TableEdit = forwardRef2((props, ref) => {
1410
1391
  duplicateDisable,
1411
1392
  decimalSeparator = ",",
1412
1393
  thousandSeparator = ".",
1394
+ handleSelect,
1413
1395
  isMulti
1414
1396
  } = props;
1415
1397
  useImperativeHandle(ref, () => {
@@ -2221,14 +2203,23 @@ var TableEdit = forwardRef2((props, ref) => {
2221
2203
  if (isMulti) {
2222
2204
  if (dataSource && selectedRows && selectedRows?.length !== selectedItem?.length) {
2223
2205
  setSelectedItem([...selectedRows]);
2206
+ if (handleSelect) {
2207
+ handleSelect([...selectedRows]);
2208
+ }
2224
2209
  }
2225
2210
  } else {
2226
2211
  if (dataSource && selectedRows?.length > 0) {
2227
2212
  if (!selectedItem || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
2228
2213
  setSelectedItem({ ...selectedRows[0] });
2214
+ if (handleSelect) {
2215
+ handleSelect({ ...selectedRows[0] });
2216
+ }
2229
2217
  }
2230
2218
  } else {
2231
2219
  setSelectedItem(void 0);
2220
+ if (handleSelect) {
2221
+ handleSelect(void 0);
2222
+ }
2232
2223
  }
2233
2224
  }
2234
2225
  }
@@ -2708,7 +2699,6 @@ export {
2708
2699
  Table_edit_default as default,
2709
2700
  messageBoxConfirm,
2710
2701
  messageBoxConfirm2,
2711
- messageBoxConfirmApprove,
2712
2702
  messageBoxConfirmDelete,
2713
2703
  messageBoxError,
2714
2704
  messageHtmlBoxConfirm,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-table-edit",
3
3
  "license": "MIT",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",