@apexcura/ui-components 0.0.14-Beta5 → 0.0.14-Beta50

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.css CHANGED
@@ -375,6 +375,9 @@ video {
375
375
  .italic {
376
376
  font-style: italic;
377
377
  }
378
+ .text-\[\\w-\] {
379
+ color: w-;
380
+ }
378
381
  .text-black {
379
382
  --tw-text-opacity: 1;
380
383
  color: rgb(0 0 0 / var(--tw-text-opacity));
package/dist/index.d.mts CHANGED
@@ -26,6 +26,9 @@ type ElementType = {
26
26
  fields?: any[];
27
27
  schema?: any[];
28
28
  options?: any[];
29
+ firstOptions?: any[];
30
+ secondOptions?: any[];
31
+ view?: boolean;
29
32
  onChange?: (value: string | number | boolean | object | any[] | undefined) => void;
30
33
  onClick?: () => void;
31
34
  dropDownOptions?: any[];
@@ -57,6 +60,7 @@ type ElementType = {
57
60
  containerClassName?: string;
58
61
  selectBefore?: any[];
59
62
  selectAfter?: any[];
63
+ isSVGStylesOverride?: boolean;
60
64
  };
61
65
 
62
66
  declare const TextElement: (props: ElementType) => React$1.JSX.Element;
@@ -82,7 +86,7 @@ declare const SingleSelectElement: (props: ElementType) => React$1.JSX.Element;
82
86
 
83
87
  declare const MultipleSelectElement: (props: ElementType) => React$1.JSX.Element;
84
88
 
85
- declare const ButtonElement: React$1.FC<ElementType>;
89
+ declare const ButtonElement: (props: ElementType) => React$1.JSX.Element;
86
90
 
87
91
  declare const AddMoreTable: (props: ElementType) => React$1.JSX.Element;
88
92
 
@@ -106,4 +110,8 @@ declare const FileUpload: (props: ElementType) => React$1.JSX.Element;
106
110
 
107
111
  declare const TabsElement: (props: ElementType) => React$1.JSX.Element;
108
112
 
109
- export { AddMoreTable, ButtonElement, CheckboxElement, CkEditor, DatePickerElement, DateRangePickerElement, DropDownGroup, FileUpload, Image, MultipleSelectElement, Navbar, NumberElement, PasswordElement, RadioElement, SelectElement, Sidebar, SingleCheckbox, SingleSelectElement, TableElement, TabsElement, TextElement, TextareaElement };
113
+ declare const SwitchElement: () => React$1.JSX.Element;
114
+
115
+ declare const Upload: (props: ElementType) => React$1.JSX.Element;
116
+
117
+ export { AddMoreTable, ButtonElement, CheckboxElement, CkEditor, DatePickerElement, DateRangePickerElement, DropDownGroup, FileUpload, Image, MultipleSelectElement, Navbar, NumberElement, PasswordElement, RadioElement, SelectElement, Sidebar, SingleCheckbox, SingleSelectElement, SwitchElement, TableElement, TabsElement, TextElement, TextareaElement, Upload };
package/dist/index.d.ts CHANGED
@@ -26,6 +26,9 @@ type ElementType = {
26
26
  fields?: any[];
27
27
  schema?: any[];
28
28
  options?: any[];
29
+ firstOptions?: any[];
30
+ secondOptions?: any[];
31
+ view?: boolean;
29
32
  onChange?: (value: string | number | boolean | object | any[] | undefined) => void;
30
33
  onClick?: () => void;
31
34
  dropDownOptions?: any[];
@@ -57,6 +60,7 @@ type ElementType = {
57
60
  containerClassName?: string;
58
61
  selectBefore?: any[];
59
62
  selectAfter?: any[];
63
+ isSVGStylesOverride?: boolean;
60
64
  };
61
65
 
62
66
  declare const TextElement: (props: ElementType) => React$1.JSX.Element;
@@ -82,7 +86,7 @@ declare const SingleSelectElement: (props: ElementType) => React$1.JSX.Element;
82
86
 
83
87
  declare const MultipleSelectElement: (props: ElementType) => React$1.JSX.Element;
84
88
 
85
- declare const ButtonElement: React$1.FC<ElementType>;
89
+ declare const ButtonElement: (props: ElementType) => React$1.JSX.Element;
86
90
 
87
91
  declare const AddMoreTable: (props: ElementType) => React$1.JSX.Element;
88
92
 
@@ -106,4 +110,8 @@ declare const FileUpload: (props: ElementType) => React$1.JSX.Element;
106
110
 
107
111
  declare const TabsElement: (props: ElementType) => React$1.JSX.Element;
108
112
 
109
- export { AddMoreTable, ButtonElement, CheckboxElement, CkEditor, DatePickerElement, DateRangePickerElement, DropDownGroup, FileUpload, Image, MultipleSelectElement, Navbar, NumberElement, PasswordElement, RadioElement, SelectElement, Sidebar, SingleCheckbox, SingleSelectElement, TableElement, TabsElement, TextElement, TextareaElement };
113
+ declare const SwitchElement: () => React$1.JSX.Element;
114
+
115
+ declare const Upload: (props: ElementType) => React$1.JSX.Element;
116
+
117
+ export { AddMoreTable, ButtonElement, CheckboxElement, CkEditor, DatePickerElement, DateRangePickerElement, DropDownGroup, FileUpload, Image, MultipleSelectElement, Navbar, NumberElement, PasswordElement, RadioElement, SelectElement, Sidebar, SingleCheckbox, SingleSelectElement, SwitchElement, TableElement, TabsElement, TextElement, TextareaElement, Upload };
package/dist/index.js CHANGED
@@ -48,10 +48,12 @@ __export(src_exports, {
48
48
  Sidebar: () => Sidebar,
49
49
  SingleCheckbox: () => SingleCheckbox,
50
50
  SingleSelectElement: () => SingleSelectElement,
51
+ SwitchElement: () => SwitchElement,
51
52
  TableElement: () => TableElement,
52
53
  TabsElement: () => TabsElement,
53
54
  TextElement: () => TextElement,
54
- TextareaElement: () => TextareaElement
55
+ TextareaElement: () => TextareaElement,
56
+ Upload: () => Upload2
55
57
  });
56
58
  module.exports = __toCommonJS(src_exports);
57
59
 
@@ -70,6 +72,7 @@ var TextElement = (props) => {
70
72
  placeholder: props.placeholder,
71
73
  allowClear: true,
72
74
  id: props.name,
75
+ value: props.value,
73
76
  prefix: props.prefix,
74
77
  type: props.type,
75
78
  status: props.status,
@@ -129,8 +132,7 @@ var NumberElement = (props) => {
129
132
  {
130
133
  placeholder: props.placeholder,
131
134
  addonBefore: props.addonBefore,
132
- allowClear: true,
133
- defaultValue: props.defaultValue,
135
+ value: props.value,
134
136
  disabled: props.disabled,
135
137
  id: props.name,
136
138
  prefix: props.prefix,
@@ -375,13 +377,79 @@ var MultipleSelectElement = (props) => {
375
377
  // src/Components/Button.tsx
376
378
  var import_react11 = __toESM(require("react"));
377
379
  var ButtonElement = (props) => {
380
+ const [svgContent, setSvgContent] = (0, import_react11.useState)(null);
381
+ const [hoverColor, setHoverColor] = (0, import_react11.useState)(null);
382
+ (0, import_react11.useEffect)(() => {
383
+ if (props.icon) {
384
+ fetch(props.icon).then((response) => response.text()).then((data) => {
385
+ const tempDiv = document.createElement("div");
386
+ tempDiv.innerHTML = data;
387
+ const svgElement = tempDiv.querySelector("svg");
388
+ if (svgElement) {
389
+ const textColorClass = props.className?.match(/text-[\w-]+/g)?.[0];
390
+ const hoverColorClass = props.className?.match(/hover:text-[\w-]+/g)?.[0];
391
+ if (textColorClass) {
392
+ const tempSpan = document.createElement("span");
393
+ tempSpan.className = textColorClass;
394
+ document.body.appendChild(tempSpan);
395
+ const computedColor = getComputedStyle(tempSpan).color;
396
+ document.body.removeChild(tempSpan);
397
+ const paths = svgElement.querySelectorAll("path");
398
+ paths.forEach((path) => path.setAttribute("fill", computedColor));
399
+ }
400
+ if (hoverColorClass) {
401
+ const tempSpan = document.createElement("span");
402
+ tempSpan.className = hoverColorClass.replace("hover:", "");
403
+ document.body.appendChild(tempSpan);
404
+ const computedHoverColor = getComputedStyle(tempSpan).color;
405
+ document.body.removeChild(tempSpan);
406
+ setHoverColor(computedHoverColor);
407
+ console.log("hoverColor", hoverColor);
408
+ }
409
+ svgElement.setAttribute(
410
+ "class",
411
+ `${props.className ? props.className : ""}`
412
+ );
413
+ setSvgContent(tempDiv.innerHTML);
414
+ }
415
+ }).catch((error) => console.error("Error fetching SVG:", error));
416
+ }
417
+ }, [props.icon, props.className]);
418
+ const handleMouseEnter = () => {
419
+ if (hoverColor && svgContent) {
420
+ const tempDiv = document.createElement("div");
421
+ tempDiv.innerHTML = svgContent;
422
+ const svgElement = tempDiv.querySelector("svg");
423
+ const paths = svgElement?.querySelectorAll("path");
424
+ paths?.forEach((path) => path.setAttribute("fill", hoverColor));
425
+ setSvgContent(tempDiv.innerHTML);
426
+ }
427
+ };
428
+ const handleMouseLeave = () => {
429
+ if (svgContent) {
430
+ const tempDiv = document.createElement("div");
431
+ tempDiv.innerHTML = svgContent;
432
+ const svgElement = tempDiv.querySelector("svg");
433
+ const paths = svgElement?.querySelectorAll("path");
434
+ paths?.forEach((path) => path.removeAttribute("fill"));
435
+ setSvgContent(tempDiv.innerHTML);
436
+ }
437
+ };
378
438
  return /* @__PURE__ */ import_react11.default.createElement(
379
439
  "button",
380
440
  {
381
- onClick: () => props.onClick && props.onClick(),
382
- className: `${props.className ? props.className : ""}`
441
+ onClick: props.onClick,
442
+ className: `${props.className ? props.className : ""}`,
443
+ onMouseEnter: handleMouseEnter,
444
+ onMouseLeave: handleMouseLeave
383
445
  },
384
- props.icon && /* @__PURE__ */ import_react11.default.createElement("img", { className: props.iconsClassName, src: props.icon }),
446
+ props.isSVGStylesOverride ? svgContent && /* @__PURE__ */ import_react11.default.createElement(
447
+ "span",
448
+ {
449
+ className: "svg-container",
450
+ dangerouslySetInnerHTML: { __html: svgContent }
451
+ }
452
+ ) : props.icon && /* @__PURE__ */ import_react11.default.createElement("img", { className: props.iconsClassName, src: props.icon }),
385
453
  props.label
386
454
  );
387
455
  };
@@ -464,9 +532,9 @@ var AddMoreTable = (props) => {
464
532
  if (!element) return null;
465
533
  const { element: type, label } = element;
466
534
  if (type === "single-select") {
467
- return /* @__PURE__ */ import_react12.default.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
535
+ return /* @__PURE__ */ import_react12.default.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [], firstOptions: [], secondOptions: [] });
468
536
  } else if (type === "textarea") {
469
- return /* @__PURE__ */ import_react12.default.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
537
+ return /* @__PURE__ */ import_react12.default.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [], firstOptions: [], secondOptions: [] });
470
538
  } else {
471
539
  return null;
472
540
  }
@@ -667,12 +735,6 @@ var TableElement = (props) => {
667
735
  dataIndex: "#",
668
736
  key: "#"
669
737
  },
670
- {
671
- title: "View",
672
- dataIndex: "View",
673
- key: "View",
674
- render: (_, record) => /* @__PURE__ */ import_react20.default.createElement(import_antd14.Button, null, "View")
675
- },
676
738
  ...thead.map((col, ind) => ({
677
739
  title: col.label,
678
740
  dataIndex: col.name,
@@ -689,6 +751,24 @@ var TableElement = (props) => {
689
751
  }
690
752
  }))
691
753
  ];
754
+ if (props.view) {
755
+ columns.push({
756
+ title: "View",
757
+ dataIndex: "View",
758
+ key: "View",
759
+ render: (_, record) => /* @__PURE__ */ import_react20.default.createElement(
760
+ "a",
761
+ {
762
+ onClick: () => {
763
+ setSelectedRecord(record);
764
+ handleChange(record);
765
+ setModel(true);
766
+ }
767
+ },
768
+ "View"
769
+ )
770
+ });
771
+ }
692
772
  }
693
773
  const dataSource = tbody && tbody.map((row, index) => ({
694
774
  ...row,
@@ -721,17 +801,7 @@ var TableElement = (props) => {
721
801
  columns,
722
802
  bordered: true,
723
803
  rowSelection: rowSelectionConfig,
724
- size: props.size && props.size,
725
- onRow: (record) => {
726
- return {
727
- onClick: () => {
728
- setSelectedRecord(record);
729
- handleChange(record);
730
- setModel(true);
731
- },
732
- style: { cursor: "pointer" }
733
- };
734
- }
804
+ size: props.size && props.size
735
805
  }
736
806
  ), model && /* @__PURE__ */ import_react20.default.createElement(ModelElement, { selectedRecord, ...props, columns, model, onCancel: () => setModel(false) }));
737
807
  };
@@ -739,59 +809,40 @@ var TableElement = (props) => {
739
809
  // src/Components/DatePicker.tsx
740
810
  var import_react21 = __toESM(require("react"));
741
811
  var import_antd15 = require("antd");
742
- var import_icons4 = require("@ant-design/icons");
743
- var import_moment = __toESM(require("moment"));
812
+ var import_dayjs = __toESM(require("dayjs"));
813
+ var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
814
+ import_dayjs.default.extend(import_customParseFormat.default);
744
815
  var DatePickerElement = (props) => {
745
- const [date, setDate] = (0, import_react21.useState)(null);
746
- const handleChange = (date2, dateString) => {
747
- console.log("date---------", date2);
748
- console.log("datestring", dateString);
749
- if (date2) {
750
- const formattedDate = dateString;
751
- console.log("formattedDate-----------------", formattedDate);
752
- setDate(date2);
753
- console.log("changedDate------------", date2);
816
+ const [dateState, setDateState] = (0, import_react21.useState)("");
817
+ const handleChange = (date, dateString) => {
818
+ if (date) {
819
+ const formattedDate = date;
820
+ setDateState(date);
754
821
  if (props.onChange) {
755
822
  props.onChange(formattedDate);
756
823
  }
757
824
  } else {
758
- setDate(null);
825
+ setDateState("");
759
826
  if (props.onChange) {
760
827
  props.onChange("");
761
828
  }
762
829
  }
763
830
  };
764
- const onHandleDecrement = () => {
765
- const currentDate = date || (0, import_moment.default)();
766
- const newDate = (0, import_moment.default)(currentDate).subtract(1, "days");
767
- setDate(newDate);
768
- if (props.onChange) {
769
- props.onChange(newDate.format("lll"));
770
- }
771
- };
772
- const onHandleIncrement = () => {
773
- const currentDate = date || (0, import_moment.default)();
774
- const newDate = (0, import_moment.default)(currentDate).add(1, "days");
775
- setDate(newDate);
776
- if (props.onChange) {
777
- props.onChange(newDate.format("lll"));
778
- }
779
- };
780
- return /* @__PURE__ */ import_react21.default.createElement("div", null, /* @__PURE__ */ import_react21.default.createElement("button", { onClick: onHandleDecrement }, /* @__PURE__ */ import_react21.default.createElement(import_icons4.LeftOutlined, null)), /* @__PURE__ */ import_react21.default.createElement(
831
+ return /* @__PURE__ */ import_react21.default.createElement("div", null, /* @__PURE__ */ import_react21.default.createElement(
781
832
  import_antd15.DatePicker,
782
833
  {
783
834
  placeholder: props.placeholder,
784
- value: date,
785
- variant: "borderless",
835
+ value: dateState,
836
+ format: { format: "DD-MM-YYYY" },
786
837
  onChange: handleChange
787
838
  }
788
- ), /* @__PURE__ */ import_react21.default.createElement("button", { onClick: onHandleIncrement }, /* @__PURE__ */ import_react21.default.createElement(import_icons4.RightOutlined, null)));
839
+ ));
789
840
  };
790
841
 
791
842
  // src/Components/DateRangePickerElement.tsx
792
843
  var import_react22 = __toESM(require("react"));
793
844
  var import_antd16 = require("antd");
794
- var import_dayjs = __toESM(require("dayjs"));
845
+ var import_dayjs2 = __toESM(require("dayjs"));
795
846
  var DateRangePickerElement = (props) => {
796
847
  const { RangePicker } = import_antd16.DatePicker;
797
848
  const handleChange = (dates, dateStrings) => {
@@ -802,10 +853,10 @@ var DateRangePickerElement = (props) => {
802
853
  }
803
854
  };
804
855
  const rangePresets = [
805
- { label: "Last 7 Days", value: [(0, import_dayjs.default)().add(-7, "d"), (0, import_dayjs.default)()] },
806
- { label: "Last 14 Days", value: [(0, import_dayjs.default)().add(-14, "d"), (0, import_dayjs.default)()] },
807
- { label: "Last 30 Days", value: [(0, import_dayjs.default)().add(-30, "d"), (0, import_dayjs.default)()] },
808
- { label: "Last 90 Days", value: [(0, import_dayjs.default)().add(-90, "d"), (0, import_dayjs.default)()] }
856
+ { label: "Last 7 Days", value: [(0, import_dayjs2.default)().add(-7, "d"), (0, import_dayjs2.default)()] },
857
+ { label: "Last 14 Days", value: [(0, import_dayjs2.default)().add(-14, "d"), (0, import_dayjs2.default)()] },
858
+ { label: "Last 30 Days", value: [(0, import_dayjs2.default)().add(-30, "d"), (0, import_dayjs2.default)()] },
859
+ { label: "Last 90 Days", value: [(0, import_dayjs2.default)().add(-90, "d"), (0, import_dayjs2.default)()] }
809
860
  ];
810
861
  return /* @__PURE__ */ import_react22.default.createElement(import_antd16.Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ import_react22.default.createElement(RangePicker, { presets: rangePresets, onChange: handleChange }));
811
862
  };
@@ -813,7 +864,7 @@ var DateRangePickerElement = (props) => {
813
864
  // src/Components/Image.tsx
814
865
  var import_react23 = __toESM(require("react"));
815
866
  var Image = (props) => {
816
- return /* @__PURE__ */ import_react23.default.createElement("div", null, /* @__PURE__ */ import_react23.default.createElement("img", { className: props.className, src: props.img, alt: "image" }));
867
+ return /* @__PURE__ */ import_react23.default.createElement("img", { className: props.className, src: props.img, alt: "image" });
817
868
  };
818
869
 
819
870
  // src/Components/SingleCheckbox.tsx
@@ -832,33 +883,44 @@ var SingleCheckbox = (props) => {
832
883
  var import_react25 = __toESM(require("react"));
833
884
  var import_antd18 = require("antd");
834
885
  var DropDownGroup = (props) => {
835
- const [selectedValue, setSelectedValue] = (0, import_react25.useState)({ firstValue: {}, secondValue: {} });
886
+ const [selectedValue, setSelectedValue] = (0, import_react25.useState)({
887
+ firstValue: {},
888
+ secondValue: {},
889
+ temp: ""
890
+ });
836
891
  const handleFirstChange = (value) => {
837
- const filterOption2 = props.options?.find((eachOption) => eachOption.value === value);
892
+ console.log(selectedValue.temp);
893
+ const filterOption2 = props.firstOptions?.find(
894
+ (eachOption) => eachOption.value === value
895
+ );
838
896
  setSelectedValue((prev) => {
839
897
  const newValue = { ...prev, firstValue: filterOption2 };
898
+ const { temp, ...rest } = newValue;
840
899
  if (newValue.firstValue) {
841
- props.onChange?.(newValue);
900
+ props.onChange?.(rest);
842
901
  }
843
- return selectedValue;
902
+ return newValue;
844
903
  });
845
904
  };
846
905
  const handleSecondChange = (value) => {
847
- const filterOption2 = props.options?.find((eachOption) => eachOption.value === value);
906
+ const filterOption2 = props.secondOptions?.find(
907
+ (eachOption) => eachOption.value === value
908
+ );
848
909
  setSelectedValue((prev) => {
849
910
  const newValue = { ...prev, secondValue: filterOption2 };
911
+ const { temp, ...rest } = newValue;
850
912
  if (newValue.secondValue) {
851
- props.onChange?.(newValue);
913
+ props.onChange?.(rest);
852
914
  }
853
- return selectedValue;
915
+ return newValue;
854
916
  });
855
917
  };
856
- return /* @__PURE__ */ import_react25.default.createElement("div", { className: props.containerClassName }, /* @__PURE__ */ import_react25.default.createElement(
918
+ return /* @__PURE__ */ import_react25.default.createElement("div", { className: props.containerClassName }, props.label && /* @__PURE__ */ import_react25.default.createElement("label", { htmlFor: props.name, className: props.labelClassName }, props.label), /* @__PURE__ */ import_react25.default.createElement("div", { className: props.subContainerClassName }, /* @__PURE__ */ import_react25.default.createElement(
857
919
  import_antd18.Select,
858
920
  {
859
921
  onChange: handleFirstChange,
860
922
  variant: props.variant,
861
- options: props.options,
923
+ options: props.firstOptions,
862
924
  className: props.className
863
925
  }
864
926
  ), /* @__PURE__ */ import_react25.default.createElement("div", { style: { borderLeft: "1px solid gray", height: "33px" } }), /* @__PURE__ */ import_react25.default.createElement(
@@ -866,27 +928,19 @@ var DropDownGroup = (props) => {
866
928
  {
867
929
  onChange: handleSecondChange,
868
930
  variant: props.variant,
869
- options: props.options,
931
+ options: props.secondOptions,
870
932
  className: props.className
871
933
  }
872
- ));
934
+ )));
873
935
  };
874
936
 
875
937
  // src/Components/FilesUpload.tsx
876
938
  var import_react26 = __toESM(require("react"));
877
939
  var import_antd19 = require("antd");
878
- var import_icons5 = require("@ant-design/icons");
940
+ var import_icons4 = require("@ant-design/icons");
879
941
  var FileUpload = (props) => {
880
942
  const { Dragger } = import_antd19.Upload;
881
943
  const [files, setFiles] = (0, import_react26.useState)([]);
882
- const beforeUpload = (file) => {
883
- const isCorrectFile = ["image/png", "image/jpg", "image/jpeg", "application/pdf"].includes(file.type);
884
- if (!isCorrectFile) {
885
- import_antd19.message.error(`(${file.name}) is an invalid file. Please upload files with the following extensions only (.png/.jpg/.jpeg/.pdf)`);
886
- return import_antd19.Upload.LIST_IGNORE;
887
- }
888
- return true;
889
- };
890
944
  const handleChange = ({ fileList }) => {
891
945
  setFiles(fileList);
892
946
  if (props.onChange) {
@@ -910,12 +964,11 @@ var FileUpload = (props) => {
910
964
  maxCount: props.max_count,
911
965
  multiple: props.multiple,
912
966
  fileList: files,
913
- beforeUpload,
914
967
  onChange: handleChange,
915
968
  showUploadList: true,
916
969
  customRequest
917
970
  },
918
- /* @__PURE__ */ import_react26.default.createElement("p", null, /* @__PURE__ */ import_react26.default.createElement(import_icons5.InboxOutlined, null)),
971
+ /* @__PURE__ */ import_react26.default.createElement("p", null, /* @__PURE__ */ import_react26.default.createElement(import_icons4.InboxOutlined, null)),
919
972
  /* @__PURE__ */ import_react26.default.createElement("p", null, "Click or drag file to upload")
920
973
  ));
921
974
  };
@@ -931,6 +984,42 @@ var TabsElement = (props) => {
931
984
  };
932
985
  return /* @__PURE__ */ import_react27.default.createElement(import_antd20.Tabs, { className: props.containerClassName, items: props.options, onChange: handleChange });
933
986
  };
987
+
988
+ // src/Components/SwitchElement.tsx
989
+ var import_react28 = __toESM(require("react"));
990
+ var import_antd21 = require("antd");
991
+ var onChange = (checked) => {
992
+ console.log(`switch to ${checked}`);
993
+ };
994
+ var SwitchElement = () => /* @__PURE__ */ import_react28.default.createElement(import_antd21.Switch, { defaultChecked: true, onChange });
995
+
996
+ // src/Components/Upload.tsx
997
+ var import_react29 = __toESM(require("react"));
998
+ var Upload2 = (props) => {
999
+ const [file, setFile] = (0, import_react29.useState)();
1000
+ const handleFileChange = (e) => {
1001
+ setFile(e.target.files[0]);
1002
+ if (props.onChange) {
1003
+ props.onChange(e.target.files[0]);
1004
+ }
1005
+ };
1006
+ const handleUpload = async () => {
1007
+ if (!file) {
1008
+ console.error("No file selected");
1009
+ return;
1010
+ }
1011
+ };
1012
+ return /* @__PURE__ */ import_react29.default.createElement("div", { style: { marginTop: 16 } }, /* @__PURE__ */ import_react29.default.createElement("input", { type: "file", onChange: handleFileChange }), /* @__PURE__ */ import_react29.default.createElement(
1013
+ "button",
1014
+ {
1015
+ type: "button",
1016
+ onClick: handleUpload,
1017
+ disabled: !file,
1018
+ style: { marginTop: 16 }
1019
+ },
1020
+ "Upload"
1021
+ ));
1022
+ };
934
1023
  // Annotate the CommonJS export names for ESM import in node:
935
1024
  0 && (module.exports = {
936
1025
  AddMoreTable,
@@ -951,8 +1040,10 @@ var TabsElement = (props) => {
951
1040
  Sidebar,
952
1041
  SingleCheckbox,
953
1042
  SingleSelectElement,
1043
+ SwitchElement,
954
1044
  TableElement,
955
1045
  TabsElement,
956
1046
  TextElement,
957
- TextareaElement
1047
+ TextareaElement,
1048
+ Upload
958
1049
  });
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,
@@ -316,26 +316,92 @@ var MultipleSelectElement = (props) => {
316
316
  };
317
317
 
318
318
  // src/Components/Button.tsx
319
- import React11 from "react";
319
+ import React11, { useEffect, useState as useState4 } from "react";
320
320
  var ButtonElement = (props) => {
321
+ const [svgContent, setSvgContent] = useState4(null);
322
+ const [hoverColor, setHoverColor] = useState4(null);
323
+ useEffect(() => {
324
+ if (props.icon) {
325
+ fetch(props.icon).then((response) => response.text()).then((data) => {
326
+ const tempDiv = document.createElement("div");
327
+ tempDiv.innerHTML = data;
328
+ const svgElement = tempDiv.querySelector("svg");
329
+ if (svgElement) {
330
+ const textColorClass = props.className?.match(/text-[\w-]+/g)?.[0];
331
+ const hoverColorClass = props.className?.match(/hover:text-[\w-]+/g)?.[0];
332
+ if (textColorClass) {
333
+ const tempSpan = document.createElement("span");
334
+ tempSpan.className = textColorClass;
335
+ document.body.appendChild(tempSpan);
336
+ const computedColor = getComputedStyle(tempSpan).color;
337
+ document.body.removeChild(tempSpan);
338
+ const paths = svgElement.querySelectorAll("path");
339
+ paths.forEach((path) => path.setAttribute("fill", computedColor));
340
+ }
341
+ if (hoverColorClass) {
342
+ const tempSpan = document.createElement("span");
343
+ tempSpan.className = hoverColorClass.replace("hover:", "");
344
+ document.body.appendChild(tempSpan);
345
+ const computedHoverColor = getComputedStyle(tempSpan).color;
346
+ document.body.removeChild(tempSpan);
347
+ setHoverColor(computedHoverColor);
348
+ console.log("hoverColor", hoverColor);
349
+ }
350
+ svgElement.setAttribute(
351
+ "class",
352
+ `${props.className ? props.className : ""}`
353
+ );
354
+ setSvgContent(tempDiv.innerHTML);
355
+ }
356
+ }).catch((error) => console.error("Error fetching SVG:", error));
357
+ }
358
+ }, [props.icon, props.className]);
359
+ const handleMouseEnter = () => {
360
+ if (hoverColor && svgContent) {
361
+ const tempDiv = document.createElement("div");
362
+ tempDiv.innerHTML = svgContent;
363
+ const svgElement = tempDiv.querySelector("svg");
364
+ const paths = svgElement?.querySelectorAll("path");
365
+ paths?.forEach((path) => path.setAttribute("fill", hoverColor));
366
+ setSvgContent(tempDiv.innerHTML);
367
+ }
368
+ };
369
+ const handleMouseLeave = () => {
370
+ if (svgContent) {
371
+ const tempDiv = document.createElement("div");
372
+ tempDiv.innerHTML = svgContent;
373
+ const svgElement = tempDiv.querySelector("svg");
374
+ const paths = svgElement?.querySelectorAll("path");
375
+ paths?.forEach((path) => path.removeAttribute("fill"));
376
+ setSvgContent(tempDiv.innerHTML);
377
+ }
378
+ };
321
379
  return /* @__PURE__ */ React11.createElement(
322
380
  "button",
323
381
  {
324
- onClick: () => props.onClick && props.onClick(),
325
- className: `${props.className ? props.className : ""}`
382
+ onClick: props.onClick,
383
+ className: `${props.className ? props.className : ""}`,
384
+ onMouseEnter: handleMouseEnter,
385
+ onMouseLeave: handleMouseLeave
326
386
  },
327
- props.icon && /* @__PURE__ */ React11.createElement("img", { className: props.iconsClassName, src: props.icon }),
387
+ props.isSVGStylesOverride ? svgContent && /* @__PURE__ */ React11.createElement(
388
+ "span",
389
+ {
390
+ className: "svg-container",
391
+ dangerouslySetInnerHTML: { __html: svgContent }
392
+ }
393
+ ) : props.icon && /* @__PURE__ */ React11.createElement("img", { className: props.iconsClassName, src: props.icon }),
328
394
  props.label
329
395
  );
330
396
  };
331
397
 
332
398
  // src/Components/AddMoreTable.tsx
333
- import React12, { useEffect, useState as useState4 } from "react";
399
+ import React12, { useEffect as useEffect2, useState as useState5 } from "react";
334
400
  import { Table, Button } from "antd";
335
401
  import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
336
402
  var AddMoreTable = (props) => {
337
403
  const { thead, tbody } = props;
338
- const [rows, setRows] = useState4(tbody || []);
404
+ const [rows, setRows] = useState5(tbody || []);
339
405
  const onHandleRows = () => {
340
406
  const newId = rows.length > 0 ? rows[rows.length - 1].id + 1 : 1;
341
407
  let newRow = {
@@ -400,16 +466,16 @@ var AddMoreTable = (props) => {
400
466
  });
401
467
  });
402
468
  };
403
- useEffect(() => {
469
+ useEffect2(() => {
404
470
  console.log(rows);
405
471
  }, [rows]);
406
472
  const renderInputElement = (element, value) => {
407
473
  if (!element) return null;
408
474
  const { element: type, label } = element;
409
475
  if (type === "single-select") {
410
- return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
476
+ return /* @__PURE__ */ React12.createElement(SingleSelectElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [], firstOptions: [], secondOptions: [] });
411
477
  } else if (type === "textarea") {
412
- return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false });
478
+ return /* @__PURE__ */ React12.createElement(TextareaElement, { onChange: (value2) => console.log(label, value2), optionType: "", className: void 0, selectedStyle: false, style: false, options1: [], options2: [], firstOptions: [], secondOptions: [] });
413
479
  } else {
414
480
  return null;
415
481
  }
@@ -535,8 +601,8 @@ var Navbar = (props) => {
535
601
  };
536
602
 
537
603
  // src/Components/TableElement.tsx
538
- import React20, { useState as useState5 } from "react";
539
- import { Button as Button3, Table as Table2 } from "antd";
604
+ import React20, { useState as useState6 } from "react";
605
+ import { Table as Table2 } from "antd";
540
606
 
541
607
  // src/Components/Model.tsx
542
608
  import React19 from "react";
@@ -593,9 +659,9 @@ var ModelElement = (props) => {
593
659
  // src/Components/TableElement.tsx
594
660
  var TableElement = (props) => {
595
661
  const { thead, tbody } = props;
596
- const [selectedRecord, setSelectedRecord] = useState5({});
597
- const [model, setModel] = useState5(false);
598
- const [selectedRowKeys, setSelectedRowKeys] = useState5([]);
662
+ const [selectedRecord, setSelectedRecord] = useState6({});
663
+ const [model, setModel] = useState6(false);
664
+ const [selectedRowKeys, setSelectedRowKeys] = useState6([]);
599
665
  const handleChange = (record) => {
600
666
  console.log("record", record);
601
667
  if (props.onChange) {
@@ -610,12 +676,6 @@ var TableElement = (props) => {
610
676
  dataIndex: "#",
611
677
  key: "#"
612
678
  },
613
- {
614
- title: "View",
615
- dataIndex: "View",
616
- key: "View",
617
- render: (_, record) => /* @__PURE__ */ React20.createElement(Button3, null, "View")
618
- },
619
679
  ...thead.map((col, ind) => ({
620
680
  title: col.label,
621
681
  dataIndex: col.name,
@@ -632,6 +692,24 @@ var TableElement = (props) => {
632
692
  }
633
693
  }))
634
694
  ];
695
+ if (props.view) {
696
+ columns.push({
697
+ title: "View",
698
+ dataIndex: "View",
699
+ key: "View",
700
+ render: (_, record) => /* @__PURE__ */ React20.createElement(
701
+ "a",
702
+ {
703
+ onClick: () => {
704
+ setSelectedRecord(record);
705
+ handleChange(record);
706
+ setModel(true);
707
+ }
708
+ },
709
+ "View"
710
+ )
711
+ });
712
+ }
635
713
  }
636
714
  const dataSource = tbody && tbody.map((row, index) => ({
637
715
  ...row,
@@ -664,77 +742,48 @@ var TableElement = (props) => {
664
742
  columns,
665
743
  bordered: true,
666
744
  rowSelection: rowSelectionConfig,
667
- size: props.size && props.size,
668
- onRow: (record) => {
669
- return {
670
- onClick: () => {
671
- setSelectedRecord(record);
672
- handleChange(record);
673
- setModel(true);
674
- },
675
- style: { cursor: "pointer" }
676
- };
677
- }
745
+ size: props.size && props.size
678
746
  }
679
747
  ), model && /* @__PURE__ */ React20.createElement(ModelElement, { selectedRecord, ...props, columns, model, onCancel: () => setModel(false) }));
680
748
  };
681
749
 
682
750
  // src/Components/DatePicker.tsx
683
- import React21, { useState as useState6 } from "react";
751
+ import React21, { useState as useState7 } from "react";
684
752
  import { DatePicker } from "antd";
685
- import { LeftOutlined, RightOutlined } from "@ant-design/icons";
686
- import moment from "moment";
753
+ import dayjs from "dayjs";
754
+ import customParseFormat from "dayjs/plugin/customParseFormat.js";
755
+ dayjs.extend(customParseFormat);
687
756
  var DatePickerElement = (props) => {
688
- const [date, setDate] = useState6(null);
689
- const handleChange = (date2, dateString) => {
690
- console.log("date---------", date2);
691
- console.log("datestring", dateString);
692
- if (date2) {
693
- const formattedDate = dateString;
694
- console.log("formattedDate-----------------", formattedDate);
695
- setDate(date2);
696
- console.log("changedDate------------", date2);
757
+ const [dateState, setDateState] = useState7("");
758
+ const handleChange = (date, dateString) => {
759
+ if (date) {
760
+ const formattedDate = date;
761
+ setDateState(date);
697
762
  if (props.onChange) {
698
763
  props.onChange(formattedDate);
699
764
  }
700
765
  } else {
701
- setDate(null);
766
+ setDateState("");
702
767
  if (props.onChange) {
703
768
  props.onChange("");
704
769
  }
705
770
  }
706
771
  };
707
- const onHandleDecrement = () => {
708
- const currentDate = date || moment();
709
- const newDate = moment(currentDate).subtract(1, "days");
710
- setDate(newDate);
711
- if (props.onChange) {
712
- props.onChange(newDate.format("lll"));
713
- }
714
- };
715
- const onHandleIncrement = () => {
716
- const currentDate = date || moment();
717
- const newDate = moment(currentDate).add(1, "days");
718
- setDate(newDate);
719
- if (props.onChange) {
720
- props.onChange(newDate.format("lll"));
721
- }
722
- };
723
- return /* @__PURE__ */ React21.createElement("div", null, /* @__PURE__ */ React21.createElement("button", { onClick: onHandleDecrement }, /* @__PURE__ */ React21.createElement(LeftOutlined, null)), /* @__PURE__ */ React21.createElement(
772
+ return /* @__PURE__ */ React21.createElement("div", null, /* @__PURE__ */ React21.createElement(
724
773
  DatePicker,
725
774
  {
726
775
  placeholder: props.placeholder,
727
- value: date,
728
- variant: "borderless",
776
+ value: dateState,
777
+ format: { format: "DD-MM-YYYY" },
729
778
  onChange: handleChange
730
779
  }
731
- ), /* @__PURE__ */ React21.createElement("button", { onClick: onHandleIncrement }, /* @__PURE__ */ React21.createElement(RightOutlined, null)));
780
+ ));
732
781
  };
733
782
 
734
783
  // src/Components/DateRangePickerElement.tsx
735
784
  import React22 from "react";
736
785
  import { DatePicker as DatePicker2, Space } from "antd";
737
- import dayjs from "dayjs";
786
+ import dayjs2 from "dayjs";
738
787
  var DateRangePickerElement = (props) => {
739
788
  const { RangePicker } = DatePicker2;
740
789
  const handleChange = (dates, dateStrings) => {
@@ -745,10 +794,10 @@ var DateRangePickerElement = (props) => {
745
794
  }
746
795
  };
747
796
  const rangePresets = [
748
- { label: "Last 7 Days", value: [dayjs().add(-7, "d"), dayjs()] },
749
- { label: "Last 14 Days", value: [dayjs().add(-14, "d"), dayjs()] },
750
- { label: "Last 30 Days", value: [dayjs().add(-30, "d"), dayjs()] },
751
- { label: "Last 90 Days", value: [dayjs().add(-90, "d"), dayjs()] }
797
+ { label: "Last 7 Days", value: [dayjs2().add(-7, "d"), dayjs2()] },
798
+ { label: "Last 14 Days", value: [dayjs2().add(-14, "d"), dayjs2()] },
799
+ { label: "Last 30 Days", value: [dayjs2().add(-30, "d"), dayjs2()] },
800
+ { label: "Last 90 Days", value: [dayjs2().add(-90, "d"), dayjs2()] }
752
801
  ];
753
802
  return /* @__PURE__ */ React22.createElement(Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ React22.createElement(RangePicker, { presets: rangePresets, onChange: handleChange }));
754
803
  };
@@ -756,7 +805,7 @@ var DateRangePickerElement = (props) => {
756
805
  // src/Components/Image.tsx
757
806
  import React23 from "react";
758
807
  var Image = (props) => {
759
- return /* @__PURE__ */ React23.createElement("div", null, /* @__PURE__ */ React23.createElement("img", { className: props.className, src: props.img, alt: "image" }));
808
+ return /* @__PURE__ */ React23.createElement("img", { className: props.className, src: props.img, alt: "image" });
760
809
  };
761
810
 
762
811
  // src/Components/SingleCheckbox.tsx
@@ -772,36 +821,47 @@ var SingleCheckbox = (props) => {
772
821
  };
773
822
 
774
823
  // src/Components/DropDownGroup.tsx
775
- import React25, { useState as useState7 } from "react";
824
+ import React25, { useState as useState8 } from "react";
776
825
  import { Select as Select4 } from "antd";
777
826
  var DropDownGroup = (props) => {
778
- const [selectedValue, setSelectedValue] = useState7({ firstValue: {}, secondValue: {} });
827
+ const [selectedValue, setSelectedValue] = useState8({
828
+ firstValue: {},
829
+ secondValue: {},
830
+ temp: ""
831
+ });
779
832
  const handleFirstChange = (value) => {
780
- const filterOption2 = props.options?.find((eachOption) => eachOption.value === value);
833
+ console.log(selectedValue.temp);
834
+ const filterOption2 = props.firstOptions?.find(
835
+ (eachOption) => eachOption.value === value
836
+ );
781
837
  setSelectedValue((prev) => {
782
838
  const newValue = { ...prev, firstValue: filterOption2 };
839
+ const { temp, ...rest } = newValue;
783
840
  if (newValue.firstValue) {
784
- props.onChange?.(newValue);
841
+ props.onChange?.(rest);
785
842
  }
786
- return selectedValue;
843
+ return newValue;
787
844
  });
788
845
  };
789
846
  const handleSecondChange = (value) => {
790
- const filterOption2 = props.options?.find((eachOption) => eachOption.value === value);
847
+ const filterOption2 = props.secondOptions?.find(
848
+ (eachOption) => eachOption.value === value
849
+ );
791
850
  setSelectedValue((prev) => {
792
851
  const newValue = { ...prev, secondValue: filterOption2 };
852
+ const { temp, ...rest } = newValue;
793
853
  if (newValue.secondValue) {
794
- props.onChange?.(newValue);
854
+ props.onChange?.(rest);
795
855
  }
796
- return selectedValue;
856
+ return newValue;
797
857
  });
798
858
  };
799
- return /* @__PURE__ */ React25.createElement("div", { className: props.containerClassName }, /* @__PURE__ */ React25.createElement(
859
+ 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(
800
860
  Select4,
801
861
  {
802
862
  onChange: handleFirstChange,
803
863
  variant: props.variant,
804
- options: props.options,
864
+ options: props.firstOptions,
805
865
  className: props.className
806
866
  }
807
867
  ), /* @__PURE__ */ React25.createElement("div", { style: { borderLeft: "1px solid gray", height: "33px" } }), /* @__PURE__ */ React25.createElement(
@@ -809,27 +869,19 @@ var DropDownGroup = (props) => {
809
869
  {
810
870
  onChange: handleSecondChange,
811
871
  variant: props.variant,
812
- options: props.options,
872
+ options: props.secondOptions,
813
873
  className: props.className
814
874
  }
815
- ));
875
+ )));
816
876
  };
817
877
 
818
878
  // src/Components/FilesUpload.tsx
819
- import React26, { useState as useState8 } from "react";
820
- import { Upload, message } from "antd";
879
+ import React26, { useState as useState9 } from "react";
880
+ import { Upload } from "antd";
821
881
  import { InboxOutlined } from "@ant-design/icons";
822
882
  var FileUpload = (props) => {
823
883
  const { Dragger } = Upload;
824
- const [files, setFiles] = useState8([]);
825
- const beforeUpload = (file) => {
826
- const isCorrectFile = ["image/png", "image/jpg", "image/jpeg", "application/pdf"].includes(file.type);
827
- if (!isCorrectFile) {
828
- message.error(`(${file.name}) is an invalid file. Please upload files with the following extensions only (.png/.jpg/.jpeg/.pdf)`);
829
- return Upload.LIST_IGNORE;
830
- }
831
- return true;
832
- };
884
+ const [files, setFiles] = useState9([]);
833
885
  const handleChange = ({ fileList }) => {
834
886
  setFiles(fileList);
835
887
  if (props.onChange) {
@@ -853,7 +905,6 @@ var FileUpload = (props) => {
853
905
  maxCount: props.max_count,
854
906
  multiple: props.multiple,
855
907
  fileList: files,
856
- beforeUpload,
857
908
  onChange: handleChange,
858
909
  showUploadList: true,
859
910
  customRequest
@@ -874,6 +925,42 @@ var TabsElement = (props) => {
874
925
  };
875
926
  return /* @__PURE__ */ React27.createElement(Tabs, { className: props.containerClassName, items: props.options, onChange: handleChange });
876
927
  };
928
+
929
+ // src/Components/SwitchElement.tsx
930
+ import React28 from "react";
931
+ import { Switch } from "antd";
932
+ var onChange = (checked) => {
933
+ console.log(`switch to ${checked}`);
934
+ };
935
+ var SwitchElement = () => /* @__PURE__ */ React28.createElement(Switch, { defaultChecked: true, onChange });
936
+
937
+ // src/Components/Upload.tsx
938
+ import React29, { useState as useState10 } from "react";
939
+ var Upload2 = (props) => {
940
+ const [file, setFile] = useState10();
941
+ const handleFileChange = (e) => {
942
+ setFile(e.target.files[0]);
943
+ if (props.onChange) {
944
+ props.onChange(e.target.files[0]);
945
+ }
946
+ };
947
+ const handleUpload = async () => {
948
+ if (!file) {
949
+ console.error("No file selected");
950
+ return;
951
+ }
952
+ };
953
+ return /* @__PURE__ */ React29.createElement("div", { style: { marginTop: 16 } }, /* @__PURE__ */ React29.createElement("input", { type: "file", onChange: handleFileChange }), /* @__PURE__ */ React29.createElement(
954
+ "button",
955
+ {
956
+ type: "button",
957
+ onClick: handleUpload,
958
+ disabled: !file,
959
+ style: { marginTop: 16 }
960
+ },
961
+ "Upload"
962
+ ));
963
+ };
877
964
  export {
878
965
  AddMoreTable,
879
966
  ButtonElement,
@@ -893,8 +980,10 @@ export {
893
980
  Sidebar,
894
981
  SingleCheckbox,
895
982
  SingleSelectElement,
983
+ SwitchElement,
896
984
  TableElement,
897
985
  TabsElement,
898
986
  TextElement,
899
- TextareaElement
987
+ TextareaElement,
988
+ Upload2 as Upload
900
989
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.14-Beta5",
3
+ "version": "0.0.14-Beta50",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",
@@ -48,8 +48,6 @@
48
48
  "node": ">=18.0.0"
49
49
  },
50
50
  "dependencies": {
51
- "@apexcura/core": "^0.0.15-Beta34",
52
- "@apexcura/ui-components": "^0.0.11-Beta256",
53
51
  "@tinymce/tinymce-react": "^5.0.1",
54
52
  "autoprefixer": "^10.4.19",
55
53
  "date-fns": "^3.6.0",