@herca/r-kit 0.0.34 → 0.0.36

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.
Files changed (43) hide show
  1. package/dist/components/calendar/index.cjs +443 -1469
  2. package/dist/components/calendar/index.cjs.map +1 -1
  3. package/dist/components/calendar/index.js +429 -1455
  4. package/dist/components/calendar/index.js.map +1 -1
  5. package/dist/components/checkbox/index.d.cts +2 -2
  6. package/dist/components/checkbox/index.d.ts +2 -2
  7. package/dist/components/counter/index.cjs.map +1 -1
  8. package/dist/components/counter/index.js.map +1 -1
  9. package/dist/components/date-picker/index.cjs +1641 -2667
  10. package/dist/components/date-picker/index.cjs.map +1 -1
  11. package/dist/components/date-picker/index.js +1629 -2655
  12. package/dist/components/date-picker/index.js.map +1 -1
  13. package/dist/components/form/index.d.cts +2 -2
  14. package/dist/components/form/index.d.ts +2 -2
  15. package/dist/components/input/index.cjs.map +1 -1
  16. package/dist/components/input/index.d.cts +1 -1
  17. package/dist/components/input/index.d.ts +1 -1
  18. package/dist/components/input/index.js.map +1 -1
  19. package/dist/components/input-file/index.cjs.map +1 -1
  20. package/dist/components/input-file/index.js.map +1 -1
  21. package/dist/components/input-otp/index.cjs.map +1 -1
  22. package/dist/components/input-otp/index.js.map +1 -1
  23. package/dist/components/modal/index.d.cts +3 -3
  24. package/dist/components/modal/index.d.ts +3 -3
  25. package/dist/components/sidebar/index.cjs.map +1 -1
  26. package/dist/components/sidebar/index.js.map +1 -1
  27. package/dist/components/switch/index.d.cts +1 -1
  28. package/dist/components/switch/index.d.ts +1 -1
  29. package/dist/components/table/index.cjs.map +1 -1
  30. package/dist/components/table/index.js.map +1 -1
  31. package/dist/components/useCopy/index.cjs +18 -0
  32. package/dist/components/useCopy/index.cjs.map +1 -0
  33. package/dist/components/useCopy/index.d.cts +6 -0
  34. package/dist/components/useCopy/index.d.ts +6 -0
  35. package/dist/components/useCopy/index.js +16 -0
  36. package/dist/components/useCopy/index.js.map +1 -0
  37. package/dist/components/useIsMobile/index.cjs +43 -0
  38. package/dist/components/useIsMobile/index.cjs.map +1 -0
  39. package/dist/components/useIsMobile/index.d.cts +3 -0
  40. package/dist/components/useIsMobile/index.d.ts +3 -0
  41. package/dist/components/useIsMobile/index.js +21 -0
  42. package/dist/components/useIsMobile/index.js.map +1 -0
  43. package/package.json +2 -2
@@ -1,14 +1,12 @@
1
- import * as React283 from 'react';
2
- import React283__default, { createContext, forwardRef, useRef, useState, useImperativeHandle, useEffect, useMemo, useContext } from 'react';
3
- import clsx9, { clsx } from 'clsx';
1
+ import * as React282 from 'react';
2
+ import React282__default, { createContext, useState, useRef, useEffect, useMemo, useContext } from 'react';
3
+ import clsx4, { clsx } from 'clsx';
4
4
  import { twMerge } from 'tailwind-merge';
5
5
  import { cva } from 'class-variance-authority';
6
6
  import { Slot } from '@radix-ui/react-slot';
7
7
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
8
- import '@radix-ui/react-collapsible';
9
- import '@radix-ui/react-dialog';
10
- import * as TooltipPrimitive from '@radix-ui/react-tooltip';
11
8
  import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
9
+ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
12
10
 
13
11
  // src/components/date-picker/date-picker.tsx
14
12
  function cn(...inputs) {
@@ -5562,589 +5560,228 @@ var ButtonNavigator = ({
5562
5560
  }
5563
5561
  );
5564
5562
  };
