@bigstack-oss/cube-ui 0.0.2 → 0.2.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,10 +1,11 @@
1
- import { omit } from 'lodash';
2
- import { twMerge } from 'tailwind-merge';
1
+ import { omit, upperFirst, range, debounce } from 'lodash';
2
+ import { twMerge, twJoin } from 'tailwind-merge';
3
3
  import { cva } from 'class-variance-authority';
4
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
- import { forwardRef, useId, cloneElement, useState, useEffect } from 'react';
6
- import i18next from 'i18next';
4
+ import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
5
+ import { forwardRef, createContext, useId, cloneElement, useState, useCallback, useEffect, useRef, Fragment, createElement, useContext, useMemo, Children, isValidElement } from 'react';
7
6
  import { initReactI18next, useTranslation } from 'react-i18next';
7
+ import i18next from 'i18next';
8
+ import { createPortal } from 'react-dom';
8
9
  import defaultTheme from 'tailwindcss/defaultTheme';
9
10
 
10
11
  // src/components/CubeButton/CubeButton.tsx
@@ -274,12 +275,12 @@ var getIconClasses = (size, classNameProps) => {
274
275
 
275
276
  // src/components/CubeButton/cubeButtonUtils.ts
276
277
  var getIconSizeByButtonSize = (size) => {
277
- const sizeMapping = {
278
+ const sizeMapping2 = {
278
279
  sm: "md-sm",
279
280
  md: "md",
280
281
  lg: "md"
281
282
  };
282
- const iconSize = sizeMapping[size];
283
+ const iconSize = sizeMapping2[size];
283
284
  return getIconSizeClass(iconSize);
284
285
  };
285
286
  var CubeLeft = (props) => {
@@ -474,6 +475,23 @@ var CubeButtonLoadingSpinner = (props) => {
474
475
  }
475
476
  );
476
477
  };
478
+ var CubeSkeleton = (props) => {
479
+ const { className, style } = props;
480
+ return /* @__PURE__ */ jsx(
481
+ "div",
482
+ {
483
+ className: twMerge(
484
+ "cube-skeleton animate-cube-skeleton rounded-[5px]",
485
+ className
486
+ ),
487
+ style
488
+ }
489
+ );
490
+ };
491
+ var CubeButtonSkeleton = (props) => {
492
+ const { size = "md", usage = "text-only" } = props;
493
+ return /* @__PURE__ */ jsx(CubeSkeleton, { className: twMerge(buttonSkeleton({ size, usage })) });
494
+ };
477
495
  var CubeButton = (props) => {
478
496
  const {
479
497
  htmlType = "button",
@@ -495,18 +513,18 @@ var CubeButton = (props) => {
495
513
  case "icon-only":
496
514
  return renderIcon(props.Icon);
497
515
  case "icon-left":
498
- return /* @__PURE__ */ jsxs(Fragment, { children: [
516
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
499
517
  renderIcon(props.Icon),
500
518
  props.children
501
519
  ] });
502
520
  case "icon-right":
503
- return /* @__PURE__ */ jsxs(Fragment, { children: [
521
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
504
522
  props.children,
505
523
  renderIcon(props.Icon)
506
524
  ] });
507
525
  case "text-only":
508
526
  default:
509
- return /* @__PURE__ */ jsxs(Fragment, { children: [
527
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
510
528
  props.children,
511
529
  loading && /* @__PURE__ */ jsx(CubeButtonLoadingSpinner, { type, usage })
512
530
  ] });
@@ -527,30 +545,118 @@ var CubeButton = (props) => {
527
545
  }
528
546
  );
529
547
  };
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
- };
548
+ CubeButton.Skeleton = CubeButtonSkeleton;
549
+ var SvgCheckbox = ({
550
+ title,
551
+ titleId,
552
+ ...props
553
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
554
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
555
+ /* @__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" })
556
+ ] });
557
+ var ForwardRef = forwardRef(SvgCheckbox);
558
+ var Checkbox_default = ForwardRef;
559
+ var SvgCheckboxCheckedFilled = ({
560
+ title,
561
+ titleId,
562
+ ...props
563
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
564
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
565
+ /* @__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" })
566
+ ] });
567
+ var ForwardRef2 = forwardRef(SvgCheckboxCheckedFilled);
568
+ var CheckboxCheckedFilled_default = ForwardRef2;
569
+ var SvgCheckboxUndeterminateFilled = ({
570
+ title,
571
+ titleId,
572
+ ...props
573
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
574
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
575
+ /* @__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" })
576
+ ] });
577
+ var ForwardRef3 = forwardRef(SvgCheckboxUndeterminateFilled);
578
+ var CheckboxUndeterminateFilled_default = ForwardRef3;
579
+ var SvgCheckmarkBold = ({
580
+ title,
581
+ titleId,
582
+ ...props
583
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
584
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
585
+ /* @__PURE__ */ jsx("path", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "m3 7.3 3.75 4.2 6.25-7" })
586
+ ] });
587
+ var ForwardRef4 = forwardRef(SvgCheckmarkBold);
588
+ var CheckmarkBold_default = ForwardRef4;
589
+ var SvgCheckmarkCircleFill = ({
590
+ title,
591
+ titleId,
592
+ ...props
593
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
594
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
595
+ /* @__PURE__ */ jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M8 1.1C4.134 1.1 1 4.19 1 8s3.134 6.9 7 6.9 7-3.09 7-6.9-3.134-6.9-7-6.9m3.446 5.413a.74.74 0 0 0-.034-1.06.77.77 0 0 0-1.076.034L7.087 8.903 5.359 7.087a.77.77 0 0 0-1.075-.034.74.74 0 0 0-.035 1.06l2.283 2.4a.766.766 0 0 0 1.11 0z", clipRule: "evenodd" })
596
+ ] });
597
+ var ForwardRef5 = forwardRef(SvgCheckmarkCircleFill);
598
+ var CheckmarkCircleFill_default = ForwardRef5;
599
+ var SvgChevronDown = ({
600
+ title,
601
+ titleId,
602
+ ...props
603
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
604
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
605
+ /* @__PURE__ */ jsx("path", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2, d: "M12.5 5.75 8 10.25l-4.5-4.5" })
606
+ ] });
607
+ var ForwardRef6 = forwardRef(SvgChevronDown);
608
+ var ChevronDown_default = ForwardRef6;
609
+ var SvgChevronRight = ({
610
+ title,
611
+ titleId,
612
+ ...props
613
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
614
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
615
+ /* @__PURE__ */ jsx("path", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2, d: "m5.75 3.5 4.5 4.5-4.5 4.5" })
616
+ ] });
617
+ var ForwardRef7 = forwardRef(SvgChevronRight);
618
+ var ChevronRight_default = ForwardRef7;
619
+ var SvgCrossFill = ({
620
+ title,
621
+ titleId,
622
+ ...props
623
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
624
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
625
+ /* @__PURE__ */ jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M8 1.1C4.134 1.1 1 4.19 1 8s3.134 6.9 7 6.9 7-3.09 7-6.9-3.134-6.9-7-6.9m2.924 4.824a.6.6 0 0 0-.848-.848L8 7.15 5.924 5.076a.6.6 0 1 0-.848.848L7.15 8l-2.075 2.076a.6.6 0 0 0 .848.848L8 8.85l2.076 2.075a.6.6 0 0 0 .848-.848L8.85 8z", clipRule: "evenodd" })
626
+ ] });
627
+ var ForwardRef8 = forwardRef(SvgCrossFill);
628
+ var CrossFill_default = ForwardRef8;
629
+ var SvgRadioButton = ({
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("circle", { cx: 8, cy: 8, r: 6.5, stroke: "currentColor", strokeWidth: 1.2 })
636
+ ] });
637
+ var ForwardRef9 = forwardRef(SvgRadioButton);
638
+ var RadioButton_default = ForwardRef9;
639
+ var SvgRadioButtonFilled = ({
640
+ title,
641
+ titleId,
642
+ ...props
643
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
644
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
645
+ /* @__PURE__ */ jsx("circle", { cx: 8, cy: 8, r: 6.5, stroke: "currentColor", strokeWidth: 1.2 }),
646
+ /* @__PURE__ */ jsx("path", { fill: "currentColor", d: "M8 13A5 5 0 1 0 8 3a5 5 0 0 0 0 10" })
647
+ ] });
648
+ var ForwardRef10 = forwardRef(SvgRadioButtonFilled);
649
+ var RadioButtonFilled_default = ForwardRef10;
650
+ var SvgSearch = ({
651
+ title,
652
+ titleId,
653
+ ...props
654
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
655
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
656
+ /* @__PURE__ */ jsx("path", { stroke: "currentColor", strokeLinecap: "round", strokeWidth: 1.2, d: "M11.083 11.107 14 14m-1.313-6.688c0 2.934-2.392 5.312-5.343 5.312S2 10.247 2 7.312 4.392 2 7.344 2c2.95 0 5.343 2.378 5.343 5.312Z" })
657
+ ] });
658
+ var ForwardRef11 = forwardRef(SvgSearch);
659
+ var Search_default = ForwardRef11;
554
660
  var SvgView = ({
555
661
  title,
556
662
  titleId,
@@ -559,8 +665,8 @@ var SvgView = ({
559
665
  title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
560
666
  /* @__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
667
  ] });
562
- var ForwardRef = forwardRef(SvgView);
563
- var View_default = ForwardRef;
668
+ var ForwardRef12 = forwardRef(SvgView);
669
+ var View_default = ForwardRef12;
564
670
  var SvgViewOff = ({
565
671
  title,
566
672
  titleId,
@@ -569,8 +675,8 @@ var SvgViewOff = ({
569
675
  title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
570
676
  /* @__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
677
  ] });
572
- var ForwardRef2 = forwardRef(SvgViewOff);
573
- var ViewOff_default = ForwardRef2;
678
+ var ForwardRef13 = forwardRef(SvgViewOff);
679
+ var ViewOff_default = ForwardRef13;
574
680
  var SvgWarningFilled = ({
575
681
  title,
576
682
  titleId,
@@ -579,183 +685,618 @@ var SvgWarningFilled = ({
579
685
  title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
580
686
  /* @__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
687
  ] });
582
- var ForwardRef3 = forwardRef(SvgWarningFilled);
583
- var WarningFilled_default = ForwardRef3;
584
- var input = cva(
585
- [
586
- "primary-body2 w-full truncate rounded-[6px] py-[9px] outline-none",
587
- "bg-grey-0",
588
- "text-functional-text placeholder:text-functional-border-darker",
589
- "border border-functional-border-divider",
590
- "hover:border-functional-hover-primary focus:border-functional-hover-primary"
591
- ],
688
+ var ForwardRef14 = forwardRef(SvgWarningFilled);
689
+ var WarningFilled_default = ForwardRef14;
690
+ var SvgX = ({
691
+ title,
692
+ titleId,
693
+ ...props
694
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
695
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
696
+ /* @__PURE__ */ jsx("path", { stroke: "currentColor", strokeLinecap: "round", strokeWidth: 1.2, d: "m12.5 3.5-9 9m9 0-9-9" })
697
+ ] });
698
+ var ForwardRef15 = forwardRef(SvgX);
699
+ var X_default = ForwardRef15;
700
+ var SvgXSmall = ({
701
+ title,
702
+ titleId,
703
+ ...props
704
+ }, ref) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", ref, "aria-labelledby": titleId, ...props, children: [
705
+ title ? /* @__PURE__ */ jsx("title", { id: titleId, children: title }) : null,
706
+ /* @__PURE__ */ jsx("path", { stroke: "currentColor", strokeLinecap: "round", strokeWidth: 1.2, d: "m11 5-6 6m6 0L5 5" })
707
+ ] });
708
+ var ForwardRef16 = forwardRef(SvgXSmall);
709
+ var XSmall_default = ForwardRef16;
710
+ var container = cva(
711
+ "inline-flex w-fit cursor-pointer items-start gap-x-2",
592
712
  {
593
713
  variants: {
594
- isError: {
595
- true: [
596
- "pl-4 pr-8",
597
- "border-status-negative hover:border-status-negative"
598
- ]
714
+ labelSize: {
715
+ md: "primary-body2",
716
+ sm: "primary-body3",
717
+ xs: "primary-body4"
599
718
  },
600
719
  disabled: {
601
- true: [
602
- "disabled:border-functional-disable-text disabled:text-functional-disable-text disabled:placeholder:text-functional-border-divider",
603
- "disabled:hover:border-functional-disable-text"
604
- ]
605
- },
606
- hasIcon: {
607
- true: "pl-4 pr-8",
608
- false: "px-4"
720
+ true: "cursor-default"
609
721
  }
610
- },
611
- compoundVariants: [
612
- { isError: true, hasIcon: true, class: "pr-[56px]" },
613
- { isError: true, hasIcon: false, class: "pr-9" }
614
- ]
722
+ }
615
723
  }
616
724
  );
