react-table-edit 0.0.1

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 ADDED
@@ -0,0 +1,2677 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // index.ts
31
+ var Table_edit_exports = {};
32
+ __export(Table_edit_exports, {
33
+ default: () => Table_edit_default,
34
+ messageBoxConfirm: () => messageBoxConfirm,
35
+ messageBoxConfirm2: () => messageBoxConfirm2,
36
+ messageBoxConfirmApprove: () => messageBoxConfirmApprove,
37
+ messageBoxConfirmDelete: () => messageBoxConfirmDelete,
38
+ messageBoxError: () => messageBoxError,
39
+ messageHtmlBoxError: () => messageHtmlBoxError,
40
+ notificationError: () => notificationError,
41
+ notificationSuccess: () => notificationSuccess
42
+ });
43
+ module.exports = __toCommonJS(Table_edit_exports);
44
+
45
+ // test-app/component/table/index.tsx
46
+ var import_react12 = require("react");
47
+ var import_reactstrap8 = require("reactstrap");
48
+ var import_classnames9 = __toESM(require("classnames"));
49
+ var import_react_i18next8 = require("react-i18next");
50
+ var import_react_select2 = __toESM(require("react-select"));
51
+ var import_ej2_react_grids2 = require("@syncfusion/ej2-react-grids");
52
+ var import_async = __toESM(require("react-select/async"));
53
+ var import_becoxy_icons4 = require("becoxy-icons");
54
+
55
+ // test-app/component/react-input/index.tsx
56
+ var import_becoxy_icons = require("becoxy-icons");
57
+ var import_classnames = __toESM(require("classnames"));
58
+ var import_react = require("react");
59
+ var import_reactstrap = require("reactstrap");
60
+ var import_jsx_runtime = require("react/jsx-runtime");
61
+ var ReactInput = (props) => {
62
+ const { setSearchTerm, onKeyPress, placeholder, style } = props;
63
+ const [value, setValue] = (0, import_react.useState)(props.value);
64
+ const handelClear = () => {
65
+ setValue("");
66
+ setSearchTerm("");
67
+ };
68
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
69
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
+ import_reactstrap.Input,
71
+ {
72
+ style,
73
+ placeholder,
74
+ onKeyPress,
75
+ className: (0, import_classnames.default)("input__value", {
76
+ "is-clearable": value
77
+ }),
78
+ value,
79
+ onChange: (val) => setValue(val.target.value)
80
+ }
81
+ ),
82
+ value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_becoxy_icons.X, { className: "input__clear-icon", onClick: handelClear, strokeWidth: 3, fontSize: 16 }) : ""
83
+ ] }) });
84
+ };
85
+ var react_input_default = ReactInput;
86
+
87
+ // test-app/component/notifications.tsx
88
+ var import_react2 = require("react");
89
+ var import_sweetalert2 = __toESM(require("sweetalert2"));
90
+ var import_sweetalert2_react_content = __toESM(require("sweetalert2-react-content"));
91
+ var import_react_hot_toast = __toESM(require("react-hot-toast"));
92
+ var import_jsx_runtime2 = require("react/jsx-runtime");
93
+ var MySwal = (0, import_sweetalert2_react_content.default)(import_sweetalert2.default);
94
+ var notificationSuccess = (param) => {
95
+ return import_react_hot_toast.default.success(
96
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react2.Fragment, { children: [
97
+ /* @__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 }) }) }),
98
+ /* @__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", {}) }) })
99
+ ] })
100
+ );
101
+ };
102
+ var messageBoxError = (t, message) => {
103
+ MySwal.fire({
104
+ title: t("Important"),
105
+ text: t(message),
106
+ allowOutsideClick: false,
107
+ showCancelButton: true,
108
+ showConfirmButton: false,
109
+ cancelButtonText: t("Ok"),
110
+ customClass: {
111
+ cancelButton: "btn btn-danger ms-1"
112
+ },
113
+ buttonsStyling: false
114
+ });
115
+ };
116
+ var messageHtmlBoxError = (t, message, title) => {
117
+ MySwal.fire({
118
+ title: title ? t(title) : t("Important"),
119
+ html: message.map((item, index) => {
120
+ return `<div style="min-width: 448px padding: 7px width:100% border: 1px solid #e0e0e0${index !== 0 ? " border-top-width: 0px" : ""}">${item}</div>`;
121
+ }).join(""),
122
+ allowOutsideClick: false,
123
+ showCancelButton: true,
124
+ showConfirmButton: false,
125
+ cancelButtonText: t("Ok"),
126
+ width: "auto",
127
+ customClass: {
128
+ cancelButton: "btn btn-danger ms-1"
129
+ },
130
+ buttonsStyling: false
131
+ });
132
+ };
133
+ var messageBoxConfirmDelete = (t, handle, data) => {
134
+ MySwal.fire({
135
+ title: t("Confirm"),
136
+ text: t("Do you want to delete item?"),
137
+ allowOutsideClick: false,
138
+ showCancelButton: true,
139
+ confirmButtonText: t("Delete"),
140
+ cancelButtonText: t("Cancel"),
141
+ customClass: {
142
+ confirmButton: "btn btn-primary",
143
+ cancelButton: "btn btn-danger ms-1"
144
+ },
145
+ buttonsStyling: false
146
+ }).then(async (result) => {
147
+ if (result.value) {
148
+ handle(data);
149
+ }
150
+ });
151
+ };
152
+ var messageBoxConfirmApprove = (t, handle, data) => {
153
+ MySwal.fire({
154
+ title: t("Confirm"),
155
+ text: t("Do you want to approve item?"),
156
+ allowOutsideClick: false,
157
+ showCancelButton: true,
158
+ confirmButtonText: t("Approve"),
159
+ cancelButtonText: t("Cancel"),
160
+ customClass: {
161
+ confirmButton: "btn btn-primary",
162
+ cancelButton: "btn btn-danger ms-1"
163
+ },
164
+ buttonsStyling: false
165
+ }).then(async (result) => {
166
+ if (result.value) {
167
+ handle(data);
168
+ }
169
+ });
170
+ };
171
+ var messageBoxConfirm = (t, handle, data, message) => {
172
+ MySwal.fire({
173
+ title: t("Confirm"),
174
+ text: t(message),
175
+ allowOutsideClick: false,
176
+ showCancelButton: true,
177
+ confirmButtonText: t("Ok"),
178
+ cancelButtonText: t("Cancel"),
179
+ customClass: {
180
+ confirmButton: "btn btn-primary",
181
+ cancelButton: "btn btn-danger ms-1"
182
+ },
183
+ buttonsStyling: false
184
+ }).then(async (result) => {
185
+ if (result.value) {
186
+ handle(data);
187
+ }
188
+ });
189
+ };
190
+ var notificationError = (param) => {
191
+ return import_react_hot_toast.default.error(
192
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react2.Fragment, { children: [
193
+ /* @__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 }) }) }),
194
+ /* @__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", {}) }) })
195
+ ] })
196
+ );
197
+ };
198
+ var messageBoxConfirm2 = async (t, data, data2, message) => {
199
+ return new Promise((resolve) => {
200
+ MySwal.fire({
201
+ title: t("Confirm"),
202
+ text: t(message),
203
+ allowOutsideClick: false,
204
+ showCancelButton: true,
205
+ confirmButtonText: t("Ok"),
206
+ cancelButtonText: t("Cancel"),
207
+ customClass: {
208
+ confirmButton: "btn btn-primary",
209
+ cancelButton: "btn btn-danger ms-1"
210
+ },
211
+ buttonsStyling: false
212
+ }).then((result) => {
213
+ if (result.isConfirmed) {
214
+ resolve(true);
215
+ } else {
216
+ resolve(false);
217
+ }
218
+ });
219
+ });
220
+ };
221
+
222
+ // test-app/component/utils.ts
223
+ var import_react3 = require("react");
224
+ var useOnClickOutside = (ref, handler) => {
225
+ (0, import_react3.useEffect)(
226
+ () => {
227
+ const listener = (event) => {
228
+ if (!ref.current || ref.current.contains(event.target)) {
229
+ return;
230
+ }
231
+ handler(event);
232
+ };
233
+ document.addEventListener("mousedown", listener);
234
+ document.addEventListener("touchstart", listener);
235
+ return () => {
236
+ document.removeEventListener("mousedown", listener);
237
+ document.removeEventListener("touchstart", listener);
238
+ };
239
+ },
240
+ // ** Add ref and handler to effect dependencies
241
+ // ** It's worth noting that because passed in handler is a new ...
242
+ // ** ... function on every render that will cause this effect ...
243
+ // ** ... callback/cleanup to run every render. It's not a big deal ...
244
+ // ** ... but to optimize you can wrap handler in useCallback before ...
245
+ // ** ... passing it into this hook.
246
+ [ref, handler]
247
+ );
248
+ };
249
+ var isNullOrUndefined = (d) => {
250
+ if (d === null || d === void 0) {
251
+ return true;
252
+ }
253
+ return false;
254
+ };
255
+ var generateUUID = () => {
256
+ let d = (/* @__PURE__ */ new Date()).getTime();
257
+ let d2 = typeof performance !== "undefined" && performance.now && performance.now() * 1e3 || 0;
258
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
259
+ let r = Math.random() * 16;
260
+ if (d > 0) {
261
+ r = (d + r) % 16 | 0;
262
+ d = Math.floor(d / 16);
263
+ } else {
264
+ r = (d2 + r) % 16 | 0;
265
+ d2 = Math.floor(d2 / 16);
266
+ }
267
+ return (c === "x" ? r : 3).toString(16);
268
+ });
269
+ };
270
+ var formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10, isDone) => {
271
+ if (str || str == "0") {
272
+ str = str.toString();
273
+ const value = decimalSeparator !== "." ? str.toString().replaceAll(".", decimalSeparator ?? "") : str;
274
+ const arr = value.toString().split(decimalSeparator ?? "", 2);
275
+ let flag = value.toString().includes(decimalSeparator ?? "");
276
+ if ((arr[0]?.length ?? 0) < 3) {
277
+ return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ""}` : arr[0];
278
+ } else {
279
+ let count = 0;
280
+ for (let i = (arr[0]?.length ?? 0) - 2; i >= 0; i--) {
281
+ if (((arr[0]?.length ?? 0) - i - count) % 3 === 0 && i > 0) {
282
+ arr[0] = `${arr[0]?.substring(0, i)}${thousandSeparator}${arr[0]?.substring(i, arr[0]?.length ?? 0)}`;
283
+ count++;
284
+ }
285
+ }
286
+ if (arr[0]?.lastIndexOf(thousandSeparator ?? "") === (arr[0]?.length ?? 0) - 1) {
287
+ arr[0] = arr[0]?.slice(0, (arr[0]?.length ?? 0) - 1);
288
+ }
289
+ if (isDone) {
290
+ flag = (arr[1]?.substring(0, fraction) ?? "") !== "";
291
+ }
292
+ return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ""}` : arr[0];
293
+ }
294
+ } else {
295
+ return "";
296
+ }
297
+ };
298
+
299
+ // test-app/component/icon/index.tsx
300
+ var Icon = __toESM(require("becoxy-icons"));
301
+ var import_react4 = require("react");
302
+ var import_jsx_runtime3 = require("react/jsx-runtime");
303
+ var IconCustom = (props) => {
304
+ const { iconName, size } = props;
305
+ if (iconName === "") {
306
+ return null;
307
+ } else {
308
+ const TagIcon = iconName === "" ? "" : Icon[iconName];
309
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react4.Fragment, { children: iconName === "" ? "" : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TagIcon, { fontSize: size }) });
310
+ }
311
+ };
312
+ var icon_default = IconCustom;
313
+
314
+ // test-app/component/table/index.tsx
315
+ var import_moment = __toESM(require("moment"));
316
+ var import_ej2_react_dropdowns = require("@syncfusion/ej2-react-dropdowns");
317
+
318
+ // test-app/component/edit-form/index.tsx
319
+ var import_react9 = require("react");
320
+ var import_reactstrap6 = require("reactstrap");
321
+ var import_react_hook_form5 = require("react-hook-form");
322
+ var import_yup = require("@hookform/resolvers/yup");
323
+ var import_react_i18next5 = require("react-i18next");
324
+ var import_classnames6 = __toESM(require("classnames"));
325
+
326
+ // test-app/component/input-text/index.tsx
327
+ var import_react_hook_form = require("react-hook-form");
328
+ var import_reactstrap2 = require("reactstrap");
329
+ var import_classnames2 = __toESM(require("classnames"));
330
+ var import_react5 = require("react");
331
+ var import_react_i18next = require("react-i18next");
332
+ var import_jsx_runtime4 = require("react/jsx-runtime");
333
+ var TextInput = (props) => {
334
+ const { t } = (0, import_react_i18next.useTranslation)();
335
+ const { control, id, name, min, max, type, label, labelSize, required, errors, height, disabled, row, isLabel, placeholder, autoFocus, inLine, callback, readOnly, classes, ...rest } = props;
336
+ const renderLabel = () => {
337
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.Fragment, { children: isLabel === false ? "" : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_reactstrap2.Label, { for: name, children: [
338
+ t(label ? label : ""),
339
+ " ",
340
+ required ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-danger", children: "*" }) : "",
341
+ " "
342
+ ] }) });
343
+ };
344
+ const renderInput = () => {
345
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react5.Fragment, { children: [
346
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
347
+ import_react_hook_form.Controller,
348
+ {
349
+ name,
350
+ control,
351
+ render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
352
+ import_reactstrap2.Input,
353
+ {
354
+ id,
355
+ value: !isNullOrUndefined(value) ? value : "",
356
+ onChange: (val) => {
357
+ if (min || max) {
358
+ if (min && Number(val.target.value) >= min) {
359
+ onChange(val.target.value);
360
+ if (callback) {
361
+ callback(val);
362
+ }
363
+ }
364
+ if (max && Number(val.target.value) <= max) {
365
+ onChange(val.target.value);
366
+ if (callback) {
367
+ callback(val);
368
+ }
369
+ }
370
+ } else {
371
+ onChange(val.target.value);
372
+ if (callback) {
373
+ callback(val);
374
+ }
375
+ }
376
+ },
377
+ style: { height: `${height}px` },
378
+ autoFocus,
379
+ disabled,
380
+ placeholder,
381
+ type: type ? type : "text",
382
+ invalid: errors && true,
383
+ className: "h-100",
384
+ rows: row,
385
+ min,
386
+ max,
387
+ readOnly,
388
+ ...rest
389
+ }
390
+ )
391
+ }
392
+ ),
393
+ errors && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_reactstrap2.FormFeedback, { children: errors?.message })
394
+ ] });
395
+ };
396
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
397
+ "div",
398
+ {
399
+ className: (0, import_classnames2.default)(
400
+ " align",
401
+ {
402
+ [labelSize ? labelSize : ""]: labelSize,
403
+ [classes ? classes : ""]: classes,
404
+ "form-row-inline-error": errors
405
+ },
406
+ inLine === false ? "form-group " : "form-row-inline d-flex"
407
+ ),
408
+ children: [
409
+ renderLabel(),
410
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: (0, import_classnames2.default)("form-input-content", { "hidden-label": isLabel === false }), children: renderInput() })
411
+ ]
412
+ }
413
+ ) });
414
+ };
415
+ var input_text_default = TextInput;
416
+
417
+ // test-app/component/select/index.tsx
418
+ var import_react_hook_form2 = require("react-hook-form");
419
+ var import_reactstrap3 = require("reactstrap");
420
+ var import_react_select = __toESM(require("react-select"));
421
+ var import_classnames3 = __toESM(require("classnames"));
422
+ var import_react6 = require("react");
423
+ var import_react_i18next2 = require("react-i18next");
424
+ var import_jsx_runtime5 = require("react/jsx-runtime");
425
+ var SelectBox = (props) => {
426
+ const { t } = (0, import_react_i18next2.useTranslation)();
427
+ const { control, id, placeholder, fieldValue, confirmHandle, disabled, name, options, label, isLabel, labelSize, classes, required, errors, isMulti, isClearable, labelComponent, callback, inLine, onInputChange, ref, menuPosition, ...rest } = props;
428
+ const handChange = ({ onChange, val }) => {
429
+ onChange(!isNullOrUndefined(val) && isMulti ? val.map((item) => item.value) : !isNullOrUndefined(val) && !isMulti ? fieldValue ? val[fieldValue] : val?.value : void 0);
430
+ if (callback) {
431
+ callback(val);
432
+ }
433
+ };
434
+ const renderSelect = () => {
435
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react6.Fragment, { children: [
436
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
437
+ import_react_hook_form2.Controller,
438
+ {
439
+ name,
440
+ control,
441
+ render: ({ field: { value, onChange } }) => {
442
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
443
+ import_react_select.default,
444
+ {
445
+ ...rest,
446
+ id,
447
+ value: isMulti && value?.length > 0 ? value.map((x) => options.find((val) => (fieldValue ? val[fieldValue] : val.value) === x)) : !isNullOrUndefined(value) && value !== "" ? options.find((val) => (fieldValue ? val[fieldValue] : val.value) === value) : "",
448
+ onChange: (val) => {
449
+ if ((fieldValue && val ? val[fieldValue] : val?.value) !== value) {
450
+ if (confirmHandle) {
451
+ confirmHandle(handChange, onChange, val);
452
+ } else {
453
+ onChange(!isNullOrUndefined(val) && isMulti ? val.map((item) => item.value) : !isNullOrUndefined(val) && !isMulti ? fieldValue ? val[fieldValue] : val?.value : void 0);
454
+ if (callback) {
455
+ callback(val);
456
+ }
457
+ }
458
+ }
459
+ },
460
+ onInputChange,
461
+ form: name,
462
+ placeholder: placeholder ? placeholder : "",
463
+ classNamePrefix: "select",
464
+ className: `react-select ${errors && "is-invalid"}`,
465
+ options,
466
+ isMulti,
467
+ isDisabled: disabled,
468
+ isClearable,
469
+ menuPosition: menuPosition ?? "fixed",
470
+ formatOptionLabel: labelComponent ? labelComponent : void 0,
471
+ ref
472
+ }
473
+ );
474
+ }
475
+ }
476
+ ),
477
+ errors && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_reactstrap3.FormFeedback, { children: errors?.message })
478
+ ] });
479
+ };
480
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react6.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
481
+ "div",
482
+ {
483
+ className: (0, import_classnames3.default)(
484
+ inLine === false ? "form-group " : "form-row-inline d-flex",
485
+ "align",
486
+ {
487
+ [labelSize ? labelSize : ""]: labelSize,
488
+ [classes ? classes : ""]: classes,
489
+ "form-row-inline-error": errors
490
+ }
491
+ ),
492
+ children: [
493
+ isLabel === false ? "" : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_reactstrap3.Label, { className: "form-label", for: name, children: [
494
+ t(label ? label : ""),
495
+ " ",
496
+ required ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-danger", children: "*" }) : "",
497
+ " "
498
+ ] }),
499
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: (0, import_classnames3.default)("form-input-content", { "hidden-label": isLabel === false }), children: renderSelect() })
500
+ ]
501
+ }
502
+ ) });
503
+ };
504
+ var select_default = SelectBox;
505
+
506
+ // test-app/component/creactable-select/index.tsx
507
+ var import_react_hook_form3 = require("react-hook-form");
508
+ var import_reactstrap4 = require("reactstrap");
509
+ var import_classnames4 = __toESM(require("classnames"));
510
+ var import_react7 = require("react");
511
+ var import_react_i18next3 = require("react-i18next");
512
+ var import_creatable = __toESM(require("react-select/creatable"));
513
+ var import_jsx_runtime6 = require("react/jsx-runtime");
514
+ var CreatableSelectBox = (props) => {
515
+ const { t } = (0, import_react_i18next3.useTranslation)();
516
+ const { isMulti, id, isLabel, control, placeholder, fieldValue, name, options, label, labelSize, required, errors, inLine, isClearable, labelComponent, onInputChange, callback, ...rest } = props;
517
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react7.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
518
+ "div",
519
+ {
520
+ className: (0, import_classnames4.default)(
521
+ inLine === false ? "form-group " : "form-row-inline d-flex",
522
+ "align",
523
+ {
524
+ [labelSize ? labelSize : ""]: labelSize,
525
+ "form-row-inline-error": errors
526
+ }
527
+ ),
528
+ children: [
529
+ isLabel === false ? "" : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_reactstrap4.Label, { className: "form-label", for: name, children: [
530
+ t(label),
531
+ " ",
532
+ required ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-danger", children: "*" }) : "",
533
+ " "
534
+ ] }),
535
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: (0, import_classnames4.default)("form-input-content", { "hidden-label": isLabel === false }), children: [
536
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
537
+ import_react_hook_form3.Controller,
538
+ {
539
+ name,
540
+ control,
541
+ render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
542
+ import_creatable.default,
543
+ {
544
+ ...rest,
545
+ id,
546
+ value: isMulti && value?.length > 0 ? value.map((x) => options.find((val) => (fieldValue ? val[fieldValue] : val.value) === x)) : !isNullOrUndefined(value) && value !== "" ? options.find((val) => (fieldValue ? val[fieldValue] : val.value) === value) : "",
547
+ onChange: (val) => {
548
+ if (fieldValue && val.__isNew__) {
549
+ val[fieldValue] = val.value;
550
+ }
551
+ onChange(!isNullOrUndefined(val) && isMulti ? val.map((item) => item.value) : !isNullOrUndefined(val) && !isMulti ? fieldValue ? val[fieldValue] : val?.value : void 0);
552
+ if (callback) {
553
+ callback(val);
554
+ }
555
+ },
556
+ onInputChange,
557
+ classNamePrefix: "select",
558
+ className: `react-select ${errors && "is-invalid"}`,
559
+ options,
560
+ placeholder,
561
+ isMulti,
562
+ isClearable,
563
+ menuPosition: "fixed",
564
+ formatOptionLabel: labelComponent ? labelComponent : void 0
565
+ }
566
+ )
567
+ }
568
+ ),
569
+ errors && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_reactstrap4.FormFeedback, { children: errors?.message })
570
+ ] })
571
+ ]
572
+ }
573
+ ) });
574
+ };
575
+ var creactable_select_default = CreatableSelectBox;
576
+
577
+ // test-app/component/input-number/index.tsx
578
+ var import_react_hook_form4 = require("react-hook-form");
579
+ var import_reactstrap5 = require("reactstrap");
580
+ var import_classnames5 = __toESM(require("classnames"));
581
+ var import_react8 = require("react");
582
+ var import_react_i18next4 = require("react-i18next");
583
+ var import_jsx_runtime7 = require("react/jsx-runtime");
584
+ var NumberInput = (props) => {
585
+ const { t } = (0, import_react_i18next4.useTranslation)();
586
+ const {
587
+ control,
588
+ id,
589
+ fractionCurrency = 10,
590
+ name,
591
+ min,
592
+ max,
593
+ type,
594
+ label,
595
+ labelSize,
596
+ required,
597
+ errors,
598
+ height,
599
+ disabled,
600
+ row,
601
+ isLabel,
602
+ placeholder,
603
+ autoFocus,
604
+ inLine,
605
+ callback,
606
+ readOnly,
607
+ decimalSeparator = ",",
608
+ thousandSeparator = ".",
609
+ classes,
610
+ ...rest
611
+ } = props;
612
+ const renderLabel = () => {
613
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react8.Fragment, { children: isLabel === false ? "" : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_reactstrap5.Label, { className: "form-label", for: name, children: [
614
+ t(label ? label : ""),
615
+ " ",
616
+ required ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-danger", children: "*" }) : "",
617
+ " "
618
+ ] }) });
619
+ };
620
+ const renderInput = () => {
621
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react8.Fragment, { children: [
622
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
623
+ import_react_hook_form4.Controller,
624
+ {
625
+ name,
626
+ control,
627
+ render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
628
+ import_reactstrap5.Input,
629
+ {
630
+ id,
631
+ value: formartNumberic(value, decimalSeparator, thousandSeparator, fractionCurrency),
632
+ onChange: (val) => {
633
+ let newVal = "";
634
+ const flag = val.target?.value.startsWith("-");
635
+ if (val.target?.value.endsWith(decimalSeparator)) {
636
+ if ((val.target?.value.match(new RegExp(decimalSeparator === "," ? "," : "\\.", "g")) || []).length > 1 || fractionCurrency === 0) {
637
+ newVal = val.target?.value.slice(0, -1).replaceAll(thousandSeparator, "");
638
+ } else {
639
+ newVal = val.target?.value.replaceAll(thousandSeparator, "");
640
+ }
641
+ } else {
642
+ newVal = val.target.value.replaceAll(new RegExp(`[^0-9${decimalSeparator}]`, "g"), "");
643
+ }
644
+ if (decimalSeparator !== ".") {
645
+ newVal = newVal.replaceAll(decimalSeparator, ".");
646
+ }
647
+ onChange(flag ? `-${newVal}` : newVal);
648
+ },
649
+ onBlur: (val) => {
650
+ let newVal = "";
651
+ const flag = val.target?.value.startsWith("-");
652
+ if (val.target?.value.endsWith(decimalSeparator)) {
653
+ newVal = val.target?.value.slice(0, -1).replaceAll(new RegExp(`[^0-9${decimalSeparator}]`, "g"), "");
654
+ } else {
655
+ newVal = val.target.value.replaceAll(new RegExp(`[^0-9${decimalSeparator}]`, "g"), "");
656
+ }
657
+ if (decimalSeparator !== ".") {
658
+ newVal = newVal.replaceAll(decimalSeparator, ".");
659
+ }
660
+ let value2 = flag ? 0 - Number(newVal) : Number(newVal);
661
+ if (max !== void 0 && value2 > max) {
662
+ value2 = max;
663
+ } else if (min !== void 0 && value2 < min) {
664
+ value2 = min;
665
+ }
666
+ onChange(value2);
667
+ if (callback) {
668
+ callback(value2);
669
+ }
670
+ },
671
+ style: { height: `${height}px` },
672
+ autoFocus,
673
+ disabled,
674
+ placeholder,
675
+ type: type ? type : "text",
676
+ invalid: errors && true,
677
+ className: "h-100",
678
+ rows: row,
679
+ min,
680
+ max,
681
+ readOnly,
682
+ ...rest
683
+ }
684
+ )
685
+ }
686
+ ),
687
+ errors && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_reactstrap5.FormFeedback, { children: errors?.message })
688
+ ] });
689
+ };
690
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
691
+ "div",
692
+ {
693
+ className: (0, import_classnames5.default)(
694
+ " align",
695
+ {
696
+ [labelSize ? labelSize : ""]: labelSize,
697
+ [classes ? classes : ""]: classes,
698
+ "form-row-inline-error": errors
699
+ },
700
+ inLine === false ? "form-group " : "form-row-inline d-flex"
701
+ ),
702
+ children: [
703
+ renderLabel(),
704
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: (0, import_classnames5.default)("form-input-content", { "hidden-label": isLabel === false }), children: renderInput() })
705
+ ]
706
+ }
707
+ ) });
708
+ };
709
+ var input_number_default = NumberInput;
710
+
711
+ // test-app/component/edit-form/index.tsx
712
+ var import_jsx_runtime8 = require("react/jsx-runtime");
713
+ var defaultWidth = 200;
714
+ var EditForm = (0, import_react9.forwardRef)((props, ref) => {
715
+ const {
716
+ id,
717
+ field,
718
+ displayValue,
719
+ menuHeight,
720
+ menuWidth,
721
+ rowData,
722
+ invalid,
723
+ onChange,
724
+ onChangeField,
725
+ onKeyDown,
726
+ defaultValues,
727
+ placeholder,
728
+ textAlign,
729
+ schema,
730
+ onFormOpen,
731
+ onFormSubmit,
732
+ footerTemplate,
733
+ minWidth,
734
+ openOnFocus,
735
+ labelSize = "label-small"
736
+ } = props;
737
+ const { innerWidth } = window;
738
+ const inputRef = (0, import_react9.useRef)();
739
+ const editFormRef = (0, import_react9.useRef)();
740
+ const buttonRef = (0, import_react9.useRef)();
741
+ const [dropdownOpen, setDropdownOpen] = (0, import_react9.useState)(false);
742
+ const [itemsField, setItemsField] = (0, import_react9.useState)([]);
743
+ const { t } = (0, import_react_i18next5.useTranslation)();
744
+ useOnClickOutside(editFormRef, () => {
745
+ closeMenu();
746
+ });
747
+ const closeMenu = () => {
748
+ setTimeout(() => {
749
+ setDropdownOpen(false);
750
+ }, onChangeField ? 10 : 0);
751
+ };
752
+ const {
753
+ control,
754
+ handleSubmit,
755
+ getValues,
756
+ reset,
757
+ setValue,
758
+ formState: { errors }
759
+ } = (0, import_react_hook_form5.useForm)({
760
+ mode: "onChange",
761
+ defaultValues,
762
+ resolver: (0, import_yup.yupResolver)(schema)
763
+ });
764
+ (0, import_react9.useEffect)(() => {
765
+ if (dropdownOpen) {
766
+ if (onFormOpen && itemsField.length === 0) {
767
+ onFormOpen(rowData, itemsField, setItemsField);
768
+ }
769
+ }
770
+ }, [dropdownOpen]);
771
+ (0, import_react9.useEffect)(() => {
772
+ if (dropdownOpen && itemsField.length > 0) {
773
+ itemsField.forEach((ele) => {
774
+ setValue(ele.name, rowData[ele.name] ?? "");
775
+ });
776
+ }
777
+ }, [dropdownOpen, itemsField]);
778
+ const handleOnClick = () => {
779
+ if (dropdownOpen) {
780
+ if (!openOnFocus) {
781
+ closeMenu();
782
+ }
783
+ } else {
784
+ setDropdownOpen(true);
785
+ }
786
+ };
787
+ const handleOnSubmit = (val) => {
788
+ closeMenu();
789
+ onChange(val);
790
+ if (onFormSubmit) {
791
+ onFormSubmit(rowData, setValue, getValues, reset);
792
+ }
793
+ inputRef.current.focus();
794
+ };
795
+ const focusElement = (id2, focus) => {
796
+ const element = document.getElementById(id2);
797
+ if (element) {
798
+ if (element.className.includes("react-select")) {
799
+ element.getElementsByTagName("input")[0]?.focus();
800
+ } else {
801
+ element.focus();
802
+ if (focus) {
803
+ element.setSelectionRange(0, element.innerText.length - 1);
804
+ }
805
+ }
806
+ }
807
+ };
808
+ const handleOnKeyDown = (e) => {
809
+ let flag = false;
810
+ if (dropdownOpen) {
811
+ if (e.code === "Escape") {
812
+ closeMenu();
813
+ flag = true;
814
+ } else if (e.code === "Enter") {
815
+ closeMenu();
816
+ flag = true;
817
+ } else if (e.code === "ArrowDown") {
818
+ focusElement(`form-element-${field}-0`);
819
+ flag = true;
820
+ }
821
+ } else {
822
+ if (e.code === "ArrowDown") {
823
+ setDropdownOpen(true);
824
+ focusElement(`form-element-${field}-0`);
825
+ flag = true;
826
+ } else if (e.code === "Space") {
827
+ setDropdownOpen(true);
828
+ flag = true;
829
+ }
830
+ }
831
+ if (onKeyDown && !flag) {
832
+ const key = onKeyDown(e);
833
+ if (key === "ArrowRight" || key === "ArrowLeft") {
834
+ closeMenu();
835
+ }
836
+ } else {
837
+ e.stopPropagation();
838
+ e.preventDefault();
839
+ }
840
+ };
841
+ const handleOnFocus = () => {
842
+ if (openOnFocus) {
843
+ setDropdownOpen(true);
844
+ if (field) {
845
+ setTimeout(() => {
846
+ focusElement(`form-element-${field}-0`, true);
847
+ }, 100);
848
+ }
849
+ }
850
+ };
851
+ const formKeyDown = (e, handSubmit) => {
852
+ if (e.code === "Enter") {
853
+ handSubmit();
854
+ e.preventDefault();
855
+ e.stopPropagation();
856
+ } else {
857
+ if (onKeyDown) {
858
+ const key = onKeyDown(e);
859
+ if (key === "ArrowRight" || key === "ArrowLeft") {
860
+ closeMenu();
861
+ }
862
+ }
863
+ }
864
+ };
865
+ const formItemKeyDown = (e, index) => {
866
+ if (e.code === "ArrowDown" && index < itemsField.length - 1) {
867
+ focusElement(`form-element-${field}-${index + 1}`);
868
+ e.preventDefault();
869
+ e.stopPropagation();
870
+ } else if (e.code === "ArrowUp" && index > 0) {
871
+ focusElement(`form-element-${field}-${index - 1}`);
872
+ e.preventDefault();
873
+ e.stopPropagation();
874
+ } else if (e.code === "Tab" && onChangeField && index === itemsField.length - 1) {
875
+ closeMenu();
876
+ }
877
+ };
878
+ const elementChange = (field2) => {
879
+ if (onChangeField) {
880
+ onChangeField(rowData, field2, setValue, getValues);
881
+ const rs = getValues();
882
+ if (rs) {
883
+ onChange(rs);
884
+ }
885
+ }
886
+ };
887
+ const renderForm = (rows) => {
888
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_reactstrap6.Row, { className: "gy-25", children: rows.map((item, index) => {
889
+ if (item.type === "numeric") {
890
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_reactstrap6.Col, { xl: 12, onKeyDown: (e) => formItemKeyDown(e, index), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
891
+ input_number_default,
892
+ {
893
+ id: `form-element-${field}-${index}`,
894
+ control,
895
+ name: item.name,
896
+ label: item.label ? item.label : "",
897
+ labelSize: `text-left ${labelSize}`,
898
+ errors: errors[item.name],
899
+ disabled: item.disabled,
900
+ min: item.min,
901
+ max: item.max,
902
+ fractionCurrency: item.fraction,
903
+ callback: () => {
904
+ elementChange(item.name);
905
+ }
906
+ },
907
+ index
908
+ ) }, index);
909
+ } else if (item.type === "text") {
910
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_reactstrap6.Col, { xl: 12, onKeyDown: (e) => formItemKeyDown(e, index), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
911
+ input_text_default,
912
+ {
913
+ id: `form-element-${field}-${index}`,
914
+ control,
915
+ name: item.name,
916
+ label: item.label ? item.label : "",
917
+ labelSize: `text-left ${labelSize}`,
918
+ errors: errors[item.name],
919
+ disabled: item.disabled,
920
+ callback: () => {
921
+ elementChange(item.name);
922
+ }
923
+ },
924
+ index
925
+ ) }, index);
926
+ } else if (item.type === "select") {
927
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_reactstrap6.Col, { xl: 12, onKeyDown: (e) => formItemKeyDown(e, index), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
928
+ select_default,
929
+ {
930
+ id: `form-element-${field}-${index}`,
931
+ options: item.options ?? [],
932
+ control,
933
+ name: item.name,
934
+ label: item.label ? item.label : "",
935
+ labelSize: `text-left ${labelSize}`,
936
+ menuPortalTarget: document.body,
937
+ errors: errors[item.name],
938
+ disabled: item.disabled,
939
+ callback: () => {
940
+ elementChange(item.name);
941
+ }
942
+ },
943
+ index
944
+ ) }, index);
945
+ } else if (item.type === "selectCreatable") {
946
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_reactstrap6.Col, { xl: 12, onKeyDown: (e) => formItemKeyDown(e, index), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
947
+ creactable_select_default,
948
+ {
949
+ id: `form-element-${field}-${index}`,
950
+ options: item.options ?? [],
951
+ control,
952
+ name: item.name,
953
+ placeholder: t("Select"),
954
+ menuPortalTarget: document.body,
955
+ label: item.label ? item.label : "",
956
+ labelSize: ` ${labelSize}`,
957
+ errors: errors[item.name],
958
+ callback: () => {
959
+ elementChange(item.name);
960
+ }
961
+ },
962
+ index
963
+ ) }, index);
964
+ }
965
+ }) });
966
+ };
967
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
968
+ "div",
969
+ {
970
+ className: "from-edit",
971
+ ref,
972
+ id,
973
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: editFormRef, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
974
+ import_reactstrap6.Dropdown,
975
+ {
976
+ isOpen: dropdownOpen,
977
+ toggle: () => {
978
+ },
979
+ children: [
980
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_reactstrap6.DropdownToggle, { tag: "div", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
981
+ import_reactstrap6.Input,
982
+ {
983
+ style: { backgroundColor: "#FFF", textAlign: textAlign ?? "left" },
984
+ placeholder,
985
+ innerRef: inputRef,
986
+ className: (0, import_classnames6.default)("input-display", { "is-invalid": invalid }),
987
+ value: displayValue,
988
+ onFocus: handleOnFocus,
989
+ onClick: handleOnClick,
990
+ onKeyDown: (e) => handleOnKeyDown(e),
991
+ readOnly: true
992
+ }
993
+ ) }),
994
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
995
+ import_reactstrap6.DropdownMenu,
996
+ {
997
+ className: "formula-dropdown icon-dropdown p-0",
998
+ style: {
999
+ minWidth: minWidth ? minWidth : defaultWidth,
1000
+ width: menuWidth ? menuWidth : "min-content",
1001
+ maxWidth: innerWidth > 1280 ? 1280 : innerWidth,
1002
+ borderRadius: 8,
1003
+ zIndex: 1060
1004
+ },
1005
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_reactstrap6.DropdownItem, { className: "p-0", style: { borderRadius: "6px" }, tag: "div", header: true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_reactstrap6.Form, { className: "todo-modal", onKeyDown: (e) => formKeyDown(e, handleSubmit(handleOnSubmit)), children: [
1006
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1007
+ "div",
1008
+ {
1009
+ className: "p-1",
1010
+ style: {
1011
+ maxHeight: menuHeight ? menuHeight : 300,
1012
+ overflow: "auto"
1013
+ },
1014
+ children: itemsField ? renderForm(itemsField) : ""
1015
+ }
1016
+ ),
1017
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "d-flex justify-content-between p-50", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: [
1018
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-primary py-25", style: { fontSize: 12 }, children: footerTemplate ? footerTemplate(rowData) : "" }),
1019
+ !onChangeField ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1020
+ import_reactstrap6.Button,
1021
+ {
1022
+ ref: buttonRef,
1023
+ color: "primary",
1024
+ className: "btn btn-primary py-25 px-50",
1025
+ onClick: handleSubmit(handleOnSubmit),
1026
+ onKeyDown: (e) => {
1027
+ if (e.code === "Tab") {
1028
+ closeMenu();
1029
+ }
1030
+ },
1031
+ children: t("Save")
1032
+ }
1033
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, {})
1034
+ ] })
1035
+ ] }) })
1036
+ }
1037
+ )
1038
+ ]
1039
+ }
1040
+ ) })
1041
+ }
1042
+ );
1043
+ });
1044
+ var edit_form_default = EditForm;
1045
+
1046
+ // test-app/component/sidebar-setting-column/index.tsx
1047
+ var import_react11 = require("react");
1048
+ var import_reactstrap7 = require("reactstrap");
1049
+ var import_react_i18next7 = require("react-i18next");
1050
+ var import_ej2_react_grids = require("@syncfusion/ej2-react-grids");
1051
+
1052
+ // test-app/component/modal-header/index.tsx
1053
+ var import_becoxy_icons2 = require("becoxy-icons");
1054
+ var import_classnames7 = __toESM(require("classnames"));
1055
+ var import_react_i18next6 = require("react-i18next");
1056
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1057
+ var ModalHeader = (props) => {
1058
+ const { title, handleModal, typeModal = "Edit", component } = props;
1059
+ const { t } = (0, import_react_i18next6.useTranslation)();
1060
+ const handleModalIcon = () => {
1061
+ if (typeModal === "Edit" || typeModal === "Approval") {
1062
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_becoxy_icons2.Edit, { fontSize: 17, className: "me-1" });
1063
+ } else if (typeModal === "View") {
1064
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_becoxy_icons2.Info, { fontSize: 17, className: "me-1" });
1065
+ } else if (typeModal === "Detail") {
1066
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_becoxy_icons2.Info, { fontSize: 17, className: "me-1" });
1067
+ } else if (typeModal === "Order") {
1068
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "e-icons e-sorting-1 me-1", style: { fontSize: "14px" } });
1069
+ } else if (typeModal === "Process") {
1070
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "e-flat e-icons e-paste-match-destination me-1", style: { fontSize: "14px" } });
1071
+ } else {
1072
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_becoxy_icons2.Plus, { fontSize: 17, className: "me-1" });
1073
+ }
1074
+ };
1075
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "modal-header d-flex align-items-center justify-content-between mb-1", children: [
1076
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "d-flex align-items-center justify-content-start", children: [
1077
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("h5", { className: "modal-title", children: [
1078
+ handleModalIcon(),
1079
+ " ",
1080
+ t(title)
1081
+ ] }),
1082
+ component ? component() : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, {})
1083
+ ] }),
1084
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "todo-item-action d-flex align-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1085
+ import_becoxy_icons2.X,
1086
+ {
1087
+ className: (0, import_classnames7.default)("fw-normal mt-25 cursor-pointer", { "d-none": !handleModal }),
1088
+ fontSize: 20,
1089
+ onClick: handleModal
1090
+ }
1091
+ ) })
1092
+ ] });
1093
+ };
1094
+ var modal_header_default = ModalHeader;
1095
+
1096
+ // test-app/component/sidebar/index.tsx
1097
+ var import_becoxy_icons3 = require("becoxy-icons");
1098
+ var import_classnames8 = __toESM(require("classnames"));
1099
+ var import_react10 = require("react");
1100
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1101
+ var Sidebar = (props) => {
1102
+ const {
1103
+ open,
1104
+ children,
1105
+ toggleSidebar,
1106
+ width,
1107
+ keyboard,
1108
+ hiddenBackground,
1109
+ hiddenFullScreenButton
1110
+ } = props;
1111
+ const [isFullScreen, setIsFullScreen] = (0, import_react10.useState)(false);
1112
+ const [flag, setFlag] = (0, import_react10.useState)(open);
1113
+ (0, import_react10.useEffect)(() => {
1114
+ if (open !== flag) {
1115
+ if (open) {
1116
+ setFlag(open);
1117
+ } else {
1118
+ setTimeout(() => {
1119
+ setFlag(open);
1120
+ }, 50);
1121
+ }
1122
+ }
1123
+ }, [open]);
1124
+ const handClose = () => {
1125
+ setFlag(false);
1126
+ setTimeout(() => {
1127
+ toggleSidebar();
1128
+ }, 400);
1129
+ };
1130
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1131
+ "div",
1132
+ {
1133
+ tabIndex: 0,
1134
+ className: (0, import_classnames8.default)({ "d-none": !open }),
1135
+ onKeyDown: (e) => {
1136
+ if (!keyboard && e.code === "Escape" && flag) {
1137
+ handClose();
1138
+ e.stopPropagation();
1139
+ e.preventDefault();
1140
+ }
1141
+ },
1142
+ children: [
1143
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1144
+ "div",
1145
+ {
1146
+ className: (0, import_classnames8.default)("offcanvas-backdrop fade", {
1147
+ "d-none": !flag || hiddenBackground,
1148
+ show: flag
1149
+ }),
1150
+ style: { zIndex: 1056 },
1151
+ onClick: handClose
1152
+ }
1153
+ ),
1154
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1155
+ "div",
1156
+ {
1157
+ className: (0, import_classnames8.default)("customizer d-none d-md-block ", `customizer-${width ?? 600}`, {
1158
+ open: flag,
1159
+ fullscreen: isFullScreen
1160
+ }),
1161
+ style: { zIndex: 1057 },
1162
+ children: [
1163
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1164
+ "div",
1165
+ {
1166
+ style: {
1167
+ position: "fixed",
1168
+ top: "50%",
1169
+ transform: "translate(-50%, -50%)",
1170
+ background: "#FFF",
1171
+ filter: "drop-shadow(0.9px 0.9px 1.5px)",
1172
+ height: 50,
1173
+ display: "flex",
1174
+ alignItems: "center",
1175
+ borderRadius: "0px 5px 5px 0px",
1176
+ cursor: "pointer",
1177
+ zIndex: 9,
1178
+ marginLeft: 7
1179
+ },
1180
+ className: (0, import_classnames8.default)({ "d-none": hiddenFullScreenButton }),
1181
+ onClick: () => {
1182
+ setIsFullScreen(!isFullScreen);
1183
+ },
1184
+ children: [
1185
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_becoxy_icons3.ChevronLeft, { className: `${isFullScreen ? "d-none" : ""}`, fontSize: 16 }),
1186
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_becoxy_icons3.ChevronRight, { className: `${!isFullScreen ? "d-none" : ""}`, fontSize: 15 })
1187
+ ]
1188
+ }
1189
+ ),
1190
+ children
1191
+ ]
1192
+ }
1193
+ )
1194
+ ]
1195
+ }
1196
+ );
1197
+ };
1198
+ var sidebar_default = Sidebar;
1199
+
1200
+ // test-app/component/sidebar-setting-column/index.tsx
1201
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1202
+ var SidebarSetColumn = (props) => {
1203
+ const { column, setColumn, openSidebar, handleSidebar } = props;
1204
+ const { t } = (0, import_react_i18next7.useTranslation)();
1205
+ const [dataSource, setDataSource] = (0, import_react11.useState)([]);
1206
+ (0, import_react11.useEffect)(() => {
1207
+ if (openSidebar) {
1208
+ setDataSource([...column]);
1209
+ }
1210
+ }, [openSidebar]);
1211
+ const handleCancel = () => {
1212
+ handleSidebar();
1213
+ setDataSource([]);
1214
+ };
1215
+ const handleSubmit = () => {
1216
+ setColumn([...dataSource]);
1217
+ handleCancel();
1218
+ };
1219
+ const getWindowSize = () => {
1220
+ const { innerWidth, innerHeight } = window;
1221
+ return { innerWidth, innerHeight };
1222
+ };
1223
+ const gird = (0, import_react11.useRef)(null);
1224
+ const [windowSize, setWindowSize] = (0, import_react11.useState)(getWindowSize());
1225
+ (0, import_react11.useEffect)(() => {
1226
+ const handleWindowResize = () => {
1227
+ setWindowSize(getWindowSize());
1228
+ };
1229
+ window.addEventListener("resize", handleWindowResize);
1230
+ return () => {
1231
+ window.removeEventListener("resize", handleWindowResize);
1232
+ };
1233
+ }, []);
1234
+ const renderFooterButtons = () => {
1235
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react11.Fragment, { children: [
1236
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_reactstrap7.Button, { color: "primary", onClick: handleSubmit, className: "me-1", children: t("Confirm") }),
1237
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_reactstrap7.Button, { color: "secondary", onClick: handleCancel, outline: true, children: t("Close") })
1238
+ ] });
1239
+ };
1240
+ const visibleTemplate = (item) => {
1241
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1242
+ import_reactstrap7.Input,
1243
+ {
1244
+ defaultChecked: item.visible ?? true,
1245
+ disabled: item.invisibleDisable,
1246
+ type: "checkbox",
1247
+ style: { height: 18 },
1248
+ className: " cursor-pointer",
1249
+ onChange: (e) => {
1250
+ if (dataSource) {
1251
+ item.column.dataSource[item.index].visible = e.target.checked;
1252
+ setDataSource(item.column.dataSource);
1253
+ }
1254
+ }
1255
+ }
1256
+ );
1257
+ };
1258
+ const fixColumnTemplate = (item) => {
1259
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1260
+ import_reactstrap7.Input,
1261
+ {
1262
+ defaultChecked: item.fixedType === "left" || item.fixedType === "right",
1263
+ type: "checkbox",
1264
+ style: { height: 18 },
1265
+ className: " cursor-pointer",
1266
+ onChange: (e) => {
1267
+ if (dataSource) {
1268
+ if (e.target.checked) {
1269
+ if (item.index * 2 <= item.column.dataSource.length) {
1270
+ item.column.dataSource[item.index].fixedType = "left";
1271
+ } else {
1272
+ item.column.dataSource[item.index].fixedType = "right";
1273
+ }
1274
+ } else {
1275
+ item.column.dataSource[item.index].fixedType = "";
1276
+ }
1277
+ setDataSource(item.column.dataSource);
1278
+ }
1279
+ }
1280
+ }
1281
+ );
1282
+ };
1283
+ const columns = [
1284
+ {
1285
+ isPrimaryKey: true,
1286
+ field: "headerText",
1287
+ headerText: "Column name",
1288
+ template: (e) => {
1289
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: t(e.headerText) });
1290
+ },
1291
+ visible: true,
1292
+ width: 100,
1293
+ maxWidth: 120,
1294
+ minWidth: 80
1295
+ },
1296
+ {
1297
+ isPrimaryKey: true,
1298
+ template: visibleTemplate,
1299
+ headerText: "Display",
1300
+ dataSource,
1301
+ visible: true,
1302
+ width: 100,
1303
+ maxWidth: 120,
1304
+ minWidth: 80
1305
+ },
1306
+ {
1307
+ isPrimaryKey: true,
1308
+ template: fixColumnTemplate,
1309
+ headerText: "Fix the column",
1310
+ dataSource,
1311
+ visible: true,
1312
+ width: 100,
1313
+ maxWidth: 120,
1314
+ minWidth: 80
1315
+ },
1316
+ {
1317
+ isPrimaryKey: true,
1318
+ field: "width",
1319
+ headerText: "Column width",
1320
+ template: (item) => {
1321
+ return item.width ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1322
+ t(item.width),
1323
+ "px"
1324
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, {});
1325
+ },
1326
+ visible: true,
1327
+ width: 100,
1328
+ maxWidth: 120,
1329
+ minWidth: 80
1330
+ }
1331
+ ];
1332
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1333
+ sidebar_default,
1334
+ {
1335
+ open: openSidebar,
1336
+ toggleSidebar: handleCancel,
1337
+ width: 700,
1338
+ children: [
1339
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(modal_header_default, { typeModal: "Edit", handleModal: handleCancel, title: "Column setup" }),
1340
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1341
+ import_ej2_react_grids.GridComponent,
1342
+ {
1343
+ className: "ms-2",
1344
+ dataSource,
1345
+ ref: gird,
1346
+ height: windowSize.innerHeight - 160,
1347
+ allowRowDragAndDrop: true,
1348
+ children: [
1349
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ej2_react_grids.ColumnsDirective, { children: columns.map((col, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ej2_react_grids.ColumnDirective, { ...col, headerText: t(col.headerText) }, index)) }),
1350
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ej2_react_grids.Inject, { services: [import_ej2_react_grids.RowDD, import_ej2_react_grids.Selection, import_ej2_react_grids.CommandColumn] })
1351
+ ]
1352
+ }
1353
+ ),
1354
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1355
+ "div",
1356
+ {
1357
+ className: "d-flex justify-content-end p-1 ",
1358
+ style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" },
1359
+ children: renderFooterButtons()
1360
+ }
1361
+ )
1362
+ ]
1363
+ }
1364
+ );
1365
+ };
1366
+ var sidebar_setting_column_default = SidebarSetColumn;
1367
+
1368
+ // test-app/component/table/index.tsx
1369
+ var import_ej2_react_popups = require("@syncfusion/ej2-react-popups");
1370
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1371
+ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1372
+ const { t } = (0, import_react_i18next8.useTranslation)();
1373
+ const {
1374
+ idTable,
1375
+ dataSource,
1376
+ columns,
1377
+ commandClick,
1378
+ dataSourceChange,
1379
+ rowChange,
1380
+ allowPaging,
1381
+ pageSize,
1382
+ totalItem,
1383
+ currentPage,
1384
+ setCurrentPage,
1385
+ setPageSize,
1386
+ setDataSource,
1387
+ height,
1388
+ maxHeight,
1389
+ minHeight,
1390
+ defaultValue,
1391
+ haveSum,
1392
+ toolbarOptions,
1393
+ toolbarBottomOptions,
1394
+ showTopToolbar,
1395
+ showBottomToolbar,
1396
+ searchTerm,
1397
+ setSearchTerm,
1398
+ searchEnable,
1399
+ setSelectedItem,
1400
+ selectedItem,
1401
+ selectEnable,
1402
+ editDisable,
1403
+ addDisable,
1404
+ deleteAllDisable,
1405
+ insertAfterDisable,
1406
+ insertBeforeDisable,
1407
+ duplicateDisable,
1408
+ decimalSeparator = ",",
1409
+ thousandSeparator = ".",
1410
+ isMulti
1411
+ } = props;
1412
+ (0, import_react12.useImperativeHandle)(ref, () => {
1413
+ return {
1414
+ refeshFocusRow: handleRefeshRow
1415
+ };
1416
+ });
1417
+ const [refreshRow, setRefreshRow] = (0, import_react12.useState)(false);
1418
+ const [indexFocus, setIndexFocus] = (0, import_react12.useState)();
1419
+ const [selectedRows, setSelectedRows] = (0, import_react12.useState)([]);
1420
+ const [tableColumns, setTableColumns] = (0, import_react12.useState)([...columns]);
1421
+ const [columnFistEdit, setColumnFistEdit] = (0, import_react12.useState)(0);
1422
+ const [columnLastEdit, setColumnlastEdit] = (0, import_react12.useState)(0);
1423
+ const [objWidthFix, setObjWidthFix] = (0, import_react12.useState)({});
1424
+ const [openPopupTree, setOpenPopupTree] = (0, import_react12.useState)(false);
1425
+ const [openPopupSetupColumn, setOpenPopupSetupColumn] = (0, import_react12.useState)(false);
1426
+ const tableElement = (0, import_react12.useRef)(null);
1427
+ const gridRef = (0, import_react12.useRef)();
1428
+ const lag = window.localStorage.getItem("i18nextLng");
1429
+ const lang = lag ? lag : "vi";
1430
+ const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? "id";
1431
+ const fieldUniKey = columns.filter((item) => item.isUnikey === true)?.map((item) => item.field);
1432
+ (0, import_react12.useEffect)(() => {
1433
+ let indexFirst = -1;
1434
+ let indexlast = -1;
1435
+ let letfWidthFix = 0;
1436
+ let rightWidthFix = 0;
1437
+ tableColumns.forEach((item, index) => {
1438
+ if (item.fixedType === "left" && item.visible !== false) {
1439
+ objWidthFix[index] = letfWidthFix;
1440
+ letfWidthFix += Number(item.minWidth ? item.minWidth : item.field === "#" ? 40 : item.width ? item.width : 0);
1441
+ }
1442
+ if (tableColumns[tableColumns.length - 1 - index].fixedType === "right" && tableColumns[tableColumns.length - 1 - index].visible !== false) {
1443
+ objWidthFix[tableColumns.length - 1 - index] = rightWidthFix;
1444
+ rightWidthFix += Number(tableColumns[tableColumns.length - 1 - index].minWidth ? tableColumns[tableColumns.length - 1 - index].minWidth : tableColumns[tableColumns.length - 1 - index].field === "#" ? 40 : tableColumns[tableColumns.length - 1 - index].width ? tableColumns[tableColumns.length - 1 - index].width : 0);
1445
+ }
1446
+ if (item.editEnable && item.visible !== false && !item.disabledCondition) {
1447
+ if (indexFirst === -1) {
1448
+ indexFirst = index;
1449
+ }
1450
+ indexlast = index;
1451
+ }
1452
+ });
1453
+ setObjWidthFix(objWidthFix);
1454
+ setColumnFistEdit(indexFirst + 1);
1455
+ setColumnlastEdit(indexlast + 1);
1456
+ }, [tableColumns]);
1457
+ (0, import_react12.useEffect)(() => {
1458
+ setTableColumns(columns.map((item, index) => {
1459
+ return { ...item, visible: item.invisibleDisable ? item.visible : tableColumns[index]?.visible ?? item.visible };
1460
+ }));
1461
+ }, [columns]);
1462
+ const handleRefeshRow = () => {
1463
+ setRefreshRow(true);
1464
+ setTimeout(() => {
1465
+ setRefreshRow(false);
1466
+ }, 5);
1467
+ };
1468
+ const handleDataChange = async (row, col, indexRow) => {
1469
+ if (dataSourceChange) {
1470
+ dataSourceChange(dataSource);
1471
+ }
1472
+ if (rowChange) {
1473
+ await rowChange(row, indexRow, col.field);
1474
+ for (let index = 0; index <= tableColumns.length; index++) {
1475
+ if (!editDisable && indexFocus === indexRow && (!col.disabledCondition || !col.disabledCondition(row)) && tableColumns[index] && tableColumns[index].editEnable) {
1476
+ const element = document.getElementById(`${idTable}-col${index + 1}-row${indexRow + 1}`);
1477
+ if (element) {
1478
+ if (element.className.includes("input-element")) {
1479
+ element.value = row[tableColumns[index].field] ?? "";
1480
+ } else if (element.className.includes("input-numeric")) {
1481
+ element.value = row[tableColumns[index].field] ? formartNumberic(row[tableColumns[index].field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction) : 0;
1482
+ } else if (element.className.includes("input-checkbox")) {
1483
+ element.checked = row[tableColumns[index].field] ?? false;
1484
+ }
1485
+ }
1486
+ }
1487
+ }
1488
+ }
1489
+ };
1490
+ const handleKeyPress = (e) => {
1491
+ if (e.code === "Enter" || e.code === "NumpadEnter") {
1492
+ setSearchTerm(e.target.value);
1493
+ }
1494
+ };
1495
+ const searchTemplate = () => {
1496
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "me-50", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1497
+ react_input_default,
1498
+ {
1499
+ style: { width: "230px" },
1500
+ value: searchTerm,
1501
+ setSearchTerm,
1502
+ placeholder: t("Search"),
1503
+ onKeyPress: handleKeyPress
1504
+ }
1505
+ ) }) });
1506
+ };
1507
+ const defaultToolbarOption = searchEnable === true ? [{ template: searchTemplate, align: "left" }] : [];
1508
+ let toolbarTopOption = [];
1509
+ if (toolbarOptions) {
1510
+ toolbarTopOption = [...defaultToolbarOption, ...toolbarOptions];
1511
+ } else {
1512
+ toolbarTopOption = [...defaultToolbarOption];
1513
+ }
1514
+ const renderEdit = (row, col, indexRow, indexCol) => {
1515
+ switch (col?.editTypeCondition ? col?.editTypeCondition(row) : col.editType) {
1516
+ case "date":
1517
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1518
+ import_reactstrap8.Input,
1519
+ {
1520
+ id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1521
+ style: { textAlign: col.textAlign, height: 29 },
1522
+ value: row[col.field] ? (0, import_moment.default)(row[col.field]).format("yyyy-MM-DD") : row[col.field],
1523
+ onChange: (val) => {
1524
+ row[col.field] = val.target.value;
1525
+ if (col.callback) {
1526
+ col.callback(val.target.value, indexRow);
1527
+ }
1528
+ handleDataChange(row, col, indexRow);
1529
+ },
1530
+ className: (0, import_classnames9.default)("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1531
+ type: "date",
1532
+ max: "9999-12-31",
1533
+ onKeyDown: (e) => {
1534
+ if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
1535
+ }
1536
+ }
1537
+ }
1538
+ );
1539
+ case "datetime":
1540
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1541
+ import_reactstrap8.Input,
1542
+ {
1543
+ id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1544
+ style: { textAlign: col.textAlign, height: 29 },
1545
+ value: row[col.field] ? (0, import_moment.default)(row[col.field]).format("yyyy-MM-DD HH:MM") : row[col.field],
1546
+ onChange: (val) => {
1547
+ row[col.field] = val.target.value;
1548
+ if (col.callback) {
1549
+ col.callback(val.target.value, indexRow);
1550
+ }
1551
+ handleDataChange(row, col, indexRow);
1552
+ },
1553
+ className: (0, import_classnames9.default)("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1554
+ type: "datetime-local",
1555
+ max: "9999-12-31T23:59",
1556
+ onKeyDown: (e) => {
1557
+ if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
1558
+ }
1559
+ }
1560
+ }
1561
+ );
1562
+ case "asyncSelect":
1563
+ let optionAsyncSelects = [];
1564
+ if (col.selectSettings?.optionsField) {
1565
+ optionAsyncSelects = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
1566
+ } else {
1567
+ optionAsyncSelects = col.selectSettings?.options ? col.selectSettings?.validateOption ? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row)) : col.selectSettings?.options : [];
1568
+ }
1569
+ let valueAsyncSelect = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? optionAsyncSelects?.find((val) => val[col.selectSettings?.fieldValue ?? "value"] === row[col.field]) : void 0;
1570
+ if (!valueAsyncSelect && col.selectSettings?.defaultValue) {
1571
+ valueAsyncSelect = col.selectSettings?.defaultValue(row);
1572
+ }
1573
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: (0, import_classnames9.default)("d-flex select-group", { "is-invalid": col.validate && col.validate(row[col.field], row) }), children: [
1574
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1575
+ import_async.default,
1576
+ {
1577
+ menuPosition: "fixed",
1578
+ value: valueAsyncSelect,
1579
+ defaultOptions: optionAsyncSelects,
1580
+ onChange: (val) => {
1581
+ row[col.field] = val ? val[col.selectSettings?.fieldValue ?? "value"] : void 0;
1582
+ if (col.callback) {
1583
+ col.callback(val, indexRow);
1584
+ }
1585
+ handleDataChange(row, col, indexRow);
1586
+ },
1587
+ menuPortalTarget: document.body,
1588
+ isClearable: col.selectSettings?.isClearable ?? false,
1589
+ classNamePrefix: col.selectSettings?.widthPopup ? `width-popup-${col.selectSettings?.widthPopup}` : "select",
1590
+ placeholder: t("Select"),
1591
+ id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1592
+ loadOptions: col.selectSettings?.loadOptions,
1593
+ className: (0, import_classnames9.default)("react-select"),
1594
+ onKeyDown: (e) => {
1595
+ if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
1596
+ }
1597
+ }
1598
+ }
1599
+ ),
1600
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1601
+ "span",
1602
+ {
1603
+ onClick: () => {
1604
+ if (col.selectSettings?.handIconGroupClick) {
1605
+ col.selectSettings?.handIconGroupClick("right");
1606
+ }
1607
+ },
1608
+ className: (0, import_classnames9.default)("input-group-text", { "d-none": !col.selectSettings?.iconGroup }),
1609
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(icon_default, { iconName: col.selectSettings?.iconGroup ?? "", size: 16 })
1610
+ }
1611
+ )
1612
+ ] });
1613
+ case "select":
1614
+ let valueSelect;
1615
+ let options = [];
1616
+ if (col.selectSettings?.optionsField) {
1617
+ options = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
1618
+ } else {
1619
+ options = col.selectSettings?.options ? col.selectSettings?.validateOption ? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row)) : col.selectSettings?.options : [];
1620
+ }
1621
+ if (col.selectSettings?.isMulti) {
1622
+ valueSelect = !isNullOrUndefined(row[col.field]) && row[col.field]?.length > 0 ? options?.filter((val) => row[col.field]?.includes(val[col.selectSettings?.fieldValue ?? "value"])) : [];
1623
+ } else {
1624
+ valueSelect = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? options?.find((val) => val[col.selectSettings?.fieldValue ?? "value"] === row[col.field]) : "";
1625
+ }
1626
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1627
+ import_react_select2.default,
1628
+ {
1629
+ menuPosition: "fixed",
1630
+ id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1631
+ value: valueSelect,
1632
+ options,
1633
+ onChange: (val) => {
1634
+ row[col.field] = col.selectSettings?.isMulti ? val?.map((item) => item[col.selectSettings?.fieldValue ?? "value"]) ?? [] : val ? val[col.selectSettings?.fieldValue ?? "value"] : void 0;
1635
+ if (col.callback) {
1636
+ col.callback(val, indexRow);
1637
+ }
1638
+ handleDataChange(row, col, indexRow);
1639
+ },
1640
+ menuPortalTarget: document.body,
1641
+ isMulti: col.selectSettings?.isMulti ?? false,
1642
+ isClearable: col.selectSettings?.isClearable ?? false,
1643
+ classNamePrefix: col.selectSettings?.widthPopup ? `width-popup-${col.selectSettings?.widthPopup}` : "select",
1644
+ placeholder: t("Select"),
1645
+ className: (0, import_classnames9.default)("react-select", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1646
+ onKeyDown: (e) => {
1647
+ if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
1648
+ }
1649
+ }
1650
+ }
1651
+ );
1652
+ case "selectTree":
1653
+ let valueSelectTree = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? [row[col.field]] : [];
1654
+ const findItemInTree = (items, value) => {
1655
+ for (let index = 0; index < items.length; index++) {
1656
+ const item = items[index];
1657
+ if (item[col.selectSettings?.fieldValue ? col.selectSettings?.fieldValue : "value"] === value) {
1658
+ return { ...item };
1659
+ } else if (item["children"]?.length > 0) {
1660
+ const itemFilter = findItemInTree(item["children"], value);
1661
+ if (itemFilter) {
1662
+ return itemFilter;
1663
+ }
1664
+ }
1665
+ }
1666
+ };
1667
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1668
+ "div",
1669
+ {
1670
+ onKeyDown: (e) => {
1671
+ if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
1672
+ }
1673
+ },
1674
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1675
+ import_ej2_react_dropdowns.DropDownTreeComponent,
1676
+ {
1677
+ id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1678
+ fields: {
1679
+ dataSource: col.selectSettings?.options,
1680
+ value: col.selectSettings?.fieldValue ? col.selectSettings?.fieldValue : "value",
1681
+ text: "label",
1682
+ parentValue: "parentId",
1683
+ child: "children"
1684
+ },
1685
+ className: (0, import_classnames9.default)("select-tree", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1686
+ allowFiltering: false,
1687
+ value: valueSelectTree,
1688
+ popupHeight: 250,
1689
+ popupWidth: "auto",
1690
+ changeOnBlur: false,
1691
+ showClearButton: col.selectSettings?.isClearable,
1692
+ change: (val) => {
1693
+ const item = val?.value?.length > 0 ? val?.value[0] : void 0;
1694
+ if (row[col.field] !== item) {
1695
+ row[col.field] = item;
1696
+ if (col.callback) {
1697
+ col.callback(item ? findItemInTree(col.selectSettings?.options, item) : void 0, indexRow);
1698
+ }
1699
+ handleDataChange(row, col, indexRow);
1700
+ }
1701
+ },
1702
+ open: () => {
1703
+ setOpenPopupTree(true);
1704
+ },
1705
+ close: () => {
1706
+ setOpenPopupTree(false);
1707
+ }
1708
+ }
1709
+ )
1710
+ }
1711
+ );
1712
+ case "checkbox":
1713
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1714
+ import_reactstrap8.Input,
1715
+ {
1716
+ checked: row[col.field],
1717
+ id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1718
+ type: "checkbox",
1719
+ className: "input-checkbox cursor-pointer",
1720
+ style: { textAlign: col.textAlign ?? "left", marginTop: 6 },
1721
+ onChange: (val) => {
1722
+ row[col.field] = val.currentTarget.checked;
1723
+ if (col.callback) {
1724
+ col.callback(val.target.value, indexRow);
1725
+ }
1726
+ handleDataChange(row, col, indexRow);
1727
+ },
1728
+ onKeyDown: (e) => {
1729
+ if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
1730
+ }
1731
+ }
1732
+ }
1733
+ );
1734
+ case "numeric":
1735
+ let valueCurrency = row[col.field];
1736
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1737
+ import_reactstrap8.Input,
1738
+ {
1739
+ id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1740
+ style: { textAlign: col.textAlign, height: 29 },
1741
+ defaultValue: formartNumberic(valueCurrency, decimalSeparator, thousandSeparator, col.numericSettings?.fraction),
1742
+ className: (0, import_classnames9.default)("border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1743
+ onChange: (val) => {
1744
+ let newVal = "";
1745
+ const flag = val.target?.value.startsWith("-");
1746
+ if (val.target?.value.endsWith(decimalSeparator)) {
1747
+ if ((val.target?.value.match(new RegExp(decimalSeparator === "," ? "," : "\\.", "g")) || []).length > 1 || col.numericSettings?.fraction === 0) {
1748
+ newVal = val.target?.value.slice(0, -1).replaceAll(thousandSeparator, "");
1749
+ } else {
1750
+ newVal = val.target?.value.replaceAll(thousandSeparator, "");
1751
+ }
1752
+ } else {
1753
+ newVal = val.target.value.replaceAll(new RegExp(`[^0-9${decimalSeparator === "," ? "," : "\\."}]`, "g"), "");
1754
+ }
1755
+ val.target.value = flag && col.numericSettings?.min !== 0 ? `-${formartNumberic(newVal, decimalSeparator, thousandSeparator, col.numericSettings?.fraction)}` : formartNumberic(newVal, decimalSeparator, thousandSeparator, col.numericSettings?.fraction);
1756
+ },
1757
+ onFocus: (e) => {
1758
+ e.target.setSelectionRange(0, e.target.innerText.length - 1);
1759
+ },
1760
+ onBlur: (val) => {
1761
+ let newVal = "";
1762
+ const flag = val.target?.value.startsWith("-");
1763
+ if (val.target?.value.endsWith(decimalSeparator)) {
1764
+ newVal = val.target?.value.slice(0, -1).replaceAll(new RegExp(`[^0-9${decimalSeparator === "," ? "," : "\\."}]`, "g"), "");
1765
+ } else {
1766
+ newVal = val.target.value.replaceAll(new RegExp(`[^0-9${decimalSeparator === "," ? "," : "\\."}]`, "g"), "");
1767
+ }
1768
+ if (decimalSeparator === ",") {
1769
+ newVal = newVal.replaceAll(",", ".");
1770
+ }
1771
+ let value = flag ? 0 - Number(newVal) : Number(newVal);
1772
+ if (col.numericSettings?.max !== void 0 && value > col.numericSettings?.max) {
1773
+ val.currentTarget.value = col.numericSettings?.max.toString();
1774
+ value = col.numericSettings?.max;
1775
+ } else if (col.numericSettings?.min !== void 0 && value < col.numericSettings?.min) {
1776
+ value = col.numericSettings?.min;
1777
+ val.currentTarget.value = col.numericSettings?.min.toString();
1778
+ }
1779
+ if (newVal !== row[col.field]) {
1780
+ row[col.field] = value;
1781
+ if (col.callback) {
1782
+ col.callback(val.target.value, indexRow);
1783
+ }
1784
+ handleDataChange(row, col, indexRow);
1785
+ }
1786
+ },
1787
+ onKeyDown: (e) => {
1788
+ if (e.key === "ArrowDown" || e.key === "NumpadEnter" || e.key === "ArrowUp" || e.key === "Enter" || e.key === "Tab") {
1789
+ let newVal = "";
1790
+ const flag = e.target?.value.startsWith("-");
1791
+ if (e.target?.value.endsWith(decimalSeparator)) {
1792
+ newVal = e.target?.value.slice(0, -1).replaceAll(new RegExp(`[^0-9${decimalSeparator === "," ? "," : "\\."}]`, "g"), "");
1793
+ } else {
1794
+ newVal = e.target.value.replaceAll(new RegExp(`[^0-9${decimalSeparator === "," ? "," : "\\."}]`, "g"), "");
1795
+ }
1796
+ if (decimalSeparator === ",") {
1797
+ newVal = newVal.replaceAll(",", ".");
1798
+ }
1799
+ let value = flag ? 0 - Number(newVal) : Number(newVal);
1800
+ if (col.numericSettings?.max !== void 0 && value > col.numericSettings?.max) {
1801
+ e.target.value = col.numericSettings?.max.toString();
1802
+ value = col.numericSettings?.max;
1803
+ } else if (col.numericSettings?.min !== void 0 && value < col.numericSettings?.min) {
1804
+ value = col.numericSettings?.min;
1805
+ e.target.value = col.numericSettings?.min.toString();
1806
+ }
1807
+ if (newVal !== row[col.field]) {
1808
+ row[col.field] = value;
1809
+ if (col.callback) {
1810
+ col.callback(e.target.value, indexRow);
1811
+ }
1812
+ handleDataChange(row, col, indexRow);
1813
+ }
1814
+ }
1815
+ checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
1816
+ },
1817
+ onPaste: (e) => {
1818
+ if (showBottomToolbar && !editDisable && !addDisable) {
1819
+ pasteDataFromExcel(indexRow, indexCol);
1820
+ e.preventDefault();
1821
+ }
1822
+ }
1823
+ }
1824
+ );
1825
+ case "color":
1826
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { padding: "4px 8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1827
+ import_reactstrap8.Input,
1828
+ {
1829
+ type: "color",
1830
+ value: row[col.field],
1831
+ style: { textAlign: col.textAlign ?? "center", padding: 0, height: 23, border: "none" },
1832
+ disabled: editDisable,
1833
+ onChange: (val) => {
1834
+ if (row[col.field] != val.target?.value) {
1835
+ row[col.field] = val.target?.value;
1836
+ if (col.callback) {
1837
+ col.callback(val.target.value, indexRow);
1838
+ }
1839
+ handleDataChange(row, col, indexRow);
1840
+ }
1841
+ },
1842
+ onKeyDown: (val) => {
1843
+ checkKeyDown(val, row, col, indexRow + 1, indexCol + 1);
1844
+ }
1845
+ },
1846
+ `col-${indexRow}-${indexCol}`
1847
+ ) });
1848
+ case "form":
1849
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1850
+ edit_form_default,
1851
+ {
1852
+ id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1853
+ ...col.formSettings,
1854
+ field: col.field,
1855
+ displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) : "",
1856
+ placeholder: col.placeholder ? t(col.placeholder) : "",
1857
+ rowData: row,
1858
+ indexRow,
1859
+ onChange: (val, field) => {
1860
+ row = { ...row, ...val };
1861
+ handleDataChange(row, col, indexRow);
1862
+ },
1863
+ invalid: col.validate && col.validate(row[col.field], row),
1864
+ textAlign: col.textAlign,
1865
+ onKeyDown: (e) => {
1866
+ return checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
1867
+ }
1868
+ }
1869
+ );
1870
+ default:
1871
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1872
+ import_reactstrap8.Input,
1873
+ {
1874
+ id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1875
+ style: { textAlign: col.textAlign, height: 29 },
1876
+ defaultValue: isNullOrUndefined(row[col.field]) ? "" : row[col.field],
1877
+ className: (0, import_classnames9.default)("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1878
+ onBlur: (val) => {
1879
+ if (row[col.field] != val.target?.value) {
1880
+ row[col.field] = val.target?.value;
1881
+ if (col.callback) {
1882
+ col.callback(val.target.value, indexRow);
1883
+ }
1884
+ handleDataChange(row, col, indexRow);
1885
+ }
1886
+ },
1887
+ onKeyDown: (e) => {
1888
+ if (e.key === "ArrowDown" || e.key === "NumpadEnter" || e.key === "ArrowUp" || e.key === "Enter" || e.key === "Tab") {
1889
+ if (row[col.field] != e.target?.value) {
1890
+ row[col.field] = e.target?.value;
1891
+ handleDataChange(row, col, indexRow);
1892
+ if (col.callback) {
1893
+ col.callback(e.target.value, indexRow);
1894
+ }
1895
+ }
1896
+ }
1897
+ checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
1898
+ },
1899
+ onPaste: (e) => {
1900
+ if (showBottomToolbar && !editDisable && !addDisable) {
1901
+ pasteDataFromExcel(indexRow, indexCol);
1902
+ e.preventDefault();
1903
+ }
1904
+ }
1905
+ }
1906
+ );
1907
+ }
1908
+ };
1909
+ const handleCommandClick = (id, rowData, index) => {
1910
+ if (commandClick) {
1911
+ commandClick({ id, rowData, index });
1912
+ }
1913
+ };
1914
+ const renderCommand = (commandItems, rowData, i) => {
1915
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "d-flex align-items-center", style: { columnGap: 10 }, children: commandItems.map((item, index) => {
1916
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1917
+ import_reactstrap8.Button,
1918
+ {
1919
+ tabIndex: -1,
1920
+ style: { padding: "5px", minWidth: 45, height: "100%" },
1921
+ className: (0, import_classnames9.default)("command-item", {
1922
+ "btn-icon": item.tooltip === ""
1923
+ }),
1924
+ color: item.color ? item.color : "#000",
1925
+ onClick: (e) => {
1926
+ handleCommandClick(item.id, rowData, i);
1927
+ if (i === indexFocus) {
1928
+ setIndexFocus(void 0);
1929
+ }
1930
+ e.preventDefault();
1931
+ },
1932
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ej2_react_popups.TooltipComponent, { content: t(item.tooltip ?? ""), children: item.icon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(icon_default, { iconName: item.icon, size: 16 }) })
1933
+ },
1934
+ `command-${index}`
1935
+ );
1936
+ }) }) });
1937
+ };
1938
+ const checkKeyDown = (e, row, col, indexRow, indexCol) => {
1939
+ if (e.code === "ArrowRight") {
1940
+ let newIndexCol = -1;
1941
+ for (let i = indexCol; i < tableColumns.length; i++) {
1942
+ if (tableColumns[i].editEnable && tableColumns[i].visible !== false && (!tableColumns[i].disabledCondition || !tableColumns[i].disabledCondition(row))) {
1943
+ newIndexCol = i + 1;
1944
+ break;
1945
+ }
1946
+ }
1947
+ if (newIndexCol > -1) {
1948
+ const element = document.getElementById(`${idTable}-col${newIndexCol}-row${indexRow}`);
1949
+ if (element) {
1950
+ if (element.className.includes("react-select") || element.className.includes("from-edit")) {
1951
+ element.getElementsByTagName("input")[0]?.focus();
1952
+ } else {
1953
+ element.focus();
1954
+ }
1955
+ element.scrollIntoView({ behavior: "smooth", block: "end", inline: "nearest" });
1956
+ }
1957
+ e.preventDefault();
1958
+ return e.code;
1959
+ }
1960
+ }
1961
+ if (e.code === "ArrowLeft") {
1962
+ let newIndexCol = -1;
1963
+ for (let i = indexCol - 2; i >= 0; i--) {
1964
+ if (tableColumns[i].editEnable && tableColumns[i].visible !== false && (!tableColumns[i].disabledCondition || !tableColumns[i].disabledCondition(row))) {
1965
+ newIndexCol = i + 1;
1966
+ break;
1967
+ }
1968
+ }
1969
+ if (newIndexCol > -1) {
1970
+ const element = document.getElementById(`${idTable}-col${newIndexCol}-row${indexRow}`);
1971
+ if (element) {
1972
+ if (element.className.includes("react-select") || element.className.includes("from-edit")) {
1973
+ element.getElementsByTagName("input")[0]?.focus();
1974
+ } else {
1975
+ element.focus();
1976
+ }
1977
+ element.scrollIntoView({ behavior: "smooth", block: "end", inline: "nearest" });
1978
+ }
1979
+ e.preventDefault();
1980
+ return e.code;
1981
+ }
1982
+ }
1983
+ if (e.code === "ArrowUp") {
1984
+ const element = document.getElementById(`${idTable}-col${indexCol}-row${indexRow}`);
1985
+ if (element && !(element.getElementsByClassName("select__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--100__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--200__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--300__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--400__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--500__control--menu-is-open").length > 0)) {
1986
+ if (indexRow > 1) {
1987
+ setIndexFocus(indexRow - 2);
1988
+ setTimeout(() => {
1989
+ const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow - 1}`);
1990
+ if (element2) {
1991
+ if (element2.className.includes("react-select") || element2.className.includes("from-edit")) {
1992
+ element2.getElementsByTagName("input")[0]?.focus();
1993
+ } else {
1994
+ element2.focus();
1995
+ }
1996
+ }
1997
+ }, 100);
1998
+ e.preventDefault();
1999
+ return e.code;
2000
+ }
2001
+ }
2002
+ }
2003
+ if (e.code === "ArrowDown") {
2004
+ const element = document.getElementById(`${idTable}-col${indexCol}-row${indexRow}`);
2005
+ if (element && !(element.getElementsByClassName("select__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--100__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--200__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--300__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--400__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--500__control--menu-is-open").length > 0)) {
2006
+ if (indexRow < dataSource?.length) {
2007
+ setIndexFocus(indexRow);
2008
+ setTimeout(() => {
2009
+ const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow + 1}`);
2010
+ if (element2) {
2011
+ if (element2.className.includes("react-select") || element2.className.includes("from-edit")) {
2012
+ element2.getElementsByTagName("input")[0]?.focus();
2013
+ } else {
2014
+ element2.focus();
2015
+ }
2016
+ }
2017
+ }, 100);
2018
+ e.preventDefault();
2019
+ return e.code;
2020
+ }
2021
+ }
2022
+ }
2023
+ if (e.code === "Tab" && indexCol === columnLastEdit) {
2024
+ if (indexRow === dataSource?.length) {
2025
+ if (setDataSource) {
2026
+ setDataSource([...dataSource, defaultValue ? { ...defaultValue } : {}]);
2027
+ }
2028
+ if (tableElement) {
2029
+ setTimeout(() => {
2030
+ tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
2031
+ }, 100);
2032
+ }
2033
+ if (!(!editDisable && !addDisable)) {
2034
+ return false;
2035
+ }
2036
+ }
2037
+ setIndexFocus(indexRow);
2038
+ setTimeout(() => {
2039
+ const element = document.getElementById(`${idTable}-col${columnFistEdit}-row${indexRow + 1}`);
2040
+ if (element) {
2041
+ if (element.className.includes("react-select") || element.className.includes("from-edit")) {
2042
+ element.getElementsByTagName("input")[0]?.focus();
2043
+ } else {
2044
+ element.focus();
2045
+ element.scrollIntoView();
2046
+ }
2047
+ }
2048
+ }, 100);
2049
+ e.preventDefault();
2050
+ }
2051
+ if ((e.code === "Enter" || e.code === "NumpadEnter") && (!editDisable && !addDisable)) {
2052
+ const element = document.getElementById(`${idTable}-col${indexCol}-row${indexRow}`);
2053
+ if (element && !(element.getElementsByClassName("select__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--100__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--200__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--300__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--400__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--500__control--menu-is-open").length > 0)) {
2054
+ if (indexRow < dataSource?.length) {
2055
+ setIndexFocus(indexRow);
2056
+ setTimeout(() => {
2057
+ const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow + 1}`);
2058
+ if (element2) {
2059
+ if (element2.className.includes("react-select") || element2.className.includes("from-edit")) {
2060
+ element2.getElementsByTagName("input")[0]?.focus();
2061
+ } else {
2062
+ element2.focus();
2063
+ }
2064
+ }
2065
+ }, 100);
2066
+ } else {
2067
+ handleAdd();
2068
+ }
2069
+ e.preventDefault();
2070
+ return e.code;
2071
+ }
2072
+ }
2073
+ if (e.code === "KeyD" && e.ctrlKey == true && (!editDisable && !addDisable)) {
2074
+ handleDuplicate(dataSource[indexFocus ?? -1], indexRow);
2075
+ e.preventDefault();
2076
+ return e.code;
2077
+ }
2078
+ return "";
2079
+ };
2080
+ const onChangePage = (args) => {
2081
+ if (args.newProp.currentPage === args.oldProp.currentPage) {
2082
+ return;
2083
+ }
2084
+ setCurrentPage(args.currentPage);
2085
+ };
2086
+ const onChangePageSize = (args) => {
2087
+ if (allowPaging) {
2088
+ if (pageSize !== args.pageSize) {
2089
+ setPageSize(args.pageSize);
2090
+ setCurrentPage(1);
2091
+ }
2092
+ }
2093
+ };
2094
+ useOnClickOutside(gridRef, () => {
2095
+ if (!openPopupTree) {
2096
+ setTimeout(() => {
2097
+ setIndexFocus(-1);
2098
+ }, 50);
2099
+ }
2100
+ });
2101
+ const handleAdd = () => {
2102
+ if (setDataSource) {
2103
+ setDataSource([...dataSource, defaultValue ? { ...defaultValue, id: generateUUID() } : {}]);
2104
+ }
2105
+ if (tableElement) {
2106
+ setIndexFocus(dataSource?.length);
2107
+ setTimeout(() => {
2108
+ tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
2109
+ const element = document.getElementById(`${idTable}-col${columnFistEdit}-row${dataSource?.length + 1}`);
2110
+ if (element && !(element.getElementsByClassName("select__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--100__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--200__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--300__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--400__control--menu-is-open").length > 0 || element.getElementsByClassName("width-popup--500__control--menu-is-open").length > 0)) {
2111
+ if (element.className.includes("react-select") || element.className.includes("from-edit")) {
2112
+ element.getElementsByTagName("input")[0]?.focus();
2113
+ } else {
2114
+ element.focus();
2115
+ }
2116
+ }
2117
+ }, 100);
2118
+ }
2119
+ };
2120
+ const deleteAll = () => {
2121
+ if (!editDisable && !addDisable) {
2122
+ setIndexFocus(-1);
2123
+ if (setDataSource) {
2124
+ setDataSource([]);
2125
+ }
2126
+ }
2127
+ };
2128
+ const handleDuplicate = (data, index) => {
2129
+ if (showBottomToolbar && !editDisable && !addDisable) {
2130
+ if (fieldKey) {
2131
+ const newdata = { ...data };
2132
+ fieldUniKey.forEach((item) => {
2133
+ newdata[item] = defaultValue[item];
2134
+ });
2135
+ newdata[fieldKey] = defaultValue[fieldKey];
2136
+ dataSource?.splice(index, 0, newdata);
2137
+ } else {
2138
+ dataSource?.splice(index, 0, { ...data });
2139
+ }
2140
+ if (setDataSource) {
2141
+ setDataSource([...dataSource]);
2142
+ }
2143
+ if (tableElement && index === dataSource?.length) {
2144
+ setTimeout(() => {
2145
+ tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
2146
+ }, 100);
2147
+ }
2148
+ }
2149
+ };
2150
+ const handleInsertAfter = () => {
2151
+ if (showBottomToolbar && !editDisable && !addDisable) {
2152
+ dataSource?.splice((indexFocus ?? -1) + 1, 0, { ...defaultValue });
2153
+ if (setDataSource) {
2154
+ setDataSource([...dataSource]);
2155
+ }
2156
+ if (tableElement && indexFocus === dataSource?.length) {
2157
+ setTimeout(() => {
2158
+ tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
2159
+ }, 100);
2160
+ }
2161
+ }
2162
+ };
2163
+ const handleInsertBefore = () => {
2164
+ if (showBottomToolbar && !editDisable && !addDisable) {
2165
+ dataSource?.splice(indexFocus ?? -1, 0, { ...defaultValue });
2166
+ if (setDataSource) {
2167
+ setDataSource([...dataSource]);
2168
+ }
2169
+ }
2170
+ };
2171
+ const handleDeleteAll = () => {
2172
+ if (showBottomToolbar && !editDisable && !addDisable) {
2173
+ messageBoxConfirmDelete(t, deleteAll, "");
2174
+ }
2175
+ };
2176
+ const pasteDataFromExcel = async (row, col) => {
2177
+ const clipboard = await navigator.clipboard.readText();
2178
+ const arrayRow = clipboard.trimEnd().split("\n");
2179
+ arrayRow.forEach((item, indexRow) => {
2180
+ const arrayCol = item.trimEnd().split(" ");
2181
+ let dataRow = dataSource[row + indexRow];
2182
+ if (!dataRow) {
2183
+ dataRow = { ...defaultValue };
2184
+ dataSource?.push(dataRow);
2185
+ }
2186
+ arrayCol.forEach((element, index) => {
2187
+ const column = tableColumns[col + index];
2188
+ if ((!column.disabledCondition || !column.disabledCondition(row)) && column.editEnable) {
2189
+ dataRow[column.field] = element;
2190
+ }
2191
+ });
2192
+ rowChange(dataRow, row + indexRow, "");
2193
+ });
2194
+ handleRefeshRow();
2195
+ if (setDataSource) {
2196
+ setDataSource([...dataSource]);
2197
+ }
2198
+ };
2199
+ (0, import_react12.useEffect)(() => {
2200
+ if (setSelectedItem) {
2201
+ if (isMulti) {
2202
+ if (dataSource && selectedRows && selectedRows?.length !== selectedItem?.length) {
2203
+ setSelectedItem([...selectedRows]);
2204
+ }
2205
+ } else {
2206
+ if (dataSource && selectedRows?.length > 0) {
2207
+ if (!selectedItem || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
2208
+ setSelectedItem({ ...selectedRows[0] });
2209
+ }
2210
+ } else {
2211
+ setSelectedItem(void 0);
2212
+ }
2213
+ }
2214
+ }
2215
+ }, [selectedRows]);
2216
+ (0, import_react12.useEffect)(() => {
2217
+ if (!isMulti) {
2218
+ if (dataSource && selectedItem && selectedItem[fieldKey]) {
2219
+ if (selectedRows?.length === 0 || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
2220
+ setSelectedRows([selectedItem]);
2221
+ }
2222
+ } else {
2223
+ setSelectedRows([]);
2224
+ }
2225
+ } else {
2226
+ if (dataSource && selectedItem && selectedRows?.length !== selectedItem.length) {
2227
+ setSelectedRows(selectedItem ? [...selectedItem] : []);
2228
+ }
2229
+ }
2230
+ }, [selectedItem]);
2231
+ const renderContentCol = (col, row, indexRow, indexCol, isSelected) => {
2232
+ if (col.field === "command") {
2233
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2234
+ "td",
2235
+ {
2236
+ className: (0, import_classnames9.default)(`e-rowcell p-0 fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "e-active": isSelected && editDisable || indexFocus === indexRow }),
2237
+ style: {
2238
+ width: col.width,
2239
+ minWidth: col.minWidth,
2240
+ maxWidth: col.maxWidth,
2241
+ left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
2242
+ right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
2243
+ textAlign: col.textAlign ? col.textAlign : "left"
2244
+ },
2245
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-rowcell-div ", children: renderCommand(col.commandItems, row, indexRow) })
2246
+ },
2247
+ `col-${indexRow}-${indexCol}`
2248
+ );
2249
+ } else if (col.field === "#") {
2250
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2251
+ "td",
2252
+ {
2253
+ className: (0, import_classnames9.default)(`e-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "e-active": isSelected && editDisable || indexFocus === indexRow }),
2254
+ tabIndex: Number(`${indexRow}${indexCol}`),
2255
+ style: {
2256
+ width: 40,
2257
+ minWidth: 40,
2258
+ maxWidth: 40,
2259
+ left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
2260
+ right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
2261
+ textAlign: "center"
2262
+ },
2263
+ onCopy: (e) => {
2264
+ if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
2265
+ navigator.clipboard.writeText(JSON.stringify(row));
2266
+ notificationSuccess(t("CopySuccessful"));
2267
+ e.stopPropagation();
2268
+ }
2269
+ },
2270
+ onPaste: (e) => {
2271
+ if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
2272
+ navigator.clipboard.readText().then((rs) => {
2273
+ dataSource[indexRow] = JSON.parse(rs);
2274
+ if (fieldKey) {
2275
+ dataSource[indexRow][fieldKey] = defaultValue[fieldKey];
2276
+ }
2277
+ if (setDataSource) {
2278
+ setDataSource([...dataSource]);
2279
+ }
2280
+ notificationSuccess(t("PasteSuccessful"));
2281
+ }).catch((ex) => {
2282
+ alert(ex);
2283
+ });
2284
+ e.stopPropagation();
2285
+ }
2286
+ },
2287
+ onClick: (e) => {
2288
+ if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
2289
+ if (!editDisable && indexRow != indexFocus) {
2290
+ setIndexFocus(indexRow);
2291
+ }
2292
+ e.stopPropagation();
2293
+ }
2294
+ },
2295
+ onKeyDown: (e) => {
2296
+ if (e.code === "KeyD" && e.ctrlKey == true && (!editDisable && !addDisable) && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
2297
+ handleDuplicate(row, indexRow);
2298
+ e.preventDefault();
2299
+ e.stopPropagation();
2300
+ }
2301
+ },
2302
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-rowcell-div pt-50", children: indexRow + 1 })
2303
+ },
2304
+ `col-${indexRow}-${indexCol}`
2305
+ );
2306
+ } else if (col.field === "checkbox") {
2307
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2308
+ "td",
2309
+ {
2310
+ className: (0, import_classnames9.default)(`e-rowcell p-0 fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "e-active": isSelected && editDisable || indexFocus === indexRow }),
2311
+ style: {
2312
+ width: col.width,
2313
+ minWidth: col.minWidth,
2314
+ maxWidth: col.maxWidth,
2315
+ left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
2316
+ right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
2317
+ textAlign: col.textAlign ? col.textAlign : "center"
2318
+ },
2319
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2320
+ "div",
2321
+ {
2322
+ className: "e-rowcell-div cursor-pointer",
2323
+ onClick: (e) => {
2324
+ if (selectEnable) {
2325
+ const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
2326
+ if (index > -1) {
2327
+ if (isMulti) {
2328
+ selectedRows?.splice(index, 1);
2329
+ setSelectedRows([...selectedRows]);
2330
+ } else {
2331
+ setSelectedRows([]);
2332
+ }
2333
+ } else {
2334
+ if (isMulti) {
2335
+ setSelectedRows([...selectedRows, row]);
2336
+ } else {
2337
+ setSelectedRows([row]);
2338
+ }
2339
+ }
2340
+ e.stopPropagation();
2341
+ }
2342
+ },
2343
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2344
+ import_reactstrap8.Input,
2345
+ {
2346
+ checked: isSelected,
2347
+ type: "checkbox",
2348
+ className: "cursor-pointer",
2349
+ onChange: () => {
2350
+ },
2351
+ style: { textAlign: col.textAlign ?? "center", marginTop: 6 }
2352
+ }
2353
+ )
2354
+ }
2355
+ )
2356
+ },
2357
+ `col-${indexRow}-${indexCol}`
2358
+ );
2359
+ } else {
2360
+ let value = row[col.field];
2361
+ if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
2362
+ value = formartNumberic(row[col.field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) ?? 0;
2363
+ } else if (col.editType === "date") {
2364
+ value = value ? (0, import_moment.default)(value).format("DD/MM/yyyy") : "";
2365
+ } else if (col.editType === "datetime") {
2366
+ value = value ? (0, import_moment.default)(value).format("DD/MM/yyyy HH:mm") : "";
2367
+ }
2368
+ const typeDis = !editDisable && (indexFocus === indexRow || col.editType === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row)) ? col.editEnable ? 1 : col.template ? 2 : 3 : col.template ? 2 : 3;
2369
+ const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
2370
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2371
+ "td",
2372
+ {
2373
+ className: (0, import_classnames9.default)(`e-rowcell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "e-active": isSelected && editDisable || indexFocus === indexRow }),
2374
+ style: {
2375
+ left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
2376
+ right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
2377
+ padding: 0,
2378
+ textAlign: col.textAlign ? col.textAlign : "left"
2379
+ },
2380
+ onFocus: (e) => {
2381
+ if (!editDisable && indexRow != indexFocus) {
2382
+ setIndexFocus(indexRow);
2383
+ }
2384
+ e.stopPropagation();
2385
+ },
2386
+ onClick: (e) => {
2387
+ if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
2388
+ if (!editDisable && indexRow != indexFocus) {
2389
+ setIndexFocus(indexRow);
2390
+ }
2391
+ if (selectEnable && editDisable) {
2392
+ const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
2393
+ if (index > -1) {
2394
+ if (isMulti) {
2395
+ selectedRows?.splice(index, 1);
2396
+ setSelectedRows([...selectedRows]);
2397
+ } else {
2398
+ setSelectedRows([]);
2399
+ }
2400
+ } else {
2401
+ if (isMulti) {
2402
+ setSelectedRows([...selectedRows, row]);
2403
+ } else {
2404
+ setSelectedRows([row]);
2405
+ }
2406
+ }
2407
+ }
2408
+ e.stopPropagation();
2409
+ }
2410
+ },
2411
+ title: `${value ?? ""}`,
2412
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2413
+ "div",
2414
+ {
2415
+ id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : "",
2416
+ className: (0, import_classnames9.default)("e-rowcell-div", { "is-invalid": errorMessage }),
2417
+ style: { padding: typeDis !== 1 ? errorMessage ? "2px 10px" : "6px 10px" : 2 },
2418
+ children: [
2419
+ typeDis === 1 && !refreshRow ? renderEdit(row, col, indexRow, indexCol) : typeDis === 2 ? col.template(row, indexRow) : value,
2420
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "icon-table", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ej2_react_popups.TooltipComponent, { className: (0, import_classnames9.default)("cursor-pointer text-primary", { "d-none": !errorMessage }), content: errorMessage, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_becoxy_icons4.AlertCircle, { fontSize: 16.5 }) }) })
2421
+ ]
2422
+ }
2423
+ )
2424
+ },
2425
+ `col-${indexRow}-${indexCol}`
2426
+ ) }, indexCol);
2427
+ }
2428
+ };
2429
+ const renderHeaderCol = (col, indexCol) => {
2430
+ if (col.field === "checkbox") {
2431
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2432
+ "th",
2433
+ {
2434
+ className: (0, import_classnames9.default)(`e-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2435
+ style: {
2436
+ width: col.width,
2437
+ padding: 0,
2438
+ minWidth: col.minWidth,
2439
+ left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
2440
+ right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
2441
+ maxWidth: col.maxWidth
2442
+ },
2443
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2444
+ "div",
2445
+ {
2446
+ style: { textAlign: "center", justifyContent: col.textAlign ?? "center" },
2447
+ className: (0, import_classnames9.default)("e-headercell-div"),
2448
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2449
+ import_reactstrap8.Input,
2450
+ {
2451
+ checked: selectedRows?.length >= dataSource?.length && dataSource?.length > 0,
2452
+ type: "checkbox",
2453
+ className: (0, import_classnames9.default)("cursor-pointer", { "d-none": !isMulti }),
2454
+ style: { textAlign: col.textAlign ?? "center", marginTop: 6 },
2455
+ onChange: (e) => {
2456
+ if (selectEnable) {
2457
+ if (e.target.checked) {
2458
+ const arr = dataSource?.map((item) => {
2459
+ return item;
2460
+ });
2461
+ setSelectedRows(arr);
2462
+ } else {
2463
+ setSelectedRows([]);
2464
+ }
2465
+ }
2466
+ }
2467
+ }
2468
+ )
2469
+ }
2470
+ )
2471
+ }
2472
+ ) }, `header-${indexCol}`);
2473
+ } else if (col.field === "#") {
2474
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2475
+ import_react12.Fragment,
2476
+ {
2477
+ children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2478
+ "th",
2479
+ {
2480
+ className: (0, import_classnames9.default)(`e-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2481
+ style: {
2482
+ padding: 0,
2483
+ width: 40,
2484
+ minWidth: 40,
2485
+ maxWidth: 40,
2486
+ left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
2487
+ right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0
2488
+ },
2489
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2490
+ "div",
2491
+ {
2492
+ title: t(col.headerText ?? ""),
2493
+ style: { textAlign: "center", justifyContent: col.textAlign ?? "center" },
2494
+ className: "e-headercell-div",
2495
+ children: t(col.headerText ?? "")
2496
+ }
2497
+ )
2498
+ }
2499
+ )
2500
+ },
2501
+ `header-${indexCol}`
2502
+ );
2503
+ } else {
2504
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2505
+ import_react12.Fragment,
2506
+ {
2507
+ children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2508
+ "th",
2509
+ {
2510
+ className: (0, import_classnames9.default)(`e-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2511
+ style: {
2512
+ width: col.width,
2513
+ padding: 0,
2514
+ minWidth: col.minWidth,
2515
+ left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
2516
+ right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
2517
+ maxWidth: col.maxWidth
2518
+ },
2519
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2520
+ "div",
2521
+ {
2522
+ title: t(col.headerText ?? ""),
2523
+ style: { textAlign: "center", justifyContent: col.textAlign ?? "left" },
2524
+ className: "e-headercell-div",
2525
+ children: t(col.headerText ?? "")
2526
+ }
2527
+ )
2528
+ }
2529
+ )
2530
+ },
2531
+ `header-${indexCol}`
2532
+ );
2533
+ }
2534
+ };
2535
+ const renderFooterCol = (col, indexCol) => {
2536
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2537
+ "td",
2538
+ {
2539
+ className: (0, import_classnames9.default)(`e-summarycell p-0 px-50 fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2540
+ style: {
2541
+ height: 30,
2542
+ fontSize: 14,
2543
+ fontWeight: 600,
2544
+ left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
2545
+ right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
2546
+ width: col.width,
2547
+ minWidth: col.minWidth,
2548
+ maxWidth: col.maxWidth,
2549
+ whiteSpace: "nowrap",
2550
+ textAlign: col.textAlign ? col.textAlign : "left"
2551
+ },
2552
+ children: col.haveSum === true && col.editType === "numeric" ? formartNumberic(dataSource?.reduce(function(accumulator, currentValue) {
2553
+ return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
2554
+ }, 0), decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) : ""
2555
+ }
2556
+ ) }, `summarycell-${indexCol}`);
2557
+ };
2558
+ const renderToolbarTop = () => {
2559
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { id: "table_custom_top_toolbar", className: "e-control e-toolbar", "aria-orientation": "horizontal", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "e-toolbar-items e-tbar-pos", children: [
2560
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-toolbar-left", children: toolbarTopOption?.map((item, index) => {
2561
+ return item.align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-toolbar-item e-template", "aria-disabled": "false", children: item.template() }, `toolbar-top-left-${index}`) : "";
2562
+ }) }),
2563
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-toolbar-center", children: toolbarTopOption?.map((item, index) => {
2564
+ return item.align === "center" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-toolbar-item e-template", "aria-disabled": "false", children: item.template() }, `toolbar-top-center-${index}`) : "";
2565
+ }) }),
2566
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-toolbar-right", children: toolbarTopOption?.map((item, index) => {
2567
+ return item.align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-toolbar-item e-template", "aria-disabled": "false", children: item.template() }, `toolbar-top-right-${index}`) : "";
2568
+ }) })
2569
+ ] }) });
2570
+ };
2571
+ const renderToolbarBottom = () => {
2572
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { id: "table_custom_bottom_toolbar", className: "e-control e-toolbar e-lib e-keyboard ", role: "toolbar", "aria-disabled": "false", "aria-haspopup": "false", "aria-orientation": "horizontal", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "e-toolbar-items e-tbar-pos", children: [
2573
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "e-toolbar-left", children: [
2574
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("e-toolbar-item e-template", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "success", outline: true, onClick: handleAdd, className: "d-flex", children: t("Add item") }) }),
2575
+ (indexFocus ?? -1) > -1 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
2576
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("e-toolbar-item e-template", { "d-none": editDisable || addDisable || duplicateDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "success", outline: true, onClick: () => {
2577
+ handleDuplicate(dataSource[indexFocus ?? -1], indexFocus ?? -1);
2578
+ }, className: "d-flex", children: t("Duplicate") }) }),
2579
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("e-toolbar-item e-template", { "d-none": editDisable || addDisable || insertBeforeDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "success", outline: true, onClick: handleInsertBefore, className: "d-flex", children: t("Insert item before") }) }),
2580
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("e-toolbar-item e-template", { "d-none": editDisable || addDisable || insertAfterDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "success", outline: true, onClick: handleInsertAfter, className: "d-flex", children: t("Insert item after") }) })
2581
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: " " }),
2582
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("e-toolbar-item e-template", { "d-none": editDisable || addDisable || deleteAllDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "primary", outline: true, onClick: handleDeleteAll, className: "d-flex", children: t("Delete all item") }) }),
2583
+ toolbarBottomOptions?.map((item, index) => {
2584
+ return item.align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-toolbar-item e-template", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-left-${index}`) : "";
2585
+ })
2586
+ ] }),
2587
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-toolbar-center", children: toolbarBottomOptions?.map((item, index) => {
2588
+ return item.align === "center" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-toolbar-item e-template", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-center-${index}`) : "";
2589
+ }) }),
2590
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "e-toolbar-right", children: [
2591
+ toolbarBottomOptions?.map((item, index) => {
2592
+ return item.align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-toolbar-item e-template", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-right-${index}`) : "";
2593
+ }),
2594
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("e-toolbar-item e-template me-25"), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_becoxy_icons4.Settings, { className: "text-primary cursor-pointer", onClick: () => setOpenPopupSetupColumn(true) }) }),
2595
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("e-toolbar-item e-template me-25", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_reactstrap8.UncontrolledDropdown, { className: "dropdown-user nav-item", children: [
2596
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.DropdownToggle, { href: "/", tag: "a", color: "info", onClick: (e) => e.preventDefault(), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_becoxy_icons4.Info, { className: "cursor-pointer" }) }),
2597
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.DropdownMenu, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "d-flex flex-column p-50 py-25", children: [
2598
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\xE0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\xE0ng v\xE0 nh\u1EA5n Ctrl + D \u0111\u1EC3 nh\xE2n b\u1EA3n" }),
2599
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { fontSize: 13 }, children: "Ch\u1ECDn \xF4 v\xE0 Ctrl + V \u0111\u1EC3 d\xE1n th\xF4ng tin t\u1EEB excel" }),
2600
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\xE0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\xE0ng v\xE0 nh\u1EA5n Ctrl + C \u0111\u1EC3 sao ch\xE9p h\xE0ng" }),
2601
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\xE0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\xE0ng v\xE0 nh\u1EA5n Ctrl + V \u0111\u1EC3 d\xE1n h\xE0ng" })
2602
+ ] }) })
2603
+ ] }) })
2604
+ ] })
2605
+ ] }) });
2606
+ };
2607
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react12.Fragment, { children: [
2608
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "table-edit-custom", children: [
2609
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "e-grid e-default e-bothlines", children: [
2610
+ showTopToolbar ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: renderToolbarTop() }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, {}),
2611
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { ref: gridRef, children: [
2612
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-gridcontent", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: tableElement, className: "e-content", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("table", { style: { width: "100%" }, children: [
2613
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("thead", { className: "e-gridheader", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { className: "e-row", role: "row", children: tableColumns.map((col, index) => {
2614
+ return renderHeaderCol(col, index);
2615
+ }) }) }),
2616
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { className: "rowgroup", style: { overflowY: "scroll" }, children: dataSource?.map((row, indexRow) => {
2617
+ const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
2618
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2619
+ "tr",
2620
+ {
2621
+ className: "e-row",
2622
+ children: tableColumns.map((col, indexCol) => {
2623
+ return renderContentCol(col, row, indexRow, indexCol, isSelected);
2624
+ })
2625
+ },
2626
+ `row-${indexRow}`
2627
+ );
2628
+ }) }),
2629
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tfoot", { className: "e-gridfoot", children: haveSum == true ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { className: "e-row", children: tableColumns.map((col, index) => {
2630
+ return renderFooterCol(col, index);
2631
+ }) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, {}) })
2632
+ ] }) }) }),
2633
+ showBottomToolbar ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: renderToolbarBottom() }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, {})
2634
+ ] })
2635
+ ] }),
2636
+ allowPaging ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2637
+ import_ej2_react_grids2.PagerComponent,
2638
+ {
2639
+ locale: lang,
2640
+ click: onChangePage,
2641
+ pageSize,
2642
+ currentPage,
2643
+ pageSizes: [20, 30, 50, 100],
2644
+ totalRecordsCount: totalItem ? totalItem : void 0,
2645
+ pageCount: 5,
2646
+ dropDownChanged: onChangePageSize
2647
+ }
2648
+ ) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, {})
2649
+ ] }),
2650
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2651
+ sidebar_setting_column_default,
2652
+ {
2653
+ handleSidebar: () => {
2654
+ setOpenPopupSetupColumn(!openPopupSetupColumn);
2655
+ },
2656
+ openSidebar: openPopupSetupColumn,
2657
+ column: tableColumns,
2658
+ setColumn: setTableColumns
2659
+ }
2660
+ )
2661
+ ] });
2662
+ });
2663
+ var table_default = TableEdit;
2664
+
2665
+ // index.ts
2666
+ var Table_edit_default = table_default;
2667
+ // Annotate the CommonJS export names for ESM import in node:
2668
+ 0 && (module.exports = {
2669
+ messageBoxConfirm,
2670
+ messageBoxConfirm2,
2671
+ messageBoxConfirmApprove,
2672
+ messageBoxConfirmDelete,
2673
+ messageBoxError,
2674
+ messageHtmlBoxError,
2675
+ notificationError,
2676
+ notificationSuccess
2677
+ });