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