react-table-edit 1.2.47 → 1.2.49

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 CHANGED
@@ -372,238 +372,21 @@ var formatDateTime = (data, format = "dd/MM/yyyy") => {
372
372
  return format.replace(/dd|MM|yyyy|HH|mm/g, (match) => map[match]);
373
373
  };
374
374
 
375
- // src/component/edit-form/index.tsx
376
- var import_react8 = require("react");
377
- var import_reactstrap6 = require("reactstrap");
378
- var import_react_hook_form4 = require("react-hook-form");
379
- var import_yup = require("@hookform/resolvers/yup");
380
- var import_react_i18next5 = require("react-i18next");
381
- var import_classnames6 = __toESM(require("classnames"));
382
-
383
- // src/component/input-text/index.tsx
384
- var import_react_hook_form = require("react-hook-form");
385
- var import_reactstrap2 = require("reactstrap");
386
- var import_classnames2 = __toESM(require("classnames"));
387
- var import_react4 = require("react");
388
- var import_react_i18next = require("react-i18next");
389
- var import_jsx_runtime3 = require("react/jsx-runtime");
390
- var TextInput = (props) => {
391
- const { t } = (0, import_react_i18next.useTranslation)();
392
- const { control, id, name, min, max, type, label, labelSize, required, errors, height, disabled, row, isLabel, placeholder, autoFocus, inLine, callback, readOnly, classes, ...rest } = props;
393
- const renderLabel = () => {
394
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react4.Fragment, { children: isLabel === false ? "" : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_reactstrap2.Label, { for: name, children: [
395
- t(label ? label : ""),
396
- " ",
397
- required ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-danger", children: "*" }) : "",
398
- " "
399
- ] }) });
400
- };
401
- const renderInput = () => {
402
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react4.Fragment, { children: [
403
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
404
- import_react_hook_form.Controller,
405
- {
406
- name,
407
- control,
408
- render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
409
- import_reactstrap2.Input,
410
- {
411
- id,
412
- value: !isNullOrUndefined(value) ? value : "",
413
- onChange: (val) => {
414
- if (min || max) {
415
- if (min && Number(val.target.value) >= min) {
416
- onChange(val.target.value);
417
- if (callback) {
418
- callback(val);
419
- }
420
- }
421
- if (max && Number(val.target.value) <= max) {
422
- onChange(val.target.value);
423
- if (callback) {
424
- callback(val);
425
- }
426
- }
427
- } else {
428
- onChange(val.target.value);
429
- if (callback) {
430
- callback(val);
431
- }
432
- }
433
- },
434
- style: { height: `${height}px` },
435
- autoFocus,
436
- disabled,
437
- placeholder,
438
- type: type ? type : "text",
439
- invalid: errors && true,
440
- className: "h-100",
441
- rows: row,
442
- min,
443
- max,
444
- readOnly,
445
- ...rest
446
- }
447
- )
448
- }
449
- ),
450
- errors && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_reactstrap2.FormFeedback, { children: errors?.message })
451
- ] });
452
- };
453
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
454
- "div",
455
- {
456
- className: (0, import_classnames2.default)(
457
- " align",
458
- {
459
- [labelSize ? labelSize : ""]: labelSize,
460
- [classes ? classes : ""]: classes,
461
- "form-row-inline-error": errors
462
- },
463
- inLine === false ? "form-group " : "form-row-inline d-flex"
464
- ),
465
- children: [
466
- renderLabel(),
467
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: (0, import_classnames2.default)("form-input-content", { "hidden-label": isLabel === false }), children: renderInput() })
468
- ]
469
- }
470
- ) });
471
- };
472
- var input_text_default = TextInput;
473
-
474
- // src/component/input-number/index.tsx
475
- var import_react_hook_form2 = require("react-hook-form");
476
- var import_reactstrap3 = require("reactstrap");
375
+ // src/component/table/paging/index.tsx
376
+ var import_becoxy_icons3 = require("becoxy-icons");
477
377
  var import_classnames3 = __toESM(require("classnames"));
478
378
  var import_react5 = require("react");
479
- var import_react_number_format = require("react-number-format");
480
379
  var import_react_i18next2 = require("react-i18next");
481
- var import_jsx_runtime4 = require("react/jsx-runtime");
482
- var NumberInput = (props) => {
483
- const {
484
- id,
485
- control,
486
- fractionCurrency,
487
- name,
488
- min,
489
- max,
490
- label,
491
- labelSize,
492
- required,
493
- errors,
494
- disabled,
495
- isLabel,
496
- fixedDecimalScale,
497
- placeholder,
498
- inLine,
499
- callback,
500
- decimalSeparator = ",",
501
- thousandSeparator = ".",
502
- classes,
503
- width,
504
- allowNegative
505
- } = props;
506
- const { t } = (0, import_react_i18next2.useTranslation)();
507
- const renderLabel = () => {
508
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.Fragment, { children: isLabel === false ? "" : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_reactstrap3.Label, { className: "form-label", for: name, children: [
509
- t(label ? label : ""),
510
- " ",
511
- required ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-danger", children: "*" }) : "",
512
- " "
513
- ] }) });
514
- };
515
- const renderInput = () => {
516
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react5.Fragment, { children: [
517
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
518
- import_react_hook_form2.Controller,
519
- {
520
- name,
521
- control,
522
- render: ({ field: { value, onChange } }) => {
523
- let floatValue = parseFloat(value);
524
- const numericFormatProps = {
525
- value: !isNullOrUndefined(value) ? value : "",
526
- thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
527
- decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
528
- allowNegative: allowNegative ?? false,
529
- decimalScale: fractionCurrency ?? 0,
530
- fixedDecimalScale
531
- };
532
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
533
- import_react_number_format.NumericFormat,
534
- {
535
- ...numericFormatProps,
536
- className: (0, import_classnames3.default)("form-control text-right", {
537
- "is-invalid": errors
538
- }),
539
- onValueChange: (values) => {
540
- floatValue = values?.floatValue;
541
- const textBeforeDot = values?.value.split(".")[1];
542
- onChange(textBeforeDot ? parseFloat(values?.value).toFixed(textBeforeDot.length) : values?.floatValue);
543
- },
544
- onFocus: (e) => {
545
- e.target.setSelectionRange(0, e.target.innerText.length - 1);
546
- },
547
- onChange: () => {
548
- if (callback) {
549
- callback(floatValue);
550
- }
551
- },
552
- onBlur: () => {
553
- if (max && floatValue > max) {
554
- onChange(max);
555
- } else if (min && floatValue < min) {
556
- onChange(min);
557
- } else {
558
- onChange(floatValue);
559
- }
560
- },
561
- placeholder,
562
- disabled
563
- }
564
- );
565
- }
566
- }
567
- ),
568
- errors && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_reactstrap3.FormFeedback, { children: errors?.message })
569
- ] });
570
- };
571
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
572
- "div",
573
- {
574
- className: (0, import_classnames3.default)(
575
- " align",
576
- {
577
- [labelSize ? labelSize : ""]: labelSize,
578
- [classes ? classes : ""]: classes,
579
- "form-row-inline-error": errors
580
- },
581
- inLine === false ? "form-group " : "form-row-inline d-flex"
582
- ),
583
- children: [
584
- renderLabel(),
585
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { width: width ? width : void 0 }, className: (0, import_classnames3.default)("form-input-content", { "hidden-label": isLabel === false }), children: renderInput() })
586
- ]
587
- }
588
- ) });
589
- };
590
- var input_number_default = NumberInput;
591
-
592
- // src/component/edit-form/select-table/index.tsx
593
- var import_react_hook_form3 = require("react-hook-form");
594
- var import_reactstrap5 = require("reactstrap");
595
- var import_classnames5 = __toESM(require("classnames"));
596
- var import_react7 = require("react");
597
380
 
598
381
  // src/component/select-table/index.tsx
599
- var import_react6 = __toESM(require("react"));
600
- var import_reactstrap4 = require("reactstrap");
601
- var import_react_i18next3 = require("react-i18next");
602
- var import_classnames4 = __toESM(require("classnames"));
382
+ var import_react4 = __toESM(require("react"));
383
+ var import_reactstrap2 = require("reactstrap");
384
+ var import_react_i18next = require("react-i18next");
385
+ var import_classnames2 = __toESM(require("classnames"));
603
386
  var import_becoxy_icons2 = require("becoxy-icons");
604
- var import_jsx_runtime5 = require("react/jsx-runtime");
387
+ var import_jsx_runtime3 = require("react/jsx-runtime");
605
388
  var defaultMaxHeight = 250;
606
- var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
389
+ var SelectTable = (0, import_react4.forwardRef)((props, ref) => {
607
390
  const {
608
391
  id,
609
392
  menuWidth,
@@ -635,18 +418,18 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
635
418
  onPaste,
636
419
  allowCreate
637
420
  } = props;
638
- const selectTableRef = (0, import_react6.useRef)();
639
- const selectMenuTableRef = (0, import_react6.useRef)();
640
- const inputRef = (0, import_react6.useRef)();
641
- const [dropdownOpen, setDropdownOpen] = (0, import_react6.useState)(false);
642
- const [indexFocus, setIndexFocus] = (0, import_react6.useState)(-1);
643
- const [isFocus, setIsFocus] = (0, import_react6.useState)(false);
644
- const [isLoading, setIsLoading] = (0, import_react6.useState)(false);
645
- const [searchTerm, setSearchTerm] = (0, import_react6.useState)("");
646
- const [optionsLoad, setOptionsLoad] = (0, import_react6.useState)();
647
- const [haveCreateNew, setHaveCreateNew] = (0, import_react6.useState)(false);
648
- const { t } = (0, import_react_i18next3.useTranslation)();
649
- const isSelectedAll = (0, import_react6.useMemo)(() => {
421
+ const selectTableRef = (0, import_react4.useRef)();
422
+ const selectMenuTableRef = (0, import_react4.useRef)();
423
+ const inputRef = (0, import_react4.useRef)();
424
+ const [dropdownOpen, setDropdownOpen] = (0, import_react4.useState)(false);
425
+ const [indexFocus, setIndexFocus] = (0, import_react4.useState)(-1);
426
+ const [isFocus, setIsFocus] = (0, import_react4.useState)(false);
427
+ const [isLoading, setIsLoading] = (0, import_react4.useState)(false);
428
+ const [searchTerm, setSearchTerm] = (0, import_react4.useState)("");
429
+ const [optionsLoad, setOptionsLoad] = (0, import_react4.useState)();
430
+ const [haveCreateNew, setHaveCreateNew] = (0, import_react4.useState)(false);
431
+ const { t } = (0, import_react_i18next.useTranslation)();
432
+ const isSelectedAll = (0, import_react4.useMemo)(() => {
650
433
  return isMulti === true && (optionsLoad ? optionsLoad : options).length > 0 && value?.length >= (optionsLoad ? optionsLoad : options).length;
651
434
  }, [optionsLoad, options, value]);
652
435
  const defaultColumns = [
@@ -671,7 +454,7 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
671
454
  }
672
455
  onChange(val);
673
456
  };
674
- (0, import_react6.useEffect)(() => {
457
+ (0, import_react4.useEffect)(() => {
675
458
  if (dropdownOpen && value && !isMulti && selectMenuTableRef) {
676
459
  const index = (optionsLoad ? optionsLoad : options)?.findIndex((e) => e[fieldValue ?? "value"] === value[fieldValue ?? "value"]);
677
460
  if (index >= 0) {
@@ -679,7 +462,7 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
679
462
  }
680
463
  }
681
464
  }, [dropdownOpen]);
682
- (0, import_react6.useEffect)(() => {
465
+ (0, import_react4.useEffect)(() => {
683
466
  if (inputRef && !isDisabled) {
684
467
  inputRef.current.addEventListener("blur", function() {
685
468
  if (onCloseMenu) {
@@ -696,7 +479,7 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
696
479
  });
697
480
  }
698
481
  }, [inputRef]);
699
- (0, import_react6.useEffect)(() => {
482
+ (0, import_react4.useEffect)(() => {
700
483
  if (searchTerm) {
701
484
  if (!dropdownOpen) {
702
485
  setDropdownOpen(true);
@@ -704,7 +487,7 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
704
487
  setIndexFocus(-1);
705
488
  }
706
489
  }, [searchTerm]);
707
- (0, import_react6.useEffect)(() => {
490
+ (0, import_react4.useEffect)(() => {
708
491
  if (dropdownOpen && onOpenMenu) {
709
492
  onOpenMenu();
710
493
  }
@@ -836,13 +619,13 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
836
619
  }, 100);
837
620
  };
838
621
  const renderHeaderCol = (col, indexCol) => {
839
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
840
- import_react6.Fragment,
622
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
623
+ import_react4.Fragment,
841
624
  {
842
- children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
625
+ children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
843
626
  "th",
844
627
  {
845
- className: (0, import_classnames4.default)(
628
+ className: (0, import_classnames2.default)(
846
629
  `r-select-headercell fix-${col.fixedType}`,
847
630
  { "cell-fixed": col.fixedType }
848
631
  ),
@@ -852,7 +635,7 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
852
635
  top: `${0 * 35}px`,
853
636
  maxWidth: col.maxWidth
854
637
  },
855
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
638
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
856
639
  "div",
857
640
  {
858
641
  role: "textbox",
@@ -887,7 +670,7 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
887
670
  setIsLoading(false);
888
671
  setOptionsLoad(rs);
889
672
  };
890
- (0, import_react6.useEffect)(() => {
673
+ (0, import_react4.useEffect)(() => {
891
674
  if (!searchTerm) {
892
675
  setOptionsLoad(void 0);
893
676
  } else if (allowCreate && !(optionsLoad ? optionsLoad : options)?.find((x) => x[fieldLabel ?? "label"] === searchTerm)) {
@@ -900,19 +683,19 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
900
683
  const element = document.getElementById(`select-${id}-${indexRow}-${indexCol}`);
901
684
  return element && element.scrollWidth > element.clientWidth;
902
685
  };
903
- const RenderElement = import_react6.default.memo((props2) => {
686
+ const RenderElement = import_react4.default.memo((props2) => {
904
687
  const { indexRow, row, isSelected, level = 0 } = props2;
905
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
688
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
906
689
  "tr",
907
690
  {
908
691
  id: `row-select-table-${indexRow}`,
909
692
  style: { paddingLeft: 10 * level },
910
- className: (0, import_classnames4.default)("r-select-row", { "last-row": indexRow === (optionsLoad ? optionsLoad : options).length - 1 }, { "fisrt-row": indexRow === 0 }),
693
+ className: (0, import_classnames2.default)("r-select-row", { "last-row": indexRow === (optionsLoad ? optionsLoad : options).length - 1 }, { "fisrt-row": indexRow === 0 }),
911
694
  children: [
912
- isMulti && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
695
+ isMulti && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
913
696
  "td",
914
697
  {
915
- className: (0, import_classnames4.default)(`r-select-rowcell`, { "r-select-move": indexFocus === indexRow, "r-select-active": !isMulti && value && value[fieldValue ?? "value"] === row[fieldValue ?? "value"] }),
698
+ className: (0, import_classnames2.default)(`r-select-rowcell`, { "r-select-move": indexFocus === indexRow, "r-select-active": !isMulti && value && value[fieldValue ?? "value"] === row[fieldValue ?? "value"] }),
916
699
  style: { width: 40, textAlign: "center", padding: 0, paddingBottom: 6 },
917
700
  onClick: (e) => {
918
701
  if (isMulti) {
@@ -931,8 +714,8 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
931
714
  e.stopPropagation();
932
715
  }
933
716
  },
934
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
935
- import_reactstrap4.Input,
717
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
718
+ import_reactstrap2.Input,
936
719
  {
937
720
  checked: isSelected,
938
721
  type: "checkbox",
@@ -953,12 +736,12 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
953
736
  } else if (col.type === "datetime") {
954
737
  valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
955
738
  }
956
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react6.Fragment, { children: [
957
- col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
739
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react4.Fragment, { children: [
740
+ col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
958
741
  "td",
959
742
  {
960
743
  id: `select-${id}-${indexRow}-${indexCol}`,
961
- className: (0, import_classnames4.default)(`r-select-rowcell`, { "r-select-move": indexFocus === indexRow, "r-select-active": !isMulti && value && value[fieldValue ?? "value"] === row[fieldValue ?? "value"] }),
744
+ className: (0, import_classnames2.default)(`r-select-rowcell`, { "r-select-move": indexFocus === indexRow, "r-select-active": !isMulti && value && value[fieldValue ?? "value"] === row[fieldValue ?? "value"] }),
962
745
  style: {
963
746
  minWidth: col.minWidth,
964
747
  width: col.width,
@@ -993,14 +776,14 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
993
776
  }
994
777
  e.stopPropagation();
995
778
  },
996
- children: col.template ? col.template(row, indexRow) : col.type === "numeric" && Number(row[col.field]) < 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [
779
+ children: col.template ? col.template(row, indexRow) : col.type === "numeric" && Number(row[col.field]) < 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [
997
780
  " ",
998
781
  `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`
999
782
  ] }) : valueDisplay
1000
783
  },
1001
784
  `col-${indexRow}-${indexCol}`
1002
785
  ),
1003
- checkOverflow(indexRow, indexCol) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_reactstrap4.UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `select-${id}-${indexRow}-${indexCol}`, children: col.template ? col.template(row, indexRow) : valueDisplay })
786
+ checkOverflow(indexRow, indexCol) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_reactstrap2.UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `select-${id}-${indexRow}-${indexCol}`, children: col.template ? col.template(row, indexRow) : valueDisplay })
1004
787
  ] }, indexCol);
1005
788
  })
1006
789
  ]
@@ -1010,16 +793,16 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
1010
793
  });
1011
794
  const RenderTable = (props2) => {
1012
795
  const {} = props2;
1013
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1014
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("table", { style: { width: "100%" }, children: [
1015
- !(noHeader || (columns?.length ?? 0) === 0) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { className: "r-select-gridheader", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { className: "r-select-row", role: "row", children: [
1016
- isMulti && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: (0, import_classnames4.default)(`r-select-headercell`), style: { width: 40, top: `0px` }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
796
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
797
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("table", { style: { width: "100%" }, children: [
798
+ !(noHeader || (columns?.length ?? 0) === 0) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("thead", { className: "r-select-gridheader", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tr", { className: "r-select-row", role: "row", children: [
799
+ isMulti && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { className: (0, import_classnames2.default)(`r-select-headercell`), style: { width: 40, top: `0px` }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1017
800
  "div",
1018
801
  {
1019
802
  style: { justifyContent: "center" },
1020
- className: (0, import_classnames4.default)("r-select-headercell-div"),
1021
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1022
- import_reactstrap4.Input,
803
+ className: (0, import_classnames2.default)("r-select-headercell-div"),
804
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
805
+ import_reactstrap2.Input,
1023
806
  {
1024
807
  checked: isSelectedAll,
1025
808
  type: "checkbox",
@@ -1034,7 +817,7 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
1034
817
  }
1035
818
  },
1036
819
  readOnly: true,
1037
- className: (0, import_classnames4.default)("cursor-pointer", { "d-none": !isMulti }),
820
+ className: (0, import_classnames2.default)("cursor-pointer", { "d-none": !isMulti }),
1038
821
  style: { textAlign: "center", marginTop: 6 }
1039
822
  }
1040
823
  )
@@ -1044,46 +827,46 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
1044
827
  return renderHeaderCol(col, index);
1045
828
  })
1046
829
  ] }) }),
1047
- (optionsLoad ? optionsLoad : options) && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tbody", { className: "r-select-gridcontent", children: [
1048
- haveCreateNew && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RenderElement, { isSelected: false, indexRow: 0, row: { valueCreate: searchTerm, [fieldValue ?? "value"]: searchTerm, [fieldLabel ?? "label"]: `${t("Create")} '${searchTerm}'`, isCreated: true } }),
830
+ (optionsLoad ? optionsLoad : options) && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tbody", { className: "r-select-gridcontent", children: [
831
+ haveCreateNew && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RenderElement, { isSelected: false, indexRow: 0, row: { valueCreate: searchTerm, [fieldValue ?? "value"]: searchTerm, [fieldLabel ?? "label"]: `${t("Create")} '${searchTerm}'`, isCreated: true } }),
1049
832
  (optionsLoad ? optionsLoad : options)?.map((row, indexRow) => {
1050
833
  const isSelected = isMulti && value?.some((x) => x[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
1051
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RenderElement, { isSelected: isSelected ?? false, indexRow: indexRow + (haveCreateNew ? 1 : 0), row }, `select-table-${indexRow}`);
834
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RenderElement, { isSelected: isSelected ?? false, indexRow: indexRow + (haveCreateNew ? 1 : 0), row }, `select-table-${indexRow}`);
1052
835
  })
1053
836
  ] }) })
1054
837
  ] }),
1055
- ((optionsLoad ? optionsLoad : options)?.length ?? 0) === 0 && !haveCreateNew && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "r-no-data", children: [
1056
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [
1057
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ellipse", { fill: "#f5f5f5", cx: "32", cy: "33", rx: "32", ry: "7" }),
1058
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("g", { fillRule: "nonzero", stroke: "#d9d9d9", children: [
1059
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" }),
1060
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z", fill: "#fafafa" })
838
+ ((optionsLoad ? optionsLoad : options)?.length ?? 0) === 0 && !haveCreateNew && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "r-no-data", children: [
839
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [
840
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ellipse", { fill: "#f5f5f5", cx: "32", cy: "33", rx: "32", ry: "7" }),
841
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("g", { fillRule: "nonzero", stroke: "#d9d9d9", children: [
842
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" }),
843
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z", fill: "#fafafa" })
1061
844
  ] })
1062
845
  ] }) }),
1063
846
  t("No data available.")
1064
847
  ] }),
1065
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "r-no-data", children: [
1066
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_reactstrap4.Spinner, { className: "me-1", children: " " }),
848
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "r-no-data", children: [
849
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_reactstrap2.Spinner, { className: "me-1", children: " " }),
1067
850
  t("Loading...")
1068
851
  ] })
1069
852
  ] });
1070
853
  };
1071
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
854
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1072
855
  "div",
1073
856
  {
1074
- className: (0, import_classnames4.default)("react-select-table", { "is-invalid": invalid }),
857
+ className: (0, import_classnames2.default)("react-select-table", { "is-invalid": invalid }),
1075
858
  ref,
1076
859
  id,
1077
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ref: selectTableRef, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1078
- import_reactstrap4.Dropdown,
860
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: selectTableRef, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
861
+ import_reactstrap2.Dropdown,
1079
862
  {
1080
863
  isOpen: dropdownOpen,
1081
864
  toggle: () => {
1082
865
  },
1083
866
  onMouseDown: (e) => e.preventDefault(),
1084
867
  children: [
1085
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1086
- import_reactstrap4.DropdownToggle,
868
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
869
+ import_reactstrap2.DropdownToggle,
1087
870
  {
1088
871
  onClick: (e) => {
1089
872
  if (!isDisabled) {
@@ -1094,25 +877,25 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
1094
877
  },
1095
878
  tag: "div",
1096
879
  style: { width: width ? width : "auto" },
1097
- className: (0, import_classnames4.default)("select-table-control", { "r-select-is-disabled": isDisabled }, { "r-select-is-open": dropdownOpen }, { "r-select-is-focus": isFocus }, { "r-select-is-invalid": invalid }),
880
+ className: (0, import_classnames2.default)("select-table-control", { "r-select-is-disabled": isDisabled }, { "r-select-is-open": dropdownOpen }, { "r-select-is-focus": isFocus }, { "r-select-is-invalid": invalid }),
1098
881
  children: [
1099
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "select-table-container", children: [
1100
- isMulti ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: (0, import_classnames4.default)("select-value is-mutil", { "d-none": searchTerm }), children: value?.map((ele, index) => {
1101
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
882
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "select-table-container", children: [
883
+ isMulti ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: (0, import_classnames2.default)("select-value is-mutil", { "d-none": searchTerm }), children: value?.map((ele, index) => {
884
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
1102
885
  index === 0 ? "" : ", ",
1103
886
  formatOptionLabel ? formatOptionLabel(ele) : ele[fieldLabel ?? "label"]
1104
887
  ] }, index);
1105
- }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: (0, import_classnames4.default)("select-value", { "d-none": searchTerm }), children: [
888
+ }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: (0, import_classnames2.default)("select-value", { "d-none": searchTerm }), children: [
1106
889
  value ? formatOptionLabel ? formatOptionLabel(value) : value[fieldLabel ?? "label"] : "",
1107
890
  " "
1108
891
  ] }) }),
1109
- !((isMulti ? value?.length > 0 : value) || isDisabled || searchTerm) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: (0, import_classnames4.default)("select-placeholder"), children: placeholder }),
1110
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "input-container", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
892
+ !((isMulti ? value?.length > 0 : value) || isDisabled || searchTerm) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: (0, import_classnames2.default)("select-placeholder"), children: placeholder }),
893
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "input-container", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1111
894
  "input",
1112
895
  {
1113
896
  style: { textAlign: textAlign ?? "left" },
1114
897
  ref: inputRef,
1115
- className: (0, import_classnames4.default)("select-input"),
898
+ className: (0, import_classnames2.default)("select-input"),
1116
899
  readOnly: isDisabled,
1117
900
  value: searchTerm,
1118
901
  onPaste: (e) => onPaste && !dropdownOpen && onPaste(e),
@@ -1134,28 +917,28 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
1134
917
  }
1135
918
  ) })