5565
- cva(
5566
- "flex items-center justify-center rounded border transition-all focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:outline-none",
5567
- {
5568
- variants: {
5569
- size: {
5570
- sm: "h-4 w-4",
5571
- md: "h-5 w-5",
5572
- lg: "h-6 w-6"
5573
- },
5574
- color: {
5575
- primary: "border-primary-1000 focus-visible:ring-primary-900",
5576
- secondary: "border-gray-600 focus-visible:ring-gray-500",
5577
- success: "border-success-500 focus-visible:ring-success-400",
5578
- danger: "border-danger-500 focus-visible:ring-danger-400",
5579
- warning: "border-warning-500 focus-visible:ring-warning-400",
5580
- info: "border-info-500 focus-visible:ring-info-400",
5581
- orange: "border-orange-500 focus-visible:ring-orange-400",
5582
- purple: "border-purple-500 focus-visible:ring-purple-400",
5583
- gray: "border-gray-600 focus-visible:ring-gray-500"
5584
- },
5585
- checked: {
5586
- true: "",
5587
- false: ""
5588
- }
5589
- },
5590
- compoundVariants: [
5591
- // Checked state - background sesuai color
5592
- {
5593
- checked: true,
5594
- color: "primary",
5595
- class: "bg-primary-1000 border-primary-1000"
5596
- },
5597
- {
5598
- checked: true,
5599
- color: "secondary",
5600
- class: "border-gray-600 bg-gray-600"
5601
- },
5602
- {
5603
- checked: true,
5604
- color: "success",
5605
- class: "bg-success-500 border-success-500"
5606
- },
5607
- {
5608
- checked: true,
5609
- color: "danger",
5610
- class: "bg-danger-500 border-danger-500"
5611
- },
5612
- {
5613
- checked: true,
5614
- color: "warning",
5615
- class: "bg-warning-500 border-warning-500"
5616
- },
5617
- { checked: true, color: "info", class: "bg-info-500 border-info-500" },
5618
- {
5619
- checked: true,
5620
- color: "orange",
5621
- class: "border-orange-500 bg-orange-500"
5622
- },
5623
- {
5624
- checked: true,
5625
- color: "purple",
5626
- class: "border-purple-500 bg-purple-500"
5627
- },
5628
- { checked: true, color: "gray", class: "border-gray-600 bg-gray-600" },
5629
- // Unchecked state - background white
5630
- { checked: false, class: "bg-white" }
5631
- ],
5632
- defaultVariants: {
5633
- size: "md",
5634
- color: "primary",
5635
- checked: false
5563
+ function Dropdown({
5564
+ children,
5565
+ ...props
5566
+ }) {
5567
+ return /* @__PURE__ */ jsx(DropdownMenu.Root, { ...props, children });
5568
+ }
5569
+ function DropdownTrigger({
5570
+ children,
5571
+ ...props
5572
+ }) {
5573
+ return /* @__PURE__ */ jsx(DropdownMenu.Trigger, { ...props, children });
5574
+ }
5575
+ function DropdownContent({
5576
+ children,
5577
+ className,
5578
+ portalProps,
5579
+ ...props
5580
+ }) {
5581
+ return /* @__PURE__ */ jsx(DropdownMenu.Portal, { ...portalProps, children: /* @__PURE__ */ jsx(
5582
+ DropdownMenu.Content,
5583
+ {
5584
+ sideOffset: props.sideOffset ?? 15,
5585
+ className: cn(
5586
+ "shadow-dropdown flex flex-col gap-1 rounded-xl border border-gray-200 bg-white p-3",
5587
+ className
5588
+ ),
5589
+ ...props,
5590
+ children
5636
5591
  }
5637
- }
5638
- );
5639
- cva("transition-all", {
5592
+ ) });
5593
+ }
5594
+ function DropdownItem({
5595
+ children,
5596
+ className,
5597
+ ...props
5598
+ }) {
5599
+ return /* @__PURE__ */ jsx(
5600
+ DropdownMenu.Item,
5601
+ {
5602
+ className: cn(
5603
+ "hover:bg-primary-50 hover:border-primary-300 flex cursor-pointer flex-row items-center gap-2 rounded-lg border border-gray-200 px-3 py-2 outline-0 transition-all",
5604
+ className
5605
+ ),
5606
+ ...props,
5607
+ children
5608
+ }
5609
+ );
5610
+ }
5611
+ var TextVariants = cva("font-metropolis", {
5640
5612
  variants: {
5641
- size: {
5642
- sm: "h-3 w-3",
5643
- md: "h-4 w-4",
5644
- lg: "h-5 w-5"
5613
+ variant: {
5614
+ h1: "text-[36px] leading-[46px]",
5615
+ h2: "text-[32px] leading-[42px]",
5616
+ h3: "text-[28px] leading-[38px]",
5617
+ h4: "text-[24px] leading-[34px]",
5618
+ p1: "text-[20px] leading-[30px]",
5619
+ p2: "text-[18px] leading-[28px]",
5620
+ p3: "text-[16px] leading-[26px]",
5621
+ t1: "text-[14px] leading-[24px]",
5622
+ t2: "text-[12px] leading-[20px]",
5623
+ t3: "text-[10px] leading-[14px]",
5624
+ t4: "text-[8px] leading-[10px]"
5625
+ },
5626
+ weight: {
5627
+ regular: "font-normal",
5628
+ medium: "font-medium",
5629
+ semibold: "font-semibold",
5630
+ bold: "font-bold"
5645
5631
  },
5646
5632
  color: {
5647
- primary: "text-white",
5648
- secondary: "text-white",
5649
- success: "text-white",
5650
- danger: "text-white",
5651
- warning: "text-white",
5652
- info: "text-white",
5653
- orange: "text-white",
5654
- purple: "text-white",
5655
- gray: "text-white"
5633
+ default: "",
5634
+ muted: "text-gray-400",
5635
+ primary: "text-primary-500",
5636
+ success: "text-success-500",
5637
+ warning: "text-warning-500",
5638
+ orange: "text-orange-500",
5639
+ danger: "text-danger-500",
5640
+ info: "text-info-500",
5641
+ purple: "text-purple-500",
5642
+ gray: "text-gray-500"
5643
+ },
5644
+ align: {
5645
+ start: "text-left",
5646
+ center: "text-center",
5647
+ end: "text-right",
5648
+ justify: "text-justify"
5656
5649
  },
5657
- icon: {
5658
- check: "",
5659
- minus: ""
5650
+ numberOfLines: {
5651
+ 1: "line-clamp-1",
5652
+ 2: "line-clamp-2",
5653
+ 3: "line-clamp-3",
5654
+ 4: "line-clamp-4"
5660
5655
  }
5661
5656
  },
5662
5657
  defaultVariants: {
5663
- size: "md",
5664
- color: "primary",
5665
- icon: "check"
5658
+ variant: "t2",
5659
+ weight: "regular",
5660
+ color: "default",
5661
+ align: "start"
5666
5662
  }
5667
5663
  });
5668
- var FormDescription = ({
5669
- className,
5670
- children
5671
- }) => {
5672
- return /* @__PURE__ */ jsx("p", { className: cn("text-xs text-gray-600", className), children });
5673
- };
5674
- var FormErrorMessages = ({
5675
- messages,
5676
- size = "md",
5664
+ function Text({
5665
+ as: TextComponent = "p",
5666
+ align,
5667
+ color,
5668
+ numberOfLines,
5669
+ variant,
5670
+ weight,
5671
+ value,
5672
+ children,
5677
5673
  className
5678
- }) => {
5679
- if (messages === void 0) return null;
5680
- const errorList = Array.isArray(messages) ? messages : [messages];
5681
- if (errorList.length === 0) return null;
5682
- return /* @__PURE__ */ jsx("div", { className: cn("space-y-0.5", className), children: errorList.map((msg, i) => /* @__PURE__ */ jsx(FormErrorMessage, { size, children: msg }, i)) });
5683
- };
5684
- var FormErrorMessage = ({
5685
- className,
5686
- children
5687
- }) => {
5688
- return /* @__PURE__ */ jsx("p", { className: cn("text-danger-500 text-xs", className), children });
5689
- };
5690
- var FormLabel = ({
5691
- htmlFor,
5692
- required = false,
5693
- size = "md",
5694
- className,
5695
- children
5696
- }) => {
5697
- const sizeClasses = {
5698
- sm: "text-xs",
5699
- md: "text-xs",
5700
- lg: "text-sm"
5701
- };
5702
- return /* @__PURE__ */ jsxs(
5703
- "label",
5674
+ }) {
5675
+ const content = value ?? children;
5676
+ return /* @__PURE__ */ jsx(
5677
+ TextComponent,
5704
5678
  {
5705
- htmlFor,
5706
5679
  className: cn(
5707
- sizeClasses[size || "md"],
5708
- "font-metropolis block font-semibold text-gray-900",
5680
+ TextVariants({
5681
+ variant,
5682
+ weight,
5683
+ color,
5684
+ align,
5685
+ numberOfLines
5686
+ }),
5709
5687
  className
5710
5688
  ),
5711
- children: [
5712
- children,
5713
- required && /* @__PURE__ */ jsx("span", { className: "text-danger-500 ml-1", children: "*" })
5714
- ]
5689
+ children: content
5715
5690
  }
5716
5691
  );
5717
- };
5718
- var FormHint = ({ className, children }) => {
5719
- return /* @__PURE__ */ jsx("p", { className: cn("text-xs text-gray-700", className), children });
5720
- };
5721
- var FormField = React283__default.forwardRef(
5722
- function FormField2({
5723
- label,
5724
- description,
5725
- hint,
5726
- errorMessages,
5727
- required = false,
5728
- size = "md",
5729
- htmlFor,
5730
- className,
5731
- children
5732
- }, ref) {
5733
- return /* @__PURE__ */ jsxs("div", { ref, className: cn("flex flex-col gap-1", className), children: [
5734
- label !== void 0 && /* @__PURE__ */ jsx(FormLabel, { htmlFor, required, size, children: label }),
5735
- description !== void 0 && /* @__PURE__ */ jsx(FormDescription, { size, children: description }),
5736
- children,
5737
- hint !== void 0 && /* @__PURE__ */ jsx(FormHint, { size, children: hint }),
5738
- errorMessages !== void 0 && /* @__PURE__ */ jsx(FormErrorMessages, { messages: errorMessages, size })
5739
- ] });
5740
- }
5741
- );
5742
- createContext(void 0);
5743
- var chipVariants = cva(
5744
- "inline-flex cursor-pointer items-center justify-center rounded-lg border transition-all duration-200",
5745
- {
5746
- variants: {
5747
- size: {
5748
- sm: "p-1.5 text-xs",
5749
- md: "p-2 text-sm",
5750
- lg: "px-3 py-2 text-base"
5751
- },
5752
- color: {
5753
- primary: "",
5754
- success: "",
5755
- danger: "",
5756
- warning: "",
5757
- info: "",
5758
- purple: "",
5759
- orange: "",
5760
- gray: ""
5761
- },
5762
- state: {
5763
- default: "",
5764
- selected: "",
5765
- disabled: ""
5766
- },
5767
- block: {
5768
- true: "w-full",
5769
- false: ""
5770
- }
5771
- },
5772
- compoundVariants: [
5773
- // Default color variants
5774
- {
5775
- color: "gray",
5776
- state: "default",
5777
- className: "border-gray-00 bg-white text-gray-700 hover:bg-gray-100"
5778
- },
5779
- {
5780
- color: "gray",
5781
- state: "selected",
5782
- className: "border-gray-400 bg-gray-200 text-gray-800"
5783
- },
5784
- {
5785
- color: "gray",
5786
- state: "disabled",
5787
- className: "cursor-not-allowed border-gray-200 bg-gray-100 text-gray-400"
5788
- },
5789
- // Primary color variants
5790
- {
5791
- color: "primary",
5792
- state: "default",
5793
- className: "border-primary-200 text-primary-1000 hover:bg-primary-50 bg-white"
5794
- },
5795
- {
5796
- color: "primary",
5797
- state: "selected",
5798
- className: "bg-primary-50 border-primary-200 text-primary-1000"
5799
- },
5800
- {
5801
- color: "primary",
5802
- state: "disabled",
5803
- className: "bg-primary-100 border-primary-200 text-primary-300 cursor-not-allowed"
5804
- },
5805
- // Success color variants
5806
- {
5807
- color: "success",
5808
- state: "default",
5809
- className: "border-success-300 text-success-500 hover:bg-success-50 bg-white"
5810
- },
5811
- {
5812
- color: "success",
5813
- state: "selected",
5814
- className: "bg-success-100 border-success-200 text-success-500"
5815
- },
5816
- {
5817
- color: "success",
5818
- state: "disabled",
5819
- className: "bg-success-100 border-success-200 text-success-300 cursor-not-allowed"
5820
- },
5821
- // Danger color variants
5822
- {
5823
- color: "danger",
5824
- state: "default",
5825
- className: "border-danger-200 text-danger-500 hover:bg-danger-50 bg-white"
5826
- },
5827
- {
5828
- color: "danger",
5829
- state: "selected",
5830
- className: "bg-danger-100 border-danger-200 text-danger-500"
5831
- },
5832
- {
5833
- color: "danger",
5834
- state: "disabled",
5835
- className: "bg-danger-100 border-danger-200 text-danger-300 cursor-not-allowed"
5836
- },
5837
- // Warning color variants
5838
- {
5839
- color: "warning",
5840
- state: "default",
5841
- className: "border-warning-300 text-warning-400 hover:bg-warning-50 bg-white"
5842
- },
5843
- {
5844
- color: "warning",
5845
- state: "selected",
5846
- className: "bg-warning-100 border-warning-300 text-warning-500"
5847
- },
5848
- {
5849
- color: "warning",
5850
- state: "disabled",
5851
- className: "bg-warning-100 border-warning-200 text-warning-300 cursor-not-allowed"
5852
- },
5853
- // Info color variants
5854
- {
5855
- color: "info",
5856
- state: "default",
5857
- className: "border-info-200 text-info-500 hover:bg-info-50 bg-white"
5858
- },
5859
- {
5860
- color: "info",
5861
- state: "selected",
5862
- className: "bg-info-100 border-info-200 text-info-500"
5863
- },
5864
- {
5865
- color: "info",
5866
- state: "disabled",
5867
- className: "bg-info-100 border-info-200 text-info-300 cursor-not-allowed"
5868
- },
5869
- // Purple color variants
5870
- {
5871
- color: "purple",
5872
- state: "default",
5873
- className: "border-purple-200 bg-white text-purple-500 hover:bg-purple-50"
5874
- },
5875
- {
5876
- color: "purple",
5877
- state: "selected",
5878
- className: "border-purple-200 bg-purple-100 text-purple-500"
5879
- },
5880
- {
5881
- color: "purple",
5882
- state: "disabled",
5883
- className: "cursor-not-allowed border-purple-200 bg-purple-100 text-purple-300"
5884
- },
5885
- // Orange color variants
5886
- {
5887
- color: "orange",
5888
- state: "default",
5889
- className: "border-orange-200 bg-white text-orange-500 hover:bg-orange-50"
5890
- },
5891
- {
5892
- color: "orange",
5893
- state: "selected",
5894
- className: "border-orange-200 bg-orange-100 text-orange-500"
5895
- },
5896
- {
5897
- color: "orange",
5898
- state: "disabled",
5899
- className: "cursor-not-allowed border-orange-200 bg-orange-100 text-orange-300"
5900
- }
5901
- ],
5902
- defaultVariants: {
5903
- size: "md",
5904
- color: "primary",
5905
- state: "default",
5906
- block: false
5907
- }
5908
- }
5909
- );
5910
- var ChipContext = createContext(null);
5911
- var Chip = ({
5912
- value,
5913
- selected: selectedProp,
5914
- disabled = false,
5915
- onClick,
5916
- children,
5917
- color: colorProp,
5918
- size: sizeProp,
5919
- block: blockProp,
5920
- className
5921
- }) => {
5922
- const context = useContext(ChipContext);
5923
- const color = colorProp ?? context?.color ?? "primary";
5924
- const size = sizeProp ?? context?.size ?? "md";
5925
- const block = blockProp ?? context?.block ?? false;
5926
- const isSelected = context ? value !== void 0 && context.selectedValues.includes(value) : selectedProp ?? false;
5927
- const state = disabled ? "disabled" : isSelected === true ? "selected" : "default";
5928
- const handleClick = () => {
5929
- if (disabled) return;
5930
- if (context && value !== void 0) {
5931
- context.toggleSelection(value);
5932
- }
5933
- onClick?.(value);
5934
- };
5692
+ }
5693
+ function ButtonMore({ count, onClick }) {
5935
5694
  return /* @__PURE__ */ jsx(
5936
5695
  "button",
5937
5696
  {
5938
5697
  type: "button",
5939
- onClick: handleClick,
5940
- disabled,
5941
- className: cn(chipVariants({ size, color, state, block }), className),
5942
- children
5698
+ onClick,
5699
+ className: "h-full w-full cursor-pointer px-1 transition-colors hover:bg-gray-50",
5700
+ title: `+${count} more`,
5701
+ children: /* @__PURE__ */ jsxs(Text, { weight: "medium", className: "line-clamp-1 text-gray-700", children: [
5702
+ "+",
5703
+ count,
5704
+ " more"
5705
+ ] })
5943
5706
  }
5944
5707
  );
5945
- };
5946
- var ChipGroup = ({
5947
- options,
5948
- selected = [],
5949
- onSelect,
5950
- direction = "horizontal",
5951
- color = "primary",
5952
- multiple = false,
5953
- scrollable = true,
5954
- block = false,
5955
- size = "md",
5956
- footer,
5957
- header,
5958
- children,
5959
- className
5960
- }) => {
5961
- const isHorizontal = direction === "horizontal";
5962
- const normalizeSelected = (val) => Array.isArray(val) ? val : val !== null || val !== void 0 ? [val] : [];
5963
- const [internalSelected, setInternalSelected] = useState(
5964
- normalizeSelected(selected)
5965
- );
5966
- useEffect(() => {
5967
- const newSelected = normalizeSelected(selected);
5968
- if (JSON.stringify(newSelected) !== JSON.stringify(internalSelected)) {
5969
- setInternalSelected(newSelected);
5970
- }
5971
- }, [selected, internalSelected]);
5972
- const toggleSelection = (value) => {
5973
- let newSelected;
5974
- if (multiple || !multiple && internalSelected.length === 0) {
5975
- newSelected = internalSelected.includes(value) ? internalSelected.filter((v) => v !== value) : [...internalSelected, value];
5976
- } else {
5977
- newSelected = [value];
5708
+ }
5709
+
5710
+ // src/components/calendar/helpers/create-date-style-helpers.ts
5711
+ function createDateStyleHelpers({
5712
+ isSelected,
5713
+ isDisabled,
5714
+ isCurrentMonth,
5715
+ styleConfig,
5716
+ day
5717
+ }) {
5718
+ const getSelectedStyle = (styleConfig2) => {
5719
+ return {
5720
+ backgroundColor: styleConfig2?.selected?.background,
5721
+ color: styleConfig2?.selected?.text
5722
+ };
5723
+ };
5724
+ const getDisabledStyle = (styleConfig2) => {
5725
+ return {
5726
+ backgroundColor: styleConfig2?.disabled?.background,
5727
+ color: styleConfig2?.disabled?.text
5728
+ };
5729
+ };
5730
+ const getDayStyle = () => {
5731
+ if (isSelected) {
5732
+ return getSelectedStyle(styleConfig);
5733
+ } else if (isDisabled && day.month === "current") {
5734
+ return getDisabledStyle(styleConfig);
5978
5735
  }
5979
- setInternalSelected(newSelected);
5980
- onSelect?.(newSelected);
5736
+ return {};
5981
5737
  };
5982
- const containerClasses = `
5983
- flex gap-2
5984
- ${isHorizontal ? "flex-row flex-wrap" : "flex-col"}
5985
- ${block ? "items-stretch" : "items-start"}
5986
- ${scrollable && isHorizontal ? "overflow-x-auto" : ""}
5987
- ${scrollable && !isHorizontal ? "overflow-y-auto" : ""}
5988
- ${className ?? ""}
5989
- `;
5990
- const contextValue = {
5991
- selectedValues: internalSelected,
5992
- toggleSelection,
5993
- color,
5994
- size,
5995
- block
5738
+ const getCursorClass = () => {
5739
+ if (isDisabled && isCurrentMonth) {
5740
+ return "cursor-not-allowed";
5741
+ }
5742
+ return "cursor-pointer";
5996
5743
  };
5997
- return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
5998
- header !== void 0 && /* @__PURE__ */ jsx("div", { className: "mb-2", children: header }),
5999
- /* @__PURE__ */ jsx(ChipContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { className: containerClasses, children: options !== void 0 ? options.map((option) => /* @__PURE__ */ jsxs(
6000
- Chip,
6001
- {
6002
- value: option.value,
6003
- disabled: option.disabled,
6004
- children: [
6005
- option.icon !== void 0 && /* @__PURE__ */ jsx("span", { className: "mr-2", children: option.icon }),
6006
- /* @__PURE__ */ jsx("span", { children: option.label })
6007
- ]
6008
- },
6009
- String(option.value)
6010
- )) : children }) }),
6011
- footer !== void 0 && /* @__PURE__ */ jsx("div", { className: "mt-2", children: footer })
6012
- ] });
6013
- };
6014
- var inputVariants = cva(
6015
- "w-full min-w-0 rounded-lg border bg-transparent px-3 py-2 text-base font-medium text-gray-800 shadow-xs transition outline-none placeholder:text-gray-500",
6016
- {
6017
- variants: {
6018
- size: {
6019
- sm: "h-8 text-xs",
6020
- md: "h-9 text-sm",
6021
- lg: "h-10 text-base"
6022
- }
6023
- },
6024
- defaultVariants: {
6025
- size: "md"
5744
+ const getTextColorClass = () => {
5745
+ if (!isCurrentMonth) {
5746
+ return "[&>h5]:text-gray-500";
6026
5747
  }
6027
- }
6028
- );
6029
- var Input = React283.forwardRef(
6030
- ({
6031
- className,
6032
- leftAddon,
6033
- rightAddon,
6034
- type = "text",
6035
- label,
6036
- hint,
6037
- errorMessages,
6038
- size,
6039
- inputSize,
6040
- description,
6041
- leftAddonClassName,
6042
- rightAddonClassName,
6043
- mergedAddon,
6044
- isError,
6045
- onContainerResize,
6046
- ...props
6047
- }, ref) => {
6048
- const hasError = fieldHasError(errorMessages) ?? isError;
6049
- const generatedId = React283.useId();
6050
- const fieldRef = React283.useRef(null);
6051
- React283.useEffect(() => {
6052
- if (!fieldRef.current || !onContainerResize) return;
6053
- const ro = new ResizeObserver(([entry]) => {
6054
- onContainerResize(entry.contentRect.width);
6055
- });
6056
- ro.observe(fieldRef.current);
6057
- return () => ro.disconnect();
6058
- }, [onContainerResize]);
6059
- return /* @__PURE__ */ jsx(
6060
- FormField,
6061
- {
6062
- ref: fieldRef,
6063
- label,
6064
- hint,
6065
- description,
6066
- errorMessages,
6067
- className,
6068
- required: props.required,
6069
- size,
6070
- htmlFor: props?.id ?? generatedId,
6071
- children: /* @__PURE__ */ jsxs(
6072
- "div",
6073
- {
6074
- className: cn(
6075
- "flex w-full items-stretch overflow-hidden rounded-lg border bg-white",
6076
- hasError ? "border-danger-500 focus-within:border-danger-500" : "focus-within:border-primary-300 border-gray-200"
6077
- ),
6078
- children: [
6079
- Boolean(leftAddon) && /* @__PURE__ */ jsx(
6080
- "div",
6081
- {
6082
- className: cn(
6083
- leftAddonClassName,
6084
- "flex items-center justify-center border-r border-gray-200 px-3",
6085
- Boolean(mergedAddon) && "border-r-0",
6086
- hasError ? "text-danger-500 border-danger-500" : "border-gray-200 text-gray-600"
6087
- ),
6088
- children: leftAddon
6089
- }
6090
- ),
6091
- /* @__PURE__ */ jsx(
6092
- "input",
6093
- {
6094
- ref,
6095
- type,
6096
- size: inputSize,
6097
- id: props?.id ?? generatedId,
6098
- className: cn(
6099
- inputVariants({ size }),
6100
- "font-metropolis w-full rounded-none border-none focus-visible:outline-none",
6101
- Boolean(leftAddon) && "pl-2",
6102
- Boolean(rightAddon) && "pr-2",
6103
- Boolean(mergedAddon) && "shadow-none",
6104
- Boolean(props.disabled) && "cursor-not-allowed bg-gray-100",
6105
- className
6106
- ),
6107
- ...props,
6108
- required: false
6109
- }
6110
- ),
6111
- Boolean(rightAddon) && /* @__PURE__ */ jsx(
6112
- "div",
6113
- {
6114
- className: cn(
6115
- rightAddonClassName,
6116
- "flex items-center justify-center border-l border-gray-200 px-3",
6117
- hasError ? "text-danger-500" : "text-gray-600",
6118
- Boolean(mergedAddon) && "border-l-0"
6119
- ),
6120
- children: rightAddon
6121
- }
6122
- )
6123
- ]
6124
- }
6125
- )
6126
- }
6127
- );
6128
- }
6129
- );
6130
- Input.displayName = "Input";
6131
- var MOBILE_BREAKPOINT = 768;
6132
- function useIsMobile() {
6133
- const [isMobile, setIsMobile] = React283.useState(false);
6134
- React283.useEffect(() => {
6135
- const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
6136
- const onChange = () => {
6137
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
6138
- };
6139
- mql.addEventListener("change", onChange);
6140
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
6141
- return () => mql.removeEventListener("change", onChange);
6142
- }, []);
6143
- return !!isMobile;
5748
+ if (isSelected && styleConfig?.selected?.text != null) {
5749
+ return "";
5750
+ }
5751
+ if (isSelected) {
5752
+ return "[&>h5]:text-white!";
5753
+ }
5754
+ if (isDisabled && styleConfig?.disabled?.text != null) {
5755
+ return "";
5756
+ }
5757
+ if (isDisabled) {
5758
+ return "*:text-red-500!";
5759
+ }
5760
+ if (isToday(day)) {
5761
+ return "*:text-info-500!";
5762
+ }
5763
+ return "*:text-gray-700!";
5764
+ };
5765
+ const getBackgroundClass = () => {
5766
+ if (isSelected && styleConfig?.selected?.background != null) {
5767
+ return "";
5768
+ }
5769
+ if (isSelected) {
5770
+ return "bg-primary-1000";
5771
+ }
5772
+ if (isDisabled && isCurrentMonth && styleConfig?.disabled?.background != null) {
5773
+ return "";
5774
+ }
5775
+ if (isDisabled && isCurrentMonth) {
5776
+ return "bg-red-500/30";
5777
+ }
5778
+ if (!isDisabled) {
5779
+ return "hover:bg-gray-100 group-hover:bg-gray-100";
5780
+ }
5781
+ return "";
5782
+ };
5783
+ return { getBackgroundClass, getTextColorClass, getCursorClass, getDayStyle };
6144
5784
  }
6145
- React283__default.createContext(
6146
- null
6147
- );
6148
5785
  function TooltipProvider({
6149
5786
  delayDuration = 0,
6150
5787
  ...props
@@ -6198,2214 +5835,1551 @@ function TooltipContent({
6198
5835
  }
6199
5836
  ) });
6200
5837
  }
6201
- cva(
6202
- "relative z-50 w-full rounded-2xl bg-white shadow-xl focus:outline-none",
6203
- {
6204
- variants: {
6205
- size: {
6206
- xs: "max-w-[327px]",
6207
- sm: "max-w-[480px]",
6208
- md: "max-w-[700px]",
6209
- lg: "max-w-[1000px]",
6210
- full: "mx-4 max-w-full"
6211
- },
6212
- state: {
6213
- open: "animate-modal-scale-in",
6214
- closed: "animate-modal-scale-out"
6215
- }
6216
- },
6217
- defaultVariants: {
6218
- size: "md"
6219
- }
6220
- }
6221
- );
6222
- cva("fixed inset-0 z-[999] m-0 flex p-4", {
6223
- variants: {
6224
- position: {
6225
- center: "items-center justify-center",
6226
- top: "items-start justify-center",
6227
- bottom: "items-end justify-center"
6228
- },
6229
- state: {
6230
- open: "animate-modal-fade-in",
6231
- closed: "animate-modal-fade-out"
6232
- }
6233
- },
6234
- defaultVariants: {
6235
- position: "center"
6236
- }
6237
- });
6238
- var TextVariants = cva("font-metropolis", {
6239
- variants: {
6240
- variant: {
6241
- h1: "text-[36px] leading-[46px]",
6242
- h2: "text-[32px] leading-[42px]",
6243
- h3: "text-[28px] leading-[38px]",
6244
- h4: "text-[24px] leading-[34px]",
6245
- p1: "text-[20px] leading-[30px]",
6246
- p2: "text-[18px] leading-[28px]",
6247
- p3: "text-[16px] leading-[26px]",
6248
- t1: "text-[14px] leading-[24px]",
6249
- t2: "text-[12px] leading-[20px]",
6250
- t3: "text-[10px] leading-[14px]",
6251
- t4: "text-[8px] leading-[10px]"
6252
- },
6253
- weight: {
6254
- regular: "font-normal",
6255
- medium: "font-medium",
6256
- semibold: "font-semibold",
6257
- bold: "font-bold"
6258
- },
6259
- color: {
6260
- default: "",
6261
- muted: "text-gray-400",
6262
- primary: "text-primary-500",
6263
- success: "text-success-500",
6264
- warning: "text-warning-500",
6265
- orange: "text-orange-500",
6266
- danger: "text-danger-500",
6267
- info: "text-info-500",
6268
- purple: "text-purple-500",
6269
- gray: "text-gray-500"
6270
- },
6271
- align: {
6272
- start: "text-left",
6273
- center: "text-center",
6274
- end: "text-right",
6275
- justify: "text-justify"
6276
- },
6277
- numberOfLines: {
6278
- 1: "line-clamp-1",
6279
- 2: "line-clamp-2",
6280
- 3: "line-clamp-3",
6281
- 4: "line-clamp-4"
6282
- }
6283
- },
6284
- defaultVariants: {
6285
- variant: "t2",
6286
- weight: "regular",
6287
- color: "default",
6288
- align: "start"
6289
- }
6290
- });
6291
- function Text({
6292
- as: TextComponent = "p",
6293
- align,
6294
- color,
6295
- numberOfLines,
6296
- variant,
6297
- weight,
6298
- value,
6299
- children,
6300
- className
6301
- }) {
6302
- const content = value ?? children;
6303
- return /* @__PURE__ */ jsx(
6304
- TextComponent,
5838
+ var date_size_map = {
5839
+ md: "size-7.5",
5840
+ sm: "size-6",
5841
+ lg: "size-9"
5842
+ };
5843
+ function CalendarDayItem({
5844
+ day,
5845
+ helpers,
5846
+ size,
5847
+ mode,
5848
+ styleConfig,
5849
+ onClick,
5850
+ variant,
5851
+ events,
5852
+ backdropOnClick
5853
+ }) {
5854
+ const dayConfig = helpers.getDayConfig(day);
5855
+ const isSelected = helpers.isDateSelected(day);
5856
+ const dots = dayConfig?.dots || [];
5857
+ const isCurrentMonth = day.month === "current";
5858
+ const isDisabled = (dayConfig?.disabled ?? false) || helpers.isDateDisabled(day);
5859
+ const rangeStart = helpers.isRangeStart(day);
5860
+ const rangeEnd = helpers.isRangeEnd(day);
5861
+ const currentDate = formatDateLocal(day.fullDate);
5862
+ const hasEvent = events?.find((event) => {
5863
+ const start = new Date(event.startDate);
5864
+ const end = new Date(event.endDate);
5865
+ return new Date(currentDate) >= start && new Date(currentDate) <= end;
5866
+ })?.title;
5867
+ const styleHelpers = createDateStyleHelpers({
5868
+ day,
5869
+ isSelected: isSelected || rangeStart || rangeEnd,
5870
+ isCurrentMonth,
5871
+ isDisabled,
5872
+ styleConfig
5873
+ });
5874
+ return /* @__PURE__ */ jsxs(
5875
+ "button",
6305
5876
  {
6306
- className: cn(
6307
- TextVariants({
6308
- variant,
6309
- weight,
6310
- color,
6311
- align,
6312
- numberOfLines
6313
- }),
6314
- className
5877
+ style: styleHelpers.getDayStyle(),
5878
+ onClick: () => onClick(day),
5879
+ disabled: isDisabled && isCurrentMonth,
5880
+ className: clsx4(
5881
+ date_size_map[size ?? "md"],
5882
+ styleHelpers.getCursorClass(),
5883
+ styleHelpers.getTextColorClass(),
5884
+ "group relative flex flex-col items-center justify-center rounded-full text-sm font-medium transition-all duration-200",
5885
+ mode === "single" && variant === "compact" && styleHelpers.getBackgroundClass(),
5886
+ //prettier-ignore
5887
+ mode === "range" && !isDisabled && helpers.getRangeBackgroundClass(day),
5888
+ variant === "default" && "h-28 md:h-36 w-full rounded-none flex items-start justify-start group p-1 md:p-3 border-r border-gray-300"
5889
+ //prettier-ignore
6315
5890
  ),
6316
- children: content
5891
+ children: [
5892
+ /* @__PURE__ */ jsx(
5893
+ "div",
5894
+ {
5895
+ className: "absolute inset-0 size-full cursor-pointer",
5896
+ onClick: () => backdropOnClick?.(day)
5897
+ }
5898
+ ),
5899
+ /* @__PURE__ */ jsx(
5900
+ "h5",
5901
+ {
5902
+ className: clsx4(
5903
+ "font-metropolis text-xs transition-colors",
5904
+ variant === "default" && "grid size-8 place-items-center justify-center rounded-full",
5905
+ //prettier-ignore
5906
+ mode === "single" && variant === "default" && styleHelpers.getBackgroundClass()
5907
+ //prettier-ignore
5908
+ ),
5909
+ children: day.date
5910
+ }
5911
+ ),
5912
+ variant === "default" && Boolean(hasEvent) === false && backdropOnClick && /* @__PURE__ */ jsx("div", { className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5913
+ /* @__PURE__ */ jsx(TooltipTrigger, { className: "cursor-pointer", children: /* @__PURE__ */ jsx(
5914
+ Icon,
5915
+ {
5916
+ name: "plus",
5917
+ className: "text-gray-700! opacity-0 transition-opacity group-hover:opacity-100",
5918
+ size: 20
5919
+ }
5920
+ ) }),
5921
+ /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", children: "Add Schedule" })
5922
+ ] }) }),
5923
+ variant === "compact" && dots.length > 0 && /* @__PURE__ */ jsx("div", { className: "-mb-1 flex gap-0.5", children: dots.map((dot, i) => /* @__PURE__ */ jsx(
5924
+ "div",
5925
+ {
5926
+ className: "size-1 rounded-full",
5927
+ style: {
5928
+ backgroundColor: dot.color ?? "#d1d5db"
5929
+ }
5930
+ },
5931
+ i
5932
+ )) })
5933
+ ]
6317
5934
  }
6318
5935
  );
6319
5936
  }
6320
- var inputFileVariants = cva("", {
6321
- variants: {
6322
- variant: {
6323
- primary: "bg-primary-1000 *:*:text-white border-primary-1000 focus-within:outline-primary-900 hover:bg-primary-1000",
6324
- //prettier-ignore
6325
- secondary: "bg-transparent *:*:text-primary-1000 border-primary-1000 focus-within:outline-primary-900 hover:bg-primary-50",
6326
- //prettier-ignore
6327
- gray: "bg-gray-700 *:*:text-white border-gray-700 focus-within:outline-gray-700 hover:bg-gray-700",
6328
- //prettier-ignore
6329
- medium: "",
6330
- large: ""
6331
- }
6332
- }
6333
- });
6334
-
6335
- // src/components/input-file/helpers.ts
6336
- var getIconName = ({
6337
- file,
6338
- fileType
6339
- }) => {
6340
- const type = file?.type ?? fileType;
6341
- const ext = file?.name.split(".").pop()?.toLowerCase();
6342
- if (type !== void 0 && type?.startsWith("image/")) {
6343
- return null;
6344
- }
6345
- if (type !== void 0 && type?.includes("spreadsheet") || ext === "xls" || ext === "xlsx") {
6346
- return "xls";
6347
- }
6348
- if (type !== void 0 && type?.includes("word") || ext === "doc" || ext === "docx") {
6349
- return "doc";
6350
- }
6351
- if (type !== void 0 && type?.startsWith("video/") || ext === "mkv" || ext === "mp4") {
6352
- return "mp4";
6353
- }
6354
- if (type !== void 0 && type?.startsWith("audio/") || ext === "mp3") {
6355
- return "mp3";
6356
- }
6357
- if (type !== void 0 && type?.includes("pdf") || ext === "pdf") {
6358
- return "pdf";
6359
- }
6360
- return "doc";
6361
- };
6362
- var ModalPreviewAttachment = ({
6363
- onClose,
6364
- open,
6365
- src,
6366
- name,
6367
- type,
6368
- iframeProps,
6369
- audioProps,
6370
- videoProps
6371
- }) => {
6372
- const [zoom, setZoom] = useState(1);
6373
- const [isDragging, setIsDragging] = useState(false);
6374
- const [position, setPosition] = useState({ x: 0, y: 0 });
6375
- const [dragStart, setDragStart] = useState({ x: 0, y: 0 });
6376
- const isImage = type.startsWith("image/");
6377
- const isMp3 = type.startsWith("audio/");
6378
- const isVideo = type.startsWith("video/");
6379
- const isPdf = type === "application/pdf";
6380
- const iconName = getIconName({ fileType: type });
6381
- const MIN_ZOOM = 0.5;
6382
- const MAX_ZOOM = 5;
6383
- const ZOOM_STEP = 0.5;
6384
- const handleZoomIn = () => {
6385
- setZoom((prev) => Math.min(prev + ZOOM_STEP, MAX_ZOOM));
6386
- };
6387
- const handleZoomOut = () => {
6388
- setZoom((prev) => {
6389
- const newZoom = Math.max(prev - ZOOM_STEP, MIN_ZOOM);
6390
- if (newZoom <= 1) {
6391
- setPosition({ x: 0, y: 0 });
6392
- }
6393
- return newZoom;
6394
- });
6395
- };
6396
- const handleMouseDown = (e) => {
6397
- if (zoom > 1) {
6398
- setIsDragging(true);
6399
- setDragStart({
6400
- x: e.clientX - position.x,
6401
- y: e.clientY - position.y
6402
- });
6403
- }
6404
- };
5937
+ function EventBar({
5938
+ segment,
5939
+ showTooltip = true,
5940
+ onClick
5941
+ }) {
5942
+ const [hovered, setHovered] = useState(false);
5943
+ const [pos, setPos] = useState({ x: 0, y: 0 });
6405
5944
  const handleMouseMove = (e) => {
6406
- if (isDragging && zoom > 1) {
6407
- setPosition({
6408
- x: e.clientX - dragStart.x,
6409
- y: e.clientY - dragStart.y
6410
- });
6411
- }
5945
+ setPos({
5946
+ x: e.clientX,
5947
+ y: e.clientY
5948
+ });
6412
5949
  };
6413
- const handleMouseUp = () => {
6414
- setIsDragging(false);
5950
+ const bg_color_map = {
5951
+ info: "#F1FDFF",
5952
+ purple: "#EEEBFF",
5953
+ orange: "#FFFBED",
5954
+ success: "#EAFFEC",
5955
+ danger: "#FEF3F2",
5956
+ warning: "#FFFAEB",
5957
+ primary: "#F1F2FF"
6415
5958
  };
6416
- const handleDownload = () => {
6417
- const link = document.createElement("a");
6418
- link.href = src;
6419
- link.download = name;
6420
- document.body.appendChild(link);
6421
- link.click();
6422
- document.body.removeChild(link);
5959
+ const ribbon_color_map = {
5960
+ info: "#6CD8FF",
5961
+ purple: "#A6A6FB",
5962
+ orange: "#FFDA71",
5963
+ success: "#6BE995",
5964
+ danger: "#FDA29B",
5965
+ warning: "#FEC84B",
5966
+ primary: "#ABB1FF"
6423
5967
  };
6424
- useEffect(() => {
6425
- if (!open.isOpen) {
6426
- setZoom(1);
6427
- setPosition({ x: 0, y: 0 });
6428
- setIsDragging(false);
6429
- }
6430
- }, [open.isOpen]);
6431
- useEffect(() => {
6432
- document.body.style.overflow = open.isOpen ? "hidden" : "unset";
6433
- }, [open.isOpen]);
6434
- if (!open.isOpen) return null;
6435
- return /* @__PURE__ */ jsxs("div", { className: cn("fixed inset-0 z-20"), children: [
6436
- /* @__PURE__ */ jsx(
6437
- "div",
6438
- {
6439
- className: cn(
6440
- `fixed inset-0 z-10 size-full bg-black/40 transition-all`,
6441
- open.isVisible ? "opacity-100" : "opacity-0"
6442
- ),
6443
- onClick: onClose
6444
- }
6445
- ),
5968
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
6446
5969
  /* @__PURE__ */ jsxs(
6447
- "div",
5970
+ "button",
6448
5971
  {
6449
- className: cn(
6450
- "relative z-20 container mx-auto flex h-full flex-col items-center gap-6 py-10 transition-all",
6451
- open.isVisible ? "translate-y-0 opacity-100" : "-translate-y-10 opacity-0"
5972
+ type: "button",
5973
+ onClick: () => onClick?.(segment),
5974
+ onMouseEnter: () => setHovered(true),
5975
+ onMouseLeave: () => setHovered(false),
5976
+ onMouseMove: handleMouseMove,
5977
+ className: clsx4(
5978
+ "relative mx-0.5 mt-1 flex items-center justify-between gap-3 overflow-hidden rounded p-1 text-[11px] leading-5 font-medium md:p-1.5",
5979
+ onClick && "cursor-pointer"
6452
5980
  ),
5981
+ style: {
5982
+ gridColumn: `${segment.startCol + 1} / span ${segment.span}`,
5983
+ backgroundColor: bg_color_map[segment?.event?.color ?? "info"] ?? "#F1FDFF"
5984
+ },
6453
5985
  children: [
6454
- /* @__PURE__ */ jsxs("div", { className: "flex w-full justify-between", children: [
6455
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
6456
- /* @__PURE__ */ jsx("button", { onClick: onClose, className: "cursor-pointer", type: "button", children: /* @__PURE__ */ jsx(Icon, { name: "times", color: "white" }) }),
6457
- /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
6458
- iconName && /* @__PURE__ */ jsx(Icon, { name: iconName, size: 48 }),
6459
- /* @__PURE__ */ jsx(
6460
- Text,
6461
- {
6462
- value: name,
6463
- variant: "p3",
6464
- weight: "semibold",
6465
- className: "text-white!"
6466
- }
6467
- )
6468
- ] })
6469
- ] }),
6470
- isImage && /* @__PURE__ */ jsx(
6471
- ZoomController,
6472
- {
6473
- onDownload: handleDownload,
6474
- onZoomIn: handleZoomIn,
6475
- onZoomOut: handleZoomOut,
6476
- maxZoom: MAX_ZOOM,
6477
- minZoom: MIN_ZOOM,
6478
- zoom
5986
+ /* @__PURE__ */ jsx(
5987
+ "span",
5988
+ {
5989
+ className: "absolute left-0 h-full w-1",
5990
+ style: {
5991
+ backgroundColor: ribbon_color_map[segment?.event?.color ?? "info"] ?? "#6CD8FF"
6479
5992
  }
6480
- )
5993
+ }
5994
+ ),
5995
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-px pl-2 *:line-clamp-1", children: [
5996
+ /* @__PURE__ */ jsx(Text, { variant: "t3", weight: "semibold", className: "text-gray-800", children: segment.event.title }),
5997
+ /* @__PURE__ */ jsx(Text, { variant: "t3", className: "text-gray-700", children: segment.event.subtitle })
6481
5998
  ] }),
6482
- isImage && /* @__PURE__ */ jsxs(Fragment, { children: [
5999
+ /* @__PURE__ */ jsx(Text, { variant: "t3", className: "line-clamp-1 text-gray-800", children: segment.event.label })
6000
+ ]
6001
+ }
6002
+ ),
6003
+ hovered && showTooltip === true && /* @__PURE__ */ jsx(
6004
+ "div",
6005
+ {
6006
+ className: "pointer-events-none fixed z-50",
6007
+ style: {
6008
+ top: pos.y + 12,
6009
+ left: pos.x + 12
6010
+ },
6011
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col rounded-lg bg-white p-3 shadow", children: [
6012
+ /* @__PURE__ */ jsx(Text, { variant: "t3", weight: "semibold", className: "text-gray-800", children: segment.event.title }),
6013
+ Boolean(segment.event.subtitle) && /* @__PURE__ */ jsx(Text, { variant: "t3", className: "text-gray-700", children: segment.event.subtitle }),
6014
+ Boolean(segment.event.label) && /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-1", children: [
6483
6015
  /* @__PURE__ */ jsx(
6484
6016
  "div",
6485
6017
  {
6486
- className: "scrollbar-hide relative flex size-full justify-center overflow-auto rounded-xl",
6487
- onMouseDown: handleMouseDown,
6488
- onMouseMove: handleMouseMove,
6489
- onMouseUp: handleMouseUp,
6490
- onMouseLeave: handleMouseUp,
6018
+ className: "size-1 rounded-full",
6491
6019
  style: {
6492
- cursor: zoom > 1 ? isDragging ? "grabbing" : "grab" : "default"
6493
- },
6494
- children: /* @__PURE__ */ jsx(
6495
- "img",
6496
- {
6497
- src,
6498
- alt: name,
6499
- draggable: false,
6500
- className: "h-full rounded-xl object-contain select-none",
6501
- style: {
6502
- transform: `scale(${zoom}) translate(${position.x / zoom}px, ${position.y / zoom}px)`,
6503
- transformOrigin: "top left",
6504
- transition: isDragging ? "none" : "transform 0.2s ease-out"
6505
- }
6506
- }
6507
- )
6020
+ backgroundColor: ribbon_color_map[segment.event.color ?? "info"] ?? "#6CD8FF"
6021
+ }
6508
6022
  }
6509
6023
  ),
6510
- zoom > 1 && /* @__PURE__ */ jsx("div", { className: "absolute bottom-14 left-1/2 -translate-x-1/2 rounded-lg bg-black/60 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
6511
- Text,
6512
- {
6513
- value: "Click and drag to pan \u2022 Scroll to zoom",
6514
- variant: "t3",
6515
- className: "text-white/80!"
6516
- }
6517
- ) })
6518
- ] }),
6519
- isVideo && /* @__PURE__ */ jsx("div", { className: "flex size-full overflow-auto", children: /* @__PURE__ */ jsx(
6520
- "video",
6521
- {
6522
- src,
6523
- controls: true,
6524
- className: cn(
6525
- "h-full w-full rounded-xl object-contain",
6526
- videoProps?.className
6527
- ),
6528
- ...videoProps
6529
- }
6530
- ) }),
6531
- isPdf && /* @__PURE__ */ jsx("div", { className: "flex size-full overflow-auto", children: /* @__PURE__ */ jsx(
6532
- "iframe",
6533
- {
6534
- src,
6535
- className: cn("h-full w-full", iframeProps?.className),
6536
- ...iframeProps
6537
- }
6538
- ) }),
6539
- isMp3 && /* @__PURE__ */ jsx("div", { className: "flex size-full items-center justify-center overflow-auto", children: /* @__PURE__ */ jsx(
6540
- "audio",
6541
- {
6542
- src,
6543
- controls: true,
6544
- className: cn("h-full w-full", audioProps?.className),
6545
- ...audioProps
6546
- }
6547
- ) })
6548
- ]
6024
+ /* @__PURE__ */ jsx(Text, { variant: "t3", className: clsx4("text-gray-800"), children: segment.event.label })
6025
+ ] })
6026
+ ] })
6549
6027
  }
