@algorithm-shift/design-system 1.2.968 → 1.2.969

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
@@ -39,7 +39,7 @@ __export(src_exports, {
39
39
  ButtonGroup: () => SplitButton,
40
40
  Checkbox: () => Checkbox_default,
41
41
  Container: () => Container_default,
42
- DatePicker: () => DatePicker,
42
+ DatePicker: () => DateTimePicker,
43
43
  DateRange: () => DateRange_default,
44
44
  Dropdown: () => Dropdown_default,
45
45
  Email: () => EmailInput_default,
@@ -28458,82 +28458,13 @@ var FileInput2 = ({ className, style, ...props }) => {
28458
28458
  var FileInput_default = FileInput2;
28459
28459
 
28460
28460
  // src/components/Inputs/DatePicker/DatePicker.tsx
28461
- var import_react26 = require("react");
28462
- var import_jsx_runtime43 = require("react/jsx-runtime");
28463
- function DatePicker({ className, style, ...props }) {
28464
- const placeholder = props.placeholder ?? "Placeholder text";
28465
- const minimumDate = props.minimumDate ?? "none";
28466
- const customMinimumDate = props.customMinimumDate ?? "";
28467
- const maximumDate = props.maximumDate ?? "none";
28468
- const customMaximumDate = props.customMaximumDate ?? "";
28469
- const isEditable = props.isEditable ?? true;
28470
- const isDisabled = props.isDisabled ?? false;
28471
- const isReadonly = props.isReadonly ?? false;
28472
- const isAutocomplete = props.isAutocomplete ?? false;
28473
- const resolveDate = (option, customOption) => {
28474
- if (!option) return void 0;
28475
- switch (option) {
28476
- case "today":
28477
- return (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
28478
- case "custom":
28479
- return customOption ?? void 0;
28480
- case "none":
28481
- default:
28482
- return void 0;
28483
- }
28484
- };
28485
- const minDate = resolveDate(minimumDate, customMinimumDate);
28486
- const maxDate = resolveDate(maximumDate, customMaximumDate);
28487
- (0, import_react26.useEffect)(() => {
28488
- if (props.value !== void 0) {
28489
- handleChange(props.value);
28490
- }
28491
- }, []);
28492
- const handleChange = (e) => {
28493
- props.onChange?.(e, props?.name || "");
28494
- };
28495
- const toDateInputValue = (value) => {
28496
- if (!value) return "";
28497
- return new Date(value).toISOString().split("T")[0];
28498
- };
28499
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
28500
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "flex justify-start items-center relative", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
28501
- Input,
28502
- {
28503
- type: "date",
28504
- id: "date",
28505
- autoComplete: isAutocomplete ? "on" : "off",
28506
- onChange: handleChange,
28507
- disabled: isDisabled || !isEditable,
28508
- name: props.name,
28509
- value: toDateInputValue(props.value),
28510
- className: cn(
28511
- className,
28512
- props.errorMessage ? "border-red-500" : "",
28513
- "appearance-auto"
28514
- ),
28515
- style: {
28516
- ...style,
28517
- borderColor: props.errorMessage ? "#f87171" : style?.borderColor
28518
- },
28519
- readOnly: isReadonly,
28520
- placeholder,
28521
- min: minDate,
28522
- max: maxDate
28523
- }
28524
- ) }),
28525
- props.errorMessage && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { className: "mt-1 text-xs text-red-500", children: props.errorMessage })
28526
- ] });
28527
- }
28528
-
28529
- // src/components/Inputs/DateRange/DateRange.tsx
28530
- var import_react27 = __toESM(require("react"));
28461
+ var React6 = __toESM(require("react"));
28531
28462
  var import_date_fns = require("date-fns");
28532
28463
 
28533
28464
  // src/components/ui/calendar.tsx
28534
- var React6 = __toESM(require("react"));
28465
+ var React5 = __toESM(require("react"));
28535
28466
  var import_react_day_picker = require("react-day-picker");