1136
919
  ] }),
1137
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: (0, import_classnames4.default)("select-table-indicator d-flex align-items-center"), children: [
1138
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_reactstrap4.Spinner, { style: { width: 4, height: 4, marginRight: 3 }, type: "grow" }),
1139
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_reactstrap4.Spinner, { style: { width: 4, height: 4, marginRight: 3 }, type: "grow" }),
1140
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_reactstrap4.Spinner, { style: { width: 4, height: 4, marginRight: 3 }, type: "grow" })
920
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: (0, import_classnames2.default)("select-table-indicator d-flex align-items-center"), children: [
921
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_reactstrap2.Spinner, { style: { width: 4, height: 4, marginRight: 3 }, type: "grow" }),
922
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_reactstrap2.Spinner, { style: { width: 4, height: 4, marginRight: 3 }, type: "grow" }),
923
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_reactstrap2.Spinner, { style: { width: 4, height: 4, marginRight: 3 }, type: "grow" })
1141
924
  ] }),
1142
- isClearable && value && !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
925
+ isClearable && value && !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1143
926
  "div",
1144
927
  {
1145
- className: (0, import_classnames4.default)("cursor-pointer"),
928
+ className: (0, import_classnames2.default)("cursor-pointer"),
1146
929
  onClick: (e) => {
1147
930
  handChange(isMulti ? [] : void 0);
1148
931
  e.stopPropagation();
1149
932
  },
1150
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { height: "20", width: "20", color: "#c4c4c4", viewBox: "0 0 20 20", "aria-hidden": "true", focusable: "false", className: "css-tj5bde-Svg", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z" }) })
933
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { height: "20", width: "20", color: "#c4c4c4", viewBox: "0 0 20 20", "aria-hidden": "true", focusable: "false", className: "css-tj5bde-Svg", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z" }) })
1151
934
  }
1152
935
  ),
1153
- !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "select-table-indicator", onMouseDown: (e) => e.preventDefault(), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { height: "20", width: "20", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" }) }) })
936
+ !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "select-table-indicator", onMouseDown: (e) => e.preventDefault(), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { height: "20", width: "20", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" }) }) })
1154
937
  ]
1155
938
  }
1156
939
  ),
1157
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1158
- import_reactstrap4.DropdownMenu,
940
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
941
+ import_reactstrap2.DropdownMenu,
1159
942
  {
1160
943
  container: component,
1161
944
  className: "formula-dropdown icon-dropdown p-0",
@@ -1166,7 +949,7 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
1166
949
  borderRadius: 4,
1167
950
  zIndex: 9999
1168
951
  },
1169
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_reactstrap4.DropdownItem, { className: (0, import_classnames4.default)("p-0 menu-select-table"), tag: "div", header: true, children: dropdownOpen && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
952
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_reactstrap2.DropdownItem, { className: (0, import_classnames2.default)("p-0 menu-select-table"), tag: "div", header: true, children: dropdownOpen && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1170
953
  "div",
1171
954
  {
1172
955
  style: { backgroundColor: "none" },
@@ -1176,11 +959,11 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
1176
959
  e.preventDefault();
1177
960
  }
1178
961
  },
1179
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "r-select-grid", children: [
1180
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: (0, import_classnames4.default)("r-select-gridtable", { "no-header": noHeader || (columns?.length ?? 0) === 0 }), ref: selectMenuTableRef, style: { width: menuWidth, minWidth: selectTableRef?.current?.clientWidth, maxHeight: maxHeight ?? defaultMaxHeight }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RenderTable, {}) }),
1181
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: (0, import_classnames4.default)("r-select-footer", { "d-none": !(showFooter === true || handleAdd) }), children: [
1182
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_reactstrap4.Button, { outline: true, color: "primary", onClick: handleAdd, className: (0, import_classnames4.default)("r-btn d-flex align-items-center", { "d-none": !handleAdd }), children: [
1183
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_becoxy_icons2.Plus, { className: "me-50", fontSize: 16 }),
962
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "r-select-grid", children: [
963
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: (0, import_classnames2.default)("r-select-gridtable", { "no-header": noHeader || (columns?.length ?? 0) === 0 }), ref: selectMenuTableRef, style: { width: menuWidth, minWidth: selectTableRef?.current?.clientWidth, maxHeight: maxHeight ?? defaultMaxHeight }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RenderTable, {}) }),
964
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: (0, import_classnames2.default)("r-select-footer", { "d-none": !(showFooter === true || handleAdd) }), children: [
965
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_reactstrap2.Button, { outline: true, color: "primary", onClick: handleAdd, className: (0, import_classnames2.default)("r-btn d-flex align-items-center", { "d-none": !handleAdd }), children: [
966
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_becoxy_icons2.Plus, { className: "me-50", fontSize: 16 }),
1184
967
  t("AddNew"),
1185
968
  " (F9)"
1186
969
  ] }),
@@ -1198,1692 +981,1909 @@ var SelectTable = (0, import_react6.forwardRef)((props, ref) => {
1198
981
  );
1199
982
  });
1200
983
 
1201
- // src/component/edit-form/select-table/index.tsx
1202
- var import_react_i18next4 = require("react-i18next");
1203
- var import_jsx_runtime6 = require("react/jsx-runtime");
1204
- var SelectTableBox = (props) => {
1205
- const {
1206
- isMulti,
1207
- isLabel,
1208
- confirmHandle,
1209
- id,
1210
- fieldValue,
1211
- fieldLabel,
1212
- labelComponent,
1213
- defaultOptions,
1214
- loadOptions,
1215
- control,
1216
- placeholder,
1217
- disabled,
1218
- name,
1219
- label,
1220
- labelSize,
1221
- required,
1222
- errors,
1223
- inLine,
1224
- callback,
1225
- desciptionLabel,
1226
- classLabel,
1227
- isClearable,
1228
- defaultValue,
1229
- handleAddNew,
1230
- columns,
1231
- ...rest
1232
- } = props;
1233
- const handChange = ({ onChange, val }) => {
1234
- onChange(!isNullOrUndefined(val) && isMulti ? val.map((item) => item.value) : !isNullOrUndefined(val) && !isMulti ? fieldValue ? val[fieldValue] : val?.value : void 0);
1235
- if (callback) {
1236
- callback(val);
1237
- }
1238
- };
1239
- const renderLabel = (props2) => {
1240
- const { t } = (0, import_react_i18next4.useTranslation)();
1241
- const { isLabel: isLabel2, desciptionLabel: desciptionLabel2, id: id2, classLabel: classLabel2, name: name2, label: label2, required: required2 } = props2;
1242
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react7.Fragment, { children: [
1243
- isLabel2 === false ? "" : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_reactstrap5.Label, { id: `label-${id2}`, className: classLabel2, for: name2, children: [
1244
- t(label2 ? label2 : ""),
1245
- " ",
1246
- required2 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-danger", children: "*" }) : ""
1247
- ] }),
1248
- (!isNullOrUndefined(desciptionLabel2) && desciptionLabel2 !== "") ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_reactstrap5.UncontrolledTooltip, { target: `label-${id2}`, children: t(desciptionLabel2 ?? "") }) })
1249
- ] });
1250
- };
1251
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react7.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1252
- "div",
1253
- {
1254
- className: (0, import_classnames5.default)(
1255
- inLine === false ? "form-group " : "form-row-inline d-flex",
1256
- "align",
984
+ // src/component/table/paging/index.tsx
985
+ var import_jsx_runtime4 = require("react/jsx-runtime");
986
+ var PagingComponent = ({ totalItem, pageSize, currentPage, onChangePage, pageOptions, onChangePageSize }) => {
987
+ const { t } = (0, import_react_i18next2.useTranslation)();
988
+ const [countPage, setCountPage] = (0, import_react5.useState)(0);
989
+ const [currentPageNumber, setCurrentPageNumber] = (0, import_react5.useState)(1);
990
+ (0, import_react5.useEffect)(() => {
991
+ setCountPage(Math.floor(totalItem / pageSize) + (Math.floor(totalItem / pageSize) === totalItem / pageSize ? 0 : 1));
992
+ }, [totalItem, pageSize]);
993
+ (0, import_react5.useEffect)(() => {
994
+ setCurrentPageNumber(Math.floor(currentPage / 5) + (Math.floor(currentPage / 5) === currentPage / 5 ? 0 : 1));
995
+ }, [currentPage]);
996
+ const renderPageNumber = (number) => {
997
+ const arr = [];
998
+ for (let index = (number - 1) * 5 + 1; index <= number * 5 && index <= Math.floor(totalItem / pageSize) + (Math.floor(totalItem / pageSize) === totalItem / pageSize ? 0 : 1); index++) {
999
+ arr.push(
1000
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1001
+ "div",
1002
+ {
1003
+ className: (0, import_classnames3.default)("r-number", { "r-active": index === currentPage }),
1004
+ onClick: () => {
1005
+ onChangePage({ totalItem, pageSize, currentPage: index, old: currentPage });
1006
+ },
1007
+ children: index
1008
+ },
1009
+ `page-${index}`
1010
+ )
1011
+ );
1012
+ }
1013
+ return arr;
1014
+ };
1015
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "r-pager", children: [
1016
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "r-pagercontainer", children: [
1017
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "r-button", type: "button", disabled: countPage <= 1 || currentPage === 1, onClick: () => onChangePage({ totalItem, pageSize, currentPage: 1, old: currentPage }), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_becoxy_icons3.ChevronsLeft, { fontSize: 16 }) }),
1018
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "r-button", type: "button", disabled: countPage <= 1 || currentPage === 1, onClick: () => onChangePage({ totalItem, pageSize, currentPage: currentPage - 1, old: currentPage }), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_becoxy_icons3.ChevronLeft, { fontSize: 16 }) }),
1019
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1020
+ "button",
1257
1021
  {
1258
- [labelSize ? labelSize : ""]: labelSize,
1259
- "form-row-inline-error": errors
1022
+ className: (0, import_classnames3.default)("r-button", { "d-none": currentPageNumber === 1 }),
1023
+ type: "button",
1024
+ onClick: () => {
1025
+ setCurrentPageNumber(currentPageNumber - 1);
1026
+ onChangePage({ totalItem, pageSize, currentPage: (currentPageNumber - 2) * 5 + 1, old: currentPage });
1027
+ },
1028
+ children: "..."
1260
1029
  }
1261
1030
  ),
