@bigstack-oss/cube-ui 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { omit } from 'lodash';
2
- import { twMerge } from 'tailwind-merge';
2
+ import { twMerge, twJoin } from 'tailwind-merge';
3
3
  import { cva } from 'class-variance-authority';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
- import { forwardRef, useId, cloneElement, useState, useEffect } from 'react';
5
+ import { forwardRef, useId, cloneElement, useState, useEffect, createElement, useRef } from 'react';
6
6
  import i18next from 'i18next';
7
7
  import { initReactI18next, useTranslation } from 'react-i18next';
8
8
  import defaultTheme from 'tailwindcss/defaultTheme';
@@ -274,12 +274,12 @@ var getIconClasses = (size, classNameProps) => {
274
274
 
275
275
  // src/components/CubeButton/cubeButtonUtils.ts
276
276
  var getIconSizeByButtonSize = (size) => {
277
- const sizeMapping = {
277
+ const sizeMapping2 = {
278
278
  sm: "md-sm",
279
279
  md: "md",
280
280
  lg: "md"
281
281
  };
282
- const iconSize = sizeMapping[size];
282
+ const iconSize = sizeMapping2[size];
283
283
  return getIconSizeClass(iconSize);
284
284
  };
285
285
  var CubeLeft = (props) => {
@@ -474,6 +474,23 @@ var CubeButtonLoadingSpinner = (props) => {
474
474
  }
475
475
  );
476
476
  };
477
+ var CubeSkeleton = (props) => {
478
+ const { className, style } = props;
479
+ return /* @__PURE__ */ jsx(
480
+ "div",
481
+ {
482
+ className: twMerge(
483
+ "cube-skeleton animate-cube-skeleton rounded-[5px]",
484
+ className
485
+ ),
486
+ style
487
+ }
488
+ );
489
+ };
490
+ var CubeButtonSkeleton = (props) => {
491
+ const { size = "md", usage = "text-only" } = props;
492
+ return /* @__PURE__ */ jsx(CubeSkeleton, { className: twMerge(buttonSkeleton({ size, usage })) });
493
+ };
477
494
  var CubeButton = (props) => {
478
495
  const {
479
496
  htmlType = "button",
@@ -527,30 +544,58 @@ var CubeButton = (props) => {
527
544
  }
528
545
  );
529
546
  };
530
- var CubeSkeleton = (props) => {
531
- const { className, style } = props;
532
- return /* @__PURE__ */ jsx(
533
- "div",
534
- {
535
- className: twMerge(
536
- "cube-skeleton animate-cube-skeleton rounded-[5px]",
537
- className
538
- ),
539
- style
540
- }
541
- );
542
- };
543
- var CubeButtonSkeleton = (props) => {
544
- const { size = "md", usage = "text-only" } = props;
545
- return /* @__PURE__ */ jsx(CubeSkeleton, { className: twMerge(buttonSkeleton({ size, usage })) });
546
- };
547
- var CubeIconFrame = (props) => {
548
- const { className: classNameProps, size = "md", children, onClick } = props;
549
- const containerClasses = getContainerClasses(size, classNameProps);
550
- const iconClasses = getIconClasses(size, children.props.className);
551
- const icon = cloneElement(children, { className: iconClasses });
552
- return /* @__PURE__ */ jsx("div", { className: containerClasses, onClick, children: icon });
553
- };
547
+ CubeButton.Skeleton = CubeButtonSkeleton;
548
+ var SvgCheckbox = ({
549
+ title,
550
+ titleId,
551
+ ...props
552
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
553
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
554
+ /* @__PURE__ */ jsx("path", { stroke: "currentColor", strokeWidth: 1.2, d: "M2 4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2z" })
555
+ ] });
556
+ var ForwardRef = forwardRef(SvgCheckbox);
557
+ var Checkbox_default = ForwardRef;
558
+ var SvgCheckboxCheckedFilled = ({
559
+ title,
560
+ titleId,
561
+ ...props
562
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
563
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
564
+ /* @__PURE__ */ jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M3.6 1.6a2 2 0 0 0-2 2v8.8a2 2 0 0 0 2 2h8.8a2 2 0 0 0 2-2V3.6a2 2 0 0 0-2-2zm7.796 4.824a.74.74 0 0 0-1.08-1.013L7.151 8.785 5.471 6.991a.74.74 0 1 0-1.08 1.013l2.22 2.37a.74.74 0 0 0 1.082 0z", clipRule: "evenodd" })
565
+ ] });
566
+ var ForwardRef2 = forwardRef(SvgCheckboxCheckedFilled);
567
+ var CheckboxCheckedFilled_default = ForwardRef2;
568
+ var SvgCheckboxUndeterminateFilled = ({
569
+ title,
570
+ titleId,
571
+ ...props
572
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
573
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
574
+ /* @__PURE__ */ jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M3.6 1.6a2 2 0 0 0-2 2v8.8a2 2 0 0 0 2 2h8.8a2 2 0 0 0 2-2V3.6a2 2 0 0 0-2-2zm1.9 5.65a.75.75 0 0 0 0 1.5h5a.75.75 0 0 0 0-1.5z", clipRule: "evenodd" })
575
+ ] });
576
+ var ForwardRef3 = forwardRef(SvgCheckboxUndeterminateFilled);
577
+ var CheckboxUndeterminateFilled_default = ForwardRef3;
578
+ var SvgRadioButton = ({
579
+ title,
580
+ titleId,
581
+ ...props
582
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
583
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
584
+ /* @__PURE__ */ jsx("circle", { cx: 8, cy: 8, r: 6.5, stroke: "currentColor", strokeWidth: 1.2 })
585
+ ] });
586
+ var ForwardRef4 = forwardRef(SvgRadioButton);
587
+ var RadioButton_default = ForwardRef4;
588
+ var SvgRadioButtonFilled = ({
589
+ title,
590
+ titleId,
591
+ ...props
592
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
593
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
594
+ /* @__PURE__ */ jsx("circle", { cx: 8, cy: 8, r: 6.5, stroke: "currentColor", strokeWidth: 1.2 }),
595
+ /* @__PURE__ */ jsx("path", { fill: "currentColor", d: "M8 13A5 5 0 1 0 8 3a5 5 0 0 0 0 10" })
596
+ ] });
597
+ var ForwardRef5 = forwardRef(SvgRadioButtonFilled);
598
+ var RadioButtonFilled_default = ForwardRef5;
554
599
  var SvgView = ({
555
600
  title,
556
601
  titleId,
@@ -559,8 +604,8 @@ var SvgView = ({
559
604
  title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
560
605
  /* @__PURE__ */ jsx("path", { fill: "currentColor", d: "m1.5 8-.58-.154a.6.6 0 0 0 0 .308zm13 0 .58.154a.6.6 0 0 0 0-.308zM9.718 8c0 .95-.77 1.721-1.721 1.721v1.2A2.92 2.92 0 0 0 10.918 8zM7.997 9.721c-.951 0-1.722-.77-1.722-1.721h-1.2a2.92 2.92 0 0 0 2.922 2.921zM6.275 8c0-.95.771-1.721 1.722-1.721v-1.2A2.92 2.92 0 0 0 5.075 8zm1.722-1.721c.95 0 1.721.77 1.721 1.721h1.2a2.92 2.92 0 0 0-2.921-2.921zm0-3.522C4.122 2.757 1.6 5.276.92 7.847l1.16.307c.549-2.073 2.615-4.197 5.917-4.197zM.92 8.154c.68 2.57 3.202 5.089 7.08 5.089v-1.2c-3.305 0-5.371-2.125-5.92-4.197zM8 13.243c3.878 0 6.396-2.519 7.08-5.089l-1.16-.308c-.552 2.073-2.615 4.197-5.92 4.197zm7.08-5.397c-.685-2.57-3.209-5.089-7.083-5.089v1.2c3.302 0 5.371 2.125 5.923 4.197z" })
561
606
  ] });
562
- var ForwardRef = forwardRef(SvgView);
563
- var View_default = ForwardRef;
607
+ var ForwardRef6 = forwardRef(SvgView);
608
+ var View_default = ForwardRef6;
564
609
  var SvgViewOff = ({
565
610
  title,
566
611
  titleId,
@@ -569,8 +614,8 @@ var SvgViewOff = ({
569
614
  title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
570
615
  /* @__PURE__ */ jsx("path", { stroke: "currentColor", strokeLinecap: "round", strokeWidth: 1.2, d: "M5.675 8.143A2.32 2.32 0 0 1 7.997 5.82M6.41 9.838a2.321 2.321 0 0 0 3.322-3.237M11.715 4.5c1.464.893 2.419 2.268 2.785 3.643-.618 2.321-2.908 4.643-6.5 4.643-1.424 0-2.643-.365-3.635-.95M3 10.76a6.04 6.04 0 0 1-1.5-2.617C2.115 5.82 4.408 3.5 7.997 3.5c.761 0 1.464.105 2.106.291M14.2 2l-12 12" })
571
616
  ] });
572
- var ForwardRef2 = forwardRef(SvgViewOff);
573
- var ViewOff_default = ForwardRef2;
617
+ var ForwardRef7 = forwardRef(SvgViewOff);
618
+ var ViewOff_default = ForwardRef7;
574
619
  var SvgWarningFilled = ({
575
620
  title,
576
621
  titleId,
@@ -579,8 +624,355 @@ var SvgWarningFilled = ({
579
624
  title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
580
625
  /* @__PURE__ */ jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M8.1 15.2A7.1 7.1 0 1 0 8.1 1a7.1 7.1 0 0 0 0 14.2m.9-4.1a.9.9 0 1 1-1.8 0 .9.9 0 0 1 1.8 0M7.5 8.5a.6.6 0 0 0 1.2 0v-4a.6.6 0 1 0-1.2 0z", clipRule: "evenodd" })
581
626
  ] });
582
- var ForwardRef3 = forwardRef(SvgWarningFilled);
583
- var WarningFilled_default = ForwardRef3;
627
+ var ForwardRef8 = forwardRef(SvgWarningFilled);
628
+ var WarningFilled_default = ForwardRef8;
629
+ var SvgX = ({
630
+ title,
631
+ titleId,
632
+ ...props
633
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
634
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
635
+ /* @__PURE__ */ jsx("path", { stroke: "currentColor", strokeLinecap: "round", strokeWidth: 1.2, d: "m12.5 3.5-9 9m9 0-9-9" })
636
+ ] });
637
+ var ForwardRef9 = forwardRef(SvgX);
638
+ var X_default = ForwardRef9;
639
+ var container = cva(
640
+ "inline-flex w-fit cursor-pointer items-start gap-x-2",
641
+ {
642
+ variants: {
643
+ labelSize: {
644
+ md: "primary-body2",
645
+ sm: "primary-body3",
646
+ xs: "primary-body4"
647
+ },
648
+ disabled: {
649
+ true: "cursor-default"
650
+ }
651
+ }
652
+ }
653
+ );
654
+ var iconWrap = cva("shrink-0 p-0.5 transition-colors duration-100", {
655
+ variants: {
656
+ color: {},
657
+ isSelected: {
658
+ true: ""
659
+ },
660
+ disabled: {
661
+ true: ""
662
+ }
663
+ },
664
+ compoundVariants: [
665
+ /** Primary */
666
+ {
667
+ color: "primary",
668
+ isSelected: false,
669
+ className: "text-functional-border-darker peer-hover:text-functional-hover-primary"
670
+ },
671
+ {
672
+ color: "primary",
673
+ isSelected: true,
674
+ className: "text-primary peer-hover:text-functional-hover-primary"
675
+ },
676
+ {
677
+ color: "primary",
678
+ disabled: true,
679
+ className: "text-functional-disable-text peer-hover:text-functional-disable-text"
680
+ },
681
+ /** Primary (dark) */
682
+ {
683
+ color: "primary-dark",
684
+ isSelected: false,
685
+ className: "text-functional-text peer-hover:text-functional-hover-primary"
686
+ },
687
+ {
688
+ color: "primary-dark",
689
+ isSelected: true,
690
+ className: "text-primary-700 peer-hover:text-primary-500"
691
+ },
692
+ {
693
+ color: "primary-dark",
694
+ disabled: true,
695
+ className: "text-functional-disable-text peer-hover:text-functional-disable-text"
696
+ },
697
+ /** Secondary */
698
+ {
699
+ color: "secondary",
700
+ isSelected: false,
701
+ className: "text-functional-border-darker peer-hover:text-blue-700"
702
+ },
703
+ {
704
+ color: "secondary",
705
+ isSelected: true,
706
+ className: "text-blue-600 peer-hover:text-blue-700"
707
+ },
708
+ {
709
+ color: "secondary",
710
+ disabled: true,
711
+ className: "text-functional-disable-text peer-hover:text-functional-disable-text"
712
+ },
713
+ /** Secondary (dark) */
714
+ {
715
+ color: "secondary-dark",
716
+ isSelected: false,
717
+ className: "text-functional-text peer-hover:text-blue-600"
718
+ },
719
+ {
720
+ color: "secondary-dark",
721
+ isSelected: true,
722
+ className: "text-blue-700 peer-hover:text-blue-600"
723
+ },
724
+ {
725
+ color: "secondary-dark",
726
+ disabled: true,
727
+ className: "text-functional-disable-text peer-hover:text-functional-disable-text"
728
+ }
729
+ ]
730
+ });
731
+ var label = cva("max-w-[152px] break-words text-functional-text", {
732
+ variants: {
733
+ color: {},
734
+ disabled: {
735
+ true: "text-functional-disable-text"
736
+ }
737
+ },
738
+ compoundVariants: [
739
+ {
740
+ color: "primary",
741
+ disabled: false,
742
+ className: "text-functional-text"
743
+ },
744
+ {
745
+ color: "primary",
746
+ disabled: true,
747
+ className: "text-functional-disable-text"
748
+ },
749
+ {
750
+ color: "primary-dark",
751
+ disabled: false,
752
+ className: "font-semibold text-functional-text"
753
+ },
754
+ {
755
+ color: "primary-dark",
756
+ disabled: true,
757
+ className: "font-semibold text-functional-disable-text"
758
+ },
759
+ {
760
+ color: "secondary",
761
+ disabled: false,
762
+ className: "text-functional-text"
763
+ },
764
+ {
765
+ color: "secondary",
766
+ disabled: true,
767
+ className: "text-functional-disable-text"
768
+ },
769
+ {
770
+ color: "secondary-dark",
771
+ disabled: false,
772
+ className: "font-semibold text-functional-text"
773
+ },
774
+ {
775
+ color: "secondary-dark",
776
+ disabled: true,
777
+ className: "font-semibold text-functional-disable-text"
778
+ }
779
+ ]
780
+ });
781
+ var CubeCheckboxSkeleton = () => /* @__PURE__ */ jsxs("div", { className: "inline-flex gap-x-2", children: [
782
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "size-5" }),
783
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "h-5 w-[152px]" })
784
+ ] });
785
+ var CubeCheckboxGrid = (props) => {
786
+ const { children, className: classNameProp, direction } = props;
787
+ const className = twMerge(
788
+ direction === "vertical" ? "flex flex-col gap-y-3" : "grid grid-cols-[repeat(auto-fill,180px)] gap-x-4 gap-y-6",
789
+ classNameProp
790
+ );
791
+ return /* @__PURE__ */ jsx("div", { className, children });
792
+ };
793
+ var CubeCheckbox = (props) => {
794
+ const {
795
+ containerClassName,
796
+ color = "primary",
797
+ label: label4,
798
+ labelSize = "md",
799
+ labelClassName,
800
+ id,
801
+ defaultChecked = false,
802
+ checked: controlledChecked,
803
+ onChange: onControlledCheckedChange,
804
+ disabled,
805
+ isLoading = false,
806
+ ref,
807
+ ...restProps
808
+ } = props;
809
+ const [uncontrolledChecked, setUncontrolledChecked] = useState(defaultChecked);
810
+ const isControlled = controlledChecked !== void 0;
811
+ const effectiveChecked = isControlled ? controlledChecked : uncontrolledChecked;
812
+ const isIndeterminate = effectiveChecked === null;
813
+ const handleChange = (event) => {
814
+ if (!isControlled) {
815
+ setUncontrolledChecked(event.target.checked);
816
+ }
817
+ onControlledCheckedChange?.(event);
818
+ };
819
+ const renderIcon = () => {
820
+ const IconComponent = (() => {
821
+ if (isIndeterminate) return CheckboxUndeterminateFilled_default;
822
+ return effectiveChecked ? CheckboxCheckedFilled_default : Checkbox_default;
823
+ })();
824
+ return /* @__PURE__ */ jsx(
825
+ "div",
826
+ {
827
+ className: twMerge(
828
+ iconWrap({
829
+ color,
830
+ isSelected: effectiveChecked || isIndeterminate,
831
+ disabled
832
+ })
833
+ ),
834
+ children: /* @__PURE__ */ jsx(IconComponent, { className: "icon-md" })
835
+ }
836
+ );
837
+ };
838
+ if (isLoading) return /* @__PURE__ */ jsx(CubeCheckboxSkeleton, {});
839
+ return /* @__PURE__ */ jsxs(
840
+ "label",
841
+ {
842
+ htmlFor: id,
843
+ className: twMerge(
844
+ container({ labelSize, disabled }),
845
+ containerClassName
846
+ ),
847
+ children: [
848
+ /* @__PURE__ */ jsx(
849
+ "input",
850
+ {
851
+ ...restProps,
852
+ id,
853
+ ref,
854
+ type: "checkbox",
855
+ checked: effectiveChecked ?? false,
856
+ onChange: handleChange,
857
+ disabled,
858
+ className: "peer hidden"
859
+ }
860
+ ),
861
+ renderIcon(),
862
+ label4 && /* @__PURE__ */ jsx(
863
+ "span",
864
+ {
865
+ className: twMerge(label({ color, disabled }), labelClassName),
866
+ children: label4
867
+ }
868
+ )
869
+ ]
870
+ }
871
+ );
872
+ };
873
+ CubeCheckbox.Skeleton = CubeCheckboxSkeleton;
874
+ CubeCheckbox.Grid = CubeCheckboxGrid;
875
+ var hyperlink = cva(
876
+ ["flex cursor-pointer items-center gap-x-1 font-medium"],
877
+ {
878
+ variants: {
879
+ color: {
880
+ primary: [
881
+ "text-primary",
882
+ "hover:text-functional-hover-primary",
883
+ "visited:text-primary-700"
884
+ ],
885
+ secondary: [
886
+ "text-functional-border-darker",
887
+ "hover:text-functional-text-light",
888
+ "visited:text-functional-border-darker"
889
+ ]
890
+ },
891
+ size: {
892
+ md: "primary-body2",
893
+ sm: "primary-body4"
894
+ },
895
+ variant: {
896
+ "text-only": "",
897
+ "text-inline": "underline underline-offset-4",
898
+ "icon-left": "",
899
+ "icon-right": ""
900
+ },
901
+ disabled: {
902
+ true: "text-functional-disable-text hover:cursor-default hover:text-functional-disable-text"
903
+ }
904
+ }
905
+ }
906
+ );
907
+ var sizeMapping = {
908
+ sm: { iconSize: "sm", iconFrameSize: "size-[15px]" },
909
+ md: { iconSize: "md-sm", iconFrameSize: "size-[17px]" }
910
+ };
911
+ var CubeHyperlink = (props) => {
912
+ const {
913
+ className: classNameProps,
914
+ color = "primary",
915
+ size = "md",
916
+ variant = "text-only",
917
+ disabled = false,
918
+ children,
919
+ href,
920
+ target,
921
+ onClick
922
+ } = props;
923
+ if (!href && !onClick) {
924
+ console.warn(
925
+ "CubeHyperlink: href or onClick must be provided to make the hyperlink interactive"
926
+ );
927
+ }
928
+ const handleClick = (e) => {
929
+ if (disabled) return;
930
+ onClick?.(e);
931
+ };
932
+ const renderIcon = (iconVariant) => {
933
+ if (props.variant !== iconVariant) {
934
+ return null;
935
+ }
936
+ const { Icon } = props;
937
+ const { iconSize, iconFrameSize } = sizeMapping[size];
938
+ const iconSizeClass = getIconSizeClass(iconSize);
939
+ return /* @__PURE__ */ jsx(
940
+ "div",
941
+ {
942
+ className: twMerge("flex items-center justify-center", iconFrameSize),
943
+ children: /* @__PURE__ */ jsx(Icon, { className: iconSizeClass })
944
+ }
945
+ );
946
+ };
947
+ const renderHyperlink = () => {
948
+ const hyperlinkType = !disabled && href ? "a" : "div";
949
+ const hrefAttribute = hyperlinkType === "a" ? href : void 0;
950
+ const targetAttribute = hyperlinkType === "a" ? target : void 0;
951
+ return createElement(
952
+ hyperlinkType,
953
+ {
954
+ className: twMerge(
955
+ hyperlink({ color, size, variant, disabled }),
956
+ classNameProps
957
+ ),
958
+ href: hrefAttribute,
959
+ target: targetAttribute,
960
+ onClick: handleClick
961
+ },
962
+ renderIcon("icon-left"),
963
+ children,
964
+ renderIcon("icon-right")
965
+ );
966
+ };
967
+ return renderHyperlink();
968
+ };
969
+ var CubeIconFrame = (props) => {
970
+ const { className: classNameProps, size = "md", children, onClick } = props;
971
+ const containerClasses = getContainerClasses(size, classNameProps);
972
+ const iconClasses = getIconClasses(size, children.props.className);
973
+ const icon = cloneElement(children, { className: iconClasses });
974
+ return /* @__PURE__ */ jsx("div", { className: containerClasses, onClick, children: icon });
975
+ };
584
976
  var input = cva(
585
977
  [
586
978
  "primary-body2 w-full truncate rounded-[6px] py-[9px] outline-none",
@@ -643,13 +1035,13 @@ var CubeInputSkeleton = (props) => {
643
1035
  const { type } = props;
644
1036
  return /* @__PURE__ */ jsx(CubeSkeleton, { className: skeleton({ type }) });
645
1037
  };
646
- var CubeInput = forwardRef(
647
- (props, ref) => {
1038
+ var CubeInput = Object.assign(
1039
+ forwardRef((props, ref) => {
648
1040
  const {
649
1041
  className,
650
1042
  required = false,
651
1043
  isLoading = false,
652
- label,
1044
+ label: label4,
653
1045
  tooltip,
654
1046
  helpMessage,
655
1047
  errorMessage,
@@ -663,7 +1055,7 @@ var CubeInput = forwardRef(
663
1055
  const hasFooter = !!helpMessage || isError;
664
1056
  const hasIcon = !!trailingIcon;
665
1057
  const renderLabel = () => {
666
- if (!label && !tooltip) return null;
1058
+ if (!label4 && !tooltip) return null;
667
1059
  if (isLoading) return /* @__PURE__ */ jsx(CubeInputSkeleton, { type: "label" });
668
1060
  return /* @__PURE__ */ jsxs("div", { className: "primary-body2 flex items-center space-x-1", children: [
669
1061
  /* @__PURE__ */ jsx(
@@ -671,7 +1063,7 @@ var CubeInput = forwardRef(
671
1063
  {
672
1064
  htmlFor: inputId,
673
1065
  className: "font-semibold text-functional-title",
674
- children: label
1066
+ children: label4
675
1067
  }
676
1068
  ),
677
1069
  required && /* @__PURE__ */ jsx("span", { className: "text-status-negative", children: "*" }),
@@ -679,6 +1071,7 @@ var CubeInput = forwardRef(
679
1071
  ] });
680
1072
  };
681
1073
  const renderIcon = () => {
1074
+ if (isLoading) return null;
682
1075
  const errorIcon = (() => {
683
1076
  if (!isError) return null;
684
1077
  return /* @__PURE__ */ jsx(WarningFilled_default, { className: "icon-md text-status-negative" });
@@ -725,7 +1118,8 @@ var CubeInput = forwardRef(
725
1118
  ] }),
726
1119
  renderFooter()
727
1120
  ] });
728
- }
1121
+ }),
1122
+ { Skeleton: CubeInputSkeleton }
729
1123
  );
730
1124
  CubeInput.displayName = "CubeInput";
731
1125
  var CubePasswordInput = (props) => {
@@ -745,6 +1139,1063 @@ var CubePasswordInput = (props) => {
745
1139
  }
746
1140
  );
747
1141
  };
1142
+ var container2 = cva(
1143
+ "primary-body2 inline-flex w-fit cursor-pointer items-start gap-x-2",
1144
+ {
1145
+ variants: {
1146
+ disabled: {
1147
+ true: "cursor-default"
1148
+ }
1149
+ }
1150
+ }
1151
+ );
1152
+ var iconWrap2 = cva(
1153
+ [
1154
+ "shrink-0 p-0.5",
1155
+ "text-functional-border-darker transition-colors duration-100 peer-hover:text-functional-hover-primary"
1156
+ ],
1157
+ {
1158
+ variants: {
1159
+ isSelected: {
1160
+ true: "text-primary"
1161
+ },
1162
+ disabled: {
1163
+ true: "text-functional-disable-text peer-hover:text-functional-disable-text"
1164
+ }
1165
+ }
1166
+ }
1167
+ );
1168
+ var label2 = cva("max-w-[152px] break-words text-functional-text", {
1169
+ variants: {
1170
+ disabled: {
1171
+ true: "text-functional-disable-text"
1172
+ }
1173
+ }
1174
+ });
1175
+ var CubeRadioButtonSkeleton = () => {
1176
+ return /* @__PURE__ */ jsxs("div", { className: "inline-flex gap-x-2", children: [
1177
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "size-5" }),
1178
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "h-5 w-[152px]" })
1179
+ ] });
1180
+ };
1181
+ var CubeRadioButtonGrid = (props) => {
1182
+ const { children, className: classNameProp, direction } = props;
1183
+ const className = twMerge(
1184
+ direction === "vertical" ? "flex flex-col gap-y-3" : "grid grid-cols-[repeat(auto-fill,180px)] gap-x-4 gap-y-6",
1185
+ classNameProp
1186
+ );
1187
+ return /* @__PURE__ */ jsx("div", { className, children });
1188
+ };
1189
+ var CubeRadioButton = (props) => {
1190
+ const {
1191
+ label: label4,
1192
+ id,
1193
+ ref,
1194
+ defaultChecked = false,
1195
+ checked: controlledChecked,
1196
+ onChange: onControlledCheckedChange,
1197
+ disabled,
1198
+ isLoading = false,
1199
+ ...restProps
1200
+ } = props;
1201
+ const [uncontrolledChecked, setUncontrolledChecked] = useState(defaultChecked);
1202
+ const isControlled = controlledChecked !== void 0;
1203
+ const effectiveChecked = isControlled ? controlledChecked : uncontrolledChecked;
1204
+ const handleChange = (event) => {
1205
+ if (!isControlled) {
1206
+ setUncontrolledChecked(event.target.checked);
1207
+ }
1208
+ onControlledCheckedChange?.(event);
1209
+ };
1210
+ const renderIcon = () => {
1211
+ const IconComponent = effectiveChecked ? RadioButtonFilled_default : RadioButton_default;
1212
+ return /* @__PURE__ */ jsx(
1213
+ "div",
1214
+ {
1215
+ className: twMerge(
1216
+ iconWrap2({ disabled, isSelected: effectiveChecked })
1217
+ ),
1218
+ children: /* @__PURE__ */ jsx(IconComponent, { className: "icon-md" })
1219
+ }
1220
+ );
1221
+ };
1222
+ if (isLoading) return /* @__PURE__ */ jsx(CubeRadioButtonSkeleton, {});
1223
+ return /* @__PURE__ */ jsxs("label", { htmlFor: id, className: twMerge(container2({ disabled })), children: [
1224
+ /* @__PURE__ */ jsx(
1225
+ "input",
1226
+ {
1227
+ ...restProps,
1228
+ id,
1229
+ ref,
1230
+ type: "radio",
1231
+ checked: effectiveChecked ?? false,
1232
+ onChange: handleChange,
1233
+ disabled,
1234
+ className: "peer hidden"
1235
+ }
1236
+ ),
1237
+ renderIcon(),
1238
+ /* @__PURE__ */ jsx("span", { className: twMerge(label2({ disabled })), children: label4 })
1239
+ ] });
1240
+ };
1241
+ CubeRadioButton.Skeleton = CubeRadioButtonSkeleton;
1242
+ CubeRadioButton.Grid = CubeRadioButtonGrid;
1243
+ var stroke = cva("", {
1244
+ variants: {
1245
+ type: {
1246
+ regular: "border-functional-border-divider",
1247
+ dot: "border-t-4 border-dotted border-primary-50"
1248
+ }
1249
+ }
1250
+ });
1251
+ var CubeStroke = (props) => {
1252
+ const { className, type = "regular", color } = props;
1253
+ return /* @__PURE__ */ jsx("hr", { className: twMerge(stroke({ type }), color, className) });
1254
+ };
1255
+ var tab = cva(
1256
+ "inline-block min-h-[34px] max-w-[200px] border-b border-b-functional-border-divider",
1257
+ {
1258
+ variants: {
1259
+ isActive: {
1260
+ false: "text-functional-text-light"
1261
+ },
1262
+ disabled: {
1263
+ false: ["cursor-pointer hover:text-functional-hover-primary"],
1264
+ true: ["cursor-default text-functional-disable-text"]
1265
+ }
1266
+ },
1267
+ compoundVariants: [
1268
+ {
1269
+ isActive: true,
1270
+ disabled: false,
1271
+ className: "border-b-cosmos-primary text-cosmos-primary"
1272
+ }
1273
+ ],
1274
+ defaultVariants: {
1275
+ isActive: false,
1276
+ disabled: false
1277
+ }
1278
+ }
1279
+ );
1280
+ var innerContainer = cva(
1281
+ [
1282
+ "secondary-body2 flex items-center justify-center px-2.5 py-2",
1283
+ "border-b border-b-transparent"
1284
+ ],
1285
+ {
1286
+ variants: {
1287
+ isActive: {
1288
+ true: "",
1289
+ false: ""
1290
+ },
1291
+ disabled: {
1292
+ false: "font-medium"
1293
+ }
1294
+ },
1295
+ compoundVariants: [
1296
+ {
1297
+ isActive: true,
1298
+ disabled: false,
1299
+ className: "border-b-cosmos-primary font-semibold"
1300
+ }
1301
+ ],
1302
+ defaultVariants: {
1303
+ isActive: false,
1304
+ disabled: false
1305
+ }
1306
+ }
1307
+ );
1308
+ var numberSpan = cva(
1309
+ "secondary-body7 ml-1 inline-flex size-4 shrink-0 items-center justify-center rounded-full text-[9px] font-extrabold",
1310
+ {
1311
+ variants: {
1312
+ disabled: {
1313
+ false: ["bg-cosmos-secondary text-functional-text"],
1314
+ true: ["bg-secondary-150 text-functional-text-light"]
1315
+ }
1316
+ },
1317
+ defaultVariants: {
1318
+ disabled: false
1319
+ }
1320
+ }
1321
+ );
1322
+ var NumberSpan = (props) => {
1323
+ const { number, disabled } = props;
1324
+ const text = number > 99 ? "N" : number;
1325
+ return /* @__PURE__ */ jsx(
1326
+ "span",
1327
+ {
1328
+ className: numberSpan({
1329
+ disabled
1330
+ }),
1331
+ children: text
1332
+ }
1333
+ );
1334
+ };
1335
+ var dotSpan = cva("ml-2.5 size-1 shrink-0 rounded-full", {
1336
+ variants: {
1337
+ disabled: {
1338
+ false: ["bg-cosmos-secondary"],
1339
+ true: ["bg-secondary-150"]
1340
+ }
1341
+ },
1342
+ defaultVariants: {
1343
+ disabled: false
1344
+ }
1345
+ });
1346
+ var DotSpan = (props) => {
1347
+ const { disabled } = props;
1348
+ return /* @__PURE__ */ jsx(
1349
+ "span",
1350
+ {
1351
+ className: dotSpan({
1352
+ disabled
1353
+ })
1354
+ }
1355
+ );
1356
+ };
1357
+ var CubeTab = (props) => {
1358
+ const {
1359
+ children,
1360
+ href,
1361
+ isActive,
1362
+ disabled = false,
1363
+ number,
1364
+ dot,
1365
+ onClick: onClickProp
1366
+ } = props;
1367
+ const onClick = (e) => {
1368
+ if (!disabled) {
1369
+ onClickProp?.(e);
1370
+ }
1371
+ };
1372
+ const renderLabel = () => /* @__PURE__ */ jsx(
1373
+ "span",
1374
+ {
1375
+ "data-label": children,
1376
+ className: twJoin(
1377
+ "inline-flex flex-col items-center",
1378
+ // Use pseudo element to avoid slight layout shift caused by the font weight changes between inactive and active states.
1379
+ "before:secondary-body2 before:pointer-events-none before:invisible before:h-0 before:select-none before:font-semibold before:content-[attr(data-label)]"
1380
+ ),
1381
+ children
1382
+ }
1383
+ );
1384
+ const renderDecoration = () => {
1385
+ if (number !== void 0) {
1386
+ return /* @__PURE__ */ jsx(NumberSpan, { number, disabled });
1387
+ } else if (dot) {
1388
+ return /* @__PURE__ */ jsx(DotSpan, { disabled });
1389
+ } else {
1390
+ return void 0;
1391
+ }
1392
+ };
1393
+ const renderTab = () => {
1394
+ const tagType = href && !disabled ? "a" : "span";
1395
+ const hrefAttribute = tagType === "a" ? href : void 0;
1396
+ return createElement(
1397
+ tagType,
1398
+ {
1399
+ className: twMerge(
1400
+ tab({
1401
+ isActive,
1402
+ disabled
1403
+ })
1404
+ ),
1405
+ href: hrefAttribute,
1406
+ onClick
1407
+ },
1408
+ /* @__PURE__ */ jsxs(
1409
+ "div",
1410
+ {
1411
+ className: twMerge(
1412
+ innerContainer({
1413
+ isActive,
1414
+ disabled
1415
+ })
1416
+ ),
1417
+ children: [
1418
+ renderLabel(),
1419
+ renderDecoration()
1420
+ ]
1421
+ }
1422
+ )
1423
+ );
1424
+ };
1425
+ return renderTab();
1426
+ };
1427
+ var CubeTabSkeleton = () => {
1428
+ return /* @__PURE__ */ jsx("div", { className: "border-b border-b-functional-border-divider px-5 py-2", children: /* @__PURE__ */ jsx(CubeSkeleton, { className: "h-4 w-9" }) });
1429
+ };
1430
+ var CubeTabs = (props) => {
1431
+ const { children } = props;
1432
+ return /* @__PURE__ */ jsx("div", { className: "flex items-end", children });
1433
+ };
1434
+ CubeTabs.Tab = CubeTab;
1435
+ CubeTabs.Skeleton = CubeTabSkeleton;
1436
+ var compoundsCreator = (color, variant, entries) => entries.map((entry) => ({ color, variant, ...entry }));
1437
+ var defaultCompounds = [
1438
+ // Filled - Base
1439
+ {
1440
+ color: "default",
1441
+ variant: "filled",
1442
+ disabled: false,
1443
+ className: twMerge(
1444
+ "bg-functional-border-divider hover:bg-grey-300",
1445
+ "text-functional-text"
1446
+ )
1447
+ },
1448
+ {
1449
+ color: "default",
1450
+ variant: "filled",
1451
+ disabled: true,
1452
+ className: twMerge(
1453
+ "bg-functional-disable-light",
1454
+ "text-functional-disable-text"
1455
+ )
1456
+ },
1457
+ // Filled - Close button
1458
+ {
1459
+ color: "default",
1460
+ variant: "filled",
1461
+ hasCloseButton: true,
1462
+ disabled: false,
1463
+ className: twMerge(
1464
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
1465
+ )
1466
+ },
1467
+ {
1468
+ color: "default",
1469
+ variant: "filled",
1470
+ hasCloseButton: true,
1471
+ disabled: true,
1472
+ className: twMerge("[&>svg]:text-functional-disable-text")
1473
+ },
1474
+ // Filled - Icon
1475
+ {
1476
+ color: "default",
1477
+ variant: "filled",
1478
+ hasIcon: true,
1479
+ disabled: false,
1480
+ className: twMerge("[&>svg]:text-functional-text-light")
1481
+ },
1482
+ {
1483
+ color: "default",
1484
+ variant: "filled",
1485
+ hasIcon: true,
1486
+ disabled: true,
1487
+ className: twMerge("[&>svg]:text-functional-disable-text")
1488
+ },
1489
+ // Stroke - Base
1490
+ {
1491
+ color: "default",
1492
+ variant: "stroke",
1493
+ disabled: false,
1494
+ className: twMerge(
1495
+ "bg-functional-border-divider hover:bg-grey-300",
1496
+ "text-functional-text",
1497
+ "border border-functional-border-darker"
1498
+ )
1499
+ },
1500
+ {
1501
+ color: "default",
1502
+ variant: "stroke",
1503
+ disabled: true,
1504
+ className: twMerge(
1505
+ "bg-functional-disable-light",
1506
+ "text-functional-disable-text",
1507
+ "border border-functional-border-divider"
1508
+ )
1509
+ },
1510
+ // Stroke - Close button
1511
+ {
1512
+ color: "default",
1513
+ variant: "stroke",
1514
+ hasCloseButton: true,
1515
+ disabled: false,
1516
+ className: twMerge(
1517
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
1518
+ )
1519
+ },
1520
+ {
1521
+ color: "default",
1522
+ variant: "stroke",
1523
+ hasCloseButton: true,
1524
+ disabled: true,
1525
+ className: twMerge("[&>svg]:text-functional-disable-text")
1526
+ },
1527
+ // Stroke - Icon
1528
+ {
1529
+ color: "default",
1530
+ variant: "stroke",
1531
+ hasIcon: true,
1532
+ disabled: false,
1533
+ className: twMerge("[&>svg]:text-functional-text-light")
1534
+ },
1535
+ {
1536
+ color: "default",
1537
+ variant: "stroke",
1538
+ hasIcon: true,
1539
+ disabled: true,
1540
+ className: twMerge("[&>svg]:text-functional-disable-text")
1541
+ }
1542
+ ];
1543
+ var primaryBlueCompounds = [
1544
+ ...compoundsCreator("primary-blue", "filled", [
1545
+ {
1546
+ disabled: false,
1547
+ className: twMerge(
1548
+ "bg-primary-200 hover:bg-primary-150",
1549
+ "text-functional-text"
1550
+ )
1551
+ },
1552
+ {
1553
+ disabled: true,
1554
+ className: twMerge("bg-primary-50", "text-functional-disable-text")
1555
+ },
1556
+ {
1557
+ hasCloseButton: true,
1558
+ disabled: false,
1559
+ className: twMerge(
1560
+ "[&>svg]:text-grey-0 [&>svg]:hover:text-functional-text"
1561
+ )
1562
+ },
1563
+ {
1564
+ hasCloseButton: true,
1565
+ disabled: true,
1566
+ className: twMerge("[&>svg]:text-functional-disable-text")
1567
+ },
1568
+ {
1569
+ hasIcon: true,
1570
+ disabled: false,
1571
+ className: twMerge("[&>svg]:text-functional-text-light")
1572
+ },
1573
+ {
1574
+ hasIcon: true,
1575
+ disabled: true,
1576
+ className: twMerge("[&>svg]:text-functional-disable-text")
1577
+ }
1578
+ ]),
1579
+ ...compoundsCreator("primary-blue", "stroke", [
1580
+ {
1581
+ disabled: false,
1582
+ className: twMerge(
1583
+ "bg-primary-0 hover:bg-primary-50",
1584
+ "text-functional-text",
1585
+ "border border-primary-200"
1586
+ )
1587
+ },
1588
+ {
1589
+ disabled: true,
1590
+ className: twMerge(
1591
+ "bg-primary-0",
1592
+ "text-functional-disable-text",
1593
+ "border border-primary-50"
1594
+ )
1595
+ },
1596
+ {
1597
+ hasCloseButton: true,
1598
+ disabled: false,
1599
+ className: twMerge(
1600
+ "[&>svg]:text-primary-200 [&>svg]:hover:text-functional-text"
1601
+ )
1602
+ },
1603
+ {
1604
+ hasCloseButton: true,
1605
+ disabled: true,
1606
+ className: twMerge("[&>svg]:text-functional-disable-text")
1607
+ },
1608
+ {
1609
+ hasIcon: true,
1610
+ disabled: false,
1611
+ className: twMerge("[&>svg]:text-primary-200")
1612
+ },
1613
+ {
1614
+ hasIcon: true,
1615
+ disabled: true,
1616
+ className: twMerge("[&>svg]:text-functional-disable-text")
1617
+ }
1618
+ ])
1619
+ ];
1620
+ var blueCompounds = [
1621
+ ...compoundsCreator("blue", "filled", [
1622
+ {
1623
+ disabled: false,
1624
+ className: twMerge(
1625
+ "bg-blue-200 hover:bg-blue-150",
1626
+ "text-functional-text"
1627
+ )
1628
+ },
1629
+ {
1630
+ disabled: true,
1631
+ className: twMerge("bg-blue-50", "text-functional-disable-text")
1632
+ },
1633
+ {
1634
+ hasCloseButton: true,
1635
+ disabled: false,
1636
+ className: twMerge(
1637
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
1638
+ )
1639
+ },
1640
+ {
1641
+ hasCloseButton: true,
1642
+ disabled: true,
1643
+ className: twMerge("[&>svg]:text-functional-disable-text")
1644
+ },
1645
+ {
1646
+ hasIcon: true,
1647
+ disabled: false,
1648
+ className: twMerge("[&>svg]:text-functional-text-light")
1649
+ },
1650
+ {
1651
+ hasIcon: true,
1652
+ disabled: true,
1653
+ className: twMerge("[&>svg]:text-functional-disable-text")
1654
+ }
1655
+ ]),
1656
+ ...compoundsCreator("blue", "stroke", [
1657
+ {
1658
+ disabled: false,
1659
+ className: twMerge(
1660
+ "bg-blue-50 hover:bg-blue-100",
1661
+ "text-functional-text",
1662
+ "border border-primary-400"
1663
+ )
1664
+ },
1665
+ {
1666
+ disabled: true,
1667
+ className: twMerge(
1668
+ "bg-blue-0",
1669
+ "text-functional-disable-text",
1670
+ "border border-primary-150"
1671
+ )
1672
+ },
1673
+ {
1674
+ hasCloseButton: true,
1675
+ disabled: false,
1676
+ className: twMerge(
1677
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
1678
+ )
1679
+ },
1680
+ {
1681
+ hasCloseButton: true,
1682
+ disabled: true,
1683
+ className: twMerge("[&>svg]:text-functional-disable-text")
1684
+ },
1685
+ {
1686
+ hasIcon: true,
1687
+ disabled: false,
1688
+ className: twMerge("[&>svg]:text-functional-text-light")
1689
+ },
1690
+ {
1691
+ hasIcon: true,
1692
+ disabled: true,
1693
+ className: twMerge("[&>svg]:text-functional-disable-text")
1694
+ }
1695
+ ])
1696
+ ];
1697
+ var cyanCompounds = [
1698
+ ...compoundsCreator("cyan", "filled", [
1699
+ {
1700
+ disabled: false,
1701
+ className: twMerge(
1702
+ "bg-secondary-200 hover:bg-secondary-150",
1703
+ "text-functional-text"
1704
+ )
1705
+ },
1706
+ {
1707
+ disabled: true,
1708
+ className: twMerge("bg-secondary-50", "text-functional-disable-text")
1709
+ },
1710
+ {
1711
+ hasCloseButton: true,
1712
+ disabled: false,
1713
+ className: twMerge(
1714
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
1715
+ )
1716
+ },
1717
+ {
1718
+ hasCloseButton: true,
1719
+ disabled: true,
1720
+ className: twMerge("[&>svg]:text-functional-disable-text")
1721
+ },
1722
+ {
1723
+ hasIcon: true,
1724
+ disabled: false,
1725
+ className: twMerge("[&>svg]:text-functional-text-light")
1726
+ },
1727
+ {
1728
+ hasIcon: true,
1729
+ disabled: true,
1730
+ className: twMerge("[&>svg]:text-functional-disable-text")
1731
+ }
1732
+ ]),
1733
+ ...compoundsCreator("cyan", "stroke", [
1734
+ {
1735
+ disabled: false,
1736
+ className: twMerge(
1737
+ "bg-secondary-50 hover:bg-secondary-100",
1738
+ "text-functional-text",
1739
+ "border border-secondary-600"
1740
+ )
1741
+ },
1742
+ {
1743
+ disabled: true,
1744
+ className: twMerge(
1745
+ "bg-secondary-0",
1746
+ "text-functional-disable-text",
1747
+ "border border-secondary-150"
1748
+ )
1749
+ },
1750
+ {
1751
+ hasCloseButton: true,
1752
+ disabled: false,
1753
+ className: twMerge(
1754
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
1755
+ )
1756
+ },
1757
+ {
1758
+ hasCloseButton: true,
1759
+ disabled: true,
1760
+ className: twMerge("[&>svg]:text-functional-disable-text")
1761
+ },
1762
+ {
1763
+ hasIcon: true,
1764
+ disabled: false,
1765
+ className: twMerge("[&>svg]:text-functional-text-light")
1766
+ },
1767
+ {
1768
+ hasIcon: true,
1769
+ disabled: true,
1770
+ className: twMerge("[&>svg]:text-functional-disable-text")
1771
+ }
1772
+ ])
1773
+ ];
1774
+ var darkCompounds = [
1775
+ ...compoundsCreator("dark", "filled", [
1776
+ {
1777
+ disabled: false,
1778
+ className: twMerge("bg-dark-500 hover:bg-dark-400", "text-grey-0")
1779
+ },
1780
+ {
1781
+ disabled: true,
1782
+ className: twMerge("bg-functional-disable", "text-grey-0")
1783
+ },
1784
+ {
1785
+ hasCloseButton: true,
1786
+ disabled: false,
1787
+ className: twMerge("[&>svg]:text-dark-150 [&>svg]:hover:text-grey-0")
1788
+ },
1789
+ {
1790
+ hasCloseButton: true,
1791
+ disabled: true,
1792
+ className: twMerge("[&>svg]:text-grey-0")
1793
+ },
1794
+ {
1795
+ hasIcon: true,
1796
+ disabled: false,
1797
+ className: twMerge("[&>svg]:text-dark-150")
1798
+ },
1799
+ {
1800
+ hasIcon: true,
1801
+ disabled: true,
1802
+ className: twMerge("[&>svg]:text-grey-0")
1803
+ }
1804
+ ]),
1805
+ ...compoundsCreator("dark", "stroke", [
1806
+ {
1807
+ disabled: false,
1808
+ className: twMerge(
1809
+ "bg-dark-50 hover:bg-dark-100",
1810
+ "text-functional-text",
1811
+ "border border-functional-text"
1812
+ )
1813
+ },
1814
+ {
1815
+ disabled: true,
1816
+ className: twMerge(
1817
+ "bg-dark-0",
1818
+ "text-functional-border-divider",
1819
+ "border border-functional-border-divider"
1820
+ )
1821
+ },
1822
+ {
1823
+ hasCloseButton: true,
1824
+ disabled: false,
1825
+ className: twMerge(
1826
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
1827
+ )
1828
+ },
1829
+ {
1830
+ hasCloseButton: true,
1831
+ disabled: true,
1832
+ className: twMerge("[&>svg]:text-functional-border-divider")
1833
+ },
1834
+ {
1835
+ hasIcon: true,
1836
+ disabled: false,
1837
+ className: twMerge("[&>svg]:text-functional-text-light")
1838
+ },
1839
+ {
1840
+ hasIcon: true,
1841
+ disabled: true,
1842
+ className: twMerge("[&>svg]:text-functional-border-divider")
1843
+ }
1844
+ ])
1845
+ ];
1846
+ var tag = cva(
1847
+ [
1848
+ "inline-flex items-center gap-x-[5px] whitespace-nowrap",
1849
+ "h-[21px] w-fit cursor-default rounded-[20px] px-2.5 py-1",
1850
+ "secondary-body5 font-semibold"
1851
+ ],
1852
+ {
1853
+ variants: {
1854
+ // Use `as` for `compoundVariants` to infer the type.
1855
+ color: {},
1856
+ variant: {},
1857
+ hasCloseButton: {
1858
+ true: void 0
1859
+ },
1860
+ hasIcon: {
1861
+ true: void 0
1862
+ },
1863
+ disabled: {
1864
+ true: void 0
1865
+ }
1866
+ },
1867
+ compoundVariants: [
1868
+ ...defaultCompounds,
1869
+ ...primaryBlueCompounds,
1870
+ ...blueCompounds,
1871
+ ...cyanCompounds,
1872
+ ...darkCompounds
1873
+ ]
1874
+ }
1875
+ );
1876
+ var closeButton = cva("icon-xs", {
1877
+ variants: {
1878
+ disabled: {
1879
+ false: "cursor-pointer",
1880
+ true: "cursor-default"
1881
+ }
1882
+ }
1883
+ });
1884
+ var skeleton2 = cva("h-[23px] rounded-full", {
1885
+ variants: {
1886
+ hasIcon: {
1887
+ true: "w-[95px]",
1888
+ false: "w-[80px]"
1889
+ }
1890
+ }
1891
+ });
1892
+ var CubeTagSkeleton = (props) => {
1893
+ const { hasIcon } = props;
1894
+ return /* @__PURE__ */ jsx(CubeSkeleton, { className: twMerge(skeleton2({ hasIcon })) });
1895
+ };
1896
+ var CubeTag = (props) => {
1897
+ const {
1898
+ className,
1899
+ children,
1900
+ color = "default",
1901
+ variant,
1902
+ disabled = false,
1903
+ isLoading = false
1904
+ } = props;
1905
+ const hasIcon = "Icon" in props;
1906
+ const hasCloseButton = "showCloseButton" in props && props.showCloseButton;
1907
+ const renderIcon = () => {
1908
+ if (!hasIcon) {
1909
+ return void 0;
1910
+ }
1911
+ const { Icon } = props;
1912
+ return /* @__PURE__ */ jsx(Icon, { className: "icon-xs" });
1913
+ };
1914
+ const renderCloseButton = () => {
1915
+ if (!hasCloseButton) {
1916
+ return void 0;
1917
+ }
1918
+ const { onClose: onCloseProp } = props;
1919
+ const onClose = () => {
1920
+ if (!disabled) {
1921
+ onCloseProp?.();
1922
+ }
1923
+ };
1924
+ return /* @__PURE__ */ jsx(X_default, { className: closeButton({ disabled }), onClick: onClose });
1925
+ };
1926
+ if (isLoading) return /* @__PURE__ */ jsx(CubeTagSkeleton, { hasIcon: hasIcon || hasCloseButton });
1927
+ return /* @__PURE__ */ jsxs(
1928
+ "span",
1929
+ {
1930
+ className: twMerge(
1931
+ tag({
1932
+ color,
1933
+ variant,
1934
+ hasCloseButton,
1935
+ hasIcon,
1936
+ disabled
1937
+ }),
1938
+ className
1939
+ ),
1940
+ children: [
1941
+ renderIcon(),
1942
+ children,
1943
+ renderCloseButton()
1944
+ ]
1945
+ }
1946
+ );
1947
+ };
1948
+ CubeTag.Skeleton = CubeTagSkeleton;
1949
+ var CubeTextareaSkeleton = () => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-[6px]", children: [
1950
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "h-[20px] min-w-[280px] max-w-[380px]" }),
1951
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "h-[140px] min-w-[280px] max-w-[380px]" })
1952
+ ] });
1953
+
1954
+ // src/components/CubeTextarea/cubeTextareaUtils.ts
1955
+ var normalizeValue = (value) => {
1956
+ if (typeof value === "string") return value;
1957
+ if (typeof value === "number") return value.toString();
1958
+ if (Array.isArray(value)) return value.join("");
1959
+ return "";
1960
+ };
1961
+ var calculateValueLength = (value) => {
1962
+ const normalizedValue = normalizeValue(value);
1963
+ return normalizedValue.length;
1964
+ };
1965
+ var assignRefValue = (ref, element) => {
1966
+ if (!ref) return;
1967
+ if (typeof ref === "function") {
1968
+ ref(element);
1969
+ } else {
1970
+ ref.current = element;
1971
+ }
1972
+ };
1973
+ var useVisibleRowsCount = () => {
1974
+ const textareaRef = useRef(null);
1975
+ const [visibleRowsCount, setVisibleRowsCount] = useState(0);
1976
+ useEffect(() => {
1977
+ const textarea2 = textareaRef.current;
1978
+ let observer = void 0;
1979
+ if (textarea2) {
1980
+ observer = new ResizeObserver((entries) => {
1981
+ const { lineHeight } = getComputedStyle(textarea2);
1982
+ const lineHeightPx = parseInt(lineHeight);
1983
+ const textareaHeight = entries[0]?.contentBoxSize[0]?.blockSize ?? 0;
1984
+ setVisibleRowsCount(
1985
+ Math.ceil((textareaHeight + textarea2.scrollTop) / lineHeightPx)
1986
+ );
1987
+ });
1988
+ observer.observe(textarea2);
1989
+ }
1990
+ return () => {
1991
+ observer?.disconnect();
1992
+ };
1993
+ }, []);
1994
+ return {
1995
+ textareaRef,
1996
+ visibleRowsCount
1997
+ };
1998
+ };
1999
+ var textarea = cva(
2000
+ [
2001
+ "primary-body2 rounded-[5px] bg-grey-0 px-4 py-[10px] outline-none",
2002
+ "max-h-[260px] min-h-[140px] min-w-[280px]",
2003
+ "text-functional-text placeholder:text-functional-border-darker",
2004
+ "border border-functional-border-divider",
2005
+ "hover:border-functional-hover-primary focus:border-functional-hover-primary"
2006
+ ],
2007
+ {
2008
+ variants: {
2009
+ isError: {
2010
+ true: "border-status-negative hover:border-status-negative"
2011
+ },
2012
+ disabled: {
2013
+ true: [
2014
+ "disabled:border-functional-disable-text disabled:text-functional-disable-text disabled:placeholder:text-functional-border-divider",
2015
+ "disabled:hover:border-functional-disable-text"
2016
+ ]
2017
+ }
2018
+ }
2019
+ }
2020
+ );
2021
+ var CubeTextarea = (props) => {
2022
+ const {
2023
+ id: textareaId,
2024
+ ref,
2025
+ className,
2026
+ disabled,
2027
+ value: valueProps,
2028
+ onChange,
2029
+ label: label4,
2030
+ maxLength,
2031
+ isLoading,
2032
+ errorMessage,
2033
+ ...restProps
2034
+ } = props;
2035
+ const [charCount, setCharCount] = useState(
2036
+ () => calculateValueLength(valueProps)
2037
+ );
2038
+ const [isFocused, setIsFocused] = useState(false);
2039
+ useEffect(() => {
2040
+ setCharCount(calculateValueLength(valueProps));
2041
+ }, [valueProps]);
2042
+ const { textareaRef: localRef, visibleRowsCount } = useVisibleRowsCount();
2043
+ const handleChange = (e) => {
2044
+ const newValue = e.target.value;
2045
+ if (newValue.length <= maxLength) {
2046
+ setCharCount(newValue.length);
2047
+ onChange?.(e);
2048
+ }
2049
+ };
2050
+ if (isLoading) {
2051
+ return /* @__PURE__ */ jsx(CubeTextareaSkeleton, {});
2052
+ }
2053
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-[6px]", children: [
2054
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
2055
+ /* @__PURE__ */ jsx(
2056
+ "label",
2057
+ {
2058
+ htmlFor: textareaId,
2059
+ className: "primary-body2 font-semibold text-functional-text",
2060
+ children: label4
2061
+ }
2062
+ ),
2063
+ /* @__PURE__ */ jsxs("div", { className: "secondary-body4 text-functional-text-light", children: [
2064
+ charCount.toLocaleString("en-US"),
2065
+ "/",
2066
+ maxLength.toLocaleString("en-US")
2067
+ ] })
2068
+ ] }),
2069
+ /* @__PURE__ */ jsx(
2070
+ "textarea",
2071
+ {
2072
+ ...restProps,
2073
+ id: textareaId,
2074
+ disabled,
2075
+ ref: (element) => {
2076
+ assignRefValue(ref, element);
2077
+ assignRefValue(localRef, element);
2078
+ },
2079
+ value: valueProps,
2080
+ onChange: handleChange,
2081
+ onFocus: () => setIsFocused(true),
2082
+ onBlur: () => setIsFocused(false),
2083
+ className: twMerge(
2084
+ textarea({ isError: !!errorMessage, disabled }),
2085
+ className
2086
+ ),
2087
+ style: isFocused ? void 0 : {
2088
+ overflow: "hidden",
2089
+ display: "-webkit-box",
2090
+ WebkitBoxOrient: "vertical",
2091
+ WebkitLineClamp: visibleRowsCount
2092
+ }
2093
+ }
2094
+ ),
2095
+ errorMessage && /* @__PURE__ */ jsx("p", { className: "primary-body4 text-status-negative", children: errorMessage })
2096
+ ] });
2097
+ };
2098
+ CubeTextarea.Skeleton = CubeTextareaSkeleton;
2099
+ var track = cva(
2100
+ "flex h-[20px] w-9 items-center rounded-full border border-transparent transition-colors",
2101
+ {
2102
+ variants: {
2103
+ checked: {
2104
+ true: "bg-status-positive",
2105
+ false: "bg-functional-disable-text"
2106
+ },
2107
+ disabled: {
2108
+ false: "cursor-pointer",
2109
+ true: "cursor-default"
2110
+ }
2111
+ },
2112
+ compoundVariants: [
2113
+ // Not disabled
2114
+ {
2115
+ checked: true,
2116
+ disabled: false,
2117
+ className: "hover:bg-green-400"
2118
+ },
2119
+ {
2120
+ checked: false,
2121
+ disabled: false,
2122
+ className: "hover:bg-grey-400"
2123
+ },
2124
+ // Disabled
2125
+ {
2126
+ checked: true,
2127
+ disabled: true,
2128
+ className: "border-green-200 bg-green-100"
2129
+ },
2130
+ {
2131
+ checked: false,
2132
+ disabled: true,
2133
+ className: "border-functional-disable bg-grey-150"
2134
+ }
2135
+ ]
2136
+ }
2137
+ );
2138
+ var thumb = cva(
2139
+ "size-[17px] rounded-full bg-grey-0 shadow-md transition-transform",
2140
+ {
2141
+ variants: {
2142
+ checked: {
2143
+ true: "translate-x-4",
2144
+ false: "translate-x-px"
2145
+ }
2146
+ }
2147
+ }
2148
+ );
2149
+ var label3 = cva("primary-body4 text-functional-text", {
2150
+ variants: {
2151
+ disabled: {
2152
+ false: "cursor-pointer",
2153
+ true: "cursor-default"
2154
+ }
2155
+ }
2156
+ });
2157
+ var CubeToggle = (props) => {
2158
+ const {
2159
+ className,
2160
+ checked,
2161
+ onCheckedChange,
2162
+ label: label4,
2163
+ disabled = false,
2164
+ "aria-label": ariaLabel
2165
+ } = props;
2166
+ const toggleId = useId();
2167
+ const labelId = useId();
2168
+ const toggleChecked = () => {
2169
+ if (disabled) return;
2170
+ onCheckedChange(!checked);
2171
+ };
2172
+ return /* @__PURE__ */ jsxs("div", { className: twMerge("flex items-center gap-x-[6px]", className), children: [
2173
+ /* @__PURE__ */ jsx(
2174
+ "button",
2175
+ {
2176
+ id: toggleId,
2177
+ type: "button",
2178
+ role: "switch",
2179
+ "aria-checked": checked,
2180
+ "aria-labelledby": label4 ? labelId : void 0,
2181
+ "aria-label": label4 ? void 0 : ariaLabel,
2182
+ className: twMerge(track({ checked, disabled })),
2183
+ disabled,
2184
+ onClick: toggleChecked,
2185
+ children: /* @__PURE__ */ jsx("span", { className: thumb({ checked }), "aria-hidden": true })
2186
+ }
2187
+ ),
2188
+ label4 && /* @__PURE__ */ jsx(
2189
+ "label",
2190
+ {
2191
+ id: labelId,
2192
+ htmlFor: toggleId,
2193
+ className: label3({ disabled }),
2194
+ children: label4
2195
+ }
2196
+ )
2197
+ ] });
2198
+ };
748
2199
 
749
2200
  // src/i18n/resources/en-US.json
750
2201
  var en_US_default = {
@@ -1458,6 +2909,6 @@ var cubePreset = {
1458
2909
  ]
1459
2910
  };
1460
2911
 
1461
- export { CubeButton, CubeButtonSkeleton, CubeIconFrame, CubeInput, CubeLoadingSpinner, CubePasswordInput, CubeSkeleton, CubeThemeProvider, CubeUiLocaleProvider, addCubeUiTranslations, cubePreset, cubeTheme, getTypography, useCubeUiTranslation };
2912
+ export { CubeButton, CubeCheckbox, CubeHyperlink, CubeIconFrame, CubeInput, CubeLoadingSpinner, CubePasswordInput, CubeRadioButton, CubeSkeleton, CubeStroke, CubeTabs, CubeTag, CubeTextarea, CubeThemeProvider, CubeToggle, CubeUiLocaleProvider, addCubeUiTranslations, cubePreset, cubeTheme, getTypography, useCubeUiTranslation };
1462
2913
  //# sourceMappingURL=index.mjs.map
1463
2914
  //# sourceMappingURL=index.mjs.map