28536
- var import_jsx_runtime44 = require("react/jsx-runtime");
28467
+ var import_jsx_runtime43 = require("react/jsx-runtime");
28537
28468
  function Calendar2({
28538
28469
  className,
28539
28470
  classNames,
@@ -28545,7 +28476,7 @@ function Calendar2({
28545
28476
  ...props
28546
28477
  }) {
28547
28478
  const defaultClassNames = (0, import_react_day_picker.getDefaultClassNames)();
28548
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
28479
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
28549
28480
  import_react_day_picker.DayPicker,
28550
28481
  {
28551
28482
  showOutsideDays,
@@ -28644,7 +28575,7 @@ function Calendar2({
28644
28575
  },
28645
28576
  components: {
28646
28577
  Root: ({ className: className2, rootRef, ...props2 }) => {
28647
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
28578
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
28648
28579
  "div",
28649
28580
  {
28650
28581
  "data-slot": "calendar",
@@ -28656,10 +28587,10 @@ function Calendar2({
28656
28587
  },
28657
28588
  Chevron: ({ className: className2, orientation, ...props2 }) => {
28658
28589
  if (orientation === "left") {
28659
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ChevronLeft, { className: cn("size-4", className2), ...props2 });
28590
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ChevronLeft, { className: cn("size-4", className2), ...props2 });
28660
28591
  }
28661
28592
  if (orientation === "right") {
28662
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
28593
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
28663
28594
  ChevronRight,
28664
28595
  {
28665
28596
  className: cn("size-4", className2),
@@ -28667,11 +28598,11 @@ function Calendar2({
28667
28598
  }
28668
28599
  );
28669
28600
  }
28670
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ChevronDown, { className: cn("size-4", className2), ...props2 });
28601
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ChevronDown, { className: cn("size-4", className2), ...props2 });
28671
28602
  },
28672
28603
  DayButton: CalendarDayButton,
28673
28604
  WeekNumber: ({ children, ...props2 }) => {
28674
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("td", { ...props2, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children }) });
28605
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("td", { ...props2, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children }) });
28675
28606
  },
28676
28607
  ...components
28677
28608
  },
@@ -28686,11 +28617,11 @@ function CalendarDayButton({
28686
28617
  ...props
28687
28618
  }) {
28688
28619
  const defaultClassNames = (0, import_react_day_picker.getDefaultClassNames)();
28689
- const ref = React6.useRef(null);
28690
- React6.useEffect(() => {
28620
+ const ref = React5.useRef(null);
28621
+ React5.useEffect(() => {
28691
28622
  if (modifiers.focused) ref.current?.focus();
28692
28623
  }, [modifiers.focused]);
28693
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
28624
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
28694
28625
  Button,
28695
28626
  {
28696
28627
  ref,
@@ -28713,16 +28644,16 @@ function CalendarDayButton({
28713
28644
 
28714
28645
  // src/components/ui/popover.tsx
28715
28646
  var PopoverPrimitive = __toESM(require("@radix-ui/react-popover"));
28716
- var import_jsx_runtime45 = require("react/jsx-runtime");
28647
+ var import_jsx_runtime44 = require("react/jsx-runtime");
28717
28648
  function Popover({
28718
28649
  ...props
28719
28650
  }) {
28720
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
28651
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
28721
28652
  }
28722
28653
  function PopoverTrigger({
28723
28654
  ...props
28724
28655
  }) {
28725
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
28656
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
28726
28657
  }
28727
28658
  function PopoverContent({
28728
28659
  className,
@@ -28730,7 +28661,7 @@ function PopoverContent({
28730
28661
  sideOffset = 4,
28731
28662
  ...props
28732
28663
  }) {
28733
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(PopoverPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
28664
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PopoverPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
28734
28665
  PopoverPrimitive.Content,
28735
28666
  {
28736
28667
  "data-slot": "popover-content",
@@ -28745,17 +28676,319 @@ function PopoverContent({
28745
28676
  ) });
28746
28677
  }
28747
28678
 
28679
+ // src/components/Inputs/DatePicker/DatePicker.tsx
28680
+ var import_jsx_runtime45 = require("react/jsx-runtime");
28681
+ function resolveDate(option, customOption) {
28682
+ if (!option) return void 0;
28683
+ switch (option) {
28684
+ case "today":
28685
+ return /* @__PURE__ */ new Date();
28686
+ case "custom":
28687
+ return customOption ? new Date(customOption) : void 0;
28688
+ case "none":
28689
+ default:
28690
+ return void 0;
28691
+ }
28692
+ }
28693
+ function DateTimePicker({
28694
+ className,
28695
+ style,
28696
+ mode = "date",
28697
+ ...props
28698
+ }) {
28699
+ const placeholderMap = {
28700
+ date: "Select date",
28701
+ datetime: "Select date & time",
28702
+ time: "Select time"
28703
+ };
28704
+ const placeholder = props.placeholder ?? placeholderMap[mode];
28705
+ const minimumDate = props.minimumDate ?? "none";
28706
+ const customMinimumDate = props.customMinimumDate ?? "";
28707
+ const maximumDate = props.maximumDate ?? "none";
28708
+ const customMaximumDate = props.customMaximumDate ?? "";
28709
+ const isEditable = props.isEditable ?? true;
28710
+ const isDisabled = props.isDisabled ?? false;
28711
+ const isReadonly = props.isReadonly ?? false;
28712
+ const isAutocomplete = props.isAutocomplete ?? false;
28713
+ const minDate = resolveDate(minimumDate, customMinimumDate);
28714
+ const maxDate = resolveDate(maximumDate, customMaximumDate);
28715
+ const [date, setDate] = React6.useState(() => {
28716
+ if (!props.value) return void 0;
28717
+ const d = new Date(props.value);
28718
+ return isNaN(d.getTime()) ? void 0 : d;
28719
+ });
28720
+ const initialHours = date ? date.getHours() : 0;
28721
+ const initialMinutes = date ? date.getMinutes() : 0;
28722
+ const [hours, setHours] = React6.useState(initialHours);
28723
+ const [minutes, setMinutes] = React6.useState(initialMinutes);
28724
+ const [amPm, setAmPm] = React6.useState("AM");
28725
+ const displayHours = React6.useMemo(() => {
28726
+ if (hours === 0) return 12;
28727
+ if (hours > 12) return hours - 12;
28728
+ return hours;
28729
+ }, [hours]);
28730
+ React6.useEffect(() => {
28731
+ setAmPm(hours >= 12 ? "PM" : "AM");
28732
+ }, [hours]);
28733
+ React6.useEffect(() => {
28734
+ if (!props.value) {
28735
+ setDate(void 0);
28736
+ return;
28737
+ }
28738
+ const d = new Date(props.value);
28739
+ if (!isNaN(d.getTime())) {
28740
+ setDate(d);
28741
+ setHours(d.getHours());
28742
+ setMinutes(d.getMinutes());
28743
+ }
28744
+ }, [props.value]);
28745
+ const [year, setYear] = React6.useState(date ? date.getFullYear() : (/* @__PURE__ */ new Date()).getFullYear());
28746
+ React6.useEffect(() => {
28747
+ if (!date) return;
28748
+ const newDate = new Date(date);
28749
+ newDate.setFullYear(year);
28750
+ setDate(newDate);
28751
+ emitChange(newDate);
28752
+ }, [year]);
28753
+ const emitChange = (nextDate) => {
28754
+ if (!props.onChange) return;
28755
+ let valueString = "";
28756
+ if (!nextDate) {
28757
+ valueString = "";
28758
+ } else if (mode === "date") {
28759
+ valueString = (0, import_date_fns.format)(nextDate, "yyyy-MM-dd");
28760
+ } else if (mode === "time") {
28761
+ valueString = (0, import_date_fns.format)(nextDate, "HH:mm:ss");
28762
+ } else {
28763
+ valueString = nextDate.toISOString();
28764
+ }
28765
+ const target = {
28766
+ name: props.name || "",
28767
+ value: valueString
28768
+ };
28769
+ const event = {
28770
+ target
28771
+ };
28772
+ props.onChange(event, props.name || "");
28773
+ };
28774
+ const updateDateTime = (nextBaseDate, h = hours, m = minutes) => {
28775
+ if (!nextBaseDate) {
28776
+ setDate(void 0);
28777
+ emitChange(void 0);
28778
+ return;
28779
+ }
28780
+ const d = new Date(nextBaseDate);
28781
+ if (mode !== "date") {
28782
+ d.setHours(h);
28783
+ d.setMinutes(m);
28784
+ d.setSeconds(0);
28785
+ d.setMilliseconds(0);
28786
+ } else {
28787
+ d.setHours(0, 0, 0, 0);
28788
+ }
28789
+ if (minDate && d < minDate) return;
28790
+ if (maxDate && d > maxDate) return;
28791
+ setDate(d);
28792
+ setYear(d.getFullYear());
28793
+ emitChange(d);
28794
+ };
28795
+ const handleDaySelect = (next) => {
28796
+ if (!next) {
28797
+ setDate(void 0);
28798
+ emitChange(void 0);
28799
+ return;
28800
+ }
28801
+ const clickedDate = new Date(next);
28802
+ const selectedYearDate = new Date(year, clickedDate.getMonth(), clickedDate.getDate());
28803
+ updateDateTime(selectedYearDate);
28804
+ };
28805
+ const updateTimeInDate = (h, m) => {
28806
+ if (!date) {
28807
+ const fallbackDate = /* @__PURE__ */ new Date();
28808
+ fallbackDate.setHours(h);
28809
+ fallbackDate.setMinutes(m);
28810
+ fallbackDate.setSeconds(0);
28811
+ fallbackDate.setMilliseconds(0);
28812
+ setDate(fallbackDate);
28813
+ emitChange(fallbackDate);
28814
+ } else {
28815
+ const newDate = new Date(date);
28816
+ newDate.setHours(h);
28817
+ newDate.setMinutes(m);
28818
+ newDate.setSeconds(0);
28819
+ newDate.setMilliseconds(0);
28820
+ setDate(newDate);
28821
+ emitChange(newDate);
28822
+ }
28823
+ };
28824
+ const handleHoursChange = (e) => {
28825
+ let h = Number(e.target.value);
28826
+ if (amPm === "PM" && h < 12) h += 12;
28827
+ if (amPm === "AM" && h === 12) h = 0;
28828
+ setHours(h);
28829
+ updateTimeInDate(h, minutes);
28830
+ };
28831
+ const handleMinutesChange = (e) => {
28832
+ const m = Number(e.target.value);
28833
+ setMinutes(m);
28834
+ updateTimeInDate(hours, m);
28835
+ };
28836
+ const handleAmPmChange = (e) => {
28837
+ const val = e.target.value;
28838
+ setAmPm(val);
28839
+ let h = displayHours;
28840
+ if (val === "PM" && h < 12) h += 12;
28841
+ if (val === "AM" && h === 12) h = 0;
28842
+ setHours(h);
28843
+ updateTimeInDate(h, minutes);
28844
+ };
28845
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
28846
+ const yearOptions = [];
28847
+ for (let y = currentYear - 50; y <= currentYear + 10; y++) {
28848
+ yearOptions.push(y);
28849
+ }
28850
+ const displayValue = React6.useMemo(() => {
28851
+ if (!date) return "";
28852
+ try {
28853
+ if (mode === "date") return (0, import_date_fns.format)(date, "yyyy-MM-dd");
28854
+ if (mode === "time") return (0, import_date_fns.format)(date, "hh:mm aa");
28855
+ return (0, import_date_fns.format)(date, "yyyy-MM-dd hh:mm aa");
28856
+ } catch {
28857
+ return "";
28858
+ }
28859
+ }, [date, mode]);
28860
+ const isInputDisabled = isDisabled || !isEditable;
28861
+ const [calendarMonthState, setCalendarMonthState] = React6.useState(() => {
28862
+ return date ? new Date(date.getFullYear(), date.getMonth()) : new Date(year, 0);
28863
+ });
28864
+ React6.useEffect(() => {
28865
+ setCalendarMonthState(new Date(year, calendarMonthState.getMonth()));
28866
+ }, [year]);
28867
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex flex-col", children: [
28868
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(Popover, { children: [
28869
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
28870
+ Button,
28871
+ {
28872
+ type: "button",
28873
+ variant: "outline",
28874
+ className: cn(
28875
+ "w-full justify-start text-left font-normal",
28876
+ !date && "text-muted-foreground",
28877
+ props.errorMessage && "border-red-500",
28878
+ className
28879
+ ),
28880
+ style: {
28881
+ ...style,
28882
+ borderColor: props.errorMessage ? "#f87171" : style?.borderColor
28883
+ },
28884
+ disabled: isInputDisabled,
28885
+ children: displayValue || placeholder
28886
+ }
28887
+ ) }),
28888
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(PopoverContent, { className: "w-auto text-sm p-2", align: "start", style: { fontSize: "0.75rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex flex-col gap-1", children: [
28889
+ (mode === "date" || mode === "datetime") && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
28890
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex items-center justify-between gap-1", children: [
28891
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("label", { className: "text-xs text-muted-foreground", children: "Year" }),
28892
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
28893
+ "select",
28894
+ {
28895
+ className: "h-8 rounded border bg-background px-2 text-sm",
28896
+ value: year,
28897
+ onChange: (e) => setYear(Number(e.target.value)),
28898
+ disabled: isInputDisabled || isReadonly,
28899
+ children: yearOptions.map((y) => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("option", { value: y, children: y }, y))
28900
+ }
28901
+ )
28902
+ ] }),
28903
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "calendar-container", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
28904
+ Calendar2,
28905
+ {
28906
+ mode: "single",
28907
+ selected: date,
28908
+ onSelect: handleDaySelect,
28909
+ month: calendarMonthState,
28910
+ onMonthChange: (newMonth) => setCalendarMonthState(newMonth),
28911
+ disabled: (d) => {
28912
+ if (minDate && d < minDate) return true;
28913
+ if (maxDate && d > maxDate) return true;
28914
+ return false;
28915
+ },
28916
+ initialFocus: true
28917
+ }
28918
+ ) })
28919
+ ] }),
28920
+ (mode === "time" || mode === "datetime") && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex items-center gap-2 mt-0", children: [
28921
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("label", { className: "text-xs text-muted-foreground", children: "Time" }),
28922
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
28923
+ "select",
28924
+ {
28925
+ className: "h-8 rounded border bg-background px-2 text-sm",
28926
+ value: displayHours,
28927
+ onChange: handleHoursChange,
28928
+ disabled: isInputDisabled || isReadonly,
28929
+ children: Array.from({ length: 12 }, (_, i) => i + 1).map((hour) => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("option", { value: hour, children: hour.toString().padStart(2, "0") }, hour))
28930
+ }
28931
+ ),
28932
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "text-sm", children: ":" }),
28933
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
28934
+ "select",
28935
+ {
28936
+ className: "h-8 rounded border bg-background px-2 text-sm",
28937
+ value: minutes,
28938
+ onChange: handleMinutesChange,
28939
+ disabled: isInputDisabled || isReadonly,
28940
+ children: Array.from({ length: 12 }).map((_, i) => {
28941
+ const val = i * 5;
28942
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("option", { value: val, children: val.toString().padStart(2, "0") }, val);
28943
+ })
28944
+ }
28945
+ ),
28946
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
28947
+ "select",
28948
+ {
28949
+ className: "h-8 rounded border bg-background px-2 text-sm",
28950
+ value: amPm,
28951
+ onChange: handleAmPmChange,
28952
+ disabled: isInputDisabled || isReadonly,
28953
+ children: [
28954
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("option", { value: "AM", children: "AM" }),
28955
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("option", { value: "PM", children: "PM" })
28956
+ ]
28957
+ }
28958
+ )
28959
+ ] })
28960
+ ] }) })
28961
+ ] }),
28962
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
28963
+ Input,
28964
+ {
28965
+ type: "hidden",
28966
+ id: props.name,
28967
+ name: props.name,
28968
+ autoComplete: isAutocomplete ? "on" : "off",
28969
+ readOnly: isReadonly,
28970
+ value: !date ? "" : mode === "date" ? (0, import_date_fns.format)(date, "yyyy-MM-dd") : mode === "time" ? (0, import_date_fns.format)(date, "HH:mm:ss") : date.toISOString(),
28971
+ onChange: () => {
28972
+ }
28973
+ }
28974
+ ),
28975
+ props.errorMessage && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "mt-1 text-xs text-red-500", children: props.errorMessage })
28976
+ ] });
28977
+ }
28978
+
28748
28979
  // src/components/Inputs/DateRange/DateRange.tsx