1262
- children: [
1263
- renderLabel({ isLabel, desciptionLabel, classLabel, name, label, required, id: id ?? "" }),
1264
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: (0, import_classnames5.default)("form-input-content", { "hidden-label": isLabel === false }), children: [
1265
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1266
- import_react_hook_form3.Controller,
1031
+ renderPageNumber(currentPageNumber),
1032
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1033
+ "button",
1034
+ {
1035
+ className: (0, import_classnames3.default)("r-button", { "d-none": currentPageNumber * 5 >= countPage }),
1036
+ type: "button",
1037
+ onClick: () => {
1038
+ setCurrentPageNumber(currentPageNumber + 1);
1039
+ onChangePage({ totalItem, pageSize, currentPage: currentPageNumber * 5 + 1, old: currentPage });
1040
+ },
1041
+ children: "..."
1042
+ }
1043
+ ),
1044
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "r-button", type: "button", disabled: countPage <= 1 || countPage === currentPage, onClick: () => onChangePage({ totalItem, pageSize, currentPage: currentPage + 1, old: currentPage }), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_becoxy_icons3.ChevronRight, { fontSize: 16 }) }),
1045
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "r-button", type: "button", disabled: countPage <= 1 || countPage === currentPage, onClick: () => onChangePage({ totalItem, pageSize, currentPage: Math.floor(totalItem / pageSize) + (Math.floor(totalItem / pageSize) === totalItem / pageSize ? 0 : 1), old: currentPage }), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_becoxy_icons3.ChevronsRight, { fontSize: 16 }) }),
1046
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "r-pagesize", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1047
+ SelectTable,
1048
+ {
1049
+ value: { value: pageSize, label: pageSize },
1050
+ noHeader: true,
1051
+ options: pageOptions.map((item) => ({ value: item, label: item })),
1052
+ onChange: (val) => {
1053
+ onChangePageSize({ totalItem, pageSize: val?.value });
1054
+ },
1055
+ menuWidth: 90,
1056
+ width: 90,
1057
+ placeholder: t("Select")
1058
+ }
1059
+ ) }),
1060
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { display: "inline", marginLeft: 10, fontSize: 13 }, children: t("pagerDropDown") })
1061
+ ] }),
1062
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "r-parentmsgbar", children: t("totalItemsInfo", { page: currentPage, countPage, totalItem }) })
1063
+ ] }) });
1064
+ };
1065
+
1066
+ // src/component/table/header.tsx
1067
+ var import_react6 = require("react");
1068
+ var import_classnames4 = __toESM(require("classnames"));
1069
+ var import_reactstrap3 = require("reactstrap");
1070
+ var import_react_i18next3 = require("react-i18next");
1071
+ var import_react_resizable = require("react-resizable");
1072
+ var import_styles = require("react-resizable/css/styles.css");
1073
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1074
+ var HeaderTableCol = (props) => {
1075
+ const {
1076
+ selectEnable,
1077
+ dataSource,
1078
+ setSelectedRows,
1079
+ col,
1080
+ indexCol,
1081
+ indexParent,
1082
+ objWidthFix,
1083
+ totalCount,
1084
+ selectedRows,
1085
+ column,
1086
+ setColumn,
1087
+ isMulti
1088
+ } = props;
1089
+ const { t } = (0, import_react_i18next3.useTranslation)();
1090
+ const handleResize = (e, { size }) => {
1091
+ if (size.width > 50) {
1092
+ const newColumns = [...column];
1093
+ newColumns[indexCol].width = size.width;
1094
+ setColumn(newColumns);
1095
+ }
1096
+ };
1097
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react6.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1098
+ import_react_resizable.Resizable,
1099
+ {
1100
+ className: "r-resize",
1101
+ width: typeof col.width === "number" ? col.width : Number((col.width ?? "").replaceAll(new RegExp(`[^0-9]`, "g"), "")),
1102
+ height: 0,
1103
+ onResize: handleResize,
1104
+ draggableOpts: { enableUserSelectHack: false },
1105
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1106
+ "th",
1107
+ {
1108
+ rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
1109
+ colSpan: col.columns?.length ?? 1,
1110
+ className: (0, import_classnames4.default)(`r-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
1111
+ style: {
1112
+ top: `${indexParent * 42}px`,
1113
+ left: col.fixedType === "left" ? objWidthFix[col.index ?? 0] : void 0,
1114
+ right: col.fixedType === "right" ? objWidthFix[col.index ?? 0] : void 0,
1115
+ width: col.width ? typeof col.width === "number" ? col.width : col.width?.includes("px") || col.width?.includes("%") ? col.width : `${col.width}px` : "auto",
1116
+ minWidth: col.width ? typeof col.width === "number" ? col.width : col.width?.includes("px") || col.width?.includes("%") ? col.width : `${col.width}px` : "auto",
1117
+ maxWidth: col.width ? typeof col.width === "number" ? col.width : col.width?.includes("px") || col.width?.includes("%") ? col.width : `${col.width}px` : "auto"
1118
+ },
1119
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1120
+ "div",
1267
1121
  {
1268
- name,
1269
- control,
1270
- render: ({ field: { value, onChange } }) => {
1271
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1272
- SelectTable,
1122
+ style: { justifyContent: col.textAlign ?? "left" },
1123
+ className: (0, import_classnames4.default)("r-headercell-div"),
1124
+ children: [
1125
+ col.field === "checkbox" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1126
+ import_reactstrap3.Input,
1273
1127
  {
1274
- ...rest,
1275
- id,
1276
- value: (isMulti ? value?.length > 0 : value) ? !isMulti ? defaultOptions.find((val) => val[fieldValue ?? "value"] === value) ?? (defaultValue ?? "") : value : isMulti ? [] : void 0,
1277
- onChange: (val) => {
1278
- if (isMulti || (fieldValue && val ? val[fieldValue] : val?.value) !== value) {
1279
- if (confirmHandle) {
1280
- confirmHandle(handChange, onChange, val);
1128
+ checked: totalCount > 0 && selectedRows?.length >= totalCount,
1129
+ type: "checkbox",
1130
+ className: (0, import_classnames4.default)("cursor-pointer", { "d-none": !isMulti }),
1131
+ style: { textAlign: col.textAlign ?? "left", marginTop: 6 },
1132
+ onChange: (e) => {
1133
+ if (selectEnable) {
1134
+ if (e.target.checked) {
1135
+ setSelectedRows(dataSource.map((item) => {
1136
+ return item;
1137
+ }));
1281
1138
  } else {
1282
- if (isMulti) {
1283
- onChange(!isNullOrUndefined(val) ? val.map((item) => item[fieldValue ?? "value"]) : []);
1284
- } else {
1285
- onChange(!isNullOrUndefined(val) ? val[fieldValue ?? "value"] : void 0);
1286
- }
1287
- if (callback) {
1288
- callback(val);
1289
- }
1139
+ setSelectedRows([]);
1290
1140
  }
1291
1141
  }
1292
- },
1293
- handleAdd: handleAddNew,
1294
- isClearable,
1295
- isMulti,
1296
- placeholder,
1297
- invalid: errors,
1298
- loadOptions,
1299
- options: defaultOptions,
1300
- isDisabled: disabled,
1301
- columns,
1302
- fieldValue,
1303
- fieldLabel,
1304
- formatOptionLabel: labelComponent ? labelComponent : void 0
1142
+ }
1305
1143
  }
1306
- );
1307
- }
1144
+ ),
1145
+ col.field !== "checkbox" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "header-content", children: t(col.headerText ?? "") }) })
1146
+ ]
1308
1147
  }
1309
- ),
1310
- errors && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_reactstrap5.FormFeedback, { children: errors?.message })
1311
- ] })
1312
- ]
1148
+ )
1149
+ }
1150
+ )
1313
1151
  }
1314
- ) });
1152
+ ) }, `header-${indexCol}`);
1315
1153
  };
1316
- var select_table_default = SelectTableBox;
1154
+ var header_default = HeaderTableCol;
1317
1155
 
1318
- // src/component/edit-form/index.tsx
1156
+ // src/component/table/command.tsx
1157
+ var import_react8 = require("react");
1158
+ var import_classnames5 = __toESM(require("classnames"));
1159
+ var import_reactstrap4 = require("reactstrap");
1160
+ var import_react_i18next4 = require("react-i18next");
1161
+
1162
+ // src/component/icon/index.tsx
1163
+ var Icon = __toESM(require("becoxy-icons"));
1164
+ var import_react7 = require("react");
1165
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1166
+ var IconCustom = (props) => {
1167
+ const { iconName, size } = props;
1168
+ if (iconName === "") {
1169
+ return null;
1170
+ } else {
1171
+ const TagIcon = iconName === "" ? "" : Icon[iconName];
1172
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react7.Fragment, { children: iconName === "" ? "" : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TagIcon, { fontSize: size }) });
1173
+ }
1174
+ };
1175
+ var icon_default = IconCustom;
1176
+
1177
+ // src/component/table/command.tsx
1319
1178
  var import_jsx_runtime7 = require("react/jsx-runtime");
1320
- var defaultWidth = 200;
1321
- var EditForm = (0, import_react8.forwardRef)((props, ref) => {
1179
+ var CommandElement = (props) => {
1180
+ const { commandItems, rowData, indexRow, handleCommandClick, indexFocus, setIndexFocus } = props;
1181
+ const { t } = (0, import_react_i18next4.useTranslation)();
1182
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "d-flex align-items-center", style: { columnGap: 10 }, children: commandItems.map((item, index) => {
1183
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1184
+ import_reactstrap4.Button,
1185
+ {
1186
+ id: `command-item-${indexRow}-${index}`,
1187
+ tabIndex: -1,
1188
+ style: { padding: "5px", minWidth: 45, height: "100%" },
1189
+ className: (0, import_classnames5.default)("command-item", {
1190
+ "btn-icon": item.tooltip === ""
1191
+ }),
1192
+ color: item.color ? item.color : "#000",
1193
+ onClick: (e) => {
1194
+ handleCommandClick(item.id, rowData, indexRow);
1195
+ if (indexRow === indexFocus) {
1196
+ setIndexFocus(void 0);
1197
+ }
1198
+ e.preventDefault();
1199
+ },
1200
+ children: [
1201
+ item.icon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(icon_default, { iconName: item.icon, size: 16 }),
1202
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_reactstrap4.UncontrolledTooltip, { className: "r-tooltip", target: `command-item-${indexRow}-${index}`, place: "top", children: t(item.tooltip ?? "") })
1203
+ ]
1204
+ },
1205
+ `command-${index}`
1206
+ );
1207
+ }) }) });
1208
+ };
1209
+ var command_default = CommandElement;
1210
+
1211
+ // src/component/select-table-tree/index.tsx
1212
+ var import_react9 = __toESM(require("react"));
1213
+ var import_reactstrap5 = require("reactstrap");
1214
+ var import_react_i18next5 = require("react-i18next");
1215
+ var import_classnames6 = __toESM(require("classnames"));
1216
+ var import_becoxy_icons4 = require("becoxy-icons");
1217
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1218
+ var defaultMaxHeight2 = 250;
1219
+ var SelectTableTree = (0, import_react9.forwardRef)((props, ref) => {
1322
1220
  const {
1323
1221
  id,
1324
- field,
1325
- displayValue,
1326
- menuHeight,
1327
1222
  menuWidth,
1328
- rowData,
1223
+ width,
1329
1224
  invalid,
1330
- onChange,
1331
- onChangeField,
1332
1225
  onKeyDown,
1333
- defaultValues,
1334
1226
  placeholder,
1335
1227
  textAlign,
1336
- schema,
1337
- onFormOpen,
1338
- onFormSubmit,
1339
- footerTemplate,
1340
- minWidth,
1341
- onPaste,
1342
- openOnFocus,
1343
- isClearable,
1344
- labelSize = "label-small"
1345
- } = props;
1346
- const { innerWidth } = window;
1347
- const inputRef = (0, import_react8.useRef)();
1348
- const editFormRef = (0, import_react8.useRef)();
1349
- const buttonRef = (0, import_react8.useRef)();
1350
- const [dropdownOpen, setDropdownOpen] = (0, import_react8.useState)(false);
1351
- const [itemsField, setItemsField] = (0, import_react8.useState)([]);
1352
- const { t } = (0, import_react_i18next5.useTranslation)();
1353
- useOnClickOutside(editFormRef, () => {
1354
- closeMenu();
1355
- });
1228
+ options,
1229
+ columns,
1230
+ onChange,
1231
+ value,
1232
+ fieldValue,
1233
+ fieldLabel,
1234
+ fieldChildren,
1235
+ maxHeight,
1236
+ handleAdd,
1237
+ isClearable,
1238
+ component,
1239
+ formatOptionLabel,
1240
+ isMulti,
1241
+ noHeader,
1242
+ isDisabled,
1243
+ showFooter,
1244
+ selectChilds,
1245
+ footerComponent,
1246
+ formatSetting,
1247
+ onOpenMenu,
1248
+ onPaste
1249
+ } = props;
1250
+ const selectTableRef = (0, import_react9.useRef)();
1251
+ const selectMenuTableRef = (0, import_react9.useRef)();
1252
+ const inputRef = (0, import_react9.useRef)();
1253
+ const [dropdownOpen, setDropdownOpen] = (0, import_react9.useState)(false);
1254
+ const [isFocus, setIsFocus] = (0, import_react9.useState)(false);
1255
+ const [searchTerm, setSearchTerm] = (0, import_react9.useState)("");
1256
+ const { t } = (0, import_react_i18next5.useTranslation)();
1257
+ const areAllItemsSelected = (value2, options2, fieldValue2) => {
1258
+ const checkAllSelected = (nodes) => {
1259
+ return nodes.every((node) => {
1260
+ const isSelected = value2.includes(node[fieldValue2]);
1261
+ const childrenSelected = node.children ? checkAllSelected(node.children) : true;
1262
+ return isSelected && childrenSelected;
1263
+ });
1264
+ };
1265
+ return checkAllSelected(options2);
1266
+ };
1267
+ const isSelectedAll = (0, import_react9.useMemo)(() => {
1268
+ return isMulti === true && options.length > 0 && areAllItemsSelected(value, options, fieldValue ?? "value");
1269
+ }, [options, value]);
1270
+ (0, import_react9.useEffect)(() => {
1271
+ if (dropdownOpen && onOpenMenu) {
1272
+ onOpenMenu();
1273
+ }
1274
+ }, [dropdownOpen]);
1275
+ const defaultColumns = [
1276
+ {
1277
+ headerText: "Name",
1278
+ field: fieldLabel ?? "label",
1279
+ width: menuWidth
1280
+ }
1281
+ ];
1356
1282
  const closeMenu = () => {
1357
- setTimeout(() => {
1358
- setDropdownOpen(false);
1359
- }, onChangeField ? 10 : 0);
1283
+ setDropdownOpen(false);
1360
1284
  };
1361
- const {
1362
- control,
1363
- handleSubmit,
1364
- getValues,
1365
- reset,
1366
- setValue,
1367
- formState: { errors }
1368
- } = (0, import_react_hook_form4.useForm)({
1369
- mode: "onChange",
1370
- defaultValues,
1371
- resolver: (0, import_yup.yupResolver)(schema)
1372
- });
1373
- (0, import_react8.useEffect)(() => {
1374
- if (dropdownOpen) {
1375
- if (onFormOpen && itemsField.length === 0) {
1376
- onFormOpen(rowData, itemsField, setItemsField);
1377
- }
1378
- if (openOnFocus) {
1379
- setTimeout(() => {
1380
- focusElement(`form-element-${field}-0`, true);
1381
- }, 100);
1285
+ (0, import_react9.useEffect)(() => {
1286
+ if (dropdownOpen && value && !isMulti && selectMenuTableRef) {
1287
+ const index = options?.findIndex((e) => e[fieldValue ?? "value"] === value[fieldValue ?? "value"]);
1288
+ if (index >= 0) {
1289
+ selectMenuTableRef.current.scrollTo({ top: (index - 1) * 30 });
1382
1290
  }
1383
1291
  }
1384
1292
  }, [dropdownOpen]);
1385
- (0, import_react8.useEffect)(() => {
1386
- if (dropdownOpen && itemsField.length > 0) {
1387
- itemsField.forEach((ele) => {
1388
- setValue(ele.name, rowData[ele.name] ?? "");
1293
+ (0, import_react9.useEffect)(() => {
1294
+ if (inputRef && !isDisabled) {
1295
+ inputRef.current.addEventListener("blur", function() {
1296
+ setDropdownOpen(false);
1297
+ setSearchTerm("");
1298
+ setIsFocus(false);
1299
+ });
1300
+ inputRef.current.addEventListener("focus", function() {
1301
+ if (!isFocus) {
1302
+ setIsFocus(true);
1303
+ }
1389
1304
  });
1390
1305
  }
1391
- }, [dropdownOpen, itemsField]);
1392
- const handleOnClick = () => {
1306
+ }, [inputRef]);
1307
+ (0, import_react9.useEffect)(() => {
1308
+ if (searchTerm && !dropdownOpen) {
1309
+ setDropdownOpen(true);
1310
+ }
1311
+ }, [searchTerm]);
1312
+ const handleOpenClose = () => {
1313
+ setSearchTerm("");
1393
1314
  if (dropdownOpen) {
1394
1315
  closeMenu();
1395
1316
  } else {
1396
- setDropdownOpen(true);
1397
- }
1398
- };
1399
- const handleOnSubmit = (val) => {
1400
- closeMenu();
1401
- onChange(val);
1402
- if (onFormSubmit) {
1403
- onFormSubmit(rowData, setValue, getValues, reset);
1404
- }
1405
- inputRef.current.focus();
1406
- };
1407
- const focusElement = (id2, focus) => {
1408
- const element = document.getElementById(id2);
1409
- if (element) {
1410
- if (element.className.includes("react-select")) {
1411
- element.getElementsByTagName("input")[0]?.focus();
1412
- } else {
1413
- element.focus();
1414
- if (focus) {
1415
- element.setSelectionRange(0, element.innerText.length - 1);
1416
- }
1317
+ if (!isDisabled) {
1318
+ setDropdownOpen(true);
1417
1319
  }
1418
1320
  }
1419
1321
  };
1322
+ const listKeyUse = ["Escape", "Space", "F9"];
1420
1323
  const handleOnKeyDown = (e) => {
1324
+ let key = "";
1325
+ if (onKeyDown && (!dropdownOpen || !listKeyUse.includes(e.code) || e.code === "Escape" && !(isClearable && value && !isDisabled))) {
1326
+ key = onKeyDown(e);
1327
+ }
1421
1328
  let flag = false;
1422
- if (dropdownOpen) {
1423
- if (e.code === "Escape") {
1424
- closeMenu();
1425
- flag = true;
1426
- } else if (e.code === "Enter") {
1427
- closeMenu();
1428
- flag = true;
1429
- } else if (e.code === "ArrowDown") {
1430
- focusElement(`form-element-${field}-0`);
1431
- flag = true;
1432
- }
1433
- } else {
1434
- if (e.code === "ArrowDown") {
1435
- setDropdownOpen(true);
1436
- focusElement(`form-element-${field}-0`);
1329
+ if (!key) {
1330
+ if (e.code === "F9") {
1331
+ handleAdd();
1437
1332
  flag = true;
1438
1333
  } else if (e.code === "Space") {
1439
- setDropdownOpen(true);
1440
- flag = true;
1334
+ if (!searchTerm) {
1335
+ handleOpenClose();
1336
+ flag = true;
1337
+ }
1338
+ } else if (e.code === "Escape") {
1339
+ if (dropdownOpen && isClearable && value && !isDisabled) {
1340
+ onChange(void 0);
1341
+ handleOpenClose();
1342
+ flag = true;
1343
+ }
1441
1344
  }
1442
1345
  }
1443
- if (onKeyDown && !flag) {
1444
- const key = onKeyDown(e);
1445
- if (key === "ArrowRight" || key === "ArrowLeft") {
1446
- closeMenu();
1447
- }
1448
- } else {
1346
+ if (flag) {
1449
1347
  e.stopPropagation();
1450
1348
  e.preventDefault();
1451
1349
  }
1452
1350
  };
1453
- const formKeyDown = (e, handSubmit) => {
1454
- if (e.code === "Enter") {
1455
- handSubmit();
1456
- e.preventDefault();
1457
- e.stopPropagation();
1458
- } else {
1459
- if (onKeyDown) {
1460
- const key = onKeyDown(e);
1461
- if (key === "ArrowRight" || key === "ArrowLeft") {
1462
- closeMenu();
1463
- }
1351
+ const renderHeaderCol = (col, indexCol) => {
1352
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react9.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1353
+ "th",
1354
+ {
1355
+ className: (0, import_classnames6.default)(`r-select-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
1356
+ style: {
1357
+ width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
1358
+ minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
1359
+ maxWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
1360
+ top: `${0 * 35}px`
1361
+ },
1362
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1363
+ "div",
1364
+ {
1365
+ role: "textbox",
1366
+ title: t(col.headerText ?? ""),
1367
+ style: {
1368
+ height: `${1 * 35}px`,
1369
+ justifyContent: col.textAlign ?? "left"
1370
+ },
1371
+ className: "r-select-headercell-div",
1372
+ children: t(col.headerText ?? "")
1373
+ }
1374
+ )
1464
1375
  }
1465
- }
1376
+ ) }, `header-select-${indexCol}`);
1466
1377
  };
1467
- const formItemKeyDown = (e, index) => {
1468
- if (e.code === "ArrowDown" && index < itemsField.length - 1) {
1469
- focusElement(`form-element-${field}-${index + 1}`);
1470
- e.preventDefault();
1471
- e.stopPropagation();
1472
- } else if (e.code === "ArrowUp" && index > 0) {
1473
- focusElement(`form-element-${field}-${index - 1}`);
1474
- e.preventDefault();
1475
- e.stopPropagation();
1476
- } else if (e.code === "Tab" && onChangeField && index === itemsField.length - 1) {
1477
- closeMenu();
1378
+ const checkSearch = (keyword, data, columnsSearch) => {
1379
+ if (!keyword || columnsSearch.length === 0) {
1380
+ return true;
1478
1381
  }
1479
- };
1480
- const elementChange = (field2) => {
1481
- if (onChangeField) {
1482
- onChangeField(rowData, field2, setValue, getValues);
1483
- const rs = getValues();
1484
- if (rs) {
1485
- onChange(rs);
1382
+ for (let index = 0; index < columnsSearch.length; index++) {
1383
+ const key = columnsSearch[index].field.trim();
1384
+ if (data[key] && data[key].toString().trim().toLowerCase().includes(keyword.trim().toLowerCase())) {
1385
+ return true;
1486
1386
  }
1487
1387
  }
1388
+ if (data[fieldChildren ?? "children"]) {
1389
+ return data[fieldChildren ?? "children"].some((child) => checkSearch(keyword, child, columnsSearch));
1390
+ }
1391
+ return false;
1488
1392
  };
1489
- const renderForm = (rows) => {
1490
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_reactstrap6.Row, { className: "gy-25", children: rows.map((item, index) => {
1491
- if (item.type === "numeric") {
1492
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_reactstrap6.Col, { xl: 12, onKeyDown: (e) => formItemKeyDown(e, index), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1493
- input_number_default,
1494
- {
1495
- id: `form-element-${field}-${index}`,
1496
- control,
1497
- name: item.name,
1498
- label: item.label ? item.label : "",
1499
- labelSize: `text-left ${labelSize}`,
1500
- errors: errors[item.name],
1501
- disabled: item.disabled,
1502
- min: item.min,
1503
- max: item.max,
1504
- fractionCurrency: item.fraction,
1505
- callback: () => {
1506
- elementChange(item.name);
1507
- }
1508
- },
1509
- index
1510
- ) }, index);
1511
- } else if (item.type === "text") {
1512
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_reactstrap6.Col, { xl: 12, onKeyDown: (e) => formItemKeyDown(e, index), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1513
- input_text_default,
1514
- {
1515
- id: `form-element-${field}-${index}`,
1516
- control,
1517
- name: item.name,
1518
- label: item.label ? item.label : "",
1519
- labelSize: `text-left ${labelSize}`,
1520
- errors: errors[item.name],
1521
- disabled: item.disabled,
1522
- callback: () => {
1523
- elementChange(item.name);
1524
- }
1525
- },
1526
- index
1527
- ) }, index);
1528
- } else if (item.type === "select") {
1529
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_reactstrap6.Col, { xl: 12, onKeyDown: (e) => formItemKeyDown(e, index), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1530
- select_table_default,
1531
- {
1532
- id: `form-element-${field}-${index}`,
1533
- defaultOptions: item.options ?? [],
1534
- control,
1535
- name: item.name,
1536
- label: item.label ? item.label : "",
1537
- labelSize: `text-left ${labelSize}`,
1538
- errors: errors[item.name],
1539
- disabled: item.disabled,
1540
- callback: () => {
1541
- elementChange(item.name);
1542
- }
1543
- },
1544
- index
1545
- ) }, index);
1546
- }
1547
- }) });
1393
+ const checkOverflow = (indexRow, indexCol) => {
1394
+ const element = document.getElementById(`select-${id}-${indexRow}-${indexCol}`);
1395
+ return element && element.scrollWidth > element.clientWidth;
1548
1396
  };