6550
6028
  )
6551
6029
  ] });
6552
- };
6553
- var ZoomController = ({
6554
- zoom,
6555
- onZoomIn,
6556
- onZoomOut,
6557
- onDownload,
6558
- maxZoom,
6559
- minZoom
6560
- }) => {
6561
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6562
- /* @__PURE__ */ jsx(
6563
- Button,
6564
- {
6565
- size: "icon",
6566
- onClick: onZoomIn,
6567
- disabled: zoom >= maxZoom,
6568
- type: "button",
6569
- children: /* @__PURE__ */ jsx(Icon, { name: "search-plus-fill" })
6570
- }
6571
- ),
6572
- /* @__PURE__ */ jsx(
6573
- Button,
6574
- {
6575
- size: "icon",
6576
- onClick: onZoomOut,
6577
- disabled: zoom <= minZoom,
6578
- type: "button",
6579
- children: /* @__PURE__ */ jsx(Icon, { name: "search-minus-fill" })
6580
- }
6581
- ),
6582
- /* @__PURE__ */ jsxs(Button, { color: "secondary", onClick: onDownload, children: [
6583
- /* @__PURE__ */ jsx(Icon, { name: "download" }),
6584
- /* @__PURE__ */ jsx(
6585
- Text,
6586
- {
6587
- as: "span",
6588
- value: "Download",
6589
- weight: "medium",
6590
- className: "text-primary-1000!"
6591
- }
6592
- )
6593
- ] })
6594
- ] });
6595
- };
6596
- var PreviewItem = ({
6597
- data,
6598
- onRemove,
6599
- onReplace,
6600
- disabled = false,
6601
- labelCustomName = "Attachment File",
6602
- onCustomNameChange,
6603
- customNamePlaceholder = "Name Attachment",
6604
- customName,
6605
- audioPlayerProps,
6606
- pdfViewerProps,
6607
- videoPlayerProps
6608
- }) => {
6609
- const [previewShow, setPreviewShow] = useState({
6610
- isOpen: false,
6611
- isVisible: false
6612
- });
6613
- const isImage = data?.file?.type.startsWith("image/");
6614
- const isMp3 = data?.file?.type.startsWith("audio/");
6615
- const isVideo = data?.file?.type.startsWith("video/");
6616
- const isPdf = data?.file?.type === "application/pdf";
6617
- const isNotViewable = !isImage && !isMp3 && !isVideo && !isPdf;
6618
- const iconName = getIconName({ file: data.file });
6619
- const handleOpenPreview = () => {
6620
- setPreviewShow({
6621
- isOpen: true,
6622
- isVisible: false
6623
- });
6624
- requestAnimationFrame(() => {
6625
- setPreviewShow({
6626
- isOpen: true,
6627
- isVisible: true
6628
- });
6629
- });
6630
- };
6631
- const handleClosePreview = () => {
6632
- setPreviewShow((s) => ({ ...s, isVisible: false }));
6633
- setTimeout(() => {
6634
- setPreviewShow({ isOpen: false, isVisible: false });
6635
- }, 200);
6636
- };
6637
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
6638
- !!onCustomNameChange && /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-2", children: [
6639
- /* @__PURE__ */ jsx(FormLabel, { children: labelCustomName }),
6640
- /* @__PURE__ */ jsx(
6641
- Input,
6642
- {
6643
- type: "text",
6644
- onChange: onCustomNameChange,
6645
- placeholder: customNamePlaceholder,
6646
- value: customName,
6647
- className: "truncate"
6648
- }
6649
- )
6650
- ] }),
6651
- /* @__PURE__ */ jsxs(
6652
- "div",
6653
- {
6654
- className: cn(
6655
- "flex w-full items-center justify-between rounded-lg border border-gray-200 p-2"
6656
- ),
6657
- children: [
6658
- /* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-center gap-2 overflow-hidden", children: [
6659
- /* @__PURE__ */ jsx(
6660
- "button",
6661
- {
6662
- type: "button",
6663
- className: "cursor-pointer disabled:cursor-not-allowed",
6664
- onClick: handleOpenPreview,
6665
- disabled: isNotViewable,
6666
- children: data.file.type.startsWith("image/") ? /* @__PURE__ */ jsx(
6667
- "img",
6668
- {
6669
- src: data.preview,
6670
- alt: data.file.name,
6671
- className: "size-11 rounded-md object-cover"
6672
- }
6673
- ) : /* @__PURE__ */ jsx(Icon, { name: iconName ?? "doc", className: "size-11" })
6674
- }
6675
- ),
6676
- /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
6677
- /* @__PURE__ */ jsx(
6678
- Text,
6679
- {
6680
- as: "h3",
6681
- value: data.file.name,
6682
- variant: "t1",
6683
- weight: "semibold",
6684
- className: "truncate"
6685
- }
6686
- ),
6687
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1", children: [
6688
- /* @__PURE__ */ jsx(
6689
- Text,
6690
- {
6691
- value: `${(data.file.size / 1024 / 1024).toFixed(2)} MB`,
6692
- className: "truncate text-gray-700!"
6693
- }
6694
- ),
6695
- (Boolean(data?.hint) || Boolean(data?.errorMessage)) && /* @__PURE__ */ jsx(Text, { value: "\u2022", className: "truncate text-gray-700!" }),
6696
- Boolean(data?.hint) && /* @__PURE__ */ jsx(
6697
- Text,
6698
- {
6699
- value: data?.hint ?? "",
6700
- className: "truncate text-gray-700!"
6701
- }
6702
- ),
6703
- Boolean(data?.hint) && Boolean(data?.errorMessage) && /* @__PURE__ */ jsx(Text, { value: "\u2022", className: "truncate text-gray-700!" }),
6704
- Boolean(data?.errorMessage) && /* @__PURE__ */ jsx(Text, { value: data?.errorMessage ?? "", color: "danger" })
6705
- ] })
6706
- ] })
6707
- ] }),
6708
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6709
- Boolean(data?.errorMessage) && /* @__PURE__ */ jsxs(Fragment, { children: [
6710
- /* @__PURE__ */ jsx(
6711
- "button",
6712
- {
6713
- type: "button",
6714
- onClick: onReplace,
6715
- disabled,
6716
- className: "cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
6717
- title: "Replace file",
6718
- children: /* @__PURE__ */ jsx(Icon, { name: "rotate-right", className: "size-4 text-gray-700" })
6719
- }
6720
- ),
6721
- /* @__PURE__ */ jsx(
6722
- Icon,
6723
- {
6724
- name: "exclamation-triangle",
6725
- className: "text-danger-500 size-4"
6726
- }
6727
- )
6728
- ] }),
6729
- /* @__PURE__ */ jsx(
6730
- "button",
6731
- {
6732
- type: "button",
6733
- onClick: onRemove,
6734
- disabled,
6735
- className: "cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
6736
- children: /* @__PURE__ */ jsx(Icon, { name: "times", className: "size-4 text-gray-700" })
6737
- }
6738
- )
6739
- ] })
6740
- ]
6741
- }
6742
- ),
6743
- /* @__PURE__ */ jsx(
6744
- ModalPreviewAttachment,
6745
- {
6746
- type: data?.file?.type,
6747
- name: data?.customName ?? data?.file?.name,
6748
- src: data?.preview,
6749
- open: previewShow,
6750
- onClose: () => handleClosePreview(),
6751
- audioProps: audioPlayerProps,
6752
- videoProps: videoPlayerProps,
6753
- iframeProps: pdfViewerProps
6754
- }
6755
- )
6756
- ] });
6757
- };
6758
- var InputFile = forwardRef(
6759
- ({
6760
- value,
6761
- onChange,
6762
- multiple = false,
6763
- accept,
6764
- maxSize,
6765
- maxFiles,
6766
- disabled = false,
6767
- variant = "primary",
6768
- buttonLabel = "Choose File",
6769
- label = "Choose File",
6770
- hint = "JPG, PNG, dan PDF (Max. 5MB)",
6771
- errorMessage,
6772
- maxSizeErrorMessage,
6773
- maxFilesErrorMessage,
6774
- customNamePlaceholder,
6775
- useCustomName,
6776
- pdfViewerProps,
6777
- audioPlayerProps,
6778
- videoPlayerProps
6779
- }, ref) => {
6780
- const inputRef = useRef(null);
6781
- const replaceInputRef = useRef(null);
6782
- const [internalFiles, setInternalFiles] = useState([]);
6783
- const [replaceIndex, setReplaceIndex] = useState(null);
6784
- const [customNames, setCustomNames] = useState({});
6785
- const [isDragging, setIsDragging] = useState(false);
6786
- const files = value ?? internalFiles;
6787
- const setFiles = onChange ?? setInternalFiles;
6788
- const processFiles = (selectedFiles) => {
6789
- if (maxFiles !== void 0 && files.length + selectedFiles.length > maxFiles) {
6790
- alert(maxFilesErrorMessage ?? `Maksimal ${maxFiles} file`);
6791
- return;
6792
- }
6793
- if (maxSize !== void 0) {
6794
- const oversized = selectedFiles.filter((file) => file.size > maxSize);
6795
- if (oversized.length > 0) {
6796
- alert(
6797
- maxSizeErrorMessage ?? `File ${oversized.map((f) => f.name).join(", ")} melebihi ukuran maksimal ${(maxSize / 1024 / 1024).toFixed(2)} MB`
6798
- );
6799
- return;
6800
- }
6801
- }
6802
- const mapped = selectedFiles.map((file) => ({
6803
- id: crypto.randomUUID(),
6804
- file,
6805
- customName: file.name,
6806
- preview: URL.createObjectURL(file)
6807
- }));
6808
- setFiles([...files, ...mapped]);
6809
- };
6810
- const handleChange = (e) => {
6811
- const selected = Array.from(e.target.files ?? []);
6812
- processFiles(selected);
6813
- if (inputRef.current) {
6814
- inputRef.current.value = "";
6815
- }
6816
- };
6817
- const handleChangeCustomName = ({
6818
- e,
6819
- i
6820
- }) => {
6821
- if (replaceIndex !== null) return;
6822
- const val = e.target.value;
6823
- setCustomNames((prev) => ({
6824
- ...prev,
6825
- [i]: val
6826
- }));
6030
+ }
6031
+ var MOBILE_BREAKPOINT = 768;
6032
+ function useIsMobile() {
6033
+ const [isMobile, setIsMobile] = React282.useState(false);
6034
+ React282.useEffect(() => {
6035
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
6036
+ const onChange = () => {
6037
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
6827
6038
  };
6828
- const handleReplace = (e) => {
6829
- if (replaceIndex === null) return;
6830
- const selected = e.target.files?.[0];
6831
- if (!selected) return;
6832
- if (maxSize !== void 0 && selected.size > maxSize) {
6833
- alert(
6834
- maxSizeErrorMessage ?? `File ${selected.name} melebihi ukuran maksimal ${(maxSize / 1024 / 1024).toFixed(2)} MB`
6039
+ mql.addEventListener("change", onChange);
6040
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
6041
+ return () => mql.removeEventListener("change", onChange);
6042
+ }, []);
6043
+ return !!isMobile;
6044
+ }
6045
+ function CalendarGrid({
6046
+ days: days2,
6047
+ helpers,
6048
+ size,
6049
+ mode,
6050
+ styleConfig,
6051
+ onClick,
6052
+ className,
6053
+ variant,
6054
+ events = [],
6055
+ showCalendarTooltip = true,
6056
+ backdropOnClick,
6057
+ onEventClick
6058
+ }) {
6059
+ const isMobile = useIsMobile();
6060
+ const weeks = Array.from(
6061
+ { length: Math.ceil(days2.length / 7) },
6062
+ (_, i) => days2.slice(i * 7, i * 7 + 7)
6063
+ );
6064
+ return /* @__PURE__ */ jsx(
6065
+ "div",
6066
+ {
6067
+ className: clsx4(
6068
+ "relative",
6069
+ variant === "compact" && size === "sm" && "space-y-1"
6070
+ ),
6071
+ children: weeks.map((week, weekIndex) => {
6072
+ const segments = getWeekEventSegments({ week, events });
6073
+ const threshold = isMobile ? 1 : 2;
6074
+ const displayLimit = 1;
6075
+ const segmentLevels = /* @__PURE__ */ new Map();
6076
+ segments.forEach((seg) => {
6077
+ let placed = false;
6078
+ for (let level = 0; level < threshold; level++) {
6079
+ const conflict = segments.some((other) => {
6080
+ if (other === seg) return false;
6081
+ const otherLevel = segmentLevels.get(other);
6082
+ if (otherLevel !== level) return false;
6083
+ const segStart = seg.startCol;
6084
+ const segEnd = seg.startCol + seg.span - 1;
6085
+ const otherStart = other.startCol;
6086
+ const otherEnd = other.startCol + other.span - 1;
6087
+ return !(segEnd < otherStart || segStart > otherEnd);
6088
+ });
6089
+ if (!conflict) {
6090
+ segmentLevels.set(seg, level);
6091
+ placed = true;
6092
+ break;
6093
+ }
6094
+ }
6095
+ if (!placed) {
6096
+ segmentLevels.set(seg, threshold);
6097
+ }
6098
+ });
6099
+ const columnHiddenCount = Array(7).fill(0);
6100
+ segments.forEach((seg) => {
6101
+ const level = segmentLevels.get(seg) ?? 0;
6102
+ if (level >= threshold) {
6103
+ for (let i = 0; i < seg.span; i++) {
6104
+ const col = seg.startCol + i;
6105
+ if (col >= 0 && col < 7) {
6106
+ columnHiddenCount[col]++;
6107
+ }
6108
+ }
6109
+ }
6110
+ });
6111
+ const hasOverflow = segments.length > threshold;
6112
+ const visibleSegments = segments.filter((seg) => {
6113
+ const level = segmentLevels.get(seg) ?? 0;
6114
+ if (!hasOverflow) {
6115
+ return level < threshold;
6116
+ }
6117
+ return level < displayLimit;
6118
+ });
6119
+ const columnHiddenSegments = Array.from(
6120
+ { length: 7 },
6121
+ () => []
6835
6122
  );
6836
- return;
6837
- }
6838
- URL.revokeObjectURL(files[replaceIndex].preview);
6839
- const newFileItem = {
6840
- file: selected,
6841
- preview: URL.createObjectURL(selected)
6842
- };
6843
- const newFiles = [...files];
6844
- newFiles[replaceIndex] = newFileItem;
6845
- setFiles(newFiles);
6846
- setReplaceIndex(null);
6847
- if (replaceInputRef.current) {
6848
- replaceInputRef.current.value = "";
6849
- }
6850
- };
6851
- const removeFile = (index) => {
6852
- const newFiles = files.filter((_, i) => i !== index);
6853
- URL.revokeObjectURL(files[index].preview);
6854
- setFiles(newFiles);
6855
- };
6856
- const clearAll = () => {
6857
- files.forEach((f) => URL.revokeObjectURL(f.preview));
6858
- setFiles([]);
6859
- if (inputRef.current) {
6860
- inputRef.current.value = "";
6861
- }
6862
- };
6863
- const triggerReplace = (index) => {
6864
- setReplaceIndex(index);
6865
- replaceInputRef.current?.click();
6866
- };
6867
- const openFilePicker = () => {
6868
- inputRef.current?.click();
6869
- };
6870
- const handleDragEnter = (e) => {
6871
- e.preventDefault();
6872
- e.stopPropagation();
6873
- if (disabled) return;
6874
- setIsDragging(true);
6875
- };
6876
- const handleDragLeave = (e) => {
6877
- e.preventDefault();
6878
- e.stopPropagation();
6879
- if (disabled) return;
6880
- const rect = e.currentTarget.getBoundingClientRect();
6881
- const x = e.clientX;
6882
- const y = e.clientY;
6883
- if (x <= rect.left || x >= rect.right || y <= rect.top || y >= rect.bottom) {
6884
- setIsDragging(false);
6885
- }
6886
- };
6887
- const handleDragOver = (e) => {
6888
- e.preventDefault();
6889
- e.stopPropagation();
6890
- };
6891
- const handleDrop = (e) => {
6892
- e.preventDefault();
6893
- e.stopPropagation();
6894
- if (disabled) return;
6895
- setIsDragging(false);
6896
- const droppedFiles = Array.from(e.dataTransfer.files);
6897
- let filteredFiles = droppedFiles;
6898
- if (accept !== void 0) {
6899
- const acceptedTypes = accept.split(",").map((type) => type.trim());
6900
- filteredFiles = droppedFiles.filter((file) => {
6901
- return acceptedTypes.some((acceptedType) => {
6902
- if (acceptedType.startsWith(".")) {
6903
- return file.name.endsWith(acceptedType);
6123
+ segments.forEach((seg) => {
6124
+ const isVisible = visibleSegments.includes(seg);
6125
+ if (!isVisible) {
6126
+ for (let i = 0; i < seg.span; i++) {
6127
+ const col = seg.startCol + i;
6128
+ if (col >= 0 && col < 7) {
6129
+ columnHiddenSegments[col].push(seg);
6130
+ }
6904
6131
  }
6905
- if (acceptedType.endsWith("/*")) {
6906
- const baseType = acceptedType.split("/")[0];
6907
- return file.type.startsWith(baseType + "/");
6132
+ }
6133
+ });
6134
+ const columnTotalCount = Array(7).fill(0);
6135
+ segments.forEach((seg) => {
6136
+ for (let i = 0; i < seg.span; i++) {
6137
+ const col = seg.startCol + i;
6138
+ if (col >= 0 && col < 7) {
6139
+ columnTotalCount[col]++;
6908
6140
  }
6909
- return file.type === acceptedType;
6910
- });
6141
+ }
6911
6142
  });
6912
- if (filteredFiles.length !== droppedFiles.length) {
6913
- alert(
6914
- `Beberapa file tidak sesuai dengan tipe yang diizinkan: ${accept}`
6915
- );
6916
- }
6917
- }
6918
- if (filteredFiles.length > 0) {
6919
- processFiles(filteredFiles);
6920
- }
6921
- };
6922
- useImperativeHandle(ref, () => ({
6923
- clearAll,
6924
- openFilePicker,
6925
- getFiles: () => files.map((f, i) => {
6926
- const base = { ...f };
6927
- if (useCustomName !== void 0) {
6928
- base.customName = customNames[i] ?? f.customName ?? f.file.name;
6929
- }
6930
- return base;
6931
- })
6932
- }));
6933
- useEffect(() => {
6934
- return () => files.forEach((f) => URL.revokeObjectURL(f.preview));
6935
- }, [files]);
6936
- const isDefault = variant === "primary" || variant === "secondary" || variant === "gray";
6937
- const isSized = variant === "medium" || variant === "large";
6938
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
6939
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
6940
- /* @__PURE__ */ jsxs(
6941
- "label",
6143
+ const columnVisibleCount = Array(7).fill(0);
6144
+ visibleSegments.forEach((seg) => {
6145
+ for (let i = 0; i < seg.span; i++) {
6146
+ const col = seg.startCol + i;
6147
+ if (col >= 0 && col < 7) {
6148
+ columnVisibleCount[col]++;
6149
+ }
6150
+ }
6151
+ });
6152
+ const columnMoreCount = columnTotalCount.map(
6153
+ (total, i) => Math.max(0, total - columnVisibleCount[i])
6154
+ );
6155
+ return /* @__PURE__ */ jsxs(
6156
+ "div",
6942
6157
  {
6943
- className: cn(
6944
- inputFileVariants({ variant }),
6945
- "group relative flex items-center gap-2 rounded-lg border px-3 py-2 transition-all",
6946
- isDefault && "w-fit outline-2 outline-offset-1 outline-transparent",
6947
- //prettier-ignore
6948
- isSized && "w-full border-dashed border-gray-400 bg-gray-50",
6949
- //prettier-ignore
6950
- variant === "large" && errorMessage !== void 0 && "border-danger-500",
6951
- variant === "large" && "flex-col items-center p-5!",
6952
- variant === "large" && isDragging && "border-primary-500 bg-primary-50",
6158
+ className: clsx4(
6159
+ "relative",
6160
+ variant === "default" && "border-b border-gray-300 last:border-b-0!",
6953
6161
  //prettier-ignore
6954
- disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"
6162
+ className
6955
6163
  ),
6956
- onDragEnter: variant === "large" ? handleDragEnter : void 0,
6957
- onDragLeave: variant === "large" ? handleDragLeave : void 0,
6958
- onDragOver: variant === "large" ? handleDragOver : void 0,
6959
- onDrop: variant === "large" ? handleDrop : void 0,
6960
6164
  children: [
6961
- isDefault && /* @__PURE__ */ jsx(Icon, { name: "upload" }),
6962
- isSized && /* @__PURE__ */ jsx(Icon, { name: "cloud-upload", size: variant === "large" ? 125 : 40 }),
6963
- /* @__PURE__ */ jsxs(
6165
+ /* @__PURE__ */ jsx(
6964
6166
  "div",
6965
6167
  {
6966
- className: cn(
6967
- "flex flex-1 flex-col",
6968
- variant === "large" && "*:text-center"
6168
+ className: clsx4(
6169
+ "grid w-full grid-cols-7",
6170
+ variant === "default" && "*:border-r *:border-gray-300 [&>*:nth-last-child(1)]:border-r-0",
6171
+ //prettier-ignore
6172
+ variant === "compact" && "place-items-center"
6969
6173
  ),
6970
- children: [
6971
- /* @__PURE__ */ jsx(
6972
- Text,
6973
- {
6974
- as: "h3",
6975
- value: label,
6976
- weight: "semibold",
6977
- className: cn(isSized && "text-gray-800!")
6978
- }
6979
- ),
6980
- isSized && /* @__PURE__ */ jsx(
6981
- Text,
6982
- {
6983
- as: "p",
6984
- value: variant === "large" && !isDragging && !hint ? `Klik atau drag & drop file disini` : hint,
6985
- className: "text-gray-600!"
6986
- }
6987
- )
6988
- ]
6989
- }
6990
- ),
6991
- errorMessage !== void 0 && variant === "large" && /* @__PURE__ */ jsx(
6992
- Text,
6993
- {
6994
- value: errorMessage,
6995
- variant: "t3",
6996
- className: "text-left",
6997
- color: "danger"
6174
+ children: week.map((day, dayIndex) => /* @__PURE__ */ jsx(
6175
+ CalendarDayItem,
6176
+ {
6177
+ day,
6178
+ helpers,
6179
+ size,
6180
+ mode,
6181
+ styleConfig,
6182
+ onClick,
6183
+ variant,
6184
+ events,
6185
+ backdropOnClick: variant === "default" && backdropOnClick ? (day2) => backdropOnClick?.(day2) : void 0
6186
+ },
6187
+ dayIndex
6188
+ ))
6998
6189
  }
6999
6190
  ),
7000
- isSized && /* @__PURE__ */ jsx(Button, { onClick: () => inputRef.current?.click(), type: "button", children: /* @__PURE__ */ jsx(
7001
- Text,
7002
- {
7003
- as: "span",
7004
- value: buttonLabel,
7005
- weight: "semibold",
7006
- className: "text-white!"
7007
- }
7008
- ) }),
7009
- /* @__PURE__ */ jsx(
7010
- "input",
7011
- {
7012
- ref: inputRef,
7013
- type: "file",
7014
- multiple,
7015
- accept,
7016
- onChange: handleChange,
7017
- disabled,
7018
- className: "absolute inset-0 -z-10 cursor-pointer opacity-0"
7019
- }
7020
- )
7021
- ]
7022
- }
7023
- ),
7024
- errorMessage !== void 0 && variant === "medium" && /* @__PURE__ */ jsx(
7025
- Text,
7026
- {
7027
- value: errorMessage,
7028
- variant: "t3",
7029
- className: "text-left",
7030
- color: "danger"
7031
- }
7032
- )
7033
- ] }),
7034
- /* @__PURE__ */ jsx(
7035
- "input",
7036
- {
7037
- ref: replaceInputRef,
7038
- type: "file",
7039
- accept,
7040
- onChange: handleReplace,
7041
- className: "hidden"
7042
- }
7043
- ),
7044
- files.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
7045
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
7046
- /* @__PURE__ */ jsx(
7047
- Text,
7048
- {
7049
- value: "Selected Files",
7050
- variant: "t1",
7051
- weight: "semibold",
7052
- as: "h1"
7053
- }
7054
- ),
7055
- /* @__PURE__ */ jsx(
7056
- "button",
7057
- {
7058
- type: "button",
7059
- onClick: clearAll,
7060
- disabled,
7061
- className: "cursor-pointer disabled:opacity-50",
7062
- children: /* @__PURE__ */ jsx(Text, { value: "Clear", weight: "semibold", color: "danger" })
7063
- }
7064
- )
7065
- ] }),
7066
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children: files.map((item, i) => /* @__PURE__ */ jsx(
7067
- PreviewItem,
7068
- {
7069
- data: item,
7070
- audioPlayerProps,
7071
- pdfViewerProps,
7072
- videoPlayerProps,
7073
- onRemove: () => removeFile(i),
7074
- onReplace: () => triggerReplace(i),
7075
- labelCustomName: item?.label,
7076
- customNamePlaceholder,
7077
- onCustomNameChange: useCustomName !== void 0 ? (e) => handleChangeCustomName?.({ e, i }) : void 0,
7078
- customName: customNames[i] ?? item.customName ?? item.file.name,
7079
- disabled
6191
+ segments.length > 0 && /* @__PURE__ */ jsxs("div", { className: "absolute inset-x-0 bottom-2 grid grid-cols-7 gap-0.5", children: [
6192
+ visibleSegments.map((seg, index) => /* @__PURE__ */ jsx(
6193
+ EventBar,
6194
+ {
6195
+ segment: seg,
6196
+ showTooltip: showCalendarTooltip,
6197
+ onClick: () => onEventClick?.(seg.event)
6198
+ },
6199
+ index
6200
+ )),
6201
+ columnMoreCount.map(
6202
+ (count, colIndex) => count > 0 ? /* @__PURE__ */ jsxs(Dropdown, { children: [
6203
+ /* @__PURE__ */ jsx(DropdownTrigger, { className: "w-full", asChild: true, children: /* @__PURE__ */ jsx("div", { style: { gridColumnStart: colIndex + 1 }, children: /* @__PURE__ */ jsx(ButtonMore, { count }, colIndex) }) }),
6204
+ /* @__PURE__ */ jsxs(DropdownContent, { sideOffset: -130, className: "min-w-45", children: [
6205
+ /* @__PURE__ */ jsx(
6206
+ Text,
6207
+ {
6208
+ variant: "t2",
6209
+ weight: "semibold",
6210
+ className: "text-gray-800",
6211
+ children: week[colIndex] && new Intl.DateTimeFormat("id-ID", {
6212
+ day: "numeric",
6213
+ month: "long",
6214
+ year: "numeric"
6215
+ }).format(week[colIndex].fullDate)
6216
+ }
6217
+ ),
6218
+ columnHiddenSegments[colIndex].map((seg, index) => /* @__PURE__ */ jsx(
6219
+ EventBar,
6220
+ {
6221
+ segment: seg,
6222
+ showTooltip: false,
6223
+ onClick: () => onEventClick?.(seg.event)
6224
+ },
6225
+ index
6226
+ ))
6227
+ ] })
6228
+ ] }, colIndex) : null
6229
+ )
6230
+ ] })
6231
+ ]
7080
6232
  },
7081
- item?.id
7082
- )) })
7083
- ] })
7084
- ] });
7085
- }
7086
- );
7087
- InputFile.displayName = "InputFile";
7088
- cva("", {
7089
- variants: {
7090
- size: {
7091
- sm: "px-0 text-xs",
7092
- md: "text-md",
7093
- lg: "text-lg"
7094
- },
7095
- controlIconSize: {
7096
- sm: "size-[10px]",
7097
- md: "size-[14px]",
7098
- lg: "size-[16px]"
7099
- },
7100
- height: {
7101
- sm: "h-[22px]",
7102
- md: "h-[30px]",
7103
- lg: "h-[40px]"
7104
- },
7105
- variant: {
7106
- primary: "border-0",
7107
- secondary: "border border-gray-500"
7108
- }
7109
- },
7110
- defaultVariants: {
7111
- size: "md"
7112
- }
7113
- });
7114
- function Dropdown({
7115
- children,
7116
- ...props
7117
- }) {
7118
- return /* @__PURE__ */ jsx(DropdownMenu.Root, { ...props, children });
7119
- }
7120
- function DropdownTrigger({
7121
- children,
7122
- ...props
7123
- }) {
7124
- return /* @__PURE__ */ jsx(DropdownMenu.Trigger, { ...props, children });
7125
- }
7126
- function DropdownContent({
7127
- children,
7128
- className,
7129
- portalProps,
7130
- ...props
7131
- }) {
7132
- return /* @__PURE__ */ jsx(DropdownMenu.Portal, { ...portalProps, children: /* @__PURE__ */ jsx(
7133
- DropdownMenu.Content,
7134
- {
7135
- sideOffset: props.sideOffset ?? 15,
7136
- className: cn(
7137
- "shadow-dropdown flex flex-col gap-1 rounded-xl border border-gray-200 bg-white p-3",
7138
- className
7139
- ),
7140
- ...props,
7141
- children
6233
+ weekIndex
6234
+ );
6235
+ })
7142
6236
  }
7143
- ) });
6237
+ );
7144
6238
  }
