@apexcura/ui-components 0.0.14-Beta20 → 0.0.14-Beta200

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.mjs CHANGED
@@ -13,6 +13,7 @@ var TextElement = (props) => {
13
13
  placeholder: props.placeholder,
14
14
  allowClear: true,
15
15
  id: props.name,
16
+ value: props.value,
16
17
  prefix: props.prefix,
17
18
  type: props.type,
18
19
  status: props.status,
@@ -72,8 +73,7 @@ var NumberElement = (props) => {
72
73
  {
73
74
  placeholder: props.placeholder,
74
75
  addonBefore: props.addonBefore,
75
- allowClear: true,
76
- defaultValue: props.defaultValue,
76
+ value: props.value,
77
77
  disabled: props.disabled,
78
78
  id: props.name,
79
79
  prefix: props.prefix,
@@ -321,11 +321,14 @@ var ButtonElement = (props) => {
321
321
  return /* @__PURE__ */ React11.createElement(
322
322
  "button",
323
323
  {
324
- onClick: () => props.onClick && props.onClick(),
325
- className: `${props.className ? props.className : ""}`
324
+ onClick: props.onClick,
325
+ className: `${props.className ? props.className : ""}`,
326
+ disabled: props.loading,
327
+ style: {
328
+ cursor: props.loading ? "no-drop" : "pointer"
329
+ }
326
330
  },
327
- props.icon && /* @__PURE__ */ React11.createElement("img", { className: props.iconsClassName, src: props.icon }),
328
- props.label
331
+ /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement("span", { className: props.iconsClassName }, /* @__PURE__ */ React11.createElement("img", { src: props.icon, className: "icon-active" })), props.label)
329
332
  );
330
333
  };
331
334
 
@@ -467,10 +470,19 @@ var Sidebar = (props) => {
467
470
  props.onChange(item);
468
471
  }
469
472
  };
470
- return /* @__PURE__ */ React13.createElement("div", { className: props.className, key: props.name }, /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement("img", { src: props.img, alt: "logo" })), /* @__PURE__ */ React13.createElement("ul", { className: props.listClassName }, props.items?.map((item) => {
471
- return /* @__PURE__ */ React13.createElement("li", { onClick: () => {
472
- handleChange(item);
473
- }, key: item.label, className: `${props.listItemClassName} ${item.active && props.activeClassName}` }, /* @__PURE__ */ React13.createElement("img", { src: item.icon, className: props.className }), /* @__PURE__ */ React13.createElement("p", null, item.label));
473
+ return /* @__PURE__ */ React13.createElement(React13.Fragment, { key: props.name }, /* @__PURE__ */ React13.createElement("div", { className: props.imgClassName }, /* @__PURE__ */ React13.createElement("img", { src: props.img, alt: "logo" })), /* @__PURE__ */ React13.createElement("div", { className: props.listClassName }, props.items?.map((item) => {
474
+ return /* @__PURE__ */ React13.createElement(React13.Fragment, { key: item.label }, /* @__PURE__ */ React13.createElement(
475
+ ButtonElement,
476
+ {
477
+ ...item,
478
+ className: item.active ? props.activeClassName : props.className,
479
+ iconsClassName: props.iconsClassName,
480
+ onClick: (e) => {
481
+ e.preventDefault();
482
+ handleChange(item);
483
+ }
484
+ }
485
+ ));
474
486
  })));
475
487
  };
476
488
 
@@ -535,7 +547,7 @@ var Navbar = (props) => {
535
547
  };
536
548
 
537
549
  // src/Components/TableElement.tsx
538
- import React20, { useState as useState5 } from "react";
550
+ import React20, { useState as useState5, useEffect as useEffect2 } from "react";
539
551
  import { Table as Table2 } from "antd";
540
552
 
541
553
  // src/Components/Model.tsx
@@ -544,18 +556,48 @@ import { Modal } from "antd";
544
556
 
545
557
  // src/Components/ModelBody.tsx
546
558
  import React18 from "react";
559
+ import moment from "moment";
547
560
  var ModelBody = (props) => {
548
- return /* @__PURE__ */ React18.createElement("div", { className: props.modalContent && props.modalContent.className }, props.modalContent && props.modalContent.fields.map((eachField) => {
549
- if (eachField.element === "div") {
550
- return /* @__PURE__ */ React18.createElement("div", { className: eachField.className }, eachField.label);
551
- } else if (eachField.element === "input-radio") {
552
- return /* @__PURE__ */ React18.createElement("div", { className: eachField.className }, /* @__PURE__ */ React18.createElement(RadioElement, { ...eachField }));
553
- } else if (eachField.element === "button") {
554
- return /* @__PURE__ */ React18.createElement("div", { className: eachField.className }, /* @__PURE__ */ React18.createElement(ButtonElement, { ...eachField }));
555
- } else {
556
- return null;
561
+ return /* @__PURE__ */ React18.createElement("div", { className: props.modalContent && props.modalContent.className }, props.modalContent && props.modalContent.fields.map(
562
+ (eachField) => {
563
+ if (eachField.element === "div") {
564
+ return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement("div", { className: eachField.className }, eachField.label), eachField.dateTime ? /* @__PURE__ */ React18.createElement(
565
+ "p",
566
+ {
567
+ style: {
568
+ fontSize: "10px",
569
+ textAlign: eachField.source === "bot" ? "left" : "right"
570
+ }
571
+ },
572
+ moment(eachField.dateTime).format("LT")
573
+ ) : "");
574
+ } else if (eachField.element === "input-radio") {
575
+ return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement("div", { className: eachField.className }, /* @__PURE__ */ React18.createElement(RadioElement, { ...eachField })), eachField.dateTime ? /* @__PURE__ */ React18.createElement(
576
+ "p",
577
+ {
578
+ style: {
579
+ fontSize: "10px",
580
+ textAlign: eachField.source === "bot" ? "left" : "right"
581
+ }
582
+ },
583
+ moment(eachField.dateTime).format("LT")
584
+ ) : "");
585
+ } else if (eachField.element === "button") {
586
+ return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement("div", { className: eachField.className }, /* @__PURE__ */ React18.createElement(ButtonElement, { ...eachField })), eachField.dateTime ? /* @__PURE__ */ React18.createElement(
587
+ "p",
588
+ {
589
+ style: {
590
+ fontSize: "10px",
591
+ textAlign: eachField.source === "bot" ? "left" : "right"
592
+ }
593
+ },
594
+ moment(eachField.dateTime).format("LT")
595
+ ) : "");
596
+ } else {
597
+ return null;
598
+ }
557
599
  }
558
- }));
600
+ ));
559
601
  };
560
602
 
561
603
  // src/Components/Model.tsx
@@ -580,9 +622,22 @@ var ModelElement = (props) => {
580
622
  margin: "-10px"
581
623
  }
582
624
  },