1549
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1550
- "div",
1551
- {
1552
- className: "form-edit",
1553
- ref,
1554
- id,
1555
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: editFormRef, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1556
- import_reactstrap6.Dropdown,
1397
+ const getSelectAll = (tree, checkValue = false) => {
1398
+ const selects = [];
1399
+ const traverse = (items) => {
1400
+ items.forEach((item) => {
1401
+ if (item[fieldValue ?? "value"] && !(checkValue && value?.includes(item[fieldValue ?? "value"]))) {
1402
+ selects.push(item[fieldValue ?? "value"]);
1403
+ }
1404
+ if (item[fieldChildren ?? "children"] && item[fieldChildren ?? "children"].length > 0) {
1405
+ traverse(item[fieldChildren ?? "children"]);
1406
+ }
1407
+ });
1408
+ };
1409
+ traverse(tree);
1410
+ return selects;
1411
+ };
1412
+ const RenderElement = import_react9.default.memo((props2) => {
1413
+ const { indexRow, row, isSelected, level = 0 } = props2;
1414
+ const [expanded, setExpanded] = (0, import_react9.useState)(row.expanded);
1415
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1416
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1417
+ "tr",
1557
1418
  {
1558
- isOpen: dropdownOpen,
1559
- toggle: () => {
1560
- },
1419
+ id: `row-select-table-${indexRow}`,
1420
+ className: (0, import_classnames6.default)("r-select-row", { "fisrt-row": indexRow === 0 && level === 0 }),
1561
1421
  children: [
1562
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_reactstrap6.DropdownToggle, { tag: "div", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1563
- import_reactstrap6.Input,
1564
- {
1565
- style: { backgroundColor: "#FFF", textAlign: textAlign ?? "left" },
1566
- placeholder,
1567
- innerRef: inputRef,
1568
- className: (0, import_classnames6.default)("input-display input-numeric", { "is-invalid": invalid }),
1569
- value: displayValue,
1570
- onClick: handleOnClick,
1571
- onKeyDown: (e) => handleOnKeyDown(e),
1572
- onPaste: (e) => onPaste && onPaste(e),
1573
- readOnly: true
1574
- }
1575
- ) }),
1576
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1577
- import_reactstrap6.DropdownMenu,
1422
+ isMulti && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1423
+ "td",
1578
1424
  {
1579
- className: "formula-dropdown icon-dropdown p-0",
1425
+ className: (0, import_classnames6.default)(`r-select-rowcell`, { "r-select-active": !isMulti && value && isSelected }),
1580
1426
  style: {
1581
- minWidth: minWidth ? minWidth : defaultWidth,
1582
- width: menuWidth ? menuWidth : "min-content",
1583
- maxWidth: innerWidth > 1280 ? 1280 : innerWidth,
1584
- borderRadius: 8,
1585
- zIndex: 1056
1427
+ textAlign: "center",
1428
+ paddingLeft: level * 15 + (row[fieldChildren ?? "children"]?.length > 0 ? 0 : 10)
1586
1429
  },
1587
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_reactstrap6.DropdownItem, { className: "p-0", style: { borderRadius: "6px" }, tag: "div", header: true, children: [
1588
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1589
- "div",
1430
+ onClick: (e) => {
1431
+ if (isMulti) {
1432
+ const index = value?.findIndex((x) => x === row[fieldValue ?? "value"]);
1433
+ if (index > -1) {
1434
+ if (!selectChilds) {
1435
+ value?.splice(index, 1);
1436
+ } else {
1437
+ value?.splice(index, 1);
1438
+ getSelectAll(row[fieldChildren ?? "children"]).forEach((x) => {
1439
+ const index2 = value?.findIndex((y) => y === x);
1440
+ if (index2 > -1) {
1441
+ value?.splice(index2, 1);
1442
+ }
1443
+ });
1444
+ }
1445
+ onChange([...value]);
1446
+ } else {
1447
+ if (value) {
1448
+ if (!selectChilds) {
1449
+ onChange([...value, row[fieldValue ?? "value"]]);
1450
+ } else {
1451
+ onChange([...value, row[fieldValue ?? "value"], ...getSelectAll(row[fieldChildren ?? "children"], true)]);
1452
+ }
1453
+ } else {
1454
+ onChange([row[fieldValue ?? "value"]]);
1455
+ }
1456
+ }
1457
+ e.stopPropagation();
1458
+ }
1459
+ },
1460
+ children: [
1461
+ row[fieldChildren ?? "children"]?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1462
+ import_becoxy_icons4.ChevronRight,
1590
1463
  {
1591
- onKeyDown: (e) => formKeyDown(e, handleSubmit(handleOnSubmit)),
1592
- className: "p-1",
1593
- style: {
1594
- maxHeight: menuHeight ? menuHeight : 300,
1595
- overflow: "auto"
1464
+ onClick: (e) => {
1465
+ if (expanded) {
1466
+ row.expanded = false;
1467
+ setExpanded(false);
1468
+ } else {
1469
+ row.expanded = true;
1470
+ setExpanded(true);
1471
+ }
1472
+ e.stopPropagation();
1596
1473
  },
1597
- children: itemsField ? renderForm(itemsField) : ""
1474
+ fontSize: 18,
1475
+ className: (0, import_classnames6.default)("me-50 pb-0 r-icon-expand", { "is-open": expanded })
1598
1476
  }
1599
1477
  ),
1600
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "d-flex justify-content-between p-50", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: [
1601
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-primary py-25", style: { fontSize: 12 }, children: footerTemplate ? footerTemplate(rowData) : "" }),
1602
- !onChangeField ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "d-flex justify-content-end", children: [
1603
- isClearable && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1604
- import_reactstrap6.Button,
1605
- {
1606
- ref: buttonRef,
1607
- className: "btn me-50 py-25 px-50",
1608
- outline: true,
1609
- onClick: () => {
1610
- itemsField.forEach((e) => {
1611
- if (e.type === "numeric") {
1612
- setValue(e.name, 0);
1613
- } else {
1614
- setValue(e.name, "");
1478
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1479
+ import_reactstrap5.Input,
1480
+ {
1481
+ checked: isSelected,
1482
+ type: "checkbox",
1483
+ className: "cursor-pointer",
1484
+ onChange: () => {
1485
+ }
1486
+ }
1487
+ )
1488
+ ]
1489
+ }
1490
+ ),
1491
+ (columns ? columns : defaultColumns).map((col, indexCol) => {
1492
+ let valueDisplay = row[col.field];
1493
+ if (col.type === "numeric" || col.typeCondition && col.typeCondition(row) === "numeric") {
1494
+ valueDisplay = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ".", formatSetting?.thousandSeparator ?? ",", col.fraction ?? 0, true) ?? 0;
1495
+ } else if (col.type === "date") {
1496
+ valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat) : "";
1497
+ } else if (col.type === "datetime") {
1498
+ valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
1499
+ }
1500
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react9.Fragment, { children: [
1501
+ col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1502
+ "td",
1503
+ {
1504
+ id: `select-${id}-${indexRow}-${indexCol}`,
1505
+ className: (0, import_classnames6.default)(`r-select-rowcell`, { "r-select-active": !isMulti && value && isSelected }),
1506
+ style: {
1507
+ paddingLeft: 9 + (indexCol === 0 && !isMulti ? level * 10 + (row[fieldChildren ?? "children"]?.length > 0 || level === 0 ? 0 : 15) : 0),
1508
+ textAlign: col.textAlign ? col.textAlign : "left"
1509
+ },
1510
+ onClick: (e) => {
1511
+ if (isMulti) {
1512
+ const index = value?.findIndex((x) => x === row[fieldValue ?? "value"]);
1513
+ if (index > -1) {
1514
+ if (!selectChilds) {
1515
+ value?.splice(index, 1);
1516
+ } else {
1517
+ value?.splice(index, 1);
1518
+ getSelectAll(row[fieldChildren ?? "children"]).forEach((x) => {
1519
+ const index2 = value?.findIndex((y) => y === x);
1520
+ if (index2 > -1) {
1521
+ value?.splice(index2, 1);
1615
1522
  }
1616
1523
  });
1617
- },
1618
- onKeyDown: (e) => {
1619
- if (e.code === "Tab") {
1620
- closeMenu();
1524
+ }
1525
+ onChange([...value]);
1526
+ } else {
1527
+ if (value) {
1528
+ if (!selectChilds) {
1529
+ onChange([...value, row[fieldValue ?? "value"]]);
1530
+ } else {
1531
+ onChange([...value, row[fieldValue ?? "value"], ...getSelectAll(row[fieldChildren ?? "children"], true)]);
1621
1532
  }
1622
- },
1623
- children: t("Clear")
1533
+ } else {
1534
+ onChange([row[fieldValue ?? "value"]]);
1535
+ }
1624
1536
  }
1625
- ),
1626
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1627
- import_reactstrap6.Button,
1537
+ e.stopPropagation();
1538
+ } else {
1539
+ onChange(row);
1540
+ setSearchTerm("");
1541
+ closeMenu();
1542
+ }
1543
+ e.preventDefault();
1544
+ e.stopPropagation();
1545
+ },
1546
+ children: [
1547
+ !isMulti && indexCol === 0 && row[fieldChildren ?? "children"]?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1548
+ import_becoxy_icons4.ChevronRight,
1628
1549
  {
1629
- ref: buttonRef,
1630
- color: "primary",
1631
- className: "btn btn-primary py-25 px-50",
1632
- onClick: handleSubmit(handleOnSubmit),
1633
- onKeyDown: (e) => {
1634
- if (e.code === "Tab") {
1635
- closeMenu();
1550
+ onClick: (e) => {
1551
+ if (expanded) {
1552
+ row.expanded = false;
1553
+ setExpanded(false);
1554
+ } else {
1555
+ row.expanded = true;
1556
+ setExpanded(true);
1636
1557
  }
1558
+ e.stopPropagation();
1637
1559
  },
1638
- children: t("Save")
1560
+ fontSize: 18,
1561
+ className: (0, import_classnames6.default)("me-50 r-icon-expand", { "is-open": expanded })
1639
1562
  }
1640
- )
1641
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, {})
1642
- ] })
1643
- ] })
1644
- }
1645
- )
1563
+ ),
1564
+ col.template ? col.template(row, indexRow) : col.type === "numeric" && Number(row[col.field]) < 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [
1565
+ " ",
1566
+ `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`
1567
+ ] }) : valueDisplay
1568
+ ]
1569
+ },
1570
+ `col-${indexRow}-${indexCol}`
1571
+ ),
1572
+ checkOverflow(indexRow, indexCol) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_reactstrap5.UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `select-${id}-${indexRow}-${indexCol}`, children: col.template ? col.template(row, indexRow) : col.type === "numeric" && Number(row[col.field]) < 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [
1573
+ " ",
1574
+ `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`
1575
+ ] }) : valueDisplay })
1576
+ ] }, indexCol);
1577
+ })
1646
1578
  ]
1579
+ },
1580
+ `row-${indexRow}`
1581
+ ),
1582
+ row[fieldChildren ?? "children"] && row.expanded && row[fieldChildren ?? "children"].map((child, indexChild) => {
1583
+ if (checkSearch(searchTerm, child, columns ? columns : defaultColumns)) {
1584
+ const isSelectedChild = value && (isMulti ? value?.some((x) => x === child[fieldValue ?? "value"]) : value[fieldValue ?? "value"] === child[fieldValue ?? "value"]);
1585
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RenderElement, { isSelected: isSelectedChild, indexRow: indexChild, row: child, level: level + 1 }, `select-table-${indexRow}-${indexChild}`);
1647
1586
  }
1648
- ) })
1649
- }
1650
- );
1651
- });
1652
- var edit_form_default = EditForm;
1653
-
1654
- // src/component/sidebar-setting-column/index.tsx
1655
- var import_react10 = require("react");
1656
- var import_reactstrap7 = require("reactstrap");
1657
- var import_react_i18next7 = require("react-i18next");
1658
-
1659
- // src/component/modal-header/index.tsx
1660
- var import_becoxy_icons3 = require("becoxy-icons");
1661
- var import_classnames7 = __toESM(require("classnames"));
1662
- var import_react_i18next6 = require("react-i18next");
1663
- var import_jsx_runtime8 = require("react/jsx-runtime");
1664
- var ModalHeader = (props) => {
1665
- const { title, handleModal, typeModal = "Edit", component } = props;
1666
- const { t } = (0, import_react_i18next6.useTranslation)();
1667
- const handleModalIcon = () => {
1668
- if (typeModal === "Edit" || typeModal === "Approval") {
1669
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_becoxy_icons3.Edit, { fontSize: 17, className: "me-1" });
1670
- } else if (typeModal === "View") {
1671
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_becoxy_icons3.Info, { fontSize: 17, className: "me-1" });
1672
- } else if (typeModal === "Detail") {
1673
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_becoxy_icons3.Info, { fontSize: 17, className: "me-1" });
1674
- } else if (typeModal === "Order") {
1675
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "e-icons e-sorting-1 me-1", style: { fontSize: "14px" } });
1676
- } else if (typeModal === "Process") {
1677
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "e-flat e-icons e-paste-match-destination me-1", style: { fontSize: "14px" } });
1678
- } else {
1679
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_becoxy_icons3.Plus, { fontSize: 17, className: "me-1" });
1680
- }
1681
- };
1682
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "modal-header d-flex align-items-center justify-content-between mb-1", children: [
1683
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "d-flex align-items-center justify-content-start", children: [
1684
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("h5", { className: "modal-title", children: [
1685
- handleModalIcon(),
1686
- " ",
1687
- t(title)
1587
+ })
1588
+ ] });
1589
+ });
1590
+ const RenderTable = (props2) => {
1591
+ const {} = props2;
1592
+ let countDisplay = 0;
1593
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1594
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("table", { style: { width: "100%" }, children: [
1595
+ !(noHeader && (columns?.length ?? 0) > 0) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("thead", { className: "r-select-gridheader", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("tr", { className: "r-select-row", role: "row", children: [
1596
+ isMulti && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1597
+ "th",
1598
+ {
1599
+ className: (0, import_classnames6.default)(`r-select-headercell checkbox-column`),
1600
+ style: { width: 40, minWidth: 40, maxWidth: 100, top: `0px` },
1601
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1602
+ "div",
1603
+ {
1604
+ style: { justifyContent: "center" },
1605
+ className: (0, import_classnames6.default)("r-select-headercell-div"),
1606
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1607
+ import_reactstrap5.Input,
1608
+ {
1609
+ checked: isSelectedAll,
1610
+ type: "checkbox",
1611
+ onClick: (e) => {
1612
+ if (isMulti) {
1613
+ if (isSelectedAll) {
1614
+ onChange([]);
1615
+ } else {
1616
+ onChange(getSelectAll(options));
1617
+ }
1618
+ e.stopPropagation();
1619
+ }
1620
+ },
1621
+ readOnly: true,
1622
+ className: (0, import_classnames6.default)("cursor-pointer", { "d-none": !isMulti }),
1623
+ style: { textAlign: "center", marginTop: 6 }
1624
+ }
1625
+ )
1626
+ }
1627
+ )
1628
+ }
1629
+ ),
1630
+ (columns ? columns : defaultColumns).map((col, index) => {
1631
+ return renderHeaderCol(col, index);
1632
+ })
1633
+ ] }) }),
1634
+ options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("tbody", { className: "r-select-gridcontent", children: options?.map((row, indexRow) => {
1635
+ if (checkSearch(searchTerm, row, columns ? columns : defaultColumns)) {
1636
+ const isSelected = value && (isMulti ? value?.some((x) => x === row[fieldValue ?? "value"]) : value[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
1637
+ countDisplay++;
1638
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RenderElement, { isSelected, indexRow, row }, `select-table-${indexRow}`);
1639
+ }
1640
+ }) }) })
1688
1641
  ] }),
1689
- component ? component() : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, {})
1690
- ] }),
1691
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "todo-item-action d-flex align-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1692
- import_becoxy_icons3.X,
1693
- {
1694
- className: (0, import_classnames7.default)("fw-normal mt-25 cursor-pointer", { "d-none": !handleModal }),
1695
- fontSize: 20,
1696
- onClick: handleModal
1697
- }
1698
- ) })
1699
- ] });
1700
- };
1701
- var modal_header_default = ModalHeader;
1702
-
1703
- // src/component/sidebar/index.tsx
1704
- var import_becoxy_icons4 = require("becoxy-icons");
1705
- var import_classnames8 = __toESM(require("classnames"));
1706
- var import_react9 = require("react");
1707
- var import_jsx_runtime9 = require("react/jsx-runtime");
1708
- var Sidebar = (props) => {
1709
- const {
1710
- open,
1711
- children,
1712
- toggleSidebar,
1713
- width,
1714
- keyboard,
1715
- hiddenBackground,
1716
- hiddenFullScreenButton
1717
- } = props;
1718
- const [isFullScreen, setIsFullScreen] = (0, import_react9.useState)(false);
1719
- const [flag, setFlag] = (0, import_react9.useState)(open);
1720
- (0, import_react9.useEffect)(() => {
1721
- if (open !== flag) {
1722
- if (open) {
1723
- setFlag(open);
1724
- } else {
1725
- setTimeout(() => {
1726
- setFlag(open);
1727
- }, 50);
1728
- }
1729
- }
1730
- }, [open]);
1731
- const handClose = () => {
1732
- setFlag(false);
1733
- setTimeout(() => {
1734
- toggleSidebar();
1735
- }, 400);
1642
+ countDisplay === 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "r-no-data", children: [
1643
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [
1644
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ellipse", { fill: "#f5f5f5", cx: "32", cy: "33", rx: "32", ry: "7" }),
1645
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("g", { fillRule: "nonzero", stroke: "#d9d9d9", children: [
1646
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" }),
1647
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z", fill: "#fafafa" })
1648
+ ] })
1649
+ ] }) }),
1650
+ t("No data available.")
1651
+ ] })
1652
+ ] });
1653
+ };
1654
+ const getSelectedRecords = (tree, value2) => {
1655
+ const records = [];
1656
+ const traverse = (nodes) => {
1657
+ nodes.forEach((node) => {
1658
+ if (value2.includes(node[fieldValue ?? "value"])) {
1659
+ records.push(node);
1660
+ }
1661
+ if (node.children && node.children.length > 0) {
1662
+ traverse(node.children);
1663
+ }
1664
+ });
1665
+ };
1666
+ traverse(tree);
1667
+ return records;
1736
1668
  };
1737
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1669
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1738
1670
  "div",
1739
1671
  {
1740
- tabIndex: 0,
1741
- className: (0, import_classnames8.default)({ "d-none": !open }),
1742
- onKeyDown: (e) => {
1743
- if (!keyboard && e.code === "Escape" && flag) {
1744
- handClose();
1745
- e.stopPropagation();
1746
- e.preventDefault();
1672
+ className: (0, import_classnames6.default)("react-select-table", { "is-invalid": invalid }),
1673
+ ref,
1674
+ id,
1675
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: selectTableRef, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1676
+ import_reactstrap5.Dropdown,
1677
+ {
1678
+ isOpen: dropdownOpen,
1679
+ toggle: () => {
1680
+ },
1681
+ onMouseDown: (e) => e.preventDefault(),
1682
+ children: [
1683
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1684
+ import_reactstrap5.DropdownToggle,
1685
+ {
1686
+ onClick: (e) => {
1687
+ if (!isDisabled) {
1688
+ inputRef?.current.focus();
1689
+ handleOpenClose();
1690
+ }
1691
+ e.preventDefault();
1692
+ },
1693
+ tag: "div",
1694
+ style: { width: "100%" },
1695
+ className: (0, import_classnames6.default)("select-table-control", { "r-select-is-disabled": isDisabled }, { "r-select-is-open": dropdownOpen }, { "r-select-is-focus": isFocus }, { "r-select-is-invalid": invalid }),
1696
+ children: [
1697
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "select-table-container", children: [
1698
+ isMulti ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: (0, import_classnames6.default)("select-value is-mutil", { "d-none": searchTerm }), children: getSelectedRecords(options, value).map((ele, index) => {
1699
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
1700
+ index === 0 ? "" : ", ",
1701
+ ele[fieldLabel ?? "label"]
1702
+ ] }, index);
1703
+ }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: (0, import_classnames6.default)("select-value", { "d-none": searchTerm }), children: [
1704
+ value ? formatOptionLabel ? formatOptionLabel(value) : value[fieldLabel ?? "label"] : "",
1705
+ " "
1706
+ ] }) }),
1707
+ !((isMulti ? value?.length > 0 : value) || isDisabled || searchTerm) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: (0, import_classnames6.default)("select-placeholder"), children: placeholder }),
1708
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "input-container", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1709
+ "input",
1710
+ {
1711
+ style: { textAlign: textAlign ?? "left" },
1712
+ ref: inputRef,
1713
+ className: (0, import_classnames6.default)("select-input"),
1714
+ readOnly: isDisabled,
1715
+ value: searchTerm,
1716
+ onPaste: (e) => onPaste && !dropdownOpen && onPaste(e),
1717
+ onChange: (val) => {
1718
+ setSearchTerm(val.target.value);
1719
+ },
1720
+ onKeyDown: (e) => handleOnKeyDown(e)
1721
+ }
1722
+ ) })
1723
+ ] }),
1724
+ isClearable && value && !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1725
+ "div",
1726
+ {
1727
+ className: (0, import_classnames6.default)("cursor-pointer"),
1728
+ onClick: (e) => {
1729
+ onChange(isMulti ? [] : void 0);
1730
+ e.stopPropagation();
1731
+ },
1732
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { height: "20", width: "20", color: "#c4c4c4", viewBox: "0 0 20 20", "aria-hidden": "true", focusable: "false", className: "css-tj5bde-Svg", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z" }) })
1733
+ }
1734
+ ),
1735
+ !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "select-table-indicator", onMouseDown: (e) => e.preventDefault(), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { height: "20", width: "20", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" }) }) })
1736
+ ]
1737
+ }
1738
+ ),
1739
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1740
+ import_reactstrap5.DropdownMenu,
1741
+ {
1742
+ container: component,
1743
+ className: "formula-dropdown icon-dropdown p-0",
1744
+ style: {
1745
+ width: width ? width + 2 : "min-content",
1746
+ position: "fixed",
1747
+ borderRadius: 4,
1748
+ zIndex: 9999
1749
+ },
1750
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_reactstrap5.DropdownItem, { className: (0, import_classnames6.default)("p-0 menu-select-table"), style: { borderRadius: "6px" }, tag: "div", header: true, children: dropdownOpen && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1751
+ "div",
1752
+ {
1753
+ onMouseDown: (e) => {
1754
+ if (!isDisabled) {
1755
+ inputRef?.current.focus();
1756
+ e.preventDefault();
1757
+ }
1758
+ },
1759
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "r-select-grid r-select-tree-grid", children: [
1760
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "r-select-gridtable ", ref: selectMenuTableRef, style: { width: menuWidth, minWidth: selectTableRef?.current?.clientWidth, maxHeight: maxHeight ?? defaultMaxHeight2 }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RenderTable, {}) }),
1761
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: (0, import_classnames6.default)("r-select-footer", { "d-none": !(showFooter === true || handleAdd || isMulti) }), children: [
1762
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_reactstrap5.Button, { outline: true, color: "primary", onClick: handleAdd, className: (0, import_classnames6.default)("r-btn d-flex align-items-center", { "d-none": !handleAdd }), children: [
1763
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_becoxy_icons4.Plus, { className: "me-50", fontSize: 16 }),
1764
+ t("AddNew"),
1765
+ " (F9)"
1766
+ ] }),
1767
+ isMulti && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ms-50 text-primary h-100 d-flex align-items-center", onClick: handleAdd, children: t("countSelected", { item: value?.length ?? 0 }) }),
1768
+ footerComponent ? footerComponent() : null
1769
+ ] })
1770
+ ] })
1771
+ }
1772
+ ) })
1773
+ }
1774
+ )
1775
+ ]
1747
1776
  }
