@tinybigui/react 0.11.0 → 0.11.2
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/README.md +17 -17
- package/dist/index.cjs +287 -254
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +114 -72
- package/dist/index.d.ts +114 -72
- package/dist/index.js +287 -254
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3667,10 +3667,9 @@ var Tabs = forwardRef(
|
|
|
3667
3667
|
Tabs.displayName = "Tabs";
|
|
3668
3668
|
var tabListVariants = cva(
|
|
3669
3669
|
[
|
|
3670
|
-
// Base classes
|
|
3671
3670
|
"relative flex",
|
|
3672
3671
|
"bg-surface",
|
|
3673
|
-
//
|
|
3672
|
+
// MD3: 1dp bottom divider in outline-variant color
|
|
3674
3673
|
"border-b border-outline-variant"
|
|
3675
3674
|
],
|
|
3676
3675
|
{
|
|
@@ -3687,108 +3686,110 @@ var tabListVariants = cva(
|
|
|
3687
3686
|
);
|
|
3688
3687
|
var tabVariants = cva(
|
|
3689
3688
|
[
|
|
3690
|
-
//
|
|
3689
|
+
// Layout
|
|
3691
3690
|
"relative flex flex-col items-center justify-center",
|
|
3692
3691
|
"min-h-12 px-4",
|
|
3693
3692
|
"cursor-pointer select-none",
|
|
3693
|
+
// Clip state layer to tab boundary
|
|
3694
3694
|
"overflow-hidden",
|
|
3695
|
-
//
|
|
3696
|
-
"text-
|
|
3697
|
-
//
|
|
3698
|
-
"transition-colors duration-
|
|
3699
|
-
//
|
|
3695
|
+
// MD3 Title Small typography
|
|
3696
|
+
"text-title-small font-medium tracking-[0.1px]",
|
|
3697
|
+
// Effects transition for color changes (not spatial)
|
|
3698
|
+
"transition-colors duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
|
|
3699
|
+
// Remove default button focus outline — handled via group-data-[focus-visible]/tab
|
|
3700
3700
|
"focus-visible:outline-none",
|
|
3701
|
-
//
|
|
3702
|
-
"
|
|
3703
|
-
|
|
3704
|
-
"
|
|
3705
|
-
"active:before:opacity-12",
|
|
3706
|
-
"focus-visible:before:opacity-12"
|
|
3701
|
+
// Disabled — self-targeting data-[x]: selectors (not group)
|
|
3702
|
+
"data-[disabled]:opacity-38 data-[disabled]:cursor-not-allowed data-[disabled]:pointer-events-none",
|
|
3703
|
+
// Icon+label stacked: 64dp height
|
|
3704
|
+
"data-[with-icon]:data-[with-label]:min-h-16"
|
|
3707
3705
|
],
|
|
3708
3706
|
{
|
|
3709
3707
|
variants: {
|
|
3710
3708
|
/**
|
|
3711
|
-
*
|
|
3709
|
+
* Design-time variant: affects active label/icon color and state-layer color.
|
|
3710
|
+
* primary: active → text-primary
|
|
3711
|
+
* secondary: active → text-on-surface
|
|
3712
3712
|
*/
|
|
3713
3713
|
variant: {
|
|
3714
|
-
primary:
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
disabled: {
|
|
3728
|
-
true: "opacity-38 cursor-not-allowed pointer-events-none",
|
|
3729
|
-
false: ""
|
|
3714
|
+
primary: [
|
|
3715
|
+
// Inactive: on-surface-variant (base)
|
|
3716
|
+
"text-on-surface-variant",
|
|
3717
|
+
// Active: text-primary
|
|
3718
|
+
"group-data-[selected]/tab:text-primary"
|
|
3719
|
+
// Disabled active: on-surface/38 inherits from opacity-38 on root
|
|
3720
|
+
],
|
|
3721
|
+
secondary: [
|
|
3722
|
+
// Inactive: on-surface-variant (base)
|
|
3723
|
+
"text-on-surface-variant",
|
|
3724
|
+
// Active: on-surface
|
|
3725
|
+
"group-data-[selected]/tab:text-on-surface"
|
|
3726
|
+
]
|
|
3730
3727
|
},
|
|
3731
3728
|
/**
|
|
3732
|
-
*
|
|
3729
|
+
* Design-time variant: affects flex sizing in the tab row.
|
|
3733
3730
|
*/
|
|
3734
3731
|
layout: {
|
|
3735
3732
|
fixed: "flex-1",
|
|
3736
3733
|
scrollable: "min-w-[90px] shrink-0"
|
|
3737
3734
|
}
|
|
3738
3735
|
},
|
|
3739
|
-
compoundVariants
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
variant: "primary",
|
|
3743
|
-
selected: true,
|
|
3744
|
-
disabled: false,
|
|
3745
|
-
className: "text-primary"
|
|
3746
|
-
},
|
|
3747
|
-
// Primary + unselected
|
|
3748
|
-
{
|
|
3749
|
-
variant: "primary",
|
|
3750
|
-
selected: false,
|
|
3751
|
-
disabled: false,
|
|
3752
|
-
className: "text-on-surface-variant"
|
|
3753
|
-
},
|
|
3754
|
-
// Secondary + selected
|
|
3755
|
-
{
|
|
3756
|
-
variant: "secondary",
|
|
3757
|
-
selected: true,
|
|
3758
|
-
disabled: false,
|
|
3759
|
-
className: "text-on-surface"
|
|
3760
|
-
},
|
|
3761
|
-
// Secondary + unselected
|
|
3762
|
-
{
|
|
3763
|
-
variant: "secondary",
|
|
3764
|
-
selected: false,
|
|
3765
|
-
disabled: false,
|
|
3766
|
-
className: "text-on-surface-variant"
|
|
3767
|
-
}
|
|
3768
|
-
],
|
|
3736
|
+
// compoundVariants intentionally empty — state combinations are handled
|
|
3737
|
+
// via group-data-[selected]/tab:group-data-[...]/tab: in state slot
|
|
3738
|
+
compoundVariants: [],
|
|
3769
3739
|
defaultVariants: {
|
|
3770
3740
|
variant: "primary",
|
|
3771
|
-
selected: false,
|
|
3772
|
-
disabled: false,
|
|
3773
3741
|
layout: "fixed"
|
|
3774
3742
|
}
|
|
3775
3743
|
}
|
|
3776
3744
|
);
|
|
3745
|
+
var tabStateLayerVariants = cva(
|
|
3746
|
+
[
|
|
3747
|
+
"absolute inset-0 pointer-events-none opacity-0",
|
|
3748
|
+
// Effects transition for opacity — no spatial overshoot
|
|
3749
|
+
"transition-opacity duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
|
|
3750
|
+
// Hover: 8%
|
|
3751
|
+
"group-data-[hovered]/tab:opacity-8",
|
|
3752
|
+
// Focus: 10%
|
|
3753
|
+
"group-data-[focus-visible]/tab:opacity-10",
|
|
3754
|
+
// Pressed: 10%, doubled selector beats hover at equal cascade position
|
|
3755
|
+
"group-data-[pressed]/tab:group-data-[pressed]/tab:opacity-10",
|
|
3756
|
+
// No state layer when disabled
|
|
3757
|
+
"group-data-[disabled]/tab:hidden"
|
|
3758
|
+
],
|
|
3759
|
+
{
|
|
3760
|
+
variants: {
|
|
3761
|
+
variant: {
|
|
3762
|
+
primary: [
|
|
3763
|
+
// Inactive state-layer color
|
|
3764
|
+
"bg-on-surface",
|
|
3765
|
+
// Active state-layer color (higher cascade position wins over base bg-on-surface)
|
|
3766
|
+
"group-data-[selected]/tab:bg-primary"
|
|
3767
|
+
],
|
|
3768
|
+
secondary: [
|
|
3769
|
+
// Secondary: always on-surface
|
|
3770
|
+
"bg-on-surface"
|
|
3771
|
+
]
|
|
3772
|
+
}
|
|
3773
|
+
},
|
|
3774
|
+
defaultVariants: {
|
|
3775
|
+
variant: "primary"
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
);
|
|
3777
3779
|
var tabIndicatorVariants = cva(
|
|
3778
3780
|
[
|
|
3779
|
-
// Base: absolutely positioned at bottom
|
|
3780
3781
|
"absolute bottom-0 left-0",
|
|
3781
3782
|
"pointer-events-none",
|
|
3782
|
-
//
|
|
3783
|
+
// Spatial spring — indicator position/width are spatial (not effects)
|
|
3783
3784
|
"transition-[left,width]",
|
|
3784
|
-
"duration-
|
|
3785
|
-
"ease-
|
|
3785
|
+
"duration-spring-standard-default-spatial",
|
|
3786
|
+
"ease-spring-standard-default-spatial"
|
|
3786
3787
|
],
|
|
3787
3788
|
{
|
|
3788
3789
|
variants: {
|
|
3789
3790
|
variant: {
|
|
3790
|
-
primary: ["h-[3px]", "bg-primary", "rounded-
|
|
3791
|
-
secondary: ["h-[2px]", "bg-
|
|
3791
|
+
primary: ["h-[3px]", "bg-primary", "rounded-tl-sm rounded-tr-sm"],
|
|
3792
|
+
secondary: ["h-[2px]", "bg-primary"]
|
|
3792
3793
|
}
|
|
3793
3794
|
},
|
|
3794
3795
|
defaultVariants: {
|
|
@@ -3796,20 +3797,28 @@ var tabIndicatorVariants = cva(
|
|
|
3796
3797
|
}
|
|
3797
3798
|
}
|
|
3798
3799
|
);
|
|
3799
|
-
var
|
|
3800
|
+
var tabIconVariants = cva(
|
|
3800
3801
|
[
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
"
|
|
3802
|
+
"relative inline-flex items-center justify-center",
|
|
3803
|
+
// MD3 tab icon size: 24dp
|
|
3804
|
+
"size-6",
|
|
3805
|
+
// Effects transition for color (inherited from parent, guard here too)
|
|
3806
|
+
"transition-colors duration-spring-standard-fast-effects ease-spring-standard-fast-effects"
|
|
3804
3807
|
],
|
|
3805
3808
|
{
|
|
3806
|
-
variants: {
|
|
3807
|
-
|
|
3809
|
+
variants: {
|
|
3810
|
+
hasLabel: {
|
|
3811
|
+
true: "mb-1",
|
|
3812
|
+
false: ""
|
|
3813
|
+
}
|
|
3814
|
+
},
|
|
3815
|
+
defaultVariants: {
|
|
3816
|
+
hasLabel: false
|
|
3817
|
+
}
|
|
3808
3818
|
}
|
|
3809
3819
|
);
|
|
3810
3820
|
var tabBadgeVariants = cva(
|
|
3811
3821
|
[
|
|
3812
|
-
// Base badge
|
|
3813
3822
|
"absolute",
|
|
3814
3823
|
"inline-flex items-center justify-center",
|
|
3815
3824
|
"bg-error text-on-error",
|
|
@@ -3819,7 +3828,7 @@ var tabBadgeVariants = cva(
|
|
|
3819
3828
|
{
|
|
3820
3829
|
variants: {
|
|
3821
3830
|
type: {
|
|
3822
|
-
dot: ["top-
|
|
3831
|
+
dot: ["top-0 right-0", "w-1.5 h-1.5", "rounded-full"],
|
|
3823
3832
|
count: ["-top-1 -right-1", "min-w-[16px] h-4", "px-1", "rounded-full", "text-[11px]"]
|
|
3824
3833
|
}
|
|
3825
3834
|
},
|
|
@@ -3828,20 +3837,10 @@ var tabBadgeVariants = cva(
|
|
|
3828
3837
|
}
|
|
3829
3838
|
}
|
|
3830
3839
|
);
|
|
3831
|
-
var
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
hasLabel: {
|
|
3836
|
-
true: "mb-1",
|
|
3837
|
-
false: ""
|
|
3838
|
-
}
|
|
3839
|
-
},
|
|
3840
|
-
defaultVariants: {
|
|
3841
|
-
hasLabel: false
|
|
3842
|
-
}
|
|
3843
|
-
}
|
|
3844
|
-
);
|
|
3840
|
+
var tabPanelVariants = cva([
|
|
3841
|
+
"outline-none",
|
|
3842
|
+
"focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2"
|
|
3843
|
+
]);
|
|
3845
3844
|
var TabList = forwardRef(
|
|
3846
3845
|
({ children, className }, forwardedRef) => {
|
|
3847
3846
|
const { state } = useHeadlessTabsContext("TabList");
|
|
@@ -3920,18 +3919,41 @@ var TabList = forwardRef(
|
|
|
3920
3919
|
const selectedTab = container.querySelector('[aria-selected="true"]');
|
|
3921
3920
|
if (!selectedTab) return;
|
|
3922
3921
|
const containerRect = container.getBoundingClientRect();
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3922
|
+
if (variant === "primary") {
|
|
3923
|
+
const contentEl = selectedTab.querySelector("[data-tab-content]");
|
|
3924
|
+
if (!contentEl) return;
|
|
3925
|
+
const contentRect = contentEl.getBoundingClientRect();
|
|
3926
|
+
const newLeft = contentRect.left - containerRect.left + container.scrollLeft;
|
|
3927
|
+
const newWidth = contentRect.width;
|
|
3928
|
+
setIndicatorStyle((prev) => {
|
|
3929
|
+
if (prev.left === newLeft && prev.width === newWidth) return prev;
|
|
3930
|
+
return { left: newLeft, width: newWidth };
|
|
3931
|
+
});
|
|
3932
|
+
} else {
|
|
3933
|
+
const tabRect = selectedTab.getBoundingClientRect();
|
|
3934
|
+
const newLeft = tabRect.left - containerRect.left + container.scrollLeft;
|
|
3935
|
+
const newWidth = tabRect.width;
|
|
3936
|
+
setIndicatorStyle((prev) => {
|
|
3937
|
+
if (prev.left === newLeft && prev.width === newWidth) return prev;
|
|
3938
|
+
return { left: newLeft, width: newWidth };
|
|
3939
|
+
});
|
|
3940
|
+
}
|
|
3930
3941
|
setIndicatorReady(true);
|
|
3931
|
-
}, [ref]);
|
|
3942
|
+
}, [ref, variant]);
|
|
3932
3943
|
useLayoutEffect(() => {
|
|
3933
3944
|
updateIndicator();
|
|
3934
3945
|
}, [state.selectedKey, updateIndicator]);
|
|
3946
|
+
useEffect(() => {
|
|
3947
|
+
const container = ref.current;
|
|
3948
|
+
if (!container || typeof ResizeObserver === "undefined") return;
|
|
3949
|
+
const observer = new ResizeObserver(() => {
|
|
3950
|
+
updateIndicator();
|
|
3951
|
+
});
|
|
3952
|
+
observer.observe(container);
|
|
3953
|
+
return () => {
|
|
3954
|
+
observer.disconnect();
|
|
3955
|
+
};
|
|
3956
|
+
}, [ref, updateIndicator]);
|
|
3935
3957
|
const mergedTabListProps = { ...tabListProps, onKeyDown: handleKeyDown };
|
|
3936
3958
|
return /* @__PURE__ */ jsxs("div", { ...mergedTabListProps, ref, className: cn(tabListVariants({ layout }), className), children: [
|
|
3937
3959
|
children,
|
|
@@ -3946,7 +3968,6 @@ var TabList = forwardRef(
|
|
|
3946
3968
|
!indicatorReady && "opacity-0"
|
|
3947
3969
|
),
|
|
3948
3970
|
style: {
|
|
3949
|
-
// Dynamic left/width values from DOM measurements
|
|
3950
3971
|
left: `${indicatorStyle.left}px`,
|
|
3951
3972
|
width: `${indicatorStyle.width}px`
|
|
3952
3973
|
}
|
|
@@ -3974,10 +3995,12 @@ var Tab = forwardRef(
|
|
|
3974
3995
|
const {
|
|
3975
3996
|
tabProps,
|
|
3976
3997
|
isSelected,
|
|
3977
|
-
isDisabled: ariaIsDisabled
|
|
3998
|
+
isDisabled: ariaIsDisabled,
|
|
3999
|
+
isPressed
|
|
3978
4000
|
} = useTab({ key: id, isDisabled }, state, ref);
|
|
3979
4001
|
const { isFocusVisible, focusProps } = useFocusRing();
|
|
3980
4002
|
const finalIsDisabled = isDisabled || ariaIsDisabled;
|
|
4003
|
+
const { isHovered, hoverProps } = useHover({ isDisabled: finalIsDisabled });
|
|
3981
4004
|
const { onMouseDown: handleRipple, ripples } = useRipple({
|
|
3982
4005
|
disabled: finalIsDisabled || disableRipple
|
|
3983
4006
|
});
|
|
@@ -3991,7 +4014,7 @@ var Tab = forwardRef(
|
|
|
3991
4014
|
state.selectionManager.setFocusedKey(id);
|
|
3992
4015
|
}
|
|
3993
4016
|
}, [state.selectionManager, id, finalIsDisabled]);
|
|
3994
|
-
const mergedProps = mergeProps(tabProps, focusProps, {
|
|
4017
|
+
const mergedProps = mergeProps(tabProps, focusProps, hoverProps, {
|
|
3995
4018
|
onMouseDown: disableRipple ? void 0 : handleRipple,
|
|
3996
4019
|
onClick: handleClick,
|
|
3997
4020
|
onFocus: handleFocus
|
|
@@ -4008,47 +4031,56 @@ var Tab = forwardRef(
|
|
|
4008
4031
|
type: "button",
|
|
4009
4032
|
"data-key": String(id),
|
|
4010
4033
|
tabIndex: finalIsDisabled ? -1 : isSelected ? 0 : -1,
|
|
4011
|
-
className: cn(
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
),
|
|
4034
|
+
className: cn(tabVariants({ variant, layout }), className),
|
|
4035
|
+
...getInteractionDataAttributes({
|
|
4036
|
+
isHovered,
|
|
4037
|
+
isFocusVisible,
|
|
4038
|
+
isPressed,
|
|
4039
|
+
isSelected,
|
|
4040
|
+
isDisabled: finalIsDisabled
|
|
4041
|
+
}),
|
|
4042
|
+
"data-with-icon": hasIcon ? "" : void 0,
|
|
4043
|
+
"data-with-label": hasLabel ? "" : void 0,
|
|
4022
4044
|
...htmlProps,
|
|
4023
4045
|
children: [
|
|
4024
4046
|
!disableRipple && ripples,
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
className:
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4047
|
+
/* @__PURE__ */ jsx("span", { className: cn(tabStateLayerVariants({ variant })), "aria-hidden": "true" }),
|
|
4048
|
+
/* @__PURE__ */ jsxs(
|
|
4049
|
+
"span",
|
|
4050
|
+
{
|
|
4051
|
+
"data-tab-content": true,
|
|
4052
|
+
className: "relative z-10 inline-flex flex-col items-center justify-center",
|
|
4053
|
+
children: [
|
|
4054
|
+
hasIcon && /* @__PURE__ */ jsxs("span", { className: cn(tabIconVariants({ hasLabel })), children: [
|
|
4055
|
+
icon,
|
|
4056
|
+
badgeDisplay && /* @__PURE__ */ jsx(
|
|
4057
|
+
"span",
|
|
4058
|
+
{
|
|
4059
|
+
"data-badge-type": isDotBadge ? "dot" : "count",
|
|
4060
|
+
"aria-hidden": "true",
|
|
4061
|
+
className: cn(tabBadgeVariants({ type: isDotBadge ? "dot" : "count" })),
|
|
4062
|
+
children: !isDotBadge && badgeDisplay
|
|
4063
|
+
}
|
|
4064
|
+
)
|
|
4065
|
+
] }),
|
|
4066
|
+
hasLabel && /* @__PURE__ */ jsxs("span", { className: "truncate", children: [
|
|
4067
|
+
label,
|
|
4068
|
+
!hasIcon && badgeDisplay && /* @__PURE__ */ jsx(
|
|
4069
|
+
"span",
|
|
4070
|
+
{
|
|
4071
|
+
"data-badge-type": isDotBadge ? "dot" : "count",
|
|
4072
|
+
"aria-hidden": "true",
|
|
4073
|
+
className: cn(
|
|
4074
|
+
"relative ml-1",
|
|
4075
|
+
tabBadgeVariants({ type: isDotBadge ? "dot" : "count" })
|
|
4076
|
+
),
|
|
4077
|
+
children: !isDotBadge && badgeDisplay
|
|
4078
|
+
}
|
|
4079
|
+
)
|
|
4080
|
+
] })
|
|
4081
|
+
]
|
|
4082
|
+
}
|
|
4083
|
+
)
|
|
4052
4084
|
]
|
|
4053
4085
|
}
|
|
4054
4086
|
);
|
|
@@ -5398,28 +5430,42 @@ var ProgressHeadless = forwardRef(
|
|
|
5398
5430
|
}
|
|
5399
5431
|
);
|
|
5400
5432
|
ProgressHeadless.displayName = "ProgressHeadless";
|
|
5401
|
-
var CardHeadless = forwardRef(function CardHeadless2({ className, children, ...
|
|
5433
|
+
var CardHeadless = forwardRef(function CardHeadless2({ className, children, onMouseDown, onMouseUp, onMouseLeave, ...rest }, forwardedRef) {
|
|
5402
5434
|
const internalRef = useRef(null);
|
|
5403
5435
|
const ref = forwardedRef ?? internalRef;
|
|
5404
|
-
const isInteractive = !!(
|
|
5405
|
-
const { buttonProps } = useButton({ elementType: "div", ...
|
|
5406
|
-
const {
|
|
5436
|
+
const isInteractive = !!(rest.onPress ?? rest.href);
|
|
5437
|
+
const { buttonProps } = useButton({ elementType: "div", ...rest }, ref);
|
|
5438
|
+
const {
|
|
5439
|
+
isDisabled: _isDisabled,
|
|
5440
|
+
onPress: _onPress,
|
|
5441
|
+
onPressStart: _onPressStart,
|
|
5442
|
+
onPressEnd: _onPressEnd,
|
|
5443
|
+
onPressChange: _onPressChange,
|
|
5444
|
+
onPressUp: _onPressUp,
|
|
5445
|
+
href: _href,
|
|
5446
|
+
target: _target,
|
|
5447
|
+
rel: _rel,
|
|
5448
|
+
...htmlAttrs
|
|
5449
|
+
} = rest;
|
|
5450
|
+
const mouseHandlers = { onMouseDown, onMouseUp, onMouseLeave };
|
|
5407
5451
|
if (isInteractive) {
|
|
5408
|
-
const interactiveProps = mergeProps(buttonProps,
|
|
5409
|
-
className,
|
|
5410
|
-
"data-focus-visible": isFocusVisible ? "true" : void 0
|
|
5411
|
-
});
|
|
5452
|
+
const interactiveProps = mergeProps(buttonProps, mouseHandlers, htmlAttrs, { className });
|
|
5412
5453
|
return /* @__PURE__ */ jsx("div", { ...interactiveProps, ref, children });
|
|
5413
5454
|
}
|
|
5414
|
-
return /* @__PURE__ */ jsx("div", { role: "article", className, ref, children });
|
|
5455
|
+
return /* @__PURE__ */ jsx("div", { role: "article", className, ref, ...mouseHandlers, ...htmlAttrs, children });
|
|
5415
5456
|
});
|
|
5416
5457
|
CardHeadless.displayName = "CardHeadless";
|
|
5417
5458
|
var cardVariants = cva(
|
|
5418
5459
|
[
|
|
5419
5460
|
// Shape: MD3 medium corner = 12dp
|
|
5420
|
-
"relative overflow-hidden rounded-md",
|
|
5421
|
-
//
|
|
5422
|
-
|
|
5461
|
+
"relative overflow-hidden rounded-md text-on-surface",
|
|
5462
|
+
// Transition: effects properties — standard default tier (cards are standard-size, not <48dp)
|
|
5463
|
+
// Covers shadow (elevation), opacity (disabled fade), border-color (outlined state)
|
|
5464
|
+
"transition-[box-shadow,opacity,border-color] duration-spring-standard-default-effects ease-spring-standard-default-effects",
|
|
5465
|
+
// Interactive affordance (content flag set by the component)
|
|
5466
|
+
"data-[interactive]:cursor-pointer",
|
|
5467
|
+
// Disabled — self-targeting selectors (38% container, no interaction)
|
|
5468
|
+
"data-[disabled]:cursor-not-allowed data-[disabled]:pointer-events-none data-[disabled]:opacity-38"
|
|
5423
5469
|
],
|
|
5424
5470
|
{
|
|
5425
5471
|
variants: {
|
|
@@ -5427,92 +5473,74 @@ var cardVariants = cva(
|
|
|
5427
5473
|
* Card visual variant per MD3 specification.
|
|
5428
5474
|
*/
|
|
5429
5475
|
variant: {
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
"
|
|
5441
|
-
"
|
|
5442
|
-
"
|
|
5443
|
-
"focus-visible:outline-offset-2"
|
|
5476
|
+
/**
|
|
5477
|
+
* Elevated — separation via shadow.
|
|
5478
|
+
* MD3: container=surface-container-low.
|
|
5479
|
+
* Elevation: 1 base → 2 hover → 1 focus → 1 pressed → 4 dragged.
|
|
5480
|
+
*/
|
|
5481
|
+
elevated: [
|
|
5482
|
+
"bg-surface-container-low",
|
|
5483
|
+
"shadow-elevation-1",
|
|
5484
|
+
"data-[hovered]:shadow-elevation-2",
|
|
5485
|
+
"data-[focus-visible]:shadow-elevation-1",
|
|
5486
|
+
"data-[pressed]:data-[pressed]:shadow-elevation-1",
|
|
5487
|
+
"data-[dragged]:data-[dragged]:data-[dragged]:shadow-elevation-4",
|
|
5488
|
+
"data-[disabled]:shadow-none"
|
|
5444
5489
|
],
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
"shadow-
|
|
5455
|
-
|
|
5456
|
-
"
|
|
5457
|
-
"
|
|
5490
|
+
/**
|
|
5491
|
+
* Filled — subtle container fill, no resting shadow.
|
|
5492
|
+
* MD3: container=surface-container-highest.
|
|
5493
|
+
* Elevation: 0 base → 1 hover → 0 focus → 0 pressed → 3 dragged.
|
|
5494
|
+
*/
|
|
5495
|
+
filled: [
|
|
5496
|
+
"bg-surface-container-highest",
|
|
5497
|
+
"shadow-none",
|
|
5498
|
+
"data-[hovered]:shadow-elevation-1",
|
|
5499
|
+
"data-[focus-visible]:shadow-none",
|
|
5500
|
+
"data-[pressed]:data-[pressed]:shadow-none",
|
|
5501
|
+
"data-[dragged]:data-[dragged]:data-[dragged]:shadow-elevation-3",
|
|
5502
|
+
"data-[disabled]:shadow-none"
|
|
5458
5503
|
],
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5504
|
+
/**
|
|
5505
|
+
* Outlined — visual boundary via border, no resting shadow.
|
|
5506
|
+
* MD3: container=surface, outline=outline-variant.
|
|
5507
|
+
* Elevation: 0 base → 1 hover → 0 focus → 0 pressed → 3 dragged.
|
|
5508
|
+
*/
|
|
5509
|
+
outlined: [
|
|
5510
|
+
"bg-surface border border-outline-variant",
|
|
5511
|
+
"shadow-none",
|
|
5512
|
+
"data-[hovered]:shadow-elevation-1",
|
|
5513
|
+
"data-[focus-visible]:shadow-none",
|
|
5514
|
+
"data-[pressed]:data-[pressed]:shadow-none",
|
|
5515
|
+
"data-[dragged]:data-[dragged]:data-[dragged]:shadow-elevation-3",
|
|
5516
|
+
"data-[disabled]:shadow-none"
|
|
5517
|
+
]
|
|
5468
5518
|
}
|
|
5469
5519
|
},
|
|
5470
|
-
compoundVariants: [
|
|
5471
|
-
// Filled + enabled
|
|
5472
|
-
{
|
|
5473
|
-
variant: "filled",
|
|
5474
|
-
isDisabled: false,
|
|
5475
|
-
class: "bg-surface-container-highest"
|
|
5476
|
-
},
|
|
5477
|
-
// Filled + disabled
|
|
5478
|
-
{
|
|
5479
|
-
variant: "filled",
|
|
5480
|
-
isDisabled: true,
|
|
5481
|
-
class: "bg-surface-container-variant"
|
|
5482
|
-
},
|
|
5483
|
-
// Elevated + enabled
|
|
5484
|
-
{
|
|
5485
|
-
variant: "elevated",
|
|
5486
|
-
isDisabled: true,
|
|
5487
|
-
class: "bg-surface"
|
|
5488
|
-
},
|
|
5489
|
-
// Elevated + disabled
|
|
5490
|
-
{
|
|
5491
|
-
variant: "elevated",
|
|
5492
|
-
isDisabled: false,
|
|
5493
|
-
class: "bg-surface-container-low"
|
|
5494
|
-
},
|
|
5495
|
-
// Outlined + enabled
|
|
5496
|
-
{
|
|
5497
|
-
variant: "outlined",
|
|
5498
|
-
isDisabled: true,
|
|
5499
|
-
class: "bg-surface"
|
|
5500
|
-
},
|
|
5501
|
-
// Outlined + disabled
|
|
5502
|
-
{
|
|
5503
|
-
variant: "outlined",
|
|
5504
|
-
isDisabled: false,
|
|
5505
|
-
class: "bg-surface"
|
|
5506
|
-
}
|
|
5507
|
-
],
|
|
5508
5520
|
defaultVariants: {
|
|
5509
|
-
variant: "elevated"
|
|
5510
|
-
isInteractive: false,
|
|
5511
|
-
isDragged: false,
|
|
5512
|
-
isDisabled: false
|
|
5521
|
+
variant: "elevated"
|
|
5513
5522
|
}
|
|
5514
5523
|
}
|
|
5515
5524
|
);
|
|
5525
|
+
var cardStateLayerVariants = cva([
|
|
5526
|
+
"pointer-events-none absolute inset-0 rounded-[inherit] opacity-0",
|
|
5527
|
+
"bg-on-surface",
|
|
5528
|
+
// Effects transition for opacity — standard default tier (200ms, no overshoot)
|
|
5529
|
+
"transition-opacity duration-spring-standard-default-effects ease-spring-standard-default-effects",
|
|
5530
|
+
"group-data-[hovered]/card:opacity-8",
|
|
5531
|
+
"group-data-[focus-visible]/card:opacity-10",
|
|
5532
|
+
"group-data-[pressed]/card:group-data-[pressed]/card:opacity-10",
|
|
5533
|
+
"group-data-[dragged]/card:group-data-[dragged]/card:group-data-[dragged]/card:opacity-16",
|
|
5534
|
+
"group-data-[disabled]/card:hidden"
|
|
5535
|
+
]);
|
|
5536
|
+
var cardFocusRingVariants = cva([
|
|
5537
|
+
"pointer-events-none absolute inset-0 z-20 rounded-[inherit]",
|
|
5538
|
+
"outline outline-2 -outline-offset-2 outline-secondary",
|
|
5539
|
+
// Effects transition — standard default tier, opacity must not overshoot
|
|
5540
|
+
"transition-opacity duration-spring-standard-default-effects ease-spring-standard-default-effects",
|
|
5541
|
+
"opacity-0",
|
|
5542
|
+
"group-data-[focus-visible]/card:opacity-100"
|
|
5543
|
+
]);
|
|
5516
5544
|
var Card = forwardRef(function Card2({
|
|
5517
5545
|
variant = "elevated",
|
|
5518
5546
|
onPress,
|
|
@@ -5523,9 +5551,15 @@ var Card = forwardRef(function Card2({
|
|
|
5523
5551
|
children,
|
|
5524
5552
|
"aria-label": ariaLabel
|
|
5525
5553
|
}, ref) {
|
|
5554
|
+
const internalRef = useRef(null);
|
|
5555
|
+
const resolvedRef = ref ?? internalRef;
|
|
5526
5556
|
const isInteractive = !!(onPress ?? href);
|
|
5527
5557
|
const [isDragged, setIsDragged] = useState(false);
|
|
5528
5558
|
const [isPressed, setIsPressed] = useState(false);
|
|
5559
|
+
const { isHovered, hoverProps } = useHover({ isDisabled: !isInteractive || isDisabled });
|
|
5560
|
+
const { isFocusVisible, focusProps } = useFocusRing();
|
|
5561
|
+
const handlePressStart = useCallback(() => setIsPressed(true), []);
|
|
5562
|
+
const handlePressEnd = useCallback(() => setIsPressed(false), []);
|
|
5529
5563
|
const { onMouseDown: handleRipple, ripples } = useRipple({
|
|
5530
5564
|
disabled: !isInteractive || isDisabled
|
|
5531
5565
|
});
|
|
@@ -5539,42 +5573,41 @@ var Card = forwardRef(function Card2({
|
|
|
5539
5573
|
const handleMouseLeave = () => {
|
|
5540
5574
|
if (isDraggable) setIsDragged(false);
|
|
5541
5575
|
};
|
|
5542
|
-
const
|
|
5543
|
-
const
|
|
5576
|
+
const interactionAttrs = isInteractive ? getInteractionDataAttributes({ isHovered, isFocusVisible, isPressed, isDisabled }) : {};
|
|
5577
|
+
const interactiveHandlers = isInteractive ? mergeProps$1(hoverProps, focusProps, {
|
|
5578
|
+
onPressStart: handlePressStart,
|
|
5579
|
+
onPressEnd: handlePressEnd
|
|
5580
|
+
}) : {};
|
|
5544
5581
|
return /* @__PURE__ */ jsxs(
|
|
5545
5582
|
CardHeadless,
|
|
5546
5583
|
{
|
|
5547
|
-
ref,
|
|
5584
|
+
ref: resolvedRef,
|
|
5548
5585
|
...onPress !== void 0 && { onPress },
|
|
5549
5586
|
...href !== void 0 && { href },
|
|
5550
5587
|
isDisabled,
|
|
5551
5588
|
...ariaLabel !== void 0 && { "aria-label": ariaLabel },
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
),
|
|
5589
|
+
...interactiveHandlers,
|
|
5590
|
+
...isInteractive && { onMouseDown: handleMouseDown },
|
|
5591
|
+
...isInteractive && isDraggable && {
|
|
5592
|
+
onMouseUp: handleMouseUp,
|
|
5593
|
+
onMouseLeave: handleMouseLeave
|
|
5594
|
+
},
|
|
5595
|
+
...interactionAttrs,
|
|
5596
|
+
"data-interactive": isInteractive ? "" : void 0,
|
|
5597
|
+
"data-dragged": isInteractive && isDragged ? "" : void 0,
|
|
5598
|
+
className: cn(cardVariants({ variant }), "group/card", className),
|
|
5562
5599
|
children: [
|
|
5563
5600
|
isInteractive && /* @__PURE__ */ jsx(
|
|
5564
|
-
"
|
|
5601
|
+
"span",
|
|
5565
5602
|
{
|
|
5566
5603
|
"data-testid": "card-state-layer",
|
|
5567
|
-
"data-pressed": isPressed ? "" : void 0,
|
|
5568
5604
|
"aria-hidden": "true",
|
|
5569
|
-
className: cn(
|
|
5570
|
-
"bg-on-surface pointer-events-none absolute inset-0 rounded-md",
|
|
5571
|
-
"opacity-0 group-hover:opacity-8 data-[pressed]:opacity-12",
|
|
5572
|
-
"duration-spring-standard-fast-effects ease-spring-standard-fast-effects transition-opacity"
|
|
5573
|
-
)
|
|
5605
|
+
className: cn(cardStateLayerVariants())
|
|
5574
5606
|
}
|
|
5575
5607
|
),
|
|
5576
5608
|
isInteractive && ripples,
|
|
5577
|
-
|
|
5609
|
+
isInteractive && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn(cardFocusRingVariants()) }),
|
|
5610
|
+
/* @__PURE__ */ jsx("div", { className: "relative z-10", children })
|
|
5578
5611
|
]
|
|
5579
5612
|
}
|
|
5580
5613
|
);
|
|
@@ -5584,7 +5617,7 @@ var cardMediaVariants = cva("w-full object-cover", {
|
|
|
5584
5617
|
variants: {
|
|
5585
5618
|
aspectRatio: {
|
|
5586
5619
|
"16/9": "aspect-video",
|
|
5587
|
-
"4/3": "aspect-
|
|
5620
|
+
"4/3": "aspect-[4/3]",
|
|
5588
5621
|
"1/1": "aspect-square",
|
|
5589
5622
|
auto: ""
|
|
5590
5623
|
}
|
|
@@ -5608,7 +5641,7 @@ var CardMedia = forwardRef(function CardMedia2({ src, alt, aspectRatio = "auto",
|
|
|
5608
5641
|
CardMedia.displayName = "CardMedia";
|
|
5609
5642
|
var CardHeader = forwardRef(function CardHeader2({ headline, subheader, className }, ref) {
|
|
5610
5643
|
return /* @__PURE__ */ jsxs("div", { ref, className: cn("p-4", className), children: [
|
|
5611
|
-
/* @__PURE__ */ jsx("h3", { className: "text-on-surface text-title-
|
|
5644
|
+
/* @__PURE__ */ jsx("h3", { className: "text-on-surface text-title-medium", children: headline }),
|
|
5612
5645
|
subheader !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-on-surface-variant text-body-medium mt-1", children: subheader })
|
|
5613
5646
|
] });
|
|
5614
5647
|
});
|