7145
- function DropdownItem({
7146
- children,
7147
- className,
7148
- ...props
7149
- }) {
6239
+ var ButtonDropdown = ({
6240
+ onClick,
6241
+ active,
6242
+ size = "md"
6243
+ }) => {
6244
+ const size_map = {
6245
+ sm: 11,
6246
+ md: 12,
6247
+ lg: 18
6248
+ };
7150
6249
  return /* @__PURE__ */ jsx(
7151
- DropdownMenu.Item,
6250
+ Button,
7152
6251
  {
6252
+ size: "icon",
6253
+ onClick,
6254
+ color: "gray",
7153
6255
  className: cn(
7154
- "hover:bg-primary-50 hover:border-primary-300 flex cursor-pointer flex-row items-center gap-2 rounded-lg border border-gray-200 px-3 py-2 outline-0 transition-all",
7155
- className
6256
+ "bg-transparent transition-colors outline-none *:duration-300 hover:bg-gray-50 focus:outline-none"
7156
6257
  ),
7157
- ...props,
7158
- children
6258
+ children: /* @__PURE__ */ jsx(
6259
+ Icon,
6260
+ {
6261
+ name: "arrow-down",
6262
+ size: size_map[size],
6263
+ className: cn(
6264
+ "text-primary-1000",
6265
+ active == true ? "rotate-180" : "rotate-0"
6266
+ )
6267
+ }
6268
+ )
7159
6269
  }
7160
6270
  );
7161
- }
7162
- cva("", {
7163
- variants: {
7164
- tableRow: {
7165
- "basic": "",
7166
- "bordered": "",
7167
- "stripped": "",
7168
- "hovered": "",
7169
- "row-bordered": "border-y border-gray-300",
7170
- "wrapped-row-bordered": "border-y border-gray-300",
7171
- "headed": ""
7172
- }
7173
- }
7174
- });
7175
- createContext({});
7176
- createContext({});
7177
- cva(
7178
- "relative inline-flex shrink-0 rounded-full transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",
7179
- {
7180
- variants: {
7181
- size: {
7182
- sm: "h-5 w-9",
7183
- md: "h-6 w-11",
7184
- lg: "h-7 w-14"
7185
- },
7186
- color: {
7187
- primary: "data-[state=checked]:bg-primary-1000 focus-visible:ring-primary-900",
7188
- secondary: "focus-visible:ring-gray-500 data-[state=checked]:bg-gray-600",
7189
- success: "data-[state=checked]:bg-success-500 focus-visible:ring-success-400",
7190
- danger: "data-[state=checked]:bg-danger-500 focus-visible:ring-danger-400",
7191
- warning: "data-[state=checked]:bg-warning-500 focus-visible:ring-warning-400",
7192
- info: "data-[state=checked]:bg-info-500 focus-visible:ring-info-400",
7193
- orange: "focus-visible:ring-orange-400 data-[state=checked]:bg-orange-500",
7194
- purple: "focus-visible:ring-purple-400 data-[state=checked]:bg-purple-500",
7195
- gray: "focus-visible:ring-gray-600 data-[state=checked]:bg-gray-700"
7196
- }
7197
- },
7198
- defaultVariants: {
7199
- size: "md",
7200
- color: "primary"
7201
- }
7202
- }
7203
- );
7204
- cva(
7205
- "pointer-events-none absolute top-0.5 inline-block rounded-full bg-white shadow-lg ring-0 transition-transform",
7206
- {
7207
- variants: {
7208
- size: {
7209
- sm: "h-4 w-4 data-[state=checked]:translate-x-4.5 data-[state=unchecked]:translate-x-0.5",
7210
- md: "h-5 w-5 data-[state=checked]:translate-x-5.5 data-[state=unchecked]:translate-x-0.5",
7211
- lg: "h-6 w-6 data-[state=checked]:translate-x-7.5 data-[state=unchecked]:translate-x-0.5"
7212
- }
7213
- },
7214
- defaultVariants: {
7215
- size: "md"
7216
- }
7217
- }
7218
- );
7219
- cva("", {
7220
- variants: {
7221
- bg: {
7222
- danger: "bg-danger-50",
7223
- gray: "bg-gray-400",
7224
- info: "bg-info-50",
7225
- orange: "bg-orange-50",
7226
- primary: "bg-primary-1000",
7227
- success: "bg-success-50",
7228
- purple: "bg-purple-50",
7229
- secondary: "bg-white",
7230
- warning: "bg-warning-50"
7231
- },
7232
- text: {
7233
- danger: "text-danger-500",
7234
- gray: "text-gray-700",
7235
- info: "text-info-500",
7236
- orange: "text-orange-500",
7237
- primary: "text-white",
7238
- success: "text-success-500",
7239
- purple: "text-purple-500",
7240
- secondary: "text-primary-1000",
7241
- warning: "text-warning-500"
7242
- }
7243
- }
7244
- });
7245
- createContext(null);
7246
- createContext(void 0);
7247
- createContext(null);
7248
- function ButtonMore({ count, onClick }) {
6271
+ };
6272
+ var ItemDropdown = ({
6273
+ active,
6274
+ value,
6275
+ onClick
6276
+ }) => {
7249
6277
  return /* @__PURE__ */ jsx(
7250
6278
  "button",
7251
6279
  {
7252
- type: "button",
7253
6280
  onClick,
7254
- className: "h-full w-full cursor-pointer px-1 transition-colors hover:bg-gray-50",
7255
- title: `+${count} more`,
7256
- children: /* @__PURE__ */ jsxs(Text, { weight: "medium", className: "line-clamp-1 text-gray-700", children: [
7257
- "+",
7258
- count,
7259
- " more"
7260
- ] })
6281
+ className: cn(
6282
+ "w-full min-w-23.5 cursor-pointer rounded-md border px-1.5 py-1 text-sm transition-colors outline-none",
6283
+ active ? "bg-primary-50 border-primary-300" : "border-transparent hover:bg-gray-50"
6284
+ ),
6285
+ children: /* @__PURE__ */ jsx(Text, { value, weight: "medium" })
7261
6286
  }
7262
6287
  );
7263
- }
7264
-
7265
- // src/components/calendar/helpers/create-date-style-helpers.ts
7266
- function createDateStyleHelpers({
7267
- isSelected,
7268
- isDisabled,
7269
- isCurrentMonth,
7270
- styleConfig,
7271
- day
6288
+ };
6289
+ var DropdownWrapper = ({
6290
+ children,
6291
+ onClose
6292
+ }) => {
6293
+ return /* @__PURE__ */ jsx("div", { className: "relative", onClick: () => onClose(false), children: /* @__PURE__ */ jsx("div", { className: "absolute top-5 left-1/2 z-20 max-h-48 -translate-x-1/2 space-y-1 overflow-y-auto rounded-lg bg-white px-2 py-1 shadow-md", children }) });
6294
+ };
6295
+ var header_size_map = {
6296
+ sm: "t2",
6297
+ md: "t1",
6298
+ lg: "p3"
6299
+ };
6300
+ function CalendarHeader({
6301
+ size = "md",
6302
+ showNavigator,
6303
+ calendar,
6304
+ dropdown,
6305
+ months,
6306
+ handleNextMonth,
6307
+ handlePrevMonth,
6308
+ showNextNavigator,
6309
+ showPrevNavigator
7272
6310
  }) {
7273
- const getSelectedStyle = (styleConfig2) => {
7274
- return {
7275
- backgroundColor: styleConfig2?.selected?.background,
7276
- color: styleConfig2?.selected?.text
7277
- };
7278
- };
7279
- const getDisabledStyle = (styleConfig2) => {
7280
- return {
7281
- backgroundColor: styleConfig2?.disabled?.background,
7282
- color: styleConfig2?.disabled?.text
7283
- };
7284
- };
7285
- const getDayStyle = () => {
7286
- if (isSelected) {
7287
- return getSelectedStyle(styleConfig);
7288
- } else if (isDisabled && day.month === "current") {
7289
- return getDisabledStyle(styleConfig);
6311
+ const { currentMonth, currentYear } = calendar;
6312
+ const years = useMemo(() => {
6313
+ const yearRange = [];
6314
+ for (let i = currentYear - 100; i <= currentYear + 100; i++) {
6315
+ yearRange.push(i);
7290
6316
  }
7291
- return {};
7292
- };
7293
- const getCursorClass = () => {
7294
- if (isDisabled && isCurrentMonth) {
7295
- return "cursor-not-allowed";
7296
- }
7297
- return "cursor-pointer";
7298
- };
7299
- const getTextColorClass = () => {
7300
- if (!isCurrentMonth) {
7301
- return "[&>h5]:text-gray-500";
7302
- }
7303
- if (isSelected && styleConfig?.selected?.text != null) {
7304
- return "";
7305
- }
7306
- if (isSelected) {
7307
- return "[&>h5]:text-white!";
7308
- }
7309
- if (isDisabled && styleConfig?.disabled?.text != null) {
7310
- return "";
7311
- }
7312
- if (isDisabled) {
7313
- return "*:text-red-500!";
7314
- }
7315
- if (isToday(day)) {
7316
- return "*:text-info-500!";
7317
- }
7318
- return "*:text-gray-700!";
7319
- };
7320
- const getBackgroundClass = () => {
7321
- if (isSelected && styleConfig?.selected?.background != null) {
7322
- return "";
7323
- }
7324
- if (isSelected) {
7325
- return "bg-primary-1000";
7326
- }
7327
- if (isDisabled && isCurrentMonth && styleConfig?.disabled?.background != null) {
7328
- return "";
7329
- }
7330
- if (isDisabled && isCurrentMonth) {
7331
- return "bg-red-500/30";
7332
- }
7333
- if (!isDisabled) {
7334
- return "hover:bg-gray-100 group-hover:bg-gray-100";
7335
- }
7336
- return "";
7337
- };
7338
- return { getBackgroundClass, getTextColorClass, getCursorClass, getDayStyle };
6317
+ return yearRange;
6318
+ }, [currentYear]);
6319
+ return /* @__PURE__ */ jsxs("div", { className: "mb-6 flex items-center justify-between", children: [
6320
+ showNavigator && /* @__PURE__ */ jsx(
6321
+ NavigatorButton,
6322
+ {
6323
+ size,
6324
+ direction: "prev",
6325
+ onClick: handlePrevMonth,
6326
+ visible: showPrevNavigator
6327
+ }
6328
+ ),
6329
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6330
+ showNavigator && /* @__PURE__ */ jsx(
6331
+ MonthDropdown,
6332
+ {
6333
+ months,
6334
+ calendar,
6335
+ dropdown
6336
+ }
6337
+ ),
6338
+ /* @__PURE__ */ jsx(
6339
+ Text,
6340
+ {
6341
+ as: "span",
6342
+ variant: header_size_map[size],
6343
+ weight: "semibold",
6344
+ value: `${months[currentMonth]} - ${currentYear}`
6345
+ }
6346
+ ),
6347
+ showNavigator && /* @__PURE__ */ jsx(YearDropdown, { years, calendar, dropdown })
6348
+ ] }),
6349
+ showNavigator && /* @__PURE__ */ jsx(
6350
+ NavigatorButton,
6351
+ {
6352
+ direction: "next",
6353
+ size,
6354
+ onClick: handleNextMonth,
6355
+ visible: showNextNavigator
6356
+ }
6357
+ )
6358
+ ] });
7339
6359
  }