583
- Object.entries(selectedRecord).map(([key, value]) => {
584
- const record = columns.filter((eachColumn) => eachColumn.key === key);
585
- return record.length > 0 ? /* @__PURE__ */ React19.createElement("p", { style: { fontWeight: "500", padding: "10px" }, key }, /* @__PURE__ */ React19.createElement("span", { style: { fontWeight: "200", color: "gray", paddingRight: "10px" } }, record[0].title), String(value)) : "";
625
+ columns.map((eachColumn) => {
626
+ if (!["index", "View"].includes(eachColumn.key) && eachColumn?.["is_detail"] !== false) {
627
+ return /* @__PURE__ */ React19.createElement("p", { style: { fontWeight: "500", padding: "10px" } }, /* @__PURE__ */ React19.createElement(
628
+ "span",
629
+ {
630
+ style: {
631
+ fontWeight: "200",
632
+ color: "gray",
633
+ paddingRight: "10px"
634
+ }
635
+ },
636
+ eachColumn.title
637
+ ), selectedRecord[eachColumn.key] !== "" ? selectedRecord[eachColumn.key] : "--");
638
+ } else {
639
+ return null;
640
+ }
586
641
  })
587
642
  )
588
643
  },
@@ -591,13 +646,24 @@ var ModelElement = (props) => {
591
646
  };
592
647
 
593
648
  // src/Components/TableElement.tsx
649
+ import { EyeOutlined } from "@ant-design/icons";
594
650
  var TableElement = (props) => {
595
651
  const { thead, tbody } = props;
596
652
  const [selectedRecord, setSelectedRecord] = useState5({});
597
653
  const [model, setModel] = useState5(false);
598
- const [selectedRowKeys, setSelectedRowKeys] = useState5([]);
654
+ const [dataSource, setDataSource] = useState5([]);
655
+ useEffect2(() => {
656
+ if (tbody) {
657
+ setDataSource(
658
+ tbody.map((row, index) => ({
659
+ ...row,
660
+ key: index,
661
+ index: index + 1
662
+ }))
663
+ );
664
+ }
665
+ }, [tbody]);
599
666
  const handleChange = (record) => {
600
- console.log("record", record);
601
667
  if (props.onChange) {
602
668
  props.onChange(record);
603
669
  }
@@ -607,105 +673,151 @@ var TableElement = (props) => {
607
673
  columns = [
608
674
  {
609
675
  title: "#",
610
- dataIndex: "#",
611
- key: "#"
676
+ dataIndex: "index",
677
+ key: "index",
678
+ fixed: "left"
612
679
  },
613
680
  ...thead.map((col, ind) => ({
614
681
  title: col.label,
615
682
  dataIndex: col.name,
616
683
  key: col.key,
684
+ ellipsis: col.ellipsis,
617
685
  render: col.render,
618
686
  sorter: {
619
687
  compare: (a, b) => {
620
- if (typeof a[col.key] === "number" && typeof a[col.key] === "number") {
688
+ if (typeof a[col.key] === "number" && typeof b[col.key] === "number") {
621
689
  return a[col.key] - b[col.key];
622
- } else if (typeof a[col.key] === "string" && typeof a[col.key] === "string") {
690
+ } else if (typeof a[col.key] === "string" && typeof b[col.key] === "string") {
623
691
  return a[col.key].localeCompare(b[col.key]);
624
692
  }
625
693
  }
626
694
  }
627
- })),
628
- {
695
+ }))
696
+ ];
697
+ if (props.view) {
698
+ columns.push({
629
699
  title: "View",
630
700
  dataIndex: "View",
631
701
  key: "View",
632
- render: (_, record) => /* @__PURE__ */ React20.createElement(
633
- "a",
634
- {
635
- onClick: () => {
636
- setSelectedRecord(record);
637
- handleChange(record);
638
- setModel(true);
639
- }
640
- },
641
- "View"
642
- )
643
- }
644
- ];
702
+ render: (_, record) => {
703
+ return /* @__PURE__ */ React20.createElement(
704
+ "a",
705
+ {
706
+ onClick: () => {
707
+ if (props.view) {
708
+ setSelectedRecord(record);
709
+ handleChange(record);
710
+ setModel(true);
711
+ }
712
+ }
713
+ },
714
+ /* @__PURE__ */ React20.createElement(EyeOutlined, null)
715
+ );
716
+ }
717
+ });
718
+ }
645
719
  }
