analytica-frontend-lib 1.0.24 → 1.0.25
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/{chunk-JNPCNN67.mjs → Alert/Alert.mjs} +1 -2
- package/dist/{chunk-GSEO6POW.mjs → Badge/Badge.mjs} +0 -1
- package/dist/{chunk-IB4IJ3GF.mjs → Button/Button.mjs} +0 -1
- package/dist/{chunk-LYOJCBOM.mjs → CheckBox/CheckBox.mjs} +2 -2
- package/dist/{chunk-KT6HNGRV.mjs → DropdownMenu/DropdownMenu.mjs} +3 -2
- package/dist/{chunk-RPYPJ5O5.mjs → IconButton/IconButton.mjs} +0 -1
- package/dist/{chunk-QOFMTSHE.mjs → IconRoundedButton/IconRoundedButton.mjs} +0 -1
- package/dist/{chunk-CETSS3RA.mjs → NavButton/NavButton.mjs} +0 -1
- package/dist/{chunk-SESX5OEP.mjs → SelectionButton/SelectionButton.mjs} +0 -1
- package/dist/{chunk-NWGRQN6R.mjs → Table/Table.mjs} +4 -5
- package/dist/{components/Text → Text}/Text.mjs +1 -1
- package/dist/{chunk-QODEDLAX.mjs → TextArea/TextArea.mjs} +2 -2
- package/dist/{components/Toast → Toast}/Toast.mjs +1 -1
- package/dist/{components/Toast → Toast}/utils/ToastStore.mjs +1 -1
- package/dist/{chunk-IH5TEC64.mjs → Toast/utils/Toaster.mjs} +3 -3
- package/dist/index.d.mts +154 -26
- package/dist/index.d.ts +154 -26
- package/dist/index.js +671 -16
- package/dist/index.mjs +676 -8
- package/package.json +1 -6
- package/dist/client-components.d.mts +0 -9
- package/dist/client-components.d.ts +0 -9
- package/dist/client-components.js +0 -755
- package/dist/client-components.mjs +0 -39
- package/dist/components/Alert/Alert.mjs +0 -7
- package/dist/components/Badge/Badge.mjs +0 -6
- package/dist/components/Button/Button.mjs +0 -6
- package/dist/components/CheckBox/CheckBox.mjs +0 -8
- package/dist/components/DropdownMenu/DropdownMenu.mjs +0 -17
- package/dist/components/IconButton/IconButton.mjs +0 -6
- package/dist/components/IconRoundedButton/IconRoundedButton.mjs +0 -6
- package/dist/components/NavButton/NavButton.mjs +0 -6
- package/dist/components/SelectionButton/SelectionButton.mjs +0 -6
- package/dist/components/Table/Table.mjs +0 -20
- package/dist/components/TextArea/TextArea.mjs +0 -8
- package/dist/components/Toast/utils/Toaster.mjs +0 -11
- package/dist/server-components.d.mts +0 -11
- package/dist/server-components.d.ts +0 -11
- package/dist/server-components.js +0 -629
- package/dist/server-components.mjs +0 -52
- /package/dist/{components/Alert → Alert}/Alert.d.mts +0 -0
- /package/dist/{components/Alert → Alert}/Alert.d.ts +0 -0
- /package/dist/{components/Alert → Alert}/Alert.js +0 -0
- /package/dist/{components/Badge → Badge}/Badge.d.mts +0 -0
- /package/dist/{components/Badge → Badge}/Badge.d.ts +0 -0
- /package/dist/{components/Badge → Badge}/Badge.js +0 -0
- /package/dist/{components/Button → Button}/Button.d.mts +0 -0
- /package/dist/{components/Button → Button}/Button.d.ts +0 -0
- /package/dist/{components/Button → Button}/Button.js +0 -0
- /package/dist/{components/CheckBox → CheckBox}/CheckBox.d.mts +0 -0
- /package/dist/{components/CheckBox → CheckBox}/CheckBox.d.ts +0 -0
- /package/dist/{components/CheckBox → CheckBox}/CheckBox.js +0 -0
- /package/dist/{components/DropdownMenu → DropdownMenu}/DropdownMenu.d.mts +0 -0
- /package/dist/{components/DropdownMenu → DropdownMenu}/DropdownMenu.d.ts +0 -0
- /package/dist/{components/DropdownMenu → DropdownMenu}/DropdownMenu.js +0 -0
- /package/dist/{components/IconButton → IconButton}/IconButton.d.mts +0 -0
- /package/dist/{components/IconButton → IconButton}/IconButton.d.ts +0 -0
- /package/dist/{components/IconButton → IconButton}/IconButton.js +0 -0
- /package/dist/{components/IconRoundedButton → IconRoundedButton}/IconRoundedButton.d.mts +0 -0
- /package/dist/{components/IconRoundedButton → IconRoundedButton}/IconRoundedButton.d.ts +0 -0
- /package/dist/{components/IconRoundedButton → IconRoundedButton}/IconRoundedButton.js +0 -0
- /package/dist/{components/NavButton → NavButton}/NavButton.d.mts +0 -0
- /package/dist/{components/NavButton → NavButton}/NavButton.d.ts +0 -0
- /package/dist/{components/NavButton → NavButton}/NavButton.js +0 -0
- /package/dist/{components/SelectionButton → SelectionButton}/SelectionButton.d.mts +0 -0
- /package/dist/{components/SelectionButton → SelectionButton}/SelectionButton.d.ts +0 -0
- /package/dist/{components/SelectionButton → SelectionButton}/SelectionButton.js +0 -0
- /package/dist/{components/Table → Table}/Table.d.mts +0 -0
- /package/dist/{components/Table → Table}/Table.d.ts +0 -0
- /package/dist/{components/Table → Table}/Table.js +0 -0
- /package/dist/{components/Text → Text}/Text.d.mts +0 -0
- /package/dist/{components/Text → Text}/Text.d.ts +0 -0
- /package/dist/{components/Text → Text}/Text.js +0 -0
- /package/dist/{components/TextArea → TextArea}/TextArea.d.mts +0 -0
- /package/dist/{components/TextArea → TextArea}/TextArea.d.ts +0 -0
- /package/dist/{components/TextArea → TextArea}/TextArea.js +0 -0
- /package/dist/{components/Toast → Toast}/Toast.d.mts +0 -0
- /package/dist/{components/Toast → Toast}/Toast.d.ts +0 -0
- /package/dist/{components/Toast → Toast}/Toast.js +0 -0
- /package/dist/{components/Toast → Toast}/utils/ToastStore.d.mts +0 -0
- /package/dist/{components/Toast → Toast}/utils/ToastStore.d.ts +0 -0
- /package/dist/{components/Toast → Toast}/utils/ToastStore.js +0 -0
- /package/dist/{components/Toast → Toast}/utils/Toaster.d.mts +0 -0
- /package/dist/{components/Toast → Toast}/utils/Toaster.d.ts +0 -0
- /package/dist/{components/Toast → Toast}/utils/Toaster.js +0 -0
package/dist/index.mjs
CHANGED
|
@@ -567,21 +567,689 @@ var TableCaption = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
567
567
|
}
|
|
568
568
|
));
|
|
569
569
|
TableCaption.displayName = "TableCaption";
|
|
570
|
+
|
|
571
|
+
// src/components/CheckBox/CheckBox.tsx
|
|
572
|
+
import {
|
|
573
|
+
forwardRef as forwardRef5,
|
|
574
|
+
useState,
|
|
575
|
+
useId
|
|
576
|
+
} from "react";
|
|
577
|
+
import { Check, Minus } from "phosphor-react";
|
|
578
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
579
|
+
var SIZE_CLASSES3 = {
|
|
580
|
+
small: {
|
|
581
|
+
checkbox: "w-4 h-4",
|
|
582
|
+
// 16px x 16px
|
|
583
|
+
textSize: "sm",
|
|
584
|
+
spacing: "gap-1.5",
|
|
585
|
+
// 6px
|
|
586
|
+
borderWidth: "border-2",
|
|
587
|
+
iconSize: 14,
|
|
588
|
+
// pixels for Phosphor icons
|
|
589
|
+
labelHeight: "h-[21px]"
|
|
590
|
+
},
|
|
591
|
+
medium: {
|
|
592
|
+
checkbox: "w-5 h-5",
|
|
593
|
+
// 20px x 20px
|
|
594
|
+
textSize: "md",
|
|
595
|
+
spacing: "gap-2",
|
|
596
|
+
// 8px
|
|
597
|
+
borderWidth: "border-2",
|
|
598
|
+
iconSize: 16,
|
|
599
|
+
// pixels for Phosphor icons
|
|
600
|
+
labelHeight: "h-6"
|
|
601
|
+
},
|
|
602
|
+
large: {
|
|
603
|
+
checkbox: "w-6 h-6",
|
|
604
|
+
// 24px x 24px
|
|
605
|
+
textSize: "lg",
|
|
606
|
+
spacing: "gap-2",
|
|
607
|
+
// 8px
|
|
608
|
+
borderWidth: "border-[3px]",
|
|
609
|
+
// 3px border
|
|
610
|
+
iconSize: 20,
|
|
611
|
+
// pixels for Phosphor icons
|
|
612
|
+
labelHeight: "h-[27px]"
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
var BASE_CHECKBOX_CLASSES = "rounded border cursor-pointer transition-all duration-200 flex items-center justify-center focus:outline-none";
|
|
616
|
+
var STATE_CLASSES = {
|
|
617
|
+
default: {
|
|
618
|
+
unchecked: "border-border-400 bg-background hover:border-border-500",
|
|
619
|
+
checked: "border-primary-950 bg-primary-950 text-text hover:border-primary-800 hover:bg-primary-800"
|
|
620
|
+
},
|
|
621
|
+
hovered: {
|
|
622
|
+
unchecked: "border-border-500 bg-background",
|
|
623
|
+
checked: "border-primary-800 bg-primary-800 text-text"
|
|
624
|
+
},
|
|
625
|
+
focused: {
|
|
626
|
+
unchecked: "border-indicator-info bg-background ring-2 ring-indicator-info/20",
|
|
627
|
+
checked: "border-indicator-info bg-primary-950 text-text ring-2 ring-indicator-info/20"
|
|
628
|
+
},
|
|
629
|
+
invalid: {
|
|
630
|
+
unchecked: "border-error-700 bg-background hover:border-error-600",
|
|
631
|
+
checked: "border-error-700 bg-primary-950 text-text"
|
|
632
|
+
},
|
|
633
|
+
disabled: {
|
|
634
|
+
unchecked: "border-border-400 bg-background cursor-not-allowed opacity-40",
|
|
635
|
+
checked: "border-primary-600 bg-primary-600 text-text cursor-not-allowed opacity-40"
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
var CheckBox = forwardRef5(
|
|
639
|
+
({
|
|
640
|
+
label,
|
|
641
|
+
size = "medium",
|
|
642
|
+
state = "default",
|
|
643
|
+
indeterminate = false,
|
|
644
|
+
errorMessage,
|
|
645
|
+
helperText,
|
|
646
|
+
className = "",
|
|
647
|
+
labelClassName = "",
|
|
648
|
+
checked: checkedProp,
|
|
649
|
+
disabled,
|
|
650
|
+
id,
|
|
651
|
+
onChange,
|
|
652
|
+
...props
|
|
653
|
+
}, ref) => {
|
|
654
|
+
const generatedId = useId();
|
|
655
|
+
const inputId = id ?? `checkbox-${generatedId}`;
|
|
656
|
+
const [internalChecked, setInternalChecked] = useState(false);
|
|
657
|
+
const isControlled = checkedProp !== void 0;
|
|
658
|
+
const checked = isControlled ? checkedProp : internalChecked;
|
|
659
|
+
const handleChange = (event) => {
|
|
660
|
+
if (!isControlled) {
|
|
661
|
+
setInternalChecked(event.target.checked);
|
|
662
|
+
}
|
|
663
|
+
onChange?.(event);
|
|
664
|
+
};
|
|
665
|
+
const currentState = disabled ? "disabled" : state;
|
|
666
|
+
const sizeClasses = SIZE_CLASSES3[size];
|
|
667
|
+
const checkVariant = checked || indeterminate ? "checked" : "unchecked";
|
|
668
|
+
const stylingClasses = STATE_CLASSES[currentState][checkVariant];
|
|
669
|
+
const borderWidthClass = state === "focused" || state === "hovered" && size === "large" ? "border-[3px]" : sizeClasses.borderWidth;
|
|
670
|
+
const checkboxClasses = `${BASE_CHECKBOX_CLASSES} ${sizeClasses.checkbox} ${borderWidthClass} ${stylingClasses} ${className}`;
|
|
671
|
+
const renderIcon = () => {
|
|
672
|
+
if (indeterminate) {
|
|
673
|
+
return /* @__PURE__ */ jsx10(
|
|
674
|
+
Minus,
|
|
675
|
+
{
|
|
676
|
+
size: sizeClasses.iconSize,
|
|
677
|
+
weight: "bold",
|
|
678
|
+
color: "currentColor"
|
|
679
|
+
}
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
if (checked) {
|
|
683
|
+
return /* @__PURE__ */ jsx10(
|
|
684
|
+
Check,
|
|
685
|
+
{
|
|
686
|
+
size: sizeClasses.iconSize,
|
|
687
|
+
weight: "bold",
|
|
688
|
+
color: "currentColor"
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
return null;
|
|
693
|
+
};
|
|
694
|
+
return /* @__PURE__ */ jsxs7("div", { className: "flex flex-col", children: [
|
|
695
|
+
/* @__PURE__ */ jsxs7(
|
|
696
|
+
"div",
|
|
697
|
+
{
|
|
698
|
+
className: `flex flex-row items-center ${sizeClasses.spacing} ${disabled ? "opacity-40" : ""}`,
|
|
699
|
+
children: [
|
|
700
|
+
/* @__PURE__ */ jsx10(
|
|
701
|
+
"input",
|
|
702
|
+
{
|
|
703
|
+
ref,
|
|
704
|
+
type: "checkbox",
|
|
705
|
+
id: inputId,
|
|
706
|
+
checked,
|
|
707
|
+
disabled,
|
|
708
|
+
onChange: handleChange,
|
|
709
|
+
className: "sr-only",
|
|
710
|
+
...props
|
|
711
|
+
}
|
|
712
|
+
),
|
|
713
|
+
/* @__PURE__ */ jsx10("label", { htmlFor: inputId, className: checkboxClasses, children: renderIcon() }),
|
|
714
|
+
label && /* @__PURE__ */ jsx10(
|
|
715
|
+
"div",
|
|
716
|
+
{
|
|
717
|
+
className: `flex flex-row items-center ${sizeClasses.labelHeight}`,
|
|
718
|
+
children: /* @__PURE__ */ jsx10(
|
|
719
|
+
Text,
|
|
720
|
+
{
|
|
721
|
+
as: "label",
|
|
722
|
+
htmlFor: inputId,
|
|
723
|
+
size: sizeClasses.textSize,
|
|
724
|
+
weight: "normal",
|
|
725
|
+
className: `cursor-pointer select-none leading-[150%] flex items-center font-roboto ${labelClassName}`,
|
|
726
|
+
children: label
|
|
727
|
+
}
|
|
728
|
+
)
|
|
729
|
+
}
|
|
730
|
+
)
|
|
731
|
+
]
|
|
732
|
+
}
|
|
733
|
+
),
|
|
734
|
+
errorMessage && /* @__PURE__ */ jsx10(
|
|
735
|
+
Text,
|
|
736
|
+
{
|
|
737
|
+
size: "sm",
|
|
738
|
+
weight: "normal",
|
|
739
|
+
className: "mt-1.5",
|
|
740
|
+
color: "text-error-600",
|
|
741
|
+
children: errorMessage
|
|
742
|
+
}
|
|
743
|
+
),
|
|
744
|
+
helperText && !errorMessage && /* @__PURE__ */ jsx10(
|
|
745
|
+
Text,
|
|
746
|
+
{
|
|
747
|
+
size: "sm",
|
|
748
|
+
weight: "normal",
|
|
749
|
+
className: "mt-1.5",
|
|
750
|
+
color: "text-text-500",
|
|
751
|
+
children: helperText
|
|
752
|
+
}
|
|
753
|
+
)
|
|
754
|
+
] });
|
|
755
|
+
}
|
|
756
|
+
);
|
|
757
|
+
CheckBox.displayName = "CheckBox";
|
|
758
|
+
|
|
759
|
+
// src/components/TextArea/TextArea.tsx
|
|
760
|
+
import {
|
|
761
|
+
forwardRef as forwardRef6,
|
|
762
|
+
useState as useState2,
|
|
763
|
+
useId as useId2
|
|
764
|
+
} from "react";
|
|
765
|
+
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
766
|
+
var SIZE_CLASSES4 = {
|
|
767
|
+
small: {
|
|
768
|
+
container: "w-72",
|
|
769
|
+
// 288px width
|
|
770
|
+
textarea: "h-24 text-sm",
|
|
771
|
+
// 96px height, 14px font
|
|
772
|
+
textSize: "sm"
|
|
773
|
+
},
|
|
774
|
+
medium: {
|
|
775
|
+
container: "w-72",
|
|
776
|
+
// 288px width
|
|
777
|
+
textarea: "h-24 text-base",
|
|
778
|
+
// 96px height, 16px font
|
|
779
|
+
textSize: "md"
|
|
780
|
+
},
|
|
781
|
+
large: {
|
|
782
|
+
container: "w-72",
|
|
783
|
+
// 288px width
|
|
784
|
+
textarea: "h-24 text-lg",
|
|
785
|
+
// 96px height, 18px font
|
|
786
|
+
textSize: "lg"
|
|
787
|
+
},
|
|
788
|
+
extraLarge: {
|
|
789
|
+
container: "w-72",
|
|
790
|
+
// 288px width
|
|
791
|
+
textarea: "h-24 text-xl",
|
|
792
|
+
// 96px height, 20px font
|
|
793
|
+
textSize: "xl"
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
var BASE_TEXTAREA_CLASSES = "w-full box-border p-3 bg-background border border-solid rounded-[4px] resize-none focus:outline-none font-roboto font-normal leading-[150%] placeholder:text-text-600 transition-all duration-200";
|
|
797
|
+
var STATE_CLASSES2 = {
|
|
798
|
+
default: {
|
|
799
|
+
base: "border-border-300 bg-background text-text-600",
|
|
800
|
+
hover: "hover:border-border-400",
|
|
801
|
+
focus: "focus:border-border-500"
|
|
802
|
+
},
|
|
803
|
+
hovered: {
|
|
804
|
+
base: "border-border-400 bg-background text-text-600",
|
|
805
|
+
hover: "",
|
|
806
|
+
focus: "focus:border-border-500"
|
|
807
|
+
},
|
|
808
|
+
focused: {
|
|
809
|
+
base: "border-2 border-primary-950 bg-background text-text-900",
|
|
810
|
+
hover: "",
|
|
811
|
+
focus: ""
|
|
812
|
+
},
|
|
813
|
+
invalid: {
|
|
814
|
+
base: "border-2 border-red-700 bg-white text-gray-800",
|
|
815
|
+
hover: "hover:border-red-700",
|
|
816
|
+
focus: "focus:border-red-700"
|
|
817
|
+
},
|
|
818
|
+
disabled: {
|
|
819
|
+
base: "border-border-300 bg-background text-text-600 cursor-not-allowed opacity-40",
|
|
820
|
+
hover: "",
|
|
821
|
+
focus: ""
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
var TextArea = forwardRef6(
|
|
825
|
+
({
|
|
826
|
+
label,
|
|
827
|
+
size = "medium",
|
|
828
|
+
state = "default",
|
|
829
|
+
errorMessage,
|
|
830
|
+
helperMessage,
|
|
831
|
+
className = "",
|
|
832
|
+
labelClassName = "",
|
|
833
|
+
disabled,
|
|
834
|
+
id,
|
|
835
|
+
onChange,
|
|
836
|
+
placeholder,
|
|
837
|
+
...props
|
|
838
|
+
}, ref) => {
|
|
839
|
+
const generatedId = useId2();
|
|
840
|
+
const inputId = id ?? `textarea-${generatedId}`;
|
|
841
|
+
const [isFocused, setIsFocused] = useState2(false);
|
|
842
|
+
const handleChange = (event) => {
|
|
843
|
+
onChange?.(event);
|
|
844
|
+
};
|
|
845
|
+
const handleFocus = (event) => {
|
|
846
|
+
setIsFocused(true);
|
|
847
|
+
props.onFocus?.(event);
|
|
848
|
+
};
|
|
849
|
+
const handleBlur = (event) => {
|
|
850
|
+
setIsFocused(false);
|
|
851
|
+
props.onBlur?.(event);
|
|
852
|
+
};
|
|
853
|
+
let currentState = disabled ? "disabled" : state;
|
|
854
|
+
if (isFocused && currentState !== "invalid" && currentState !== "disabled") {
|
|
855
|
+
currentState = "focused";
|
|
856
|
+
}
|
|
857
|
+
const sizeClasses = SIZE_CLASSES4[size];
|
|
858
|
+
const stateClasses = STATE_CLASSES2[currentState];
|
|
859
|
+
const textareaClasses = `${BASE_TEXTAREA_CLASSES} ${sizeClasses.textarea} ${stateClasses.base} ${stateClasses.hover} ${stateClasses.focus} ${className}`;
|
|
860
|
+
return /* @__PURE__ */ jsxs8("div", { className: `flex flex-col ${sizeClasses.container}`, children: [
|
|
861
|
+
label && /* @__PURE__ */ jsx11(
|
|
862
|
+
Text,
|
|
863
|
+
{
|
|
864
|
+
as: "label",
|
|
865
|
+
htmlFor: inputId,
|
|
866
|
+
size: sizeClasses.textSize,
|
|
867
|
+
weight: "medium",
|
|
868
|
+
color: "text-text-950",
|
|
869
|
+
className: `mb-1.5 ${labelClassName}`,
|
|
870
|
+
children: label
|
|
871
|
+
}
|
|
872
|
+
),
|
|
873
|
+
/* @__PURE__ */ jsx11(
|
|
874
|
+
"textarea",
|
|
875
|
+
{
|
|
876
|
+
ref,
|
|
877
|
+
id: inputId,
|
|
878
|
+
disabled,
|
|
879
|
+
onChange: handleChange,
|
|
880
|
+
onFocus: handleFocus,
|
|
881
|
+
onBlur: handleBlur,
|
|
882
|
+
className: textareaClasses,
|
|
883
|
+
placeholder,
|
|
884
|
+
...props
|
|
885
|
+
}
|
|
886
|
+
),
|
|
887
|
+
errorMessage && /* @__PURE__ */ jsx11(Text, { size: "sm", weight: "normal", className: "mt-1.5 text-error-600", children: errorMessage }),
|
|
888
|
+
helperMessage && !errorMessage && /* @__PURE__ */ jsx11(Text, { size: "sm", weight: "normal", className: "mt-1.5 text-text-500", children: helperMessage })
|
|
889
|
+
] });
|
|
890
|
+
}
|
|
891
|
+
);
|
|
892
|
+
TextArea.displayName = "TextArea";
|
|
893
|
+
|
|
894
|
+
// src/components/DropdownMenu/DropdownMenu.tsx
|
|
895
|
+
import {
|
|
896
|
+
createContext,
|
|
897
|
+
useState as useState3,
|
|
898
|
+
useCallback,
|
|
899
|
+
useContext,
|
|
900
|
+
forwardRef as forwardRef7,
|
|
901
|
+
useEffect,
|
|
902
|
+
useRef,
|
|
903
|
+
useMemo
|
|
904
|
+
} from "react";
|
|
905
|
+
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
906
|
+
var DropdownMenuContext = createContext(
|
|
907
|
+
void 0
|
|
908
|
+
);
|
|
909
|
+
var DropdownMenu = ({ children, open, onOpenChange }) => {
|
|
910
|
+
const [internalOpen, setInternalOpen] = useState3(false);
|
|
911
|
+
const isControlled = open !== void 0;
|
|
912
|
+
const currentOpen = isControlled ? open : internalOpen;
|
|
913
|
+
const setOpen = useCallback(
|
|
914
|
+
(newOpen) => {
|
|
915
|
+
if (onOpenChange) onOpenChange(newOpen);
|
|
916
|
+
if (!isControlled) setInternalOpen(newOpen);
|
|
917
|
+
},
|
|
918
|
+
[isControlled, onOpenChange]
|
|
919
|
+
);
|
|
920
|
+
const menuRef = useRef(null);
|
|
921
|
+
const handleArrowDownOrArrowUp = (event) => {
|
|
922
|
+
const menuContent = menuRef.current?.querySelector('[role="menu"]');
|
|
923
|
+
if (menuContent) {
|
|
924
|
+
event.preventDefault();
|
|
925
|
+
const items = Array.from(
|
|
926
|
+
menuContent.querySelectorAll(
|
|
927
|
+
'[role="menuitem"]:not([aria-disabled="true"])'
|
|
928
|
+
)
|
|
929
|
+
).filter((el) => el instanceof HTMLElement);
|
|
930
|
+
if (items.length === 0) return;
|
|
931
|
+
const focusedItem = document.activeElement;
|
|
932
|
+
const currentIndex = items.findIndex((item) => item === focusedItem);
|
|
933
|
+
let nextIndex;
|
|
934
|
+
if (event.key === "ArrowDown") {
|
|
935
|
+
nextIndex = currentIndex === -1 ? 0 : (currentIndex + 1) % items.length;
|
|
936
|
+
} else {
|
|
937
|
+
nextIndex = currentIndex === -1 ? items.length - 1 : (currentIndex - 1 + items.length) % items.length;
|
|
938
|
+
}
|
|
939
|
+
items[nextIndex]?.focus();
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
const handleDownkey = (event) => {
|
|
943
|
+
if (event.key === "Escape") {
|
|
944
|
+
setOpen(false);
|
|
945
|
+
} else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
946
|
+
handleArrowDownOrArrowUp(event);
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
const handleClickOutside = (event) => {
|
|
950
|
+
if (menuRef.current && !menuRef.current.contains(event.target)) {
|
|
951
|
+
setOpen(false);
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
useEffect(() => {
|
|
955
|
+
if (currentOpen) {
|
|
956
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
957
|
+
document.addEventListener("keydown", handleDownkey);
|
|
958
|
+
}
|
|
959
|
+
return () => {
|
|
960
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
961
|
+
document.removeEventListener("keydown", handleDownkey);
|
|
962
|
+
};
|
|
963
|
+
}, [currentOpen]);
|
|
964
|
+
const value = useMemo(
|
|
965
|
+
() => ({ open: currentOpen, setOpen }),
|
|
966
|
+
[currentOpen, setOpen]
|
|
967
|
+
);
|
|
968
|
+
return /* @__PURE__ */ jsx12(DropdownMenuContext.Provider, { value, children: /* @__PURE__ */ jsx12("div", { className: "relative", ref: menuRef, children }) });
|
|
969
|
+
};
|
|
970
|
+
var DropdownMenuTrigger = forwardRef7(({ className, children, onClick, ...props }, ref) => {
|
|
971
|
+
const context = useContext(DropdownMenuContext);
|
|
972
|
+
if (!context)
|
|
973
|
+
throw new Error("DropdownMenuTrigger must be used within a DropdownMenu");
|
|
974
|
+
const { open, setOpen } = context;
|
|
975
|
+
return /* @__PURE__ */ jsx12(
|
|
976
|
+
"button",
|
|
977
|
+
{
|
|
978
|
+
ref,
|
|
979
|
+
className: `border border-border-200 cursor-pointer bg-background-muted hover:bg-background-200 transition-colors px-4 py-2 rounded-sm ${className}`,
|
|
980
|
+
onClick: (e) => {
|
|
981
|
+
e.stopPropagation();
|
|
982
|
+
setOpen(!open);
|
|
983
|
+
if (onClick) onClick(e);
|
|
984
|
+
},
|
|
985
|
+
"aria-expanded": open,
|
|
986
|
+
...props,
|
|
987
|
+
children
|
|
988
|
+
}
|
|
989
|
+
);
|
|
990
|
+
});
|
|
991
|
+
DropdownMenuTrigger.displayName = "DropdownMenuTrigger";
|
|
992
|
+
var ITEM_SIZE_CLASSES = {
|
|
993
|
+
small: "text-sm",
|
|
994
|
+
medium: "text-md"
|
|
995
|
+
};
|
|
996
|
+
var SIDE_CLASSES = {
|
|
997
|
+
top: "bottom-full",
|
|
998
|
+
right: "top-full",
|
|
999
|
+
bottom: "top-full",
|
|
1000
|
+
left: "top-full"
|
|
1001
|
+
};
|
|
1002
|
+
var ALIGN_CLASSES = {
|
|
1003
|
+
start: "left-0",
|
|
1004
|
+
center: "left-1/2 -translate-x-1/2",
|
|
1005
|
+
end: "right-0"
|
|
1006
|
+
};
|
|
1007
|
+
var MenuLabel = forwardRef7(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx12(
|
|
1008
|
+
"fieldset",
|
|
1009
|
+
{
|
|
1010
|
+
ref,
|
|
1011
|
+
role: "group",
|
|
1012
|
+
className: `text-sm w-full ${inset ? "pl-8" : ""} ${className ?? ""}`,
|
|
1013
|
+
...props
|
|
1014
|
+
}
|
|
1015
|
+
));
|
|
1016
|
+
MenuLabel.displayName = "MenuLabel";
|
|
1017
|
+
var MenuContent = forwardRef7(
|
|
1018
|
+
({
|
|
1019
|
+
className,
|
|
1020
|
+
align = "start",
|
|
1021
|
+
side = "bottom",
|
|
1022
|
+
sideOffset = 4,
|
|
1023
|
+
children,
|
|
1024
|
+
...props
|
|
1025
|
+
}, ref) => {
|
|
1026
|
+
const { open } = useContext(DropdownMenuContext);
|
|
1027
|
+
const [isVisible, setIsVisible] = useState3(open);
|
|
1028
|
+
useEffect(() => {
|
|
1029
|
+
if (open) {
|
|
1030
|
+
setIsVisible(true);
|
|
1031
|
+
} else {
|
|
1032
|
+
const timer = setTimeout(() => setIsVisible(false), 200);
|
|
1033
|
+
return () => clearTimeout(timer);
|
|
1034
|
+
}
|
|
1035
|
+
}, [open]);
|
|
1036
|
+
if (!isVisible) return null;
|
|
1037
|
+
const getPositionClasses = () => {
|
|
1038
|
+
const vertical = SIDE_CLASSES[side];
|
|
1039
|
+
const horizontal = ALIGN_CLASSES[align];
|
|
1040
|
+
return `absolute ${vertical} ${horizontal}`;
|
|
1041
|
+
};
|
|
1042
|
+
return /* @__PURE__ */ jsx12(
|
|
1043
|
+
"div",
|
|
1044
|
+
{
|
|
1045
|
+
ref,
|
|
1046
|
+
role: "menu",
|
|
1047
|
+
className: `
|
|
1048
|
+
bg-background z-50 min-w-[210px] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md border-border-100
|
|
1049
|
+
${open ? "animate-in fade-in-0 zoom-in-95" : "animate-out fade-out-0 zoom-out-95"}
|
|
1050
|
+
${getPositionClasses()}
|
|
1051
|
+
${className}
|
|
1052
|
+
`,
|
|
1053
|
+
style: {
|
|
1054
|
+
marginTop: side === "bottom" ? sideOffset : void 0,
|
|
1055
|
+
marginBottom: side === "top" ? sideOffset : void 0,
|
|
1056
|
+
marginLeft: side === "right" ? sideOffset : void 0,
|
|
1057
|
+
marginRight: side === "left" ? sideOffset : void 0
|
|
1058
|
+
},
|
|
1059
|
+
...props,
|
|
1060
|
+
children
|
|
1061
|
+
}
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
);
|
|
1065
|
+
MenuContent.displayName = "MenuContent";
|
|
1066
|
+
var MenuItem = forwardRef7(
|
|
1067
|
+
({
|
|
1068
|
+
className,
|
|
1069
|
+
inset,
|
|
1070
|
+
size = "small",
|
|
1071
|
+
children,
|
|
1072
|
+
iconRight,
|
|
1073
|
+
iconLeft,
|
|
1074
|
+
disabled = false,
|
|
1075
|
+
onClick,
|
|
1076
|
+
...props
|
|
1077
|
+
}, ref) => {
|
|
1078
|
+
const sizeClasses = ITEM_SIZE_CLASSES[size];
|
|
1079
|
+
const handleClick = (e) => {
|
|
1080
|
+
if (disabled) {
|
|
1081
|
+
e.preventDefault();
|
|
1082
|
+
e.stopPropagation();
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
onClick?.(e);
|
|
1086
|
+
};
|
|
1087
|
+
return /* @__PURE__ */ jsxs9(
|
|
1088
|
+
"div",
|
|
1089
|
+
{
|
|
1090
|
+
ref,
|
|
1091
|
+
role: "menuitem",
|
|
1092
|
+
"aria-disabled": disabled,
|
|
1093
|
+
className: `
|
|
1094
|
+
focus-visible:bg-background-50
|
|
1095
|
+
relative flex select-none items-center gap-2 rounded-sm p-3 text-sm outline-none transition-colors [&>svg]:size-4 [&>svg]:shrink-0
|
|
1096
|
+
${inset && "pl-8"}
|
|
1097
|
+
${sizeClasses}
|
|
1098
|
+
${className}
|
|
1099
|
+
${disabled ? "cursor-not-allowed text-text-400" : "cursor-pointer hover:bg-background-50 text-text-700 focus:bg-accent focus:text-accent-foreground hover:bg-accent hover:text-accent-foreground"}
|
|
1100
|
+
`,
|
|
1101
|
+
onClick: handleClick,
|
|
1102
|
+
onKeyDown: (e) => {
|
|
1103
|
+
if (e.key === "Enter" || e.key === " ") handleClick(e);
|
|
1104
|
+
},
|
|
1105
|
+
tabIndex: disabled ? -1 : 0,
|
|
1106
|
+
...props,
|
|
1107
|
+
children: [
|
|
1108
|
+
iconLeft,
|
|
1109
|
+
children,
|
|
1110
|
+
iconRight
|
|
1111
|
+
]
|
|
1112
|
+
}
|
|
1113
|
+
);
|
|
1114
|
+
}
|
|
1115
|
+
);
|
|
1116
|
+
MenuItem.displayName = "MenuItem";
|
|
1117
|
+
var MenuSeparator = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx12(
|
|
1118
|
+
"div",
|
|
1119
|
+
{
|
|
1120
|
+
ref,
|
|
1121
|
+
className: `my-1 h-px bg-border-200 ${className}`,
|
|
1122
|
+
...props
|
|
1123
|
+
}
|
|
1124
|
+
));
|
|
1125
|
+
MenuSeparator.displayName = "MenuSeparator";
|
|
1126
|
+
|
|
1127
|
+
// src/components/Toast/Toast.tsx
|
|
1128
|
+
import { CheckCircle as CheckCircle2, WarningCircle as WarningCircle2, Info as Info2, X } from "phosphor-react";
|
|
1129
|
+
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1130
|
+
var VARIANT_ACTION_CLASSES4 = {
|
|
1131
|
+
solid: {
|
|
1132
|
+
warning: "bg-warning text-warning-800 border-none focus-visible:outline-none",
|
|
1133
|
+
success: "bg-success text-success-800 border-none focus-visible:outline-none",
|
|
1134
|
+
info: "bg-info text-info-800 border-none focus-visible:outline-none"
|
|
1135
|
+
},
|
|
1136
|
+
outlined: {
|
|
1137
|
+
warning: "bg-warning text-warning-800 border border-warning-200 focus-visible:outline-none",
|
|
1138
|
+
success: "bg-success text-success-800 border border-success-200 focus-visible:outline-none",
|
|
1139
|
+
info: "bg-info text-info-800 border border-info-200 focus-visible:outline-none"
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
var iconMap = {
|
|
1143
|
+
success: CheckCircle2,
|
|
1144
|
+
info: Info2,
|
|
1145
|
+
warning: WarningCircle2
|
|
1146
|
+
};
|
|
1147
|
+
var Toast = ({
|
|
1148
|
+
variant = "outlined",
|
|
1149
|
+
action = "success",
|
|
1150
|
+
className = "",
|
|
1151
|
+
onClose,
|
|
1152
|
+
title,
|
|
1153
|
+
description,
|
|
1154
|
+
position = "default",
|
|
1155
|
+
...props
|
|
1156
|
+
}) => {
|
|
1157
|
+
const variantClasses = VARIANT_ACTION_CLASSES4[variant][action];
|
|
1158
|
+
const positionClasses = {
|
|
1159
|
+
"top-left": "fixed top-4 left-4",
|
|
1160
|
+
"top-center": "fixed top-4 left-1/2 transform -translate-x-1/2",
|
|
1161
|
+
"top-right": "fixed top-4 right-4",
|
|
1162
|
+
"bottom-left": "fixed bottom-4 left-4",
|
|
1163
|
+
"bottom-center": "fixed bottom-4 left-1/2 transform -translate-x-1/2",
|
|
1164
|
+
"bottom-right": "fixed bottom-4 right-4",
|
|
1165
|
+
default: ""
|
|
1166
|
+
};
|
|
1167
|
+
const IconAction = iconMap[action] || iconMap["success"];
|
|
1168
|
+
const baseClasses = "max-w-[390px] w-full flex flex-row items-start justify-between shadow-lg rounded-lg border p-4 gap-6 group";
|
|
1169
|
+
return /* @__PURE__ */ jsxs10(
|
|
1170
|
+
"div",
|
|
1171
|
+
{
|
|
1172
|
+
role: "alert",
|
|
1173
|
+
"aria-live": "assertive",
|
|
1174
|
+
"aria-atomic": "true",
|
|
1175
|
+
className: `${baseClasses} ${positionClasses[position]} ${variantClasses} ${className}`,
|
|
1176
|
+
...props,
|
|
1177
|
+
children: [
|
|
1178
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-row items-start gap-3", children: [
|
|
1179
|
+
/* @__PURE__ */ jsx13("span", { className: "mt-1", "data-testid": `toast-icon-${action}`, children: /* @__PURE__ */ jsx13(IconAction, {}) }),
|
|
1180
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-col items-start justify-start", children: [
|
|
1181
|
+
/* @__PURE__ */ jsx13("p", { className: "font-semibold text-md", children: title }),
|
|
1182
|
+
description && /* @__PURE__ */ jsx13("p", { className: "text-md text-text-900", children: description })
|
|
1183
|
+
] })
|
|
1184
|
+
] }),
|
|
1185
|
+
/* @__PURE__ */ jsx13(
|
|
1186
|
+
"button",
|
|
1187
|
+
{
|
|
1188
|
+
onClick: onClose,
|
|
1189
|
+
"aria-label": "Dismiss notification",
|
|
1190
|
+
className: "text-background-500 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",
|
|
1191
|
+
children: /* @__PURE__ */ jsx13(X, {})
|
|
1192
|
+
}
|
|
1193
|
+
)
|
|
1194
|
+
]
|
|
1195
|
+
}
|
|
1196
|
+
);
|
|
1197
|
+
};
|
|
1198
|
+
|
|
1199
|
+
// src/components/Toast/utils/ToastStore.ts
|
|
1200
|
+
import { create } from "zustand";
|
|
1201
|
+
var useToastStore = create((set) => ({
|
|
1202
|
+
toasts: [],
|
|
1203
|
+
addToast: (toast) => {
|
|
1204
|
+
const id = crypto.randomUUID();
|
|
1205
|
+
set((state) => ({
|
|
1206
|
+
toasts: [...state.toasts, { id, ...toast }]
|
|
1207
|
+
}));
|
|
1208
|
+
},
|
|
1209
|
+
removeToast: (id) => {
|
|
1210
|
+
set((state) => ({
|
|
1211
|
+
toasts: state.toasts.filter((t) => t.id !== id)
|
|
1212
|
+
}));
|
|
1213
|
+
}
|
|
1214
|
+
}));
|
|
1215
|
+
|
|
1216
|
+
// src/components/Toast/utils/Toaster.tsx
|
|
1217
|
+
import { Fragment, jsx as jsx14 } from "react/jsx-runtime";
|
|
1218
|
+
var Toaster = () => {
|
|
1219
|
+
const toasts = useToastStore((state) => state.toasts);
|
|
1220
|
+
const removeToast = useToastStore((state) => state.removeToast);
|
|
1221
|
+
return /* @__PURE__ */ jsx14(Fragment, { children: toasts.map((toast) => /* @__PURE__ */ jsx14(
|
|
1222
|
+
Toast,
|
|
1223
|
+
{
|
|
1224
|
+
title: toast.title,
|
|
1225
|
+
description: toast.description,
|
|
1226
|
+
variant: toast.variant,
|
|
1227
|
+
action: toast.action,
|
|
1228
|
+
position: toast.position,
|
|
1229
|
+
onClose: () => removeToast(toast.id)
|
|
1230
|
+
},
|
|
1231
|
+
toast.id
|
|
1232
|
+
)) });
|
|
1233
|
+
};
|
|
570
1234
|
export {
|
|
571
1235
|
Alert,
|
|
572
1236
|
Badge,
|
|
573
1237
|
Button,
|
|
1238
|
+
CheckBox,
|
|
1239
|
+
DropdownMenu,
|
|
1240
|
+
MenuContent as DropdownMenuContent,
|
|
1241
|
+
MenuItem as DropdownMenuItem,
|
|
1242
|
+
MenuLabel as DropdownMenuLabel,
|
|
1243
|
+
MenuSeparator as DropdownMenuSeparator,
|
|
1244
|
+
DropdownMenuTrigger,
|
|
574
1245
|
IconButton,
|
|
575
1246
|
IconRoundedButton,
|
|
576
1247
|
NavButton,
|
|
577
1248
|
SelectionButton,
|
|
578
1249
|
Table,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
TableHeader,
|
|
585
|
-
TableRow,
|
|
586
|
-
Text
|
|
1250
|
+
Text,
|
|
1251
|
+
TextArea,
|
|
1252
|
+
Toast,
|
|
1253
|
+
Toaster,
|
|
1254
|
+
useToastStore
|
|
587
1255
|
};
|