7340
- var date_size_map = {
7341
- md: "size-7.5",
7342
- sm: "size-6",
7343
- lg: "size-9"
7344
- };
7345
- function CalendarDayItem({
7346
- day,
7347
- helpers,
6360
+ function MonthDropdown({ months, calendar, dropdown }) {
6361
+ const { currentMonth, setCurrentMonth } = calendar;
6362
+ const { isMonthOpen, setMonthOpen } = dropdown;
6363
+ return /* @__PURE__ */ jsxs("div", { children: [
6364
+ /* @__PURE__ */ jsx(
6365
+ ButtonDropdown,
6366
+ {
6367
+ onClick: () => setMonthOpen(!isMonthOpen),
6368
+ active: isMonthOpen
6369
+ }
6370
+ ),
6371
+ isMonthOpen && /* @__PURE__ */ jsx(DropdownWrapper, { onClose: setMonthOpen, children: months.map((month2, index) => /* @__PURE__ */ jsx(
6372
+ ItemDropdown,
6373
+ {
6374
+ onClick: () => setCurrentMonth(index),
6375
+ active: currentMonth === index,
6376
+ value: month2
6377
+ },
6378
+ index
6379
+ )) })
6380
+ ] });
6381
+ }
6382
+ function YearDropdown({ calendar, dropdown, years }) {
6383
+ const { currentYear, setCurrentYear } = calendar;
6384
+ const { isYearOpen, setYearOpen } = dropdown;
6385
+ return /* @__PURE__ */ jsxs("div", { children: [
6386
+ /* @__PURE__ */ jsx(
6387
+ ButtonDropdown,
6388
+ {
6389
+ onClick: () => setYearOpen(!isYearOpen),
6390
+ active: isYearOpen
6391
+ }
6392
+ ),
6393
+ isYearOpen && /* @__PURE__ */ jsx(DropdownWrapper, { onClose: setYearOpen, children: years.map((year) => /* @__PURE__ */ jsx(
6394
+ ItemDropdown,
6395
+ {
6396
+ onClick: () => setCurrentYear(year),
6397
+ active: currentYear === year,
6398
+ value: year.toString()
6399
+ },
6400
+ year
6401
+ )) })
6402
+ ] });
6403
+ }
6404
+ function NavigatorButton({
6405
+ direction,
7348
6406
  size,
7349
- mode,
7350
- styleConfig,
7351
6407
  onClick,
7352
- variant,
7353
- events,
7354
- backdropOnClick
6408
+ visible = true
6409
+ }) {
6410
+ const icon = direction === "prev" ? "angle-left-small" : "angle-right-small";
6411
+ return /* @__PURE__ */ jsx(
6412
+ ButtonNavigator,
6413
+ {
6414
+ size,
6415
+ onClick,
6416
+ icon,
6417
+ className: visible ? "" : "pointer-events-none opacity-0"
6418
+ }
6419
+ );
6420
+ }
6421
+ var day_of_week_size = {
6422
+ sm: "t2",
6423
+ md: "t2",
6424
+ lg: "t1"
6425
+ };
6426
+ function DaysOfWeek({
6427
+ daysOfWeek,
6428
+ size = "md",
6429
+ wrapperClassName,
6430
+ variant = "default",
6431
+ type = "month",
6432
+ renderItem
7355
6433
  }) {
7356
- const dayConfig = helpers.getDayConfig(day);
7357
- const isSelected = helpers.isDateSelected(day);
7358
- const dots = dayConfig?.dots || [];
7359
- const isCurrentMonth = day.month === "current";
7360
- const isDisabled = (dayConfig?.disabled ?? false) || helpers.isDateDisabled(day);
7361
- const rangeStart = helpers.isRangeStart(day);
7362
- const rangeEnd = helpers.isRangeEnd(day);
7363
- const currentDate = formatDateLocal(day.fullDate);
7364
- const hasEvent = events?.find((event) => {
7365
- const start = new Date(event.startDate);
7366
- const end = new Date(event.endDate);
7367
- return new Date(currentDate) >= start && new Date(currentDate) <= end;
7368
- })?.title;
7369
- const styleHelpers = createDateStyleHelpers({
7370
- day,
7371
- isSelected: isSelected || rangeStart || rangeEnd,
7372
- isCurrentMonth,
7373
- isDisabled,
7374
- styleConfig
7375
- });
7376
6434
  return /* @__PURE__ */ jsxs(
7377
- "button",
6435
+ "div",
7378
6436
  {
7379
- style: styleHelpers.getDayStyle(),
7380
- onClick: () => onClick(day),
7381
- disabled: isDisabled && isCurrentMonth,
7382
- className: clsx9(
7383
- date_size_map[size ?? "md"],
7384
- styleHelpers.getCursorClass(),
7385
- styleHelpers.getTextColorClass(),
7386
- "group relative flex flex-col items-center justify-center rounded-full text-sm font-medium transition-all duration-200",
7387
- mode === "single" && variant === "compact" && styleHelpers.getBackgroundClass(),
6437
+ className: clsx4(
6438
+ "grid justify-items-center",
6439
+ variant === "compact" && "calendar-cols mb-3 gap-x-1 *:text-center!",
6440
+ variant === "default" && "w-full bg-gray-100 *:p-3 *:w-full *:text-start! *:border-r *:border-gray-300 *:last:border-r-0",
7388
6441
  //prettier-ignore
7389
- mode === "range" && !isDisabled && helpers.getRangeBackgroundClass(day),
7390
- variant === "default" && "h-28 md:h-36 w-full rounded-none flex items-start justify-start group p-1 md:p-3 border-r border-gray-300"
6442
+ variant === "default" && type === "month" && "grid-cols-7",
6443
+ variant === "default" && type === "week" && "grid-cols-[60px_1fr_1fr_1fr_1fr_1fr_1fr_1fr]",
7391
6444
  //prettier-ignore
6445
+ wrapperClassName
7392
6446
  ),
7393
6447
  children: [
7394
- /* @__PURE__ */ jsx(
7395
- "div",
7396
- {
7397
- className: "absolute inset-0 size-full cursor-pointer",
7398
- onClick: () => backdropOnClick?.(day)
7399
- }
7400
- ),
7401
- /* @__PURE__ */ jsx(
7402
- "h5",
6448
+ type === "week" && variant === "default" && renderItem === void 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
6449
+ /* @__PURE__ */ jsx("div", {}),
6450
+ daysOfWeek.map((day) => /* @__PURE__ */ jsx(Text, { as: "h5", value: day, variant: "t1" }, day))
6451
+ ] }),
6452
+ type === "month" && renderItem === void 0 && daysOfWeek.map((day) => /* @__PURE__ */ jsx(
6453
+ Text,
7403
6454
  {
7404
- className: clsx9(
7405
- "font-metropolis text-xs transition-colors",
7406
- variant === "default" && "grid size-8 place-items-center justify-center rounded-full",
7407
- //prettier-ignore
7408
- mode === "single" && variant === "default" && styleHelpers.getBackgroundClass()
7409
- //prettier-ignore
6455
+ as: "h5",
6456
+ weight: variant === "compact" ? "medium" : "semibold",
6457
+ value: day,
6458
+ className: clsx4(
6459
+ variant === "compact" && "text-gray-600!",
6460
+ variant === "default" && "text-gray-900! uppercase"
7410
6461
  ),
7411
- children: day.date
7412
- }
7413
- ),
7414
- variant === "default" && Boolean(hasEvent) === false && backdropOnClick && /* @__PURE__ */ jsx("div", { className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
7415
- /* @__PURE__ */ jsx(TooltipTrigger, { className: "cursor-pointer", children: /* @__PURE__ */ jsx(
7416
- Icon,
7417
- {
7418
- name: "plus",
7419
- className: "text-gray-700! opacity-0 transition-opacity group-hover:opacity-100",
7420
- size: 20
7421
- }
7422
- ) }),
7423
- /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", children: "Add Schedule" })
7424
- ] }) }),
7425
- variant === "compact" && dots.length > 0 && /* @__PURE__ */ jsx("div", { className: "-mb-1 flex gap-0.5", children: dots.map((dot, i) => /* @__PURE__ */ jsx(
7426
- "div",
7427
- {
7428
- className: "size-1 rounded-full",
7429
- style: {
7430
- backgroundColor: dot.color ?? "#d1d5db"
7431
- }
6462
+ variant: variant === "compact" ? day_of_week_size[size] : "t1"
7432
6463
  },
7433
- i
7434
- )) })
6464
+ day
6465
+ ))
7435
6466
  ]
7436
6467
  }
7437
6468
  );
7438
6469
  }