1748
- },
1749
- children: [
1750
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1751
- "div",
1752
- {
1753
- className: (0, import_classnames8.default)("offcanvas-backdrop fade", {
1754
- "d-none": !flag || hiddenBackground,
1755
- show: flag
1756
- }),
1757
- style: { zIndex: 1056 },
1758
- onClick: handClose
1759
- }
1760
- ),
1761
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1762
- "div",
1763
- {
1764
- className: (0, import_classnames8.default)("r-sidebar", `customizer-${width ?? 600}`, {
1765
- open: flag,
1766
- fullscreen: isFullScreen
1767
- }),
1768
- style: { zIndex: 1057 },
1769
- children: [
1770
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1771
- "div",
1772
- {
1773
- style: {
1774
- position: "fixed",
1775
- top: "50%",
1776
- transform: "translate(-50%, -50%)",
1777
- background: "#FFF",
1778
- filter: "drop-shadow(0.9px 0.9px 1.5px)",
1779
- height: 50,
1780
- display: "flex",
1781
- alignItems: "center",
1782
- borderRadius: "0px 5px 5px 0px",
1783
- cursor: "pointer",
1784
- zIndex: 9,
1785
- marginLeft: 7
1786
- },
1787
- className: (0, import_classnames8.default)({ "d-none": hiddenFullScreenButton }),
1788
- onClick: () => {
1789
- setIsFullScreen(!isFullScreen);
1790
- },
1791
- children: [
1792
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_becoxy_icons4.ChevronLeft, { className: `${isFullScreen ? "d-none" : ""}`, fontSize: 16 }),
1793
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_becoxy_icons4.ChevronRight, { className: `${!isFullScreen ? "d-none" : ""}`, fontSize: 15 })
1794
- ]
1795
- }
1796
- ),
1797
- children
1798
- ]
1799
- }
1800
- )
1801
- ]
1777
+ ) })
1802
1778
  }
1803
1779
  );
1780
+ });
1781
+
1782
+ // src/component/table/index.tsx
1783
+ var import_react_number_format2 = require("react-number-format");
1784
+
1785
+ // src/component/table/toolbar-top.tsx
1786
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1787
+ var renderToolbarTop = (toolbarTopOption) => {
1788
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { id: "table_custom_top_toolbar", className: "r-toolbar r-toolbar-top", "aria-orientation": "horizontal", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "r-toolbar-items", children: [
1789
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "r-toolbar-left", children: toolbarTopOption?.map((item, index) => {
1790
+ return item.align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-left-${index}`) }) : "";
1791
+ }) }),
1792
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "r-toolbar-center", children: toolbarTopOption?.map((item, index) => {
1793
+ return item.align === "center" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-center-${index}`) }) : "";
1794
+ }) }),
1795
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "r-toolbar-right", children: toolbarTopOption?.map((item, index) => {
1796
+ return item.align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-right-${index}`) }) : "";
1797
+ }) })
1798
+ ] }) });
1804
1799
  };
1805
- var sidebar_default = Sidebar;
1800
+ var toolbar_top_default = renderToolbarTop;
1806
1801
 
1807
- // src/component/sidebar-setting-column/index.tsx
1808
- var import_classnames9 = __toESM(require("classnames"));
1802
+ // src/component/edit-form/index.tsx
1803
+ var import_react13 = require("react");
1804
+ var import_reactstrap9 = require("reactstrap");
1805
+ var import_react_hook_form4 = require("react-hook-form");
1806
+ var import_yup = require("@hookform/resolvers/yup");
1807
+ var import_react_i18next9 = require("react-i18next");
1808
+ var import_classnames10 = __toESM(require("classnames"));
1809
+
1810
+ // src/component/input-text/index.tsx
1811
+ var import_react_hook_form = require("react-hook-form");
1812
+ var import_reactstrap6 = require("reactstrap");
1813
+ var import_classnames7 = __toESM(require("classnames"));
1814
+ var import_react10 = require("react");
1815
+ var import_react_i18next6 = require("react-i18next");
1809
1816
  var import_jsx_runtime10 = require("react/jsx-runtime");
1810
- var SidebarSetColumn = (props) => {
1811
- const { column, setColumn, openSidebar, handleSidebar } = props;
1812
- const { t } = (0, import_react_i18next7.useTranslation)();
1813
- const [dataSource, setDataSource] = (0, import_react10.useState)([]);
1814
- const [indexFocus, setIndexFocus] = (0, import_react10.useState)();
1815
- (0, import_react10.useEffect)(() => {
1816
- if (openSidebar) {
1817
- setDataSource(column.map((e) => ({ ...e })));
1818
- }
1819
- }, [openSidebar]);
1820
- const handleCancel = () => {
1821
- handleSidebar();
1822
- setDataSource([]);
1823
- };
1824
- const handleSubmit = () => {
1825
- setColumn([...dataSource]);
1826
- handleCancel();
1827
- };
1828
- const getWindowSize = () => {
1829
- const { innerWidth, innerHeight } = window;
1830
- return { innerWidth, innerHeight };
1817
+ var TextInput = (props) => {
1818
+ const { t } = (0, import_react_i18next6.useTranslation)();
1819
+ const { control, id, name, min, max, type, label, labelSize, required, errors, height, disabled, row, isLabel, placeholder, autoFocus, inLine, callback, readOnly, classes, ...rest } = props;
1820
+ const renderLabel = () => {
1821
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react10.Fragment, { children: isLabel === false ? "" : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_reactstrap6.Label, { for: name, children: [
1822
+ t(label ? label : ""),
1823
+ " ",
1824
+ required ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-danger", children: "*" }) : "",
1825
+ " "
1826
+ ] }) });
1831
1827
  };
1832
- const [windowSize, setWindowSize] = (0, import_react10.useState)(getWindowSize());
1833
- (0, import_react10.useEffect)(() => {
1834
- const handleWindowResize = () => {
1835
- setWindowSize(getWindowSize());
1836
- };
1837
- window.addEventListener("resize", handleWindowResize);
1838
- return () => {
1839
- window.removeEventListener("resize", handleWindowResize);
1840
- };
1841
- }, []);
1842
- const renderFooterButtons = () => {
1828
+ const renderInput = () => {
1843
1829
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react10.Fragment, { children: [
1844
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_reactstrap7.Button, { color: "primary", onClick: handleSubmit, className: "me-1", children: t("Confirm") }),
1845
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_reactstrap7.Button, { color: "secondary", onClick: handleCancel, outline: true, children: t("Close") })
1846
- ] });
1847
- };
1848
- const visibleTemplate = (item, index) => {
1849
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1850
- import_reactstrap7.Input,
1851
- {
1852
- defaultChecked: item.visible ?? true,
1853
- disabled: item.invisibleDisable,
1854
- type: "checkbox",
1855
- style: { height: 18 },
1856
- className: " cursor-pointer",
1857
- onChange: (e) => {
1858
- if (dataSource) {
1859
- dataSource[index].visible = e.target.checked;
1860
- setDataSource(dataSource);
1861
- }
1862
- }
1863
- }
1864
- );
1865
- };
1866
- const fixColumnTemplate = (item, index) => {
1867
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1868
- import_reactstrap7.Input,
1869
- {
1870
- defaultChecked: item.fixedType === "left" || item.fixedType === "right",
1871
- type: "checkbox",
1872
- style: { height: 18 },
1873
- className: " cursor-pointer",
1874
- onChange: (e) => {
1875
- if (dataSource) {
1876
- if (e.target.checked) {
1877
- if (index * 2 <= dataSource.length) {
1878
- dataSource[index].fixedType = "left";
1879
- } else {
1880
- dataSource[index].fixedType = "right";
1881
- }
1882
- } else {
1883
- dataSource[index].fixedType = void 0;
1830
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1831
+ import_react_hook_form.Controller,
1832
+ {
1833
+ name,
1834
+ control,
1835
+ render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1836
+ import_reactstrap6.Input,
1837
+ {
1838
+ id,
1839
+ value: !isNullOrUndefined(value) ? value : "",
1840
+ onChange: (val) => {
1841
+ if (min || max) {
1842
+ if (min && Number(val.target.value) >= min) {
1843
+ onChange(val.target.value);
1844
+ if (callback) {
1845
+ callback(val);
1846
+ }
1847
+ }
1848
+ if (max && Number(val.target.value) <= max) {
1849
+ onChange(val.target.value);
1850
+ if (callback) {
1851
+ callback(val);
1852
+ }
1853
+ }
1854
+ } else {
1855
+ onChange(val.target.value);
1856
+ if (callback) {
1857
+ callback(val);
1858
+ }
1859
+ }
1860
+ },
1861
+ style: { height: `${height}px` },
1862
+ autoFocus,
1863
+ disabled,
1864
+ placeholder,
1865
+ type: type ? type : "text",
1866
+ invalid: errors && true,
1867
+ className: "h-100",
1868
+ rows: row,
1869
+ min,
1870
+ max,
1871
+ readOnly,
1872
+ ...rest
1884
1873
  }
1885
- setDataSource(dataSource);
1886
- }
1874
+ )
1887
1875
  }
1888
- }
1889
- );
1890
- };
1891
- const columns = [
1892
- {
1893
- field: "headerText",
1894
- headerText: "Column name",
1895
- template: (e) => {
1896
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: t(e.headerText) });
1897
- },
1898
- visible: true,
1899
- width: 175,
1900
- maxWidth: 200,
1901
- minWidth: 150
1902
- },
1903
- {
1904
- field: "",
1905
- template: visibleTemplate,
1906
- headerText: "Display",
1907
- textAlign: "center",
1908
- visible: true,
1909
- width: 100,
1910
- maxWidth: 120,
1911
- minWidth: 80
1912
- },
1913
- {
1914
- field: "",
1915
- template: fixColumnTemplate,
1916
- headerText: "Fix the column",
1917
- textAlign: "center",
1918
- visible: true,
1919
- width: 100,
1920
- maxWidth: 120,
1921
- minWidth: 80
1922
- },
1923
- {
1924
- field: "width",
1925
- headerText: "Column width",
1926
- textAlign: "right",
1927
- visible: true,
1928
- width: 100,
1929
- maxWidth: 120,
1930
- minWidth: 80
1931
- }
1932
- ];
1933
- const renderHeaderCol = (col, indexCol) => {
1934
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1935
- import_react10.Fragment,
1936
- {
1937
- children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1938
- "th",
1939
- {
1940
- className: (0, import_classnames9.default)(
1941
- `r-headercell fix-${col.fixedType}`,
1942
- { "cell-fixed": col.fixedType }
1943
- ),
1944
- style: {
1945
- width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
1946
- minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
1947
- top: `${0 * 42}px`,
1948
- maxWidth: col.maxWidth
1949
- },
1950
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1951
- "div",
1952
- {
1953
- role: "textbox",
1954
- title: t(col.headerText ?? ""),
1955
- style: {
1956
- height: `${1 * 42}px`,
1957
- justifyContent: col.textAlign ?? "left"
1958
- },
1959
- className: "r-headercell-div",
1960
- children: t(col.headerText ?? "")
1961
- }
1962
- )
1963
- }
1964
- )
1965
- },
1966
- `header-${indexCol}`
1967
- );
1876
+ ),
1877
+ errors && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_reactstrap6.FormFeedback, { children: errors?.message })
1878
+ ] });
1968
1879
  };
1969
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1970
- sidebar_default,
1880
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react10.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1881
+ "div",
1971
1882
  {
1972
- open: openSidebar,
1973
- toggleSidebar: handleCancel,
1974
- width: 700,
1883
+ className: (0, import_classnames7.default)(
1884
+ " align",
1885
+ {
1886
+ [labelSize ? labelSize : ""]: labelSize,
1887
+ [classes ? classes : ""]: classes,
1888
+ "form-row-inline-error": errors
1889
+ },
1890
+ inLine === false ? "form-group " : "form-row-inline d-flex"
1891
+ ),
1975
1892
  children: [
1976
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(modal_header_default, { typeModal: "Edit", handleModal: handleCancel, title: "Column setup" }),
1977
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "ms-2 react-table-edit", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "r-grid", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "r-gridtable", style: { height: windowSize.innerHeight - 120 }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("table", { style: { width: "100%" }, children: [
1978
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("thead", { className: "r-gridheader", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("tr", { className: "r-row", role: "row", children: columns.map((col, index) => {
1979
- return renderHeaderCol(col, index);
1980
- }) }) }),
1981
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("tbody", { className: "r-gridcontent", children: dataSource?.map((row, indexRow) => {
1982
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1983
- "tr",
1984
- {
1985
- className: (0, import_classnames9.default)("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }),
1986
- children: columns.map((col, indexCol) => {
1987
- let value = row[col.field];
1988
- if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
1989
- value = formartNumberic(row[col.field], ",", ".", col.numericSettings?.fraction, true) ?? 0;
1990
- }
1991
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react10.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1992
- "td",
1993
- {
1994
- className: (0, import_classnames9.default)(
1995
- `r-rowcell fix-${col.fixedType}`,
1996
- { "cell-fixed": col.fixedType },
1997
- { "r-active": indexFocus === indexRow }
1998
- ),
1999
- style: {
2000
- padding: 0,
2001
- textAlign: col.textAlign ? col.textAlign : "left"
2002
- },
2003
- onFocus: (e) => {
2004
- if (indexRow !== indexFocus) {
2005
- setIndexFocus(indexRow);
2006
- }
2007
- e.stopPropagation();
2008
- },
2009
- onClick: (e) => {
2010
- if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
2011
- if (indexRow !== indexFocus) {
2012
- setIndexFocus(indexRow);
2013
- }
2014
- e.stopPropagation();
2015
- }
2016
- },
2017
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2018
- "div",
2019
- {
2020
- className: (0, import_classnames9.default)("r-rowcell-div"),
2021
- style: {
2022
- width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : "auto"
2023
- },
2024
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2025
- "div",
2026
- {
2027
- className: (0, import_classnames9.default)("r-rowcell-content"),
2028
- style: {
2029
- margin: "7px 9px"
2030
- },
2031
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "r-cell-text", children: col.template ? col.template(row, indexRow) : value })
2032
- }
2033
- )
2034
- }
2035
- )
2036
- },
2037
- `col-${indexRow}-${indexCol}`
2038
- ) }, indexCol);
2039
- })
2040
- },
2041
- `row-${indexRow}`
2042
- );
2043
- }) })
2044
- ] }) }) }) }),
2045
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2046
- "div",
2047
- {
2048
- className: "d-flex justify-content-end p-1 ",
2049
- style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" },
2050
- children: renderFooterButtons()
2051
- }
2052
- )
1893
+ renderLabel(),
1894
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: (0, import_classnames7.default)("form-input-content", { "hidden-label": isLabel === false }), children: renderInput() })
2053
1895
  ]
2054
1896
  }
2055
- );
1897
+ ) });
2056
1898
  };
2057
- var sidebar_setting_column_default = SidebarSetColumn;
1899
+ var input_text_default = TextInput;
2058
1900
 
2059
- // src/component/table/paging/index.tsx
2060
- var import_becoxy_icons5 = require("becoxy-icons");
2061
- var import_classnames10 = __toESM(require("classnames"));
1901
+ // src/component/input-number/index.tsx
1902
+ var import_react_hook_form2 = require("react-hook-form");
1903
+ var import_reactstrap7 = require("reactstrap");
1904
+ var import_classnames8 = __toESM(require("classnames"));
2062
1905
  var import_react11 = require("react");
2063
- var import_react_i18next8 = require("react-i18next");
1906
+ var import_react_number_format = require("react-number-format");
1907
+ var import_react_i18next7 = require("react-i18next");
2064
1908
  var import_jsx_runtime11 = require("react/jsx-runtime");
2065
- var PagingComponent = ({ totalItem, pageSize, currentPage, onChangePage, pageOptions, onChangePageSize }) => {
2066
- const { t } = (0, import_react_i18next8.useTranslation)();
2067
- const [countPage, setCountPage] = (0, import_react11.useState)(0);
2068
- const [currentPageNumber, setCurrentPageNumber] = (0, import_react11.useState)(1);
2069
- (0, import_react11.useEffect)(() => {
2070
- setCountPage(Math.floor(totalItem / pageSize) + (Math.floor(totalItem / pageSize) === totalItem / pageSize ? 0 : 1));
2071
- }, [totalItem, pageSize]);
2072
- (0, import_react11.useEffect)(() => {
2073
- setCurrentPageNumber(Math.floor(currentPage / 5) + (Math.floor(currentPage / 5) === currentPage / 5 ? 0 : 1));
2074
- }, [currentPage]);
2075
- const renderPageNumber = (number) => {
2076
- const arr = [];
2077
- for (let index = (number - 1) * 5 + 1; index <= number * 5 && index <= Math.floor(totalItem / pageSize) + (Math.floor(totalItem / pageSize) === totalItem / pageSize ? 0 : 1); index++) {
2078
- arr.push(
2079
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2080
- "div",
2081
- {
2082
- className: (0, import_classnames10.default)("r-number", { "r-active": index === currentPage }),
2083
- onClick: () => {
2084
- onChangePage({ totalItem, pageSize, currentPage: index, old: currentPage });
2085
- },
2086
- children: index
2087
- },
2088
- `page-${index}`
2089
- )
2090
- );
2091
- }
2092
- return arr;
1909
+ var NumberInput = (props) => {
1910
+ const {
1911
+ id,
1912
+ control,
1913
+ fractionCurrency,
1914
+ name,
1915
+ min,
1916
+ max,
1917
+ label,
1918
+ labelSize,
1919
+ required,
1920
+ errors,
1921
+ disabled,
1922
+ isLabel,
1923
+ fixedDecimalScale,
1924
+ placeholder,
1925
+ inLine,
1926
+ callback,
1927
+ decimalSeparator = ",",
1928
+ thousandSeparator = ".",
1929
+ classes,
1930
+ width,
1931
+ allowNegative
1932
+ } = props;
1933
+ const { t } = (0, import_react_i18next7.useTranslation)();
1934
+ const renderLabel = () => {
1935
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react11.Fragment, { children: isLabel === false ? "" : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_reactstrap7.Label, { className: "form-label", for: name, children: [
1936
+ t(label ? label : ""),
1937
+ " ",
1938
+ required ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-danger", children: "*" }) : "",
1939
+ " "
1940
+ ] }) });
2093
1941
  };
2094
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react11.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "r-pager", children: [
2095
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "r-pagercontainer", children: [
2096
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "r-button", type: "button", disabled: countPage <= 1 || currentPage === 1, onClick: () => onChangePage({ totalItem, pageSize, currentPage: 1, old: currentPage }), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_becoxy_icons5.ChevronsLeft, { fontSize: 16 }) }),
2097
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "r-button", type: "button", disabled: countPage <= 1 || currentPage === 1, onClick: () => onChangePage({ totalItem, pageSize, currentPage: currentPage - 1, old: currentPage }), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_becoxy_icons5.ChevronLeft, { fontSize: 16 }) }),
1942
+ const renderInput = () => {
1943
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react11.Fragment, { children: [
2098
1944
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2099
- "button",
1945
+ import_react_hook_form2.Controller,
2100
1946
  {
2101
- className: (0, import_classnames10.default)("r-button", { "d-none": currentPageNumber === 1 }),
2102
- type: "button",
2103
- onClick: () => {
2104
- setCurrentPageNumber(currentPageNumber - 1);
2105
- onChangePage({ totalItem, pageSize, currentPage: (currentPageNumber - 2) * 5 + 1, old: currentPage });
2106
- },
2107
- children: "..."
1947
+ name,
1948
+ control,
1949
+ render: ({ field: { value, onChange } }) => {
1950
+ let floatValue = parseFloat(value);
1951
+ const numericFormatProps = {
1952
+ value: !isNullOrUndefined(value) ? value : "",
1953
+ thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
1954
+ decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
1955
+ allowNegative: allowNegative ?? false,
1956
+ decimalScale: fractionCurrency ?? 0,
1957
+ fixedDecimalScale
1958
+ };
1959
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1960
+ import_react_number_format.NumericFormat,
1961
+ {
1962
+ ...numericFormatProps,
1963
+ className: (0, import_classnames8.default)("form-control text-right", {
1964
+ "is-invalid": errors
1965
+ }),
1966
+ onValueChange: (values) => {
1967
+ floatValue = values?.floatValue;
1968
+ const textBeforeDot = values?.value.split(".")[1];
1969
+ onChange(textBeforeDot ? parseFloat(values?.value).toFixed(textBeforeDot.length) : values?.floatValue);
1970
+ },
1971
+ onFocus: (e) => {
1972
+ e.target.setSelectionRange(0, e.target.innerText.length - 1);
1973
+ },
1974
+ onChange: () => {
1975
+ if (callback) {
1976
+ callback(floatValue);
1977
+ }
1978
+ },
1979
+ onBlur: () => {
1980
+ if (max && floatValue > max) {
1981
+ onChange(max);
1982
+ } else if (min && floatValue < min) {
1983
+ onChange(min);
1984
+ } else {
1985
+ onChange(floatValue);
1986
+ }
1987
+ },
1988
+ placeholder,
1989
+ disabled
1990
+ }
1991
+ );
1992
+ }
2108
1993
  }
2109
1994
  ),
2110
- renderPageNumber(currentPageNumber),
2111
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2112
- "button",
1995
+ errors && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_reactstrap7.FormFeedback, { children: errors?.message })
1996
+ ] });
1997
+ };
1998
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react11.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1999
+ "div",
2000
+ {
2001
+ className: (0, import_classnames8.default)(
2002
+ " align",
2113
2003
  {
2114
- className: (0, import_classnames10.default)("r-button", { "d-none": currentPageNumber * 5 >= countPage }),
2115
- type: "button",
2116
- onClick: () => {
2117
- setCurrentPageNumber(currentPageNumber + 1);
2118
- onChangePage({ totalItem, pageSize, currentPage: currentPageNumber * 5 + 1, old: currentPage });
2119
- },
2120
- children: "..."
2121
- }
2004
+ [labelSize ? labelSize : ""]: labelSize,
2005
+ [classes ? classes : ""]: classes,
2006
+ "form-row-inline-error": errors
2007
+ },
2008
+ inLine === false ? "form-group " : "form-row-inline d-flex"
2122
2009
  ),
2123
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "r-button", type: "button", disabled: countPage <= 1 || countPage === currentPage, onClick: () => onChangePage({ totalItem, pageSize, currentPage: currentPage + 1, old: currentPage }), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_becoxy_icons5.ChevronRight, { fontSize: 16 }) }),
2124
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "r-button", type: "button", disabled: countPage <= 1 || countPage === currentPage, onClick: () => onChangePage({ totalItem, pageSize, currentPage: Math.floor(totalItem / pageSize) + (Math.floor(totalItem / pageSize) === totalItem / pageSize ? 0 : 1), old: currentPage }), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_becoxy_icons5.ChevronsRight, { fontSize: 16 }) }),
2125
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "r-pagesize", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2126
- SelectTable,
2127
- {
2128
- value: { value: pageSize, label: pageSize },
2129
- noHeader: true,
2130
- options: pageOptions.map((item) => ({ value: item, label: item })),
2131
- onChange: (val) => {
2132
- onChangePageSize({ totalItem, pageSize: val?.value });
2133
- },
2134
- menuWidth: 90,
2135
- width: 90,
2136
- placeholder: t("Select")
2137
- }
2138
- ) }),
2139
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { style: { display: "inline", marginLeft: 10, fontSize: 13 }, children: t("pagerDropDown") })
2140
- ] }),
2141
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "r-parentmsgbar", children: t("totalItemsInfo", { page: currentPage, countPage, totalItem }) })
2142
- ] }) });
2010
+ children: [
2011
+ renderLabel(),
2012
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { width: width ? width : void 0 }, className: (0, import_classnames8.default)("form-input-content", { "hidden-label": isLabel === false }), children: renderInput() })
2013
+ ]
2014
+ }
2015
+ ) });
2143
2016
  };
2017
+ var input_number_default = NumberInput;
2144
2018
 
2145
- // src/component/table/header.tsx
2146
- var import_react12 = require("react");
2147
- var import_classnames11 = __toESM(require("classnames"));
2019
+ // src/component/edit-form/select-table/index.tsx
2020
+ var import_react_hook_form3 = require("react-hook-form");
2148
2021
  var import_reactstrap8 = require("reactstrap");
2149
- var import_react_i18next9 = require("react-i18next");
2150
- var import_react_resizable = require("react-resizable");
2151
- var import_styles = require("react-resizable/css/styles.css");
2022
+ var import_classnames9 = __toESM(require("classnames"));
2023
+ var import_react12 = require("react");
2024
+ var import_react_i18next8 = require("react-i18next");
2152
2025
  var import_jsx_runtime12 = require("react/jsx-runtime");
2153
- var HeaderTableCol = (props) => {
2026
+ var SelectTableBox = (props) => {
2154
2027
  const {
2155
- selectEnable,
2156
- dataSource,
2157
- setSelectedRows,
2158
- col,
2159
- indexCol,
2160
- indexParent,
2161
- objWidthFix,
2162
- totalCount,
2163
- selectedRows,
2164
- column,
2165
- setColumn,
2166
- isMulti
2028
+ isMulti,
2029
+ isLabel,
2030
+ confirmHandle,
2031
+ id,
2032
+ fieldValue,
2033
+ fieldLabel,
2034
+ labelComponent,
2035
+ defaultOptions,
2036
+ loadOptions,
2037
+ control,
2038
+ placeholder,
2039
+ disabled,
2040
+ name,
2041
+ label,
2042
+ labelSize,
2043
+ required,
2044
+ errors,
2045
+ inLine,
2046
+ callback,
2047
+ desciptionLabel,
2048
+ classLabel,
2049
+ isClearable,
2050
+ defaultValue,
2051
+ handleAddNew,
2052
+ columns,
2053
+ ...rest
2167
2054
  } = props;
2168
- const { t } = (0, import_react_i18next9.useTranslation)();
2169
- const handleResize = (e, { size }) => {
2170
- if (size.width > 50) {
2171
- const newColumns = [...column];
2172
- newColumns[indexCol].width = size.width;
2173
- setColumn(newColumns);
2055
+ const handChange = ({ onChange, val }) => {
2056
+ onChange(!isNullOrUndefined(val) && isMulti ? val.map((item) => item.value) : !isNullOrUndefined(val) && !isMulti ? fieldValue ? val[fieldValue] : val?.value : void 0);
2057
+ if (callback) {
2058
+ callback(val);
2174
2059
  }
2175
2060
  };
2176
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2177
- import_react_resizable.Resizable,
2061
+ const renderLabel = (props2) => {
2062
+ const { t } = (0, import_react_i18next8.useTranslation)();
2063
+ const { isLabel: isLabel2, desciptionLabel: desciptionLabel2, id: id2, classLabel: classLabel2, name: name2, label: label2, required: required2 } = props2;
2064
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react12.Fragment, { children: [
2065
+ isLabel2 === false ? "" : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_reactstrap8.Label, { id: `label-${id2}`, className: classLabel2, for: name2, children: [
2066
+ t(label2 ? label2 : ""),
2067
+ " ",
2068
+ required2 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-danger", children: "*" }) : ""
2069
+ ] }),
2070
+ (!isNullOrUndefined(desciptionLabel2) && desciptionLabel2 !== "") ?? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.UncontrolledTooltip, { target: `label-${id2}`, children: t(desciptionLabel2 ?? "") }) })
2071
+ ] });
2072
+ };
2073
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2074
+ "div",
2178
2075
  {
2179
- className: "r-resize",
2180
- width: typeof col.width === "number" ? col.width : Number((col.width ?? "").replaceAll(new RegExp(`[^0-9]`, "g"), "")),
2181
- height: 0,
2182
- onResize: handleResize,
2183
- draggableOpts: { enableUserSelectHack: false },
2184
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2185
- "th",
2076
+ className: (0, import_classnames9.default)(
2077
+ inLine === false ? "form-group " : "form-row-inline d-flex",
2078
+ "align",
2186
2079
  {
2187
- rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
2188
- colSpan: col.columns?.length ?? 1,
2189
- className: (0, import_classnames11.default)(`r-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2190
- style: {
2191
- top: `${indexParent * 42}px`,
2192
- left: col.fixedType === "left" ? objWidthFix[col.index ?? 0] : void 0,
2193
- right: col.fixedType === "right" ? objWidthFix[col.index ?? 0] : void 0,
2194
- width: col.width ? typeof col.width === "number" ? col.width : col.width?.includes("px") || col.width?.includes("%") ? col.width : `${col.width}px` : "auto",
2195
- minWidth: col.width ? typeof col.width === "number" ? col.width : col.width?.includes("px") || col.width?.includes("%") ? col.width : `${col.width}px` : "auto",
2196
- maxWidth: col.width ? typeof col.width === "number" ? col.width : col.width?.includes("px") || col.width?.includes("%") ? col.width : `${col.width}px` : "auto"
2197
- },
2198
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2199
- "div",
2080
+ [labelSize ? labelSize : ""]: labelSize,
2081
+ "form-row-inline-error": errors
2082
+ }
2083
+ ),
2084
+ children: [
2085
+ renderLabel({ isLabel, desciptionLabel, classLabel, name, label, required, id: id ?? "" }),
2086
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: (0, import_classnames9.default)("form-input-content", { "hidden-label": isLabel === false }), children: [
2087
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2088
+ import_react_hook_form3.Controller,
2200
2089
  {
2201
- style: { justifyContent: col.textAlign ?? "left" },
2202
- className: (0, import_classnames11.default)("r-headercell-div"),
2203
- children: [
2204
- col.field === "checkbox" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2205
- import_reactstrap8.Input,
2090
+ name,
2091
+ control,
2092
+ render: ({ field: { value, onChange } }) => {
2093
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2094
+ SelectTable,
2206
2095
  {
2207
- checked: totalCount > 0 && selectedRows?.length >= totalCount,
2208
- type: "checkbox",
2209
- className: (0, import_classnames11.default)("cursor-pointer", { "d-none": !isMulti }),
2210
- style: { textAlign: col.textAlign ?? "left", marginTop: 6 },
2211
- onChange: (e) => {
2212
- if (selectEnable) {
2213
- if (e.target.checked) {
2214
- setSelectedRows(dataSource.map((item) => {
2215
- return item;
2216
- }));
2096
+ ...rest,
2097
+ id,
2098
+ value: (isMulti ? value?.length > 0 : value) ? !isMulti ? defaultOptions.find((val) => val[fieldValue ?? "value"] === value) ?? (defaultValue ?? "") : value : isMulti ? [] : void 0,
2099
+ onChange: (val) => {
2100
+ if (isMulti || (fieldValue && val ? val[fieldValue] : val?.value) !== value) {
2101
+ if (confirmHandle) {
2102
+ confirmHandle(handChange, onChange, val);
2217
2103
  } else {
2218
- setSelectedRows([]);
2104
+ if (isMulti) {
2105
+ onChange(!isNullOrUndefined(val) ? val.map((item) => item[fieldValue ?? "value"]) : []);
2106
+ } else {
2107
+ onChange(!isNullOrUndefined(val) ? val[fieldValue ?? "value"] : void 0);
2108
+ }
2109
+ if (callback) {
2110
+ callback(val);
2111
+ }
2219
2112
  }
2220
2113
  }
2221
- }
2222
- }
2223
- ),
2224
- col.field !== "checkbox" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "header-content", children: t(col.headerText ?? "") }) })
2225
- ]
2226
- }
2227
- )
2228
- }
2229
- )
2230
- }
2231
- ) }, `header-${indexCol}`);
2232
- };
2233
- var header_default = HeaderTableCol;
2234
-
2235
- // src/component/table/command.tsx
2236
- var import_react14 = require("react");
2237
- var import_classnames12 = __toESM(require("classnames"));
2238
- var import_reactstrap9 = require("reactstrap");
2239
- var import_react_i18next10 = require("react-i18next");
2240
-
2241
- // src/component/icon/index.tsx
2242
- var Icon = __toESM(require("becoxy-icons"));
2243
- var import_react13 = require("react");
2244
- var import_jsx_runtime13 = require("react/jsx-runtime");
2245
- var IconCustom = (props) => {
2246
- const { iconName, size } = props;
2247
- if (iconName === "") {
2248
- return null;
2249
- } else {
2250
- const TagIcon = iconName === "" ? "" : Icon[iconName];
2251
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react13.Fragment, { children: iconName === "" ? "" : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TagIcon, { fontSize: size }) });
2252
- }
2253
- };
2254
- var icon_default = IconCustom;
2255
-
2256
- // src/component/table/command.tsx
2257
- var import_jsx_runtime14 = require("react/jsx-runtime");
2258
- var CommandElement = (props) => {
2259
- const { commandItems, rowData, indexRow, handleCommandClick, indexFocus, setIndexFocus } = props;
2260
- const { t } = (0, import_react_i18next10.useTranslation)();
2261
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react14.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "d-flex align-items-center", style: { columnGap: 10 }, children: commandItems.map((item, index) => {
2262
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2263
- import_reactstrap9.Button,
2264
- {
2265
- id: `command-item-${indexRow}-${index}`,
2266
- tabIndex: -1,
2267
- style: { padding: "5px", minWidth: 45, height: "100%" },
2268
- className: (0, import_classnames12.default)("command-item", {
2269
- "btn-icon": item.tooltip === ""
2270
- }),
2271
- color: item.color ? item.color : "#000",
2272
- onClick: (e) => {
2273
- handleCommandClick(item.id, rowData, indexRow);
2274
- if (indexRow === indexFocus) {
2275
- setIndexFocus(void 0);
2276
- }
2277
- e.preventDefault();
2278
- },
2279
- children: [
2280
- item.icon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(icon_default, { iconName: item.icon, size: 16 }),
2281
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_reactstrap9.UncontrolledTooltip, { className: "r-tooltip", target: `command-item-${indexRow}-${index}`, place: "top", children: t(item.tooltip ?? "") })
2282
- ]
2283
- },
2284
- `command-${index}`
2285
- );
2286
- }) }) });
2114
+ },
2115
+ handleAdd: handleAddNew,
2116
+ isClearable,
2117
+ isMulti,
2118
+ placeholder,
2119
+ invalid: errors,
2120
+ loadOptions,
2121
+ options: defaultOptions,
2122
+ isDisabled: disabled,
2123
+ columns,
2124
+ fieldValue,
2125
+ fieldLabel,
2126
+ formatOptionLabel: labelComponent ? labelComponent : void 0
2127
+ }
2128
+ );
2129
+ }
2130
+ }
2131
+ ),
2132
+ errors && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.FormFeedback, { children: errors?.message })
2133
+ ] })
2134
+ ]
2135
+ }
2136
+ ) });
2287
2137
  };