646
- const dataSource = tbody && tbody.map((row, index) => ({
647
- ...row,
648
- [columns[0].key]: index + 1
649
- }));
650
- const count = dataSource ? dataSource.length : 0;
720
+ const onChangeTable = (pagination, filters, sorter, extra) => {
721
+ if (extra && extra.currentDataSource) {
722
+ setDataSource(
723
+ extra.currentDataSource.map((row, index) => ({
724
+ ...row,
725
+ index: index + 1
726
+ }))
727
+ );
728
+ }
729
+ };
651
730
  const onChangePage = (page, pageSize) => {
652
731
  if (props.onChange) {
653
732
  props.onChange({ name: "pagination", page, pageSize });
654
733
  }
655
734
  };
656
- const onSelectChange = (newSelectedRowKeys) => {
657
- console.log("selectedRowKeys changed: ", newSelectedRowKeys);
658
- setSelectedRowKeys(newSelectedRowKeys);
659
- };
660
735
  const rowSelectionConfig = props.rowSelection ? {
661
- selectedRowKeys,
662
- onChange: onSelectChange
736
+ onChange: (selectedRowKeys, selectedRows) => {
737
+ console.log(
738
+ `selectedRowKeys: ${selectedRowKeys}`,
739
+ "selectedRows: ",
740
+ selectedRows
741
+ );
742
+ if (props.onChange) {
743
+ props.onChange(selectedRows);
744
+ }
745
+ }
663
746
  } : void 0;
664
747
  return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(
665
748
  Table2,
666
749
  {
667
- pagination: {
750
+ className: props.className,
751
+ pagination: props.pagination ? {
668
752
  showTotal: (total) => `Total: ${total} items`,
669
- total: count,
670
- showSizeChanger: count > 10,
753
+ total: props.count,
754
+ showSizeChanger: props.count ? props.count > 10 : 0 > 10,
671
755
  onChange: onChangePage
756
+ } : false,
757
+ onRow: (record) => {
758
+ return {
759
+ onClick: () => {
760
+ if (props.view) {
761
+ setSelectedRecord(record);
762
+ handleChange(record);
763
+ setModel(true);
764
+ }
765
+ },
766
+ style: { cursor: "pointer" }
767
+ };
672
768
  },
769
+ rowSelection: rowSelectionConfig,
673
770
  dataSource,
674
771
  columns,
772
+ size: props.size,
675
773
  bordered: true,
676
- rowSelection: rowSelectionConfig,
677
- size: props.size && props.size
774
+ onChange: onChangeTable
775
+ }
776
+ ), model && /* @__PURE__ */ React20.createElement(
777
+ ModelElement,
778
+ {
779
+ selectedRecord,
780
+ ...props,
781
+ columns,
782
+ model,
783
+ onCancel: () => setModel(false)
678
784
  }
679
- ), model && /* @__PURE__ */ React20.createElement(ModelElement, { selectedRecord, ...props, columns, model, onCancel: () => setModel(false) }));
785
+ ));
680
786
  };
681
787
 
682
788
  // src/Components/DatePicker.tsx
683
789
  import React21, { useState as useState6 } from "react";
684
790
  import { DatePicker } from "antd";
