@codefast/ui 0.3.16-canary.3 → 0.4.0-canary.5
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/CHANGELOG.md +112 -0
- package/README.md +27 -16
- package/dist/components/accordion.d.mts +7 -22
- package/dist/components/accordion.mjs +26 -29
- package/dist/components/alert-dialog.d.mts +27 -26
- package/dist/components/alert-dialog.mjs +53 -45
- package/dist/components/alert.d.mts +12 -2
- package/dist/components/alert.mjs +15 -6
- package/dist/components/aspect-ratio.d.mts +2 -2
- package/dist/components/aspect-ratio.mjs +2 -3
- package/dist/components/avatar.d.mts +41 -5
- package/dist/components/avatar.mjs +40 -10
- package/dist/components/badge.mjs +4 -4
- package/dist/components/breadcrumb.d.mts +1 -0
- package/dist/components/breadcrumb.mjs +11 -10
- package/dist/components/button-group.d.mts +1 -1
- package/dist/components/button-group.mjs +6 -7
- package/dist/components/button.d.mts +0 -1
- package/dist/components/button.mjs +7 -7
- package/dist/components/calendar.d.mts +6 -2
- package/dist/components/calendar.mjs +39 -43
- package/dist/components/card.d.mts +4 -2
- package/dist/components/card.mjs +9 -9
- package/dist/components/carousel.d.mts +16 -4
- package/dist/components/carousel.mjs +25 -12
- package/dist/components/chart.d.mts +8 -3
- package/dist/components/chart.mjs +21 -15
- package/dist/components/checkbox-cards.mjs +6 -6
- package/dist/components/checkbox-group.mjs +6 -7
- package/dist/components/checkbox.d.mts +2 -2
- package/dist/components/checkbox.mjs +8 -9
- package/dist/components/collapsible.d.mts +4 -4
- package/dist/components/collapsible.mjs +4 -5
- package/dist/components/command.d.mts +11 -1
- package/dist/components/command.mjs +35 -32
- package/dist/components/context-menu.d.mts +22 -15
- package/dist/components/context-menu.mjs +44 -39
- package/dist/components/dialog.d.mts +19 -23
- package/dist/components/dialog.mjs +48 -47
- package/dist/components/direction.d.mts +24 -0
- package/dist/components/direction.mjs +18 -0
- package/dist/components/drawer.d.mts +2 -20
- package/dist/components/drawer.mjs +17 -25
- package/dist/components/dropdown-menu.d.mts +22 -15
- package/dist/components/dropdown-menu.mjs +41 -37
- package/dist/components/empty.mjs +5 -5
- package/dist/components/field.d.mts +1 -1
- package/dist/components/field.mjs +11 -12
- package/dist/components/form.d.mts +6 -7
- package/dist/components/form.mjs +6 -7
- package/dist/components/hover-card.d.mts +5 -5
- package/dist/components/hover-card.mjs +14 -12
- package/dist/components/input-group.d.mts +1 -1
- package/dist/components/input-group.mjs +12 -7
- package/dist/components/input-number.d.mts +3 -1
- package/dist/components/input-number.mjs +49 -27
- package/dist/components/input-otp.mjs +9 -7
- package/dist/components/input-password.mjs +1 -4
- package/dist/components/input-search.mjs +3 -5
- package/dist/components/input.mjs +1 -2
- package/dist/components/item.mjs +9 -9
- package/dist/components/kbd.mjs +1 -1
- package/dist/components/label.d.mts +2 -2
- package/dist/components/label.mjs +3 -4
- package/dist/components/menubar.d.mts +22 -16
- package/dist/components/menubar.mjs +54 -47
- package/dist/components/native-select.d.mts +5 -1
- package/dist/components/native-select.mjs +9 -6
- package/dist/components/navigation-menu.d.mts +30 -8
- package/dist/components/navigation-menu.mjs +33 -23
- package/dist/components/pagination.d.mts +6 -0
- package/dist/components/pagination.mjs +26 -11
- package/dist/components/popover.d.mts +40 -7
- package/dist/components/popover.mjs +46 -14
- package/dist/components/progress-circle.d.mts +1 -1
- package/dist/components/progress-circle.mjs +1 -2
- package/dist/components/progress.d.mts +2 -2
- package/dist/components/progress.mjs +5 -6
- package/dist/components/radio-cards.d.mts +3 -3
- package/dist/components/radio-cards.mjs +11 -11
- package/dist/components/radio-group.d.mts +3 -3
- package/dist/components/radio-group.mjs +9 -9
- package/dist/components/radio.mjs +2 -3
- package/dist/components/resizable.mjs +3 -8
- package/dist/components/scroll-area.d.mts +5 -5
- package/dist/components/scroll-area.mjs +13 -10
- package/dist/components/select.d.mts +14 -14
- package/dist/components/select.mjs +47 -47
- package/dist/components/separator.d.mts +2 -2
- package/dist/components/separator.mjs +3 -4
- package/dist/components/sheet.d.mts +13 -14
- package/dist/components/sheet.mjs +41 -39
- package/dist/components/sidebar.d.mts +2 -3
- package/dist/components/sidebar.mjs +46 -46
- package/dist/components/skeleton.mjs +1 -1
- package/dist/components/slider.d.mts +2 -2
- package/dist/components/slider.mjs +9 -11
- package/dist/components/sonner.mjs +11 -3
- package/dist/components/spinner.mjs +6 -7
- package/dist/components/switch.d.mts +5 -2
- package/dist/components/switch.mjs +7 -7
- package/dist/components/table.mjs +10 -10
- package/dist/components/tabs.d.mts +8 -5
- package/dist/components/tabs.mjs +18 -12
- package/dist/components/textarea.mjs +1 -1
- package/dist/components/toggle-group.d.mts +9 -6
- package/dist/components/toggle-group.mjs +19 -20
- package/dist/components/toggle.d.mts +2 -3
- package/dist/components/toggle.mjs +4 -6
- package/dist/components/tooltip.d.mts +7 -6
- package/dist/components/tooltip.mjs +19 -17
- package/dist/hooks/use-animated-value.mjs +0 -1
- package/dist/hooks/use-copy-to-clipboard.mjs +0 -1
- package/dist/hooks/use-is-mobile.mjs +0 -1
- package/dist/hooks/use-media-query.mjs +0 -1
- package/dist/hooks/use-mutation-observer.mjs +0 -1
- package/dist/hooks/use-pagination.mjs +0 -1
- package/dist/index.d.mts +15 -13
- package/dist/index.mjs +18 -16
- package/dist/primitives/checkbox-group.d.mts +9 -10
- package/dist/primitives/checkbox-group.mjs +14 -19
- package/dist/primitives/input-number.d.mts +3 -3
- package/dist/primitives/input-number.mjs +3 -5
- package/dist/primitives/input.d.mts +4 -4
- package/dist/primitives/input.mjs +2 -3
- package/dist/primitives/progress-circle.d.mts +3 -3
- package/dist/primitives/progress-circle.mjs +2 -3
- package/dist/variants/alert.d.mts +1 -1
- package/dist/variants/alert.mjs +3 -13
- package/dist/variants/badge.d.mts +6 -4
- package/dist/variants/badge.mjs +7 -34
- package/dist/variants/button-group.d.mts +2 -2
- package/dist/variants/button-group.mjs +3 -14
- package/dist/variants/button.d.mts +12 -10
- package/dist/variants/button.mjs +15 -57
- package/dist/variants/empty.d.mts +1 -1
- package/dist/variants/empty.mjs +2 -7
- package/dist/variants/field.d.mts +3 -3
- package/dist/variants/field.mjs +4 -22
- package/dist/variants/input-group.d.mts +9 -9
- package/dist/variants/input-group.mjs +11 -70
- package/dist/variants/input-number.d.mts +45 -0
- package/dist/variants/input-number.mjs +40 -0
- package/dist/variants/item.d.mts +5 -4
- package/dist/variants/item.mjs +9 -31
- package/dist/variants/navigation-menu.d.mts +1 -1
- package/dist/variants/navigation-menu.mjs +1 -5
- package/dist/variants/progress-circle.d.mts +1 -1
- package/dist/variants/progress-circle.mjs +1 -5
- package/dist/variants/scroll-area.d.mts +2 -2
- package/dist/variants/scroll-area.mjs +3 -8
- package/dist/variants/separator.mjs +6 -6
- package/dist/variants/sheet.d.mts +4 -4
- package/dist/variants/sheet.mjs +5 -38
- package/dist/variants/sidebar.d.mts +4 -4
- package/dist/variants/sidebar.mjs +6 -23
- package/dist/variants/tabs.d.mts +18 -0
- package/dist/variants/tabs.mjs +15 -0
- package/dist/variants/toggle.d.mts +4 -4
- package/dist/variants/toggle.mjs +9 -27
- package/package.json +27 -44
- package/src/components/accordion.tsx +26 -68
- package/src/components/alert-dialog.tsx +70 -86
- package/src/components/alert.tsx +27 -19
- package/src/components/aspect-ratio.tsx +1 -4
- package/src/components/avatar.tsx +99 -12
- package/src/components/badge.tsx +5 -8
- package/src/components/breadcrumb.tsx +18 -24
- package/src/components/button-group.tsx +10 -20
- package/src/components/button.tsx +8 -19
- package/src/components/calendar.tsx +77 -132
- package/src/components/card.tsx +16 -22
- package/src/components/carousel.tsx +40 -58
- package/src/components/chart.tsx +41 -92
- package/src/components/checkbox-cards.tsx +11 -30
- package/src/components/checkbox-group.tsx +6 -28
- package/src/components/checkbox.tsx +6 -26
- package/src/components/collapsible.tsx +1 -4
- package/src/components/command.tsx +52 -65
- package/src/components/context-menu.tsx +46 -125
- package/src/components/dialog.tsx +49 -101
- package/src/components/direction.tsx +32 -0
- package/src/components/drawer.tsx +17 -79
- package/src/components/dropdown-menu.tsx +39 -118
- package/src/components/empty.tsx +6 -20
- package/src/components/field.tsx +19 -52
- package/src/components/form.tsx +19 -61
- package/src/components/hover-card.tsx +4 -27
- package/src/components/input-group.tsx +13 -52
- package/src/components/input-number.tsx +55 -75
- package/src/components/input-otp.tsx +19 -38
- package/src/components/input-password.tsx +5 -29
- package/src/components/input-search.tsx +6 -23
- package/src/components/input.tsx +1 -17
- package/src/components/item.tsx +17 -31
- package/src/components/kbd.tsx +2 -14
- package/src/components/label.tsx +2 -10
- package/src/components/menubar.tsx +34 -125
- package/src/components/native-select.tsx +21 -30
- package/src/components/navigation-menu.tsx +34 -94
- package/src/components/pagination.tsx +28 -34
- package/src/components/popover.tsx +66 -35
- package/src/components/progress-circle.tsx +7 -25
- package/src/components/progress.tsx +3 -16
- package/src/components/radio-cards.tsx +8 -27
- package/src/components/radio-group.tsx +7 -27
- package/src/components/radio.tsx +3 -24
- package/src/components/resizable.tsx +5 -26
- package/src/components/scroll-area.tsx +12 -32
- package/src/components/select.tsx +37 -60
- package/src/components/separator.tsx +4 -18
- package/src/components/sheet.tsx +37 -74
- package/src/components/sidebar.tsx +47 -177
- package/src/components/skeleton.tsx +1 -3
- package/src/components/slider.tsx +7 -36
- package/src/components/sonner.tsx +16 -6
- package/src/components/spinner.tsx +6 -15
- package/src/components/switch.tsx +8 -30
- package/src/components/table.tsx +18 -35
- package/src/components/tabs.tsx +16 -34
- package/src/components/textarea.tsx +1 -15
- package/src/components/toggle-group.tsx +34 -38
- package/src/components/toggle.tsx +4 -13
- package/src/components/tooltip.tsx +11 -37
- package/src/css/foundation/base.css +74 -0
- package/src/css/foundation/motion.css +69 -0
- package/src/css/foundation/source.css +10 -0
- package/src/css/foundation/tokens.css +107 -0
- package/src/css/foundation/variants.css +121 -0
- package/src/css/preset.css +13 -214
- package/src/css/style.css +9 -1
- package/src/css/{amber.css → themes/amber.css} +29 -0
- package/src/css/{blue.css → themes/blue.css} +29 -0
- package/src/css/{cyan.css → themes/cyan.css} +29 -0
- package/src/css/{emerald.css → themes/emerald.css} +29 -0
- package/src/css/{fuchsia.css → themes/fuchsia.css} +29 -0
- package/src/css/{gray.css → themes/gray.css} +29 -0
- package/src/css/{green.css → themes/green.css} +29 -0
- package/src/css/{indigo.css → themes/indigo.css} +29 -0
- package/src/css/{lime.css → themes/lime.css} +29 -0
- package/src/css/{neutral.css → themes/neutral.css} +29 -0
- package/src/css/{orange.css → themes/orange.css} +29 -0
- package/src/css/{pink.css → themes/pink.css} +29 -0
- package/src/css/{purple.css → themes/purple.css} +29 -0
- package/src/css/{red.css → themes/red.css} +29 -0
- package/src/css/{rose.css → themes/rose.css} +29 -0
- package/src/css/{sky.css → themes/sky.css} +29 -0
- package/src/css/{slate.css → themes/slate.css} +29 -0
- package/src/css/{stone.css → themes/stone.css} +29 -0
- package/src/css/{teal.css → themes/teal.css} +29 -0
- package/src/css/{violet.css → themes/violet.css} +29 -0
- package/src/css/{yellow.css → themes/yellow.css} +29 -0
- package/src/css/{zinc.css → themes/zinc.css} +29 -0
- package/src/hooks/use-animated-value.ts +1 -7
- package/src/hooks/use-copy-to-clipboard.ts +1 -6
- package/src/hooks/use-is-mobile.ts +0 -2
- package/src/hooks/use-media-query.ts +0 -2
- package/src/hooks/use-mutation-observer.ts +0 -3
- package/src/hooks/use-pagination.ts +0 -2
- package/src/index.ts +39 -80
- package/src/primitives/checkbox-group.tsx +25 -39
- package/src/primitives/input-number.tsx +17 -63
- package/src/primitives/input.tsx +8 -24
- package/src/primitives/progress-circle.tsx +13 -43
- package/src/variants/alert.ts +3 -14
- package/src/variants/badge.ts +8 -35
- package/src/variants/button-group.ts +5 -18
- package/src/variants/button.ts +21 -58
- package/src/variants/empty.ts +2 -11
- package/src/variants/field.ts +6 -19
- package/src/variants/input-group.ts +12 -64
- package/src/variants/input-number.ts +65 -0
- package/src/variants/item.ts +10 -32
- package/src/variants/navigation-menu.ts +1 -8
- package/src/variants/progress-circle.ts +1 -2
- package/src/variants/scroll-area.ts +3 -9
- package/src/variants/separator.ts +6 -7
- package/src/variants/sheet.ts +6 -39
- package/src/variants/sidebar.ts +7 -27
- package/src/variants/tabs.ts +34 -0
- package/src/variants/toggle.ts +9 -28
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Slider as SliderPrimitive } from "radix-ui";
|
|
3
2
|
import type { ComponentProps, JSX } from "react";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
4
|
|
|
5
5
|
import { cn } from "#/lib/utils";
|
|
6
|
-
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
7
|
-
import { useMemo } from "react";
|
|
8
6
|
|
|
9
7
|
/* -----------------------------------------------------------------------------
|
|
10
8
|
* Component: Slider
|
|
@@ -18,14 +16,7 @@ type SliderProps = ComponentProps<typeof SliderPrimitive.Root>;
|
|
|
18
16
|
/**
|
|
19
17
|
* @since 0.3.16-canary.0
|
|
20
18
|
*/
|
|
21
|
-
function Slider({
|
|
22
|
-
className,
|
|
23
|
-
defaultValue,
|
|
24
|
-
max = 100,
|
|
25
|
-
min = 0,
|
|
26
|
-
value,
|
|
27
|
-
...props
|
|
28
|
-
}: SliderProps): JSX.Element {
|
|
19
|
+
function Slider({ className, defaultValue, max = 100, min = 0, value, ...props }: SliderProps): JSX.Element {
|
|
29
20
|
const _values = useMemo(() => {
|
|
30
21
|
if (Array.isArray(value)) {
|
|
31
22
|
return value;
|
|
@@ -37,10 +28,7 @@ function Slider({
|
|
|
37
28
|
return (
|
|
38
29
|
<SliderPrimitive.Root
|
|
39
30
|
className={cn(
|
|
40
|
-
"relative flex w-full items-center",
|
|
41
|
-
"touch-none select-none",
|
|
42
|
-
"data-vertical:h-full data-vertical:min-h-44 data-vertical:w-auto data-vertical:flex-col",
|
|
43
|
-
"data-disabled:opacity-50",
|
|
31
|
+
"relative flex w-full touch-none items-center select-none data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col data-disabled:opacity-50",
|
|
44
32
|
className,
|
|
45
33
|
)}
|
|
46
34
|
data-slot="slider"
|
|
@@ -51,35 +39,18 @@ function Slider({
|
|
|
51
39
|
{...props}
|
|
52
40
|
>
|
|
53
41
|
<SliderPrimitive.Track
|
|
54
|
-
className=
|
|
55
|
-
"relative",
|
|
56
|
-
"w-full grow overflow-hidden",
|
|
57
|
-
"rounded-full",
|
|
58
|
-
"bg-input",
|
|
59
|
-
"data-horizontal:h-1 data-horizontal:w-full",
|
|
60
|
-
"data-vertical:h-full data-vertical:w-1",
|
|
61
|
-
)}
|
|
42
|
+
className="relative grow overflow-hidden rounded-full bg-muted data-horizontal:h-1.5 data-horizontal:w-full data-vertical:h-full data-vertical:w-1.5"
|
|
62
43
|
data-slot="slider-track"
|
|
63
44
|
>
|
|
64
45
|
<SliderPrimitive.Range
|
|
65
|
-
className=
|
|
46
|
+
className="absolute bg-primary select-none data-horizontal:h-full data-vertical:w-full"
|
|
66
47
|
data-slot="slider-range"
|
|
67
48
|
/>
|
|
68
49
|
</SliderPrimitive.Track>
|
|
69
50
|
{Array.from({ length: _values.length }, (_, index) => (
|
|
70
51
|
<SliderPrimitive.Thumb
|
|
71
52
|
key={index}
|
|
72
|
-
|
|
73
|
-
className={cn(
|
|
74
|
-
"flex size-4 items-center justify-center",
|
|
75
|
-
"rounded-full border-2 border-primary",
|
|
76
|
-
"bg-primary shadow-sm outline-hidden",
|
|
77
|
-
"after:size-full after:rounded-full after:bg-background after:transition-[width,height] after:duration-200 after:ease-spring",
|
|
78
|
-
"motion-reduce:after:transition-none motion-reduce:after:duration-0",
|
|
79
|
-
"focus-visible:ring-4 focus-visible:ring-primary/20",
|
|
80
|
-
"active:not-data-disabled:after:size-1",
|
|
81
|
-
"dark:focus-visible:ring-primary/40",
|
|
82
|
-
)}
|
|
53
|
+
className="block size-4 shrink-0 rounded-full border border-primary bg-white shadow-sm ring-ring/50 transition-[color,box-shadow] select-none hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
|
|
83
54
|
data-slot="slider-thumb"
|
|
84
55
|
/>
|
|
85
56
|
))}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { cn } from "#/lib/utils";
|
|
1
|
+
import { CircleCheckIcon, InfoIcon, Loader2Icon, OctagonXIcon, TriangleAlertIcon } from "lucide-react";
|
|
2
|
+
import { useTheme } from "next-themes";
|
|
4
3
|
import type { CSSProperties, JSX } from "react";
|
|
5
4
|
import type { ToasterProps as SonnerToasterProps } from "sonner";
|
|
6
|
-
|
|
7
|
-
import { useTheme } from "next-themes";
|
|
8
5
|
import { Toaster as Sonner } from "sonner";
|
|
9
6
|
|
|
10
7
|
/* -----------------------------------------------------------------------------
|
|
@@ -24,15 +21,28 @@ function Toaster({ ...props }: ToasterProps): JSX.Element {
|
|
|
24
21
|
|
|
25
22
|
return (
|
|
26
23
|
<Sonner
|
|
27
|
-
className=
|
|
24
|
+
className="toaster group"
|
|
25
|
+
icons={{
|
|
26
|
+
error: <OctagonXIcon className="size-4" />,
|
|
27
|
+
info: <InfoIcon className="size-4" />,
|
|
28
|
+
loading: <Loader2Icon className="size-4 animate-spin" />,
|
|
29
|
+
success: <CircleCheckIcon className="size-4" />,
|
|
30
|
+
warning: <TriangleAlertIcon className="size-4" />,
|
|
31
|
+
}}
|
|
28
32
|
style={
|
|
29
33
|
{
|
|
34
|
+
"--border-radius": "var(--radius)",
|
|
30
35
|
"--normal-bg": "var(--popover)",
|
|
31
36
|
"--normal-border": "var(--border)",
|
|
32
37
|
"--normal-text": "var(--popover-foreground)",
|
|
33
38
|
} as CSSProperties
|
|
34
39
|
}
|
|
35
40
|
theme={theme as ToasterProps["theme"]}
|
|
41
|
+
toastOptions={{
|
|
42
|
+
classNames: {
|
|
43
|
+
toast: "rounded-2xl",
|
|
44
|
+
},
|
|
45
|
+
}}
|
|
36
46
|
{...props}
|
|
37
47
|
/>
|
|
38
48
|
);
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { VisuallyHidden } from "radix-ui";
|
|
3
2
|
import type { ComponentProps, CSSProperties, ReactNode } from "react";
|
|
4
3
|
|
|
5
4
|
import { cn } from "#/lib/utils";
|
|
6
|
-
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
|
|
7
5
|
|
|
8
6
|
/* -----------------------------------------------------------------------------
|
|
9
7
|
* Component: Spinner
|
|
@@ -27,18 +25,11 @@ function Spinner({ children, className, loading = true, ...props }: SpinnerProps
|
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
const spinner = (
|
|
30
|
-
<span
|
|
31
|
-
className={cn("relative flex size-4 items-center justify-center", "opacity-60", className)}
|
|
32
|
-
{...props}
|
|
33
|
-
>
|
|
28
|
+
<span className={cn("relative flex size-4 items-center justify-center opacity-60", className)} {...props}>
|
|
34
29
|
{Array.from({ length: SPINNER_COUNT }, (_, index) => (
|
|
35
30
|
<span
|
|
36
31
|
key={index}
|
|
37
|
-
className=
|
|
38
|
-
"absolute",
|
|
39
|
-
"h-full rotate-(--spinner-rotate)",
|
|
40
|
-
"before:block before:h-1/3 before:w-full before:animate-out before:rounded-full before:bg-current before:delay-(--spinner-delay) before:animation-duration-(--spinner-duration) before:fade-out-25 before:repeat-infinite motion-reduce:before:animate-none",
|
|
41
|
-
)}
|
|
32
|
+
className="absolute h-full rotate-(--spinner-rotate) before:block before:h-1/3 before:w-full before:animate-out before:rounded-full before:bg-current before:delay-(--spinner-delay) before:animation-duration-(--spinner-duration) before:fade-out-25 before:repeat-infinite motion-reduce:before:animate-none"
|
|
42
33
|
style={
|
|
43
34
|
{
|
|
44
35
|
"--spinner-delay": `-${((SPINNER_COUNT - index) * 100).toString()}ms`,
|
|
@@ -58,11 +49,11 @@ function Spinner({ children, className, loading = true, ...props }: SpinnerProps
|
|
|
58
49
|
|
|
59
50
|
return (
|
|
60
51
|
<span className="relative">
|
|
61
|
-
<span aria-hidden className=
|
|
52
|
+
<span aria-hidden className="invisible contents">
|
|
62
53
|
{children}
|
|
63
54
|
</span>
|
|
64
|
-
<VisuallyHidden>{children}</VisuallyHidden>
|
|
65
|
-
<span className=
|
|
55
|
+
<VisuallyHidden.Root>{children}</VisuallyHidden.Root>
|
|
56
|
+
<span className="absolute inset-0 flex items-center justify-center">{spinner}</span>
|
|
66
57
|
</span>
|
|
67
58
|
);
|
|
68
59
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Switch as SwitchPrimitives } from "radix-ui";
|
|
3
2
|
import type { ComponentProps, JSX } from "react";
|
|
4
3
|
|
|
5
4
|
import { cn } from "#/lib/utils";
|
|
6
|
-
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
7
5
|
|
|
8
6
|
/* -----------------------------------------------------------------------------
|
|
9
7
|
* Component: Switch
|
|
@@ -12,46 +10,26 @@ import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
|
12
10
|
/**
|
|
13
11
|
* @since 0.3.16-canary.0
|
|
14
12
|
*/
|
|
15
|
-
type SwitchProps = ComponentProps<typeof SwitchPrimitives.Root
|
|
13
|
+
type SwitchProps = ComponentProps<typeof SwitchPrimitives.Root> & {
|
|
14
|
+
size?: "default" | "sm";
|
|
15
|
+
};
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @since 0.3.16-canary.0
|
|
19
19
|
*/
|
|
20
|
-
function Switch({ className, ...props }: SwitchProps): JSX.Element {
|
|
20
|
+
function Switch({ className, size = "default", ...props }: SwitchProps): JSX.Element {
|
|
21
21
|
return (
|
|
22
22
|
<SwitchPrimitives.Root
|
|
23
23
|
className={cn(
|
|
24
|
-
"peer group/switch inline-flex h-5 w-
|
|
25
|
-
"rounded-full border border-transparent shadow-xs outline-hidden",
|
|
26
|
-
"transition-[background-color,box-shadow] duration-200 ease-snappy",
|
|
27
|
-
"motion-reduce:transition-none motion-reduce:duration-0",
|
|
28
|
-
"active:not-disabled:inset-shadow-sm",
|
|
29
|
-
"focus-visible:ring-3 focus-visible:ring-ring/50",
|
|
30
|
-
"focus-visible:not-data-checked:border-ring/60",
|
|
31
|
-
"disabled:opacity-50",
|
|
32
|
-
"data-checked:bg-primary",
|
|
33
|
-
"data-checked:focus-visible:ring-primary/20",
|
|
34
|
-
"dark:data-checked:focus-visible:ring-primary/40",
|
|
35
|
-
"data-unchecked:bg-input",
|
|
36
|
-
"dark:data-unchecked:bg-input/80",
|
|
24
|
+
"peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all duration-control ease-snappy outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-4.5 data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
37
25
|
className,
|
|
38
26
|
)}
|
|
27
|
+
data-size={size}
|
|
39
28
|
data-slot="switch"
|
|
40
29
|
{...props}
|
|
41
30
|
>
|
|
42
31
|
<SwitchPrimitives.Thumb
|
|
43
|
-
className=
|
|
44
|
-
"block",
|
|
45
|
-
"size-3.5",
|
|
46
|
-
"rounded-full",
|
|
47
|
-
"bg-background shadow-sm",
|
|
48
|
-
"pointer-events-none",
|
|
49
|
-
"transition-transform duration-300 ease-spring",
|
|
50
|
-
"motion-reduce:transition-none motion-reduce:duration-0",
|
|
51
|
-
"dark:not-data-checked:bg-foreground",
|
|
52
|
-
"data-checked:translate-x-3.5",
|
|
53
|
-
"data-unchecked:translate-x-0",
|
|
54
|
-
)}
|
|
32
|
+
className="pointer-events-none block rounded-full bg-background ring-0 transition-transform duration-control-indicator ease-spring group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-3.5 group-data-[size=sm]/switch:data-checked:translate-x-2.5 rtl:group-data-[size=default]/switch:data-checked:-translate-x-3.5 rtl:group-data-[size=sm]/switch:data-checked:-translate-x-2.5 dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 rtl:group-data-[size=default]/switch:data-unchecked:-translate-x-0 rtl:group-data-[size=sm]/switch:data-unchecked:-translate-x-0 dark:data-unchecked:bg-foreground"
|
|
55
33
|
data-slot="switch-thumb"
|
|
56
34
|
/>
|
|
57
35
|
</SwitchPrimitives.Root>
|
package/src/components/table.tsx
CHANGED
|
@@ -16,12 +16,8 @@ type TableProps = ComponentProps<"table">;
|
|
|
16
16
|
*/
|
|
17
17
|
function Table({ className, ...props }: TableProps): JSX.Element {
|
|
18
18
|
return (
|
|
19
|
-
<div className=
|
|
20
|
-
<table
|
|
21
|
-
className={cn("w-full text-sm", "caption-bottom", className)}
|
|
22
|
-
data-slot="table"
|
|
23
|
-
{...props}
|
|
24
|
-
/>
|
|
19
|
+
<div className="relative w-full overflow-x-auto" data-slot="table-container">
|
|
20
|
+
<table className={cn("w-full caption-bottom text-sm", className)} data-slot="table" {...props} />
|
|
25
21
|
</div>
|
|
26
22
|
);
|
|
27
23
|
}
|
|
@@ -39,13 +35,7 @@ type TableHeaderProps = ComponentProps<"thead">;
|
|
|
39
35
|
* @since 0.3.16-canary.0
|
|
40
36
|
*/
|
|
41
37
|
function TableHeader({ className, ...props }: TableHeaderProps): JSX.Element {
|
|
42
|
-
return (
|
|
43
|
-
<thead
|
|
44
|
-
className={cn("*:border-b", "*:has-aria-expanded:bg-transparent", className)}
|
|
45
|
-
data-slot="table-header"
|
|
46
|
-
{...props}
|
|
47
|
-
/>
|
|
48
|
-
);
|
|
38
|
+
return <thead className={cn("[&_tr]:border-b", className)} data-slot="table-header" {...props} />;
|
|
49
39
|
}
|
|
50
40
|
|
|
51
41
|
/* -----------------------------------------------------------------------------
|
|
@@ -61,9 +51,7 @@ type TableBodyProps = ComponentProps<"tbody">;
|
|
|
61
51
|
* @since 0.3.16-canary.0
|
|
62
52
|
*/
|
|
63
53
|
function TableBody({ className, ...props }: TableBodyProps): JSX.Element {
|
|
64
|
-
return (
|
|
65
|
-
<tbody className={cn("*:last-child:border-0", className)} data-slot="table-body" {...props} />
|
|
66
|
-
);
|
|
54
|
+
return <tbody className={cn("[&_tr:last-child]:border-0", className)} data-slot="table-body" {...props} />;
|
|
67
55
|
}
|
|
68
56
|
|
|
69
57
|
/* -----------------------------------------------------------------------------
|
|
@@ -81,12 +69,7 @@ type TableFooterProps = ComponentProps<"tfoot">;
|
|
|
81
69
|
function TableFooter({ className, ...props }: TableFooterProps): JSX.Element {
|
|
82
70
|
return (
|
|
83
71
|
<tfoot
|
|
84
|
-
className={cn(
|
|
85
|
-
"bg-muted/50 font-medium",
|
|
86
|
-
"*:border-t *:border-b-0",
|
|
87
|
-
"*:has-aria-expanded:bg-transparent",
|
|
88
|
-
className,
|
|
89
|
-
)}
|
|
72
|
+
className={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className)}
|
|
90
73
|
data-slot="table-footer"
|
|
91
74
|
{...props}
|
|
92
75
|
/>
|
|
@@ -109,12 +92,7 @@ function TableRow({ className, ...props }: TableRowProps): JSX.Element {
|
|
|
109
92
|
return (
|
|
110
93
|
<tr
|
|
111
94
|
className={cn(
|
|
112
|
-
"border-b",
|
|
113
|
-
"transition-colors",
|
|
114
|
-
"motion-reduce:transition-none",
|
|
115
|
-
"hover:bg-muted/50",
|
|
116
|
-
"has-aria-expanded:bg-muted/50",
|
|
117
|
-
"data-selected:bg-muted",
|
|
95
|
+
"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-selected:bg-muted",
|
|
118
96
|
className,
|
|
119
97
|
)}
|
|
120
98
|
data-slot="table-row"
|
|
@@ -138,7 +116,10 @@ type TableHeadProps = ComponentProps<"th">;
|
|
|
138
116
|
function TableHead({ className, ...props }: TableHeadProps): JSX.Element {
|
|
139
117
|
return (
|
|
140
118
|
<th
|
|
141
|
-
className={cn(
|
|
119
|
+
className={cn(
|
|
120
|
+
"h-10 px-2 text-start align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pe-0",
|
|
121
|
+
className,
|
|
122
|
+
)}
|
|
142
123
|
data-slot="table-head"
|
|
143
124
|
{...props}
|
|
144
125
|
/>
|
|
@@ -158,7 +139,13 @@ type TableCellProps = ComponentProps<"td">;
|
|
|
158
139
|
* @since 0.3.16-canary.0
|
|
159
140
|
*/
|
|
160
141
|
function TableCell({ className, ...props }: TableCellProps): JSX.Element {
|
|
161
|
-
return
|
|
142
|
+
return (
|
|
143
|
+
<td
|
|
144
|
+
className={cn("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pe-0", className)}
|
|
145
|
+
data-slot="table-cell"
|
|
146
|
+
{...props}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
162
149
|
}
|
|
163
150
|
|
|
164
151
|
/* -----------------------------------------------------------------------------
|
|
@@ -175,11 +162,7 @@ type TableCaptionProps = ComponentProps<"caption">;
|
|
|
175
162
|
*/
|
|
176
163
|
function TableCaption({ className, ...props }: TableCaptionProps): JSX.Element {
|
|
177
164
|
return (
|
|
178
|
-
<caption
|
|
179
|
-
className={cn("mt-4", "text-sm text-muted-foreground", className)}
|
|
180
|
-
data-slot="table-caption"
|
|
181
|
-
{...props}
|
|
182
|
-
/>
|
|
165
|
+
<caption className={cn("mt-4 text-sm text-muted-foreground", className)} data-slot="table-caption" {...props} />
|
|
183
166
|
);
|
|
184
167
|
}
|
|
185
168
|
|
package/src/components/tabs.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Tabs as TabsPrimitive } from "radix-ui";
|
|
3
2
|
import type { ComponentProps, JSX } from "react";
|
|
4
3
|
|
|
5
4
|
import { cn } from "#/lib/utils";
|
|
6
|
-
import
|
|
5
|
+
import type { TabsListVariants } from "#/variants/tabs";
|
|
6
|
+
import { tabsListVariants } from "#/variants/tabs";
|
|
7
7
|
|
|
8
8
|
/* -----------------------------------------------------------------------------
|
|
9
9
|
* Component: Tabs
|
|
@@ -17,11 +17,13 @@ type TabsProps = ComponentProps<typeof TabsPrimitive.Root>;
|
|
|
17
17
|
/**
|
|
18
18
|
* @since 0.3.16-canary.0
|
|
19
19
|
*/
|
|
20
|
-
function Tabs({ className, ...props }: TabsProps): JSX.Element {
|
|
20
|
+
function Tabs({ className, orientation = "horizontal", ...props }: TabsProps): JSX.Element {
|
|
21
21
|
return (
|
|
22
22
|
<TabsPrimitive.Root
|
|
23
|
-
className={cn("
|
|
23
|
+
className={cn("group/tabs flex gap-2 data-horizontal:flex-col", className)}
|
|
24
|
+
data-orientation={orientation}
|
|
24
25
|
data-slot="tabs"
|
|
26
|
+
orientation={orientation}
|
|
25
27
|
{...props}
|
|
26
28
|
/>
|
|
27
29
|
);
|
|
@@ -34,21 +36,17 @@ function Tabs({ className, ...props }: TabsProps): JSX.Element {
|
|
|
34
36
|
/**
|
|
35
37
|
* @since 0.3.16-canary.0
|
|
36
38
|
*/
|
|
37
|
-
type TabsListProps = ComponentProps<typeof TabsPrimitive.List
|
|
39
|
+
type TabsListProps = ComponentProps<typeof TabsPrimitive.List> & TabsListVariants;
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
42
|
* @since 0.3.16-canary.0
|
|
41
43
|
*/
|
|
42
|
-
function TabsList({ className, ...props }: TabsListProps): JSX.Element {
|
|
44
|
+
function TabsList({ className, variant = "default", ...props }: TabsListProps): JSX.Element {
|
|
43
45
|
return (
|
|
44
46
|
<TabsPrimitive.List
|
|
45
|
-
className={
|
|
46
|
-
"inline-flex w-fit items-center justify-center gap-1 px-1 py-1",
|
|
47
|
-
"rounded-xl",
|
|
48
|
-
"bg-muted text-muted-foreground",
|
|
49
|
-
className,
|
|
50
|
-
)}
|
|
47
|
+
className={tabsListVariants({ className, variant })}
|
|
51
48
|
data-slot="tabs-list"
|
|
49
|
+
data-variant={variant}
|
|
52
50
|
{...props}
|
|
53
51
|
/>
|
|
54
52
|
);
|
|
@@ -70,21 +68,10 @@ function TabsTrigger({ className, ...props }: TabsTriggerProps): JSX.Element {
|
|
|
70
68
|
return (
|
|
71
69
|
<TabsPrimitive.Trigger
|
|
72
70
|
className={cn(
|
|
73
|
-
"inline-flex items-center justify-center gap-1.5",
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"transition-[color,background-color,box-shadow] duration-150 ease-snappy",
|
|
78
|
-
"motion-reduce:transition-none motion-reduce:duration-0",
|
|
79
|
-
"not-dark:outline-hidden",
|
|
80
|
-
"hover:not-disabled:text-foreground",
|
|
81
|
-
"focus-visible:ring-3 focus-visible:ring-ring/50",
|
|
82
|
-
"disabled:opacity-50",
|
|
83
|
-
"dark:focus-visible:-outline-offset-1 dark:focus-visible:outline-ring",
|
|
84
|
-
"data-active:bg-background data-active:text-foreground data-active:shadow-sm",
|
|
85
|
-
"dark:data-active:bg-input/50",
|
|
86
|
-
"dark:focus-visible:data-active:outline-1",
|
|
87
|
-
"[&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
71
|
+
"relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
72
|
+
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",
|
|
73
|
+
"data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
|
|
74
|
+
"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:-bottom-1.25 group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-end-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
|
|
88
75
|
className,
|
|
89
76
|
)}
|
|
90
77
|
data-slot="tabs-trigger"
|
|
@@ -108,12 +95,7 @@ type TabsContentProps = ComponentProps<typeof TabsPrimitive.Content>;
|
|
|
108
95
|
function TabsContent({ className, ...props }: TabsContentProps): JSX.Element {
|
|
109
96
|
return (
|
|
110
97
|
<TabsPrimitive.Content
|
|
111
|
-
className={cn(
|
|
112
|
-
"mt-2",
|
|
113
|
-
"rounded-xl ring-ring/50 outline-ring",
|
|
114
|
-
"focus-visible:ring-4 focus-visible:outline-1",
|
|
115
|
-
className,
|
|
116
|
-
)}
|
|
98
|
+
className={cn("flex-1 text-sm outline-none", className)}
|
|
117
99
|
data-slot="tabs-content"
|
|
118
100
|
{...props}
|
|
119
101
|
/>
|
|
@@ -18,21 +18,7 @@ function Textarea({ className, ...props }: TextareaProps): JSX.Element {
|
|
|
18
18
|
return (
|
|
19
19
|
<textarea
|
|
20
20
|
className={cn(
|
|
21
|
-
"flex min-h-16 w-full
|
|
22
|
-
"rounded-lg border border-input shadow-xs outline-hidden",
|
|
23
|
-
"text-base",
|
|
24
|
-
"transition-[color,box-shadow] duration-150 ease-snappy",
|
|
25
|
-
"motion-reduce:transition-none motion-reduce:duration-0",
|
|
26
|
-
"placeholder:text-muted-foreground",
|
|
27
|
-
"hover:not-disabled:not-focus-visible:border-ring/60",
|
|
28
|
-
"focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",
|
|
29
|
-
"disabled:opacity-50",
|
|
30
|
-
"aria-invalid:border-destructive",
|
|
31
|
-
"focus-within:aria-invalid:ring-destructive/20",
|
|
32
|
-
"hover:not-disabled:not-focus-within:aria-invalid:border-destructive/60",
|
|
33
|
-
"md:text-sm",
|
|
34
|
-
"dark:bg-input/30",
|
|
35
|
-
"dark:focus-within:aria-invalid:ring-destructive/40",
|
|
21
|
+
"flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-2.5 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
|
36
22
|
className,
|
|
37
23
|
)}
|
|
38
24
|
data-slot="textarea"
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { Scope } from "@radix-ui/react-context";
|
|
1
|
+
import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui";
|
|
2
|
+
import { Context } from "radix-ui/internal";
|
|
4
3
|
import type { ComponentProps, CSSProperties, JSX } from "react";
|
|
5
4
|
|
|
5
|
+
import type { VariantProps } from "#/lib/utils";
|
|
6
6
|
import { cn } from "#/lib/utils";
|
|
7
|
-
import { createContextScope } from "@radix-ui/react-context";
|
|
8
|
-
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
9
|
-
import { createToggleGroupScope } from "@radix-ui/react-toggle-group";
|
|
10
|
-
|
|
11
7
|
import { toggleVariants } from "#/variants/toggle";
|
|
12
|
-
import type { VariantProps } from "#/lib/utils";
|
|
13
8
|
|
|
14
9
|
/* -----------------------------------------------------------------------------
|
|
15
10
|
* Context: ToggleGroup
|
|
@@ -17,14 +12,17 @@ import type { VariantProps } from "#/lib/utils";
|
|
|
17
12
|
|
|
18
13
|
const TOGGLE_GROUP_NAME = "ToggleGroup";
|
|
19
14
|
|
|
20
|
-
type ScopedProps<P> = P & { __scopeToggleGroup?: Scope };
|
|
15
|
+
type ScopedProps<P> = P & { __scopeToggleGroup?: Context.Scope };
|
|
21
16
|
|
|
22
|
-
const [createToggleGroupContext] = createContextScope(TOGGLE_GROUP_NAME, [
|
|
17
|
+
const [createToggleGroupContext] = Context.createContextScope(TOGGLE_GROUP_NAME, [
|
|
18
|
+
ToggleGroupPrimitive.createToggleGroupScope,
|
|
19
|
+
]);
|
|
23
20
|
|
|
24
|
-
const useToggleGroupScope = createToggleGroupScope();
|
|
21
|
+
const useToggleGroupScope = ToggleGroupPrimitive.createToggleGroupScope();
|
|
25
22
|
|
|
26
23
|
const [ToggleGroupProvider, useToggleGroupContext] = createToggleGroupContext<
|
|
27
24
|
VariantProps<typeof toggleVariants> & {
|
|
25
|
+
orientation?: "horizontal" | "vertical";
|
|
28
26
|
spacing?: number;
|
|
29
27
|
}
|
|
30
28
|
>(TOGGLE_GROUP_NAME);
|
|
@@ -38,6 +36,7 @@ const [ToggleGroupProvider, useToggleGroupContext] = createToggleGroupContext<
|
|
|
38
36
|
*/
|
|
39
37
|
type ToggleGroupProps = ComponentProps<typeof ToggleGroupPrimitive.Root> &
|
|
40
38
|
VariantProps<typeof toggleVariants> & {
|
|
39
|
+
orientation?: "horizontal" | "vertical";
|
|
41
40
|
spacing?: number;
|
|
42
41
|
};
|
|
43
42
|
|
|
@@ -48,22 +47,28 @@ function ToggleGroup({
|
|
|
48
47
|
__scopeToggleGroup,
|
|
49
48
|
children,
|
|
50
49
|
className,
|
|
50
|
+
orientation = "horizontal",
|
|
51
51
|
size,
|
|
52
|
-
spacing =
|
|
52
|
+
spacing = 2,
|
|
53
53
|
variant,
|
|
54
54
|
...props
|
|
55
55
|
}: ScopedProps<ToggleGroupProps>): JSX.Element {
|
|
56
56
|
const toggleGroupScope = useToggleGroupScope(__scopeToggleGroup);
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
|
-
<ToggleGroupProvider
|
|
59
|
+
<ToggleGroupProvider
|
|
60
|
+
orientation={orientation}
|
|
61
|
+
scope={__scopeToggleGroup}
|
|
62
|
+
size={size}
|
|
63
|
+
spacing={spacing}
|
|
64
|
+
variant={variant}
|
|
65
|
+
>
|
|
60
66
|
<ToggleGroupPrimitive.Root
|
|
61
67
|
className={cn(
|
|
62
|
-
"group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))]",
|
|
63
|
-
"rounded-lg",
|
|
64
|
-
"data-[spacing=default]:data-[variant=outline]:shadow-xs",
|
|
68
|
+
"group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=0]:data-[variant=outline]:shadow-xs data-vertical:flex-col data-vertical:items-stretch",
|
|
65
69
|
className,
|
|
66
70
|
)}
|
|
71
|
+
data-orientation={orientation}
|
|
67
72
|
data-size={size}
|
|
68
73
|
data-slot="toggle-group"
|
|
69
74
|
data-spacing={spacing}
|
|
@@ -87,49 +92,40 @@ const TOGGLE_GROUP_ITEM_NAME = "ToggleGroupItem";
|
|
|
87
92
|
/**
|
|
88
93
|
* @since 0.3.16-canary.0
|
|
89
94
|
*/
|
|
90
|
-
type ToggleGroupItemProps = ScopedProps<
|
|
95
|
+
type ToggleGroupItemProps = ScopedProps<
|
|
96
|
+
ComponentProps<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants>
|
|
97
|
+
>;
|
|
91
98
|
|
|
92
99
|
/**
|
|
93
100
|
* @since 0.3.16-canary.0
|
|
94
101
|
*/
|
|
95
102
|
function ToggleGroupItem({
|
|
96
103
|
__scopeToggleGroup,
|
|
97
|
-
children,
|
|
98
104
|
className,
|
|
105
|
+
size = "default",
|
|
106
|
+
variant = "default",
|
|
99
107
|
...props
|
|
100
108
|
}: ToggleGroupItemProps): JSX.Element {
|
|
101
|
-
const
|
|
102
|
-
TOGGLE_GROUP_ITEM_NAME,
|
|
103
|
-
__scopeToggleGroup,
|
|
104
|
-
);
|
|
109
|
+
const context = useToggleGroupContext(TOGGLE_GROUP_ITEM_NAME, __scopeToggleGroup);
|
|
105
110
|
const toggleGroupScope = useToggleGroupScope(__scopeToggleGroup);
|
|
106
111
|
|
|
107
112
|
return (
|
|
108
113
|
<ToggleGroupPrimitive.Item
|
|
109
114
|
className={cn(
|
|
110
|
-
"
|
|
111
|
-
"focus:z-10",
|
|
112
|
-
"focus-visible:z-10",
|
|
113
|
-
"data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none",
|
|
114
|
-
"data-[spacing=0]:first:rounded-l-lg",
|
|
115
|
-
"data-[spacing=0]:last:rounded-r-lg",
|
|
116
|
-
"data-[spacing=0]:data-[variant=outline]:border-l-0",
|
|
117
|
-
"data-[spacing=0]:data-[variant=outline]:first:border-l",
|
|
115
|
+
"shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pe-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:ps-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-s-md group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-md group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-e-md group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-md group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-s-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-s group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t data-on:bg-muted",
|
|
118
116
|
toggleVariants({
|
|
119
117
|
className,
|
|
120
|
-
size,
|
|
121
|
-
variant,
|
|
118
|
+
size: context.size ?? size,
|
|
119
|
+
variant: context.variant ?? variant,
|
|
122
120
|
}),
|
|
123
121
|
)}
|
|
124
|
-
data-size={size}
|
|
122
|
+
data-size={context.size ?? size}
|
|
125
123
|
data-slot="toggle-group-item"
|
|
126
|
-
data-spacing={spacing}
|
|
127
|
-
data-variant={variant}
|
|
124
|
+
data-spacing={context.spacing}
|
|
125
|
+
data-variant={context.variant ?? variant}
|
|
128
126
|
{...toggleGroupScope}
|
|
129
127
|
{...props}
|
|
130
|
-
|
|
131
|
-
{children}
|
|
132
|
-
</ToggleGroupPrimitive.Item>
|
|
128
|
+
/>
|
|
133
129
|
);
|
|
134
130
|
}
|
|
135
131
|
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { ToggleVariants } from "#/variants/toggle";
|
|
1
|
+
import { Toggle as TogglePrimitive } from "radix-ui";
|
|
4
2
|
import type { ComponentProps, JSX } from "react";
|
|
5
3
|
|
|
6
|
-
import
|
|
7
|
-
|
|
4
|
+
import type { ToggleVariants } from "#/variants/toggle";
|
|
8
5
|
import { toggleVariants } from "#/variants/toggle";
|
|
9
6
|
|
|
10
7
|
/* -----------------------------------------------------------------------------
|
|
@@ -19,15 +16,9 @@ interface ToggleProps extends ComponentProps<typeof TogglePrimitive.Root>, Toggl
|
|
|
19
16
|
/**
|
|
20
17
|
* @since 0.3.16-canary.0
|
|
21
18
|
*/
|
|
22
|
-
function Toggle({
|
|
19
|
+
function Toggle({ className, size, variant, ...props }: ToggleProps): JSX.Element {
|
|
23
20
|
return (
|
|
24
|
-
<TogglePrimitive.Root
|
|
25
|
-
className={toggleVariants({ className, size, variant })}
|
|
26
|
-
data-slot="toggle"
|
|
27
|
-
{...props}
|
|
28
|
-
>
|
|
29
|
-
{children}
|
|
30
|
-
</TogglePrimitive.Root>
|
|
21
|
+
<TogglePrimitive.Root className={toggleVariants({ className, size, variant })} data-slot="toggle" {...props} />
|
|
31
22
|
);
|
|
32
23
|
}
|
|
33
24
|
|