2288
- var command_default = CommandElement;
2138
+ var select_table_default = SelectTableBox;
2289
2139
 
2290
- // src/component/select-table-tree/index.tsx
2291
- var import_react15 = __toESM(require("react"));
2292
- var import_reactstrap10 = require("reactstrap");
2293
- var import_react_i18next11 = require("react-i18next");
2294
- var import_classnames13 = __toESM(require("classnames"));
2295
- var import_becoxy_icons6 = require("becoxy-icons");
2296
- var import_jsx_runtime15 = require("react/jsx-runtime");
2297
- var defaultMaxHeight2 = 250;
2298
- var SelectTableTree = (0, import_react15.forwardRef)((props, ref) => {
2140
+ // src/component/edit-form/index.tsx
2141
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2142
+ var defaultWidth = 200;
2143
+ var EditForm = (0, import_react13.forwardRef)((props, ref) => {
2299
2144
  const {
2300
2145
  id,
2146
+ field,
2147
+ displayValue,
2148
+ menuHeight,
2301
2149
  menuWidth,
2302
- width,
2150
+ rowData,
2303
2151
  invalid,
2152
+ onChange,
2153
+ onChangeField,
2304
2154
  onKeyDown,
2155
+ defaultValues,
2305
2156
  placeholder,
2306
2157
  textAlign,
2307
- options,
2308
- columns,
2309
- onChange,
2310
- value,
2311
- fieldValue,
2312
- fieldLabel,
2313
- fieldChildren,
2314
- maxHeight,
2315
- handleAdd,
2158
+ schema,
2159
+ onFormOpen,
2160
+ onFormSubmit,
2161
+ footerTemplate,
2162
+ minWidth,
2163
+ onPaste,
2164
+ openOnFocus,
2316
2165
  isClearable,
2317
- component,
2318
- formatOptionLabel,
2319
- isMulti,
2320
- noHeader,
2321
- isDisabled,
2322
- showFooter,
2323
- selectChilds,
2324
- footerComponent,
2325
- formatSetting,
2326
- onOpenMenu,
2327
- onPaste
2166
+ labelSize = "label-small"
2328
2167
  } = props;
2329
- const selectTableRef = (0, import_react15.useRef)();
2330
- const selectMenuTableRef = (0, import_react15.useRef)();
2331
- const inputRef = (0, import_react15.useRef)();
2332
- const [dropdownOpen, setDropdownOpen] = (0, import_react15.useState)(false);
2333
- const [isFocus, setIsFocus] = (0, import_react15.useState)(false);
2334
- const [searchTerm, setSearchTerm] = (0, import_react15.useState)("");
2335
- const { t } = (0, import_react_i18next11.useTranslation)();
2336
- const areAllItemsSelected = (value2, options2, fieldValue2) => {
2337
- const checkAllSelected = (nodes) => {
2338
- return nodes.every((node) => {
2339
- const isSelected = value2.includes(node[fieldValue2]);
2340
- const childrenSelected = node.children ? checkAllSelected(node.children) : true;
2341
- return isSelected && childrenSelected;
2342
- });
2343
- };
2344
- return checkAllSelected(options2);
2345
- };
2346
- const isSelectedAll = (0, import_react15.useMemo)(() => {
2347
- return isMulti === true && options.length > 0 && areAllItemsSelected(value, options, fieldValue ?? "value");
2348
- }, [options, value]);
2349
- (0, import_react15.useEffect)(() => {
2350
- if (dropdownOpen && onOpenMenu) {
2351
- onOpenMenu();
2352
- }
2353
- }, [dropdownOpen]);
2354
- const defaultColumns = [
2355
- {
2356
- headerText: "Name",
2357
- field: fieldLabel ?? "label",
2358
- width: menuWidth
2359
- }
2360
- ];
2168
+ const { innerWidth } = window;
2169
+ const inputRef = (0, import_react13.useRef)();
2170
+ const editFormRef = (0, import_react13.useRef)();
2171
+ const buttonRef = (0, import_react13.useRef)();
2172
+ const [dropdownOpen, setDropdownOpen] = (0, import_react13.useState)(false);
2173
+ const [itemsField, setItemsField] = (0, import_react13.useState)([]);
2174
+ const { t } = (0, import_react_i18next9.useTranslation)();
2175
+ useOnClickOutside(editFormRef, () => {
2176
+ closeMenu();
2177
+ });
2361
2178
  const closeMenu = () => {
2362
- setDropdownOpen(false);
2179
+ setTimeout(() => {
2180
+ setDropdownOpen(false);
2181
+ }, onChangeField ? 10 : 0);
2363
2182
  };
2364
- (0, import_react15.useEffect)(() => {
2365
- if (dropdownOpen && value && !isMulti && selectMenuTableRef) {
2366
- const index = options?.findIndex((e) => e[fieldValue ?? "value"] === value[fieldValue ?? "value"]);
2367
- if (index >= 0) {
2368
- selectMenuTableRef.current.scrollTo({ top: (index - 1) * 30 });
2183
+ const {
2184
+ control,
2185
+ handleSubmit,
2186
+ getValues,
2187
+ reset,
2188
+ setValue,
2189
+ formState: { errors }
2190
+ } = (0, import_react_hook_form4.useForm)({
2191
+ mode: "onChange",
2192
+ defaultValues,
2193
+ resolver: (0, import_yup.yupResolver)(schema)
2194
+ });
2195
+ (0, import_react13.useEffect)(() => {
2196
+ if (dropdownOpen) {
2197
+ if (onFormOpen && itemsField.length === 0) {
2198
+ onFormOpen(rowData, itemsField, setItemsField);
2199
+ }
2200
+ if (openOnFocus) {
2201
+ setTimeout(() => {
2202
+ focusElement(`form-element-${field}-0`, true);
2203
+ }, 100);
2369
2204
  }
2370
2205
  }
2371
2206
  }, [dropdownOpen]);
2372
- (0, import_react15.useEffect)(() => {
2373
- if (inputRef && !isDisabled) {
2374
- inputRef.current.addEventListener("blur", function() {
2375
- setDropdownOpen(false);
2376
- setSearchTerm("");
2377
- setIsFocus(false);
2378
- });
2379
- inputRef.current.addEventListener("focus", function() {
2380
- if (!isFocus) {
2381
- setIsFocus(true);
2382
- }
2207
+ (0, import_react13.useEffect)(() => {
2208
+ if (dropdownOpen && itemsField.length > 0) {
2209
+ itemsField.forEach((ele) => {
2210
+ setValue(ele.name, rowData[ele.name] ?? "");
2383
2211
  });
2384
2212
  }
2385
- }, [inputRef]);
2386
- (0, import_react15.useEffect)(() => {
2387
- if (searchTerm && !dropdownOpen) {
2388
- setDropdownOpen(true);
2389
- }
2390
- }, [searchTerm]);
2391
- const handleOpenClose = () => {
2392
- setSearchTerm("");
2213
+ }, [dropdownOpen, itemsField]);
2214
+ const handleOnClick = () => {
2393
2215
  if (dropdownOpen) {
2394
2216
  closeMenu();
2395
2217
  } else {
2396
- if (!isDisabled) {
2397
- setDropdownOpen(true);
2218
+ setDropdownOpen(true);
2219
+ }
2220
+ };
2221
+ const handleOnSubmit = (val) => {
2222
+ closeMenu();
2223
+ onChange(val);
2224
+ if (onFormSubmit) {
2225
+ onFormSubmit(rowData, setValue, getValues, reset);
2226
+ }
2227
+ inputRef.current.focus();
2228
+ };
2229
+ const focusElement = (id2, focus) => {
2230
+ const element = document.getElementById(id2);
2231
+ if (element) {
2232
+ if (element.className.includes("react-select")) {
2233
+ element.getElementsByTagName("input")[0]?.focus();
2234
+ } else {
2235
+ element.focus();
2236
+ if (focus) {
2237
+ element.setSelectionRange(0, element.innerText.length - 1);
2238
+ }
2398
2239
  }
2399
2240
  }
2400
2241
  };
2401
- const listKeyUse = ["Escape", "Space", "F9"];
2402
2242
  const handleOnKeyDown = (e) => {
2403
- let key = "";
2404
- if (onKeyDown && (!dropdownOpen || !listKeyUse.includes(e.code) || e.code === "Escape" && !(isClearable && value && !isDisabled))) {
2405
- key = onKeyDown(e);
2406
- }
2407
2243
  let flag = false;
2408
- if (!key) {
2409
- if (e.code === "F9") {
2410
- handleAdd();
2244
+ if (dropdownOpen) {
2245
+ if (e.code === "Escape") {
2246
+ closeMenu();
2247
+ flag = true;
2248
+ } else if (e.code === "Enter") {
2249
+ closeMenu();
2250
+ flag = true;
2251
+ } else if (e.code === "ArrowDown") {
2252
+ focusElement(`form-element-${field}-0`);
2253
+ flag = true;
2254
+ }
2255
+ } else {
2256
+ if (e.code === "ArrowDown") {
2257
+ setDropdownOpen(true);
2258
+ focusElement(`form-element-${field}-0`);
2411
2259
  flag = true;
2412
2260
  } else if (e.code === "Space") {
2413
- if (!searchTerm) {
2414
- handleOpenClose();
2415
- flag = true;
2416
- }
2417
- } else if (e.code === "Escape") {
2418
- if (dropdownOpen && isClearable && value && !isDisabled) {
2419
- onChange(void 0);
2420
- handleOpenClose();
2421
- flag = true;
2422
- }
2261
+ setDropdownOpen(true);
2262
+ flag = true;
2423
2263
  }
2424
2264
  }
2425
- if (flag) {
2265
+ if (onKeyDown && !flag) {
2266
+ const key = onKeyDown(e);
2267
+ if (key === "ArrowRight" || key === "ArrowLeft") {
2268
+ closeMenu();
2269
+ }
2270
+ } else {
2426
2271
  e.stopPropagation();
2427
2272
  e.preventDefault();
2428
2273
  }
2429
2274
  };
2430
- const renderHeaderCol = (col, indexCol) => {
2431
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react15.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2432
- "th",
2433
- {
2434
- className: (0, import_classnames13.default)(`r-select-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2435
- style: {
2436
- width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2437
- minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
2438
- maxWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
2439
- top: `${0 * 35}px`
2440
- },
2441
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2442
- "div",
2443
- {
2444
- role: "textbox",
2445
- title: t(col.headerText ?? ""),
2446
- style: {
2447
- height: `${1 * 35}px`,
2448
- justifyContent: col.textAlign ?? "left"
2449
- },
2450
- className: "r-select-headercell-div",
2451
- children: t(col.headerText ?? "")
2452
- }
2453
- )
2275
+ const formKeyDown = (e, handSubmit) => {
2276
+ if (e.code === "Enter") {
2277
+ handSubmit();
2278
+ e.preventDefault();
2279
+ e.stopPropagation();
2280
+ } else {
2281
+ if (onKeyDown) {
2282
+ const key = onKeyDown(e);
2283
+ if (key === "ArrowRight" || key === "ArrowLeft") {
2284
+ closeMenu();
2285
+ }
2454
2286
  }
2455
- ) }, `header-select-${indexCol}`);
2287
+ }
2456
2288
  };
2457
- const checkSearch = (keyword, data, columnsSearch) => {
2458
- if (!keyword || columnsSearch.length === 0) {
2459
- return true;
2289
+ const formItemKeyDown = (e, index) => {
2290
+ if (e.code === "ArrowDown" && index < itemsField.length - 1) {
2291
+ focusElement(`form-element-${field}-${index + 1}`);
2292
+ e.preventDefault();
2293
+ e.stopPropagation();
2294
+ } else if (e.code === "ArrowUp" && index > 0) {
2295
+ focusElement(`form-element-${field}-${index - 1}`);
2296
+ e.preventDefault();
2297
+ e.stopPropagation();
2298
+ } else if (e.code === "Tab" && onChangeField && index === itemsField.length - 1) {
2299
+ closeMenu();
2460
2300
  }
2461
- for (let index = 0; index < columnsSearch.length; index++) {
2462
- const key = columnsSearch[index].field.trim();
2463
- if (data[key] && data[key].toString().trim().toLowerCase().includes(keyword.trim().toLowerCase())) {
2464
- return true;
2301
+ };
2302
+ const elementChange = (field2) => {
2303
+ if (onChangeField) {
2304
+ onChangeField(rowData, field2, setValue, getValues);
2305
+ const rs = getValues();
2306
+ if (rs) {
2307
+ onChange(rs);
2465
2308
  }
2466
2309
  }
2467
- if (data[fieldChildren ?? "children"]) {
2468
- return data[fieldChildren ?? "children"].some((child) => checkSearch(keyword, child, columnsSearch));
2469
- }
2470
- return false;
2471
- };
2472
- const checkOverflow = (indexRow, indexCol) => {
2473
- const element = document.getElementById(`select-${id}-${indexRow}-${indexCol}`);
2474
- return element && element.scrollWidth > element.clientWidth;
2475
2310
  };
2476
- const getSelectAll = (tree, checkValue = false) => {
2477
- const selects = [];
2478
- const traverse = (items) => {
2479
- items.forEach((item) => {
2480
- if (item[fieldValue ?? "value"] && !(checkValue && value?.includes(item[fieldValue ?? "value"]))) {
2481
- selects.push(item[fieldValue ?? "value"]);
2482
- }
2483
- if (item[fieldChildren ?? "children"] && item[fieldChildren ?? "children"].length > 0) {
2484
- traverse(item[fieldChildren ?? "children"]);
2485
- }
2486
- });
2487
- };
2488
- traverse(tree);
2489
- return selects;
2311
+ const renderForm = (rows) => {
2312
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap9.Row, { className: "gy-25", children: rows.map((item, index) => {
2313
+ if (item.type === "numeric") {
2314
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap9.Col, { xl: 12, onKeyDown: (e) => formItemKeyDown(e, index), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2315
+ input_number_default,
2316
+ {
2317
+ id: `form-element-${field}-${index}`,
2318
+ control,
2319
+ name: item.name,
2320
+ label: item.label ? item.label : "",
2321
+ labelSize: `text-left ${labelSize}`,
2322
+ errors: errors[item.name],
2323
+ disabled: item.disabled,
2324
+ min: item.min,
2325
+ max: item.max,
2326
+ fractionCurrency: item.fraction,
2327
+ callback: () => {
2328
+ elementChange(item.name);
2329
+ }
2330
+ },
2331
+ index
2332
+ ) }, index);
2333
+ } else if (item.type === "text") {
2334
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap9.Col, { xl: 12, onKeyDown: (e) => formItemKeyDown(e, index), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2335
+ input_text_default,
2336
+ {
2337
+ id: `form-element-${field}-${index}`,
2338
+ control,
2339
+ name: item.name,
2340
+ label: item.label ? item.label : "",
2341
+ labelSize: `text-left ${labelSize}`,
2342
+ errors: errors[item.name],
2343
+ disabled: item.disabled,
2344
+ callback: () => {
2345
+ elementChange(item.name);
2346
+ }
2347
+ },
2348
+ index
2349
+ ) }, index);
2350
+ } else if (item.type === "select") {
2351
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap9.Col, { xl: 12, onKeyDown: (e) => formItemKeyDown(e, index), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2352
+ select_table_default,
2353
+ {
2354
+ id: `form-element-${field}-${index}`,
2355
+ defaultOptions: item.options ?? [],
2356
+ control,
2357
+ name: item.name,
2358
+ label: item.label ? item.label : "",
2359
+ labelSize: `text-left ${labelSize}`,
2360
+ errors: errors[item.name],
2361
+ disabled: item.disabled,
2362
+ callback: () => {
2363
+ elementChange(item.name);
2364
+ }
2365
+ },
2366
+ index
2367
+ ) }, index);
2368
+ }
2369
+ }) });
2490
2370
  };
2491
- const RenderElement = import_react15.default.memo((props2) => {
2492
- const { indexRow, row, isSelected, level = 0 } = props2;
2493
- const [expanded, setExpanded] = (0, import_react15.useState)(row.expanded);
2494
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
2495
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2496
- "tr",
2371
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2372
+ "div",
2373
+ {
2374
+ className: "form-edit",
2375
+ ref,
2376
+ id,
2377
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ref: editFormRef, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2378
+ import_reactstrap9.Dropdown,
2497
2379
  {
2498
- id: `row-select-table-${indexRow}`,
2499
- className: (0, import_classnames13.default)("r-select-row", { "fisrt-row": indexRow === 0 && level === 0 }),
2380
+ isOpen: dropdownOpen,
2381
+ toggle: () => {
2382
+ },
2500
2383
  children: [
2501
- isMulti && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2502
- "td",
2384
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_reactstrap9.DropdownToggle, { tag: "div", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2385
+ import_reactstrap9.Input,
2386
+ {
2387
+ style: { backgroundColor: "#FFF", textAlign: textAlign ?? "left" },
2388
+ placeholder,
2389
+ innerRef: inputRef,
2390
+ className: (0, import_classnames10.default)("input-display input-numeric", { "is-invalid": invalid }),
2391
+ value: displayValue,
2392
+ onClick: handleOnClick,
2393
+ onKeyDown: (e) => handleOnKeyDown(e),
2394
+ onPaste: (e) => onPaste && onPaste(e),
2395
+ readOnly: true
2396
+ }
2397
+ ) }),
2398
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2399
+ import_reactstrap9.DropdownMenu,
2503
2400
  {
2504
- className: (0, import_classnames13.default)(`r-select-rowcell`, { "r-select-active": !isMulti && value && isSelected }),
2401
+ className: "formula-dropdown icon-dropdown p-0",
2505
2402
  style: {
2506
- textAlign: "center",
2507
- paddingLeft: level * 15 + (row[fieldChildren ?? "children"]?.length > 0 ? 0 : 10)
2508
- },
2509
- onClick: (e) => {
2510
- if (isMulti) {
2511
- const index = value?.findIndex((x) => x === row[fieldValue ?? "value"]);
2512
- if (index > -1) {
2513
- if (!selectChilds) {
2514
- value?.splice(index, 1);
2515
- } else {
2516
- value?.splice(index, 1);
2517
- getSelectAll(row[fieldChildren ?? "children"]).forEach((x) => {
2518
- const index2 = value?.findIndex((y) => y === x);
2519
- if (index2 > -1) {
2520
- value?.splice(index2, 1);
2521
- }
2522
- });
2523
- }
2524
- onChange([...value]);
2525
- } else {
2526
- if (value) {
2527
- if (!selectChilds) {
2528
- onChange([...value, row[fieldValue ?? "value"]]);
2529
- } else {
2530
- onChange([...value, row[fieldValue ?? "value"], ...getSelectAll(row[fieldChildren ?? "children"], true)]);
2531
- }
2532
- } else {
2533
- onChange([row[fieldValue ?? "value"]]);
2534
- }
2535
- }
2536
- e.stopPropagation();
2537
- }
2403
+ minWidth: minWidth ? minWidth : defaultWidth,
2404
+ width: menuWidth ? menuWidth : "min-content",
2405
+ maxWidth: innerWidth > 1280 ? 1280 : innerWidth,
2406
+ borderRadius: 8,
2407
+ zIndex: 1056
2538
2408
  },
2539
- children: [
2540
- row[fieldChildren ?? "children"]?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2541
- import_becoxy_icons6.ChevronRight,
2409
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_reactstrap9.DropdownItem, { className: "p-0", style: { borderRadius: "6px" }, tag: "div", header: true, children: [
2410
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2411
+ "div",
2542
2412
  {
2543
- onClick: (e) => {
2544
- if (expanded) {
2545
- row.expanded = false;
2546
- setExpanded(false);
2547
- } else {
2548
- row.expanded = true;
2549
- setExpanded(true);
2550
- }
2551
- e.stopPropagation();
2413
+ onKeyDown: (e) => formKeyDown(e, handleSubmit(handleOnSubmit)),
2414
+ className: "p-1",
2415
+ style: {
2416
+ maxHeight: menuHeight ? menuHeight : 300,
2417
+ overflow: "auto"
2552
2418
  },
2553
- fontSize: 18,
2554
- className: (0, import_classnames13.default)("me-50 pb-0 r-icon-expand", { "is-open": expanded })
2419
+ children: itemsField ? renderForm(itemsField) : ""
2555
2420
  }
2556
2421
  ),
2557
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2558
- import_reactstrap10.Input,
2559
- {
2560
- checked: isSelected,
2561
- type: "checkbox",
2562
- className: "cursor-pointer",
2563
- onChange: () => {
2564
- }
2565
- }
2566
- )
2567
- ]
2568
- }
2569
- ),
2570
- (columns ? columns : defaultColumns).map((col, indexCol) => {
2571
- let valueDisplay = row[col.field];
2572
- if (col.type === "numeric" || col.typeCondition && col.typeCondition(row) === "numeric") {
2573
- valueDisplay = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ".", formatSetting?.thousandSeparator ?? ",", col.fraction ?? 0, true) ?? 0;
2574
- } else if (col.type === "date") {
2575
- valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat) : "";
2576
- } else if (col.type === "datetime") {
2577
- valueDisplay = valueDisplay ? formatDateTime(valueDisplay, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
2578
- }
2579
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react15.Fragment, { children: [
2580
- col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2581
- "td",
2582
- {
2583
- id: `select-${id}-${indexRow}-${indexCol}`,
2584
- className: (0, import_classnames13.default)(`r-select-rowcell`, { "r-select-active": !isMulti && value && isSelected }),
2585
- style: {
2586
- paddingLeft: 9 + (indexCol === 0 && !isMulti ? level * 10 + (row[fieldChildren ?? "children"]?.length > 0 || level === 0 ? 0 : 15) : 0),
2587
- textAlign: col.textAlign ? col.textAlign : "left"
2588
- },
2589
- onClick: (e) => {
2590
- if (isMulti) {
2591
- const index = value?.findIndex((x) => x === row[fieldValue ?? "value"]);
2592
- if (index > -1) {
2593
- if (!selectChilds) {
2594
- value?.splice(index, 1);
2595
- } else {
2596
- value?.splice(index, 1);
2597
- getSelectAll(row[fieldChildren ?? "children"]).forEach((x) => {
2598
- const index2 = value?.findIndex((y) => y === x);
2599
- if (index2 > -1) {
2600
- value?.splice(index2, 1);
2422
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "d-flex justify-content-between p-50", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: [
2423
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-primary py-25", style: { fontSize: 12 }, children: footerTemplate ? footerTemplate(rowData) : "" }),
2424
+ !onChangeField ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "d-flex justify-content-end", children: [
2425
+ isClearable && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2426
+ import_reactstrap9.Button,
2427
+ {
2428
+ ref: buttonRef,
2429
+ className: "btn me-50 py-25 px-50",
2430
+ outline: true,
2431
+ onClick: () => {
2432
+ itemsField.forEach((e) => {
2433
+ if (e.type === "numeric") {
2434
+ setValue(e.name, 0);
2435
+ } else {
2436
+ setValue(e.name, "");
2601
2437
  }
2602
2438
  });
2603
- }
2604
- onChange([...value]);
2605
- } else {
2606
- if (value) {
2607
- if (!selectChilds) {
2608
- onChange([...value, row[fieldValue ?? "value"]]);
2609
- } else {
2610
- onChange([...value, row[fieldValue ?? "value"], ...getSelectAll(row[fieldChildren ?? "children"], true)]);
2439
+ },
2440
+ onKeyDown: (e) => {
2441
+ if (e.code === "Tab") {
2442
+ closeMenu();
2611
2443
  }
2612
- } else {
2613
- onChange([row[fieldValue ?? "value"]]);
2614
- }
2444
+ },
2445
+ children: t("Clear")
2615
2446
  }
2616
- e.stopPropagation();
2617
- } else {
2618
- onChange(row);
2619
- setSearchTerm("");
2620
- closeMenu();
2621
- }
2622
- e.preventDefault();
2623
- e.stopPropagation();
2624
- },
2625
- children: [
2626
- !isMulti && indexCol === 0 && row[fieldChildren ?? "children"]?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2627
- import_becoxy_icons6.ChevronRight,
2447
+ ),
2448
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2449
+ import_reactstrap9.Button,
2628
2450
  {
2629
- onClick: (e) => {
2630
- if (expanded) {
2631
- row.expanded = false;
2632
- setExpanded(false);
2633
- } else {
2634
- row.expanded = true;
2635
- setExpanded(true);
2451
+ ref: buttonRef,
2452
+ color: "primary",
2453
+ className: "btn btn-primary py-25 px-50",
2454
+ onClick: handleSubmit(handleOnSubmit),
2455
+ onKeyDown: (e) => {
2456
+ if (e.code === "Tab") {
2457
+ closeMenu();
2636
2458
  }
2637
- e.stopPropagation();
2638
2459
  },
2639
- fontSize: 18,
2640
- className: (0, import_classnames13.default)("me-50 r-icon-expand", { "is-open": expanded })
2460
+ children: t("Save")
2641
2461
  }
2642
- ),
2643
- col.template ? col.template(row, indexRow) : col.type === "numeric" && Number(row[col.field]) < 0 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [
2644
- " ",
2645
- `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`
2646
- ] }) : valueDisplay
2647
- ]
2648
- },
2649
- `col-${indexRow}-${indexCol}`
2650
- ),
2651
- checkOverflow(indexRow, indexCol) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_reactstrap10.UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `select-${id}-${indexRow}-${indexCol}`, children: col.template ? col.template(row, indexRow) : col.type === "numeric" && Number(row[col.field]) < 0 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { color: formatSetting?.colorNegative ?? "red" }, children: [
2652
- " ",
2653
- `${formatSetting?.prefixNegative ?? "-"}${value}${formatSetting?.suffixNegative ?? ""}`
2654
- ] }) : valueDisplay })
2655
- ] }, indexCol);
2656
- })
2462
+ )
2463
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, {})
2464
+ ] })
2465
+ ] })
2466
+ }
2467
+ )
2657
2468
  ]
2658
- },
2659
- `row-${indexRow}`
2660
- ),
2661
- row[fieldChildren ?? "children"] && row.expanded && row[fieldChildren ?? "children"].map((child, indexChild) => {
2662
- if (checkSearch(searchTerm, child, columns ? columns : defaultColumns)) {
2663
- const isSelectedChild = value && (isMulti ? value?.some((x) => x === child[fieldValue ?? "value"]) : value[fieldValue ?? "value"] === child[fieldValue ?? "value"]);
2664
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RenderElement, { isSelected: isSelectedChild, indexRow: indexChild, row: child, level: level + 1 }, `select-table-${indexRow}-${indexChild}`);
2665
2469
  }
2666
- })
2667
- ] });
2668
- });
2669
- const RenderTable = (props2) => {
2670
- const {} = props2;
2671
- let countDisplay = 0;
2672
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
2673
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("table", { style: { width: "100%" }, children: [
2674
- !(noHeader && (columns?.length ?? 0) > 0) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("thead", { className: "r-select-gridheader", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("tr", { className: "r-select-row", role: "row", children: [
2675
- isMulti && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2676
- "th",
2677
- {
2678
- className: (0, import_classnames13.default)(`r-select-headercell checkbox-column`),
2679
- style: { width: 40, minWidth: 40, maxWidth: 100, top: `0px` },
2680
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2470
+ ) })
2471
+ }
2472
+ );
2473
+ });
2474
+ var edit_form_default = EditForm;
2475
+
2476
+ // src/component/sidebar-setting-column/index.tsx
2477
+ var import_react15 = require("react");
2478
+ var import_reactstrap10 = require("reactstrap");
2479
+ var import_react_i18next11 = require("react-i18next");
2480
+
2481
+ // src/component/modal-header/index.tsx
2482
+ var import_becoxy_icons5 = require("becoxy-icons");
2483
+ var import_classnames11 = __toESM(require("classnames"));
2484
+ var import_react_i18next10 = require("react-i18next");
2485
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2486
+ var ModalHeader = (props) => {
2487
+ const { title, handleModal, typeModal = "Edit", component } = props;
2488
+ const { t } = (0, import_react_i18next10.useTranslation)();
2489
+ const handleModalIcon = () => {
2490
+ if (typeModal === "Edit" || typeModal === "Approval") {
2491
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_becoxy_icons5.Edit, { fontSize: 17, className: "me-1" });
2492
+ } else if (typeModal === "View") {
2493
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_becoxy_icons5.Info, { fontSize: 17, className: "me-1" });
2494
+ } else if (typeModal === "Detail") {
2495
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_becoxy_icons5.Info, { fontSize: 17, className: "me-1" });
2496
+ } else if (typeModal === "Order") {
2497
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "e-icons e-sorting-1 me-1", style: { fontSize: "14px" } });
2498
+ } else if (typeModal === "Process") {
2499
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "e-flat e-icons e-paste-match-destination me-1", style: { fontSize: "14px" } });
2500
+ } else {
2501
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_becoxy_icons5.Plus, { fontSize: 17, className: "me-1" });
2502
+ }
2503
+ };
2504
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "modal-header d-flex align-items-center justify-content-between mb-1", children: [
2505
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "d-flex align-items-center justify-content-start", children: [
2506
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("h5", { className: "modal-title", children: [
2507
+ handleModalIcon(),
2508
+ " ",
2509
+ t(title)
2510
+ ] }),
2511
+ component ? component() : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, {})
2512
+ ] }),
2513
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "todo-item-action d-flex align-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2514
+ import_becoxy_icons5.X,
2515
+ {
2516
+ className: (0, import_classnames11.default)("fw-normal mt-25 cursor-pointer", { "d-none": !handleModal }),
2517
+ fontSize: 20,
2518
+ onClick: handleModal
2519
+ }
2520
+ ) })
2521
+ ] });
2522
+ };
2523
+ var modal_header_default = ModalHeader;
2524
+
2525
+ // src/component/sidebar/index.tsx
2526
+ var import_becoxy_icons6 = require("becoxy-icons");
2527
+ var import_classnames12 = __toESM(require("classnames"));
2528
+ var import_react14 = require("react");
2529
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2530
+ var Sidebar = (props) => {
2531
+ const {
2532
+ open,
2533
+ children,
2534
+ toggleSidebar,
2535
+ width,
2536
+ keyboard,
2537
+ hiddenBackground,
2538
+ hiddenFullScreenButton
2539
+ } = props;
2540
+ const [isFullScreen, setIsFullScreen] = (0, import_react14.useState)(false);
2541
+ const [flag, setFlag] = (0, import_react14.useState)(open);
2542
+ (0, import_react14.useEffect)(() => {
2543
+ if (open !== flag) {
2544
+ if (open) {
2545
+ setFlag(open);
2546
+ } else {
2547
+ setTimeout(() => {
2548
+ setFlag(open);
2549
+ }, 50);
2550
+ }
2551
+ }
2552
+ }, [open]);
2553
+ const handClose = () => {
2554
+ setFlag(false);
2555
+ setTimeout(() => {
2556
+ toggleSidebar();
2557
+ }, 400);
2558
+ };
2559
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2560
+ "div",
2561
+ {
2562
+ tabIndex: 0,
2563
+ className: (0, import_classnames12.default)({ "d-none": !open }),
2564
+ onKeyDown: (e) => {
2565
+ if (!keyboard && e.code === "Escape" && flag) {
2566
+ handClose();
2567
+ e.stopPropagation();
2568
+ e.preventDefault();
2569
+ }
2570
+ },
2571
+ children: [
2572
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2573
+ "div",
2574
+ {
2575
+ className: (0, import_classnames12.default)("offcanvas-backdrop fade", {
2576
+ "d-none": !flag || hiddenBackground,
2577
+ show: flag
2578
+ }),
2579
+ style: { zIndex: 1056 },
2580
+ onClick: handClose
2581
+ }
2582
+ ),
2583
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2584
+ "div",
2585
+ {
2586
+ className: (0, import_classnames12.default)("r-sidebar", `customizer-${width ?? 600}`, {
2587
+ open: flag,
2588
+ fullscreen: isFullScreen
2589
+ }),
2590
+ style: { zIndex: 1057 },
2591
+ children: [
2592
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2681
2593
  "div",
2682
2594
  {
2683
- style: { justifyContent: "center" },
2684
- className: (0, import_classnames13.default)("r-select-headercell-div"),
2685
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2686
- import_reactstrap10.Input,
2687
- {
2688
- checked: isSelectedAll,
2689
- type: "checkbox",
2690
- onClick: (e) => {
2691
- if (isMulti) {
2692
- if (isSelectedAll) {
2693
- onChange([]);
2694
- } else {
2695
- onChange(getSelectAll(options));
2696
- }
2697
- e.stopPropagation();
2698
- }
2699
- },
2700
- readOnly: true,
2701
- className: (0, import_classnames13.default)("cursor-pointer", { "d-none": !isMulti }),
2702
- style: { textAlign: "center", marginTop: 6 }
2703
- }
2704
- )
2595
+ style: {
2596
+ position: "fixed",
2597
+ top: "50%",
2598
+ transform: "translate(-50%, -50%)",
2599
+ background: "#FFF",
2600
+ filter: "drop-shadow(0.9px 0.9px 1.5px)",
2601
+ height: 50,
2602
+ display: "flex",
2603
+ alignItems: "center",
2604
+ borderRadius: "0px 5px 5px 0px",
2605
+ cursor: "pointer",
2606
+ zIndex: 9,
2607
+ marginLeft: 7
2608
+ },
2609
+ className: (0, import_classnames12.default)({ "d-none": hiddenFullScreenButton }),
2610
+ onClick: () => {
2611
+ setIsFullScreen(!isFullScreen);
2612
+ },
2613
+ children: [
2614
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_becoxy_icons6.ChevronLeft, { className: `${isFullScreen ? "d-none" : ""}`, fontSize: 16 }),
2615
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_becoxy_icons6.ChevronRight, { className: `${!isFullScreen ? "d-none" : ""}`, fontSize: 15 })
2616
+ ]
2705
2617
  }
2706
- )
2707
- }
2708
- ),
2709
- (columns ? columns : defaultColumns).map((col, index) => {
2710
- return renderHeaderCol(col, index);
2711
- })
2712
- ] }) }),
2713
- options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tbody", { className: "r-select-gridcontent", children: options?.map((row, indexRow) => {
2714
- if (checkSearch(searchTerm, row, columns ? columns : defaultColumns)) {
2715
- const isSelected = value && (isMulti ? value?.some((x) => x === row[fieldValue ?? "value"]) : value[fieldValue ?? "value"] === row[fieldValue ?? "value"]);
2716
- countDisplay++;
2717
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RenderElement, { isSelected, indexRow, row }, `select-table-${indexRow}`);
2618
+ ),
2619
+ children
2620
+ ]
2718
2621
  }
2719
- }) }) })
2720
- ] }),
2721
- countDisplay === 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "r-no-data", children: [
2722
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [
2723
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("ellipse", { fill: "#f5f5f5", cx: "32", cy: "33", rx: "32", ry: "7" }),
2724
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { fillRule: "nonzero", stroke: "#d9d9d9", children: [
2725
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" }),
2726
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z", fill: "#fafafa" })
2727
- ] })
2728
- ] }) }),
2729
- t("No data available.")
2730
- ] })
2622
+ )
2623
+ ]
2624
+ }
2625
+ );
2626
+ };
2627
+ var sidebar_default = Sidebar;
2628
+
2629
+ // src/component/sidebar-setting-column/index.tsx
2630
+ var import_classnames13 = __toESM(require("classnames"));
2631
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2632
+ var SidebarSetColumn = (props) => {
2633
+ const { column, setColumn, openSidebar, handleSidebar } = props;
2634
+ const { t } = (0, import_react_i18next11.useTranslation)();
2635
+ const [dataSource, setDataSource] = (0, import_react15.useState)([]);
2636
+ const [indexFocus, setIndexFocus] = (0, import_react15.useState)();
2637
+ (0, import_react15.useEffect)(() => {
2638
+ if (openSidebar) {
2639
+ setDataSource(column.map((e) => ({ ...e })));
2640
+ }
2641
+ }, [openSidebar]);
2642
+ const handleCancel = () => {
2643
+ handleSidebar();
2644
+ setDataSource([]);
2645
+ };
2646
+ const handleSubmit = () => {
2647
+ setColumn([...dataSource]);
2648
+ handleCancel();
2649
+ };
2650
+ const getWindowSize = () => {
2651
+ const { innerWidth, innerHeight } = window;
2652
+ return { innerWidth, innerHeight };
2653
+ };
2654
+ const [windowSize, setWindowSize] = (0, import_react15.useState)(getWindowSize());
2655
+ (0, import_react15.useEffect)(() => {
2656
+ const handleWindowResize = () => {
2657
+ setWindowSize(getWindowSize());
2658
+ };
2659
+ window.addEventListener("resize", handleWindowResize);
2660
+ return () => {
2661
+ window.removeEventListener("resize", handleWindowResize);
2662
+ };
2663
+ }, []);
2664
+ const renderFooterButtons = () => {
2665
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react15.Fragment, { children: [
2666
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_reactstrap10.Button, { color: "primary", onClick: handleSubmit, className: "me-1", children: t("Confirm") }),
2667
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_reactstrap10.Button, { color: "secondary", onClick: handleCancel, outline: true, children: t("Close") })
2731
2668
  ] });
2732
2669
  };
2733
- const getSelectedRecords = (tree, value2) => {
2734
- const records = [];
2735
- const traverse = (nodes) => {
2736
- nodes.forEach((node) => {
2737
- if (value2.includes(node[fieldValue ?? "value"])) {
2738
- records.push(node);
2670
+ const visibleTemplate = (item, index) => {
2671
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2672
+ import_reactstrap10.Input,
2673
+ {
2674
+ defaultChecked: item.visible ?? true,
2675
+ disabled: item.invisibleDisable,
2676
+ type: "checkbox",
2677
+ style: { height: 18 },
2678
+ className: " cursor-pointer",
2679
+ onChange: (e) => {
2680
+ if (dataSource) {
2681
+ dataSource[index].visible = e.target.checked;
2682
+ setDataSource(dataSource);
2683
+ }
2739
2684
  }
2740
- if (node.children && node.children.length > 0) {
2741
- traverse(node.children);
2685
+ }
2686
+ );
2687
+ };
2688
+ const fixColumnTemplate = (item, index) => {
2689
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2690
+ import_reactstrap10.Input,
2691
+ {
2692
+ defaultChecked: item.fixedType === "left" || item.fixedType === "right",
2693
+ type: "checkbox",
2694
+ style: { height: 18 },
2695
+ className: " cursor-pointer",
2696
+ onChange: (e) => {
2697
+ if (dataSource) {
2698
+ if (e.target.checked) {
2699
+ if (index * 2 <= dataSource.length) {
2700
+ dataSource[index].fixedType = "left";
2701
+ } else {
2702
+ dataSource[index].fixedType = "right";
2703
+ }
2704
+ } else {
2705
+ dataSource[index].fixedType = void 0;
2706
+ }
2707
+ setDataSource(dataSource);
2708
+ }
2742
2709
  }
2743
- });
2744
- };
2745
- traverse(tree);
2746
- return records;
2710
+ }
2711
+ );
2747
2712
  };
2748
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2749
- "div",
2713
+ const columns = [
2750
2714
  {
2751
- className: (0, import_classnames13.default)("react-select-table", { "is-invalid": invalid }),
2752
- ref,
2753
- id,
2754
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { ref: selectTableRef, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2755
- import_reactstrap10.Dropdown,
2756
- {
2757
- isOpen: dropdownOpen,
2758
- toggle: () => {
2759
- },
2760
- onMouseDown: (e) => e.preventDefault(),
2761
- children: [
2762
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2763
- import_reactstrap10.DropdownToggle,
2764
- {
2765
- onClick: (e) => {
2766
- if (!isDisabled) {
2767
- inputRef?.current.focus();
2768
- handleOpenClose();
2769
- }
2770
- e.preventDefault();
2771
- },
2772
- tag: "div",
2773
- style: { width: "100%" },
2774
- className: (0, import_classnames13.default)("select-table-control", { "r-select-is-disabled": isDisabled }, { "r-select-is-open": dropdownOpen }, { "r-select-is-focus": isFocus }, { "r-select-is-invalid": invalid }),
2775
- children: [
2776
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "select-table-container", children: [
2777
- isMulti ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: (0, import_classnames13.default)("select-value is-mutil", { "d-none": searchTerm }), children: getSelectedRecords(options, value).map((ele, index) => {
2778
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
2779
- index === 0 ? "" : ", ",
2780
- ele[fieldLabel ?? "label"]
2781
- ] }, index);
2782
- }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: (0, import_classnames13.default)("select-value", { "d-none": searchTerm }), children: [
2783
- value ? formatOptionLabel ? formatOptionLabel(value) : value[fieldLabel ?? "label"] : "",
2784
- " "
2785
- ] }) }),
2786
- !((isMulti ? value?.length > 0 : value) || isDisabled || searchTerm) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: (0, import_classnames13.default)("select-placeholder"), children: placeholder }),
2787
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "input-container", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2788
- "input",
2789
- {
2790
- style: { textAlign: textAlign ?? "left" },
2791
- ref: inputRef,
2792
- className: (0, import_classnames13.default)("select-input"),
2793
- readOnly: isDisabled,
2794
- value: searchTerm,
2795
- onPaste: (e) => onPaste && !dropdownOpen && onPaste(e),
2796
- onChange: (val) => {
2797
- setSearchTerm(val.target.value);
2798
- },
2799
- onKeyDown: (e) => handleOnKeyDown(e)
2800
- }
2801
- ) })
2802
- ] }),
2803
- isClearable && value && !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2804
- "div",
2805
- {
2806
- className: (0, import_classnames13.default)("cursor-pointer"),
2807
- onClick: (e) => {
2808
- onChange(isMulti ? [] : void 0);
2809
- e.stopPropagation();
2810
- },
2811
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("svg", { height: "20", width: "20", color: "#c4c4c4", viewBox: "0 0 20 20", "aria-hidden": "true", focusable: "false", className: "css-tj5bde-Svg", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z" }) })
2812
- }
2813
- ),
2814
- !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "select-table-indicator", onMouseDown: (e) => e.preventDefault(), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("svg", { height: "20", width: "20", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" }) }) })
2815
- ]
2816
- }
2715
+ field: "headerText",
2716
+ headerText: "Column name",
2717
+ template: (e) => {
2718
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: t(e.headerText) });
2719
+ },
2720
+ visible: true,
2721
+ width: 175,
2722
+ maxWidth: 200,
2723
+ minWidth: 150
2724
+ },
2725
+ {
2726
+ field: "",
2727
+ template: visibleTemplate,
2728
+ headerText: "Display",
2729
+ textAlign: "center",
2730
+ visible: true,
2731
+ width: 100,
2732
+ maxWidth: 120,
2733
+ minWidth: 80
2734
+ },
2735
+ {
2736
+ field: "",
2737
+ template: fixColumnTemplate,
2738
+ headerText: "Fix the column",
2739
+ textAlign: "center",
2740
+ visible: true,
2741
+ width: 100,
2742
+ maxWidth: 120,
2743
+ minWidth: 80
2744
+ },
2745
+ {
2746
+ field: "width",
2747
+ headerText: "Column width",
2748
+ textAlign: "right",
2749
+ visible: true,
2750
+ width: 100,
2751
+ maxWidth: 120,
2752
+ minWidth: 80
2753
+ }
2754
+ ];
2755
+ const renderHeaderCol = (col, indexCol) => {
2756
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2757
+ import_react15.Fragment,
2758
+ {
2759
+ children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2760
+ "th",
2761
+ {
2762
+ className: (0, import_classnames13.default)(
2763
+ `r-headercell fix-${col.fixedType}`,
2764
+ { "cell-fixed": col.fixedType }
2817
2765
  ),
2818
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2819
- import_reactstrap10.DropdownMenu,
2766
+ style: {
2767
+ width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2768
+ minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
2769
+ top: `${0 * 42}px`,
2770
+ maxWidth: col.maxWidth
2771
+ },
2772
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2773
+ "div",
2820
2774
  {
2821
- container: component,
2822
- className: "formula-dropdown icon-dropdown p-0",
2775
+ role: "textbox",
2776
+ title: t(col.headerText ?? ""),
2823
2777
  style: {
2824
- width: width ? width + 2 : "min-content",
2825
- position: "fixed",
2826
- borderRadius: 4,
2827
- zIndex: 9999
2778
+ height: `${1 * 42}px`,
2779
+ justifyContent: col.textAlign ?? "left"
2828
2780
  },
2829
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_reactstrap10.DropdownItem, { className: (0, import_classnames13.default)("p-0 menu-select-table"), style: { borderRadius: "6px" }, tag: "div", header: true, children: dropdownOpen && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2830
- "div",
2831
- {
2832
- onMouseDown: (e) => {
2833
- if (!isDisabled) {
2834
- inputRef?.current.focus();
2835
- e.preventDefault();
2836
- }
2837
- },
2838
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "r-select-grid r-select-tree-grid", children: [
2839
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "r-select-gridtable ", ref: selectMenuTableRef, style: { width: menuWidth, minWidth: selectTableRef?.current?.clientWidth, maxHeight: maxHeight ?? defaultMaxHeight2 }, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RenderTable, {}) }),
2840
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: (0, import_classnames13.default)("r-select-footer", { "d-none": !(showFooter === true || handleAdd || isMulti) }), children: [
2841
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_reactstrap10.Button, { outline: true, color: "primary", onClick: handleAdd, className: (0, import_classnames13.default)("r-btn d-flex align-items-center", { "d-none": !handleAdd }), children: [
2842
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_becoxy_icons6.Plus, { className: "me-50", fontSize: 16 }),
2843
- t("AddNew"),
2844
- " (F9)"
2845
- ] }),
2846
- isMulti && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "ms-50 text-primary h-100 d-flex align-items-center", onClick: handleAdd, children: t("countSelected", { item: value?.length ?? 0 }) }),
2847
- footerComponent ? footerComponent() : null
2848
- ] })
2849
- ] })
2850
- }
2851
- ) })
2781
+ className: "r-headercell-div",
2782
+ children: t(col.headerText ?? "")
2852
2783
  }
2853
2784
  )
2854
- ]
2855
- }
2856
- ) })
2785
+ }
2786
+ )
2787
+ },
2788
+ `header-${indexCol}`
2789
+ );
2790
+ };
2791
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
2792
+ sidebar_default,
2793
+ {
2794
+ open: openSidebar,
2795
+ toggleSidebar: handleCancel,
2796
+ width: 700,
2797
+ children: [
2798
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(modal_header_default, { typeModal: "Edit", handleModal: handleCancel, title: "Column setup" }),
2799
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "ms-2 react-table-edit", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-grid", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-gridtable", style: { height: windowSize.innerHeight - 120 }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("table", { style: { width: "100%" }, children: [
2800
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("thead", { className: "r-gridheader", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tr", { className: "r-row", role: "row", children: columns.map((col, index) => {
2801
+ return renderHeaderCol(col, index);
2802
+ }) }) }),
2803
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tbody", { className: "r-gridcontent", children: dataSource?.map((row, indexRow) => {
2804
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2805
+ "tr",
2806
+ {
2807
+ className: (0, import_classnames13.default)("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }),
2808
+ children: columns.map((col, indexCol) => {
2809
+ let value = row[col.field];
2810
+ if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
2811
+ value = formartNumberic(row[col.field], ",", ".", col.numericSettings?.fraction, true) ?? 0;
2812
+ }
2813
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react15.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2814
+ "td",
2815
+ {
2816
+ className: (0, import_classnames13.default)(
2817
+ `r-rowcell fix-${col.fixedType}`,
2818
+ { "cell-fixed": col.fixedType },
2819
+ { "r-active": indexFocus === indexRow }
2820
+ ),
2821
+ style: {
2822
+ padding: 0,
2823
+ textAlign: col.textAlign ? col.textAlign : "left"
2824
+ },
2825
+ onFocus: (e) => {
2826
+ if (indexRow !== indexFocus) {
2827
+ setIndexFocus(indexRow);
2828
+ }
2829
+ e.stopPropagation();
2830
+ },
2831
+ onClick: (e) => {
2832
+ if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
2833
+ if (indexRow !== indexFocus) {
2834
+ setIndexFocus(indexRow);
2835
+ }
2836
+ e.stopPropagation();
2837
+ }
2838
+ },
2839
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2840
+ "div",
2841
+ {
2842
+ className: (0, import_classnames13.default)("r-rowcell-div"),
2843
+ style: {
2844
+ width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : "auto"
2845
+ },
2846
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2847
+ "div",
2848
+ {
2849
+ className: (0, import_classnames13.default)("r-rowcell-content"),
2850
+ style: {
2851
+ margin: "7px 9px"
2852
+ },
2853
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-cell-text", children: col.template ? col.template(row, indexRow) : value })
2854
+ }
2855
+ )
2856
+ }
2857
+ )
2858
+ },
2859
+ `col-${indexRow}-${indexCol}`
2860
+ ) }, indexCol);
2861
+ })
2862
+ },
2863
+ `row-${indexRow}`
2864
+ );
2865
+ }) })
2866
+ ] }) }) }) }),
2867
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2868
+ "div",
2869
+ {
2870
+ className: "d-flex justify-content-end p-1 ",
2871
+ style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" },
2872
+ children: renderFooterButtons()
2873
+ }
2874
+ )
2875
+ ]
2857
2876
  }
2858
2877
  );
2859
- });
2860
-
2861
- // src/component/table/index.tsx
2862
- var import_react_number_format2 = require("react-number-format");
2863
-
2864
- // src/component/table/toolbar-top.tsx
2865
- var import_jsx_runtime16 = require("react/jsx-runtime");
2866
- var renderToolbarTop = (toolbarTopOption) => {
2867
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { id: "table_custom_top_toolbar", className: "r-toolbar r-toolbar-top", "aria-orientation": "horizontal", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "r-toolbar-items", children: [
2868
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-toolbar-left", children: toolbarTopOption?.map((item, index) => {
2869
- return item.align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-left-${index}`) }) : "";
2870
- }) }),
2871
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-toolbar-center", children: toolbarTopOption?.map((item, index) => {
2872
- return item.align === "center" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-center-${index}`) }) : "";
2873
- }) }),
2874
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-toolbar-right", children: toolbarTopOption?.map((item, index) => {
2875
- return item.align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-right-${index}`) }) : "";
2876
- }) })
2877
- ] }) });
2878
2878
  };
2879
- var toolbar_top_default = renderToolbarTop;
2879
+ var sidebar_setting_column_default = SidebarSetColumn;
2880
2880
 
2881
2881
  // src/component/input-date/index.tsx
2882
2882
  var import_react16 = require("react");
2883
2883
  var import_react_datepicker = __toESM(require("react-datepicker"));
2884
2884
  var import_react_input_mask = __toESM(require("react-input-mask"));
2885
2885
  var import_jsx_runtime17 = require("react/jsx-runtime");
2886
- var DateInput = (props) => {
2886
+ var DateInput = (0, import_react16.forwardRef)((props, ref) => {
2887
2887
  const { id, onKeyDown, dateFormat, className, onChange, value } = props;
2888
2888
  const [open, setOpen] = (0, import_react16.useState)(false);
2889
2889
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -2926,7 +2926,7 @@ var DateInput = (props) => {
2926
2926
  }
2927
2927
  }
2928
2928
  );
2929
- };
2929
+ });
2930
2930
  var input_date_default = DateInput;
2931
2931
 
2932
2932
  // src/component/table/index.tsx