791
+ import dayjs from "dayjs";
792
+ import customParseFormat from "dayjs/plugin/customParseFormat.js";
793
+ import moment2 from "moment";
794
+ dayjs.extend(customParseFormat);
685
795
  var DatePickerElement = (props) => {
686
- const [date, setDate] = useState6(null);
687
- const dateFormat = "DD/MM/YYYY";
688
- const handleChange = (date2, dateString) => {
689
- console.log(dateString);
690
- if (date2) {
691
- const formattedDate = date2.format(dateFormat);
692
- setDate(date2);
796
+ const [dateState, setDateState] = useState6("");
797
+ const handleChange = (date, dateString) => {
798
+ if (date) {
799
+ const formattedDate = dateString;
800
+ setDateState(date);
693
801
  if (props.onChange) {
694
802
  props.onChange(formattedDate);
695
803
  }
696
804
  } else {
697
- setDate(null);
805
+ setDateState("");
698
806
  if (props.onChange) {
699
807
  props.onChange("");
700
808
  }
701
809
  }
702
810
  };
811
+ const disabledDate = (current) => {
812
+ return current && current > moment2();
813
+ };
703
814
  return /* @__PURE__ */ React21.createElement("div", null, /* @__PURE__ */ React21.createElement(
704
815
  DatePicker,
705
816
  {
817
+ disabledDate,
706
818
  placeholder: props.placeholder,
707
- value: date?.format(dateFormat),
708
- variant: "borderless",
819
+ value: dateState,
820
+ format: { format: "DD-MM-YYYY" },
709
821
  onChange: handleChange
710
822
  }
711
823
  ));
@@ -714,29 +826,42 @@ var DatePickerElement = (props) => {
714
826
  // src/Components/DateRangePickerElement.tsx
715
827
  import React22 from "react";
716
828
  import { DatePicker as DatePicker2, Space } from "antd";
717
- import dayjs from "dayjs";
829
+ import dayjs2 from "dayjs";
830
+ import moment3 from "moment";
718
831
  var DateRangePickerElement = (props) => {
832
+ const { value } = props;
719
833
  const { RangePicker } = DatePicker2;
720
834
  const handleChange = (dates, dateStrings) => {
721
- if (dates && props.onChange) {
722
- props.onChange(dateStrings);
835
+ if (dates) {
836
+ props.onChange && props.onChange(dateStrings);
723
837
  } else {
724
- console.log("Clear");
838
+ props.onChange && props.onChange("");
725
839
  }
726
840
  };
727
841
  const rangePresets = [
728
- { label: "Last 7 Days", value: [dayjs().add(-7, "d"), dayjs()] },
729
- { label: "Last 14 Days", value: [dayjs().add(-14, "d"), dayjs()] },
730
- { label: "Last 30 Days", value: [dayjs().add(-30, "d"), dayjs()] },
731
- { label: "Last 90 Days", value: [dayjs().add(-90, "d"), dayjs()] }
842
+ { label: "Last 7 Days", value: [dayjs2().add(-7, "d"), dayjs2()] },
843
+ { label: "Last 14 Days", value: [dayjs2().add(-14, "d"), dayjs2()] },
844
+ { label: "Last 30 Days", value: [dayjs2().add(-30, "d"), dayjs2()] },
845
+ { label: "Last 90 Days", value: [dayjs2().add(-90, "d"), dayjs2()] }
732
846
  ];
733
- return /* @__PURE__ */ React22.createElement(Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ React22.createElement(RangePicker, { presets: rangePresets, onChange: handleChange }));
847
+ const disabledDate = (current) => {
848
+ return current && current > moment3();
849
+ };
850
+ return /* @__PURE__ */ React22.createElement(Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ React22.createElement(
851
+ RangePicker,
852
+ {
853
+ disabledDate,
854
+ presets: rangePresets,
855
+ onChange: handleChange,
856
+ value: value && [dayjs2(value[0]), dayjs2(value[1])]
857
+ }
858
+ ));
734
859
  };
735
860
 
736
861
  // src/Components/Image.tsx
737
862
  import React23 from "react";
738
863
  var Image = (props) => {
739
- return /* @__PURE__ */ React23.createElement("div", null, /* @__PURE__ */ React23.createElement("img", { className: props.className, src: props.img, alt: "image" }));
864
+ return /* @__PURE__ */ React23.createElement("img", { className: props.className, src: props.img, alt: "image" });
740
865
  };
741
866
 
742
867
  // src/Components/SingleCheckbox.tsx
@@ -755,60 +880,64 @@ var SingleCheckbox = (props) => {
755
880
  import React25, { useState as useState7 } from "react";
756
881
  import { Select as Select4 } from "antd";
757
882
  var DropDownGroup = (props) => {
758
- const [selectedValue, setSelectedValue] = useState7({ firstValue: {}, secondValue: {} });
883
+ const [selectedValue, setSelectedValue] = useState7({
884
+ firstValue: {},
885
+ secondValue: {},
886
+ temp: ""
887
+ });
759
888
  const handleFirstChange = (value) => {
760
- const filterOption2 = props.firstOptions?.find((eachOption) => eachOption.value === value);
889
+ console.log(selectedValue.temp);
890
+ const filterOption2 = props.firstOptions?.find(
891
+ (eachOption) => eachOption.value === value
892
+ );
761
893
  setSelectedValue((prev) => {
762
894
  const newValue = { ...prev, firstValue: filterOption2 };
895
+ const { temp, ...rest } = newValue;
763
896
  if (newValue.firstValue) {
764
- props.onChange?.(newValue);
897
+ props.onChange?.(rest);
765
898
  }
766
- return selectedValue;
899
+ return newValue;
767
900
  });
768
901
  };
769
902
  const handleSecondChange = (value) => {
770
- const filterOption2 = props.secondOptions?.find((eachOption) => eachOption.value === value);
903
+ const filterOption2 = props.secondOptions?.find(
904
+ (eachOption) => eachOption.value === value
905
+ );
771
906
  setSelectedValue((prev) => {
772
907
  const newValue = { ...prev, secondValue: filterOption2 };
908
+ const { temp, ...rest } = newValue;
773
909
  if (newValue.secondValue) {
774
- props.onChange?.(newValue);
910
+ props.onChange?.(rest);
775
911
  }
776
- return selectedValue;
912
+ return newValue;
777
913
  });
778
914
  };
779
- console.log("selectedValue", selectedValue);
780
- return /* @__PURE__ */ React25.createElement("div", { className: props.className, style: { display: "flex", flexDirection: "row", backgroundColor: "white", borderRadius: 10, border: "1px solid gray" } }, /* @__PURE__ */ React25.createElement(
915
+ return /* @__PURE__ */ React25.createElement("div", { className: props.containerClassName }, props.label && /* @__PURE__ */ React25.createElement("label", { htmlFor: props.name, className: props.labelClassName }, props.label), /* @__PURE__ */ React25.createElement("div", { className: props.subContainerClassName }, /* @__PURE__ */ React25.createElement(
781
916
  Select4,
782
917
  {
783
918
  onChange: handleFirstChange,
784
919
  variant: props.variant,
785
- options: props.firstOptions
920
+ options: props.firstOptions,
921
+ className: props.className
786
922
  }
787
923
  ), /* @__PURE__ */ React25.createElement("div", { style: { borderLeft: "1px solid gray", height: "33px" } }), /* @__PURE__ */ React25.createElement(
788
924
  Select4,
789
925
  {
790
926
  onChange: handleSecondChange,
791
927
  variant: props.variant,
792
- options: props.secondOptions
928
+ options: props.secondOptions,
929
+ className: props.className
793
930
  }
794
- ));
931
+ )));
795
932
  };
796
933
 
797
934
  // src/Components/FilesUpload.tsx
798
935
  import React26, { useState as useState8 } from "react";
799
- import { Upload, message } from "antd";
936
+ import { Upload } from "antd";
800
937
  import { InboxOutlined } from "@ant-design/icons";
801
938
  var FileUpload = (props) => {
802
939
  const { Dragger } = Upload;
803
940
  const [files, setFiles] = useState8([]);
804
- const beforeUpload = (file) => {
805
- const isCorrectFile = ["image/*", "video/*", "application/*"].includes(file.type);
806
- if (!isCorrectFile) {
807
- message.error(`(${file.name}) is an invalid file. Please upload files with the following extensions only (.png/.jpg/.jpeg/.pdf)`);
808
- return Upload.LIST_IGNORE;
809
- }
810
- return true;
811
- };
812
941
  const handleChange = ({ fileList }) => {
813
942
  setFiles(fileList);
814
943
  if (props.onChange) {
@@ -832,7 +961,6 @@ var FileUpload = (props) => {
832
961
  maxCount: props.max_count,
833
962
  multiple: props.multiple,
834
963
  fileList: files,
835
- beforeUpload,
836
964
  onChange: handleChange,
837
965
  showUploadList: true,
838
966
  customRequest
@@ -861,22 +989,569 @@ var onChange = (checked) => {
861
989
  console.log(`switch to ${checked}`);
862
990
  };
863
991
  var SwitchElement = () => /* @__PURE__ */ React28.createElement(Switch, { defaultChecked: true, onChange });
992
+
993
+ // src/Components/Upload.tsx
994
+ import React29, { useState as useState9 } from "react";
995
+ var Upload2 = (props) => {
996
+ const [file, setFile] = useState9();
997
+ const handleFileChange = (e) => {
998
+ setFile(e.target.files[0]);
999
+ if (props.onChange) {
1000
+ props.onChange(e.target.files[0]);
1001
+ }
1002
+ };
1003
+ const handleUpload = async () => {
1004
+ if (!file) {
1005
+ console.error("No file selected");
1006
+ return;
1007
+ }
1008
+ };
1009
+ return /* @__PURE__ */ React29.createElement("div", { style: { marginTop: 16 } }, /* @__PURE__ */ React29.createElement("input", { type: "file", onChange: handleFileChange }), /* @__PURE__ */ React29.createElement(
1010
+ "button",
1011
+ {
1012
+ type: "button",
1013
+ onClick: handleUpload,
1014
+ disabled: !file,
1015
+ style: { marginTop: 16 }
1016
+ },
1017
+ "Upload"
1018
+ ));
1019
+ };
1020
+
1021
+ // src/Components/OtpElement.tsx
1022
+ import React30, { useState as useState10, useRef, useEffect as useEffect3 } from "react";
1023
+ import { Input as Input3 } from "antd";
1024
+ var OtpElement = (props) => {
1025
+ const length = props.length;
1026
+ const [otp, setOtp] = useState10(Array(length).fill(""));
1027
+ const inputRefs = useRef([]);
1028
+ const handleChange = (e, index) => {
1029
+ const value = e.target.value;
1030
+ if (/^[0-9]$/.test(value) || value === "") {
1031
+ const newOtp = [...otp];
1032
+ newOtp[index] = value;
1033
+ setOtp(newOtp);
1034
+ props.onChange && props.onChange(newOtp.join(""));
1035
+ if (value && index < length - 1) {
1036
+ inputRefs.current[index + 1]?.focus();
1037
+ }
1038
+ }
1039
+ };
1040
+ const handleKeyDown = (e, index) => {
1041
+ if (e.key === "Backspace" && !otp[index] && index > 0) {
1042
+ inputRefs.current[index - 1]?.focus();
1043
+ }
1044
+ };
1045
+ const handlePaste = (e) => {
1046
+ e.preventDefault();
1047
+ const pasteData = e.clipboardData.getData("text");
1048
+ if (/^\d+$/.test(pasteData)) {
1049
+ const newOtp = pasteData.split("").slice(0, length);
1050
+ setOtp(newOtp.concat(Array(length - newOtp.length).fill("")));
1051
+ props.onChange && props.onChange(newOtp.join(""));
1052
+ newOtp.forEach((_, idx) => {
1053
+ if (inputRefs.current[idx]) {
1054
+ inputRefs.current[idx]?.focus();
1055
+ }
1056
+ });
1057
+ }
1058
+ };
1059
+ useEffect3(() => {
1060
+ inputRefs.current[0]?.focus();
1061
+ }, []);
1062
+ return /* @__PURE__ */ React30.createElement("div", { className: props.containerClassName }, Array.from({ length }).map((_, index) => /* @__PURE__ */ React30.createElement(
1063
+ Input3,
1064
+ {
1065
+ key: index,
1066
+ className: props.className,
1067
+ maxLength: 1,
1068
+ value: otp[index],
1069
+ onChange: (e) => handleChange(e, index),
1070
+ onKeyDown: (e) => handleKeyDown(e, index),
1071
+ onPaste: handlePaste,
1072
+ ref: (el) => inputRefs.current[index] = el
1073
+ }
1074
+ )));
1075
+ };
1076
+
1077
+ // src/Components/CircleDonut.tsx
1078
+ import React31 from "react";
1079
+ import { Doughnut } from "react-chartjs-2";
1080
+ import {
1081
+ Chart as ChartJS,
1082
+ DoughnutController,
1083
+ ArcElement,
1084
+ Tooltip,
1085
+ Legend
1086
+ } from "chart.js";
1087
+ ChartJS.register(DoughnutController, ArcElement, Tooltip, Legend);
1088
+ var CircleDonut = (props) => {
1089
+ const data = {
1090
+ labels: props.labels,
1091
+ datasets: [
1092
+ {
1093
+ label: "Bot Conversation",
1094
+ data: props.data,
1095
+ backgroundColor: [
1096
+ "#FFCB8A",
1097
+ "#CADBBF",
1098
+ "#8AC1BB",
1099
+ "#FCB0CB",
1100
+ "#CEB0FA"
1101
+ ],
1102
+ borderWidth: 0
1103
+ }
1104
+ ]
1105
+ };
1106
+ const options = {
1107
+ responsive: true,
1108
+ cutout: "80%",
1109
+ plugins: {
1110
+ legend: {
1111
+ position: "left",
1112
+ labels: {
1113
+ font: {
1114
+ size: 10
1115
+ },
1116
+ boxWidth: 15,
1117
+ generateLabels: (chart) => {
1118
+ const dataset = chart.data.datasets[0];
1119
+ return chart.data.labels.map((label, index) => {
1120
+ const value = dataset.data[index];
1121
+ return {
1122
+ text: `${label}: ${value}`,
1123
+ fillStyle: dataset.backgroundColor[index]
1124
+ };
1125
+ });
1126
+ }
1127
+ }
1128
+ },
1129
+ tooltip: {
1130
+ enabled: true,
1131
+ callbacks: {
1132
+ label: function(context) {
1133
+ const label = context.label || "";
1134
+ const value = context.raw || 0;
1135
+ return `${label}: ${value}`;
1136
+ }
1137
+ }
1138
+ }
1139
+ }
1140
+ };
1141
+ const centerTextPlugin = {
1142
+ id: "centerText",
1143
+ beforeDraw: (chart) => {
1144
+ const { ctx, chartArea: { left, right, top, bottom } } = chart;
1145
+ const width = right - left;
1146
+ const height = bottom - top;
1147
+ const centerX = left + width / 2;
1148
+ const centerY = top + height / 2;
1149
+ ctx.save();
1150
+ ctx.font = "7px Arial";
1151
+ ctx.fillStyle = "blue";
1152
+ ctx.textAlign = "center";
1153
+ ctx.textBaseline = "middle";
1154
+ ctx.fillText("Total Sessions", centerX, centerY - 10);
1155
+ ctx.font = "25px Arial";
1156
+ ctx.fillStyle = "black";
1157
+ ctx.fillText("85", centerX, centerY + 20);
1158
+ ctx.restore();
1159
+ }
1160
+ };
1161
+ return /* @__PURE__ */ React31.createElement("div", { className: props.className }, /* @__PURE__ */ React31.createElement("h1", { className: props.labelClassName }, props.label), /* @__PURE__ */ React31.createElement(Doughnut, { data, options, plugins: [centerTextPlugin] }));
1162
+ };
1163
+
1164
+ // src/Components/SemiCircleDonut.tsx
1165
+ import React32 from "react";
1166
+ import { Doughnut as Doughnut2 } from "react-chartjs-2";
1167
+ import {
1168
+ Chart as ChartJS2,
1169
+ DoughnutController as DoughnutController2,
1170
+ ArcElement as ArcElement2,
1171
+ Tooltip as Tooltip2,
1172
+ Legend as Legend2
1173
+ } from "chart.js";
1174
+ ChartJS2.register(DoughnutController2, ArcElement2, Tooltip2, Legend2);
1175
+ var SemiCircleDonut = (props) => {
1176
+ const data = {
1177
+ labels: [
1178
+ "Registration",
1179
+ "Book Appointment",
1180
+ "Diagnostic Tests",
1181
+ "Hospital Facility",
1182
+ "Others, Prescriptions"
1183
+ ],
1184
+ datasets: [
1185
+ {
1186
+ label: "Bot Conversation",
1187
+ data: [30, 10, 27, 40, 12],
1188
+ backgroundColor: [
1189
+ "#FFCB8A",
1190
+ "#CADBBF",
1191
+ "#8AC1BB",
1192
+ "#FCB0CB",
1193
+ "#CEB0FA"
1194
+ ],
1195
+ borderWidth: 0
1196
+ }
1197
+ ]
1198
+ };
1199
+ const options = {
1200
+ responsive: true,
1201
+ circumference: 180,
1202
+ rotation: -90,
1203
+ cutout: "80%",
1204
+ plugins: {
1205
+ legend: {
1206
+ display: false
1207
+ // Disable the legend
1208
+ },
1209
+ tooltip: {
1210
+ enabled: true,
1211
+ callbacks: {
1212
+ label: function(context) {
1213
+ const label = context.label || "";
1214
+ const value = context.raw || 0;
1215
+ return `${label}: ${value}`;
1216
+ }
1217
+ }
1218
+ }
1219
+ }
1220
+ };
1221
+ const centerTextPlugin = {
1222
+ id: "centerText",
1223
+ beforeDraw: (chart) => {
1224
+ const { ctx, chartArea: { left, right, top, bottom } } = chart;
1225
+ const width = right - left;
1226
+ const height = bottom - top;
1227
+ const centerX = left + width / 2;
1228
+ const centerY = top + height / 1.5;
1229
+ const maxWidth = width * 0.8;
1230
+ ctx.save();
1231
+ ctx.fillStyle = "black";
1232
+ ctx.textAlign = "center";
1233
+ ctx.textBaseline = "middle";
1234
+ const drawText = (text, y, fontSize) => {
1235
+ ctx.font = `${fontSize}px Arial`;
1236
+ const textWidth = ctx.measureText(text).width;
1237
+ if (textWidth > maxWidth) {
1238
+ const newFontSize = fontSize * maxWidth / textWidth;
1239
+ ctx.font = `${newFontSize}px Arial`;
1240
+ }
1241
+ ctx.fillText(text, centerX, y);
1242
+ };
1243
+ drawText(props.fillText1, centerY - 10, 16);
1244
+ drawText(props.fillText2, centerY + 20, 8);
1245
+ ctx.restore();
1246
+ }
1247
+ };
1248
+ return /* @__PURE__ */ React32.createElement("div", { className: props.className }, /* @__PURE__ */ React32.createElement("h1", { className: props.labelClassName }, props.label), /* @__PURE__ */ React32.createElement(Doughnut2, { data, options, plugins: [centerTextPlugin] }));
1249
+ };
1250
+
1251
+ // src/Components/HorizontalBarChart.tsx
1252
+ import React33 from "react";
1253
+ import { Bar } from "react-chartjs-2";
1254
+ import {
1255
+ Chart as ChartJS3,
1256
+ BarElement,
1257
+ CategoryScale,
1258
+ LinearScale,
1259
+ Tooltip as Tooltip3
1260
+ } from "chart.js";
1261
+ ChartJS3.register(BarElement, CategoryScale, LinearScale, Tooltip3);
1262
+ var HorizontalBarChart = (props) => {
1263
+ const data = {
1264
+ labels: ["18-24", "25-34", "35-44", "45-54", "55-64", "65+"],
1265
+ datasets: [
1266
+ {
1267
+ data: [30, 10, 27, 40, 12, 24],
1268
+ backgroundColor: "#6298D5",
1269
+ barThickness: 15
1270
+ }
1271
+ ]
1272
+ };
1273
+ const options = {
1274
+ responsive: true,
1275
+ indexAxis: "y",
1276
+ scales: {
1277
+ x: {
1278
+ beginAtZero: true,
1279
+ ticks: {
1280
+ callback: function(value) {
1281
+ return `${value}%`;
1282
+ }
1283
+ }
1284
+ },
1285
+ y: {
1286
+ grid: {
1287
+ display: false
1288
+ }
1289
+ }
1290
+ },
1291
+ plugins: {
1292
+ tooltip: {
1293
+ enabled: true,
1294
+ callbacks: {
1295
+ label: function(context) {
1296
+ const label = context.label || "";
1297
+ const value = context.raw || 0;
1298
+ return `${label}: ${value}`;
1299
+ }
1300
+ }
1301
+ },
1302
+ legend: {
1303
+ display: false
1304
+ }
1305
+ }
1306
+ };
1307
+ return /* @__PURE__ */ React33.createElement("div", { className: props.className }, /* @__PURE__ */ React33.createElement("h1", { className: props.labelClassName }, props.label), /* @__PURE__ */ React33.createElement(Bar, { data, options }));
1308
+ };
1309
+
1310
+ // src/Components/LineChart.tsx
1311
+ import React34, { useEffect as useEffect4, useRef as useRef2 } from "react";
1312
+ import Chart from "chart.js/auto";
1313
+ var LineChart = (props) => {
1314
+ const chartRef = useRef2(null);
1315
+ const chartInstance = useRef2(null);
1316
+ const data = [
1317
+ { label: "ROI", data: [10, 13, 20, 15, 10] },
1318
+ { label: "Engagement Rate", data: [20, 23, 30, 28, 20] },
1319
+ { label: "Conversion Rate", data: [50, 100, 150, 180, 50] }
1320
+ ];
1321
+ const labels = ["Instagram", "Whatsapp", "Messages", "Telegram", "Linkedin"];
1322
+ useEffect4(() => {
1323
+ if (chartRef.current) {
1324
+ if (chartInstance.current) {
1325
+ chartInstance.current.destroy();
1326
+ }
1327
+ chartInstance.current = new Chart(chartRef.current, {
1328
+ type: "line",
1329
+ data: {
1330
+ labels,
1331
+ datasets: data.map((dataset, index) => ({
1332
+ label: dataset.label,
1333
+ data: dataset.data,
1334
+ borderColor: index === 0 ? "#FF8F00" : index === 1 ? "#F50057" : "#254AAA",
1335
+ backgroundColor: "rgba(0, 0, 0, 0)",
1336
+ pointBackgroundColor: index === 0 ? "#FF8F00" : index === 1 ? "#F50057" : "#254AAA",
1337
+ pointBorderColor: "white",
1338
+ pointStyle: "circle",
1339
+ pointRadius: 3,
1340
+ tension: 0.1,
1341
+ fill: true
1342
+ }))
1343
+ },
1344
+ options: {
1345
+ plugins: {
1346
+ legend: {
1347
+ labels: {
1348
+ usePointStyle: true
1349
+ }
1350
+ }
1351
+ },
1352
+ scales: {
1353
+ x: {
1354
+ grid: {
1355
+ display: false
1356
+ }
1357
+ },
1358
+ y: {
1359
+ beginAtZero: true,
1360
+ suggestedMax: 200,
1361
+ ticks: {
1362
+ callback: function(value) {
1363
+ return value + "%";
1364
+ }
1365
+ },
1366
+ grid: {
1367
+ display: true
1368
+ }
1369
+ }
1370
+ }
1371
+ }
1372
+ });
1373
+ }
1374
+ return () => {
1375
+ if (chartInstance.current) {
1376
+ chartInstance.current.destroy();
1377
+ }
1378
+ };
1379
+ }, [labels, data]);
1380
+ return /* @__PURE__ */ React34.createElement("div", { className: props.className }, /* @__PURE__ */ React34.createElement("canvas", { ref: chartRef }));
1381
+ };
1382
+
1383
+ // src/Components/DoubleBarChart.tsx
1384
+ import React35, { useEffect as useEffect5, useRef as useRef3 } from "react";
1385
+ import Chart2 from "chart.js/auto";
1386
+ var DoubleBarChart = (props) => {
1387
+ const chartRef = useRef3(null);
1388
+ const chartInstance = useRef3(null);
1389
+ useEffect5(() => {
1390
+ if (chartRef.current) {
1391
+ if (chartInstance.current) {
1392
+ chartInstance.current.destroy();
1393
+ }
1394
+ chartInstance.current = new Chart2(chartRef.current, {
1395
+ type: "bar",
1396
+ data: {
1397
+ labels: [
1398
+ "Summer Health Tips",
1399
+ "New Services Launch",
1400
+ "Discounts on Checkups",
1401
+ "Wellness Webinar",
1402
+ "LinkedIn Insights"
1403
+ ],
1404
+ datasets: [
1405
+ {
1406
+ label: "Engagement Rate",
1407
+ data: [60, 70, 50, 80, 65],
1408
+ // Example data for male
1409
+ backgroundColor: "#93B8E2",
1410
+ barThickness: 10
1411
+ },
1412
+ {
1413
+ label: "Conversion Rate",
1414
+ data: [70, 65, 75, 55, 85],
1415
+ // Example data for female
1416
+ backgroundColor: "#4484CD",
1417
+ barThickness: 10
1418
+ }
1419
+ ]
1420
+ },
1421
+ options: {
1422
+ scales: {
1423
+ x: {
1424
+ grid: {
1425
+ display: false
1426
+ // Display x-axis grid lines
1427
+ }
1428
+ },
1429
+ y: {
1430
+ beginAtZero: true,
1431
+ suggestedMax: 100,
1432
+ ticks: {
1433
+ callback: function(value) {
1434
+ return value + "%";
1435
+ }
1436
+ },
1437
+ grid: {
1438
+ display: true
1439
+ }
1440
+ }
1441
+ },
1442
+ plugins: {
1443
+ legend: {
1444
+ labels: {
1445
+ usePointStyle: true
1446
+ }
1447
+ }
1448
+ }
1449
+ }
1450
+ });
1451
+ }
1452
+ return () => {
1453
+ if (chartInstance.current) {
1454
+ chartInstance.current.destroy();
1455
+ }
1456
+ };
1457
+ }, []);
1458
+ return /* @__PURE__ */ React35.createElement("div", { className: props.className }, /* @__PURE__ */ React35.createElement("h1", { className: props.labelClassName }, props.label), /* @__PURE__ */ React35.createElement("canvas", { ref: chartRef }));
1459
+ };
1460
+
1461
+ // src/Components/BarChart.tsx
1462
+ import React36 from "react";
1463
+ import { Bar as Bar2 } from "react-chartjs-2";
1464
+ import {
1465
+ Chart as ChartJS4,
1466
+ BarElement as BarElement2,
1467
+ CategoryScale as CategoryScale2,
1468
+ LinearScale as LinearScale2,
1469
+ Tooltip as Tooltip4
1470
+ } from "chart.js";
1471
+ ChartJS4.register(BarElement2, CategoryScale2, LinearScale2, Tooltip4);
1472
+ var BarChart = (props) => {
1473
+ const data = {
1474
+ labels: [
1475
+ "17 June",
1476
+ "18 June",
1477
+ "19 June",
1478
+ "20 June",
1479
+ "21 June",
1480
+ "22 June",
1481
+ "23 June"
1482
+ ],
1483
+ datasets: [
1484
+ {
1485
+ data: [30, 100, 270, 140, 120, 240],
1486
+ backgroundColor: "#1565C0",
1487
+ barThickness: 15
1488
+ }
1489
+ ]
1490
+ };
1491
+ const options = {
1492
+ responsive: true,
1493
+ scales: {
1494
+ x: {
1495
+ beginAtZero: true,
1496
+ grid: {
1497
+ display: false
1498
+ }
1499
+ },
1500
+ y: {
1501
+ grid: {
1502
+ display: true
1503
+ },
1504
+ ticks: {
1505
+ min: 0,
1506
+ max: 400,
1507
+ stepSize: 200,
1508
+ callback: function(value) {
1509
+ return `${value}`;
1510
+ }
1511
+ }
1512
+ }
1513
+ },
1514
+ plugins: {
1515
+ tooltip: {
1516
+ enabled: true,
1517
+ callbacks: {
1518
+ label: function(context) {
1519
+ const label = context.label || "";
1520
+ const value = context.raw || 0;
1521
+ return ` ${label}: ${value}`;
1522
+ }
1523
+ }
1524
+ },
1525
+ legend: {
1526
+ display: false
1527
+ }
1528
+ }
1529
+ };
1530
+ return /* @__PURE__ */ React36.createElement("div", { className: props.className }, /* @__PURE__ */ React36.createElement("h1", { className: props.labelClassName }, props.label), /* @__PURE__ */ React36.createElement(Bar2, { data, options }));
1531
+ };
864
1532
  export {
865
1533
  AddMoreTable,
1534
+ BarChart,
866
1535
  ButtonElement,
867
1536
  CheckboxElement,
1537
+ CircleDonut,
868
1538
  CkEditor,
869
1539
  DatePickerElement,
870
1540
  DateRangePickerElement,
1541
+ DoubleBarChart,
871
1542
  DropDownGroup,
872
1543
  FileUpload,
1544
+ HorizontalBarChart,
873
1545
  Image,
1546
+ LineChart,
874
1547
  MultipleSelectElement,
875
1548
  Navbar,
876
1549
  NumberElement,
1550
+ OtpElement,
877
1551
  PasswordElement,
878
1552
  RadioElement,
879
1553
  SelectElement,
1554
+ SemiCircleDonut,
880
1555
  Sidebar,
881
1556
  SingleCheckbox,
882
1557
  SingleSelectElement,
@@ -884,5 +1559,6 @@ export {
884
1559
  TableElement,
885
1560
  TabsElement,
886
1561
  TextElement,
887
- TextareaElement
1562
+ TextareaElement,
1563
+ Upload2 as Upload
888
1564
  };