28980
+ var import_react26 = __toESM(require("react"));
28981
+ var import_date_fns2 = require("date-fns");
28749
28982
  var import_jsx_runtime46 = require("react/jsx-runtime");
28750
28983
  var DateRange = ({ className, style, ...props }) => {
28751
28984
  const isDateRange = (val) => !!val && val.from instanceof Date;
28752
- const [date, setDate] = import_react27.default.useState(
28985
+ const [date, setDate] = import_react26.default.useState(
28753
28986
  isDateRange(props.value) ? props.value : {
28754
28987
  from: /* @__PURE__ */ new Date(),
28755
- to: (0, import_date_fns.addDays)(/* @__PURE__ */ new Date(), 7)
28988
+ to: (0, import_date_fns2.addDays)(/* @__PURE__ */ new Date(), 7)
28756
28989
  }
28757
28990
  );
28758
- (0, import_react27.useEffect)(() => {
28991
+ (0, import_react26.useEffect)(() => {
28759
28992
  if (props.value && isDateRange(props.value)) {
28760
28993
  handleChange?.(props.value);
28761
28994
  }
@@ -28778,11 +29011,11 @@ var DateRange = ({ className, style, ...props }) => {
28778
29011
  !date && "text-muted-foreground"
28779
29012
  ),
28780
29013
  children: date?.from ? date.to ? /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
28781
- (0, import_date_fns.format)(date.from, "LLL dd, y"),
29014
+ (0, import_date_fns2.format)(date.from, "LLL dd, y"),
28782
29015
  " -",
28783
29016
  " ",
28784
- (0, import_date_fns.format)(date.to, "LLL dd, y")
28785
- ] }) : (0, import_date_fns.format)(date.from, "LLL dd, y") : /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { children: "Pick a date range" })
29017
+ (0, import_date_fns2.format)(date.to, "LLL dd, y")
29018
+ ] }) : (0, import_date_fns2.format)(date.from, "LLL dd, y") : /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { children: "Pick a date range" })
28786
29019
  }