7439
- function EventBar({
7440
- segment,
7441
- showTooltip = true,
7442
- onClick
7443
- }) {
7444
- const [hovered, setHovered] = useState(false);
7445
- const [pos, setPos] = useState({ x: 0, y: 0 });
7446
- const handleMouseMove = (e) => {
7447
- setPos({
7448
- x: e.clientX,
7449
- y: e.clientY
6470
+
6471
+ // src/components/calendar/constants.tsx
6472
+ var typeOptions = [
6473
+ // {
6474
+ // label: 'Year',
6475
+ // value: 'year',
6476
+ // },
6477
+ {
6478
+ label: "Month",
6479
+ value: "month"
6480
+ },
6481
+ {
6482
+ label: "Week",
6483
+ value: "week"
6484
+ }
6485
+ // {
6486
+ // label: 'Day',
6487
+ // value: 'day',
6488
+ // },
6489
+ // {
6490
+ // label: 'Agenda',
6491
+ // value: 'agenda',
6492
+ // },
6493
+ ];
6494
+ var days = ["Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"];
6495
+ var month = [
6496
+ "Januari",
6497
+ "Februari",
6498
+ "Maret",
6499
+ "April",
6500
+ "Mei",
6501
+ "Juni",
6502
+ "Juli",
6503
+ "Agustus",
6504
+ "September",
6505
+ "Oktober",
6506
+ "November",
6507
+ "Desember"
6508
+ ];
6509
+ var Calendar2 = ({
6510
+ showNavigator = true,
6511
+ showHeader = true,
6512
+ value,
6513
+ onChange,
6514
+ disabledDates = [],
6515
+ dayConfigs = [],
6516
+ defaultMonth,
6517
+ defaultYear,
6518
+ styleConfig,
6519
+ wrapperClassname,
6520
+ weekWrapperClassname,
6521
+ dayWrapperClassname,
6522
+ daysOfWeek = days,
6523
+ months = month,
6524
+ showNextNavigator = true,
6525
+ showPrevNavigator = true,
6526
+ mode = "single",
6527
+ rangeValue,
6528
+ size = "md",
6529
+ variant = "default",
6530
+ events,
6531
+ showCalendarTooltip = true,
6532
+ type = "month",
6533
+ onTypeChange,
6534
+ onEventClick,
6535
+ backdropOnClick,
6536
+ onMonthChange,
6537
+ onYearChange,
6538
+ showDefaultController = false
6539
+ }) => {
6540
+ const currentDate = /* @__PURE__ */ new Date();
6541
+ const [currentMonth, setCurrentMonth] = useState(defaultMonth ?? currentDate.getMonth());
6542
+ const [currentYear, setCurrentYear] = useState(defaultYear ?? currentDate.getFullYear());
6543
+ const [isDropdownYearShow, setIsDropdownYearShow] = useState(false);
6544
+ const [isDropdownMonthShow, setIsDropdownMonthShow] = useState(false);
6545
+ const [selectedType, setSelectedType] = useState(type);
6546
+ const [selectedTypeIndex, setSelectedTypeIndex] = useState(
6547
+ null
6548
+ );
6549
+ const [currentWeekStart, setCurrentWeekStart] = useState(() => {
6550
+ const today = /* @__PURE__ */ new Date();
6551
+ const day = today.getDay();
6552
+ const start = new Date(today);
6553
+ start.setDate(today.getDate() - day);
6554
+ start.setHours(0, 0, 0, 0);
6555
+ return start;
6556
+ });
6557
+ const calendarDays = getCalendarDays({ currentMonth, currentYear });
6558
+ const calendarHelpers = createCalendarHelpers({
6559
+ disabledDates,
6560
+ dayConfigs,
6561
+ rangeValue,
6562
+ mode,
6563
+ value
6564
+ });
6565
+ const calendarState = {
6566
+ currentMonth,
6567
+ currentYear,
6568
+ setCurrentMonth,
6569
+ setCurrentYear
6570
+ };
6571
+ const dropdownState = {
6572
+ isMonthOpen: isDropdownMonthShow,
6573
+ setMonthOpen: setIsDropdownMonthShow,
6574
+ isYearOpen: isDropdownYearShow,
6575
+ setYearOpen: setIsDropdownYearShow
6576
+ };
6577
+ const handleDateClick = (day) => {
6578
+ const dayConfig = calendarHelpers.getDayConfig(day);
6579
+ const disabled = (dayConfig?.disabled ?? false) || calendarHelpers.isDateDisabled(day);
6580
+ if (disabled) {
6581
+ return;
6582
+ }
6583
+ onChange?.(day.fullDate);
6584
+ };
6585
+ const getWeekDaysLabel = (weekStart) => {
6586
+ return Array.from({ length: 7 }, (_, i) => {
6587
+ const d = new Date(weekStart);
6588
+ d.setDate(weekStart.getDate() + i);
6589
+ const dayName = daysOfWeek[d.getDay()];
6590
+ const date = d.getDate();
6591
+ return `${dayName} ${date}`;
7450
6592
  });
7451
6593
  };
7452
- const bg_color_map = {
7453
- info: "#F1FDFF",
7454
- purple: "#EEEBFF",
7455
- orange: "#FFFBED",
7456
- success: "#EAFFEC",
7457
- danger: "#FEF3F2",
7458
- warning: "#FFFAEB",
7459
- primary: "#F1F2FF"
6594
+ const changeWeek = (delta) => {
6595
+ setCurrentWeekStart((prev) => {
6596
+ const next = new Date(prev);
6597
+ next.setDate(prev.getDate() + delta * 7);
6598
+ setCurrentMonth(next.getMonth());
6599
+ setCurrentYear(next.getFullYear());
6600
+ return next;
6601
+ });
7460
6602
  };
7461
- const ribbon_color_map = {
7462
- info: "#6CD8FF",
7463
- purple: "#A6A6FB",
7464
- orange: "#FFDA71",
7465
- success: "#6BE995",
7466
- danger: "#FDA29B",
7467
- warning: "#FEC84B",
7468
- primary: "#ABB1FF"
6603
+ const changeMonth = (delta) => {
6604
+ let newMonth = currentMonth + delta;
6605
+ let newYear = currentYear;
6606
+ if (newMonth < 0) {
6607
+ newMonth = 11;
6608
+ newYear -= 1;
6609
+ } else if (newMonth > 11) {
6610
+ newMonth = 0;
6611
+ newYear += 1;
6612
+ }
6613
+ onMonthChange?.(newMonth);
6614
+ onYearChange?.(newYear);
6615
+ setCurrentMonth(newMonth);
6616
+ setCurrentYear(newYear);
7469
6617
  };
7470
- return /* @__PURE__ */ jsxs(Fragment, { children: [
7471
- /* @__PURE__ */ jsxs(
7472
- "button",
7473
- {
7474
- type: "button",
7475
- onClick: () => onClick?.(segment),
7476
- onMouseEnter: () => setHovered(true),
7477
- onMouseLeave: () => setHovered(false),
7478
- onMouseMove: handleMouseMove,
7479
- className: clsx9(
7480
- "relative mx-0.5 mt-1 flex items-center justify-between gap-3 overflow-hidden rounded p-1 text-[11px] leading-5 font-medium md:p-1.5",
7481
- onClick && "cursor-pointer"
7482
- ),
7483
- style: {
7484
- gridColumn: `${segment.startCol + 1} / span ${segment.span}`,
7485
- backgroundColor: bg_color_map[segment?.event?.color ?? "info"] ?? "#F1FDFF"
7486
- },
7487
- children: [
6618
+ const handleNavigationDefault = (type2, action) => {
6619
+ if (type2 === "month") {
6620
+ if (action === "prev") {
6621
+ return changeMonth(-1);
6622
+ } else {
6623
+ return changeMonth(1);
6624
+ }
6625
+ }
6626
+ if (type2 === "week") {
6627
+ if (action === "prev") {
6628
+ return changeWeek(1);
6629
+ } else {
6630
+ return changeWeek(-1);
6631
+ }
6632
+ }
6633
+ };
6634
+ useEffect(() => {
6635
+ if (value !== void 0) {
6636
+ setCurrentMonth(
6637
+ value?.getMonth() ?? defaultMonth ?? currentDate?.getMonth()
6638
+ );
6639
+ setCurrentYear(
6640
+ value?.getFullYear() ?? defaultYear ?? currentDate?.getFullYear()
6641
+ );
6642
+ }
6643
+ }, [value]);
6644
+ useEffect(() => {
6645
+ if (type !== void 0) {
6646
+ setSelectedType(type);
6647
+ }
6648
+ }, [type]);
6649
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: clsx4(variant === "default" && "flex flex-col gap-2"), children: [
6650
+ variant === "default" && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
6651
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-6", children: [
6652
+ /* @__PURE__ */ jsxs("div", { className: "*:cursor-pointer", children: [
7488
6653
  /* @__PURE__ */ jsx(
7489
- "span",
6654
+ ButtonNavigation,
7490
6655
  {
7491
- className: "absolute left-0 h-full w-1",
7492
- style: {
7493
- backgroundColor: ribbon_color_map[segment?.event?.color ?? "info"] ?? "#6CD8FF"
7494
- }
6656
+ onClick: () => handleNavigationDefault(selectedType, "prev"),
6657
+ type: "prev"
7495
6658
  }
7496
6659
  ),
7497
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-px pl-2 *:line-clamp-1", children: [
7498
- /* @__PURE__ */ jsx(Text, { variant: "t3", weight: "semibold", className: "text-gray-800", children: segment.event.title }),
7499
- /* @__PURE__ */ jsx(Text, { variant: "t3", className: "text-gray-700", children: segment.event.subtitle })
7500
- ] }),
7501
- /* @__PURE__ */ jsx(Text, { variant: "t3", className: "line-clamp-1 text-gray-800", children: segment.event.label })
7502
- ]
7503
- }
7504
- ),
7505
- hovered && showTooltip === true && /* @__PURE__ */ jsx(
7506
- "div",
7507
- {
7508
- className: "pointer-events-none fixed z-50",
7509
- style: {
7510
- top: pos.y + 12,
7511
- left: pos.x + 12
7512
- },
7513
- children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col rounded-lg bg-white p-3 shadow", children: [
7514
- /* @__PURE__ */ jsx(Text, { variant: "t3", weight: "semibold", className: "text-gray-800", children: segment.event.title }),
7515
- Boolean(segment.event.subtitle) && /* @__PURE__ */ jsx(Text, { variant: "t3", className: "text-gray-700", children: segment.event.subtitle }),
7516
- Boolean(segment.event.label) && /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-1", children: [
7517
- /* @__PURE__ */ jsx(
7518
- "div",
7519
- {
7520
- className: "size-1 rounded-full",
7521
- style: {
7522
- backgroundColor: ribbon_color_map[segment.event.color ?? "info"] ?? "#6CD8FF"
7523
- }
6660
+ /* @__PURE__ */ jsx(
6661
+ ButtonNavigation,
6662
+ {
6663
+ onClick: () => handleNavigationDefault(selectedType, "next"),
6664
+ type: "next"
6665
+ }
6666
+ )
6667
+ ] }),
6668
+ /* @__PURE__ */ jsxs(
6669
+ Text,
6670
+ {
6671
+ variant: "h4",
6672
+ weight: "semibold",
6673
+ className: "-translate-y-0.5 text-gray-900",
6674
+ children: [
6675
+ months[currentMonth],
6676
+ " ",
6677
+ currentYear
6678
+ ]
6679
+ }
6680
+ )
6681
+ ] }),
6682
+ showDefaultController && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6683
+ /* @__PURE__ */ jsx(
6684
+ Button,
6685
+ {
6686
+ size: "sm",
6687
+ color: "gray",
6688
+ variant: "outline",
6689
+ className: "capitalize",
6690
+ onClick: () => setCurrentMonth((/* @__PURE__ */ new Date()).getMonth()),
6691
+ children: "Today"
6692
+ }
6693
+ ),
6694
+ /* @__PURE__ */ jsxs(Dropdown, { children: [
6695
+ /* @__PURE__ */ jsx(DropdownTrigger, { children: /* @__PURE__ */ jsxs(
6696
+ Button,
6697
+ {
6698
+ size: "sm",
6699
+ color: "gray",
6700
+ variant: "outline",
6701
+ className: "flex items-center capitalize",
6702
+ children: [
6703
+ selectedType,
6704
+ " ",
6705
+ /* @__PURE__ */ jsx(Icon, { name: "angle-down-small", size: 20 })
6706
+ ]
6707
+ }
6708
+ ) }),
6709
+ /* @__PURE__ */ jsx(
6710
+ DropdownContent,
6711
+ {
6712
+ align: "end",
6713
+ className: "w-36 *:rounded-md *:border-0",
6714
+ children: typeOptions.map((option, index) => /* @__PURE__ */ jsx(
6715
+ DropdownItem,
6716
+ {
6717
+ onFocus: () => setSelectedTypeIndex(index),
6718
+ onClick: () => {
6719
+ setSelectedType(option.value);
6720
+ onTypeChange?.(option.value);
6721
+ },
6722
+ className: clsx4(
6723
+ (selectedType === option.value || index === selectedTypeIndex) && "bg-primary-50!"
6724
+ ),
6725
+ children: /* @__PURE__ */ jsx(Text, { className: "text-gray-900", children: option.label })
6726
+ },
6727
+ option.value
6728
+ ))
6729
+ }
6730
+ )
6731
+ ] })
6732
+ ] })
6733
+ ] }),
6734
+ /* @__PURE__ */ jsxs(
6735
+ "div",
6736
+ {
6737
+ className: cn(
6738
+ "border bg-white",
6739
+ variant === "compact" && "mx-auto w-fit rounded-2xl border-gray-200 p-6 ",
6740
+ //prettier-ignore
6741
+ variant === "default" && "overflow-hidden rounded-xl border-gray-300",
6742
+ //prettier-ignore
6743
+ wrapperClassname
6744
+ ),
6745
+ children: [
6746
+ selectedType === "week" && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
6747
+ DaysOfWeek,
6748
+ {
6749
+ type: "week",
6750
+ size,
6751
+ variant,
6752
+ daysOfWeek: getWeekDaysLabel(currentWeekStart),
6753
+ wrapperClassName: weekWrapperClassname
6754
+ }
6755
+ ) }),
6756
+ selectedType === "month" && /* @__PURE__ */ jsxs(Fragment, { children: [
6757
+ showHeader && variant === "compact" && /* @__PURE__ */ jsx(
6758
+ CalendarHeader,
6759
+ {
6760
+ size,
6761
+ calendar: calendarState,
6762
+ dropdown: dropdownState,
6763
+ handleNextMonth: () => changeMonth(1),
6764
+ handlePrevMonth: () => changeMonth(-1),
6765
+ showNavigator,
6766
+ months,
6767
+ showNextNavigator,
6768
+ showPrevNavigator
6769
+ }
6770
+ ),
6771
+ /* @__PURE__ */ jsx(
6772
+ DaysOfWeek,
6773
+ {
6774
+ size,
6775
+ variant,
6776
+ daysOfWeek,
6777
+ wrapperClassName: weekWrapperClassname
7524
6778
  }
7525
6779
  ),
7526
- /* @__PURE__ */ jsx(Text, { variant: "t3", className: clsx9("text-gray-800"), children: segment.event.label })
6780
+ /* @__PURE__ */ jsx(
6781
+ CalendarGrid,
6782
+ {
6783
+ className: dayWrapperClassname,
6784
+ days: calendarDays,
6785
+ helpers: calendarHelpers,
6786
+ size,
6787
+ mode,
6788
+ styleConfig,
6789
+ onClick: handleDateClick,
6790
+ variant,
6791
+ events,
6792
+ showCalendarTooltip,
6793
+ onEventClick,
6794
+ backdropOnClick
6795
+ }
6796
+ )
7527
6797
  ] })
7528
- ] })
6798
+ ]
7529
6799
  }
7530
6800
  )
