@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 clsx10 = require('clsx');
3
+ var React280 = require('react');
4
+ var clsx5 = 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 clsx10__default = /*#__PURE__*/_interopDefault(clsx10);
36
- var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
32
+ var React280__namespace = /*#__PURE__*/_interopNamespace(React280);
33
+ var clsx5__default = /*#__PURE__*/_interopDefault(clsx5);
37
34
  var DropdownMenu__namespace = /*#__PURE__*/_interopNamespace(DropdownMenu);
35
+ var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
38
36
 
39
37
  // src/components/calendar/calendar.tsx
40
38
  function cn(...inputs) {
41
- return tailwindMerge.twMerge(clsx10.clsx(inputs));
39
+ return tailwindMerge.twMerge(clsx5.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;
@@ -5592,109 +5590,167 @@ var ButtonNavigator = ({
5592
5590
  }
5593
5591
  );
5594
5592
  };
5595
- classVarianceAuthority.cva(
5596
- "flex items-center justify-center rounded border transition-all focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:outline-none",
5597
- {
5598
- variants: {
5599
- size: {
5600
- sm: "h-4 w-4",
5601
- md: "h-5 w-5",
5602
- lg: "h-6 w-6"
5603
- },
5604
- color: {
5605
- primary: "border-primary-1000 focus-visible:ring-primary-900",
5606
- secondary: "border-gray-600 focus-visible:ring-gray-500",
5607
- success: "border-success-500 focus-visible:ring-success-400",
5608
- danger: "border-danger-500 focus-visible:ring-danger-400",
5609
- warning: "border-warning-500 focus-visible:ring-warning-400",
5610
- info: "border-info-500 focus-visible:ring-info-400",
5611
- orange: "border-orange-500 focus-visible:ring-orange-400",
5612
- purple: "border-purple-500 focus-visible:ring-purple-400",
5613
- gray: "border-gray-600 focus-visible:ring-gray-500"
5614
- },
5615
- checked: {
5616
- true: "",
5617
- false: ""
5618
- }
5619
- },
5620
- compoundVariants: [
5621
- // Checked state - background sesuai color
5622
- {
5623
- checked: true,
5624
- color: "primary",
5625
- class: "bg-primary-1000 border-primary-1000"
5626
- },
5627
- {
5628
- checked: true,
5629
- color: "secondary",
5630
- class: "border-gray-600 bg-gray-600"
5631
- },
5632
- {
5633
- checked: true,
5634
- color: "success",
5635
- class: "bg-success-500 border-success-500"
5636
- },
5637
- {
5638
- checked: true,
5639
- color: "danger",
5640
- class: "bg-danger-500 border-danger-500"
5641
- },
5642
- {
5643
- checked: true,
5644
- color: "warning",
5645
- class: "bg-warning-500 border-warning-500"
5646
- },
5647
- { checked: true, color: "info", class: "bg-info-500 border-info-500" },
5648
- {
5649
- checked: true,
5650
- color: "orange",
5651
- class: "border-orange-500 bg-orange-500"
5652
- },
5653
- {
5654
- checked: true,
5655
- color: "purple",
5656
- class: "border-purple-500 bg-purple-500"
5657
- },
5658
- { checked: true, color: "gray", class: "border-gray-600 bg-gray-600" },
5659
- // Unchecked state - background white
5660
- { checked: false, class: "bg-white" }
5661
- ],
5662
- defaultVariants: {
5663
- size: "md",
5664
- color: "primary",
5665
- checked: false
5593
+ function Dropdown({
5594
+ children,
5595
+ ...props
5596
+ }) {
5597
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Root, { ...props, children });
5598
+ }
5599
+ function DropdownTrigger({
5600
+ children,
5601
+ ...props
5602
+ }) {
5603
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Trigger, { ...props, children });
5604
+ }
5605
+ function DropdownContent({
5606
+ children,
5607
+ className,
5608
+ portalProps,
5609
+ ...props
5610
+ }) {
5611
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Portal, { ...portalProps, children: /* @__PURE__ */ jsxRuntime.jsx(
5612
+ DropdownMenu__namespace.Content,
5613
+ {
5614
+ sideOffset: props.sideOffset ?? 15,
5615
+ className: cn(
5616
+ "shadow-dropdown flex flex-col gap-1 rounded-xl border border-gray-200 bg-white p-3",
5617
+ className
5618
+ ),
5619
+ ...props,
5620
+ children
5666
5621
  }
5667
- }
5668
- );
5669
- classVarianceAuthority.cva("transition-all", {
5622
+ ) });
5623
+ }
5624
+ function DropdownItem({
5625
+ children,
5626
+ className,
5627
+ ...props
5628
+ }) {
5629
+ return /* @__PURE__ */ jsxRuntime.jsx(
5630
+ DropdownMenu__namespace.Item,
5631
+ {
5632
+ className: cn(
5633
+ "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",
5634
+ className
5635
+ ),
5636
+ ...props,
5637
+ children
5638
+ }
5639
+ );
5640
+ }
5641
+ var TextVariants = classVarianceAuthority.cva("font-metropolis", {
5670
5642
  variants: {
5671
- size: {
5672
- sm: "h-3 w-3",
5673
- md: "h-4 w-4",
5674
- lg: "h-5 w-5"
5643
+ variant: {
5644
+ h1: "text-[36px] leading-[46px]",
5645
+ h2: "text-[32px] leading-[42px]",
5646
+ h3: "text-[28px] leading-[38px]",
5647
+ h4: "text-[24px] leading-[34px]",
5648
+ p1: "text-[20px] leading-[30px]",
5649
+ p2: "text-[18px] leading-[28px]",
5650
+ p3: "text-[16px] leading-[26px]",
5651
+ t1: "text-[14px] leading-[24px]",
5652
+ t2: "text-[12px] leading-[20px]",
5653
+ t3: "text-[10px] leading-[14px]",
5654
+ t4: "text-[8px] leading-[10px]"
5655
+ },
5656
+ weight: {
5657
+ regular: "font-normal",
5658
+ medium: "font-medium",
5659
+ semibold: "font-semibold",
5660
+ bold: "font-bold"
5675
5661
  },
5676
5662
  color: {
5677
- primary: "text-white",
5678
- secondary: "text-white",
5679
- success: "text-white",
5680
- danger: "text-white",
5681
- warning: "text-white",
5682
- info: "text-white",
5683
- orange: "text-white",
5684
- purple: "text-white",
5685
- gray: "text-white"
5663
+ default: "",
5664
+ muted: "text-gray-400",
5665
+ primary: "text-primary-500",
5666
+ success: "text-success-500",
5667
+ warning: "text-warning-500",
5668
+ orange: "text-orange-500",
5669
+ danger: "text-danger-500",
5670
+ info: "text-info-500",
5671
+ purple: "text-purple-500",
5672
+ gray: "text-gray-500"
5673
+ },
5674
+ align: {
5675
+ start: "text-left",
5676
+ center: "text-center",
5677
+ end: "text-right",
5678
+ justify: "text-justify"
5686
5679
  },
5687
- icon: {
5688
- check: "",
5689
- minus: ""
5680
+ numberOfLines: {
5681
+ 1: "line-clamp-1",
5682
+ 2: "line-clamp-2",
5683
+ 3: "line-clamp-3",
5684
+ 4: "line-clamp-4"
5690
5685
  }
5691
5686
  },
5692
5687
  defaultVariants: {
5693
- size: "md",
5694
- color: "primary",
5695
- icon: "check"
5688
+ variant: "t2",
5689
+ weight: "regular",
5690
+ color: "default",
5691
+ align: "start"
5696
5692
  }
5697
5693
  });
5694
+ function Text({
5695
+ as: TextComponent = "p",
5696
+ align,
5697
+ color,
5698
+ numberOfLines,
5699
+ variant,
5700
+ weight,
5701
+ value,
5702
+ children,
5703
+ className
5704
+ }) {
5705
+ const content = value ?? children;
5706
+ return /* @__PURE__ */ jsxRuntime.jsx(
5707
+ TextComponent,
5708
+ {
5709
+ className: cn(
5710
+ TextVariants({
5711
+ variant,
5712
+ weight,
5713
+ color,
5714
+ align,
5715
+ numberOfLines
5716
+ }),
5717
+ className
5718
+ ),
5719
+ children: content
5720
+ }
5721
+ );
5722
+ }
5723
+ function ButtonMore({ count, onClick }) {
5724
+ return /* @__PURE__ */ jsxRuntime.jsx(
5725
+ "button",
5726
+ {
5727
+ type: "button",
5728
+ onClick,
5729
+ className: "h-full w-full cursor-pointer px-1 transition-colors hover:bg-gray-50",
5730
+ title: `+${count} more`,
5731
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Text, { weight: "medium", className: "line-clamp-1 text-gray-700", children: [
5732
+ "+",
5733
+ count,
5734
+ " more"
5735
+ ] })
5736
+ }
5737
+ );
5738
+ }
5739
+ var inputVariants = classVarianceAuthority.cva(
5740
+ "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",
5741
+ {
5742
+ variants: {
5743
+ size: {
5744
+ sm: "h-8 text-xs",
5745
+ md: "h-9 text-sm",
5746
+ lg: "h-10 text-base"
5747
+ }
5748
+ },
5749
+ defaultVariants: {
5750
+ size: "md"
5751
+ }
5752
+ }
5753
+ );
5698
5754
  var FormDescription = ({
5699
5755
  className,
5700
5756
  children
@@ -5748,7 +5804,7 @@ var FormLabel = ({
5748
5804
  var FormHint = ({ className, children }) => {
5749
5805
  return /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn("text-xs text-gray-700", className), children });
5750
5806
  };
5751
- var FormField = React283__namespace.default.forwardRef(
5807
+ var FormField = React280__namespace.default.forwardRef(
5752
5808
  function FormField2({
5753
5809
  label,
5754
5810
  description,
@@ -5769,222 +5825,38 @@ var FormField = React283__namespace.default.forwardRef(
5769
5825
  ] });
5770
5826
  }
5771
5827
  );
5772
- React283.createContext(void 0);
5773
- classVarianceAuthority.cva(
5774
- "inline-flex cursor-pointer items-center justify-center rounded-lg border transition-all duration-200",
5775
- {
5776
- variants: {
5777
- size: {
5778
- sm: "p-1.5 text-xs",
5779
- md: "p-2 text-sm",
5780
- lg: "px-3 py-2 text-base"
5781
- },
5782
- color: {
5783
- primary: "",
5784
- success: "",
5785
- danger: "",
5786
- warning: "",
5787
- info: "",
5788
- purple: "",
5789
- orange: "",
5790
- gray: ""
5791
- },
5792
- state: {
5793
- default: "",
5794
- selected: "",
5795
- disabled: ""
5796
- },
5797
- block: {
5798
- true: "w-full",
5799
- false: ""
5800
- }
5801
- },
5802
- compoundVariants: [
5803
- // Default color variants
5804
- {
5805
- color: "gray",
5806
- state: "default",
5807
- className: "border-gray-00 bg-white text-gray-700 hover:bg-gray-100"
5808
- },
5809
- {
5810
- color: "gray",
5811
- state: "selected",
5812
- className: "border-gray-400 bg-gray-200 text-gray-800"
5813
- },
5814
- {
5815
- color: "gray",
5816
- state: "disabled",
5817
- className: "cursor-not-allowed border-gray-200 bg-gray-100 text-gray-400"
5818
- },
5819
- // Primary color variants
5820
- {
5821
- color: "primary",
5822
- state: "default",
5823
- className: "border-primary-200 text-primary-1000 hover:bg-primary-50 bg-white"
5824
- },
5825
- {
5826
- color: "primary",
5827
- state: "selected",
5828
- className: "bg-primary-50 border-primary-200 text-primary-1000"
5829
- },
5830
- {
5831
- color: "primary",
5832
- state: "disabled",
5833
- className: "bg-primary-100 border-primary-200 text-primary-300 cursor-not-allowed"
5834
- },
5835
- // Success color variants
5836
- {
5837
- color: "success",
5838
- state: "default",
5839
- className: "border-success-300 text-success-500 hover:bg-success-50 bg-white"
5840
- },
5841
- {
5842
- color: "success",
5843
- state: "selected",
5844
- className: "bg-success-100 border-success-200 text-success-500"
5845
- },
5846
- {
5847
- color: "success",
5848
- state: "disabled",
5849
- className: "bg-success-100 border-success-200 text-success-300 cursor-not-allowed"
5850
- },
5851
- // Danger color variants
5852
- {
5853
- color: "danger",
5854
- state: "default",
5855
- className: "border-danger-200 text-danger-500 hover:bg-danger-50 bg-white"
5856
- },
5857
- {
5858
- color: "danger",
5859
- state: "selected",
5860
- className: "bg-danger-100 border-danger-200 text-danger-500"
5861
- },
5862
- {
5863
- color: "danger",
5864
- state: "disabled",
5865
- className: "bg-danger-100 border-danger-200 text-danger-300 cursor-not-allowed"
5866
- },
5867
- // Warning color variants
5868
- {
5869
- color: "warning",
5870
- state: "default",
5871
- className: "border-warning-300 text-warning-400 hover:bg-warning-50 bg-white"
5872
- },
5873
- {
5874
- color: "warning",
5875
- state: "selected",
5876
- className: "bg-warning-100 border-warning-300 text-warning-500"
5877
- },
5878
- {
5879
- color: "warning",
5880
- state: "disabled",
5881
- className: "bg-warning-100 border-warning-200 text-warning-300 cursor-not-allowed"
5882
- },
5883
- // Info color variants
5884
- {
5885
- color: "info",
5886
- state: "default",
5887
- className: "border-info-200 text-info-500 hover:bg-info-50 bg-white"
5888
- },
5889
- {
5890
- color: "info",
5891
- state: "selected",
5892
- className: "bg-info-100 border-info-200 text-info-500"
5893
- },
5894
- {
5895
- color: "info",
5896
- state: "disabled",
5897
- className: "bg-info-100 border-info-200 text-info-300 cursor-not-allowed"
5898
- },
5899
- // Purple color variants
5900
- {
5901
- color: "purple",
5902
- state: "default",
5903
- className: "border-purple-200 bg-white text-purple-500 hover:bg-purple-50"
5904
- },
5905
- {
5906
- color: "purple",
5907
- state: "selected",
5908
- className: "border-purple-200 bg-purple-100 text-purple-500"
5909
- },
5910
- {
5911
- color: "purple",
5912
- state: "disabled",
5913
- className: "cursor-not-allowed border-purple-200 bg-purple-100 text-purple-300"
5914
- },
5915
- // Orange color variants
5916
- {
5917
- color: "orange",
5918
- state: "default",
5919
- className: "border-orange-200 bg-white text-orange-500 hover:bg-orange-50"
5920
- },
5921
- {
5922
- color: "orange",
5923
- state: "selected",
5924
- className: "border-orange-200 bg-orange-100 text-orange-500"
5925
- },
5926
- {
5927
- color: "orange",
5928
- state: "disabled",
5929
- className: "cursor-not-allowed border-orange-200 bg-orange-100 text-orange-300"
5930
- }
5931
- ],
5932
- defaultVariants: {
5933
- size: "md",
5934
- color: "primary",
5935
- state: "default",
5936
- block: false
5937
- }
5938
- }
5939
- );
5940
- React283.createContext(null);
5941
- var inputVariants = classVarianceAuthority.cva(
5942
- "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",
5943
- {
5944
- variants: {
5945
- size: {
5946
- sm: "h-8 text-xs",
5947
- md: "h-9 text-sm",
5948
- lg: "h-10 text-base"
5949
- }
5950
- },
5951
- defaultVariants: {
5952
- size: "md"
5953
- }
5954
- }
5955
- );
5956
- var Input = React283__namespace.forwardRef(
5957
- ({
5958
- className,
5959
- leftAddon,
5960
- rightAddon,
5961
- type = "text",
5962
- label,
5963
- hint,
5964
- errorMessages,
5965
- size,
5966
- inputSize,
5967
- description,
5968
- leftAddonClassName,
5969
- rightAddonClassName,
5970
- mergedAddon,
5971
- isError,
5972
- onContainerResize,
5973
- ...props
5974
- }, ref) => {
5975
- const hasError = fieldHasError(errorMessages) ?? isError;
5976
- const generatedId = React283__namespace.useId();
5977
- const fieldRef = React283__namespace.useRef(null);
5978
- React283__namespace.useEffect(() => {
5979
- if (!fieldRef.current || !onContainerResize) return;
5980
- const ro = new ResizeObserver(([entry]) => {
5981
- onContainerResize(entry.contentRect.width);
5982
- });
5983
- ro.observe(fieldRef.current);
5984
- return () => ro.disconnect();
5985
- }, [onContainerResize]);
5986
- return /* @__PURE__ */ jsxRuntime.jsx(
5987
- FormField,
5828
+ var Input = React280__namespace.forwardRef(
5829
+ ({
5830
+ className,
5831
+ leftAddon,
5832
+ rightAddon,
5833
+ type = "text",
5834
+ label,
5835
+ hint,
5836
+ errorMessages,
5837
+ size,
5838
+ inputSize,
5839
+ description,
5840
+ leftAddonClassName,
5841
+ rightAddonClassName,
5842
+ mergedAddon,
5843
+ isError,
5844
+ onContainerResize,
5845
+ ...props
5846
+ }, ref) => {
5847
+ const hasError = fieldHasError(errorMessages) ?? isError;
5848
+ const generatedId = React280__namespace.useId();
5849
+ const fieldRef = React280__namespace.useRef(null);
5850
+ React280__namespace.useEffect(() => {
5851
+ if (!fieldRef.current || !onContainerResize) return;
5852
+ const ro = new ResizeObserver(([entry]) => {
5853
+ onContainerResize(entry.contentRect.width);
5854
+ });
5855
+ ro.observe(fieldRef.current);
5856
+ return () => ro.disconnect();
5857
+ }, [onContainerResize]);
5858
+ return /* @__PURE__ */ jsxRuntime.jsx(
5859
+ FormField,
5988
5860
  {
5989
5861
  ref: fieldRef,
5990
5862
  label,
@@ -6055,1147 +5927,182 @@ var Input = React283__namespace.forwardRef(
6055
5927
  }
6056
5928
  );
6057
5929
  Input.displayName = "Input";
6058
- var MOBILE_BREAKPOINT = 768;
6059
- function useIsMobile() {
6060
- const [isMobile, setIsMobile] = React283__namespace.useState(false);
6061
- React283__namespace.useEffect(() => {
6062
- const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
6063
- const onChange = () => {
6064
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
6065
- };
6066
- mql.addEventListener("change", onChange);
6067
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
6068
- return () => mql.removeEventListener("change", onChange);
6069
- }, []);
6070
- return !!isMobile;
6071
- }
6072
- React283__namespace.default.createContext(
6073
- null
6074
- );
6075
- function TooltipProvider({
6076
- delayDuration = 0,
6077
- ...props
6078
- }) {
6079
- return /* @__PURE__ */ jsxRuntime.jsx(
6080
- TooltipPrimitive__namespace.Provider,
6081
- {
6082
- "data-slot": "tooltip-provider",
6083
- delayDuration,
6084
- ...props
6085
- }
6086
- );
6087
- }
6088
- function Tooltip({
6089
- ...props
6090
- }) {
6091
- return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Root, { "data-slot": "tooltip", ...props }) });
6092
- }
6093
- function TooltipTrigger({
6094
- ...props
6095
- }) {
6096
- return /* @__PURE__ */ jsxRuntime.jsx(
6097
- TooltipPrimitive__namespace.Trigger,
6098
- {
6099
- "data-slot": "tooltip-trigger",
6100
- type: "button",
6101
- ...props
6102
- }
6103
- );
6104
- }
6105
- function TooltipContent({
6106
- className,
6107
- sideOffset = 0,
6108
- children,
6109
- ...props
6110
- }) {
6111
- return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
6112
- TooltipPrimitive__namespace.Content,
6113
- {
6114
- "data-slot": "tooltip-content",
6115
- sideOffset,
6116
- className: cn(
6117
- "text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md bg-gray-900 px-3 py-1.5 text-xs text-balance text-white",
6118
- className
6119
- ),
6120
- ...props,
6121
- children: [
6122
- children,
6123
- /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Arrow, { className: "z-50 size-2.5 -translate-y-1 rounded-xs bg-transparent fill-gray-900" })
6124
- ]
6125
- }
6126
- ) });
5930
+
5931
+ // src/components/date-picker/helpers.ts
5932
+ function formatDateLocal(date) {
5933
+ const y = date.getFullYear();
5934
+ const m = String(date.getMonth() + 1).padStart(2, "0");
5935
+ const d = String(date.getDate()).padStart(2, "0");
5936
+ return `${y}-${m}-${d}`;
6127
5937
  }
6128
5938
  classVarianceAuthority.cva(
6129
- "relative z-50 w-full rounded-2xl bg-white shadow-xl focus:outline-none",
6130
- {
6131
- variants: {
6132
- size: {
6133
- xs: "max-w-[327px]",
6134
- sm: "max-w-[480px]",
6135
- md: "max-w-[700px]",
6136
- lg: "max-w-[1000px]",
6137
- full: "mx-4 max-w-full"
6138
- },
6139
- state: {
6140
- open: "animate-modal-scale-in",
6141
- closed: "animate-modal-scale-out"
6142
- }
6143
- },
6144
- defaultVariants: {
6145
- size: "md"
6146
- }
6147
- }
6148
- );
6149
- classVarianceAuthority.cva("fixed inset-0 z-[999] m-0 flex p-4", {
6150
- variants: {
6151
- position: {
6152
- center: "items-center justify-center",
6153
- top: "items-start justify-center",
6154
- bottom: "items-end justify-center"
6155
- },
6156
- state: {
6157
- open: "animate-modal-fade-in",
6158
- closed: "animate-modal-fade-out"
6159
- }
6160
- },
6161
- defaultVariants: {
6162
- position: "center"
6163
- }
6164
- });
6165
- var TextVariants = classVarianceAuthority.cva("font-metropolis", {
6166
- variants: {
6167
- variant: {
6168
- h1: "text-[36px] leading-[46px]",
6169
- h2: "text-[32px] leading-[42px]",
6170
- h3: "text-[28px] leading-[38px]",
6171
- h4: "text-[24px] leading-[34px]",
6172
- p1: "text-[20px] leading-[30px]",
6173
- p2: "text-[18px] leading-[28px]",
6174
- p3: "text-[16px] leading-[26px]",
6175
- t1: "text-[14px] leading-[24px]",
6176
- t2: "text-[12px] leading-[20px]",
6177
- t3: "text-[10px] leading-[14px]",
6178
- t4: "text-[8px] leading-[10px]"
6179
- },
6180
- weight: {
6181
- regular: "font-normal",
6182
- medium: "font-medium",
6183
- semibold: "font-semibold",
6184
- bold: "font-bold"
6185
- },
6186
- color: {
6187
- default: "",
6188
- muted: "text-gray-400",
6189
- primary: "text-primary-500",
6190
- success: "text-success-500",
6191
- warning: "text-warning-500",
6192
- orange: "text-orange-500",
6193
- danger: "text-danger-500",
6194
- info: "text-info-500",
6195
- purple: "text-purple-500",
6196
- gray: "text-gray-500"
6197
- },
6198
- align: {
6199
- start: "text-left",
6200
- center: "text-center",
6201
- end: "text-right",
6202
- justify: "text-justify"
6203
- },
6204
- numberOfLines: {
6205
- 1: "line-clamp-1",
6206
- 2: "line-clamp-2",
6207
- 3: "line-clamp-3",
6208
- 4: "line-clamp-4"
6209
- }
6210
- },
6211
- defaultVariants: {
6212
- variant: "t2",
6213
- weight: "regular",
6214
- color: "default",
6215
- align: "start"
6216
- }
6217
- });
6218
- function Text({
6219
- as: TextComponent = "p",
6220
- align,
6221
- color,
6222
- numberOfLines,
6223
- variant,
6224
- weight,
6225
- value,
6226
- children,
6227
- className
6228
- }) {
6229
- const content = value ?? children;
6230
- return /* @__PURE__ */ jsxRuntime.jsx(
6231
- TextComponent,
6232
- {
6233
- className: cn(
6234
- TextVariants({
6235
- variant,
6236
- weight,
6237
- color,
6238
- align,
6239
- numberOfLines
6240
- }),
6241
- className
6242
- ),
6243
- children: content
6244
- }
6245
- );
6246
- }
6247
- var inputFileVariants = classVarianceAuthority.cva("", {
6248
- variants: {
6249
- variant: {
6250
- primary: "bg-primary-1000 *:*:text-white border-primary-1000 focus-within:outline-primary-900 hover:bg-primary-1000",
6251
- //prettier-ignore
6252
- secondary: "bg-transparent *:*:text-primary-1000 border-primary-1000 focus-within:outline-primary-900 hover:bg-primary-50",
6253
- //prettier-ignore
6254
- gray: "bg-gray-700 *:*:text-white border-gray-700 focus-within:outline-gray-700 hover:bg-gray-700",
6255
- //prettier-ignore
6256
- medium: "",
6257
- large: ""
6258
- }
6259
- }
6260
- });
6261
-
6262
- // src/components/input-file/helpers.ts
6263
- var getIconName = ({
6264
- file,
6265
- fileType
6266
- }) => {
6267
- const type = file?.type ?? fileType;
6268
- const ext = file?.name.split(".").pop()?.toLowerCase();
6269
- if (type !== void 0 && type?.startsWith("image/")) {
6270
- return null;
6271
- }
6272
- if (type !== void 0 && type?.includes("spreadsheet") || ext === "xls" || ext === "xlsx") {
6273
- return "xls";
6274
- }
6275
- if (type !== void 0 && type?.includes("word") || ext === "doc" || ext === "docx") {
6276
- return "doc";
6277
- }
6278
- if (type !== void 0 && type?.startsWith("video/") || ext === "mkv" || ext === "mp4") {
6279
- return "mp4";
6280
- }
6281
- if (type !== void 0 && type?.startsWith("audio/") || ext === "mp3") {
6282
- return "mp3";
6283
- }
6284
- if (type !== void 0 && type?.includes("pdf") || ext === "pdf") {
6285
- return "pdf";
6286
- }
6287
- return "doc";
6288
- };
6289
- var ModalPreviewAttachment = ({
6290
- onClose,
6291
- open,
6292
- src,
6293
- name,
6294
- type,
6295
- iframeProps,
6296
- audioProps,
6297
- videoProps
6298
- }) => {
6299
- const [zoom, setZoom] = React283.useState(1);
6300
- const [isDragging, setIsDragging] = React283.useState(false);
6301
- const [position, setPosition] = React283.useState({ x: 0, y: 0 });
6302
- const [dragStart, setDragStart] = React283.useState({ x: 0, y: 0 });
6303
- const isImage = type.startsWith("image/");
6304
- const isMp3 = type.startsWith("audio/");
6305
- const isVideo = type.startsWith("video/");
6306
- const isPdf = type === "application/pdf";
6307
- const iconName = getIconName({ fileType: type });
6308
- const MIN_ZOOM = 0.5;
6309
- const MAX_ZOOM = 5;
6310
- const ZOOM_STEP = 0.5;
6311
- const handleZoomIn = () => {
6312
- setZoom((prev) => Math.min(prev + ZOOM_STEP, MAX_ZOOM));
6313
- };
6314
- const handleZoomOut = () => {
6315
- setZoom((prev) => {
6316
- const newZoom = Math.max(prev - ZOOM_STEP, MIN_ZOOM);
6317
- if (newZoom <= 1) {
6318
- setPosition({ x: 0, y: 0 });
6319
- }
6320
- return newZoom;
6321
- });
6322
- };
6323
- const handleMouseDown = (e) => {
6324
- if (zoom > 1) {
6325
- setIsDragging(true);
6326
- setDragStart({
6327
- x: e.clientX - position.x,
6328
- y: e.clientY - position.y
6329
- });
6330
- }
6331
- };
6332
- const handleMouseMove = (e) => {
6333
- if (isDragging && zoom > 1) {
6334
- setPosition({
6335
- x: e.clientX - dragStart.x,
6336
- y: e.clientY - dragStart.y
6337
- });
6338
- }
6339
- };
6340
- const handleMouseUp = () => {
6341
- setIsDragging(false);
6342
- };
6343
- const handleDownload = () => {
6344
- const link = document.createElement("a");
6345
- link.href = src;
6346
- link.download = name;
6347
- document.body.appendChild(link);
6348
- link.click();
6349
- document.body.removeChild(link);
6350
- };
6351
- React283.useEffect(() => {
6352
- if (!open.isOpen) {
6353
- setZoom(1);
6354
- setPosition({ x: 0, y: 0 });
6355
- setIsDragging(false);
6356
- }
6357
- }, [open.isOpen]);
6358
- React283.useEffect(() => {
6359
- document.body.style.overflow = open.isOpen ? "hidden" : "unset";
6360
- }, [open.isOpen]);
6361
- if (!open.isOpen) return null;
6362
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("fixed inset-0 z-20"), children: [
6363
- /* @__PURE__ */ jsxRuntime.jsx(
6364
- "div",
6365
- {
6366
- className: cn(
6367
- `fixed inset-0 z-10 size-full bg-black/40 transition-all`,
6368
- open.isVisible ? "opacity-100" : "opacity-0"
6369
- ),
6370
- onClick: onClose
6371
- }
6372
- ),
6373
- /* @__PURE__ */ jsxRuntime.jsxs(
6374
- "div",
6375
- {
6376
- className: cn(
6377
- "relative z-20 container mx-auto flex h-full flex-col items-center gap-6 py-10 transition-all",
6378
- open.isVisible ? "translate-y-0 opacity-100" : "-translate-y-10 opacity-0"
6379
- ),
6380
- children: [
6381
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full justify-between", children: [
6382
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
6383
- /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: onClose, className: "cursor-pointer", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "times", color: "white" }) }),
6384
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
6385
- iconName && /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: iconName, size: 48 }),
6386
- /* @__PURE__ */ jsxRuntime.jsx(
6387
- Text,
6388
- {
6389
- value: name,
6390
- variant: "p3",
6391
- weight: "semibold",
6392
- className: "text-white!"
6393
- }
6394
- )
6395
- ] })
6396
- ] }),
6397
- isImage && /* @__PURE__ */ jsxRuntime.jsx(
6398
- ZoomController,
6399
- {
6400
- onDownload: handleDownload,
6401
- onZoomIn: handleZoomIn,
6402
- onZoomOut: handleZoomOut,
6403
- maxZoom: MAX_ZOOM,
6404
- minZoom: MIN_ZOOM,
6405
- zoom
6406
- }
6407
- )
6408
- ] }),
6409
- isImage && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6410
- /* @__PURE__ */ jsxRuntime.jsx(
6411
- "div",
6412
- {
6413
- className: "scrollbar-hide relative flex size-full justify-center overflow-auto rounded-xl",
6414
- onMouseDown: handleMouseDown,
6415
- onMouseMove: handleMouseMove,
6416
- onMouseUp: handleMouseUp,
6417
- onMouseLeave: handleMouseUp,
6418
- style: {
6419
- cursor: zoom > 1 ? isDragging ? "grabbing" : "grab" : "default"
6420
- },
6421
- children: /* @__PURE__ */ jsxRuntime.jsx(
6422
- "img",
6423
- {
6424
- src,
6425
- alt: name,
6426
- draggable: false,
6427
- className: "h-full rounded-xl object-contain select-none",
6428
- style: {
6429
- transform: `scale(${zoom}) translate(${position.x / zoom}px, ${position.y / zoom}px)`,
6430
- transformOrigin: "top left",
6431
- transition: isDragging ? "none" : "transform 0.2s ease-out"
6432
- }
6433
- }
6434
- )
6435
- }
6436
- ),
6437
- 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(
6438
- Text,
6439
- {
6440
- value: "Click and drag to pan \u2022 Scroll to zoom",
6441
- variant: "t3",
6442
- className: "text-white/80!"
6443
- }
6444
- ) })
6445
- ] }),
6446
- isVideo && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
6447
- "video",
6448
- {
6449
- src,
6450
- controls: true,
6451
- className: cn(
6452
- "h-full w-full rounded-xl object-contain",
6453
- videoProps?.className
6454
- ),
6455
- ...videoProps
6456
- }
6457
- ) }),
6458
- isPdf && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
6459
- "iframe",
6460
- {
6461
- src,
6462
- className: cn("h-full w-full", iframeProps?.className),
6463
- ...iframeProps
6464
- }
6465
- ) }),
6466
- isMp3 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-full items-center justify-center overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
6467
- "audio",
6468
- {
6469
- src,
6470
- controls: true,
6471
- className: cn("h-full w-full", audioProps?.className),
6472
- ...audioProps
6473
- }
6474
- ) })
6475
- ]
6476
- }
6477
- )
6478
- ] });
6479
- };
6480
- var ZoomController = ({
6481
- zoom,
6482
- onZoomIn,
6483
- onZoomOut,
6484
- onDownload,
6485
- maxZoom,
6486
- minZoom
6487
- }) => {
6488
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
6489
- /* @__PURE__ */ jsxRuntime.jsx(
6490
- Button,
6491
- {
6492
- size: "icon",
6493
- onClick: onZoomIn,
6494
- disabled: zoom >= maxZoom,
6495
- type: "button",
6496
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "search-plus-fill" })
6497
- }
6498
- ),
6499
- /* @__PURE__ */ jsxRuntime.jsx(
6500
- Button,
6501
- {
6502
- size: "icon",
6503
- onClick: onZoomOut,
6504
- disabled: zoom <= minZoom,
6505
- type: "button",
6506
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "search-minus-fill" })
6507
- }
6508
- ),
6509
- /* @__PURE__ */ jsxRuntime.jsxs(Button, { color: "secondary", onClick: onDownload, children: [
6510
- /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "download" }),
6511
- /* @__PURE__ */ jsxRuntime.jsx(
6512
- Text,
6513
- {
6514
- as: "span",
6515
- value: "Download",
6516
- weight: "medium",
6517
- className: "text-primary-1000!"
6518
- }
6519
- )
6520
- ] })
6521
- ] });
6522
- };
6523
- var PreviewItem = ({
6524
- data,
6525
- onRemove,
6526
- onReplace,
6527
- disabled = false,
6528
- labelCustomName = "Attachment File",
6529
- onCustomNameChange,
6530
- customNamePlaceholder = "Name Attachment",
6531
- customName,
6532
- audioPlayerProps,
6533
- pdfViewerProps,
6534
- videoPlayerProps
6535
- }) => {
6536
- const [previewShow, setPreviewShow] = React283.useState({
6537
- isOpen: false,
6538
- isVisible: false
6539
- });
6540
- const isImage = data?.file?.type.startsWith("image/");
6541
- const isMp3 = data?.file?.type.startsWith("audio/");
6542
- const isVideo = data?.file?.type.startsWith("video/");
6543
- const isPdf = data?.file?.type === "application/pdf";
6544
- const isNotViewable = !isImage && !isMp3 && !isVideo && !isPdf;
6545
- const iconName = getIconName({ file: data.file });
6546
- const handleOpenPreview = () => {
6547
- setPreviewShow({
6548
- isOpen: true,
6549
- isVisible: false
6550
- });
6551
- requestAnimationFrame(() => {
6552
- setPreviewShow({
6553
- isOpen: true,
6554
- isVisible: true
6555
- });
6556
- });
6557
- };
6558
- const handleClosePreview = () => {
6559
- setPreviewShow((s) => ({ ...s, isVisible: false }));
6560
- setTimeout(() => {
6561
- setPreviewShow({ isOpen: false, isVisible: false });
6562
- }, 200);
6563
- };
6564
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
6565
- !!onCustomNameChange && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full flex-col gap-2", children: [
6566
- /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: labelCustomName }),
6567
- /* @__PURE__ */ jsxRuntime.jsx(
6568
- Input,
6569
- {
6570
- type: "text",
6571
- onChange: onCustomNameChange,
6572
- placeholder: customNamePlaceholder,
6573
- value: customName,
6574
- className: "truncate"
6575
- }
6576
- )
6577
- ] }),
6578
- /* @__PURE__ */ jsxRuntime.jsxs(
6579
- "div",
6580
- {
6581
- className: cn(
6582
- "flex w-full items-center justify-between rounded-lg border border-gray-200 p-2"
6583
- ),
6584
- children: [
6585
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 items-center gap-2 overflow-hidden", children: [
6586
- /* @__PURE__ */ jsxRuntime.jsx(
6587
- "button",
6588
- {
6589
- type: "button",
6590
- className: "cursor-pointer disabled:cursor-not-allowed",
6591
- onClick: handleOpenPreview,
6592
- disabled: isNotViewable,
6593
- children: data.file.type.startsWith("image/") ? /* @__PURE__ */ jsxRuntime.jsx(
6594
- "img",
6595
- {
6596
- src: data.preview,
6597
- alt: data.file.name,
6598
- className: "size-11 rounded-md object-cover"
6599
- }
6600
- ) : /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: iconName ?? "doc", className: "size-11" })
6601
- }
6602
- ),
6603
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
6604
- /* @__PURE__ */ jsxRuntime.jsx(
6605
- Text,
6606
- {
6607
- as: "h3",
6608
- value: data.file.name,
6609
- variant: "t1",
6610
- weight: "semibold",
6611
- className: "truncate"
6612
- }
6613
- ),
6614
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-1", children: [
6615
- /* @__PURE__ */ jsxRuntime.jsx(
6616
- Text,
6617
- {
6618
- value: `${(data.file.size / 1024 / 1024).toFixed(2)} MB`,
6619
- className: "truncate text-gray-700!"
6620
- }
6621
- ),
6622
- (Boolean(data?.hint) || Boolean(data?.errorMessage)) && /* @__PURE__ */ jsxRuntime.jsx(Text, { value: "\u2022", className: "truncate text-gray-700!" }),
6623
- Boolean(data?.hint) && /* @__PURE__ */ jsxRuntime.jsx(
6624
- Text,
6625
- {
6626
- value: data?.hint ?? "",
6627
- className: "truncate text-gray-700!"
6628
- }
6629
- ),
6630
- Boolean(data?.hint) && Boolean(data?.errorMessage) && /* @__PURE__ */ jsxRuntime.jsx(Text, { value: "\u2022", className: "truncate text-gray-700!" }),
6631
- Boolean(data?.errorMessage) && /* @__PURE__ */ jsxRuntime.jsx(Text, { value: data?.errorMessage ?? "", color: "danger" })
6632
- ] })
6633
- ] })
6634
- ] }),
6635
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
6636
- Boolean(data?.errorMessage) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6637
- /* @__PURE__ */ jsxRuntime.jsx(
6638
- "button",
6639
- {
6640
- type: "button",
6641
- onClick: onReplace,
6642
- disabled,
6643
- className: "cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
6644
- title: "Replace file",
6645
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "rotate-right", className: "size-4 text-gray-700" })
6646
- }
6647
- ),
6648
- /* @__PURE__ */ jsxRuntime.jsx(
6649
- Icon,
6650
- {
6651
- name: "exclamation-triangle",
6652
- className: "text-danger-500 size-4"
6653
- }
6654
- )
6655
- ] }),
6656
- /* @__PURE__ */ jsxRuntime.jsx(
6657
- "button",
6658
- {
6659
- type: "button",
6660
- onClick: onRemove,
6661
- disabled,
6662
- className: "cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
6663
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "times", className: "size-4 text-gray-700" })
6664
- }
6665
- )
6666
- ] })
6667
- ]
6668
- }
6669
- ),
6670
- /* @__PURE__ */ jsxRuntime.jsx(
6671
- ModalPreviewAttachment,
6672
- {
6673
- type: data?.file?.type,
6674
- name: data?.customName ?? data?.file?.name,
6675
- src: data?.preview,
6676
- open: previewShow,
6677
- onClose: () => handleClosePreview(),
6678
- audioProps: audioPlayerProps,
6679
- videoProps: videoPlayerProps,
6680
- iframeProps: pdfViewerProps
6681
- }
6682
- )
6683
- ] });
6684
- };
6685
- var InputFile = React283.forwardRef(
6686
- ({
6687
- value,
6688
- onChange,
6689
- multiple = false,
6690
- accept,
6691
- maxSize,
6692
- maxFiles,
6693
- disabled = false,
6694
- variant = "primary",
6695
- buttonLabel = "Choose File",
6696
- label = "Choose File",
6697
- hint = "JPG, PNG, dan PDF (Max. 5MB)",
6698
- errorMessage,
6699
- maxSizeErrorMessage,
6700
- maxFilesErrorMessage,
6701
- customNamePlaceholder,
6702
- useCustomName,
6703
- pdfViewerProps,
6704
- audioPlayerProps,
6705
- videoPlayerProps
6706
- }, ref) => {
6707
- const inputRef = React283.useRef(null);
6708
- const replaceInputRef = React283.useRef(null);
6709
- const [internalFiles, setInternalFiles] = React283.useState([]);
6710
- const [replaceIndex, setReplaceIndex] = React283.useState(null);
6711
- const [customNames, setCustomNames] = React283.useState({});
6712
- const [isDragging, setIsDragging] = React283.useState(false);
6713
- const files = value ?? internalFiles;
6714
- const setFiles = onChange ?? setInternalFiles;
6715
- const processFiles = (selectedFiles) => {
6716
- if (maxFiles !== void 0 && files.length + selectedFiles.length > maxFiles) {
6717
- alert(maxFilesErrorMessage ?? `Maksimal ${maxFiles} file`);
6718
- return;
6719
- }
6720
- if (maxSize !== void 0) {
6721
- const oversized = selectedFiles.filter((file) => file.size > maxSize);
6722
- if (oversized.length > 0) {
6723
- alert(
6724
- maxSizeErrorMessage ?? `File ${oversized.map((f) => f.name).join(", ")} melebihi ukuran maksimal ${(maxSize / 1024 / 1024).toFixed(2)} MB`
6725
- );
6726
- return;
6727
- }
6728
- }
6729
- const mapped = selectedFiles.map((file) => ({
6730
- id: crypto.randomUUID(),
6731
- file,
6732
- customName: file.name,
6733
- preview: URL.createObjectURL(file)
6734
- }));
6735
- setFiles([...files, ...mapped]);
6736
- };
6737
- const handleChange = (e) => {
6738
- const selected = Array.from(e.target.files ?? []);
6739
- processFiles(selected);
6740
- if (inputRef.current) {
6741
- inputRef.current.value = "";
6742
- }
6743
- };
6744
- const handleChangeCustomName = ({
6745
- e,
6746
- i
6747
- }) => {
6748
- if (replaceIndex !== null) return;
6749
- const val = e.target.value;
6750
- setCustomNames((prev) => ({
6751
- ...prev,
6752
- [i]: val
6753
- }));
6754
- };
6755
- const handleReplace = (e) => {
6756
- if (replaceIndex === null) return;
6757
- const selected = e.target.files?.[0];
6758
- if (!selected) return;
6759
- if (maxSize !== void 0 && selected.size > maxSize) {
6760
- alert(
6761
- maxSizeErrorMessage ?? `File ${selected.name} melebihi ukuran maksimal ${(maxSize / 1024 / 1024).toFixed(2)} MB`
6762
- );
6763
- return;
6764
- }
6765
- URL.revokeObjectURL(files[replaceIndex].preview);
6766
- const newFileItem = {
6767
- file: selected,
6768
- preview: URL.createObjectURL(selected)
6769
- };
6770
- const newFiles = [...files];
6771
- newFiles[replaceIndex] = newFileItem;
6772
- setFiles(newFiles);
6773
- setReplaceIndex(null);
6774
- if (replaceInputRef.current) {
6775
- replaceInputRef.current.value = "";
6776
- }
6777
- };
6778
- const removeFile = (index) => {
6779
- const newFiles = files.filter((_, i) => i !== index);
6780
- URL.revokeObjectURL(files[index].preview);
6781
- setFiles(newFiles);
6782
- };
6783
- const clearAll = () => {
6784
- files.forEach((f) => URL.revokeObjectURL(f.preview));
6785
- setFiles([]);
6786
- if (inputRef.current) {
6787
- inputRef.current.value = "";
6788
- }
6789
- };
6790
- const triggerReplace = (index) => {
6791
- setReplaceIndex(index);
6792
- replaceInputRef.current?.click();
6793
- };
6794
- const openFilePicker = () => {
6795
- inputRef.current?.click();
6796
- };
6797
- const handleDragEnter = (e) => {
6798
- e.preventDefault();
6799
- e.stopPropagation();
6800
- if (disabled) return;
6801
- setIsDragging(true);
6802
- };
6803
- const handleDragLeave = (e) => {
6804
- e.preventDefault();
6805
- e.stopPropagation();
6806
- if (disabled) return;
6807
- const rect = e.currentTarget.getBoundingClientRect();
6808
- const x = e.clientX;
6809
- const y = e.clientY;
6810
- if (x <= rect.left || x >= rect.right || y <= rect.top || y >= rect.bottom) {
6811
- setIsDragging(false);
6812
- }
6813
- };
6814
- const handleDragOver = (e) => {
6815
- e.preventDefault();
6816
- e.stopPropagation();
6817
- };
6818
- const handleDrop = (e) => {
6819
- e.preventDefault();
6820
- e.stopPropagation();
6821
- if (disabled) return;
6822
- setIsDragging(false);
6823
- const droppedFiles = Array.from(e.dataTransfer.files);
6824
- let filteredFiles = droppedFiles;
6825
- if (accept !== void 0) {
6826
- const acceptedTypes = accept.split(",").map((type) => type.trim());
6827
- filteredFiles = droppedFiles.filter((file) => {
6828
- return acceptedTypes.some((acceptedType) => {
6829
- if (acceptedType.startsWith(".")) {
6830
- return file.name.endsWith(acceptedType);
6831
- }
6832
- if (acceptedType.endsWith("/*")) {
6833
- const baseType = acceptedType.split("/")[0];
6834
- return file.type.startsWith(baseType + "/");
6835
- }
6836
- return file.type === acceptedType;
6837
- });
6838
- });
6839
- if (filteredFiles.length !== droppedFiles.length) {
6840
- alert(
6841
- `Beberapa file tidak sesuai dengan tipe yang diizinkan: ${accept}`
6842
- );
6843
- }
6844
- }
6845
- if (filteredFiles.length > 0) {
6846
- processFiles(filteredFiles);
6847
- }
6848
- };
6849
- React283.useImperativeHandle(ref, () => ({
6850
- clearAll,
6851
- openFilePicker,
6852
- getFiles: () => files.map((f, i) => {
6853
- const base = { ...f };
6854
- if (useCustomName !== void 0) {
6855
- base.customName = customNames[i] ?? f.customName ?? f.file.name;
6856
- }
6857
- return base;
6858
- })
6859
- }));
6860
- React283.useEffect(() => {
6861
- return () => files.forEach((f) => URL.revokeObjectURL(f.preview));
6862
- }, [files]);
6863
- const isDefault = variant === "primary" || variant === "secondary" || variant === "gray";
6864
- const isSized = variant === "medium" || variant === "large";
6865
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
6866
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
6867
- /* @__PURE__ */ jsxRuntime.jsxs(
6868
- "label",
6869
- {
6870
- className: cn(
6871
- inputFileVariants({ variant }),
6872
- "group relative flex items-center gap-2 rounded-lg border px-3 py-2 transition-all",
6873
- isDefault && "w-fit outline-2 outline-offset-1 outline-transparent",
6874
- //prettier-ignore
6875
- isSized && "w-full border-dashed border-gray-400 bg-gray-50",
6876
- //prettier-ignore
6877
- variant === "large" && errorMessage !== void 0 && "border-danger-500",
6878
- variant === "large" && "flex-col items-center p-5!",
6879
- variant === "large" && isDragging && "border-primary-500 bg-primary-50",
6880
- //prettier-ignore
6881
- disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"
6882
- ),
6883
- onDragEnter: variant === "large" ? handleDragEnter : void 0,
6884
- onDragLeave: variant === "large" ? handleDragLeave : void 0,
6885
- onDragOver: variant === "large" ? handleDragOver : void 0,
6886
- onDrop: variant === "large" ? handleDrop : void 0,
6887
- children: [
6888
- isDefault && /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "upload" }),
6889
- isSized && /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "cloud-upload", size: variant === "large" ? 125 : 40 }),
6890
- /* @__PURE__ */ jsxRuntime.jsxs(
6891
- "div",
6892
- {
6893
- className: cn(
6894
- "flex flex-1 flex-col",
6895
- variant === "large" && "*:text-center"
6896
- ),
6897
- children: [
6898
- /* @__PURE__ */ jsxRuntime.jsx(
6899
- Text,
6900
- {
6901
- as: "h3",
6902
- value: label,
6903
- weight: "semibold",
6904
- className: cn(isSized && "text-gray-800!")
6905
- }
6906
- ),
6907
- isSized && /* @__PURE__ */ jsxRuntime.jsx(
6908
- Text,
6909
- {
6910
- as: "p",
6911
- value: variant === "large" && !isDragging && !hint ? `Klik atau drag & drop file disini` : hint,
6912
- className: "text-gray-600!"
6913
- }
6914
- )
6915
- ]
6916
- }
6917
- ),
6918
- errorMessage !== void 0 && variant === "large" && /* @__PURE__ */ jsxRuntime.jsx(
6919
- Text,
6920
- {
6921
- value: errorMessage,
6922
- variant: "t3",
6923
- className: "text-left",
6924
- color: "danger"
6925
- }
6926
- ),
6927
- isSized && /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => inputRef.current?.click(), type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(
6928
- Text,
6929
- {
6930
- as: "span",
6931
- value: buttonLabel,
6932
- weight: "semibold",
6933
- className: "text-white!"
6934
- }
6935
- ) }),
6936
- /* @__PURE__ */ jsxRuntime.jsx(
6937
- "input",
6938
- {
6939
- ref: inputRef,
6940
- type: "file",
6941
- multiple,
6942
- accept,
6943
- onChange: handleChange,
6944
- disabled,
6945
- className: "absolute inset-0 -z-10 cursor-pointer opacity-0"
6946
- }
6947
- )
6948
- ]
6949
- }
6950
- ),
6951
- errorMessage !== void 0 && variant === "medium" && /* @__PURE__ */ jsxRuntime.jsx(
6952
- Text,
6953
- {
6954
- value: errorMessage,
6955
- variant: "t3",
6956
- className: "text-left",
6957
- color: "danger"
6958
- }
6959
- )
6960
- ] }),
6961
- /* @__PURE__ */ jsxRuntime.jsx(
6962
- "input",
6963
- {
6964
- ref: replaceInputRef,
6965
- type: "file",
6966
- accept,
6967
- onChange: handleReplace,
6968
- className: "hidden"
6969
- }
6970
- ),
6971
- files.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
6972
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
6973
- /* @__PURE__ */ jsxRuntime.jsx(
6974
- Text,
6975
- {
6976
- value: "Selected Files",
6977
- variant: "t1",
6978
- weight: "semibold",
6979
- as: "h1"
6980
- }
6981
- ),
6982
- /* @__PURE__ */ jsxRuntime.jsx(
6983
- "button",
6984
- {
6985
- type: "button",
6986
- onClick: clearAll,
6987
- disabled,
6988
- className: "cursor-pointer disabled:opacity-50",
6989
- children: /* @__PURE__ */ jsxRuntime.jsx(Text, { value: "Clear", weight: "semibold", color: "danger" })
6990
- }
6991
- )
6992
- ] }),
6993
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3", children: files.map((item, i) => /* @__PURE__ */ jsxRuntime.jsx(
6994
- PreviewItem,
6995
- {
6996
- data: item,
6997
- audioPlayerProps,
6998
- pdfViewerProps,
6999
- videoPlayerProps,
7000
- onRemove: () => removeFile(i),
7001
- onReplace: () => triggerReplace(i),
7002
- labelCustomName: item?.label,
7003
- customNamePlaceholder,
7004
- onCustomNameChange: useCustomName !== void 0 ? (e) => handleChangeCustomName?.({ e, i }) : void 0,
7005
- customName: customNames[i] ?? item.customName ?? item.file.name,
7006
- disabled
7007
- },
7008
- item?.id
7009
- )) })
7010
- ] })
7011
- ] });
7012
- }
7013
- );
7014
- InputFile.displayName = "InputFile";
7015
- classVarianceAuthority.cva("", {
7016
- variants: {
7017
- size: {
7018
- sm: "px-0 text-xs",
7019
- md: "text-md",
7020
- lg: "text-lg"
7021
- },
7022
- controlIconSize: {
7023
- sm: "size-[10px]",
7024
- md: "size-[14px]",
7025
- lg: "size-[16px]"
7026
- },
7027
- height: {
7028
- sm: "h-[22px]",
7029
- md: "h-[30px]",
7030
- lg: "h-[40px]"
7031
- },
7032
- variant: {
7033
- primary: "border-0",
7034
- secondary: "border border-gray-500"
7035
- }
7036
- },
7037
- defaultVariants: {
7038
- size: "md"
7039
- }
7040
- });
7041
- function Dropdown({
7042
- children,
7043
- ...props
7044
- }) {
7045
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Root, { ...props, children });
7046
- }
7047
- function DropdownTrigger({
7048
- children,
7049
- ...props
7050
- }) {
7051
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Trigger, { ...props, children });
7052
- }
7053
- function DropdownContent({
7054
- children,
7055
- className,
7056
- portalProps,
7057
- ...props
7058
- }) {
7059
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Portal, { ...portalProps, children: /* @__PURE__ */ jsxRuntime.jsx(
7060
- DropdownMenu__namespace.Content,
7061
- {
7062
- sideOffset: props.sideOffset ?? 15,
7063
- className: cn(
7064
- "shadow-dropdown flex flex-col gap-1 rounded-xl border border-gray-200 bg-white p-3",
7065
- className
7066
- ),
7067
- ...props,
7068
- children
7069
- }
7070
- ) });
7071
- }
7072
- function DropdownItem({
7073
- children,
7074
- className,
7075
- ...props
7076
- }) {
7077
- return /* @__PURE__ */ jsxRuntime.jsx(
7078
- DropdownMenu__namespace.Item,
7079
- {
7080
- className: cn(
7081
- "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",
7082
- className
7083
- ),
7084
- ...props,
7085
- children
7086
- }
7087
- );
7088
- }
7089
- classVarianceAuthority.cva("", {
7090
- variants: {
7091
- tableRow: {
7092
- "basic": "",
7093
- "bordered": "",
7094
- "stripped": "",
7095
- "hovered": "",
7096
- "row-bordered": "border-y border-gray-300",
7097
- "wrapped-row-bordered": "border-y border-gray-300",
7098
- "headed": ""
7099
- }
7100
- }
7101
- });
7102
- React283.createContext({});
7103
- React283.createContext({});
7104
-
7105
- // src/components/date-picker/helpers.ts
7106
- function formatDateLocal(date) {
7107
- const y = date.getFullYear();
7108
- const m = String(date.getMonth() + 1).padStart(2, "0");
7109
- const d = String(date.getDate()).padStart(2, "0");
7110
- return `${y}-${m}-${d}`;
7111
- }
7112
- classVarianceAuthority.cva(
7113
- "relative inline-flex shrink-0 rounded-full transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",
5939
+ "inline-flex cursor-pointer items-center justify-center rounded-lg border transition-all duration-200",
7114
5940
  {
7115
5941
  variants: {
7116
5942
  size: {
7117
- sm: "h-5 w-9",
7118
- md: "h-6 w-11",
7119
- lg: "h-7 w-14"
5943
+ sm: "p-1.5 text-xs",
5944
+ md: "p-2 text-sm",
5945
+ lg: "px-3 py-2 text-base"
7120
5946
  },
7121
5947
  color: {
7122
- primary: "data-[state=checked]:bg-primary-1000 focus-visible:ring-primary-900",
7123
- secondary: "focus-visible:ring-gray-500 data-[state=checked]:bg-gray-600",
7124
- success: "data-[state=checked]:bg-success-500 focus-visible:ring-success-400",
7125
- danger: "data-[state=checked]:bg-danger-500 focus-visible:ring-danger-400",
7126
- warning: "data-[state=checked]:bg-warning-500 focus-visible:ring-warning-400",
7127
- info: "data-[state=checked]:bg-info-500 focus-visible:ring-info-400",
7128
- orange: "focus-visible:ring-orange-400 data-[state=checked]:bg-orange-500",
7129
- purple: "focus-visible:ring-purple-400 data-[state=checked]:bg-purple-500",
7130
- gray: "focus-visible:ring-gray-600 data-[state=checked]:bg-gray-700"
5948
+ primary: "",
5949
+ success: "",
5950
+ danger: "",
5951
+ warning: "",
5952
+ info: "",
5953
+ purple: "",
5954
+ orange: "",
5955
+ gray: ""
5956
+ },
5957
+ state: {
5958
+ default: "",
5959
+ selected: "",
5960
+ disabled: ""
5961
+ },
5962
+ block: {
5963
+ true: "w-full",
5964
+ false: ""
7131
5965
  }
7132
5966
  },
7133
- defaultVariants: {
7134
- size: "md",
7135
- color: "primary"
7136
- }
7137
- }
7138
- );
7139
- classVarianceAuthority.cva(
7140
- "pointer-events-none absolute top-0.5 inline-block rounded-full bg-white shadow-lg ring-0 transition-transform",
7141
- {
7142
- variants: {
7143
- size: {
7144
- sm: "h-4 w-4 data-[state=checked]:translate-x-4.5 data-[state=unchecked]:translate-x-0.5",
7145
- md: "h-5 w-5 data-[state=checked]:translate-x-5.5 data-[state=unchecked]:translate-x-0.5",
7146
- lg: "h-6 w-6 data-[state=checked]:translate-x-7.5 data-[state=unchecked]:translate-x-0.5"
5967
+ compoundVariants: [
5968
+ // Default color variants
5969
+ {
5970
+ color: "gray",
5971
+ state: "default",
5972
+ className: "border-gray-00 bg-white text-gray-700 hover:bg-gray-100"
5973
+ },
5974
+ {
5975
+ color: "gray",
5976
+ state: "selected",
5977
+ className: "border-gray-400 bg-gray-200 text-gray-800"
5978
+ },
5979
+ {
5980
+ color: "gray",
5981
+ state: "disabled",
5982
+ className: "cursor-not-allowed border-gray-200 bg-gray-100 text-gray-400"
5983
+ },
5984
+ // Primary color variants
5985
+ {
5986
+ color: "primary",
5987
+ state: "default",
5988
+ className: "border-primary-200 text-primary-1000 hover:bg-primary-50 bg-white"
5989
+ },
5990
+ {
5991
+ color: "primary",
5992
+ state: "selected",
5993
+ className: "bg-primary-50 border-primary-200 text-primary-1000"
5994
+ },
5995
+ {
5996
+ color: "primary",
5997
+ state: "disabled",
5998
+ className: "bg-primary-100 border-primary-200 text-primary-300 cursor-not-allowed"
5999
+ },
6000
+ // Success color variants
6001
+ {
6002
+ color: "success",
6003
+ state: "default",
6004
+ className: "border-success-300 text-success-500 hover:bg-success-50 bg-white"
6005
+ },
6006
+ {
6007
+ color: "success",
6008
+ state: "selected",
6009
+ className: "bg-success-100 border-success-200 text-success-500"
6010
+ },
6011
+ {
6012
+ color: "success",
6013
+ state: "disabled",
6014
+ className: "bg-success-100 border-success-200 text-success-300 cursor-not-allowed"
6015
+ },
6016
+ // Danger color variants
6017
+ {
6018
+ color: "danger",
6019
+ state: "default",
6020
+ className: "border-danger-200 text-danger-500 hover:bg-danger-50 bg-white"
6021
+ },
6022
+ {
6023
+ color: "danger",
6024
+ state: "selected",
6025
+ className: "bg-danger-100 border-danger-200 text-danger-500"
6026
+ },
6027
+ {
6028
+ color: "danger",
6029
+ state: "disabled",
6030
+ className: "bg-danger-100 border-danger-200 text-danger-300 cursor-not-allowed"
6031
+ },
6032
+ // Warning color variants
6033
+ {
6034
+ color: "warning",
6035
+ state: "default",
6036
+ className: "border-warning-300 text-warning-400 hover:bg-warning-50 bg-white"
6037
+ },
6038
+ {
6039
+ color: "warning",
6040
+ state: "selected",
6041
+ className: "bg-warning-100 border-warning-300 text-warning-500"
6042
+ },
6043
+ {
6044
+ color: "warning",
6045
+ state: "disabled",
6046
+ className: "bg-warning-100 border-warning-200 text-warning-300 cursor-not-allowed"
6047
+ },
6048
+ // Info color variants
6049
+ {
6050
+ color: "info",
6051
+ state: "default",
6052
+ className: "border-info-200 text-info-500 hover:bg-info-50 bg-white"
6053
+ },
6054
+ {
6055
+ color: "info",
6056
+ state: "selected",
6057
+ className: "bg-info-100 border-info-200 text-info-500"
6058
+ },
6059
+ {
6060
+ color: "info",
6061
+ state: "disabled",
6062
+ className: "bg-info-100 border-info-200 text-info-300 cursor-not-allowed"
6063
+ },
6064
+ // Purple color variants
6065
+ {
6066
+ color: "purple",
6067
+ state: "default",
6068
+ className: "border-purple-200 bg-white text-purple-500 hover:bg-purple-50"
6069
+ },
6070
+ {
6071
+ color: "purple",
6072
+ state: "selected",
6073
+ className: "border-purple-200 bg-purple-100 text-purple-500"
6074
+ },
6075
+ {
6076
+ color: "purple",
6077
+ state: "disabled",
6078
+ className: "cursor-not-allowed border-purple-200 bg-purple-100 text-purple-300"
6079
+ },
6080
+ // Orange color variants
6081
+ {
6082
+ color: "orange",
6083
+ state: "default",
6084
+ className: "border-orange-200 bg-white text-orange-500 hover:bg-orange-50"
6085
+ },
6086
+ {
6087
+ color: "orange",
6088
+ state: "selected",
6089
+ className: "border-orange-200 bg-orange-100 text-orange-500"
6090
+ },
6091
+ {
6092
+ color: "orange",
6093
+ state: "disabled",
6094
+ className: "cursor-not-allowed border-orange-200 bg-orange-100 text-orange-300"
7147
6095
  }
7148
- },
6096
+ ],
7149
6097
  defaultVariants: {
7150
- size: "md"
6098
+ size: "md",
6099
+ color: "primary",
6100
+ state: "default",
6101
+ block: false
7151
6102
  }
7152
6103
  }
7153
6104
  );
7154
- classVarianceAuthority.cva("", {
7155
- variants: {
7156
- bg: {
7157
- danger: "bg-danger-50",
7158
- gray: "bg-gray-400",
7159
- info: "bg-info-50",
7160
- orange: "bg-orange-50",
7161
- primary: "bg-primary-1000",
7162
- success: "bg-success-50",
7163
- purple: "bg-purple-50",
7164
- secondary: "bg-white",
7165
- warning: "bg-warning-50"
7166
- },
7167
- text: {
7168
- danger: "text-danger-500",
7169
- gray: "text-gray-700",
7170
- info: "text-info-500",
7171
- orange: "text-orange-500",
7172
- primary: "text-white",
7173
- success: "text-success-500",
7174
- purple: "text-purple-500",
7175
- secondary: "text-primary-1000",
7176
- warning: "text-warning-500"
7177
- }
7178
- }
7179
- });
7180
- React283.createContext(null);
7181
- React283.createContext(void 0);
7182
- React283.createContext(null);
7183
- function ButtonMore({ count, onClick }) {
7184
- return /* @__PURE__ */ jsxRuntime.jsx(
7185
- "button",
7186
- {
7187
- type: "button",
7188
- onClick,
7189
- className: "h-full w-full cursor-pointer px-1 transition-colors hover:bg-gray-50",
7190
- title: `+${count} more`,
7191
- children: /* @__PURE__ */ jsxRuntime.jsxs(Text, { weight: "medium", className: "line-clamp-1 text-gray-700", children: [
7192
- "+",
7193
- count,
7194
- " more"
7195
- ] })
7196
- }
7197
- );
7198
- }
6105
+ React280.createContext(null);
7199
6106
 
7200
6107
  // src/components/calendar/helpers/create-date-style-helpers.ts
7201
6108
  function createDateStyleHelpers({
@@ -7272,6 +6179,59 @@ function createDateStyleHelpers({
7272
6179
  };
7273
6180
  return { getBackgroundClass, getTextColorClass, getCursorClass, getDayStyle };
7274
6181
  }
6182
+ function TooltipProvider({
6183
+ delayDuration = 0,
6184
+ ...props
6185
+ }) {
6186
+ return /* @__PURE__ */ jsxRuntime.jsx(
6187
+ TooltipPrimitive__namespace.Provider,
6188
+ {
6189
+ "data-slot": "tooltip-provider",
6190
+ delayDuration,
6191
+ ...props
6192
+ }
6193
+ );
6194
+ }
6195
+ function Tooltip({
6196
+ ...props
6197
+ }) {
6198
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Root, { "data-slot": "tooltip", ...props }) });
6199
+ }
6200
+ function TooltipTrigger({
6201
+ ...props
6202
+ }) {
6203
+ return /* @__PURE__ */ jsxRuntime.jsx(
6204
+ TooltipPrimitive__namespace.Trigger,
6205
+ {
6206
+ "data-slot": "tooltip-trigger",
6207
+ type: "button",
6208
+ ...props
6209
+ }
6210
+ );
6211
+ }
6212
+ function TooltipContent({
6213
+ className,
6214
+ sideOffset = 0,
6215
+ children,
6216
+ ...props
6217
+ }) {
6218
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
6219
+ TooltipPrimitive__namespace.Content,
6220
+ {
6221
+ "data-slot": "tooltip-content",
6222
+ sideOffset,
6223
+ className: cn(
6224
+ "text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md bg-gray-900 px-3 py-1.5 text-xs text-balance text-white",
6225
+ className
6226
+ ),
6227
+ ...props,
6228
+ children: [
6229
+ children,
6230
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Arrow, { className: "z-50 size-2.5 -translate-y-1 rounded-xs bg-transparent fill-gray-900" })
6231
+ ]
6232
+ }
6233
+ ) });
6234
+ }
7275
6235
  var date_size_map = {
7276
6236
  md: "size-7.5",
7277
6237
  sm: "size-6",
@@ -7314,7 +6274,7 @@ function CalendarDayItem({
7314
6274
  style: styleHelpers.getDayStyle(),
7315
6275
  onClick: () => onClick(day),
7316
6276
  disabled: isDisabled && isCurrentMonth,
7317
- className: clsx10__default.default(
6277
+ className: clsx5__default.default(
7318
6278
  date_size_map[size ?? "md"],
7319
6279
  styleHelpers.getCursorClass(),
7320
6280
  styleHelpers.getTextColorClass(),
@@ -7336,7 +6296,7 @@ function CalendarDayItem({
7336
6296
  /* @__PURE__ */ jsxRuntime.jsx(
7337
6297
  "h5",
7338
6298
  {
7339
- className: clsx10__default.default(
6299
+ className: clsx5__default.default(
7340
6300
  "font-metropolis text-xs transition-colors",
7341
6301
  variant === "default" && "grid size-8 place-items-center justify-center rounded-full",
7342
6302
  //prettier-ignore
@@ -7376,8 +6336,8 @@ function EventBar({
7376
6336
  showTooltip = true,
7377
6337
  onClick
7378
6338
  }) {
7379
- const [hovered, setHovered] = React283.useState(false);
7380
- const [pos, setPos] = React283.useState({ x: 0, y: 0 });
6339
+ const [hovered, setHovered] = React280.useState(false);
6340
+ const [pos, setPos] = React280.useState({ x: 0, y: 0 });
7381
6341
  const handleMouseMove = (e) => {
7382
6342
  setPos({
7383
6343
  x: e.clientX,
@@ -7411,7 +6371,7 @@ function EventBar({
7411
6371
  onMouseEnter: () => setHovered(true),
7412
6372
  onMouseLeave: () => setHovered(false),
7413
6373
  onMouseMove: handleMouseMove,
7414
- className: clsx10__default.default(
6374
+ className: clsx5__default.default(
7415
6375
  "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",
7416
6376
  onClick && "cursor-pointer"
7417
6377
  ),
@@ -7458,13 +6418,27 @@ function EventBar({
7458
6418
  }
7459
6419
  }
7460
6420
  ),
7461
- /* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "t3", className: clsx10__default.default("text-gray-800"), children: segment.event.label })
6421
+ /* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "t3", className: clsx5__default.default("text-gray-800"), children: segment.event.label })
7462
6422
  ] })
7463
6423
  ] })
7464
6424
  }
7465
6425
  )
7466
6426
  ] });
7467
6427
  }
6428
+ var MOBILE_BREAKPOINT = 768;
6429
+ function useIsMobile() {
6430
+ const [isMobile, setIsMobile] = React280__namespace.useState(false);
6431
+ React280__namespace.useEffect(() => {
6432
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
6433
+ const onChange = () => {
6434
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
6435
+ };
6436
+ mql.addEventListener("change", onChange);
6437
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
6438
+ return () => mql.removeEventListener("change", onChange);
6439
+ }, []);
6440
+ return !!isMobile;
6441
+ }
7468
6442
  function CalendarGrid({
7469
6443
  days: days2,
7470
6444
  helpers,
@@ -7487,7 +6461,7 @@ function CalendarGrid({
7487
6461
  return /* @__PURE__ */ jsxRuntime.jsx(
7488
6462
  "div",
7489
6463
  {
7490
- className: clsx10__default.default(
6464
+ className: clsx5__default.default(
7491
6465
  "relative",
7492
6466
  variant === "compact" && size === "sm" && "space-y-1"
7493
6467
  ),
@@ -7578,7 +6552,7 @@ function CalendarGrid({
7578
6552
  return /* @__PURE__ */ jsxRuntime.jsxs(
7579
6553
  "div",
7580
6554
  {
7581
- className: clsx10__default.default(
6555
+ className: clsx5__default.default(
7582
6556
  "relative",
7583
6557
  variant === "default" && "border-b border-gray-300 last:border-b-0!",
7584
6558
  //prettier-ignore
@@ -7588,7 +6562,7 @@ function CalendarGrid({
7588
6562
  /* @__PURE__ */ jsxRuntime.jsx(
7589
6563
  "div",
7590
6564
  {
7591
- className: clsx10__default.default(
6565
+ className: clsx5__default.default(
7592
6566
  "grid w-full grid-cols-7",
7593
6567
  variant === "default" && "*:border-r *:border-gray-300 [&>*:nth-last-child(1)]:border-r-0",
7594
6568
  //prettier-ignore
@@ -7732,7 +6706,7 @@ function CalendarHeader({
7732
6706
  showPrevNavigator
7733
6707
  }) {
7734
6708
  const { currentMonth, currentYear } = calendar;
7735
- const years = React283.useMemo(() => {
6709
+ const years = React280.useMemo(() => {
7736
6710
  const yearRange = [];
7737
6711
  for (let i = currentYear - 100; i <= currentYear + 100; i++) {
7738
6712
  yearRange.push(i);
@@ -7857,7 +6831,7 @@ function DaysOfWeek({
7857
6831
  return /* @__PURE__ */ jsxRuntime.jsxs(
7858
6832
  "div",
7859
6833
  {
7860
- className: clsx10__default.default(
6834
+ className: clsx5__default.default(
7861
6835
  "grid justify-items-center",
7862
6836
  variant === "compact" && "calendar-cols mb-3 gap-x-1 *:text-center!",
7863
6837
  variant === "default" && "w-full bg-gray-100 *:p-3 *:w-full *:text-start! *:border-r *:border-gray-300 *:last:border-r-0",
@@ -7878,7 +6852,7 @@ function DaysOfWeek({
7878
6852
  as: "h5",
7879
6853
  weight: variant === "compact" ? "medium" : "semibold",
7880
6854
  value: day,
7881
- className: clsx10__default.default(
6855
+ className: clsx5__default.default(
7882
6856
  variant === "compact" && "text-gray-600!",
7883
6857
  variant === "default" && "text-gray-900! uppercase"
7884
6858
  ),
@@ -7961,15 +6935,15 @@ var Calendar2 = ({
7961
6935
  showDefaultController = false
7962
6936
  }) => {
7963
6937
  const currentDate = /* @__PURE__ */ new Date();
7964
- const [currentMonth, setCurrentMonth] = React283.useState(defaultMonth ?? currentDate.getMonth());
7965
- const [currentYear, setCurrentYear] = React283.useState(defaultYear ?? currentDate.getFullYear());
7966
- const [isDropdownYearShow, setIsDropdownYearShow] = React283.useState(false);
7967
- const [isDropdownMonthShow, setIsDropdownMonthShow] = React283.useState(false);
7968
- const [selectedType, setSelectedType] = React283.useState(type);
7969
- const [selectedTypeIndex, setSelectedTypeIndex] = React283.useState(
6938
+ const [currentMonth, setCurrentMonth] = React280.useState(defaultMonth ?? currentDate.getMonth());
6939
+ const [currentYear, setCurrentYear] = React280.useState(defaultYear ?? currentDate.getFullYear());
6940
+ const [isDropdownYearShow, setIsDropdownYearShow] = React280.useState(false);
6941
+ const [isDropdownMonthShow, setIsDropdownMonthShow] = React280.useState(false);
6942
+ const [selectedType, setSelectedType] = React280.useState(type);
6943
+ const [selectedTypeIndex, setSelectedTypeIndex] = React280.useState(
7970
6944
  null
7971
6945
  );
7972
- const [currentWeekStart, setCurrentWeekStart] = React283.useState(() => {
6946
+ const [currentWeekStart, setCurrentWeekStart] = React280.useState(() => {
7973
6947
  const today = /* @__PURE__ */ new Date();
7974
6948
  const day = today.getDay();
7975
6949
  const start = new Date(today);
@@ -8054,7 +7028,7 @@ var Calendar2 = ({
8054
7028
  }
8055
7029
  }
8056
7030
  };
8057
- React283.useEffect(() => {
7031
+ React280.useEffect(() => {
8058
7032
  if (value !== void 0) {
8059
7033
  setCurrentMonth(
8060
7034
  value?.getMonth() ?? defaultMonth ?? currentDate?.getMonth()
@@ -8064,12 +7038,12 @@ var Calendar2 = ({
8064
7038
  );
8065
7039
  }
8066
7040
  }, [value]);
8067
- React283.useEffect(() => {
7041
+ React280.useEffect(() => {
8068
7042
  if (type !== void 0) {
8069
7043
  setSelectedType(type);
8070
7044
  }
8071
7045
  }, [type]);
8072
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx10__default.default(variant === "default" && "flex flex-col gap-2"), children: [
7046
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx5__default.default(variant === "default" && "flex flex-col gap-2"), children: [
8073
7047
  variant === "default" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
8074
7048
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-6", children: [
8075
7049
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "*:cursor-pointer", children: [
@@ -8142,7 +7116,7 @@ var Calendar2 = ({
8142
7116
  setSelectedType(option.value);
8143
7117
  onTypeChange?.(option.value);
8144
7118
  },
8145
- className: clsx10__default.default(
7119
+ className: clsx5__default.default(
8146
7120
  (selectedType === option.value || index === selectedTypeIndex) && "bg-primary-50!"
8147
7121
  ),
8148
7122
  children: /* @__PURE__ */ jsxRuntime.jsx(Text, { className: "text-gray-900", children: option.label })