28787
29020
  ) }),
28788
29021
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
@@ -28802,7 +29035,7 @@ var DateRange = ({ className, style, ...props }) => {
28802
29035
  var DateRange_default = DateRange;
28803
29036
 
28804
29037
  // src/components/Inputs/TextInputGroup/TextInputGroup.tsx
28805
- var import_react28 = require("react");
29038
+ var import_react27 = require("react");
28806
29039
  var import_jsx_runtime47 = require("react/jsx-runtime");
28807
29040
  var TextInputGroup = ({ className, style, prepend, append, ...props }) => {
28808
29041
  const placeholder = props.placeholder ?? "Placeholder text";
@@ -28810,7 +29043,7 @@ var TextInputGroup = ({ className, style, prepend, append, ...props }) => {
28810
29043
  const isDisabled = props.isDisabled ?? false;
28811
29044
  const isReadonly = props.isReadonly ?? false;
28812
29045
  const isAutocomplete = props.isAutocomplete ?? false;
28813
- (0, import_react28.useEffect)(() => {
29046
+ (0, import_react27.useEffect)(() => {
28814
29047
  if (props.value !== void 0) {
28815
29048
  const e = { target: { value: props.value } };
28816
29049
  handleChange?.(e);
@@ -28863,7 +29096,7 @@ var TextInputGroup = ({ className, style, prepend, append, ...props }) => {
28863
29096
  var TextInputGroup_default = TextInputGroup;
28864
29097
 
28865
29098
  // src/components/Inputs/Multiselect/MultiSelect.tsx
28866
- var import_react29 = require("react");
29099
+ var import_react28 = require("react");
28867
29100
  var import_jsx_runtime48 = require("react/jsx-runtime");
28868
29101
  function LazyMultiSelectDropdown({
28869
29102
  options = [],
@@ -28883,10 +29116,10 @@ function LazyMultiSelectDropdown({
28883
29116
  axiosInstance,
28884
29117
  outputFormat = "array"
28885
29118
  }) {
28886
- const [isOpen, setIsOpen] = (0, import_react29.useState)(false);
28887
- const [searchTerm, setSearchTerm] = (0, import_react29.useState)("");
28888
- const dropdownRef = (0, import_react29.useRef)(null);
28889
- const observerTarget = (0, import_react29.useRef)(null);
29119
+ const [isOpen, setIsOpen] = (0, import_react28.useState)(false);
29120
+ const [searchTerm, setSearchTerm] = (0, import_react28.useState)("");
29121
+ const dropdownRef = (0, import_react28.useRef)(null);
29122
+ const observerTarget = (0, import_react28.useRef)(null);
28890
29123
  const ensureUnique = (arr) => {
28891
29124
  return Array.from(new Set(arr));
28892
29125
  };
@@ -28934,10 +29167,10 @@ function LazyMultiSelectDropdown({
28934
29167
  return unique;
28935
29168
  }
28936
29169
  };
28937
- const selectedOptions = (0, import_react29.useMemo)(() => {
29170
+ const selectedOptions = (0, import_react28.useMemo)(() => {
28938
29171
  return lazyOptions.filter((opt) => normalizedValue.includes(opt.value));
28939
29172
  }, [lazyOptions, normalizedValue]);
28940
- (0, import_react29.useEffect)(() => {
29173
+ (0, import_react28.useEffect)(() => {
28941
29174
  const handleClick = (e) => {
28942
29175
  if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
28943
29176
  setIsOpen(false);
@@ -28946,7 +29179,7 @@ function LazyMultiSelectDropdown({
28946
29179
  document.addEventListener("mousedown", handleClick);
28947
29180
  return () => document.removeEventListener("mousedown", handleClick);
28948
29181
  }, []);
28949
- (0, import_react29.useEffect)(() => {
29182
+ (0, import_react28.useEffect)(() => {
28950
29183
  if (!isOpen || !hasMore || loading) return;
28951
29184
  const obs = new IntersectionObserver(
28952
29185
  (entries) => {
@@ -29168,7 +29401,7 @@ function TableCell({ className, ...props }) {
29168
29401
  var import_react_table = require("@tanstack/react-table");
29169
29402
 
29170
29403
  // src/lib/table/cellRendererFactory.tsx
29171
- var import_react30 = __toESM(require("react"));
29404
+ var import_react29 = __toESM(require("react"));
29172
29405
  var import_image3 = __toESM(require("next/image"));
29173
29406
 
29174
29407
  // src/lib/dayjs-setup.ts
@@ -29178,14 +29411,14 @@ import_dayjs.default.extend(import_utc.default);
29178
29411
  var dayjs_setup_default = import_dayjs.default;
29179
29412
 
29180
29413
  // src/lib/table/valueFormatter.ts
29181
- var valueFormatter = (value, format2, customFormatters = {}) => {
29182
- if (!format2) return value;
29414
+ var valueFormatter = (value, format3, customFormatters = {}) => {
29415
+ if (!format3) return value;
29183
29416
  if (value == null || value === "" || value === void 0) return "-";
29184
- if (format2.startsWith("custom:")) {
29185
- const key = format2.replace("custom:", "");
29417
+ if (format3.startsWith("custom:")) {
29418
+ const key = format3.replace("custom:", "");
29186
29419
  return customFormatters[key] ? customFormatters[key](value) : value;
29187
29420
  }
29188
- const [type, arg] = format2.split(":");
29421
+ const [type, arg] = format3.split(":");
29189
29422
  switch (type) {
29190
29423
  case "date":
29191
29424
  return dayjs_setup_default(value).format(arg || "YYYY-MM-DD");
@@ -29254,9 +29487,9 @@ var getContrastColor = (bg) => {
29254
29487
  };
29255
29488
  var sanitizeValue = (val) => {
29256
29489
  if (val == null) return null;
29257
- if (import_react30.default.isValidElement(val)) return val;
29490
+ if (import_react29.default.isValidElement(val)) return val;
29258
29491
  if (typeof val === "string" || typeof val === "number") return val;
29259
- if (Array.isArray(val)) return val.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_react30.default.Fragment, { children: sanitizeValue(v) }, i));
29492
+ if (Array.isArray(val)) return val.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_react29.default.Fragment, { children: sanitizeValue(v) }, i));
29260
29493
  if (typeof val === "object") {
29261
29494
  if ("name" in val && typeof val.name === "string") return val.name;
29262
29495
  if ("label" in val && typeof val.label === "string") return val.label;
@@ -29268,8 +29501,8 @@ var sanitizeValue = (val) => {
29268
29501
  }
29269
29502
  return String(val);
29270
29503
  };
29271
- var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers = {}, format2, customFormatters = {}) => {
29272
- const formattedValue = valueFormatter(value, format2, customFormatters);
29504
+ var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers = {}, format3, customFormatters = {}) => {
29505
+ const formattedValue = valueFormatter(value, format3, customFormatters);
29273
29506
  const rowValue = row?.[rendererProps?.rowField];
29274
29507
  switch (renderer) {
29275
29508
  /* -------------------- BASIC -------------------- */
@@ -29278,7 +29511,7 @@ var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers
29278
29511
  case "number":
29279
29512
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "tabular-nums text-right", children: valueFormatter(rowValue || value, "number:2") });
29280
29513
  case "date":
29281
- return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: valueFormatter(rowValue || value, format2) });
29514
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: valueFormatter(rowValue || value, format3) });
29282
29515
  case "link":
29283
29516
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
29284
29517
  "a",
@@ -30091,7 +30324,7 @@ var CustomPagination = ({
30091
30324
  var Pagination_default = CustomPagination;
30092
30325
 
30093
30326
  // src/components/Navigation/Tabs/Tabs.tsx
30094
- var import_react31 = require("react");
30327
+ var import_react30 = require("react");
30095
30328
  var import_link5 = __toESM(require("next/link"));
30096
30329
  var import_navigation3 = require("next/navigation");
30097
30330
 
@@ -30249,7 +30482,7 @@ function showSonnerToast({
30249
30482
  // src/components/Navigation/Tabs/Tabs.tsx
30250
30483
  var import_jsx_runtime56 = require("react/jsx-runtime");
30251
30484
  var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder = false, source, parentKey, menuNameKey, menuUrlKey, loading, bgActiveColor, textActiveColor }) => {
30252
- const [openIndex, setOpenIndex] = (0, import_react31.useState)(null);
30485
+ const [openIndex, setOpenIndex] = (0, import_react30.useState)(null);
30253
30486
  const currentPathname = (0, import_navigation3.usePathname)();
30254
30487
  function groupMenus(menus = []) {
30255
30488
  const menuMap = /* @__PURE__ */ new Map();
@@ -30283,7 +30516,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30283
30516
  });
30284
30517
  return sortMenus(rootMenus);
30285
30518
  }
30286
- const rawTabs = (0, import_react31.useMemo)(() => {
30519
+ const rawTabs = (0, import_react30.useMemo)(() => {
30287
30520
  if (!Array.isArray(tabs)) return [];
30288
30521
  if (source === "manual") return Array.isArray(tabs) ? tabs : [];
30289
30522
  return groupMenus(tabs);
@@ -30313,9 +30546,9 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30313
30546
  return tab.children.some((child) => isActive(child.url));
30314
30547
  };
30315
30548
  const router = (0, import_navigation3.useRouter)();
30316
- const [showExitDialog, setShowExitDialog] = (0, import_react31.useState)(false);
30317
- const [pendingUrl, setPendingUrl] = (0, import_react31.useState)(null);
30318
- const handleBuilderExit = (0, import_react31.useCallback)(
30549
+ const [showExitDialog, setShowExitDialog] = (0, import_react30.useState)(false);
30550
+ const [pendingUrl, setPendingUrl] = (0, import_react30.useState)(null);
30551
+ const handleBuilderExit = (0, import_react30.useCallback)(
30319
30552
  (e, url) => {
30320
30553
  if (isBuilder) {
30321
30554
  e.preventDefault();
@@ -30482,11 +30715,11 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
30482
30715
  var Tabs_default = Tabs;
30483
30716
 
30484
30717
  // src/components/Navigation/Stages/Stages.tsx
30485
- var import_react32 = __toESM(require("react"));
30718
+ var import_react31 = __toESM(require("react"));
30486
30719
  var import_jsx_runtime57 = require("react/jsx-runtime");
30487
30720
  var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey = "key", dataLabel = "header", loading, saving, triggerOnClick = false }) => {
30488
- const [activeStage, setActiveStage] = (0, import_react32.useState)(currentStage || (stages && stages.length > 0 ? stages[0].key : null));
30489
- const [isCompleted, setIsCompleted] = (0, import_react32.useState)(false);
30721
+ const [activeStage, setActiveStage] = (0, import_react31.useState)(currentStage || (stages && stages.length > 0 ? stages[0].key : null));
30722
+ const [isCompleted, setIsCompleted] = (0, import_react31.useState)(false);
30490
30723
  const updateStage = (stageKey) => {
30491
30724
  setActiveStage(stageKey);
30492
30725
  onStageChange?.(stageKey);
@@ -30531,7 +30764,7 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
30531
30764
  const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
30532
30765
  const isCompleted2 = isAllStagesCompleted || index < currentIndex;
30533
30766
  const isActive = !isAllStagesCompleted && index === currentIndex;
30534
- return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_react32.default.Fragment, { children: [
30767
+ return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_react31.default.Fragment, { children: [
30535
30768
  /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
30536
30769
  "button",
30537
30770
  {
@@ -30622,7 +30855,7 @@ var import_link6 = __toESM(require("next/link"));
30622
30855
  var import_image4 = __toESM(require("next/image"));
30623
30856
  var import_navigation4 = require("next/navigation");
30624
30857
  var import_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
30625
- var import_react33 = require("react");
30858
+ var import_react32 = require("react");
30626
30859
  var import_jsx_runtime63 = require("react/jsx-runtime");
30627
30860
  function Navbar({
30628
30861
  style,
@@ -30643,9 +30876,9 @@ function Navbar({
30643
30876
  }) {
30644
30877
  const isMobileView = canvasMode === "mobile" || canvasMode === "tablet";
30645
30878
  const router = (0, import_navigation4.useRouter)();
30646
- const [showExitDialog, setShowExitDialog] = (0, import_react33.useState)(false);
30647
- const [pendingUrl, setPendingUrl] = (0, import_react33.useState)(null);
30648
- const handleBuilderExit = (0, import_react33.useCallback)(
30879
+ const [showExitDialog, setShowExitDialog] = (0, import_react32.useState)(false);
30880
+ const [pendingUrl, setPendingUrl] = (0, import_react32.useState)(null);
30881
+ const handleBuilderExit = (0, import_react32.useCallback)(
30649
30882
  (e, url) => {
30650
30883
  if (isBuilder) {
30651
30884
  e.preventDefault();
@@ -30661,7 +30894,7 @@ function Navbar({
30661
30894
  router.push(pendingUrl);
30662
30895
  }
30663
30896
  };
30664
- const formatedMenu = (0, import_react33.useMemo)(() => {
30897
+ const formatedMenu = (0, import_react32.useMemo)(() => {
30665
30898
  if (source === "state" && navList && navList.length) {
30666
30899
  return navList.map((i) => ({ ...i, header: i.name || "Menu" }));
30667
30900
  }
@@ -30764,7 +30997,7 @@ function Navbar({
30764
30997
  }
30765
30998
 
30766
30999
  // src/components/Chart/BarChart.tsx
30767
- var import_react34 = __toESM(require("react"));
31000
+ var import_react33 = __toESM(require("react"));
30768
31001
  var import_recharts = require("recharts");
30769
31002
  var import_jsx_runtime64 = require("react/jsx-runtime");
30770
31003
  var ChartComponent = ({ className, style, loading, ...props }) => {
@@ -30825,10 +31058,10 @@ var ChartComponent = ({ className, style, loading, ...props }) => {
30825
31058
  )
30826
31059
  ] }) }) });
30827
31060
  };
30828
- var BarChart_default = import_react34.default.memo(ChartComponent);
31061
+ var BarChart_default = import_react33.default.memo(ChartComponent);
30829
31062
 
30830
31063
  // src/components/Chart/PieChart.tsx
30831
- var import_react35 = __toESM(require("react"));
31064
+ var import_react34 = __toESM(require("react"));
30832
31065
  var import_recharts2 = require("recharts");
30833
31066
  var import_jsx_runtime65 = require("react/jsx-runtime");
30834
31067
  var getRandomColor = () => {
@@ -30850,18 +31083,18 @@ var DonutChart = ({ className, style, loading, ...props }) => {
30850
31083
  const showLegends = props.showLegends ?? true;
30851
31084
  const labelType = props.labelType || "inside";
30852
31085
  const canvasMode = props.canvasMode;
30853
- const data = (0, import_react35.useMemo)(() => {
31086
+ const data = (0, import_react34.useMemo)(() => {
30854
31087
  if (!Array.isArray(props.data)) return [];
30855
31088
  return props.data.map((item) => ({ ...item, color: getRandomColor() }));
30856
31089
  }, [props.data]);
30857
- const total = (0, import_react35.useMemo)(() => data.reduce((sum, d) => sum + d.value, 0), [data]);
31090
+ const total = (0, import_react34.useMemo)(() => data.reduce((sum, d) => sum + d.value, 0), [data]);
30858
31091
  const forceMobile = canvasMode === "mobile" || canvasMode === "tablet";
30859
- const [mounted, setMounted] = (0, import_react35.useState)(false);
30860
- (0, import_react35.useEffect)(() => {
31092
+ const [mounted, setMounted] = (0, import_react34.useState)(false);
31093
+ (0, import_react34.useEffect)(() => {
30861
31094
  const timeout = setTimeout(() => setMounted(true), 100);
30862
31095
  return () => clearTimeout(timeout);
30863
31096
  }, []);
30864
- const renderLegends = (0, import_react35.useMemo)(() => {
31097
+ const renderLegends = (0, import_react34.useMemo)(() => {
30865
31098
  if (!showLegends) return null;
30866
31099
  return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_jsx_runtime65.Fragment, { children: data.map((d) => /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
30867
31100
  "div",
@@ -30949,7 +31182,7 @@ var DonutChart = ({ className, style, loading, ...props }) => {
30949
31182
  }
30950
31183
  );
30951
31184
  };
30952
- var PieChart_default = import_react35.default.memo(DonutChart);
31185
+ var PieChart_default = import_react34.default.memo(DonutChart);
30953
31186
 
30954
31187
  // src/components/Blocks/EmailComposer.tsx
30955
31188
  var import_jsx_runtime66 = require("react/jsx-runtime");