7531
- ] });
7532
- }
7533
- function CalendarGrid({
7534
- days: days2,
7535
- helpers,
7536
- size,
7537
- mode,
7538
- styleConfig,
6801
+ ] }) });
6802
+ };
6803
+ var ButtonNavigation = ({
7539
6804
  onClick,
6805
+ type
6806
+ }) => {
6807
+ return /* @__PURE__ */ jsx("button", { onClick, children: /* @__PURE__ */ jsx(
6808
+ Icon,
6809
+ {
6810
+ name: type === "next" ? "angle-right-small" : "angle-left-small",
6811
+ size: 30,
6812
+ className: "text-gray-900"
6813
+ }
6814
+ ) });
6815
+ };
6816
+ var inputVariants = cva(
6817
+ "w-full min-w-0 rounded-lg border bg-transparent px-3 py-2 text-base font-medium text-gray-800 shadow-xs transition outline-none placeholder:text-gray-500",
6818
+ {
6819
+ variants: {
6820
+ size: {
6821
+ sm: "h-8 text-xs",
6822
+ md: "h-9 text-sm",
6823
+ lg: "h-10 text-base"
6824
+ }
6825
+ },
6826
+ defaultVariants: {
6827
+ size: "md"
6828
+ }
6829
+ }
6830
+ );
6831
+ var FormDescription = ({
7540
6832
  className,
7541
- variant,
7542
- events = [],
7543
- showCalendarTooltip = true,
7544
- backdropOnClick,
7545
- onEventClick
7546
- }) {
7547
- const isMobile = useIsMobile();
7548
- const weeks = Array.from(
7549
- { length: Math.ceil(days2.length / 7) },
7550
- (_, i) => days2.slice(i * 7, i * 7 + 7)
7551
- );
7552
- return /* @__PURE__ */ jsx(
7553
- "div",
6833
+ children
6834
+ }) => {
6835
+ return /* @__PURE__ */ jsx("p", { className: cn("text-xs text-gray-600", className), children });
6836
+ };
6837
+ var FormErrorMessages = ({
6838
+ messages,
6839
+ size = "md",
6840
+ className
6841
+ }) => {
6842
+ if (messages === void 0) return null;
6843
+ const errorList = Array.isArray(messages) ? messages : [messages];
6844
+ if (errorList.length === 0) return null;
6845
+ return /* @__PURE__ */ jsx("div", { className: cn("space-y-0.5", className), children: errorList.map((msg, i) => /* @__PURE__ */ jsx(FormErrorMessage, { size, children: msg }, i)) });
6846
+ };
6847
+ var FormErrorMessage = ({
6848
+ className,
6849
+ children
6850
+ }) => {
6851
+ return /* @__PURE__ */ jsx("p", { className: cn("text-danger-500 text-xs", className), children });
6852
+ };
6853
+ var FormLabel = ({
6854
+ htmlFor,
6855
+ required = false,
6856
+ size = "md",
6857
+ className,
6858
+ children
6859
+ }) => {
6860
+ const sizeClasses = {
6861
+ sm: "text-xs",
6862
+ md: "text-xs",
6863
+ lg: "text-sm"
6864
+ };
6865
+ return /* @__PURE__ */ jsxs(
6866
+ "label",
7554
6867
  {
7555
- className: clsx9(
7556
- "relative",
7557
- variant === "compact" && size === "sm" && "space-y-1"
6868
+ htmlFor,
6869
+ className: cn(
6870
+ sizeClasses[size || "md"],
6871
+ "font-metropolis block font-semibold text-gray-900",
6872
+ className
7558
6873
  ),
7559
- children: weeks.map((week, weekIndex) => {
7560
- const segments = getWeekEventSegments({ week, events });
7561
- const threshold = isMobile ? 1 : 2;
7562
- const displayLimit = 1;
7563
- const segmentLevels = /* @__PURE__ */ new Map();
7564
- segments.forEach((seg) => {
7565
- let placed = false;
7566
- for (let level = 0; level < threshold; level++) {
7567
- const conflict = segments.some((other) => {
7568
- if (other === seg) return false;
7569
- const otherLevel = segmentLevels.get(other);
7570
- if (otherLevel !== level) return false;
7571
- const segStart = seg.startCol;
7572
- const segEnd = seg.startCol + seg.span - 1;
7573
- const otherStart = other.startCol;
7574
- const otherEnd = other.startCol + other.span - 1;
7575
- return !(segEnd < otherStart || segStart > otherEnd);
7576
- });
7577
- if (!conflict) {
7578
- segmentLevels.set(seg, level);
7579
- placed = true;
7580
- break;
7581
- }
7582
- }
7583
- if (!placed) {
7584
- segmentLevels.set(seg, threshold);
7585
- }
7586
- });
7587
- const columnHiddenCount = Array(7).fill(0);
7588
- segments.forEach((seg) => {
7589
- const level = segmentLevels.get(seg) ?? 0;
7590
- if (level >= threshold) {
7591
- for (let i = 0; i < seg.span; i++) {
7592
- const col = seg.startCol + i;
7593
- if (col >= 0 && col < 7) {
7594
- columnHiddenCount[col]++;
7595
- }
7596
- }
7597
- }
7598
- });
7599
- const hasOverflow = segments.length > threshold;
7600
- const visibleSegments = segments.filter((seg) => {
7601
- const level = segmentLevels.get(seg) ?? 0;
7602
- if (!hasOverflow) {
7603
- return level < threshold;
7604
- }
7605
- return level < displayLimit;
7606
- });
7607
- const columnHiddenSegments = Array.from(
7608
- { length: 7 },
7609
- () => []
7610
- );
7611
- segments.forEach((seg) => {
7612
- const isVisible = visibleSegments.includes(seg);
7613
- if (!isVisible) {
7614
- for (let i = 0; i < seg.span; i++) {
7615
- const col = seg.startCol + i;
7616
- if (col >= 0 && col < 7) {
7617
- columnHiddenSegments[col].push(seg);
7618
- }
7619
- }
7620
- }
7621
- });
7622
- const columnTotalCount = Array(7).fill(0);
7623
- segments.forEach((seg) => {
7624
- for (let i = 0; i < seg.span; i++) {
7625
- const col = seg.startCol + i;
7626
- if (col >= 0 && col < 7) {
7627
- columnTotalCount[col]++;
7628
- }
7629
- }
7630
- });
7631
- const columnVisibleCount = Array(7).fill(0);
7632
- visibleSegments.forEach((seg) => {
7633
- for (let i = 0; i < seg.span; i++) {
7634
- const col = seg.startCol + i;
7635
- if (col >= 0 && col < 7) {
7636
- columnVisibleCount[col]++;
7637
- }
7638
- }
7639
- });
7640
- const columnMoreCount = columnTotalCount.map(
7641
- (total, i) => Math.max(0, total - columnVisibleCount[i])
7642
- );
7643
- return /* @__PURE__ */ jsxs(
6874
+ children: [
6875
+ children,
6876
+ required && /* @__PURE__ */ jsx("span", { className: "text-danger-500 ml-1", children: "*" })
6877
+ ]
6878
+ }
6879
+ );
6880
+ };
6881
+ var FormHint = ({ className, children }) => {
6882
+ return /* @__PURE__ */ jsx("p", { className: cn("text-xs text-gray-700", className), children });
6883
+ };
6884
+ var FormField = React282__default.forwardRef(
6885
+ function FormField2({
6886
+ label,
6887
+ description,
6888
+ hint,
6889
+ errorMessages,
6890
+ required = false,
6891
+ size = "md",
6892
+ htmlFor,
6893
+ className,
6894
+ children
6895
+ }, ref) {
6896
+ return /* @__PURE__ */ jsxs("div", { ref, className: cn("flex flex-col gap-1", className), children: [
6897
+ label !== void 0 && /* @__PURE__ */ jsx(FormLabel, { htmlFor, required, size, children: label }),
6898
+ description !== void 0 && /* @__PURE__ */ jsx(FormDescription, { size, children: description }),
6899
+ children,
6900
+ hint !== void 0 && /* @__PURE__ */ jsx(FormHint, { size, children: hint }),
6901
+ errorMessages !== void 0 && /* @__PURE__ */ jsx(FormErrorMessages, { messages: errorMessages, size })
6902
+ ] });
6903
+ }
6904
+ );
6905
+ var Input = React282.forwardRef(
6906
+ ({
6907
+ className,
6908
+ leftAddon,
6909
+ rightAddon,
6910
+ type = "text",
6911
+ label,
6912
+ hint,
6913
+ errorMessages,
6914
+ size,
6915
+ inputSize,
6916
+ description,
6917
+ leftAddonClassName,
6918
+ rightAddonClassName,
6919
+ mergedAddon,
6920
+ isError,
6921
+ onContainerResize,
6922
+ ...props
6923
+ }, ref) => {
6924
+ const hasError = fieldHasError(errorMessages) ?? isError;
6925
+ const generatedId = React282.useId();
6926
+ const fieldRef = React282.useRef(null);
6927
+ React282.useEffect(() => {
6928
+ if (!fieldRef.current || !onContainerResize) return;
6929
+ const ro = new ResizeObserver(([entry]) => {
6930
+ onContainerResize(entry.contentRect.width);
6931
+ });
6932
+ ro.observe(fieldRef.current);
6933
+ return () => ro.disconnect();
6934
+ }, [onContainerResize]);
6935
+ return /* @__PURE__ */ jsx(
6936
+ FormField,
6937
+ {
6938
+ ref: fieldRef,
6939
+ label,
6940
+ hint,
6941
+ description,
6942
+ errorMessages,
6943
+ className,
6944
+ required: props.required,
6945
+ size,
6946
+ htmlFor: props?.id ?? generatedId,
6947
+ children: /* @__PURE__ */ jsxs(
7644
6948
  "div",
7645
6949
  {
7646
- className: clsx9(
7647
- "relative",
7648
- variant === "default" && "border-b border-gray-300 last:border-b-0!",
7649
- //prettier-ignore
7650
- className
6950
+ className: cn(
6951
+ "flex w-full items-stretch overflow-hidden rounded-lg border bg-white",
6952
+ hasError ? "border-danger-500 focus-within:border-danger-500" : "focus-within:border-primary-300 border-gray-200"
7651
6953
  ),
7652
6954
  children: [
7653
- /* @__PURE__ */ jsx(
6955
+ Boolean(leftAddon) && /* @__PURE__ */ jsx(
7654
6956
  "div",
7655
6957
  {
7656
- className: clsx9(
7657
- "grid w-full grid-cols-7",
7658
- variant === "default" && "*:border-r *:border-gray-300 [&>*:nth-last-child(1)]:border-r-0",
7659
- //prettier-ignore
7660
- variant === "compact" && "place-items-center"
6958
+ className: cn(
6959
+ leftAddonClassName,
6960
+ "flex items-center justify-center border-r border-gray-200 px-3",
6961
+ Boolean(mergedAddon) && "border-r-0",
6962
+ hasError ? "text-danger-500 border-danger-500" : "border-gray-200 text-gray-600"
7661
6963
  ),
7662
- children: week.map((day, dayIndex) => /* @__PURE__ */ jsx(
7663
- CalendarDayItem,
7664
- {
7665
- day,
7666
- helpers,
7667
- size,
7668
- mode,
7669
- styleConfig,
7670
- onClick,
7671
- variant,
7672
- events,
7673
- backdropOnClick: variant === "default" && backdropOnClick ? (day2) => backdropOnClick?.(day2) : void 0
7674
- },
7675
- dayIndex
7676
- ))
6964
+ children: leftAddon
7677
6965
  }
7678
6966
  ),
7679
- segments.length > 0 && /* @__PURE__ */ jsxs("div", { className: "absolute inset-x-0 bottom-2 grid grid-cols-7 gap-0.5", children: [
7680
- visibleSegments.map((seg, index) => /* @__PURE__ */ jsx(
7681
- EventBar,
7682
- {
7683
- segment: seg,
7684
- showTooltip: showCalendarTooltip,
7685
- onClick: () => onEventClick?.(seg.event)
7686
- },
7687
- index
7688
- )),
7689
- columnMoreCount.map(
7690
- (count, colIndex) => count > 0 ? /* @__PURE__ */ jsxs(Dropdown, { children: [
7691
- /* @__PURE__ */ jsx(DropdownTrigger, { className: "w-full", asChild: true, children: /* @__PURE__ */ jsx("div", { style: { gridColumnStart: colIndex + 1 }, children: /* @__PURE__ */ jsx(ButtonMore, { count }, colIndex) }) }),
7692
- /* @__PURE__ */ jsxs(DropdownContent, { sideOffset: -130, className: "min-w-45", children: [
7693
- /* @__PURE__ */ jsx(
7694
- Text,
7695
- {
7696
- variant: "t2",
7697
- weight: "semibold",
7698
- className: "text-gray-800",
7699
- children: week[colIndex] && new Intl.DateTimeFormat("id-ID", {
7700
- day: "numeric",
7701
- month: "long",
7702
- year: "numeric"
7703
- }).format(week[colIndex].fullDate)
7704
- }
7705
- ),
7706
- columnHiddenSegments[colIndex].map((seg, index) => /* @__PURE__ */ jsx(
7707
- EventBar,
7708
- {
7709
- segment: seg,
7710
- showTooltip: false,
7711
- onClick: () => onEventClick?.(seg.event)
7712
- },
7713
- index
7714
- ))
7715
- ] })
7716
- ] }, colIndex) : null
7717
- )
7718
- ] })
6967
+ /* @__PURE__ */ jsx(
6968
+ "input",
6969
+ {
6970
+ ref,
6971
+ type,
6972
+ size: inputSize,
6973
+ id: props?.id ?? generatedId,
6974
+ className: cn(
6975
+ inputVariants({ size }),
6976
+ "font-metropolis w-full rounded-none border-none focus-visible:outline-none",
6977
+ Boolean(leftAddon) && "pl-2",
6978
+ Boolean(rightAddon) && "pr-2",
6979
+ Boolean(mergedAddon) && "shadow-none",
6980
+ Boolean(props.disabled) && "cursor-not-allowed bg-gray-100",
6981
+ className
6982
+ ),
6983
+ ...props,
6984
+ required: false
6985
+ }
6986
+ ),
6987
+ Boolean(rightAddon) && /* @__PURE__ */ jsx(
6988
+ "div",
6989
+ {
6990
+ className: cn(
6991
+ rightAddonClassName,
6992
+ "flex items-center justify-center border-l border-gray-200 px-3",
6993
+ hasError ? "text-danger-500" : "text-gray-600",
6994
+ Boolean(mergedAddon) && "border-l-0"
6995
+ ),
6996
+ children: rightAddon
6997
+ }
6998
+ )
7719
6999
  ]
7720
- },
7721
- weekIndex
7722
- );
7723
- })
7724
- }
7725
- );
7726
- }
7727
- var ButtonDropdown = ({
7728
- onClick,
7729
- active,
7730
- size = "md"
7731
- }) => {
7732
- const size_map = {
7733
- sm: 11,
7734
- md: 12,
7735
- lg: 18
7736
- };
7737
- return /* @__PURE__ */ jsx(
7738
- Button,
7739
- {
7740
- size: "icon",
7741
- onClick,
7742
- color: "gray",
7743
- className: cn(
7744
- "bg-transparent transition-colors outline-none *:duration-300 hover:bg-gray-50 focus:outline-none"
7745
- ),
7746
- children: /* @__PURE__ */ jsx(
7747
- Icon,
7748
- {
7749
- name: "arrow-down",
7750
- size: size_map[size],
7751
- className: cn(
7752
- "text-primary-1000",
7753
- active == true ? "rotate-180" : "rotate-0"
7754
- )
7755
- }
7756
- )
7757
- }
7758
- );
7759
- };
7760
- var ItemDropdown = ({
7761
- active,
7762
- value,
7763
- onClick
7764
- }) => {
7765
- return /* @__PURE__ */ jsx(
7766
- "button",
7767
- {
7768
- onClick,
7769
- className: cn(
7770
- "w-full min-w-23.5 cursor-pointer rounded-md border px-1.5 py-1 text-sm transition-colors outline-none",
7771
- active ? "bg-primary-50 border-primary-300" : "border-transparent hover:bg-gray-50"
7772
- ),
7773
- children: /* @__PURE__ */ jsx(Text, { value, weight: "medium" })
7774
- }
7775
- );
7000
+ }
7001
+ )
7002
+ }
7003
+ );
7004
+ }
7005
+ );
7006
+ Input.displayName = "Input";
7007
+
7008
+ // src/components/date-picker/helpers.ts
7009
+ var monthsShort = [
7010
+ "Jan",
7011
+ "Feb",
7012
+ "Mar",
7013
+ "Apr",
7014
+ "Mei",
7015
+ "Jun",
7016
+ "Jul",
7017
+ "Aug",
7018
+ "Sep",
7019
+ "Oct",
7020
+ "Nov",
7021
+ "Dec"
7022
+ ];
7023
+ var monthsFull = [
7024
+ "January",
7025
+ "February",
7026
+ "March",
7027
+ "April",
7028
+ "May",
7029
+ "June",
7030
+ "July",
7031
+ "August",
7032
+ "September",
7033
+ "October",
7034
+ "November",
7035
+ "December"
7036
+ ];
7037
+ var getFormatConfig = (format) => {
7038
+ switch (format) {
7039
+ case "DD-MM-YYYY":
7040
+ return { separator: "-", placeholder: "DD-MM-YYYY", maxLength: 10 };
7041
+ case "DD/MM/YYYY":
7042
+ return { separator: "/", placeholder: "DD/MM/YYYY", maxLength: 10 };
7043
+ case "DD MMM YYYY":
7044
+ return { separator: " ", placeholder: "DD MMM YYYY", maxLength: 11 };
7045
+ case "DD MMMM YYYY":
7046
+ return { separator: " ", placeholder: "DD MMMM YYYY", maxLength: 18 };
7047
+ case "YYYY-MM-DD":
7048
+ return { separator: "-", placeholder: "YYYY-MM-DD", maxLength: 10 };
7049
+ case "MM/DD/YYYY":
7050
+ return { separator: "/", placeholder: "MM/DD/YYYY", maxLength: 10 };
7051
+ default:
7052
+ return { separator: "-", placeholder: "DD-MM-YYYY", maxLength: 10 };
7053
+ }
7776
7054
  };
7777
- var DropdownWrapper = ({
7778
- children,
7779
- onClose
7780
- }) => {
7781
- return /* @__PURE__ */ jsx("div", { className: "relative", onClick: () => onClose(false), children: /* @__PURE__ */ jsx("div", { className: "absolute top-5 left-1/2 z-20 max-h-48 -translate-x-1/2 space-y-1 overflow-y-auto rounded-lg bg-white px-2 py-1 shadow-md", children }) });
7055
+ var formatDateToString = (date, format) => {
7056
+ if (!date) return "";
7057
+ const day = String(date.getDate()).padStart(2, "0");
7058
+ const month2 = String(date.getMonth() + 1).padStart(2, "0");
7059
+ const monthShort = monthsShort[date.getMonth()];
7060
+ const monthFull = monthsFull[date.getMonth()];
7061
+ const year = date.getFullYear();
7062
+ const hours = String(date.getHours()).padStart(2, "0");
7063
+ const minutes = String(date.getMinutes()).padStart(2, "0");
7064
+ const seconds = String(date.getSeconds()).padStart(2, "0");
7065
+ const time = `${hours}:${minutes}:${seconds}`;
7066
+ switch (format) {
7067
+ case "DD-MM-YYYY":
7068
+ return `${day}-${month2}-${year}`;
7069
+ case "DD/MM/YYYY":
7070
+ return `${day}/${month2}/${year}`;
7071
+ case "DD MMM YYYY":
7072
+ return `${day} ${monthShort} ${year}`;
7073
+ case "DD MMMM YYYY":
7074
+ return `${day} ${monthFull} ${year}`;
7075
+ case "YYYY-MM-DD":
7076
+ return `${year}-${month2}-${day}`;
7077
+ case "MM/DD/YYYY":
7078
+ return `${month2}/${day}/${year}`;
7079
+ case "DD-MM-YYYY HH:mm:ss":
7080
+ return `${day}-${month2}-${year} ${time}`;
7081
+ case "DD/MM/YYYY HH:mm:ss":
7082
+ return `${day}/${month2}/${year} ${time}`;
7083
+ case "DD MMM YYYY HH:mm:ss":
7084
+ return `${day} ${monthShort} ${year} ${time}`;
7085
+ case "DD MMM YYYY - HH:mm:ss":
7086
+ return `${day} ${monthShort} ${year} - ${time}`;
7087
+ case "DD MMMM YYYY HH:mm:ss":
7088
+ return `${day} ${monthFull} ${year} ${time}`;
7089
+ case "DD MMMM YYYY - HH:mm:ss":
7090
+ return `${day} ${monthFull} ${year} - ${time}`;
7091
+ case "YYYY-MM-DD HH:mm:ss":
7092
+ return `${year}-${month2}-${day} ${time}`;
7093
+ default:
7094
+ return `${day}-${month2}-${year}`;
7095
+ }
7782
7096
  };
7783
- var header_size_map = {
7784
- sm: "t2",
7785
- md: "t1",
7786
- lg: "p3"
7097
+ function formatDateLocal(date) {
7098
+ const y = date.getFullYear();
7099
+ const m = String(date.getMonth() + 1).padStart(2, "0");
7100
+ const d = String(date.getDate()).padStart(2, "0");
7101
+ return `${y}-${m}-${d}`;
7102
+ }
7103
+ var parseMonthName = (monthStr) => {
7104
+ const monthLower = monthStr.toLowerCase();
7105
+ const shortIndex = monthsShort.findIndex(
7106
+ (m) => m.toLowerCase() === monthLower
7107
+ );
7108
+ if (shortIndex !== -1) return shortIndex + 1;
7109
+ const fullIndex = monthsFull.findIndex((m) => m.toLowerCase() === monthLower);
7110
+ if (fullIndex !== -1) return fullIndex + 1;
7111
+ return null;
7787
7112
  };
7788
- function CalendarHeader({
7789
- size = "md",
7790
- showNavigator,
7791
- calendar,
7792
- dropdown,
7793
- months,
7794
- handleNextMonth,
7795
- handlePrevMonth,
7796
- showNextNavigator,
7797
- showPrevNavigator
7798
- }) {
7799
- const { currentMonth, currentYear } = calendar;
7800
- const years = useMemo(() => {
7801
- const yearRange = [];
7802
- for (let i = currentYear - 100; i <= currentYear + 100; i++) {
7803
- yearRange.push(i);
7804
- }
7805
- return yearRange;
7806
- }, [currentYear]);
7807
- return /* @__PURE__ */ jsxs("div", { className: "mb-6 flex items-center justify-between", children: [
7808
- showNavigator && /* @__PURE__ */ jsx(
7809
- NavigatorButton,
7810
- {
7811
- size,
7812
- direction: "prev",
7813
- onClick: handlePrevMonth,
7814
- visible: showPrevNavigator
7113
+ var chipVariants = cva(
7114
+ "inline-flex cursor-pointer items-center justify-center rounded-lg border transition-all duration-200",
7115
+ {
7116
+ variants: {
7117
+ size: {
7118
+ sm: "p-1.5 text-xs",
7119
+ md: "p-2 text-sm",
7120
+ lg: "px-3 py-2 text-base"
7121
+ },
7122
+ color: {
7123
+ primary: "",
7124
+ success: "",
7125
+ danger: "",
7126
+ warning: "",
7127
+ info: "",
7128
+ purple: "",
7129
+ orange: "",
7130
+ gray: ""
7131
+ },
7132
+ state: {
7133
+ default: "",
7134
+ selected: "",
7135
+ disabled: ""
7136
+ },
7137
+ block: {
7138
+ true: "w-full",
7139
+ false: ""
7815
7140
  }
7816
- ),
7817
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
7818
- showNavigator && /* @__PURE__ */ jsx(
7819
- MonthDropdown,
7820
- {
7821
- months,
7822
- calendar,
7823
- dropdown
7824
- }
7825
- ),
7826
- /* @__PURE__ */ jsx(
7827
- Text,
7828
- {
7829
- as: "span",
7830
- variant: header_size_map[size],
7831
- weight: "semibold",
7832
- value: `${months[currentMonth]} - ${currentYear}`
7833
- }
7834
- ),
7835
- showNavigator && /* @__PURE__ */ jsx(YearDropdown, { years, calendar, dropdown })
7836
- ] }),
7837
- showNavigator && /* @__PURE__ */ jsx(
7838
- NavigatorButton,
7141
+ },
7142
+ compoundVariants: [
7143
+ // Default color variants
7839
7144
  {
7840
- direction: "next",
7841
- size,
7842
- onClick: handleNextMonth,
7843
- visible: showNextNavigator
7844
- }
7845
- )
7846
- ] });
7847
- }
7848
- function MonthDropdown({ months, calendar, dropdown }) {
7849
- const { currentMonth, setCurrentMonth } = calendar;
7850
- const { isMonthOpen, setMonthOpen } = dropdown;
7851
- return /* @__PURE__ */ jsxs("div", { children: [
7852
- /* @__PURE__ */ jsx(
7853
- ButtonDropdown,
7145
+ color: "gray",
7146
+ state: "default",
7147
+ className: "border-gray-00 bg-white text-gray-700 hover:bg-gray-100"
7148
+ },
7854
7149
  {
7855
- onClick: () => setMonthOpen(!isMonthOpen),
7856
- active: isMonthOpen
7857
- }
7858
- ),
7859
- isMonthOpen && /* @__PURE__ */ jsx(DropdownWrapper, { onClose: setMonthOpen, children: months.map((month2, index) => /* @__PURE__ */ jsx(
7860
- ItemDropdown,
7150
+ color: "gray",
7151
+ state: "selected",
7152
+ className: "border-gray-400 bg-gray-200 text-gray-800"
7153
+ },
7861
7154
  {
7862
- onClick: () => setCurrentMonth(index),
7863
- active: currentMonth === index,
7864
- value: month2
7155
+ color: "gray",
7156
+ state: "disabled",
7157
+ className: "cursor-not-allowed border-gray-200 bg-gray-100 text-gray-400"
7865
7158
  },
7866
- index
7867
- )) })
7868
- ] });
7869
- }
7870
- function YearDropdown({ calendar, dropdown, years }) {
7871
- const { currentYear, setCurrentYear } = calendar;
7872
- const { isYearOpen, setYearOpen } = dropdown;
7873
- return /* @__PURE__ */ jsxs("div", { children: [
7874
- /* @__PURE__ */ jsx(
7875
- ButtonDropdown,
7159
+ // Primary color variants
7876
7160
  {
7877
- onClick: () => setYearOpen(!isYearOpen),
7878
- active: isYearOpen
7879
- }
7880
- ),
7881
- isYearOpen && /* @__PURE__ */ jsx(DropdownWrapper, { onClose: setYearOpen, children: years.map((year) => /* @__PURE__ */ jsx(
7882
- ItemDropdown,
7161
+ color: "primary",
7162
+ state: "default",
7163
+ className: "border-primary-200 text-primary-1000 hover:bg-primary-50 bg-white"
7164
+ },
7883
7165
  {
7884
- onClick: () => setCurrentYear(year),
7885
- active: currentYear === year,
7886
- value: year.toString()
7166
+ color: "primary",
7167
+ state: "selected",
7168
+ className: "bg-primary-50 border-primary-200 text-primary-1000"
7887
7169
  },
7888
- year
7889
- )) })
7890
- ] });
7891
- }
7892
- function NavigatorButton({
7893
- direction,
7894
- size,
7895
- onClick,
7896
- visible = true
7897
- }) {
7898
- const icon = direction === "prev" ? "angle-left-small" : "angle-right-small";
7899
- return /* @__PURE__ */ jsx(
7900
- ButtonNavigator,
7901
- {
7902
- size,
7903
- onClick,
7904
- icon,
7905
- className: visible ? "" : "pointer-events-none opacity-0"
7906
- }
7907
- );
7908
- }
7909
- var day_of_week_size = {
7910
- sm: "t2",
7911
- md: "t2",
7912
- lg: "t1"
7913
- };
7914
- function DaysOfWeek({
7915
- daysOfWeek,
7916
- size = "md",
7917
- wrapperClassName,
7918
- variant = "default",
7919
- type = "month",
7920
- renderItem
7921
- }) {
7922
- return /* @__PURE__ */ jsxs(
7923
- "div",
7924
- {
7925
- className: clsx9(
7926
- "grid justify-items-center",
7927
- variant === "compact" && "calendar-cols mb-3 gap-x-1 *:text-center!",
7928
- variant === "default" && "w-full bg-gray-100 *:p-3 *:w-full *:text-start! *:border-r *:border-gray-300 *:last:border-r-0",
7929
- //prettier-ignore
7930
- variant === "default" && type === "month" && "grid-cols-7",
7931
- variant === "default" && type === "week" && "grid-cols-[60px_1fr_1fr_1fr_1fr_1fr_1fr_1fr]",
7932
- //prettier-ignore
7933
- wrapperClassName
7934
- ),
7935
- children: [
7936
- type === "week" && variant === "default" && renderItem === void 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
7937
- /* @__PURE__ */ jsx("div", {}),
7938
- daysOfWeek.map((day) => /* @__PURE__ */ jsx(Text, { as: "h5", value: day, variant: "t1" }, day))
7939
- ] }),
7940
- type === "month" && renderItem === void 0 && daysOfWeek.map((day) => /* @__PURE__ */ jsx(
7941
- Text,
7942
- {
7943
- as: "h5",
7944
- weight: variant === "compact" ? "medium" : "semibold",
7945
- value: day,
7946
- className: clsx9(
7947
- variant === "compact" && "text-gray-600!",
7948
- variant === "default" && "text-gray-900! uppercase"
7949
- ),
7950
- variant: variant === "compact" ? day_of_week_size[size] : "t1"
7951
- },
7952
- day
7953
- ))
7954
- ]
7955
- }
7956
- );
7957
- }
7958
-
7959
- // src/components/calendar/constants.tsx
7960
- var typeOptions = [
7961
- // {
7962
- // label: 'Year',
7963
- // value: 'year',
7964
- // },
7965
- {
7966
- label: "Month",
7967
- value: "month"
7968
- },
7969
- {
7970
- label: "Week",
7971
- value: "week"
7972
- }
7973
- // {
7974
- // label: 'Day',
7975
- // value: 'day',
7976
- // },
7977
- // {
7978
- // label: 'Agenda',
7979
- // value: 'agenda',
7980
- // },
7981
- ];
7982
- var days = ["Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"];
7983
- var month = [
7984
- "Januari",
7985
- "Februari",
7986
- "Maret",
7987
- "April",
7988
- "Mei",
7989
- "Juni",
7990
- "Juli",
7991
- "Agustus",
7992
- "September",
7993
- "Oktober",
7994
- "November",
7995
- "Desember"
7996
- ];
7997
- var Calendar2 = ({
7998
- showNavigator = true,
7999
- showHeader = true,
8000
- value,
8001
- onChange,
8002
- disabledDates = [],
8003
- dayConfigs = [],
8004
- defaultMonth,
8005
- defaultYear,
8006
- styleConfig,
8007
- wrapperClassname,
8008
- weekWrapperClassname,
8009
- dayWrapperClassname,
8010
- daysOfWeek = days,
8011
- months = month,
8012
- showNextNavigator = true,
8013
- showPrevNavigator = true,
8014
- mode = "single",
8015
- rangeValue,
8016
- size = "md",
8017
- variant = "default",
8018
- events,
8019
- showCalendarTooltip = true,
8020
- type = "month",
8021
- onTypeChange,
8022
- onEventClick,
8023
- backdropOnClick,
8024
- onMonthChange,
8025
- onYearChange,
8026
- showDefaultController = false
8027
- }) => {
8028
- const currentDate = /* @__PURE__ */ new Date();
8029
- const [currentMonth, setCurrentMonth] = useState(defaultMonth ?? currentDate.getMonth());
8030
- const [currentYear, setCurrentYear] = useState(defaultYear ?? currentDate.getFullYear());
8031
- const [isDropdownYearShow, setIsDropdownYearShow] = useState(false);
8032
- const [isDropdownMonthShow, setIsDropdownMonthShow] = useState(false);
8033
- const [selectedType, setSelectedType] = useState(type);
8034
- const [selectedTypeIndex, setSelectedTypeIndex] = useState(
8035
- null
8036
- );
8037
- const [currentWeekStart, setCurrentWeekStart] = useState(() => {
8038
- const today = /* @__PURE__ */ new Date();
8039
- const day = today.getDay();
8040
- const start = new Date(today);
8041
- start.setDate(today.getDate() - day);
8042
- start.setHours(0, 0, 0, 0);
8043
- return start;
8044
- });
8045
- const calendarDays = getCalendarDays({ currentMonth, currentYear });
8046
- const calendarHelpers = createCalendarHelpers({
8047
- disabledDates,
8048
- dayConfigs,
8049
- rangeValue,
8050
- mode,
8051
- value
8052
- });
8053
- const calendarState = {
8054
- currentMonth,
8055
- currentYear,
8056
- setCurrentMonth,
8057
- setCurrentYear
8058
- };
8059
- const dropdownState = {
8060
- isMonthOpen: isDropdownMonthShow,
8061
- setMonthOpen: setIsDropdownMonthShow,
8062
- isYearOpen: isDropdownYearShow,
8063
- setYearOpen: setIsDropdownYearShow
8064
- };
8065
- const handleDateClick = (day) => {
8066
- const dayConfig = calendarHelpers.getDayConfig(day);
8067
- const disabled = (dayConfig?.disabled ?? false) || calendarHelpers.isDateDisabled(day);
8068
- if (disabled) {
8069
- return;
8070
- }
8071
- onChange?.(day.fullDate);
8072
- };
8073
- const getWeekDaysLabel = (weekStart) => {
8074
- return Array.from({ length: 7 }, (_, i) => {
8075
- const d = new Date(weekStart);
8076
- d.setDate(weekStart.getDate() + i);
8077
- const dayName = daysOfWeek[d.getDay()];
8078
- const date = d.getDate();
8079
- return `${dayName} ${date}`;
8080
- });
8081
- };
8082
- const changeWeek = (delta) => {
8083
- setCurrentWeekStart((prev) => {
8084
- const next = new Date(prev);
8085
- next.setDate(prev.getDate() + delta * 7);
8086
- setCurrentMonth(next.getMonth());
8087
- setCurrentYear(next.getFullYear());
8088
- return next;
8089
- });
8090
- };
8091
- const changeMonth = (delta) => {
8092
- let newMonth = currentMonth + delta;
8093
- let newYear = currentYear;
8094
- if (newMonth < 0) {
8095
- newMonth = 11;
8096
- newYear -= 1;
8097
- } else if (newMonth > 11) {
8098
- newMonth = 0;
8099
- newYear += 1;
8100
- }
8101
- onMonthChange?.(newMonth);
8102
- onYearChange?.(newYear);
8103
- setCurrentMonth(newMonth);
8104
- setCurrentYear(newYear);
8105
- };
8106
- const handleNavigationDefault = (type2, action) => {
8107
- if (type2 === "month") {
8108
- if (action === "prev") {
8109
- return changeMonth(-1);
8110
- } else {
8111
- return changeMonth(1);
8112
- }
8113
- }
8114
- if (type2 === "week") {
8115
- if (action === "prev") {
8116
- return changeWeek(1);
8117
- } else {
8118
- return changeWeek(-1);
8119
- }
8120
- }
8121
- };
8122
- useEffect(() => {
8123
- if (value !== void 0) {
8124
- setCurrentMonth(
8125
- value?.getMonth() ?? defaultMonth ?? currentDate?.getMonth()
8126
- );
8127
- setCurrentYear(
8128
- value?.getFullYear() ?? defaultYear ?? currentDate?.getFullYear()
8129
- );
8130
- }
8131
- }, [value]);
8132
- useEffect(() => {
8133
- if (type !== void 0) {
8134
- setSelectedType(type);
8135
- }
8136
- }, [type]);
8137
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: clsx9(variant === "default" && "flex flex-col gap-2"), children: [
8138
- variant === "default" && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
8139
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-6", children: [
8140
- /* @__PURE__ */ jsxs("div", { className: "*:cursor-pointer", children: [
8141
- /* @__PURE__ */ jsx(
8142
- ButtonNavigation,
8143
- {
8144
- onClick: () => handleNavigationDefault(selectedType, "prev"),
8145
- type: "prev"
8146
- }
8147
- ),
8148
- /* @__PURE__ */ jsx(
8149
- ButtonNavigation,
8150
- {
8151
- onClick: () => handleNavigationDefault(selectedType, "next"),
8152
- type: "next"
8153
- }
8154
- )
8155
- ] }),
8156
- /* @__PURE__ */ jsxs(
8157
- Text,
8158
- {
8159
- variant: "h4",
8160
- weight: "semibold",
8161
- className: "-translate-y-0.5 text-gray-900",
8162
- children: [
8163
- months[currentMonth],
8164
- " ",
8165
- currentYear
8166
- ]
8167
- }
8168
- )
8169
- ] }),
8170
- showDefaultController && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
8171
- /* @__PURE__ */ jsx(
8172
- Button,
8173
- {
8174
- size: "sm",
8175
- color: "gray",
8176
- variant: "outline",
8177
- className: "capitalize",
8178
- onClick: () => setCurrentMonth((/* @__PURE__ */ new Date()).getMonth()),
8179
- children: "Today"
8180
- }
8181
- ),
8182
- /* @__PURE__ */ jsxs(Dropdown, { children: [
8183
- /* @__PURE__ */ jsx(DropdownTrigger, { children: /* @__PURE__ */ jsxs(
8184
- Button,
8185
- {
8186
- size: "sm",
8187
- color: "gray",
8188
- variant: "outline",
8189
- className: "flex items-center capitalize",
8190
- children: [
8191
- selectedType,
8192
- " ",
8193
- /* @__PURE__ */ jsx(Icon, { name: "angle-down-small", size: 20 })
8194
- ]
8195
- }
8196
- ) }),
8197
- /* @__PURE__ */ jsx(
8198
- DropdownContent,
8199
- {
8200
- align: "end",
8201
- className: "w-36 *:rounded-md *:border-0",
8202
- children: typeOptions.map((option, index) => /* @__PURE__ */ jsx(
8203
- DropdownItem,
8204
- {
8205
- onFocus: () => setSelectedTypeIndex(index),
8206
- onClick: () => {
8207
- setSelectedType(option.value);
8208
- onTypeChange?.(option.value);
8209
- },
8210
- className: clsx9(
8211
- (selectedType === option.value || index === selectedTypeIndex) && "bg-primary-50!"
8212
- ),
8213
- children: /* @__PURE__ */ jsx(Text, { className: "text-gray-900", children: option.label })
8214
- },
8215
- option.value
8216
- ))
8217
- }
8218
- )
8219
- ] })
8220
- ] })
8221
- ] }),
8222
- /* @__PURE__ */ jsxs(
8223
- "div",
8224
7170
  {
8225
- className: cn(
8226
- "border bg-white",
8227
- variant === "compact" && "mx-auto w-fit rounded-2xl border-gray-200 p-6 ",
8228
- //prettier-ignore
8229
- variant === "default" && "overflow-hidden rounded-xl border-gray-300",
8230
- //prettier-ignore
8231
- wrapperClassname
8232
- ),
8233
- children: [
8234
- selectedType === "week" && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
8235
- DaysOfWeek,
8236
- {
8237
- type: "week",
8238
- size,
8239
- variant,
8240
- daysOfWeek: getWeekDaysLabel(currentWeekStart),
8241
- wrapperClassName: weekWrapperClassname
8242
- }
8243
- ) }),
8244
- selectedType === "month" && /* @__PURE__ */ jsxs(Fragment, { children: [
8245
- showHeader && variant === "compact" && /* @__PURE__ */ jsx(
8246
- CalendarHeader,
8247
- {
8248
- size,
8249
- calendar: calendarState,
8250
- dropdown: dropdownState,
8251
- handleNextMonth: () => changeMonth(1),
8252
- handlePrevMonth: () => changeMonth(-1),
8253
- showNavigator,
8254
- months,
8255
- showNextNavigator,
8256
- showPrevNavigator
8257
- }
8258
- ),
8259
- /* @__PURE__ */ jsx(
8260
- DaysOfWeek,
8261
- {
8262
- size,
8263
- variant,
8264
- daysOfWeek,
8265
- wrapperClassName: weekWrapperClassname
8266
- }
8267
- ),
8268
- /* @__PURE__ */ jsx(
8269
- CalendarGrid,
8270
- {
8271
- className: dayWrapperClassname,
8272
- days: calendarDays,
8273
- helpers: calendarHelpers,
8274
- size,
8275
- mode,
8276
- styleConfig,
8277
- onClick: handleDateClick,
8278
- variant,
8279
- events,
8280
- showCalendarTooltip,
8281
- onEventClick,
8282
- backdropOnClick
8283
- }
8284
- )
8285
- ] })
8286
- ]
7171
+ color: "primary",
7172
+ state: "disabled",
7173
+ className: "bg-primary-100 border-primary-200 text-primary-300 cursor-not-allowed"
7174
+ },
7175
+ // Success color variants
7176
+ {
7177
+ color: "success",
7178
+ state: "default",
7179
+ className: "border-success-300 text-success-500 hover:bg-success-50 bg-white"
7180
+ },
7181
+ {
7182
+ color: "success",
7183
+ state: "selected",
7184
+ className: "bg-success-100 border-success-200 text-success-500"
7185
+ },
7186
+ {
7187
+ color: "success",
7188
+ state: "disabled",
7189
+ className: "bg-success-100 border-success-200 text-success-300 cursor-not-allowed"
7190
+ },
7191
+ // Danger color variants
7192
+ {
7193
+ color: "danger",
7194
+ state: "default",
7195
+ className: "border-danger-200 text-danger-500 hover:bg-danger-50 bg-white"
7196
+ },
7197
+ {
7198
+ color: "danger",
7199
+ state: "selected",
7200
+ className: "bg-danger-100 border-danger-200 text-danger-500"
7201
+ },
7202
+ {
7203
+ color: "danger",
7204
+ state: "disabled",
7205
+ className: "bg-danger-100 border-danger-200 text-danger-300 cursor-not-allowed"
7206
+ },
7207
+ // Warning color variants
7208
+ {
7209
+ color: "warning",
7210
+ state: "default",
7211
+ className: "border-warning-300 text-warning-400 hover:bg-warning-50 bg-white"
7212
+ },
7213
+ {
7214
+ color: "warning",
7215
+ state: "selected",
7216
+ className: "bg-warning-100 border-warning-300 text-warning-500"
7217
+ },
7218
+ {
7219
+ color: "warning",
7220
+ state: "disabled",
7221
+ className: "bg-warning-100 border-warning-200 text-warning-300 cursor-not-allowed"
7222
+ },
7223
+ // Info color variants
7224
+ {
7225
+ color: "info",
7226
+ state: "default",
7227
+ className: "border-info-200 text-info-500 hover:bg-info-50 bg-white"
7228
+ },
7229
+ {
7230
+ color: "info",
7231
+ state: "selected",
7232
+ className: "bg-info-100 border-info-200 text-info-500"
7233
+ },
7234
+ {
7235
+ color: "info",
7236
+ state: "disabled",
7237
+ className: "bg-info-100 border-info-200 text-info-300 cursor-not-allowed"
7238
+ },
7239
+ // Purple color variants
7240
+ {
7241
+ color: "purple",
7242
+ state: "default",
7243
+ className: "border-purple-200 bg-white text-purple-500 hover:bg-purple-50"
7244
+ },
7245
+ {
7246
+ color: "purple",
7247
+ state: "selected",
7248
+ className: "border-purple-200 bg-purple-100 text-purple-500"
7249
+ },
7250
+ {
7251
+ color: "purple",
7252
+ state: "disabled",
7253
+ className: "cursor-not-allowed border-purple-200 bg-purple-100 text-purple-300"
7254
+ },
7255
+ // Orange color variants
7256
+ {
7257
+ color: "orange",
7258
+ state: "default",
7259
+ className: "border-orange-200 bg-white text-orange-500 hover:bg-orange-50"
7260
+ },
7261
+ {
7262
+ color: "orange",
7263
+ state: "selected",
7264
+ className: "border-orange-200 bg-orange-100 text-orange-500"
7265
+ },
7266
+ {
7267
+ color: "orange",
7268
+ state: "disabled",
7269
+ className: "cursor-not-allowed border-orange-200 bg-orange-100 text-orange-300"
8287
7270
  }