617
- var customIcon = cva("icon-md", {
725
+ var iconWrap = cva("shrink-0 p-0.5 transition-colors duration-100", {
618
726
  variants: {
727
+ color: {},
728
+ isSelected: {
729
+ true: ""
730
+ },
619
731
  disabled: {
620
- true: "cursor-default text-functional-border-divider",
621
- false: "cursor-pointer text-functional-text"
732
+ true: ""
622
733
  }
623
- }
624
- });
625
- var footer = cva("primary-body4", {
626
- variants: {
627
- isError: {
628
- true: "text-status-negative",
629
- false: "text-functional-text-light"
734
+ },
735
+ compoundVariants: [
736
+ /** Primary */
737
+ {
738
+ color: "primary",
739
+ isSelected: false,
740
+ className: "text-functional-border-darker peer-hover:text-functional-hover-primary"
741
+ },
742
+ {
743
+ color: "primary",
744
+ isSelected: true,
745
+ className: "text-primary peer-hover:text-functional-hover-primary"
746
+ },
747
+ {
748
+ color: "primary",
749
+ disabled: true,
750
+ className: "text-functional-disable-text peer-hover:text-functional-disable-text"
751
+ },
752
+ /** Primary (dark) */
753
+ {
754
+ color: "primary-dark",
755
+ isSelected: false,
756
+ className: "text-functional-text peer-hover:text-functional-hover-primary"
757
+ },
758
+ {
759
+ color: "primary-dark",
760
+ isSelected: true,
761
+ className: "text-primary-700 peer-hover:text-primary-500"
762
+ },
763
+ {
764
+ color: "primary-dark",
765
+ disabled: true,
766
+ className: "text-functional-disable-text peer-hover:text-functional-disable-text"
767
+ },
768
+ /** Secondary */
769
+ {
770
+ color: "secondary",
771
+ isSelected: false,
772
+ className: "text-functional-border-darker peer-hover:text-blue-700"
773
+ },
774
+ {
775
+ color: "secondary",
776
+ isSelected: true,
777
+ className: "text-blue-600 peer-hover:text-blue-700"
778
+ },
779
+ {
780
+ color: "secondary",
781
+ disabled: true,
782
+ className: "text-functional-disable-text peer-hover:text-functional-disable-text"
783
+ },
784
+ /** Secondary (dark) */
785
+ {
786
+ color: "secondary-dark",
787
+ isSelected: false,
788
+ className: "text-functional-text peer-hover:text-blue-600"
789
+ },
790
+ {
791
+ color: "secondary-dark",
792
+ isSelected: true,
793
+ className: "text-blue-700 peer-hover:text-blue-600"
794
+ },
795
+ {
796
+ color: "secondary-dark",
797
+ disabled: true,
798
+ className: "text-functional-disable-text peer-hover:text-functional-disable-text"
630
799
  }
631
- }
800
+ ]
632
801
  });
633
- var skeleton = cva("w-full", {
802
+ var label = cva("max-w-[152px] break-words text-functional-text", {
634
803
  variants: {
635
- type: {
636
- label: "h-[20px]",
637
- input: "h-[38px]",
638
- footer: "h-[16px]"
804
+ color: {},
805
+ disabled: {
806
+ true: "text-functional-disable-text"
639
807
  }
640
- }
808
+ },
809
+ compoundVariants: [
810
+ {
811
+ color: "primary",
812
+ disabled: false,
813
+ className: "text-functional-text"
814
+ },
815
+ {
816
+ color: "primary",
817
+ disabled: true,
818
+ className: "text-functional-disable-text"
819
+ },
820
+ {
821
+ color: "primary-dark",
822
+ disabled: false,
823
+ className: "font-semibold text-functional-text"
824
+ },
825
+ {
826
+ color: "primary-dark",
827
+ disabled: true,
828
+ className: "font-semibold text-functional-disable-text"
829
+ },
830
+ {
831
+ color: "secondary",
832
+ disabled: false,
833
+ className: "text-functional-text"
834
+ },
835
+ {
836
+ color: "secondary",
837
+ disabled: true,
838
+ className: "text-functional-disable-text"
839
+ },
840
+ {
841
+ color: "secondary-dark",
842
+ disabled: false,
843
+ className: "font-semibold text-functional-text"
844
+ },
845
+ {
846
+ color: "secondary-dark",
847
+ disabled: true,
848
+ className: "font-semibold text-functional-disable-text"
849
+ }
850
+ ]
641
851
  });
642
- var CubeInputSkeleton = (props) => {
643
- const { type } = props;
644
- return /* @__PURE__ */ jsx(CubeSkeleton, { className: skeleton({ type }) });
852
+ var CubeCheckboxSkeleton = () => /* @__PURE__ */ jsxs("div", { className: "inline-flex gap-x-2", children: [
853
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "size-5" }),
854
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "h-5 w-[152px]" })
855
+ ] });
856
+ var CubeCheckboxGrid = (props) => {
857
+ const { children, className: classNameProp, direction } = props;
858
+ const className = twMerge(
859
+ direction === "vertical" ? "flex flex-col gap-y-3" : "grid grid-cols-[repeat(auto-fill,180px)] gap-x-4 gap-y-6",
860
+ classNameProp
861
+ );
862
+ return /* @__PURE__ */ jsx("div", { className, children });
645
863
  };
646
- var CubeInput = forwardRef(
647
- (props, ref) => {
648
- const {
649
- className,
650
- required = false,
651
- isLoading = false,
652
- label,
653
- tooltip,
654
- helpMessage,
655
- errorMessage,
656
- trailingIcon,
657
- disabled,
658
- ...restProps
659
- } = props;
660
- const defaultId = useId();
661
- const inputId = restProps.id || defaultId;
662
- const isError = !!errorMessage && typeof errorMessage === "string";
663
- const hasFooter = !!helpMessage || isError;
664
- const hasIcon = !!trailingIcon;
665
- const renderLabel = () => {
666
- if (!label && !tooltip) return null;
667
- if (isLoading) return /* @__PURE__ */ jsx(CubeInputSkeleton, { type: "label" });
668
- return /* @__PURE__ */ jsxs("div", { className: "primary-body2 flex items-center space-x-1", children: [
864
+ var CubeCheckbox = (props) => {
865
+ const {
866
+ containerClassName,
867
+ color = "primary",
868
+ label: label6,
869
+ labelSize = "md",
870
+ labelClassName,
871
+ id,
872
+ defaultChecked = false,
873
+ checked: controlledChecked,
874
+ onChange: onControlledCheckedChange,
875
+ disabled,
876
+ isLoading = false,
877
+ ref,
878
+ ...restProps
879
+ } = props;
880
+ const [uncontrolledChecked, setUncontrolledChecked] = useState(defaultChecked);
881
+ const isControlled = controlledChecked !== void 0;
882
+ const effectiveChecked = isControlled ? controlledChecked : uncontrolledChecked;
883
+ const isIndeterminate = effectiveChecked === null;
884
+ const handleChange = (event) => {
885
+ if (!isControlled) {
886
+ setUncontrolledChecked(event.target.checked);
887
+ }
888
+ onControlledCheckedChange?.(event);
889
+ };
890
+ const renderIcon = () => {
891
+ const IconComponent = (() => {
892
+ if (isIndeterminate) return CheckboxUndeterminateFilled_default;
893
+ return effectiveChecked ? CheckboxCheckedFilled_default : Checkbox_default;
894
+ })();
895
+ return /* @__PURE__ */ jsx(
896
+ "div",
897
+ {
898
+ className: twMerge(
899
+ iconWrap({
900
+ color,
901
+ isSelected: effectiveChecked || isIndeterminate,
902
+ disabled
903
+ })
904
+ ),
905
+ children: /* @__PURE__ */ jsx(IconComponent, { className: "icon-md" })
906
+ }
907
+ );
908
+ };
909
+ if (isLoading) return /* @__PURE__ */ jsx(CubeCheckboxSkeleton, {});
910
+ return /* @__PURE__ */ jsxs(
911
+ "label",
912
+ {
913
+ htmlFor: id,
914
+ className: twMerge(
915
+ container({ labelSize, disabled }),
916
+ containerClassName
917
+ ),
918
+ children: [
669
919
  /* @__PURE__ */ jsx(
670
- "label",
920
+ "input",
671
921
  {
672
- htmlFor: inputId,
673
- className: "font-semibold text-functional-title",
674
- children: label
922
+ ...restProps,
923
+ id,
924
+ ref,
925
+ type: "checkbox",
926
+ checked: effectiveChecked ?? false,
927
+ onChange: handleChange,
928
+ disabled,
929
+ className: "peer hidden"
675
930
  }
676
931
  ),
677
- required && /* @__PURE__ */ jsx("span", { className: "text-status-negative", children: "*" }),
678
- tooltip
679
- ] });
932
+ renderIcon(),
933
+ label6 && /* @__PURE__ */ jsx(
934
+ "span",
935
+ {
936
+ className: twMerge(label({ color, disabled }), labelClassName),
937
+ children: label6
938
+ }
939
+ )
940
+ ]
941
+ }
942
+ );
943
+ };
944
+ CubeCheckbox.Skeleton = CubeCheckboxSkeleton;
945
+ CubeCheckbox.Grid = CubeCheckboxGrid;
946
+ var UseFloatingExternalContext = createContext({});
947
+
948
+ // src/internals/utils/floating/splitPlacements.ts
949
+ var splitPlacements = (placement) => {
950
+ const [verticalPlacement, ...horizontalPlacementParts] = placement.split("-");
951
+ const horizontalPlacement = horizontalPlacementParts.join("-");
952
+ return [verticalPlacement, horizontalPlacement];
953
+ };
954
+
955
+ // src/internals/utils/floating/autoPlacement/computeIdealPlacement.ts
956
+ var computeIdealPlacement = (placement, overflowPx) => {
957
+ const [vertical, horizontal] = splitPlacements(placement);
958
+ let newVertical = vertical;
959
+ let newHorizontal = horizontal;
960
+ if (shouldFlipVertically(vertical, overflowPx)) {
961
+ newVertical = flipVerticalPlacement(vertical);
962
+ }
963
+ if (horizontal !== "follow-cursor") {
964
+ if (overflowPx.left > 0) {
965
+ newHorizontal = "left";
966
+ } else if (overflowPx.right > 0) {
967
+ newHorizontal = "right";
968
+ }
969
+ }
970
+ return `${newVertical}-${newHorizontal}`;
971
+ };
972
+ var shouldFlipVertically = (verticalPlacement, overflowPx) => {
973
+ return verticalPlacement === "top" && overflowPx.top > 0 || verticalPlacement === "bottom" && overflowPx.bottom > 0;
974
+ };
975
+ var flipVerticalPlacement = (verticalPlacement) => {
976
+ const flippedMap = {
977
+ top: "bottom",
978
+ bottom: "top"
979
+ };
980
+ return flippedMap[verticalPlacement];
981
+ };
982
+
983
+ // src/internals/utils/floating/rect/computeXBound.ts
984
+ var computeXBound = (anchorDomRect, elementWidth, horizontalPlacement, xOffset, mouseX) => {
985
+ const fn = computeFn[horizontalPlacement];
986
+ return fn(anchorDomRect, elementWidth, xOffset, mouseX);
987
+ };
988
+ var computeFn = {
989
+ left: (anchorDomRect, elementWidth, xOffset) => {
990
+ const left = anchorDomRect.left - xOffset;
991
+ return {
992
+ left,
993
+ right: left + elementWidth
680
994
  };
681
- const renderIcon = () => {
682
- const errorIcon = (() => {
683
- if (!isError) return null;
684
- return /* @__PURE__ */ jsx(WarningFilled_default, { className: "icon-md text-status-negative" });
685
- })();
686
- const customIcon2 = (() => {
687
- if (!hasIcon) return null;
688
- return cloneElement(trailingIcon, {
689
- className: twMerge(
690
- trailingIcon.props.className,
691
- // Overrides icon size, color, and cursor style within the input.
692
- customIcon({ disabled })
693
- )
694
- });
695
- })();
696
- return /* @__PURE__ */ jsxs("span", { className: "absolute right-0 flex h-4 shrink-0 -translate-x-4 items-center justify-center gap-2 overflow-hidden", children: [
697
- errorIcon,
698
- customIcon2
699
- ] });
995
+ },
996
+ center: (anchorDomRect, elementWidth) => {
997
+ const left = anchorDomRect.left + anchorDomRect.width / 2 - elementWidth / 2;
998
+ return {
999
+ left,
1000
+ right: left + elementWidth
700
1001
  };
701
- const renderInput = () => {
702
- if (isLoading) return /* @__PURE__ */ jsx(CubeInputSkeleton, { type: "input" });
703
- return /* @__PURE__ */ jsx(
704
- "input",
705
- {
706
- ...restProps,
707
- id: inputId,
708
- ref,
709
- disabled,
710
- className: twMerge(input({ isError, disabled, hasIcon }), className),
711
- required
712
- }
713
- );
1002
+ },
1003
+ right: (anchorDomRect, elementWidth, xOffset) => {
1004
+ const right = anchorDomRect.right + xOffset;
1005
+ return {
1006
+ left: right - elementWidth,
1007
+ right
714
1008
  };
715
- const renderFooter = () => {
716
- if (!hasFooter) return null;
717
- if (isLoading) return /* @__PURE__ */ jsx(CubeInputSkeleton, { type: "footer" });
718
- return /* @__PURE__ */ jsx("div", { className: twMerge(footer({ isError })), children: errorMessage ?? helpMessage });
1009
+ },
1010
+ "follow-cursor": (_anchorDomRect, elementWidth, _xOffset, mouseX) => {
1011
+ const left = mouseX - elementWidth / 2;
1012
+ return {
1013
+ left,
1014
+ right: left + elementWidth
719
1015
  };
720
- return /* @__PURE__ */ jsxs("div", { className: "min-w-[202px] space-y-[6px]", children: [
721
- renderLabel(),
722
- /* @__PURE__ */ jsxs("div", { className: "relative flex items-center", children: [
723
- renderInput(),
724
- renderIcon()
725
- ] }),
726
- renderFooter()
727
- ] });
728
1016
  }
729
- );
730
- CubeInput.displayName = "CubeInput";
731
- var CubePasswordInput = (props) => {
732
- const { initialShowPassword = false, disabled, ...restProps } = props;
733
- const [showPassword, setShowPassword] = useState(initialShowPassword);
734
- const handleShowHide = () => {
735
- setShowPassword((prev) => !prev);
1017
+ };
1018
+
1019
+ // src/internals/utils/floating/rect/computeYBound.ts
1020
+ var computeYBound = (anchorDomRect, elementHeight, verticalPlacement, yOffset) => {
1021
+ const fn = computeFn2[verticalPlacement];
1022
+ return fn(anchorDomRect, elementHeight, yOffset);
1023
+ };
1024
+ var computeFn2 = {
1025
+ top: (anchorDomRect, elementHeight, yOffset) => {
1026
+ const bottom = anchorDomRect.top - yOffset;
1027
+ return {
1028
+ top: bottom - elementHeight,
1029
+ bottom
1030
+ };
1031
+ },
1032
+ bottom: (anchorDomRect, elementHeight, yOffset) => {
1033
+ const top = anchorDomRect.bottom + yOffset;
1034
+ return {
1035
+ top,
1036
+ bottom: top + elementHeight
1037
+ };
1038
+ }
1039
+ };
1040
+
1041
+ // src/internals/utils/floating/rect/computeFloatingBoundary.ts
1042
+ var computeFloatingBoundary = (anchorDomRect, elementSize, placement, offsets, mouseX) => {
1043
+ const [verticalPlacement, horizontalPlacement] = splitPlacements(placement);
1044
+ const xBound = computeXBound(
1045
+ anchorDomRect,
1046
+ elementSize.width,
1047
+ horizontalPlacement,
1048
+ offsets?.x ?? 0,
1049
+ mouseX ?? 0
1050
+ );
1051
+ const yBound = computeYBound(
1052
+ anchorDomRect,
1053
+ elementSize.height,
1054
+ verticalPlacement,
1055
+ offsets?.y ?? 0
1056
+ );
1057
+ return {
1058
+ ...xBound,
1059
+ ...yBound
736
1060
  };
737
- const IconComponent = showPassword ? View_default : ViewOff_default;
738
- return /* @__PURE__ */ jsx(
739
- CubeInput,
740
- {
741
- ...restProps,
742
- type: showPassword ? "text" : "password",
743
- disabled,
744
- trailingIcon: /* @__PURE__ */ jsx(IconComponent, { onClick: disabled ? void 0 : handleShowHide })
1061
+ };
1062
+
1063
+ // src/internals/utils/floating/rect/computeTranslateX.ts
1064
+ var computeTranslateX = (placement, overflowPx) => {
1065
+ const [, horizontalPlacement] = splitPlacements(placement);
1066
+ if (horizontalPlacement !== "follow-cursor") return 0;
1067
+ if (overflowPx.left > 0) {
1068
+ return overflowPx.left;
1069
+ }
1070
+ if (overflowPx.right > 0) {
1071
+ return -1 * overflowPx.right;
1072
+ }
1073
+ return 0;
1074
+ };
1075
+
1076
+ // src/internals/utils/floating/rect/FloatingRect.ts
1077
+ var FloatingRect = class {
1078
+ _anchorDomRect;
1079
+ _size;
1080
+ _originalPlacement;
1081
+ _offsets = void 0;
1082
+ _mouseX = 0;
1083
+ constructor(args) {
1084
+ const { anchorDomRect, size, placement, offsets, mouseX } = args;
1085
+ this._anchorDomRect = anchorDomRect;
1086
+ this._size = size;
1087
+ this._originalPlacement = placement;
1088
+ this._offsets = offsets;
1089
+ this._mouseX = mouseX ?? 0;
1090
+ }
1091
+ resolveStyles() {
1092
+ const floatingBoundary = computeFloatingBoundary(
1093
+ this._anchorDomRect,
1094
+ this._size,
1095
+ this._originalPlacement,
1096
+ this._offsets,
1097
+ this._mouseX
1098
+ );
1099
+ let finalBoundary = { ...floatingBoundary };
1100
+ const overflowPx = this.computeOverflowPx(floatingBoundary);
1101
+ const idealPlacement = computeIdealPlacement(
1102
+ this._originalPlacement,
1103
+ overflowPx
1104
+ );
1105
+ if (idealPlacement !== this._originalPlacement) {
1106
+ finalBoundary = computeFloatingBoundary(
1107
+ this._anchorDomRect,
1108
+ this._size,
1109
+ idealPlacement,
1110
+ this._offsets,
1111
+ this._mouseX
1112
+ );
1113
+ }
1114
+ const translateX = computeTranslateX(idealPlacement, overflowPx);
1115
+ const floatingStyle = {
1116
+ position: "absolute",
1117
+ // Convert the position from viewport-relative coordinates to document-relative coordinates.
1118
+ top: finalBoundary.top + window.scrollY,
1119
+ left: finalBoundary.left + window.scrollX + translateX
1120
+ };
1121
+ return {
1122
+ idealPlacement,
1123
+ floatingStyle,
1124
+ translateX
1125
+ };
1126
+ }
1127
+ computeOverflowPx(floatingBoundary) {
1128
+ const { top, left } = floatingBoundary;
1129
+ const { clientWidth, clientHeight } = document.documentElement;
1130
+ return {
1131
+ top: top < 0 ? Math.abs(top) : 0,
1132
+ right: Math.max(floatingBoundary.right - clientWidth, 0),
1133
+ bottom: Math.max(floatingBoundary.bottom - clientHeight, 0),
1134
+ left: left < 0 ? Math.abs(left) : 0
1135
+ };
1136
+ }
1137
+ };
1138
+ var isRectEqual = (rectA, rectB) => {
1139
+ if (!rectA && !rectB) return true;
1140
+ if (!!rectA !== !!rectB) return false;
1141
+ const keys = [
1142
+ "top",
1143
+ "right",
1144
+ "bottom",
1145
+ "left",
1146
+ "width",
1147
+ "height",
1148
+ "x",
1149
+ "y"
1150
+ ];
1151
+ return keys.every((key) => rectA[key] === rectB[key]);
1152
+ };
1153
+ var useElementDomRect = (elementRef, scrollableRootSelector) => {
1154
+ const [rect, setRect] = useState();
1155
+ const getScrollableRoot = useCallback(() => {
1156
+ if (scrollableRootSelector) {
1157
+ const element = document.querySelector(scrollableRootSelector);
1158
+ if (!element) {
1159
+ console.warn(
1160
+ `Cannot find element with selector ${scrollableRootSelector}`
1161
+ );
1162
+ }
1163
+ return element;
1164
+ } else {
1165
+ return window;
745
1166
  }
1167
+ }, [scrollableRootSelector]);
1168
+ useEffect(() => {
1169
+ const syncRect = () => {
1170
+ setRect((prevRect) => {
1171
+ const currentRect = elementRef.current?.getBoundingClientRect();
1172
+ if (isRectEqual(prevRect, currentRect)) return prevRect;
1173
+ return currentRect;
1174
+ });
1175
+ };
1176
+ const debouncedSync = debounce(syncRect, 100);
1177
+ syncRect();
1178
+ const scrollableRoot = getScrollableRoot();
1179
+ scrollableRoot?.addEventListener("scroll", debouncedSync);
1180
+ scrollableRoot?.addEventListener("resize", debouncedSync);
1181
+ const intervalId = setInterval(() => {
1182
+ syncRect();
1183
+ }, 250);
1184
+ return () => {
1185
+ scrollableRoot?.removeEventListener("scroll", debouncedSync);
1186
+ scrollableRoot?.removeEventListener("resize", debouncedSync);
1187
+ clearInterval(intervalId);
1188
+ };
1189
+ }, [elementRef, getScrollableRoot]);
1190
+ return rect;
1191
+ };
1192
+
1193
+ // src/internals/utils/floating/useFloating.ts
1194
+ var createInvisibleFloatingStyles = (originalPlacement) => ({
1195
+ idealPlacement: originalPlacement,
1196
+ floatingStyle: {
1197
+ position: "absolute",
1198
+ visibility: "hidden",
1199
+ top: "-9999px",
1200
+ left: "-9999px"
1201
+ },
1202
+ translateX: 0
1203
+ });
1204
+ var useFloating = (options) => {
1205
+ const {
1206
+ isOpen,
1207
+ anchorRef: anchorRefOption,
1208
+ placement,
1209
+ offsets,
1210
+ mouseX = 0
1211
+ } = options;
1212
+ const anchorRef = useRef(null);
1213
+ const elementRef = useRef(null);
1214
+ const { scrollableRootSelector } = useContext(UseFloatingExternalContext);
1215
+ const anchorRect = useElementDomRect(
1216
+ anchorRefOption ?? anchorRef,
1217
+ scrollableRootSelector
746
1218
  );
1219
+ const elementRect = useElementDomRect(elementRef, scrollableRootSelector);
1220
+ const resolvedStyles = useMemo(() => {
1221
+ if (!anchorRect || !elementRect) return void 0;
1222
+ if (!isOpen) return createInvisibleFloatingStyles(placement);
1223
+ const floatingRect = new FloatingRect({
1224
+ anchorDomRect: anchorRect,
1225
+ size: {
1226
+ width: elementRect.width,
1227
+ height: elementRect.height
1228
+ },
1229
+ placement,
1230
+ offsets,
1231
+ mouseX
1232
+ });
1233
+ return floatingRect.resolveStyles();
1234
+ }, [isOpen, anchorRect, elementRect, placement, offsets, mouseX]);
1235
+ return {
1236
+ anchorRef,
1237
+ elementRef,
1238
+ resolvedStyles
1239
+ };
747
1240
  };
748
1241
 
749
1242
  // src/i18n/resources/en-US.json
750
1243
  var en_US_default = {
751
1244
  "component.common.loading": "Loading",
752
- "component.common.noData": "No Data"
1245
+ "component.common.noData": "No Data",
1246
+ "component.dropdown.choose": "Choose",
1247
+ "component.dropdown.all": "All",
1248
+ "component.dropdown.search": "Search",
1249
+ "component.status.host.neutral": "Neutral",
1250
+ "component.status.host.inUse": "In-Use",
1251
+ "component.status.host.finished": "Finished",
1252
+ "component.status.host.ok": "Ok",
1253
+ "component.status.host.success": "Success",
1254
+ "component.status.host.active": "Active",
1255
+ "component.status.host.available": "Available",
1256
+ "component.status.host.poweringOn": "Powering-On",
1257
+ "component.status.host.warning": "Warning",
1258
+ "component.status.host.error": "Error",
1259
+ "component.status.host.fail": "Fail",
1260
+ "component.status.host.failed": "Failed",
1261
+ "component.status.host.stopped": "Stopped",
1262
+ "component.status.host.poweringOff": "Powering-Off",
1263
+ "component.status.reaction.neutral": "Neutral",
1264
+ "component.status.reaction.success": "Success",
1265
+ "component.status.reaction.available": "Available",
1266
+ "component.status.reaction.done": "Done",
1267
+ "component.status.reaction.error": "Error",
1268
+ "component.status.reaction.duplicate": "Duplicate",
1269
+ "component.status.reaction.failed": "Failed"
753
1270
  };
754
1271
 
755
1272
  // src/i18n/resources/zh-TW.json
756
1273
  var zh_TW_default = {
757
1274
  "component.common.loading": "\u8F09\u5165\u4E2D",
758
- "component.common.noData": "\u6C92\u6709\u8CC7\u6599"
1275
+ "component.common.noData": "\u6C92\u6709\u8CC7\u6599",
1276
+ "component.dropdown.choose": "\u9078\u64C7",
1277
+ "component.dropdown.all": "\u5168\u90E8",
1278
+ "component.dropdown.search": "\u641C\u5C0B",
1279
+ "component.status.host.neutral": "\u4E2D\u6027",
1280
+ "component.status.host.inUse": "\u4F7F\u7528\u4E2D",
1281
+ "component.status.host.finished": "\u5DF2\u5B8C\u6210",
1282
+ "component.status.host.ok": "\u6B63\u5E38",
1283
+ "component.status.host.success": "\u6210\u529F",
1284
+ "component.status.host.active": "\u555F\u7528",
1285
+ "component.status.host.available": "\u53EF\u7528",
1286
+ "component.status.host.poweringOn": "\u555F\u52D5\u4E2D",
1287
+ "component.status.host.warning": "\u8B66\u544A",
1288
+ "component.status.host.error": "\u932F\u8AA4",
1289
+ "component.status.host.fail": "\u5931\u6557",
1290
+ "component.status.host.failed": "\u5DF2\u5931\u6557",
1291
+ "component.status.host.stopped": "\u5DF2\u505C\u6B62",
1292
+ "component.status.host.poweringOff": "\u95DC\u6A5F\u4E2D",
1293
+ "component.status.reaction.neutral": "\u4E2D\u6027",
1294
+ "component.status.reaction.success": "\u6210\u529F",
1295
+ "component.status.reaction.available": "\u53EF\u7528",
1296
+ "component.status.reaction.done": "\u5B8C\u6210",
1297
+ "component.status.reaction.error": "\u932F\u8AA4",
1298
+ "component.status.reaction.duplicate": "\u91CD\u8907",
1299
+ "component.status.reaction.failed": "\u5931\u6557"
759
1300
  };
760
1301
 
761
1302
  // src/i18n/i18n.ts
@@ -774,23 +1315,2779 @@ i18n.use(initReactI18next).init({
774
1315
  });
775
1316
  var i18n_default = i18n;
776
1317
 
777
- // src/i18n/addCubeUiTranslations.ts
778
- function addCubeUiTranslations(locale, resources) {
779
- i18n_default.addResourceBundle(locale, "translation", resources, true, true);
780
- if (i18n_default.isInitialized) {
781
- i18n_default.emit("languageChanged", i18n_default.language);
782
- }
783
- }
784
- var CubeUiLocaleProvider = (props) => {
785
- const { locale, children } = props;
786
- useEffect(() => {
787
- i18n_default.changeLanguage(locale);
788
- }, [locale]);
789
- return children;
790
- };
1318
+ // src/i18n/useCubeUiTranslation.ts
791
1319
  var useCubeUiTranslation = (ns, options) => {
792
1320
  return useTranslation(ns, { ...options, i18n: i18n_default });
793
1321
  };
1322
+ var CubeDropdownContext = createContext({
1323
+ floatingProps: void 0,
1324
+ dropdownOpen: false,
1325
+ toggleDropdownOpen: () => {
1326
+ },
1327
+ size: "md",
1328
+ type: "radio",
1329
+ variant: "regular",
1330
+ disabled: false,
1331
+ selectedItems: [],
1332
+ enabledItemCount: 0,
1333
+ onAllCheckChange: void 0,
1334
+ onClearSelection: void 0,
1335
+ searchValue: "",
1336
+ handleSearchValueChange: void 0
1337
+ });
1338
+ var label2 = cva("primary-body3 font-semibold text-functional-title", {
1339
+ variants: {
1340
+ size: {
1341
+ md: "mb-2",
1342
+ sm: "mb-1.5"
1343
+ }
1344
+ }
1345
+ });
1346
+ var skeletonContainer = cva("w-full", {
1347
+ variants: {
1348
+ size: {
1349
+ md: "space-y-[8px]",
1350
+ sm: "space-y-[6px]"
1351
+ }
1352
+ }
1353
+ });
1354
+ var skeletonInput = cva("w-full", {
1355
+ variants: {
1356
+ size: {
1357
+ md: "h-[38px]",
1358
+ sm: "h-[34px]"
1359
+ }
1360
+ }
1361
+ });
1362
+ var triggerContainer = cva(
1363
+ "primary-body3 flex w-full items-center justify-between gap-x-3 rounded-[5px] border",
1364
+ {
1365
+ variants: {
1366
+ size: {
1367
+ md: "h-[38px] min-w-[116px] max-w-[360px] px-4 py-[10px]",
1368
+ sm: "h-[34px] min-w-[80px] max-w-[240px] px-3 py-2"
1369
+ },
1370
+ variant: {
1371
+ regular: "",
1372
+ withFilter: ""
1373
+ },
1374
+ dropdownOpen: {
1375
+ true: "",
1376
+ false: ""
1377
+ },
1378
+ isSelected: {
1379
+ true: "",
1380
+ false: ""
1381
+ },
1382
+ disabled: {
1383
+ true: "",
1384
+ false: ""
1385
+ }
1386
+ },
1387
+ compoundVariants: [
1388
+ // Regular Dropdown
1389
+ {
1390
+ variant: "regular",
1391
+ dropdownOpen: false,
1392
+ isSelected: false,
1393
+ disabled: false,
1394
+ class: [
1395
+ "hover:border-functional-hover-primary",
1396
+ "border-functional-border-divider",
1397
+ "text-functional-text-light",
1398
+ "bg-white"
1399
+ ]
1400
+ },
1401
+ {
1402
+ variant: "regular",
1403
+ dropdownOpen: false,
1404
+ isSelected: true,
1405
+ disabled: false,
1406
+ class: [
1407
+ "hover:border-functional-hover-primary",
1408
+ "border-functional-border-divider",
1409
+ "text-functional-text",
1410
+ "bg-white"
1411
+ ]
1412
+ },
1413
+ {
1414
+ variant: "regular",
1415
+ dropdownOpen: false,
1416
+ isSelected: false,
1417
+ disabled: true,
1418
+ class: [
1419
+ "hover:border-functional-border-divider",
1420
+ "border-functional-border-divider",
1421
+ "text-functional-disable-text",
1422
+ "bg-white"
1423
+ ]
1424
+ },
1425
+ {
1426
+ variant: "regular",
1427
+ dropdownOpen: false,
1428
+ isSelected: true,
1429
+ disabled: true,
1430
+ class: [
1431
+ "hover:border-functional-border-divider",
1432
+ "border-functional-border-divider",
1433
+ "text-functional-disable-text",
1434
+ "bg-white"
1435
+ ]
1436
+ },
1437
+ {
1438
+ variant: "regular",
1439
+ dropdownOpen: true,
1440
+ isSelected: false,
1441
+ disabled: false,
1442
+ class: [
1443
+ "border-functional-hover-primary",
1444
+ "text-functional-text-light",
1445
+ "bg-white"
1446
+ ]
1447
+ },
1448
+ {
1449
+ variant: "regular",
1450
+ dropdownOpen: true,
1451
+ isSelected: true,
1452
+ disabled: false,
1453
+ class: [
1454
+ "border-functional-hover-primary",
1455
+ "text-functional-text",
1456
+ "bg-white"
1457
+ ]
1458
+ },
1459
+ // Dropdown with filter
1460
+ {
1461
+ variant: "withFilter",
1462
+ isSelected: false,
1463
+ disabled: false,
1464
+ class: [
1465
+ "hover:border-blue-700",
1466
+ "border-blue-700",
1467
+ "text-functional-text",
1468
+ "bg-white"
1469
+ ]
1470
+ },
1471
+ {
1472
+ variant: "withFilter",
1473
+ isSelected: true,
1474
+ disabled: false,
1475
+ class: [
1476
+ "hover:border-blue-800 hover:bg-secondary-100",
1477
+ "border-blue-700",
1478
+ "text-blue-850",
1479
+ "bg-secondary-50"
1480
+ ]
1481
+ },
1482
+ {
1483
+ variant: "withFilter",
1484
+ isSelected: false,
1485
+ disabled: true,
1486
+ class: [
1487
+ "hover:border-blue-200",
1488
+ "border-blue-200",
1489
+ "text-functional-disable-text",
1490
+ "bg-white"
1491
+ ]
1492
+ },
1493
+ {
1494
+ variant: "withFilter",
1495
+ isSelected: true,
1496
+ disabled: true,
1497
+ class: [
1498
+ "hover:border-blue-200",
1499
+ "border-blue-200",
1500
+ "text-functional-disable-text",
1501
+ "bg-secondary-0"
1502
+ ]
1503
+ }
1504
+ ]
1505
+ }
1506
+ );
1507
+ var triggerIcon = cva("icon-md shrink-0 transition-transform", {
1508
+ variants: {
1509
+ dropdownOpen: {
1510
+ true: "rotate-180",
1511
+ false: "rotate-0"
1512
+ },
1513
+ disabled: {
1514
+ true: "text-functional-disable-text",
1515
+ false: "text-functional-text"
1516
+ }
1517
+ }
1518
+ });
1519
+ var triggerCount = cva("primary-body3", {
1520
+ variants: {
1521
+ variant: {
1522
+ regular: "",
1523
+ withFilter: ""
1524
+ },
1525
+ disabled: {
1526
+ true: "",
1527
+ false: ""
1528
+ }
1529
+ },
1530
+ compoundVariants: [
1531
+ {
1532
+ variant: "regular",
1533
+ disabled: true,
1534
+ class: "text-functional-disable-text"
1535
+ },
1536
+ {
1537
+ variant: "regular",
1538
+ disabled: false,
1539
+ class: "text-functional-text-light"
1540
+ },
1541
+ {
1542
+ variant: "withFilter",
1543
+ disabled: true,
1544
+ class: "text-functional-disable-text"
1545
+ },
1546
+ { variant: "withFilter", disabled: false, class: "text-blue-850" }
1547
+ ]
1548
+ });
1549
+ var triggerClearButton = cva("icon-md text-functional-text-light", {
1550
+ variants: {
1551
+ disabled: {
1552
+ true: "hidden"
1553
+ }
1554
+ }
1555
+ });
1556
+ var menu = cva(
1557
+ [
1558
+ "z-10 overflow-y-auto rounded-[5px] border bg-white py-2",
1559
+ "shadow-[0_0_2px_0_rgba(0,0,0,0.2)]"
1560
+ ],
1561
+ {
1562
+ variants: {
1563
+ size: {
1564
+ md: "max-h-[442px] min-w-[116px] max-w-[360px]",
1565
+ sm: "max-h-[390px] min-w-[80px] max-w-[240px]"
1566
+ },
1567
+ dropdownOpen: { false: "invisible" }
1568
+ }
1569
+ }
1570
+ );
1571
+ var filterContainer = cva("relative flex shrink-0 items-center", {
1572
+ variants: {
1573
+ size: {
1574
+ md: "",
1575
+ sm: ""
1576
+ },
1577
+ type: {
1578
+ radio: "",
1579
+ checkbox: ""
1580
+ }
1581
+ },
1582
+ compoundVariants: [
1583
+ { size: "md", type: "radio", class: "px-[24px] py-[10px]" },
1584
+ { size: "md", type: "checkbox", class: "px-[22px] py-[11px]" },
1585
+ { size: "sm", type: "radio", class: "px-[24px] py-[9px]" },
1586
+ { size: "sm", type: "checkbox", class: "px-[16px] py-[9.5px]" }
1587
+ ]
1588
+ });
1589
+ var filterInput = cva([
1590
+ "primary-body2 w-full rounded-[5px] px-4 py-[7px] outline-none",
1591
+ "bg-secondary-0 text-functional-text placeholder:text-functional-text-light"
1592
+ ]);
1593
+ var filterIcon = cva(
1594
+ "icon-md absolute shrink-0 text-functional-text",
1595
+ {
1596
+ variants: {
1597
+ size: {
1598
+ md: "",
1599
+ sm: ""
1600
+ },
1601
+ type: {
1602
+ radio: "",
1603
+ checkbox: ""
1604
+ }
1605
+ },
1606
+ compoundVariants: [
1607
+ { size: "md", type: "radio", class: "right-[40px]" },
1608
+ { size: "md", type: "checkbox", class: "right-[38px]" },
1609
+ { size: "sm", type: "radio", class: "right-[40px]" },
1610
+ { size: "sm", type: "checkbox", class: "right-[32px]" }
1611
+ ]
1612
+ }
1613
+ );
1614
+ var itemRadio = cva(
1615
+ "cursor-pointer truncate text-functional-text hover:bg-functional-hover-grey",
1616
+ {
1617
+ variants: {
1618
+ size: {
1619
+ md: "primary-body3",
1620
+ sm: "primary-body4"
1621
+ },
1622
+ variant: {
1623
+ regular: "",
1624
+ withFilter: ""
1625
+ },
1626
+ isSelected: {
1627
+ true: "font-semibold"
1628
+ },
1629
+ disabled: {
1630
+ true: "cursor-default text-functional-disable-text hover:bg-white"
1631
+ }
1632
+ },
1633
+ compoundVariants: [
1634
+ { size: "md", variant: "regular", class: "px-[24px] py-[10px]" },
1635
+ { size: "md", variant: "withFilter", class: "px-[24px] py-[10px]" },
1636
+ { size: "sm", variant: "regular", class: "px-[24px] py-[9px]" },
1637
+ { size: "sm", variant: "withFilter", class: "px-[24px] py-[9px]" }
1638
+ ]
1639
+ }
1640
+ );
1641
+ var itemCheckbox = cva(
1642
+ "truncate text-functional-text hover:bg-functional-hover-grey",
1643
+ {
1644
+ variants: {
1645
+ size: {
1646
+ md: "primary-body3",
1647
+ sm: "primary-body4"
1648
+ },
1649
+ variant: {
1650
+ regular: "",
1651
+ withFilter: ""
1652
+ },
1653
+ isSelected: {
1654
+ true: "font-semibold"
1655
+ },
1656
+ disabled: {
1657
+ true: "cursor-default text-functional-disable-text hover:bg-white"
1658
+ }
1659
+ },
1660
+ compoundVariants: [
1661
+ { size: "md", variant: "regular", class: "px-[22px] py-[11px]" },
1662
+ { size: "md", variant: "withFilter", class: "px-[22px] py-[11px]" },
1663
+ { size: "sm", variant: "regular", class: "px-[16px] py-[9.5px]" },
1664
+ { size: "sm", variant: "withFilter", class: "px-[16px] py-[9.5px]" }
1665
+ ]
1666
+ }
1667
+ );
1668
+ var itemNoData = cva("text-functional-text", {
1669
+ variants: {
1670
+ size: {
1671
+ md: "primary-body3",
1672
+ sm: "primary-body4"
1673
+ },
1674
+ type: {
1675
+ radio: "",
1676
+ checkbox: ""
1677
+ }
1678
+ },
1679
+ compoundVariants: [
1680
+ { size: "md", type: "radio", class: "px-[24px] py-[10px]" },
1681
+ { size: "md", type: "checkbox", class: "px-[22px] py-[11px]" },
1682
+ { size: "sm", type: "radio", class: "px-[24px] py-[9px]" },
1683
+ { size: "sm", type: "checkbox", class: "px-[16px] py-[9.5px]" }
1684
+ ]
1685
+ });
1686
+ var CubeDropdownTrigger = (props) => {
1687
+ const { children, placeholder, className } = props;
1688
+ const {
1689
+ dropdownOpen,
1690
+ toggleDropdownOpen,
1691
+ floatingProps,
1692
+ size,
1693
+ type,
1694
+ variant,
1695
+ selectedItems,
1696
+ disabled,
1697
+ onClearSelection
1698
+ } = useContext(CubeDropdownContext);
1699
+ const { t } = useCubeUiTranslation();
1700
+ const isSelected = selectedItems.length > 0;
1701
+ const placeholderText = placeholder ?? t("component.dropdown.choose");
1702
+ const displayText = isSelected ? children : placeholderText;
1703
+ const renderSelectedItemCount = () => {
1704
+ if (type === "radio" || !isSelected) return null;
1705
+ return /* @__PURE__ */ jsx("p", { className: triggerCount({ variant, disabled }), children: `(${selectedItems.length})` });
1706
+ };
1707
+ const renderClearButton = () => {
1708
+ const handleClearClick = (e) => {
1709
+ e.stopPropagation();
1710
+ onClearSelection?.();
1711
+ };
1712
+ if (type === "checkbox" && variant === "withFilter" && isSelected)
1713
+ return /* @__PURE__ */ jsx(
1714
+ XSmall_default,
1715
+ {
1716
+ className: twMerge(triggerClearButton({ disabled })),
1717
+ onClick: (e) => handleClearClick(e)
1718
+ }
1719
+ );
1720
+ return null;
1721
+ };
1722
+ return /* @__PURE__ */ jsxs(
1723
+ "button",
1724
+ {
1725
+ ref: floatingProps.anchorRef,
1726
+ type: "button",
1727
+ disabled,
1728
+ onClick: toggleDropdownOpen,
1729
+ className: twMerge(
1730
+ triggerContainer({
1731
+ size,
1732
+ variant,
1733
+ dropdownOpen,
1734
+ isSelected,
1735
+ disabled
1736
+ }),
1737
+ className
1738
+ ),
1739
+ children: [
1740
+ /* @__PURE__ */ jsx("span", { className: "w-full truncate text-left", children: displayText }),
1741
+ /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-2", children: [
1742
+ renderSelectedItemCount(),
1743
+ renderClearButton(),
1744
+ /* @__PURE__ */ jsx(
1745
+ ChevronDown_default,
1746
+ {
1747
+ className: twMerge(triggerIcon({ dropdownOpen, disabled }))
1748
+ }
1749
+ )
1750
+ ] })
1751
+ ]
1752
+ }
1753
+ );
1754
+ };
1755
+ var ItemCheckbox = (props) => {
1756
+ const {
1757
+ isDark = false,
1758
+ size,
1759
+ variant,
1760
+ label: label6,
1761
+ onClick,
1762
+ isSelected,
1763
+ disabled
1764
+ } = props;
1765
+ const getColor = () => {
1766
+ if (variant === "regular") {
1767
+ return isDark ? "primary-dark" : "primary";
1768
+ } else {
1769
+ return isDark ? "secondary-dark" : "secondary";
1770
+ }
1771
+ };
1772
+ const getLabelSize = () => {
1773
+ return size === "md" ? "sm" : "xs";
1774
+ };
1775
+ return /* @__PURE__ */ jsx(
1776
+ "div",
1777
+ {
1778
+ className: twMerge(itemCheckbox({ size, variant, isSelected, disabled })),
1779
+ children: /* @__PURE__ */ jsx(
1780
+ CubeCheckbox,
1781
+ {
1782
+ label: label6,
1783
+ labelClassName: "truncate",
1784
+ disabled,
1785
+ checked: isSelected,
1786
+ onChange: onClick,
1787
+ color: getColor(),
1788
+ labelSize: getLabelSize()
1789
+ }
1790
+ )
1791
+ }
1792
+ );
1793
+ };
1794
+ var ItemNoData = (props) => {
1795
+ const { size, type } = props;
1796
+ const { t } = useCubeUiTranslation();
1797
+ return /* @__PURE__ */ jsx("div", { className: twMerge(itemNoData({ size, type })), children: t("component.common.noData") });
1798
+ };
1799
+ var CubeDropdownFilter = () => {
1800
+ const { size, type, searchValue, handleSearchValueChange } = useContext(CubeDropdownContext);
1801
+ const { t } = useCubeUiTranslation();
1802
+ return /* @__PURE__ */ jsxs("div", { className: twMerge(filterContainer({ size, type })), children: [
1803
+ /* @__PURE__ */ jsx(
1804
+ "input",
1805
+ {
1806
+ type: "text",
1807
+ className: twMerge(filterInput()),
1808
+ placeholder: t("component.dropdown.search"),
1809
+ value: searchValue,
1810
+ onChange: handleSearchValueChange
1811
+ }
1812
+ ),
1813
+ /* @__PURE__ */ jsx(Search_default, { className: twMerge(filterIcon({ size, type })) })
1814
+ ] });
1815
+ };
1816
+ var ItemRadio = (props) => {
1817
+ const { size, variant, label: label6, onClick, isSelected, disabled } = props;
1818
+ return /* @__PURE__ */ jsx(
1819
+ "div",
1820
+ {
1821
+ className: twMerge(itemRadio({ size, variant, isSelected, disabled })),
1822
+ onClick,
1823
+ children: label6
1824
+ }
1825
+ );
1826
+ };
1827
+ var CubeDropdownItem = (props) => {
1828
+ const {
1829
+ children: label6,
1830
+ item,
1831
+ disabled = false,
1832
+ onClick: onClickProp
1833
+ } = props;
1834
+ const { size, type, variant, selectedItems, toggleDropdownOpen } = useContext(CubeDropdownContext);
1835
+ const isSelected = selectedItems.includes(item);
1836
+ const onClick = () => {
1837
+ if (disabled) return;
1838
+ onClickProp();
1839
+ if (type === "radio") toggleDropdownOpen();
1840
+ };
1841
+ if (type === "checkbox")
1842
+ return /* @__PURE__ */ jsx(
1843
+ ItemCheckbox,
1844
+ {
1845
+ size,
1846
+ variant,
1847
+ label: label6,
1848
+ isSelected,
1849
+ disabled,
1850
+ onClick
1851
+ }
1852
+ );
1853
+ return /* @__PURE__ */ jsx(
1854
+ ItemRadio,
1855
+ {
1856
+ size,
1857
+ variant,
1858
+ label: label6,
1859
+ isSelected,
1860
+ disabled,
1861
+ onClick
1862
+ }
1863
+ );
1864
+ };
1865
+
1866
+ // src/components/CubeDropdown/cubeDropdownUtils.ts
1867
+ var getOptionalProps = (props) => {
1868
+ return {
1869
+ onAllCheckChange: props.type === "checkbox" ? props.onAllCheckChange : void 0,
1870
+ onClearSelection: props.type === "checkbox" && props.variant === "withFilter" ? props.onClearSelection : void 0
1871
+ };
1872
+ };
1873
+ var checkIsCubeDropdownItemElement = (child) => isValidElement(child) && child.type === CubeDropdownItem;
1874
+ var CubeDropdownMenu = (props) => {
1875
+ const { children, className } = props;
1876
+ const {
1877
+ floatingProps,
1878
+ dropdownOpen,
1879
+ size,
1880
+ variant,
1881
+ type,
1882
+ onAllCheckChange,
1883
+ selectedItems,
1884
+ enabledItemCount,
1885
+ searchValue
1886
+ } = useContext(CubeDropdownContext);
1887
+ const { t } = useCubeUiTranslation();
1888
+ const { elementRef, resolvedStyles } = floatingProps;
1889
+ const isAllSelected = useMemo(() => {
1890
+ return selectedItems.length === enabledItemCount;
1891
+ }, [selectedItems.length, enabledItemCount]);
1892
+ const onAllClick = useCallback(() => {
1893
+ onAllCheckChange?.(!isAllSelected);
1894
+ }, [isAllSelected, onAllCheckChange]);
1895
+ const renderFilter = () => {
1896
+ if (variant === "regular") return null;
1897
+ return /* @__PURE__ */ jsx(CubeDropdownFilter, {});
1898
+ };
1899
+ const renderSelectAllCheckbox = () => {
1900
+ if (type === "radio" || searchValue || !children) return null;
1901
+ return /* @__PURE__ */ jsx(
1902
+ ItemCheckbox,
1903
+ {
1904
+ isDark: true,
1905
+ size,
1906
+ variant,
1907
+ label: t("component.dropdown.all"),
1908
+ onClick: onAllClick,
1909
+ isSelected: isAllSelected,
1910
+ disabled: false
1911
+ }
1912
+ );
1913
+ };
1914
+ const renderMenuItems = () => {
1915
+ const allItems = Children.toArray(children).filter(
1916
+ checkIsCubeDropdownItemElement
1917
+ );
1918
+ const visibleItems = variant !== "withFilter" || !searchValue ? allItems : allItems.filter(
1919
+ (child) => child.props.children.toLowerCase().includes(searchValue.toLowerCase())
1920
+ );
1921
+ if (visibleItems.length === 0) {
1922
+ return /* @__PURE__ */ jsx(ItemNoData, { size, type });
1923
+ }
1924
+ return visibleItems;
1925
+ };
1926
+ return createPortal(
1927
+ /* @__PURE__ */ jsxs(
1928
+ "div",
1929
+ {
1930
+ ref: elementRef,
1931
+ className: twMerge(menu({ size, dropdownOpen }), className),
1932
+ style: resolvedStyles?.floatingStyle,
1933
+ children: [
1934
+ renderFilter(),
1935
+ renderSelectAllCheckbox(),
1936
+ renderMenuItems()
1937
+ ]
1938
+ }
1939
+ ),
1940
+ document.body
1941
+ );
1942
+ };
1943
+ var CubeDropdownSkeleton = (props) => {
1944
+ const { className, size, hasLabel } = props;
1945
+ const renderLabelSkeleton = () => {
1946
+ return hasLabel ? /* @__PURE__ */ jsx(CubeSkeleton, { className: "h-[18px] w-full" }) : null;
1947
+ };
1948
+ return /* @__PURE__ */ jsxs("div", { className: twMerge(skeletonContainer({ size }), className), children: [
1949
+ renderLabelSkeleton(),
1950
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: twMerge(skeletonInput({ size })) })
1951
+ ] });
1952
+ };
1953
+ var parseNodes = (node) => {
1954
+ const payload = {
1955
+ triggerNode: void 0,
1956
+ menuNode: void 0,
1957
+ enabledItemCount: 0
1958
+ };
1959
+ Children.toArray(node).forEach((child) => {
1960
+ if (!isValidElement(child)) {
1961
+ return;
1962
+ }
1963
+ if (child.type === CubeDropdownTrigger) {
1964
+ assignTriggerNode(payload, child);
1965
+ } else if (child.type === CubeDropdownMenu) {
1966
+ assignMenuNode(payload, child);
1967
+ }
1968
+ });
1969
+ return payload;
1970
+ };
1971
+ var assignTriggerNode = (payload, value) => {
1972
+ if (payload.triggerNode) {
1973
+ console.warn(
1974
+ "Found multiple trigger nodes. Only one trigger node is allowed in a CubeDropdown."
1975
+ );
1976
+ } else {
1977
+ payload.triggerNode = value;
1978
+ }
1979
+ };
1980
+ var assignMenuNode = (payload, value) => {
1981
+ if (payload.menuNode) {
1982
+ console.warn(
1983
+ "Found multiple menu nodes. Only one menu node is allowed in a CubeDropdown."
1984
+ );
1985
+ } else {
1986
+ payload.menuNode = value;
1987
+ payload.enabledItemCount = computeEnabledItemCount(
1988
+ Children.toArray(value.props.children)
1989
+ );
1990
+ }
1991
+ };
1992
+ var computeEnabledItemCount = (menuChildren) => {
1993
+ const enabledItems = menuChildren.filter((child) => {
1994
+ if (!isValidElement(child) || child.type !== CubeDropdownItem) {
1995
+ console.warn(
1996
+ "The children of CubeDropdown.Menu can only be CubeDropdown.Item, but found: ",
1997
+ child
1998
+ );
1999
+ return false;
2000
+ }
2001
+ const itemProps = child.props;
2002
+ return !itemProps.disabled;
2003
+ });
2004
+ return enabledItems.length;
2005
+ };
2006
+ var CubeDropdown = (props) => {
2007
+ const {
2008
+ size = "md",
2009
+ type,
2010
+ variant = "regular",
2011
+ selectedItems,
2012
+ isLoading = false,
2013
+ disabled = false,
2014
+ label: label6,
2015
+ skeletonClassName,
2016
+ children
2017
+ } = props;
2018
+ const optionalProps = getOptionalProps(props);
2019
+ const [dropdownOpen, setDropdownOpen] = useState(false);
2020
+ const [searchValue, setSearchValue] = useState("");
2021
+ const toggleDropdownOpen = () => {
2022
+ setDropdownOpen((prev) => !prev);
2023
+ };
2024
+ const handleSearchValueChange = (e) => {
2025
+ setSearchValue(e.target.value);
2026
+ };
2027
+ const floatingProps = useFloating({
2028
+ isOpen: dropdownOpen,
2029
+ placement: "bottom-left",
2030
+ offsets: {
2031
+ y: 8
2032
+ }
2033
+ });
2034
+ const { anchorRef, elementRef } = floatingProps;
2035
+ const { triggerNode, menuNode, enabledItemCount } = parseNodes(children);
2036
+ const handleClickOutside = useCallback(
2037
+ (event) => {
2038
+ const target = event.target;
2039
+ const isTrigger = anchorRef.current?.contains(target);
2040
+ const isMenu = elementRef.current?.contains(target);
2041
+ if (!isTrigger && !isMenu) {
2042
+ setDropdownOpen(false);
2043
+ }
2044
+ },
2045
+ [anchorRef, elementRef]
2046
+ );
2047
+ useEffect(() => {
2048
+ document.addEventListener("mousedown", handleClickOutside);
2049
+ return () => {
2050
+ document.removeEventListener("mousedown", handleClickOutside);
2051
+ };
2052
+ }, [handleClickOutside]);
2053
+ const renderLabel = () => {
2054
+ if (!label6) return null;
2055
+ return /* @__PURE__ */ jsx("p", { className: twMerge(label2({ size })), children: label6 });
2056
+ };
2057
+ if (isLoading) {
2058
+ return /* @__PURE__ */ jsx(
2059
+ CubeDropdownSkeleton,
2060
+ {
2061
+ className: skeletonClassName,
2062
+ size,
2063
+ hasLabel: !!label6
2064
+ }
2065
+ );
2066
+ }
2067
+ return /* @__PURE__ */ jsx(
2068
+ CubeDropdownContext.Provider,
2069
+ {
2070
+ value: {
2071
+ floatingProps,
2072
+ dropdownOpen,
2073
+ toggleDropdownOpen,
2074
+ size,
2075
+ type,
2076
+ variant,
2077
+ disabled,
2078
+ selectedItems,
2079
+ enabledItemCount,
2080
+ onAllCheckChange: optionalProps.onAllCheckChange,
2081
+ onClearSelection: optionalProps.onClearSelection,
2082
+ searchValue,
2083
+ handleSearchValueChange
2084
+ },
2085
+ children: /* @__PURE__ */ jsxs("div", { children: [
2086
+ renderLabel(),
2087
+ triggerNode,
2088
+ menuNode
2089
+ ] })
2090
+ }
2091
+ );
2092
+ };
2093
+ CubeDropdown.Trigger = CubeDropdownTrigger;
2094
+ CubeDropdown.Menu = CubeDropdownMenu;
2095
+ CubeDropdown.Item = CubeDropdownItem;
2096
+ var hyperlink = cva(
2097
+ ["flex cursor-pointer items-center gap-x-1 font-medium"],
2098
+ {
2099
+ variants: {
2100
+ color: {
2101
+ primary: [
2102
+ "text-primary",
2103
+ "hover:text-functional-hover-primary",
2104
+ "visited:text-primary-700"
2105
+ ],
2106
+ secondary: [
2107
+ "text-functional-border-darker",
2108
+ "hover:text-functional-text-light",
2109
+ "visited:text-functional-border-darker"
2110
+ ]
2111
+ },
2112
+ size: {
2113
+ md: "primary-body2",
2114
+ sm: "primary-body4"
2115
+ },
2116
+ variant: {
2117
+ "text-only": "",
2118
+ "text-inline": "underline underline-offset-4",
2119
+ "icon-left": "",
2120
+ "icon-right": ""
2121
+ },
2122
+ disabled: {
2123
+ true: "text-functional-disable-text hover:cursor-default hover:text-functional-disable-text"
2124
+ }
2125
+ }
2126
+ }
2127
+ );
2128
+ var sizeMapping = {
2129
+ sm: { iconSize: "sm", iconFrameSize: "size-[15px]" },
2130
+ md: { iconSize: "md-sm", iconFrameSize: "size-[17px]" }
2131
+ };
2132
+ var CubeHyperlink = (props) => {
2133
+ const {
2134
+ className: classNameProps,
2135
+ color = "primary",
2136
+ size = "md",
2137
+ variant = "text-only",
2138
+ disabled = false,
2139
+ children,
2140
+ href,
2141
+ target,
2142
+ onClick
2143
+ } = props;
2144
+ if (!href && !onClick) {
2145
+ console.warn(
2146
+ "CubeHyperlink: href or onClick must be provided to make the hyperlink interactive"
2147
+ );
2148
+ }
2149
+ const handleClick = (e) => {
2150
+ if (disabled) return;
2151
+ onClick?.(e);
2152
+ };
2153
+ const renderIcon = (iconVariant) => {
2154
+ if (props.variant !== iconVariant) {
2155
+ return null;
2156
+ }
2157
+ const { Icon } = props;
2158
+ const { iconSize, iconFrameSize } = sizeMapping[size];
2159
+ const iconSizeClass = getIconSizeClass(iconSize);
2160
+ return /* @__PURE__ */ jsx(
2161
+ "div",
2162
+ {
2163
+ className: twMerge("flex items-center justify-center", iconFrameSize),
2164
+ children: /* @__PURE__ */ jsx(Icon, { className: iconSizeClass })
2165
+ }
2166
+ );
2167
+ };
2168
+ const renderHyperlink = () => {
2169
+ const hyperlinkType = !disabled && href ? "a" : "div";
2170
+ const hrefAttribute = hyperlinkType === "a" ? href : void 0;
2171
+ const targetAttribute = hyperlinkType === "a" ? target : void 0;
2172
+ return createElement(
2173
+ hyperlinkType,
2174
+ {
2175
+ className: twMerge(
2176
+ hyperlink({ color, size, variant, disabled }),
2177
+ classNameProps
2178
+ ),
2179
+ href: hrefAttribute,
2180
+ target: targetAttribute,
2181
+ onClick: handleClick
2182
+ },
2183
+ renderIcon("icon-left"),
2184
+ children,
2185
+ renderIcon("icon-right")
2186
+ );
2187
+ };
2188
+ return renderHyperlink();
2189
+ };
2190
+ var CubeIconFrame = (props) => {
2191
+ const { className: classNameProps, size = "md", children, onClick } = props;
2192
+ const containerClasses = getContainerClasses(size, classNameProps);
2193
+ const iconClasses = getIconClasses(size, children.props.className);
2194
+ const icon = cloneElement(children, { className: iconClasses });
2195
+ return /* @__PURE__ */ jsx("div", { className: containerClasses, onClick, children: icon });
2196
+ };
2197
+ var input = cva(
2198
+ [
2199
+ "primary-body2 w-full truncate rounded-[6px] py-[9px] outline-none",
2200
+ "bg-grey-0",
2201
+ "text-functional-text placeholder:text-functional-border-darker",
2202
+ "border border-functional-border-divider",
2203
+ "hover:border-functional-hover-primary focus:border-functional-hover-primary"
2204
+ ],
2205
+ {
2206
+ variants: {
2207
+ isError: {
2208
+ true: [
2209
+ "pl-4 pr-8",
2210
+ "border-status-negative hover:border-status-negative"
2211
+ ]
2212
+ },
2213
+ disabled: {
2214
+ true: [
2215
+ "disabled:border-functional-disable-text disabled:text-functional-disable-text disabled:placeholder:text-functional-border-divider",
2216
+ "disabled:hover:border-functional-disable-text"
2217
+ ]
2218
+ },
2219
+ hasIcon: {
2220
+ true: "pl-4 pr-8",
2221
+ false: "px-4"
2222
+ }
2223
+ },
2224
+ compoundVariants: [
2225
+ { isError: true, hasIcon: true, class: "pr-[56px]" },
2226
+ { isError: true, hasIcon: false, class: "pr-9" }
2227
+ ]
2228
+ }
2229
+ );
2230
+ var customIcon = cva("icon-md", {
2231
+ variants: {
2232
+ disabled: {
2233
+ true: "cursor-default text-functional-border-divider",
2234
+ false: "cursor-pointer text-functional-text"
2235
+ }
2236
+ }
2237
+ });
2238
+ var footer = cva("primary-body4", {
2239
+ variants: {
2240
+ isError: {
2241
+ true: "text-status-negative",
2242
+ false: "text-functional-text-light"
2243
+ }
2244
+ }
2245
+ });
2246
+ var skeleton = cva("w-full", {
2247
+ variants: {
2248
+ type: {
2249
+ label: "h-[20px]",
2250
+ input: "h-[38px]",
2251
+ footer: "h-[16px]"
2252
+ }
2253
+ }
2254
+ });
2255
+ var CubeInputSkeleton = (props) => {
2256
+ const { type } = props;
2257
+ return /* @__PURE__ */ jsx(CubeSkeleton, { className: skeleton({ type }) });
2258
+ };
2259
+ var CubeInput = Object.assign(
2260
+ forwardRef((props, ref) => {
2261
+ const {
2262
+ className,
2263
+ required = false,
2264
+ isLoading = false,
2265
+ label: label6,
2266
+ tooltip,
2267
+ helpMessage,
2268
+ errorMessage,
2269
+ trailingIcon,
2270
+ disabled,
2271
+ ...restProps
2272
+ } = props;
2273
+ const defaultId = useId();
2274
+ const inputId = restProps.id || defaultId;
2275
+ const isError = !!errorMessage && typeof errorMessage === "string";
2276
+ const hasFooter = !!helpMessage || isError;
2277
+ const hasIcon = !!trailingIcon;
2278
+ const renderLabel = () => {
2279
+ if (!label6 && !tooltip) return null;
2280
+ if (isLoading) return /* @__PURE__ */ jsx(CubeInputSkeleton, { type: "label" });
2281
+ return /* @__PURE__ */ jsxs("div", { className: "primary-body2 flex items-center space-x-1", children: [
2282
+ /* @__PURE__ */ jsx(
2283
+ "label",
2284
+ {
2285
+ htmlFor: inputId,
2286
+ className: "font-semibold text-functional-title",
2287
+ children: label6
2288
+ }
2289
+ ),
2290
+ required && /* @__PURE__ */ jsx("span", { className: "text-status-negative", children: "*" }),
2291
+ tooltip
2292
+ ] });
2293
+ };
2294
+ const renderIcon = () => {
2295
+ if (isLoading) return null;
2296
+ const errorIcon = (() => {
2297
+ if (!isError) return null;
2298
+ return /* @__PURE__ */ jsx(WarningFilled_default, { className: "icon-md text-status-negative" });
2299
+ })();
2300
+ const customIcon2 = (() => {
2301
+ if (!hasIcon) return null;
2302
+ return cloneElement(trailingIcon, {
2303
+ className: twMerge(
2304
+ trailingIcon.props.className,
2305
+ // Overrides icon size, color, and cursor style within the input.
2306
+ customIcon({ disabled })
2307
+ )
2308
+ });
2309
+ })();
2310
+ return /* @__PURE__ */ jsxs("span", { className: "absolute right-0 flex h-4 shrink-0 -translate-x-4 items-center justify-center gap-2 overflow-hidden", children: [
2311
+ errorIcon,
2312
+ customIcon2
2313
+ ] });
2314
+ };
2315
+ const renderInput = () => {
2316
+ if (isLoading) return /* @__PURE__ */ jsx(CubeInputSkeleton, { type: "input" });
2317
+ return /* @__PURE__ */ jsx(
2318
+ "input",
2319
+ {
2320
+ ...restProps,
2321
+ id: inputId,
2322
+ ref,
2323
+ disabled,
2324
+ className: twMerge(input({ isError, disabled, hasIcon }), className),
2325
+ required
2326
+ }
2327
+ );
2328
+ };
2329
+ const renderFooter = () => {
2330
+ if (!hasFooter) return null;
2331
+ if (isLoading) return /* @__PURE__ */ jsx(CubeInputSkeleton, { type: "footer" });
2332
+ return /* @__PURE__ */ jsx("div", { className: twMerge(footer({ isError })), children: errorMessage ?? helpMessage });
2333
+ };
2334
+ return /* @__PURE__ */ jsxs("div", { className: "min-w-[202px] space-y-[6px]", children: [
2335
+ renderLabel(),
2336
+ /* @__PURE__ */ jsxs("div", { className: "relative flex items-center", children: [
2337
+ renderInput(),
2338
+ renderIcon()
2339
+ ] }),
2340
+ renderFooter()
2341
+ ] });
2342
+ }),
2343
+ { Skeleton: CubeInputSkeleton }
2344
+ );
2345
+ CubeInput.displayName = "CubeInput";
2346
+
2347
+ // src/components/CubeTextarea/cubeTextareaUtils.ts
2348
+ var normalizeValue = (value) => {
2349
+ if (typeof value === "string") return value;
2350
+ if (typeof value === "number") return value.toString();
2351
+ if (Array.isArray(value)) return value.join("");
2352
+ return "";
2353
+ };
2354
+ var calculateValueLength = (value) => {
2355
+ const normalizedValue = normalizeValue(value);
2356
+ return normalizedValue.length;
2357
+ };
2358
+ var assignRefValue = (ref, element) => {
2359
+ if (!ref) return;
2360
+ if (typeof ref === "function") {
2361
+ ref(element);
2362
+ } else {
2363
+ ref.current = element;
2364
+ }
2365
+ };
2366
+ var CubeOverflowMenuContext = createContext(() => void 0);
2367
+ var CubeOverflowMenuDivider = () => {
2368
+ return /* @__PURE__ */ jsx("div", { className: "my-2 h-px bg-functional-border-divider" });
2369
+ };
2370
+
2371
+ // src/components/CubeOverflowMenu/cubeOverflowMenuUtils.ts
2372
+ var renderNothing = () => void 0;
2373
+ var CubeOverflowMenuItemLeadingContent = (props) => {
2374
+ const { type } = props;
2375
+ const renderMenuIcon = () => {
2376
+ const { MenuIcon } = props;
2377
+ return /* @__PURE__ */ jsx("div", { className: "mx-[3px] flex size-8 shrink-0 items-center justify-center rounded-[5px] bg-primary-100 p-1 group-[.group]:bg-primary-50", children: /* @__PURE__ */ jsx(MenuIcon, { className: "icon-xl text-functional-text group-[.group]:text-functional-disable-text" }) });
2378
+ };
2379
+ const renderCheckmark = () => {
2380
+ const { isChecked } = props;
2381
+ return /* @__PURE__ */ jsx("div", { className: "shrink-0 px-2.5", children: /* @__PURE__ */ jsx(
2382
+ CheckmarkBold_default,
2383
+ {
2384
+ className: twMerge(
2385
+ "icon-md text-functional-text group-[.group]:text-functional-disable-text",
2386
+ !isChecked && "invisible"
2387
+ )
2388
+ }
2389
+ ) });
2390
+ };
2391
+ const renderCustomLeadingElement = () => {
2392
+ const { element } = props;
2393
+ return /* @__PURE__ */ jsx("div", { className: "shrink-0 px-2.5", children: element });
2394
+ };
2395
+ const renderFnMap = {
2396
+ plain: renderNothing,
2397
+ "menu-icon": renderMenuIcon,
2398
+ "check-mark": renderCheckmark,
2399
+ toggle: renderNothing,
2400
+ "trailing-icon": renderNothing,
2401
+ "custom-leading-element": renderCustomLeadingElement
2402
+ };
2403
+ return !!type && renderFnMap[type]();
2404
+ };
2405
+ var track = cva(
2406
+ "flex h-[20px] w-9 items-center rounded-full border border-transparent transition-colors",
2407
+ {
2408
+ variants: {
2409
+ checked: {
2410
+ true: "bg-status-positive",
2411
+ false: "bg-functional-disable-text"
2412
+ },
2413
+ disabled: {
2414
+ false: "cursor-pointer",
2415
+ true: "cursor-default"
2416
+ }
2417
+ },
2418
+ compoundVariants: [
2419
+ // Not disabled
2420
+ {
2421
+ checked: true,
2422
+ disabled: false,
2423
+ className: "hover:bg-green-400"
2424
+ },
2425
+ {
2426
+ checked: false,
2427
+ disabled: false,
2428
+ className: "hover:bg-grey-400"
2429
+ },
2430
+ // Disabled
2431
+ {
2432
+ checked: true,
2433
+ disabled: true,
2434
+ className: "border-green-200 bg-green-100"
2435
+ },
2436
+ {
2437
+ checked: false,
2438
+ disabled: true,
2439
+ className: "border-functional-disable bg-grey-150"
2440
+ }
2441
+ ]
2442
+ }
2443
+ );
2444
+ var thumb = cva(
2445
+ "size-[17px] rounded-full bg-grey-0 shadow-md transition-transform",
2446
+ {
2447
+ variants: {
2448
+ checked: {
2449
+ true: "translate-x-4",
2450
+ false: "translate-x-px"
2451
+ }
2452
+ }
2453
+ }
2454
+ );
2455
+ var label3 = cva("primary-body4 text-functional-text", {
2456
+ variants: {
2457
+ disabled: {
2458
+ false: "cursor-pointer",
2459
+ true: "cursor-default"
2460
+ }
2461
+ }
2462
+ });
2463
+ var CubeToggle = (props) => {
2464
+ const {
2465
+ className,
2466
+ checked,
2467
+ onCheckedChange,
2468
+ label: label6,
2469
+ disabled = false,
2470
+ "aria-label": ariaLabel
2471
+ } = props;
2472
+ const toggleId = useId();
2473
+ const labelId = useId();
2474
+ const toggleChecked = () => {
2475
+ if (disabled) return;
2476
+ onCheckedChange(!checked);
2477
+ };
2478
+ return /* @__PURE__ */ jsxs("div", { className: twMerge("flex items-center gap-x-[6px]", className), children: [
2479
+ /* @__PURE__ */ jsx(
2480
+ "button",
2481
+ {
2482
+ id: toggleId,
2483
+ type: "button",
2484
+ role: "switch",
2485
+ "aria-checked": checked,
2486
+ "aria-labelledby": label6 ? labelId : void 0,
2487
+ "aria-label": label6 ? void 0 : ariaLabel,
2488
+ className: twMerge(track({ checked, disabled })),
2489
+ disabled,
2490
+ onClick: toggleChecked,
2491
+ children: /* @__PURE__ */ jsx("span", { className: thumb({ checked }), "aria-hidden": true })
2492
+ }
2493
+ ),
2494
+ label6 && /* @__PURE__ */ jsx(
2495
+ "label",
2496
+ {
2497
+ id: labelId,
2498
+ htmlFor: toggleId,
2499
+ className: label3({ disabled }),
2500
+ children: label6
2501
+ }
2502
+ )
2503
+ ] });
2504
+ };
2505
+ var CubeOverflowMenuItemTrailingContent = (props) => {
2506
+ const { type, title } = props;
2507
+ const renderToggle = () => {
2508
+ const { disabled, checked, onCheckedChange } = props;
2509
+ return /* @__PURE__ */ jsx(
2510
+ CubeToggle,
2511
+ {
2512
+ className: "ml-8 shrink-0",
2513
+ checked,
2514
+ disabled,
2515
+ "aria-label": title,
2516
+ onCheckedChange: (next) => onCheckedChange?.(next)
2517
+ }
2518
+ );
2519
+ };
2520
+ const renderTrailingIcon = () => {
2521
+ const { TrailingIcon } = props;
2522
+ return /* @__PURE__ */ jsx("div", { className: "shrink-0 px-2.5", children: /* @__PURE__ */ jsx(TrailingIcon, { className: "icon-md text-functional-text group-[.group]:text-functional-disable-text" }) });
2523
+ };
2524
+ const renderFnMap = {
2525
+ plain: renderNothing,
2526
+ "menu-icon": renderNothing,
2527
+ "check-mark": renderNothing,
2528
+ toggle: renderToggle,
2529
+ "trailing-icon": renderTrailingIcon,
2530
+ "custom-leading-element": renderNothing
2531
+ };
2532
+ return !!type && renderFnMap[type]();
2533
+ };
2534
+ var menu2 = cva([
2535
+ "z-10",
2536
+ "rounded-[5px] border border-functional-border-divider bg-grey-0 py-2",
2537
+ "shadow-[0px_0px_2px_0px_rgba(0,_0,_0,_0.20)]"
2538
+ ]);
2539
+ var itemContainer = cva(
2540
+ [
2541
+ "flex items-center gap-x-1",
2542
+ "min-w-40 max-w-[360px] px-[22px] py-2",
2543
+ "bg-transparent transition-colors"
2544
+ ],
2545
+ {
2546
+ variants: {
2547
+ hasOnClickProp: {
2548
+ true: "cursor-pointer",
2549
+ false: "cursor-default"
2550
+ },
2551
+ withSubtext: {
2552
+ true: "h-[53px]",
2553
+ false: "h-[36ox]"
2554
+ },
2555
+ disabled: {
2556
+ true: "group cursor-default",
2557
+ false: "hover:bg-functional-hover-grey"
2558
+ }
2559
+ }
2560
+ }
2561
+ );
2562
+ var CubeOverflowMenuItem = (props) => {
2563
+ const { type, title, boldTitle, subText } = props;
2564
+ const closeMenu = useContext(CubeOverflowMenuContext);
2565
+ const getIsDisabled = () => {
2566
+ return "disabled" in props && !!props.disabled;
2567
+ };
2568
+ const onClick = () => {
2569
+ if (getIsDisabled()) {
2570
+ return;
2571
+ }
2572
+ if ("onClick" in props) {
2573
+ props.onClick?.();
2574
+ if (type !== "check-mark" && type !== "toggle") {
2575
+ closeMenu();
2576
+ }
2577
+ }
2578
+ };
2579
+ return /* @__PURE__ */ jsxs(
2580
+ "div",
2581
+ {
2582
+ className: twMerge(
2583
+ itemContainer({
2584
+ hasOnClickProp: "onClick" in props,
2585
+ withSubtext: !!subText,
2586
+ disabled: getIsDisabled()
2587
+ })
2588
+ ),
2589
+ onClick,
2590
+ children: [
2591
+ /* @__PURE__ */ jsx(CubeOverflowMenuItemLeadingContent, { ...props }),
2592
+ /* @__PURE__ */ jsxs("div", { className: "flex grow flex-col gap-y-0.5 overflow-hidden", children: [
2593
+ /* @__PURE__ */ jsx(
2594
+ "div",
2595
+ {
2596
+ className: twMerge(
2597
+ "primary-body2 truncate text-functional-title group-[.group]:text-functional-disable-text",
2598
+ boldTitle && "font-semibold"
2599
+ ),
2600
+ children: title
2601
+ }
2602
+ ),
2603
+ subText && /* @__PURE__ */ jsx("div", { className: "primary-body5 truncate text-functional-text-light group-[.group]:text-functional-disable-text", children: subText })
2604
+ ] }),
2605
+ /* @__PURE__ */ jsx(CubeOverflowMenuItemTrailingContent, { ...props })
2606
+ ]
2607
+ }
2608
+ );
2609
+ };
2610
+ var CubeOverflowMenuTitle = (props) => {
2611
+ const { children } = props;
2612
+ return /* @__PURE__ */ jsx("div", { className: "primary-body4 truncate px-[22px] pb-1 pt-2 text-functional-text-light", children });
2613
+ };
2614
+ var CubeOverflowMenu = (props) => {
2615
+ const { triggerElement, children } = props;
2616
+ const [isOpen, setIsOpen] = useState(false);
2617
+ const { anchorRef, elementRef, resolvedStyles } = useFloating({
2618
+ isOpen,
2619
+ placement: "bottom-left",
2620
+ offsets: {
2621
+ y: 8
2622
+ }
2623
+ });
2624
+ const closeMenu = useCallback(() => {
2625
+ setIsOpen(false);
2626
+ }, []);
2627
+ useEffect(() => {
2628
+ const onOutsideClick = (e) => {
2629
+ const target = e.target;
2630
+ const isAnchor = anchorRef.current?.contains(target);
2631
+ const isMenu = elementRef.current?.contains(target);
2632
+ if (!isAnchor && !isMenu) {
2633
+ setIsOpen(false);
2634
+ }
2635
+ };
2636
+ window.addEventListener("click", onOutsideClick);
2637
+ return () => {
2638
+ window.removeEventListener("click", onOutsideClick);
2639
+ };
2640
+ }, [anchorRef, elementRef]);
2641
+ const clonedAnchor = cloneElement(triggerElement, {
2642
+ ref: (element) => {
2643
+ assignRefValue(triggerElement.props.ref, element);
2644
+ assignRefValue(anchorRef, element);
2645
+ },
2646
+ onClick: (e) => {
2647
+ setIsOpen((prev) => !prev);
2648
+ triggerElement.props.onClick?.(e);
2649
+ }
2650
+ });
2651
+ return /* @__PURE__ */ jsxs(CubeOverflowMenuContext.Provider, { value: closeMenu, children: [
2652
+ clonedAnchor,
2653
+ createPortal(
2654
+ /* @__PURE__ */ jsx(
2655
+ "div",
2656
+ {
2657
+ ref: elementRef,
2658
+ className: menu2(),
2659
+ style: resolvedStyles?.floatingStyle,
2660
+ children
2661
+ }
2662
+ ),
2663
+ document.body
2664
+ )
2665
+ ] });
2666
+ };
2667
+ CubeOverflowMenu.Item = CubeOverflowMenuItem;
2668
+ CubeOverflowMenu.Divider = CubeOverflowMenuDivider;
2669
+ CubeOverflowMenu.Title = CubeOverflowMenuTitle;
2670
+ var CubePasswordInput = (props) => {
2671
+ const { initialShowPassword = false, disabled, ...restProps } = props;
2672
+ const [showPassword, setShowPassword] = useState(initialShowPassword);
2673
+ const handleShowHide = () => {
2674
+ setShowPassword((prev) => !prev);
2675
+ };
2676
+ const IconComponent = showPassword ? View_default : ViewOff_default;
2677
+ return /* @__PURE__ */ jsx(
2678
+ CubeInput,
2679
+ {
2680
+ ...restProps,
2681
+ type: showPassword ? "text" : "password",
2682
+ disabled,
2683
+ trailingIcon: /* @__PURE__ */ jsx(IconComponent, { onClick: disabled ? void 0 : handleShowHide })
2684
+ }
2685
+ );
2686
+ };
2687
+ var container2 = cva(
2688
+ "primary-body2 inline-flex w-fit cursor-pointer items-start gap-x-2",
2689
+ {
2690
+ variants: {
2691
+ disabled: {
2692
+ true: "cursor-default"
2693
+ }
2694
+ }
2695
+ }
2696
+ );
2697
+ var iconWrap2 = cva(
2698
+ [
2699
+ "shrink-0 p-0.5",
2700
+ "text-functional-border-darker transition-colors duration-100 peer-hover:text-functional-hover-primary"
2701
+ ],
2702
+ {
2703
+ variants: {
2704
+ isSelected: {
2705
+ true: "text-primary"
2706
+ },
2707
+ disabled: {
2708
+ true: "text-functional-disable-text peer-hover:text-functional-disable-text"
2709
+ }
2710
+ }
2711
+ }
2712
+ );
2713
+ var label4 = cva("max-w-[152px] break-words text-functional-text", {
2714
+ variants: {
2715
+ disabled: {
2716
+ true: "text-functional-disable-text"
2717
+ }
2718
+ }
2719
+ });
2720
+ var CubeRadioButtonSkeleton = () => {
2721
+ return /* @__PURE__ */ jsxs("div", { className: "inline-flex gap-x-2", children: [
2722
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "size-5" }),
2723
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "h-5 w-[152px]" })
2724
+ ] });
2725
+ };
2726
+ var CubeRadioButtonGrid = (props) => {
2727
+ const { children, className: classNameProp, direction } = props;
2728
+ const className = twMerge(
2729
+ direction === "vertical" ? "flex flex-col gap-y-3" : "grid grid-cols-[repeat(auto-fill,180px)] gap-x-4 gap-y-6",
2730
+ classNameProp
2731
+ );
2732
+ return /* @__PURE__ */ jsx("div", { className, children });
2733
+ };
2734
+ var CubeRadioButton = (props) => {
2735
+ const {
2736
+ label: label6,
2737
+ id,
2738
+ ref,
2739
+ defaultChecked = false,
2740
+ checked: controlledChecked,
2741
+ onChange: onControlledCheckedChange,
2742
+ disabled,
2743
+ isLoading = false,
2744
+ ...restProps
2745
+ } = props;
2746
+ const [uncontrolledChecked, setUncontrolledChecked] = useState(defaultChecked);
2747
+ const isControlled = controlledChecked !== void 0;
2748
+ const effectiveChecked = isControlled ? controlledChecked : uncontrolledChecked;
2749
+ const handleChange = (event) => {
2750
+ if (!isControlled) {
2751
+ setUncontrolledChecked(event.target.checked);
2752
+ }
2753
+ onControlledCheckedChange?.(event);
2754
+ };
2755
+ const renderIcon = () => {
2756
+ const IconComponent = effectiveChecked ? RadioButtonFilled_default : RadioButton_default;
2757
+ return /* @__PURE__ */ jsx(
2758
+ "div",
2759
+ {
2760
+ className: twMerge(
2761
+ iconWrap2({ disabled, isSelected: effectiveChecked })
2762
+ ),
2763
+ children: /* @__PURE__ */ jsx(IconComponent, { className: "icon-md" })
2764
+ }
2765
+ );
2766
+ };
2767
+ if (isLoading) return /* @__PURE__ */ jsx(CubeRadioButtonSkeleton, {});
2768
+ return /* @__PURE__ */ jsxs("label", { htmlFor: id, className: twMerge(container2({ disabled })), children: [
2769
+ /* @__PURE__ */ jsx(
2770
+ "input",
2771
+ {
2772
+ ...restProps,
2773
+ id,
2774
+ ref,
2775
+ type: "radio",
2776
+ checked: effectiveChecked ?? false,
2777
+ onChange: handleChange,
2778
+ disabled,
2779
+ className: "peer hidden"
2780
+ }
2781
+ ),
2782
+ renderIcon(),
2783
+ /* @__PURE__ */ jsx("span", { className: twMerge(label4({ disabled })), children: label6 })
2784
+ ] });
2785
+ };
2786
+ CubeRadioButton.Skeleton = CubeRadioButtonSkeleton;
2787
+ CubeRadioButton.Grid = CubeRadioButtonGrid;
2788
+
2789
+ // src/components/CubeStatus/cubeStatusTypes.ts
2790
+ var cubeStatusNeutralValues = [
2791
+ "neutral",
2792
+ "in-use",
2793
+ "finished"
2794
+ ];
2795
+ var cubeStatusSuccessValues = [
2796
+ "ok",
2797
+ "success",
2798
+ "active",
2799
+ "available",
2800
+ "powering on"
2801
+ ];
2802
+ var cubeStatusWarningValues = [
2803
+ "warning",
2804
+ "error",
2805
+ "fail",
2806
+ "failed",
2807
+ "stopped",
2808
+ "powering off"
2809
+ ];
2810
+
2811
+ // src/components/CubeStatus/cubeStatusUtils.ts
2812
+ var neutralStatusSet = new Set(cubeStatusNeutralValues);
2813
+ var successStatusSet = new Set(cubeStatusSuccessValues);
2814
+ var warningStatusSet = new Set(cubeStatusWarningValues);
2815
+ var computeStatusType = (status2) => {
2816
+ if (neutralStatusSet.has(status2)) {
2817
+ return "neutral";
2818
+ } else if (successStatusSet.has(status2)) {
2819
+ return "success";
2820
+ } else if (warningStatusSet.has(status2)) {
2821
+ return "warning";
2822
+ }
2823
+ return "others";
2824
+ };
2825
+ var formatOtherStatusText = (status2) => {
2826
+ const substrings = status2.split("-").filter((text) => !!text);
2827
+ if (!substrings.length) {
2828
+ return status2;
2829
+ }
2830
+ const [firstSubstring = "", ...otherSubstrings] = substrings;
2831
+ const capitalizedFirstSubstring = firstSubstring.charAt(0).toUpperCase() + firstSubstring.substring(1);
2832
+ return [capitalizedFirstSubstring, ...otherSubstrings].join("-");
2833
+ };
2834
+ var status = cva(
2835
+ [
2836
+ "flex h-[19px] w-fit cursor-default items-center rounded-[20px] border px-2.5",
2837
+ "secondary-body6 whitespace-nowrap font-semibold"
2838
+ ],
2839
+ {
2840
+ variants: {
2841
+ type: {
2842
+ neutral: "border-cosmos-primary text-cosmos-primary",
2843
+ success: "border-status-positive text-status-positive",
2844
+ warning: "border-status-negative text-status-negative",
2845
+ others: "border-functional-text-light text-functional-text-light"
2846
+ }
2847
+ }
2848
+ }
2849
+ );
2850
+
2851
+ // src/components/CubeStatus/useCubeStatusTranslation.ts
2852
+ var useCubeStatusTranslation = () => {
2853
+ const { t } = useCubeUiTranslation();
2854
+ return {
2855
+ neutral: t("component.status.host.neutral"),
2856
+ "in-use": t("component.status.host.inUse"),
2857
+ finished: t("component.status.host.finished"),
2858
+ ok: t("component.status.host.ok"),
2859
+ success: t("component.status.host.success"),
2860
+ active: t("component.status.host.active"),
2861
+ available: t("component.status.host.available"),
2862
+ "powering on": t("component.status.host.poweringOn"),
2863
+ warning: t("component.status.host.warning"),
2864
+ error: t("component.status.host.error"),
2865
+ fail: t("component.status.host.fail"),
2866
+ failed: t("component.status.host.failed"),
2867
+ stopped: t("component.status.host.stopped"),
2868
+ "powering off": t("component.status.host.poweringOff")
2869
+ };
2870
+ };
2871
+ var CubeStatusSkeleton = () => {
2872
+ return /* @__PURE__ */ jsx(CubeSkeleton, { className: "h-[17px] w-[49px] rounded-[20px]" });
2873
+ };
2874
+ var CubeStatus = (props) => {
2875
+ const { status: status2, message } = props;
2876
+ const type = computeStatusType(status2);
2877
+ const translationMap = useCubeStatusTranslation();
2878
+ const getMessage = () => {
2879
+ if (message) {
2880
+ return message;
2881
+ }
2882
+ if (status2 in translationMap) {
2883
+ return translationMap[status2];
2884
+ }
2885
+ return formatOtherStatusText(status2);
2886
+ };
2887
+ return /* @__PURE__ */ jsx("span", { className: twMerge(status({ type })), children: getMessage() });
2888
+ };
2889
+ CubeStatus.Skeleton = CubeStatusSkeleton;
2890
+
2891
+ // src/components/CubeStatusReaction/cubeStatusReactionTypes.ts
2892
+ var cubeStatusReactionNeutralStatuses = ["neutral"];
2893
+ var cubeStatusReactionSuccessStatuses = [
2894
+ "success",
2895
+ "available",
2896
+ "done"
2897
+ ];
2898
+ var cubeStatusReactionWarningStatuses = [
2899
+ "error",
2900
+ "duplicate",
2901
+ "failed"
2902
+ ];
2903
+
2904
+ // src/components/CubeStatusReaction/cubeStatusReactionUtils.ts
2905
+ var neutralStatusSet2 = new Set(cubeStatusReactionNeutralStatuses);
2906
+ var successStatusSet2 = new Set(cubeStatusReactionSuccessStatuses);
2907
+ var warningStatusSet2 = new Set(cubeStatusReactionWarningStatuses);
2908
+ var computeStatusType2 = (status2) => {
2909
+ if (neutralStatusSet2.has(status2)) {
2910
+ return "neutral";
2911
+ } else if (successStatusSet2.has(status2)) {
2912
+ return "success";
2913
+ } else if (warningStatusSet2.has(status2)) {
2914
+ return "warning";
2915
+ }
2916
+ throw new Error(`Status ${status2} is not defined in CubeStatusReaction`);
2917
+ };
2918
+ var baseClass = "inline-flex w-fit items-center gap-x-2 px-2 py-[5px]";
2919
+ var statusReaction = cva(
2920
+ [baseClass, "secondary-body3 whitespace-nowrap font-semibold"],
2921
+ {
2922
+ variants: {
2923
+ type: {
2924
+ neutral: "text-status-neutral",
2925
+ success: "text-status-positive",
2926
+ warning: "text-status-negative"
2927
+ }
2928
+ }
2929
+ }
2930
+ );
2931
+
2932
+ // src/components/CubeStatusReaction/useCubeStatusReactionTranslation.ts
2933
+ var useCubeStatusReactionTranslation = () => {
2934
+ const { t } = useCubeUiTranslation();
2935
+ return {
2936
+ neutral: t("component.status.reaction.neutral"),
2937
+ success: t("component.status.reaction.success"),
2938
+ available: t("component.status.reaction.available"),
2939
+ done: t("component.status.reaction.done"),
2940
+ error: t("component.status.reaction.error"),
2941
+ duplicate: t("component.status.reaction.duplicate"),
2942
+ failed: t("component.status.reaction.failed")
2943
+ };
2944
+ };
2945
+ var CubeStatusReactionSkeleton = () => {
2946
+ return /* @__PURE__ */ jsxs("div", { className: baseClass, children: [
2947
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "size-4" }),
2948
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "h-4 w-11" })
2949
+ ] });
2950
+ };
2951
+ var iconMap = {
2952
+ neutral: CheckmarkBold_default,
2953
+ success: CheckmarkCircleFill_default,
2954
+ warning: CrossFill_default
2955
+ };
2956
+ var CubeStatusReaction = (props) => {
2957
+ const { status: status2, message } = props;
2958
+ const type = computeStatusType2(status2);
2959
+ const Icon = iconMap[type];
2960
+ const translationMap = useCubeStatusReactionTranslation();
2961
+ const getMessage = () => {
2962
+ if (message) {
2963
+ return message;
2964
+ }
2965
+ if (status2 in translationMap) {
2966
+ return translationMap[status2];
2967
+ }
2968
+ return upperFirst(status2);
2969
+ };
2970
+ return /* @__PURE__ */ jsxs("div", { className: twMerge(statusReaction({ type })), children: [
2971
+ /* @__PURE__ */ jsx(Icon, { className: "icon-md-sm shrink-0" }),
2972
+ /* @__PURE__ */ jsx("span", { children: getMessage() })
2973
+ ] });
2974
+ };
2975
+ CubeStatusReaction.Skeleton = CubeStatusReactionSkeleton;
2976
+ var number = cva(
2977
+ "secondary-body7 flex size-4 shrink-0 items-center justify-center rounded-full font-extrabold text-white",
2978
+ {
2979
+ variants: {
2980
+ isActive: {
2981
+ true: "bg-functional-text",
2982
+ false: "bg-functional-disable-text"
2983
+ }
2984
+ }
2985
+ }
2986
+ );
2987
+ var label5 = cva("primary-body3", {
2988
+ variants: {
2989
+ isActive: {
2990
+ true: "font-semibold text-functional-text",
2991
+ false: "text-functional-disable-text"
2992
+ }
2993
+ }
2994
+ });
2995
+ var CubeStepProcessItem = (props) => {
2996
+ const { stepNumber, label: label6, isActive } = props;
2997
+ return /* @__PURE__ */ jsxs("div", { className: "group flex items-center gap-3", children: [
2998
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
2999
+ /* @__PURE__ */ jsx("div", { className: twMerge(number({ isActive })), children: stepNumber.toString() }),
3000
+ /* @__PURE__ */ jsx("p", { className: twMerge(label5({ isActive })), children: label6 })
3001
+ ] }),
3002
+ /* @__PURE__ */ jsx(ChevronRight_default, { className: "icon-lg text-functional-text-light group-last:hidden" })
3003
+ ] });
3004
+ };
3005
+ var CubeStepProcessSkeleton = (props) => {
3006
+ const { length = 5 } = props;
3007
+ return /* @__PURE__ */ jsx("div", { className: "flex gap-3", children: range(0, length).map((_, index) => /* @__PURE__ */ jsxs("div", { className: "group flex", children: [
3008
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "mr-2 size-[18px]" }),
3009
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "mr-3 h-[18px] w-[58px]" }),
3010
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "size-[18px] group-last:hidden" })
3011
+ ] }, index)) });
3012
+ };
3013
+ var CubeStepProcess = (props) => {
3014
+ const { className, children, isLoading } = props;
3015
+ if (isLoading) {
3016
+ return /* @__PURE__ */ jsx(CubeStepProcessSkeleton, {});
3017
+ }
3018
+ return /* @__PURE__ */ jsx("div", { className: twMerge("flex items-center gap-3", className), children });
3019
+ };
3020
+ CubeStepProcess.Item = CubeStepProcessItem;
3021
+ CubeStepProcess.Skeleton = CubeStepProcessSkeleton;
3022
+ var stroke = cva("", {
3023
+ variants: {
3024
+ type: {
3025
+ regular: "border-functional-border-divider",
3026
+ dot: "border-t-4 border-dotted border-primary-50"
3027
+ }
3028
+ }
3029
+ });
3030
+ var CubeStroke = (props) => {
3031
+ const { className, type = "regular", color } = props;
3032
+ return /* @__PURE__ */ jsx("hr", { className: twMerge(stroke({ type }), color, className) });
3033
+ };
3034
+ var tab = cva(
3035
+ "inline-block min-h-[34px] max-w-[200px] border-b border-b-functional-border-divider",
3036
+ {
3037
+ variants: {
3038
+ isActive: {
3039
+ false: "text-functional-text-light"
3040
+ },
3041
+ disabled: {
3042
+ false: ["cursor-pointer hover:text-functional-hover-primary"],
3043
+ true: ["cursor-default text-functional-disable-text"]
3044
+ }
3045
+ },
3046
+ compoundVariants: [
3047
+ {
3048
+ isActive: true,
3049
+ disabled: false,
3050
+ className: "border-b-cosmos-primary text-cosmos-primary"
3051
+ }
3052
+ ],
3053
+ defaultVariants: {
3054
+ isActive: false,
3055
+ disabled: false
3056
+ }
3057
+ }
3058
+ );
3059
+ var innerContainer = cva(
3060
+ [
3061
+ "secondary-body2 flex items-center justify-center px-2.5 py-2",
3062
+ "border-b border-b-transparent"
3063
+ ],
3064
+ {
3065
+ variants: {
3066
+ isActive: {
3067
+ true: "",
3068
+ false: ""
3069
+ },
3070
+ disabled: {
3071
+ false: "font-medium"
3072
+ }
3073
+ },
3074
+ compoundVariants: [
3075
+ {
3076
+ isActive: true,
3077
+ disabled: false,
3078
+ className: "border-b-cosmos-primary font-semibold"
3079
+ }
3080
+ ],
3081
+ defaultVariants: {
3082
+ isActive: false,
3083
+ disabled: false
3084
+ }
3085
+ }
3086
+ );
3087
+ var numberSpan = cva(
3088
+ "secondary-body7 ml-1 inline-flex size-4 shrink-0 items-center justify-center rounded-full text-[9px] font-extrabold",
3089
+ {
3090
+ variants: {
3091
+ disabled: {
3092
+ false: ["bg-cosmos-secondary text-functional-text"],
3093
+ true: ["bg-secondary-150 text-functional-text-light"]
3094
+ }
3095
+ },
3096
+ defaultVariants: {
3097
+ disabled: false
3098
+ }
3099
+ }
3100
+ );
3101
+ var NumberSpan = (props) => {
3102
+ const { number: number2, disabled } = props;
3103
+ const text = number2 > 99 ? "N" : number2;
3104
+ return /* @__PURE__ */ jsx(
3105
+ "span",
3106
+ {
3107
+ className: numberSpan({
3108
+ disabled
3109
+ }),
3110
+ children: text
3111
+ }
3112
+ );
3113
+ };
3114
+ var dotSpan = cva("ml-2.5 size-1 shrink-0 rounded-full", {
3115
+ variants: {
3116
+ disabled: {
3117
+ false: ["bg-cosmos-secondary"],
3118
+ true: ["bg-secondary-150"]
3119
+ }
3120
+ },
3121
+ defaultVariants: {
3122
+ disabled: false
3123
+ }
3124
+ });
3125
+ var DotSpan = (props) => {
3126
+ const { disabled } = props;
3127
+ return /* @__PURE__ */ jsx(
3128
+ "span",
3129
+ {
3130
+ className: dotSpan({
3131
+ disabled
3132
+ })
3133
+ }
3134
+ );
3135
+ };
3136
+ var CubeTab = (props) => {
3137
+ const {
3138
+ children,
3139
+ href,
3140
+ isActive,
3141
+ disabled = false,
3142
+ number: number2,
3143
+ dot,
3144
+ onClick: onClickProp
3145
+ } = props;
3146
+ const onClick = (e) => {
3147
+ if (!disabled) {
3148
+ onClickProp?.(e);
3149
+ }
3150
+ };
3151
+ const renderLabel = () => /* @__PURE__ */ jsx(
3152
+ "span",
3153
+ {
3154
+ "data-label": children,
3155
+ className: twJoin(
3156
+ "inline-flex flex-col items-center",
3157
+ // Use pseudo element to avoid slight layout shift caused by the font weight changes between inactive and active states.
3158
+ "before:secondary-body2 before:pointer-events-none before:invisible before:h-0 before:select-none before:font-semibold before:content-[attr(data-label)]"
3159
+ ),
3160
+ children
3161
+ }
3162
+ );
3163
+ const renderDecoration = () => {
3164
+ if (number2 !== void 0) {
3165
+ return /* @__PURE__ */ jsx(NumberSpan, { number: number2, disabled });
3166
+ } else if (dot) {
3167
+ return /* @__PURE__ */ jsx(DotSpan, { disabled });
3168
+ } else {
3169
+ return void 0;
3170
+ }
3171
+ };
3172
+ const renderTab = () => {
3173
+ const tagType = href && !disabled ? "a" : "span";
3174
+ const hrefAttribute = tagType === "a" ? href : void 0;
3175
+ return createElement(
3176
+ tagType,
3177
+ {
3178
+ className: twMerge(
3179
+ tab({
3180
+ isActive,
3181
+ disabled
3182
+ })
3183
+ ),
3184
+ href: hrefAttribute,
3185
+ onClick
3186
+ },
3187
+ /* @__PURE__ */ jsxs(
3188
+ "div",
3189
+ {
3190
+ className: twMerge(
3191
+ innerContainer({
3192
+ isActive,
3193
+ disabled
3194
+ })
3195
+ ),
3196
+ children: [
3197
+ renderLabel(),
3198
+ renderDecoration()
3199
+ ]
3200
+ }
3201
+ )
3202
+ );
3203
+ };
3204
+ return renderTab();
3205
+ };
3206
+ var CubeTabSkeleton = () => {
3207
+ 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" }) });
3208
+ };
3209
+ var CubeTabs = (props) => {
3210
+ const { children } = props;
3211
+ return /* @__PURE__ */ jsx("div", { className: "flex items-end", children });
3212
+ };
3213
+ CubeTabs.Tab = CubeTab;
3214
+ CubeTabs.Skeleton = CubeTabSkeleton;
3215
+ var compoundsCreator = (color, variant, entries) => entries.map((entry) => ({ color, variant, ...entry }));
3216
+ var defaultCompounds = [
3217
+ // Filled - Base
3218
+ {
3219
+ color: "default",
3220
+ variant: "filled",
3221
+ disabled: false,
3222
+ className: twMerge(
3223
+ "bg-functional-border-divider hover:bg-grey-300",
3224
+ "text-functional-text"
3225
+ )
3226
+ },
3227
+ {
3228
+ color: "default",
3229
+ variant: "filled",
3230
+ disabled: true,
3231
+ className: twMerge(
3232
+ "bg-functional-disable-light",
3233
+ "text-functional-disable-text"
3234
+ )
3235
+ },
3236
+ // Filled - Close button
3237
+ {
3238
+ color: "default",
3239
+ variant: "filled",
3240
+ hasCloseButton: true,
3241
+ disabled: false,
3242
+ className: twMerge(
3243
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
3244
+ )
3245
+ },
3246
+ {
3247
+ color: "default",
3248
+ variant: "filled",
3249
+ hasCloseButton: true,
3250
+ disabled: true,
3251
+ className: twMerge("[&>svg]:text-functional-disable-text")
3252
+ },
3253
+ // Filled - Icon
3254
+ {
3255
+ color: "default",
3256
+ variant: "filled",
3257
+ hasIcon: true,
3258
+ disabled: false,
3259
+ className: twMerge("[&>svg]:text-functional-text-light")
3260
+ },
3261
+ {
3262
+ color: "default",
3263
+ variant: "filled",
3264
+ hasIcon: true,
3265
+ disabled: true,
3266
+ className: twMerge("[&>svg]:text-functional-disable-text")
3267
+ },
3268
+ // Stroke - Base
3269
+ {
3270
+ color: "default",
3271
+ variant: "stroke",
3272
+ disabled: false,
3273
+ className: twMerge(
3274
+ "bg-functional-border-divider hover:bg-grey-300",
3275
+ "text-functional-text",
3276
+ "border border-functional-border-darker"
3277
+ )
3278
+ },
3279
+ {
3280
+ color: "default",
3281
+ variant: "stroke",
3282
+ disabled: true,
3283
+ className: twMerge(
3284
+ "bg-functional-disable-light",
3285
+ "text-functional-disable-text",
3286
+ "border border-functional-border-divider"
3287
+ )
3288
+ },
3289
+ // Stroke - Close button
3290
+ {
3291
+ color: "default",
3292
+ variant: "stroke",
3293
+ hasCloseButton: true,
3294
+ disabled: false,
3295
+ className: twMerge(
3296
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
3297
+ )
3298
+ },
3299
+ {
3300
+ color: "default",
3301
+ variant: "stroke",
3302
+ hasCloseButton: true,
3303
+ disabled: true,
3304
+ className: twMerge("[&>svg]:text-functional-disable-text")
3305
+ },
3306
+ // Stroke - Icon
3307
+ {
3308
+ color: "default",
3309
+ variant: "stroke",
3310
+ hasIcon: true,
3311
+ disabled: false,
3312
+ className: twMerge("[&>svg]:text-functional-text-light")
3313
+ },
3314
+ {
3315
+ color: "default",
3316
+ variant: "stroke",
3317
+ hasIcon: true,
3318
+ disabled: true,
3319
+ className: twMerge("[&>svg]:text-functional-disable-text")
3320
+ }
3321
+ ];
3322
+ var primaryBlueCompounds = [
3323
+ ...compoundsCreator("primary-blue", "filled", [
3324
+ {
3325
+ disabled: false,
3326
+ className: twMerge(
3327
+ "bg-primary-200 hover:bg-primary-150",
3328
+ "text-functional-text"
3329
+ )
3330
+ },
3331
+ {
3332
+ disabled: true,
3333
+ className: twMerge("bg-primary-50", "text-functional-disable-text")
3334
+ },
3335
+ {
3336
+ hasCloseButton: true,
3337
+ disabled: false,
3338
+ className: twMerge(
3339
+ "[&>svg]:text-grey-0 [&>svg]:hover:text-functional-text"
3340
+ )
3341
+ },
3342
+ {
3343
+ hasCloseButton: true,
3344
+ disabled: true,
3345
+ className: twMerge("[&>svg]:text-functional-disable-text")
3346
+ },
3347
+ {
3348
+ hasIcon: true,
3349
+ disabled: false,
3350
+ className: twMerge("[&>svg]:text-functional-text-light")
3351
+ },
3352
+ {
3353
+ hasIcon: true,
3354
+ disabled: true,
3355
+ className: twMerge("[&>svg]:text-functional-disable-text")
3356
+ }
3357
+ ]),
3358
+ ...compoundsCreator("primary-blue", "stroke", [
3359
+ {
3360
+ disabled: false,
3361
+ className: twMerge(
3362
+ "bg-primary-0 hover:bg-primary-50",
3363
+ "text-functional-text",
3364
+ "border border-primary-200"
3365
+ )
3366
+ },
3367
+ {
3368
+ disabled: true,
3369
+ className: twMerge(
3370
+ "bg-primary-0",
3371
+ "text-functional-disable-text",
3372
+ "border border-primary-50"
3373
+ )
3374
+ },
3375
+ {
3376
+ hasCloseButton: true,
3377
+ disabled: false,
3378
+ className: twMerge(
3379
+ "[&>svg]:text-primary-200 [&>svg]:hover:text-functional-text"
3380
+ )
3381
+ },
3382
+ {
3383
+ hasCloseButton: true,
3384
+ disabled: true,
3385
+ className: twMerge("[&>svg]:text-functional-disable-text")
3386
+ },
3387
+ {
3388
+ hasIcon: true,
3389
+ disabled: false,
3390
+ className: twMerge("[&>svg]:text-primary-200")
3391
+ },
3392
+ {
3393
+ hasIcon: true,
3394
+ disabled: true,
3395
+ className: twMerge("[&>svg]:text-functional-disable-text")
3396
+ }
3397
+ ])
3398
+ ];
3399
+ var blueCompounds = [
3400
+ ...compoundsCreator("blue", "filled", [
3401
+ {
3402
+ disabled: false,
3403
+ className: twMerge(
3404
+ "bg-blue-200 hover:bg-blue-150",
3405
+ "text-functional-text"
3406
+ )
3407
+ },
3408
+ {
3409
+ disabled: true,
3410
+ className: twMerge("bg-blue-50", "text-functional-disable-text")
3411
+ },
3412
+ {
3413
+ hasCloseButton: true,
3414
+ disabled: false,
3415
+ className: twMerge(
3416
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
3417
+ )
3418
+ },
3419
+ {
3420
+ hasCloseButton: true,
3421
+ disabled: true,
3422
+ className: twMerge("[&>svg]:text-functional-disable-text")
3423
+ },
3424
+ {
3425
+ hasIcon: true,
3426
+ disabled: false,
3427
+ className: twMerge("[&>svg]:text-functional-text-light")
3428
+ },
3429
+ {
3430
+ hasIcon: true,
3431
+ disabled: true,
3432
+ className: twMerge("[&>svg]:text-functional-disable-text")
3433
+ }
3434
+ ]),
3435
+ ...compoundsCreator("blue", "stroke", [
3436
+ {
3437
+ disabled: false,
3438
+ className: twMerge(
3439
+ "bg-blue-50 hover:bg-blue-100",
3440
+ "text-functional-text",
3441
+ "border border-primary-400"
3442
+ )
3443
+ },
3444
+ {
3445
+ disabled: true,
3446
+ className: twMerge(
3447
+ "bg-blue-0",
3448
+ "text-functional-disable-text",
3449
+ "border border-primary-150"
3450
+ )
3451
+ },
3452
+ {
3453
+ hasCloseButton: true,
3454
+ disabled: false,
3455
+ className: twMerge(
3456
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
3457
+ )
3458
+ },
3459
+ {
3460
+ hasCloseButton: true,
3461
+ disabled: true,
3462
+ className: twMerge("[&>svg]:text-functional-disable-text")
3463
+ },
3464
+ {
3465
+ hasIcon: true,
3466
+ disabled: false,
3467
+ className: twMerge("[&>svg]:text-functional-text-light")
3468
+ },
3469
+ {
3470
+ hasIcon: true,
3471
+ disabled: true,
3472
+ className: twMerge("[&>svg]:text-functional-disable-text")
3473
+ }
3474
+ ])
3475
+ ];
3476
+ var cyanCompounds = [
3477
+ ...compoundsCreator("cyan", "filled", [
3478
+ {
3479
+ disabled: false,
3480
+ className: twMerge(
3481
+ "bg-secondary-200 hover:bg-secondary-150",
3482
+ "text-functional-text"
3483
+ )
3484
+ },
3485
+ {
3486
+ disabled: true,
3487
+ className: twMerge("bg-secondary-50", "text-functional-disable-text")
3488
+ },
3489
+ {
3490
+ hasCloseButton: true,
3491
+ disabled: false,
3492
+ className: twMerge(
3493
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
3494
+ )
3495
+ },
3496
+ {
3497
+ hasCloseButton: true,
3498
+ disabled: true,
3499
+ className: twMerge("[&>svg]:text-functional-disable-text")
3500
+ },
3501
+ {
3502
+ hasIcon: true,
3503
+ disabled: false,
3504
+ className: twMerge("[&>svg]:text-functional-text-light")
3505
+ },
3506
+ {
3507
+ hasIcon: true,
3508
+ disabled: true,
3509
+ className: twMerge("[&>svg]:text-functional-disable-text")
3510
+ }
3511
+ ]),
3512
+ ...compoundsCreator("cyan", "stroke", [
3513
+ {
3514
+ disabled: false,
3515
+ className: twMerge(
3516
+ "bg-secondary-50 hover:bg-secondary-100",
3517
+ "text-functional-text",
3518
+ "border border-secondary-600"
3519
+ )
3520
+ },
3521
+ {
3522
+ disabled: true,
3523
+ className: twMerge(
3524
+ "bg-secondary-0",
3525
+ "text-functional-disable-text",
3526
+ "border border-secondary-150"
3527
+ )
3528
+ },
3529
+ {
3530
+ hasCloseButton: true,
3531
+ disabled: false,
3532
+ className: twMerge(
3533
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
3534
+ )
3535
+ },
3536
+ {
3537
+ hasCloseButton: true,
3538
+ disabled: true,
3539
+ className: twMerge("[&>svg]:text-functional-disable-text")
3540
+ },
3541
+ {
3542
+ hasIcon: true,
3543
+ disabled: false,
3544
+ className: twMerge("[&>svg]:text-functional-text-light")
3545
+ },
3546
+ {
3547
+ hasIcon: true,
3548
+ disabled: true,
3549
+ className: twMerge("[&>svg]:text-functional-disable-text")
3550
+ }
3551
+ ])
3552
+ ];
3553
+ var darkCompounds = [
3554
+ ...compoundsCreator("dark", "filled", [
3555
+ {
3556
+ disabled: false,
3557
+ className: twMerge("bg-dark-500 hover:bg-dark-400", "text-grey-0")
3558
+ },
3559
+ {
3560
+ disabled: true,
3561
+ className: twMerge("bg-functional-disable", "text-grey-0")
3562
+ },
3563
+ {
3564
+ hasCloseButton: true,
3565
+ disabled: false,
3566
+ className: twMerge("[&>svg]:text-dark-150 [&>svg]:hover:text-grey-0")
3567
+ },
3568
+ {
3569
+ hasCloseButton: true,
3570
+ disabled: true,
3571
+ className: twMerge("[&>svg]:text-grey-0")
3572
+ },
3573
+ {
3574
+ hasIcon: true,
3575
+ disabled: false,
3576
+ className: twMerge("[&>svg]:text-dark-150")
3577
+ },
3578
+ {
3579
+ hasIcon: true,
3580
+ disabled: true,
3581
+ className: twMerge("[&>svg]:text-grey-0")
3582
+ }
3583
+ ]),
3584
+ ...compoundsCreator("dark", "stroke", [
3585
+ {
3586
+ disabled: false,
3587
+ className: twMerge(
3588
+ "bg-dark-50 hover:bg-dark-100",
3589
+ "text-functional-text",
3590
+ "border border-functional-text"
3591
+ )
3592
+ },
3593
+ {
3594
+ disabled: true,
3595
+ className: twMerge(
3596
+ "bg-dark-0",
3597
+ "text-functional-border-divider",
3598
+ "border border-functional-border-divider"
3599
+ )
3600
+ },
3601
+ {
3602
+ hasCloseButton: true,
3603
+ disabled: false,
3604
+ className: twMerge(
3605
+ "[&>svg]:text-functional-text-light [&>svg]:hover:text-functional-text"
3606
+ )
3607
+ },
3608
+ {
3609
+ hasCloseButton: true,
3610
+ disabled: true,
3611
+ className: twMerge("[&>svg]:text-functional-border-divider")
3612
+ },
3613
+ {
3614
+ hasIcon: true,
3615
+ disabled: false,
3616
+ className: twMerge("[&>svg]:text-functional-text-light")
3617
+ },
3618
+ {
3619
+ hasIcon: true,
3620
+ disabled: true,
3621
+ className: twMerge("[&>svg]:text-functional-border-divider")
3622
+ }
3623
+ ])
3624
+ ];
3625
+ var tag = cva(
3626
+ [
3627
+ "inline-flex items-center gap-x-[5px] whitespace-nowrap",
3628
+ "h-[21px] w-fit cursor-default rounded-[20px] px-2.5 py-1",
3629
+ "secondary-body5 font-semibold"
3630
+ ],
3631
+ {
3632
+ variants: {
3633
+ // Use `as` for `compoundVariants` to infer the type.
3634
+ color: {},
3635
+ variant: {},
3636
+ hasCloseButton: {
3637
+ true: void 0
3638
+ },
3639
+ hasIcon: {
3640
+ true: void 0
3641
+ },
3642
+ disabled: {
3643
+ true: void 0
3644
+ }
3645
+ },
3646
+ compoundVariants: [
3647
+ ...defaultCompounds,
3648
+ ...primaryBlueCompounds,
3649
+ ...blueCompounds,
3650
+ ...cyanCompounds,
3651
+ ...darkCompounds
3652
+ ]
3653
+ }
3654
+ );
3655
+ var closeButton = cva("icon-xs", {
3656
+ variants: {
3657
+ disabled: {
3658
+ false: "cursor-pointer",
3659
+ true: "cursor-default"
3660
+ }
3661
+ }
3662
+ });
3663
+ var skeleton2 = cva("h-[23px] rounded-full", {
3664
+ variants: {
3665
+ hasIcon: {
3666
+ true: "w-[95px]",
3667
+ false: "w-[80px]"
3668
+ }
3669
+ }
3670
+ });
3671
+ var CubeTagSkeleton = (props) => {
3672
+ const { hasIcon } = props;
3673
+ return /* @__PURE__ */ jsx(CubeSkeleton, { className: twMerge(skeleton2({ hasIcon })) });
3674
+ };
3675
+ var CubeTag = (props) => {
3676
+ const {
3677
+ className,
3678
+ children,
3679
+ color = "default",
3680
+ variant,
3681
+ disabled = false,
3682
+ isLoading = false
3683
+ } = props;
3684
+ const hasIcon = "Icon" in props;
3685
+ const hasCloseButton = "showCloseButton" in props && props.showCloseButton;
3686
+ const renderIcon = () => {
3687
+ if (!hasIcon) {
3688
+ return void 0;
3689
+ }
3690
+ const { Icon } = props;
3691
+ return /* @__PURE__ */ jsx(Icon, { className: "icon-xs" });
3692
+ };
3693
+ const renderCloseButton = () => {
3694
+ if (!hasCloseButton) {
3695
+ return void 0;
3696
+ }
3697
+ const { onClose: onCloseProp } = props;
3698
+ const onClose = () => {
3699
+ if (!disabled) {
3700
+ onCloseProp?.();
3701
+ }
3702
+ };
3703
+ return /* @__PURE__ */ jsx(X_default, { className: closeButton({ disabled }), onClick: onClose });
3704
+ };
3705
+ if (isLoading) return /* @__PURE__ */ jsx(CubeTagSkeleton, { hasIcon: hasIcon || hasCloseButton });
3706
+ return /* @__PURE__ */ jsxs(
3707
+ "span",
3708
+ {
3709
+ className: twMerge(
3710
+ tag({
3711
+ color,
3712
+ variant,
3713
+ hasCloseButton,
3714
+ hasIcon,
3715
+ disabled
3716
+ }),
3717
+ className
3718
+ ),
3719
+ children: [
3720
+ renderIcon(),
3721
+ children,
3722
+ renderCloseButton()
3723
+ ]
3724
+ }
3725
+ );
3726
+ };
3727
+ CubeTag.Skeleton = CubeTagSkeleton;
3728
+ var CubeTextareaSkeleton = () => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-[6px]", children: [
3729
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "h-[20px] min-w-[280px] max-w-[380px]" }),
3730
+ /* @__PURE__ */ jsx(CubeSkeleton, { className: "h-[140px] min-w-[280px] max-w-[380px]" })
3731
+ ] });
3732
+ var useVisibleRowsCount = () => {
3733
+ const textareaRef = useRef(null);
3734
+ const [visibleRowsCount, setVisibleRowsCount] = useState(0);
3735
+ useEffect(() => {
3736
+ const textarea2 = textareaRef.current;
3737
+ let observer = void 0;
3738
+ if (textarea2) {
3739
+ observer = new ResizeObserver((entries) => {
3740
+ const { lineHeight } = getComputedStyle(textarea2);
3741
+ const lineHeightPx = parseInt(lineHeight);
3742
+ const textareaHeight = entries[0]?.contentBoxSize[0]?.blockSize ?? 0;
3743
+ setVisibleRowsCount(
3744
+ Math.ceil((textareaHeight + textarea2.scrollTop) / lineHeightPx)
3745
+ );
3746
+ });
3747
+ observer.observe(textarea2);
3748
+ }
3749
+ return () => {
3750
+ observer?.disconnect();
3751
+ };
3752
+ }, []);
3753
+ return {
3754
+ textareaRef,
3755
+ visibleRowsCount
3756
+ };
3757
+ };
3758
+ var textarea = cva(
3759
+ [
3760
+ "primary-body2 rounded-[5px] bg-grey-0 px-4 py-[10px] outline-none",
3761
+ "max-h-[260px] min-h-[140px] min-w-[280px]",
3762
+ "text-functional-text placeholder:text-functional-border-darker",
3763
+ "border border-functional-border-divider",
3764
+ "hover:border-functional-hover-primary focus:border-functional-hover-primary"
3765
+ ],
3766
+ {
3767
+ variants: {
3768
+ isError: {
3769
+ true: "border-status-negative hover:border-status-negative"
3770
+ },
3771
+ disabled: {
3772
+ true: [
3773
+ "disabled:border-functional-disable-text disabled:text-functional-disable-text disabled:placeholder:text-functional-border-divider",
3774
+ "disabled:hover:border-functional-disable-text"
3775
+ ]
3776
+ }
3777
+ }
3778
+ }
3779
+ );
3780
+ var CubeTextarea = (props) => {
3781
+ const {
3782
+ id: textareaId,
3783
+ ref,
3784
+ className,
3785
+ disabled,
3786
+ value: valueProps,
3787
+ onChange,
3788
+ label: label6,
3789
+ maxLength,
3790
+ isLoading,
3791
+ errorMessage,
3792
+ ...restProps
3793
+ } = props;
3794
+ const [charCount, setCharCount] = useState(
3795
+ () => calculateValueLength(valueProps)
3796
+ );
3797
+ const [isFocused, setIsFocused] = useState(false);
3798
+ useEffect(() => {
3799
+ setCharCount(calculateValueLength(valueProps));
3800
+ }, [valueProps]);
3801
+ const { textareaRef: localRef, visibleRowsCount } = useVisibleRowsCount();
3802
+ const handleChange = (e) => {
3803
+ const newValue = e.target.value;
3804
+ if (newValue.length <= maxLength) {
3805
+ setCharCount(newValue.length);
3806
+ onChange?.(e);
3807
+ }
3808
+ };
3809
+ if (isLoading) {
3810
+ return /* @__PURE__ */ jsx(CubeTextareaSkeleton, {});
3811
+ }
3812
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-[6px]", children: [
3813
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
3814
+ /* @__PURE__ */ jsx(
3815
+ "label",
3816
+ {
3817
+ htmlFor: textareaId,
3818
+ className: "primary-body2 font-semibold text-functional-text",
3819
+ children: label6
3820
+ }
3821
+ ),
3822
+ /* @__PURE__ */ jsxs("div", { className: "secondary-body4 text-functional-text-light", children: [
3823
+ charCount.toLocaleString("en-US"),
3824
+ "/",
3825
+ maxLength.toLocaleString("en-US")
3826
+ ] })
3827
+ ] }),
3828
+ /* @__PURE__ */ jsx(
3829
+ "textarea",
3830
+ {
3831
+ ...restProps,
3832
+ id: textareaId,
3833
+ disabled,
3834
+ ref: (element) => {
3835
+ assignRefValue(ref, element);
3836
+ assignRefValue(localRef, element);
3837
+ },
3838
+ value: valueProps,
3839
+ onChange: handleChange,
3840
+ onFocus: () => setIsFocused(true),
3841
+ onBlur: () => setIsFocused(false),
3842
+ className: twMerge(
3843
+ textarea({ isError: !!errorMessage, disabled }),
3844
+ className
3845
+ ),
3846
+ style: isFocused ? void 0 : {
3847
+ overflow: "hidden",
3848
+ display: "-webkit-box",
3849
+ WebkitBoxOrient: "vertical",
3850
+ WebkitLineClamp: visibleRowsCount
3851
+ }
3852
+ }
3853
+ ),
3854
+ errorMessage && /* @__PURE__ */ jsx("p", { className: "primary-body4 text-status-negative", children: errorMessage })
3855
+ ] });
3856
+ };
3857
+ CubeTextarea.Skeleton = CubeTextareaSkeleton;
3858
+ var caret = cva(
3859
+ "inline-block size-0 border-[6px] border-t-0 border-solid border-transparent border-b-dark-700",
3860
+ {
3861
+ variants: {
3862
+ horizontalPlacement: {
3863
+ left: "ml-4 self-start",
3864
+ center: "self-center",
3865
+ right: "mr-4 self-end",
3866
+ "follow-cursor": "self-center"
3867
+ }
3868
+ }
3869
+ }
3870
+ );
3871
+ var infoBoxContainer = cva(
3872
+ "pointer-events-none flex min-w-[50px] max-w-[480px]",
3873
+ {
3874
+ variants: {
3875
+ verticalPlacement: {
3876
+ top: "flex-col",
3877
+ bottom: "flex-col-reverse"
3878
+ },
3879
+ /**
3880
+ * Hidden and pinned to the viewport's top-left corner: `fixed` keeps it
3881
+ * out of the document flow (no extra scroll height), and the left edge
3882
+ * gives it the full viewport width so it's measured without wrapping.
3883
+ */
3884
+ isMeasuring: {
3885
+ true: "invisible fixed left-0 top-0",
3886
+ false: "absolute"
3887
+ }
3888
+ }
3889
+ }
3890
+ );
3891
+ var Caret = (props) => {
3892
+ const { placement, translateX: translateXProp } = props;
3893
+ const [verticalPlacement, horizontalPlacement] = splitPlacements(placement);
3894
+ const style = useMemo(() => {
3895
+ const rotateAngle = verticalPlacement === "top" ? 180 : 0;
3896
+ let translateX = translateXProp;
3897
+ if (verticalPlacement === "bottom" && horizontalPlacement === "follow-cursor" && translateXProp < 0) {
3898
+ translateX = translateXProp * -1;
3899
+ }
3900
+ return {
3901
+ transform: `rotate(${rotateAngle}deg) translateX(${translateX}px)`
3902
+ };
3903
+ }, [verticalPlacement, horizontalPlacement, translateXProp]);
3904
+ return /* @__PURE__ */ jsx(
3905
+ "span",
3906
+ {
3907
+ className: twMerge(
3908
+ caret({
3909
+ horizontalPlacement
3910
+ })
3911
+ ),
3912
+ style
3913
+ }
3914
+ );
3915
+ };
3916
+ var InfoBox = (props) => {
3917
+ const {
3918
+ id,
3919
+ information: { title, subtext, message },
3920
+ placement,
3921
+ mouseX,
3922
+ anchorRef
3923
+ } = props;
3924
+ const { elementRef, resolvedStyles } = useFloating({
3925
+ isOpen: true,
3926
+ anchorRef,
3927
+ placement,
3928
+ offsets: {
3929
+ x: 14,
3930
+ y: 2
3931
+ },
3932
+ mouseX
3933
+ });
3934
+ const {
3935
+ idealPlacement = placement,
3936
+ floatingStyle,
3937
+ translateX = 0
3938
+ } = resolvedStyles ?? {};
3939
+ const [verticalPlacement] = splitPlacements(idealPlacement);
3940
+ const renderContent = () => {
3941
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-0.5 rounded-[5px] bg-dark-700 px-3 pb-2.5 pt-2", children: [
3942
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-6 text-primary-200", children: [
3943
+ /* @__PURE__ */ jsx("div", { className: "primary-body2 shrink-0 font-semibold", children: title }),
3944
+ /* @__PURE__ */ jsx("div", { className: "primary-body4 shrink-0", children: subtext })
3945
+ ] }),
3946
+ /* @__PURE__ */ jsx("p", { className: "primary-body3 text-grey-0", children: message })
3947
+ ] });
3948
+ };
3949
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3950
+ /* @__PURE__ */ jsx(
3951
+ "div",
3952
+ {
3953
+ ref: elementRef,
3954
+ "aria-hidden": true,
3955
+ className: infoBoxContainer({
3956
+ verticalPlacement,
3957
+ isMeasuring: true
3958
+ }),
3959
+ children: renderContent()
3960
+ }
3961
+ ),
3962
+ /* @__PURE__ */ jsxs(
3963
+ "div",
3964
+ {
3965
+ id,
3966
+ role: "tooltip",
3967
+ className: infoBoxContainer({
3968
+ verticalPlacement,
3969
+ isMeasuring: !floatingStyle
3970
+ }),
3971
+ style: floatingStyle,
3972
+ children: [
3973
+ renderContent(),
3974
+ /* @__PURE__ */ jsx(Caret, { placement: idealPlacement, translateX })
3975
+ ]
3976
+ }
3977
+ )
3978
+ ] });
3979
+ };
3980
+ var CubeTooltip = (props) => {
3981
+ const {
3982
+ placement = "top-center",
3983
+ hoverContent,
3984
+ clickContent,
3985
+ children: anchorElement
3986
+ } = props;
3987
+ const [visibilityState, setVisibilityState] = useState(void 0);
3988
+ const [mouseX, setMouseX] = useState(0);
3989
+ const anchorRef = useRef(null);
3990
+ const tooltipId = useId();
3991
+ const infoMap = {
3992
+ hover: hoverContent,
3993
+ click: clickContent
3994
+ };
3995
+ const isVisible = visibilityState !== void 0 && infoMap[visibilityState] !== void 0;
3996
+ useEffect(() => {
3997
+ if (!isVisible) return;
3998
+ const onKeyDown = (e) => {
3999
+ if (e.key === "Escape") {
4000
+ setVisibilityState(void 0);
4001
+ }
4002
+ };
4003
+ document.addEventListener("keydown", onKeyDown);
4004
+ return () => {
4005
+ document.removeEventListener("keydown", onKeyDown);
4006
+ };
4007
+ }, [isVisible]);
4008
+ const onMouseEnter = (e) => {
4009
+ if (hoverContent) {
4010
+ setVisibilityState("hover");
4011
+ }
4012
+ anchorElement.props.onMouseEnter?.(e);
4013
+ };
4014
+ const onMouseMove = (e) => {
4015
+ setMouseX(e.clientX);
4016
+ anchorElement.props.onMouseMove?.(e);
4017
+ };
4018
+ const onMouseLeave = (e) => {
4019
+ setVisibilityState(void 0);
4020
+ anchorElement.props.onMouseLeave?.(e);
4021
+ };
4022
+ const onClick = (e) => {
4023
+ if (clickContent) {
4024
+ setVisibilityState("click");
4025
+ }
4026
+ anchorElement.props.onClick?.(e);
4027
+ };
4028
+ const onFocus = (e) => {
4029
+ if (hoverContent) {
4030
+ const rect = e.currentTarget.getBoundingClientRect();
4031
+ setMouseX(rect.left + rect.width / 2);
4032
+ setVisibilityState("hover");
4033
+ }
4034
+ anchorElement.props.onFocus?.(e);
4035
+ };
4036
+ const onBlur = (e) => {
4037
+ setVisibilityState(void 0);
4038
+ anchorElement.props.onBlur?.(e);
4039
+ };
4040
+ if (anchorElement.type === Fragment) {
4041
+ throw new Error("Fragment children is not supported in CubeTooltip");
4042
+ }
4043
+ const ariaDescribedBy = [anchorElement.props["aria-describedby"], isVisible ? tooltipId : null].filter(Boolean).join(" ") || void 0;
4044
+ const clonedAnchor = cloneElement(anchorElement, {
4045
+ ref: (element) => {
4046
+ const { ref: anchorRefProp } = anchorElement.props;
4047
+ assignRefValue(anchorRefProp, element);
4048
+ assignRefValue(anchorRef, element);
4049
+ },
4050
+ onMouseEnter,
4051
+ onMouseMove,
4052
+ onMouseLeave,
4053
+ onClick,
4054
+ onFocus,
4055
+ onBlur,
4056
+ "aria-describedby": ariaDescribedBy
4057
+ });
4058
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
4059
+ clonedAnchor,
4060
+ visibilityState !== void 0 && infoMap[visibilityState] && createPortal(
4061
+ /* @__PURE__ */ jsx(
4062
+ InfoBox,
4063
+ {
4064
+ id: tooltipId,
4065
+ information: infoMap[visibilityState],
4066
+ placement,
4067
+ mouseX,
4068
+ anchorRef
4069
+ },
4070
+ visibilityState
4071
+ ),
4072
+ document.body
4073
+ )
4074
+ ] });
4075
+ };
4076
+
4077
+ // src/i18n/addCubeUiTranslations.ts
4078
+ function addCubeUiTranslations(locale, resources) {
4079
+ i18n_default.addResourceBundle(locale, "translation", resources, true, true);
4080
+ if (i18n_default.isInitialized) {
4081
+ i18n_default.emit("languageChanged", i18n_default.language);
4082
+ }
4083
+ }
4084
+ var CubeUiLocaleProvider = (props) => {
4085
+ const { locale, children } = props;
4086
+ useEffect(() => {
4087
+ i18n_default.changeLanguage(locale);
4088
+ }, [locale]);
4089
+ return children;
4090
+ };
794
4091
  var CubeThemeProvider = (props) => {
795
4092
  const { theme, children } = props;
796
4093
  useEffect(() => {
@@ -1458,6 +4755,6 @@ var cubePreset = {
1458
4755
  ]
1459
4756
  };
1460
4757
 
1461
- export { CubeButton, CubeButtonSkeleton, CubeIconFrame, CubeInput, CubeLoadingSpinner, CubePasswordInput, CubeSkeleton, CubeThemeProvider, CubeUiLocaleProvider, addCubeUiTranslations, cubePreset, cubeTheme, getTypography, useCubeUiTranslation };
4758
+ export { CubeButton, CubeCheckbox, CubeDropdown, CubeHyperlink, CubeIconFrame, CubeInput, CubeLoadingSpinner, CubeOverflowMenu, CubePasswordInput, CubeRadioButton, CubeSkeleton, CubeStatus, CubeStatusReaction, CubeStepProcess, CubeStroke, CubeTabs, CubeTag, CubeTextarea, CubeThemeProvider, CubeToggle, CubeTooltip, CubeUiLocaleProvider, addCubeUiTranslations, cubePreset, cubeTheme, getTypography, useCubeUiTranslation };
1462
4759
  //# sourceMappingURL=index.mjs.map
1463
4760
  //# sourceMappingURL=index.mjs.map