8288
- )
8289
- ] }) });
8290
- };
8291
- var ButtonNavigation = ({
7271
+ ],
7272
+ defaultVariants: {
7273
+ size: "md",
7274
+ color: "primary",
7275
+ state: "default",
7276
+ block: false
7277
+ }
7278
+ }
7279
+ );
7280
+ var ChipContext = createContext(null);
7281
+ var Chip = ({
7282
+ value,
7283
+ selected: selectedProp,
7284
+ disabled = false,
8292
7285
  onClick,
8293
- type
7286
+ children,
7287
+ color: colorProp,
7288
+ size: sizeProp,
7289
+ block: blockProp,
7290
+ className
8294
7291
  }) => {
8295
- return /* @__PURE__ */ jsx("button", { onClick, children: /* @__PURE__ */ jsx(
8296
- Icon,
7292
+ const context = useContext(ChipContext);
7293
+ const color = colorProp ?? context?.color ?? "primary";
7294
+ const size = sizeProp ?? context?.size ?? "md";
7295
+ const block = blockProp ?? context?.block ?? false;
7296
+ const isSelected = context ? value !== void 0 && context.selectedValues.includes(value) : selectedProp ?? false;
7297
+ const state = disabled ? "disabled" : isSelected === true ? "selected" : "default";
7298
+ const handleClick = () => {
7299
+ if (disabled) return;
7300
+ if (context && value !== void 0) {
7301
+ context.toggleSelection(value);
7302
+ }
7303
+ onClick?.(value);
7304
+ };
7305
+ return /* @__PURE__ */ jsx(
7306
+ "button",
8297
7307
  {
8298
- name: type === "next" ? "angle-right-small" : "angle-left-small",
8299
- size: 30,
8300
- className: "text-gray-900"
7308
+ type: "button",
7309
+ onClick: handleClick,
7310
+ disabled,
7311
+ className: cn(chipVariants({ size, color, state, block }), className),
7312
+ children
8301
7313
  }
8302
- ) });
8303
- };
8304
-
8305
- // src/components/date-picker/helpers.ts
8306
- var monthsShort = [
8307
- "Jan",
8308
- "Feb",
8309
- "Mar",
8310
- "Apr",
8311
- "Mei",
8312
- "Jun",
8313
- "Jul",
8314
- "Aug",
8315
- "Sep",
8316
- "Oct",
8317
- "Nov",
8318
- "Dec"
8319
- ];
8320
- var monthsFull = [
8321
- "January",
8322
- "February",
8323
- "March",
8324
- "April",
8325
- "May",
8326
- "June",
8327
- "July",
8328
- "August",
8329
- "September",
8330
- "October",
8331
- "November",
8332
- "December"
8333
- ];
8334
- var getFormatConfig = (format) => {
8335
- switch (format) {
8336
- case "DD-MM-YYYY":
8337
- return { separator: "-", placeholder: "DD-MM-YYYY", maxLength: 10 };
8338
- case "DD/MM/YYYY":
8339
- return { separator: "/", placeholder: "DD/MM/YYYY", maxLength: 10 };
8340
- case "DD MMM YYYY":
8341
- return { separator: " ", placeholder: "DD MMM YYYY", maxLength: 11 };
8342
- case "DD MMMM YYYY":
8343
- return { separator: " ", placeholder: "DD MMMM YYYY", maxLength: 18 };
8344
- case "YYYY-MM-DD":
8345
- return { separator: "-", placeholder: "YYYY-MM-DD", maxLength: 10 };
8346
- case "MM/DD/YYYY":
8347
- return { separator: "/", placeholder: "MM/DD/YYYY", maxLength: 10 };
8348
- default:
8349
- return { separator: "-", placeholder: "DD-MM-YYYY", maxLength: 10 };
8350
- }
8351
- };
8352
- var formatDateToString = (date, format) => {
8353
- if (!date) return "";
8354
- const day = String(date.getDate()).padStart(2, "0");
8355
- const month2 = String(date.getMonth() + 1).padStart(2, "0");
8356
- const monthShort = monthsShort[date.getMonth()];
8357
- const monthFull = monthsFull[date.getMonth()];
8358
- const year = date.getFullYear();
8359
- const hours = String(date.getHours()).padStart(2, "0");
8360
- const minutes = String(date.getMinutes()).padStart(2, "0");
8361
- const seconds = String(date.getSeconds()).padStart(2, "0");
8362
- const time = `${hours}:${minutes}:${seconds}`;
8363
- switch (format) {
8364
- case "DD-MM-YYYY":
8365
- return `${day}-${month2}-${year}`;
8366
- case "DD/MM/YYYY":
8367
- return `${day}/${month2}/${year}`;
8368
- case "DD MMM YYYY":
8369
- return `${day} ${monthShort} ${year}`;
8370
- case "DD MMMM YYYY":
8371
- return `${day} ${monthFull} ${year}`;
8372
- case "YYYY-MM-DD":
8373
- return `${year}-${month2}-${day}`;
8374
- case "MM/DD/YYYY":
8375
- return `${month2}/${day}/${year}`;
8376
- case "DD-MM-YYYY HH:mm:ss":
8377
- return `${day}-${month2}-${year} ${time}`;
8378
- case "DD/MM/YYYY HH:mm:ss":
8379
- return `${day}/${month2}/${year} ${time}`;
8380
- case "DD MMM YYYY HH:mm:ss":
8381
- return `${day} ${monthShort} ${year} ${time}`;
8382
- case "DD MMM YYYY - HH:mm:ss":
8383
- return `${day} ${monthShort} ${year} - ${time}`;
8384
- case "DD MMMM YYYY HH:mm:ss":
8385
- return `${day} ${monthFull} ${year} ${time}`;
8386
- case "DD MMMM YYYY - HH:mm:ss":
8387
- return `${day} ${monthFull} ${year} - ${time}`;
8388
- case "YYYY-MM-DD HH:mm:ss":
8389
- return `${year}-${month2}-${day} ${time}`;
8390
- default:
8391
- return `${day}-${month2}-${year}`;
8392
- }
7314
+ );
8393
7315
  };
8394
- function formatDateLocal(date) {
8395
- const y = date.getFullYear();
8396
- const m = String(date.getMonth() + 1).padStart(2, "0");
8397
- const d = String(date.getDate()).padStart(2, "0");
8398
- return `${y}-${m}-${d}`;
8399
- }
8400
- var parseMonthName = (monthStr) => {
8401
- const monthLower = monthStr.toLowerCase();
8402
- const shortIndex = monthsShort.findIndex(
8403
- (m) => m.toLowerCase() === monthLower
7316
+ var ChipGroup = ({
7317
+ options,
7318
+ selected = [],
7319
+ onSelect,
7320
+ direction = "horizontal",
7321
+ color = "primary",
7322
+ multiple = false,
7323
+ scrollable = true,
7324
+ block = false,
7325
+ size = "md",
7326
+ footer,
7327
+ header,
7328
+ children,
7329
+ className
7330
+ }) => {
7331
+ const isHorizontal = direction === "horizontal";
7332
+ const normalizeSelected = (val) => Array.isArray(val) ? val : val !== null || val !== void 0 ? [val] : [];
7333
+ const [internalSelected, setInternalSelected] = useState(
7334
+ normalizeSelected(selected)
8404
7335
  );
8405
- if (shortIndex !== -1) return shortIndex + 1;
8406
- const fullIndex = monthsFull.findIndex((m) => m.toLowerCase() === monthLower);
8407
- if (fullIndex !== -1) return fullIndex + 1;
8408
- return null;
7336
+ useEffect(() => {
7337
+ const newSelected = normalizeSelected(selected);
7338
+ if (JSON.stringify(newSelected) !== JSON.stringify(internalSelected)) {
7339
+ setInternalSelected(newSelected);
7340
+ }
7341
+ }, [selected, internalSelected]);
7342
+ const toggleSelection = (value) => {
7343
+ let newSelected;
7344
+ if (multiple || !multiple && internalSelected.length === 0) {
7345
+ newSelected = internalSelected.includes(value) ? internalSelected.filter((v) => v !== value) : [...internalSelected, value];
7346
+ } else {
7347
+ newSelected = [value];
7348
+ }
7349
+ setInternalSelected(newSelected);
7350
+ onSelect?.(newSelected);
7351
+ };
7352
+ const containerClasses = `
7353
+ flex gap-2
7354
+ ${isHorizontal ? "flex-row flex-wrap" : "flex-col"}
7355
+ ${block ? "items-stretch" : "items-start"}
7356
+ ${scrollable && isHorizontal ? "overflow-x-auto" : ""}
7357
+ ${scrollable && !isHorizontal ? "overflow-y-auto" : ""}
7358
+ ${className ?? ""}
7359
+ `;
7360
+ const contextValue = {
7361
+ selectedValues: internalSelected,
7362
+ toggleSelection,
7363
+ color,
7364
+ size,
7365
+ block
7366
+ };
7367
+ return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
7368
+ header !== void 0 && /* @__PURE__ */ jsx("div", { className: "mb-2", children: header }),
7369
+ /* @__PURE__ */ jsx(ChipContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { className: containerClasses, children: options !== void 0 ? options.map((option) => /* @__PURE__ */ jsxs(
7370
+ Chip,
7371
+ {
7372
+ value: option.value,
7373
+ disabled: option.disabled,
7374
+ children: [
7375
+ option.icon !== void 0 && /* @__PURE__ */ jsx("span", { className: "mr-2", children: option.icon }),
7376
+ /* @__PURE__ */ jsx("span", { children: option.label })
7377
+ ]
7378
+ },
7379
+ String(option.value)
7380
+ )) : children }) }),
7381
+ footer !== void 0 && /* @__PURE__ */ jsx("div", { className: "mt-2", children: footer })
7382
+ ] });
8409
7383
  };
8410
7384
  var DatePicker = ({
8411
7385
  format = "DD-MM-YYYY",
@@ -8564,7 +7538,7 @@ var DatePicker = ({
8564
7538
  }
8565
7539
  return formatted;
8566
7540
  };
8567
- const handleInputChange2 = (e) => {
7541
+ const handleInputChange = (e) => {
8568
7542
  const value = e.target.value;
8569
7543
  const formatted = usesMonthName ? value : autoFormatInput(value);
8570
7544
  setInputValue(formatted);
@@ -8654,7 +7628,7 @@ var DatePicker = ({
8654
7628
  "div",
8655
7629
  {
8656
7630
  ref: containerRef,
8657
- className: clsx9("relative flex max-w-sm flex-col", containerClassName),
7631
+ className: clsx4("relative flex max-w-sm flex-col", containerClassName),
8658
7632
  children: /* @__PURE__ */ jsxs(
8659
7633
  Dropdown,
8660
7634
  {
@@ -8676,7 +7650,7 @@ var DatePicker = ({
8676
7650
  leftAddonClassName: "pr-1!",
8677
7651
  leftAddon: /* @__PURE__ */ jsx(Icon, { name: "calendar", className: "text-gray-900" }),
8678
7652
  placeholder: mode === "range" ? `${formatConfig.placeholder} - ${formatConfig.placeholder}` : formatConfig.placeholder,
8679
- onChange: handleInputChange2,
7653
+ onChange: handleInputChange,
8680
7654
  value: inputValue,
8681
7655
  readOnly: mode === "range"
8682
7656
  }
@@ -8686,7 +7660,7 @@ var DatePicker = ({
8686
7660
  {
8687
7661
  align,
8688
7662
  sideOffset: 5,
8689
- className: clsx9("z-10 overflow-hidden p-0", wrapperClassName),
7663
+ className: clsx4("z-10 overflow-hidden p-0", wrapperClassName),
8690
7664
  children: /* @__PURE__ */ jsx("div", { className: "top-full z-10", children: mode === "single" ? /* @__PURE__ */ jsx(
8691
7665
  Calendar2,
8692
7666
  {