@codefast/ui 0.3.16-canary.1 → 0.3.16-canary.3
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 +30 -0
- package/README.md +1 -1
- package/dist/components/accordion.mjs +2 -2
- package/dist/components/alert-dialog.d.mts +1 -1
- package/dist/components/alert-dialog.mjs +4 -4
- package/dist/components/alert.d.mts +3 -13
- package/dist/components/alert.mjs +3 -23
- package/dist/components/badge.d.mts +3 -15
- package/dist/components/badge.mjs +2 -44
- package/dist/components/breadcrumb.mjs +1 -1
- package/dist/components/button-group.d.mts +3 -13
- package/dist/components/button-group.mjs +3 -24
- package/dist/components/button.d.mts +3 -25
- package/dist/components/button.mjs +2 -72
- package/dist/components/calendar.mjs +2 -1
- package/dist/components/carousel.d.mts +1 -2
- package/dist/components/chart.d.mts +2 -4
- package/dist/components/checkbox.mjs +2 -2
- package/dist/components/context-menu.mjs +2 -2
- package/dist/components/dialog.d.mts +1 -1
- package/dist/components/dialog.mjs +4 -4
- package/dist/components/drawer.d.mts +1 -1
- package/dist/components/drawer.mjs +2 -2
- package/dist/components/dropdown-menu.mjs +2 -2
- package/dist/components/empty.d.mts +3 -13
- package/dist/components/empty.mjs +3 -18
- package/dist/components/field.d.mts +3 -14
- package/dist/components/field.mjs +3 -32
- package/dist/components/form.d.mts +2 -4
- package/dist/components/hover-card.mjs +1 -1
- package/dist/components/input-group.d.mts +4 -31
- package/dist/components/input-group.mjs +3 -90
- package/dist/components/input-number.mjs +4 -4
- package/dist/components/input-otp.mjs +2 -2
- package/dist/components/input.mjs +1 -1
- package/dist/components/item.d.mts +4 -29
- package/dist/components/item.mjs +3 -56
- package/dist/components/menubar.mjs +2 -2
- package/dist/components/native-select.mjs +1 -1
- package/dist/components/navigation-menu.d.mts +1 -6
- package/dist/components/navigation-menu.mjs +8 -15
- package/dist/components/pagination.d.mts +1 -1
- package/dist/components/pagination.mjs +1 -1
- package/dist/components/popover.mjs +1 -1
- package/dist/components/progress-circle.d.mts +3 -47
- package/dist/components/progress-circle.mjs +2 -47
- package/dist/components/progress.mjs +1 -1
- package/dist/components/radio-group.mjs +1 -1
- package/dist/components/radio.mjs +1 -1
- package/dist/components/scroll-area.d.mts +3 -19
- package/dist/components/scroll-area.mjs +4 -61
- package/dist/components/select.d.mts +1 -1
- package/dist/components/select.mjs +3 -3
- package/dist/components/separator.d.mts +3 -18
- package/dist/components/separator.mjs +3 -23
- package/dist/components/sheet.d.mts +6 -18
- package/dist/components/sheet.mjs +6 -49
- package/dist/components/sidebar.d.mts +4 -19
- package/dist/components/sidebar.mjs +10 -46
- package/dist/components/skeleton.mjs +1 -1
- package/dist/components/slider.mjs +1 -1
- package/dist/components/spinner.mjs +1 -1
- package/dist/components/switch.mjs +2 -2
- package/dist/components/table.mjs +1 -1
- package/dist/components/tabs.mjs +1 -1
- package/dist/components/textarea.mjs +1 -1
- package/dist/components/toggle-group.d.mts +3 -2
- package/dist/components/toggle-group.mjs +1 -1
- package/dist/components/toggle.d.mts +2 -21
- package/dist/components/toggle.mjs +2 -39
- package/dist/components/tooltip.mjs +1 -1
- package/dist/index.d.mts +31 -16
- package/dist/index.mjs +30 -15
- package/dist/lib/utils.d.mts +1 -12
- package/dist/lib/utils.mjs +1 -9
- package/dist/primitives/checkbox-group.d.mts +1 -2
- package/dist/primitives/input-number.d.mts +1 -2
- package/dist/primitives/input.d.mts +1 -2
- package/dist/primitives/progress-circle.d.mts +1 -2
- package/dist/variants/alert.d.mts +18 -0
- package/dist/variants/alert.mjs +25 -0
- package/dist/variants/badge.d.mts +20 -0
- package/dist/variants/badge.mjs +46 -0
- package/dist/variants/button-group.d.mts +18 -0
- package/dist/variants/button-group.mjs +26 -0
- package/dist/variants/button.d.mts +30 -0
- package/dist/variants/button.mjs +76 -0
- package/dist/variants/empty.d.mts +18 -0
- package/dist/variants/empty.mjs +20 -0
- package/dist/variants/field.d.mts +19 -0
- package/dist/variants/field.mjs +34 -0
- package/dist/variants/input-group.d.mts +43 -0
- package/dist/variants/input-group.mjs +93 -0
- package/dist/variants/item.d.mts +37 -0
- package/dist/variants/item.mjs +60 -0
- package/dist/variants/navigation-menu.d.mts +13 -0
- package/dist/variants/navigation-menu.mjs +12 -0
- package/dist/variants/progress-circle.d.mts +52 -0
- package/dist/variants/progress-circle.mjs +49 -0
- package/dist/variants/scroll-area.d.mts +24 -0
- package/dist/variants/scroll-area.mjs +63 -0
- package/dist/variants/separator.d.mts +23 -0
- package/dist/variants/separator.mjs +25 -0
- package/dist/variants/sheet.d.mts +20 -0
- package/dist/variants/sheet.mjs +50 -0
- package/dist/variants/sidebar.d.mts +23 -0
- package/dist/variants/sidebar.mjs +42 -0
- package/dist/variants/toggle.d.mts +23 -0
- package/dist/variants/toggle.mjs +43 -0
- package/package.json +169 -21
- package/src/components/accordion.tsx +156 -0
- package/src/components/alert-dialog.tsx +314 -0
- package/src/components/alert.tsx +86 -0
- package/src/components/aspect-ratio.tsx +28 -0
- package/src/components/avatar.tsx +84 -0
- package/src/components/badge.tsx +38 -0
- package/src/components/breadcrumb.tsx +197 -0
- package/src/components/button-group.tsx +107 -0
- package/src/components/button.tsx +66 -0
- package/src/components/calendar.tsx +277 -0
- package/src/components/card.tsx +175 -0
- package/src/components/carousel.tsx +367 -0
- package/src/components/chart.tsx +587 -0
- package/src/components/checkbox-cards.tsx +92 -0
- package/src/components/checkbox-group.tsx +83 -0
- package/src/components/checkbox.tsx +65 -0
- package/src/components/collapsible.tsx +60 -0
- package/src/components/command.tsx +311 -0
- package/src/components/context-menu.tsx +489 -0
- package/src/components/dialog.tsx +295 -0
- package/src/components/drawer.tsx +271 -0
- package/src/components/dropdown-menu.tsx +498 -0
- package/src/components/empty.tsx +169 -0
- package/src/components/field.tsx +362 -0
- package/src/components/form.tsx +300 -0
- package/src/components/hover-card.tsx +116 -0
- package/src/components/input-group.tsx +224 -0
- package/src/components/input-number.tsx +161 -0
- package/src/components/input-otp.tsx +151 -0
- package/src/components/input-password.tsx +74 -0
- package/src/components/input-search.tsx +98 -0
- package/src/components/input.tsx +52 -0
- package/src/components/item.tsx +280 -0
- package/src/components/kbd.tsx +59 -0
- package/src/components/label.tsx +44 -0
- package/src/components/menubar.tsx +531 -0
- package/src/components/native-select.tsx +96 -0
- package/src/components/navigation-menu.tsx +295 -0
- package/src/components/pagination.tsx +204 -0
- package/src/components/popover.tsx +139 -0
- package/src/components/progress-circle.tsx +203 -0
- package/src/components/progress.tsx +54 -0
- package/src/components/radio-cards.tsx +85 -0
- package/src/components/radio-group.tsx +79 -0
- package/src/components/radio.tsx +61 -0
- package/src/components/resizable.tsx +99 -0
- package/src/components/scroll-area.tsx +115 -0
- package/src/components/select.tsx +319 -0
- package/src/components/separator.tsx +74 -0
- package/src/components/sheet.tsx +278 -0
- package/src/components/sidebar.tsx +1056 -0
- package/src/components/skeleton.tsx +37 -0
- package/src/components/slider.tsx +95 -0
- package/src/components/sonner.tsx +47 -0
- package/src/components/spinner.tsx +75 -0
- package/src/components/switch.tsx +66 -0
- package/src/components/table.tsx +200 -0
- package/src/components/tabs.tsx +128 -0
- package/src/components/textarea.tsx +49 -0
- package/src/components/toggle-group.tsx +141 -0
- package/src/components/toggle.tsx +39 -0
- package/src/components/tooltip.tsx +141 -0
- package/src/css/amber.css +59 -22
- package/src/css/blue.css +59 -22
- package/src/css/cyan.css +59 -22
- package/src/css/emerald.css +59 -22
- package/src/css/fuchsia.css +59 -22
- package/src/css/gray.css +59 -22
- package/src/css/green.css +59 -22
- package/src/css/indigo.css +59 -22
- package/src/css/lime.css +59 -22
- package/src/css/neutral.css +59 -22
- package/src/css/orange.css +59 -22
- package/src/css/pink.css +59 -22
- package/src/css/preset.css +32 -13
- package/src/css/purple.css +59 -22
- package/src/css/red.css +59 -22
- package/src/css/rose.css +59 -22
- package/src/css/sky.css +59 -22
- package/src/css/slate.css +59 -22
- package/src/css/stone.css +59 -22
- package/src/css/teal.css +59 -22
- package/src/css/violet.css +59 -22
- package/src/css/yellow.css +59 -22
- package/src/css/zinc.css +59 -22
- package/src/hooks/use-animated-value.ts +97 -0
- package/src/hooks/use-copy-to-clipboard.ts +63 -0
- package/src/hooks/use-is-mobile.ts +27 -0
- package/src/hooks/use-media-query.ts +71 -0
- package/src/hooks/use-mutation-observer.ts +54 -0
- package/src/hooks/use-pagination.ts +166 -0
- package/src/index.ts +720 -0
- package/src/lib/utils.ts +5 -0
- package/src/primitives/checkbox-group.tsx +360 -0
- package/src/primitives/input-number.tsx +1013 -0
- package/src/primitives/input.tsx +243 -0
- package/src/primitives/progress-circle.tsx +537 -0
- package/src/variants/alert.ts +45 -0
- package/src/variants/badge.ts +66 -0
- package/src/variants/button-group.ts +49 -0
- package/src/variants/button.ts +93 -0
- package/src/variants/empty.ts +43 -0
- package/src/variants/field.ts +50 -0
- package/src/variants/input-group.ts +132 -0
- package/src/variants/item.ts +90 -0
- package/src/variants/navigation-menu.ts +32 -0
- package/src/variants/progress-circle.ts +47 -0
- package/src/variants/scroll-area.ts +79 -0
- package/src/variants/separator.ts +41 -0
- package/src/variants/sheet.ts +70 -0
- package/src/variants/sidebar.ts +61 -0
- package/src/variants/toggle.ts +59 -0
- package/dist/node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/clsx.d.mts +0 -6
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ComponentProps, JSX } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "#/lib/utils";
|
|
4
|
+
|
|
5
|
+
/* -----------------------------------------------------------------------------
|
|
6
|
+
* Component: Skeleton
|
|
7
|
+
* -------------------------------------------------------------------------- */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @since 0.3.16-canary.0
|
|
11
|
+
*/
|
|
12
|
+
type SkeletonProps = ComponentProps<"div">;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @since 0.3.16-canary.0
|
|
16
|
+
*/
|
|
17
|
+
function Skeleton({ className, ...props }: SkeletonProps): JSX.Element {
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
className={cn(
|
|
21
|
+
"rounded-lg",
|
|
22
|
+
"bg-gradient-to-r from-muted via-white/15 to-muted bg-[length:400%_100%]",
|
|
23
|
+
"animate-shimmer motion-reduce:animate-none",
|
|
24
|
+
className,
|
|
25
|
+
)}
|
|
26
|
+
data-slot="skeleton"
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* -----------------------------------------------------------------------------
|
|
33
|
+
* Exports
|
|
34
|
+
* -------------------------------------------------------------------------- */
|
|
35
|
+
|
|
36
|
+
export { Skeleton };
|
|
37
|
+
export type { SkeletonProps };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ComponentProps, JSX } from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "#/lib/utils";
|
|
6
|
+
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
7
|
+
import { useMemo } from "react";
|
|
8
|
+
|
|
9
|
+
/* -----------------------------------------------------------------------------
|
|
10
|
+
* Component: Slider
|
|
11
|
+
* -------------------------------------------------------------------------- */
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @since 0.3.16-canary.0
|
|
15
|
+
*/
|
|
16
|
+
type SliderProps = ComponentProps<typeof SliderPrimitive.Root>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @since 0.3.16-canary.0
|
|
20
|
+
*/
|
|
21
|
+
function Slider({
|
|
22
|
+
className,
|
|
23
|
+
defaultValue,
|
|
24
|
+
max = 100,
|
|
25
|
+
min = 0,
|
|
26
|
+
value,
|
|
27
|
+
...props
|
|
28
|
+
}: SliderProps): JSX.Element {
|
|
29
|
+
const _values = useMemo(() => {
|
|
30
|
+
if (Array.isArray(value)) {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return Array.isArray(defaultValue) ? defaultValue : [min, max];
|
|
35
|
+
}, [value, defaultValue, min, max]);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<SliderPrimitive.Root
|
|
39
|
+
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",
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
46
|
+
data-slot="slider"
|
|
47
|
+
defaultValue={defaultValue}
|
|
48
|
+
max={max}
|
|
49
|
+
min={min}
|
|
50
|
+
value={value}
|
|
51
|
+
{...props}
|
|
52
|
+
>
|
|
53
|
+
<SliderPrimitive.Track
|
|
54
|
+
className={cn(
|
|
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
|
+
)}
|
|
62
|
+
data-slot="slider-track"
|
|
63
|
+
>
|
|
64
|
+
<SliderPrimitive.Range
|
|
65
|
+
className={cn("absolute", "bg-primary", "data-horizontal:h-full", "data-vertical:w-full")}
|
|
66
|
+
data-slot="slider-range"
|
|
67
|
+
/>
|
|
68
|
+
</SliderPrimitive.Track>
|
|
69
|
+
{Array.from({ length: _values.length }, (_, index) => (
|
|
70
|
+
<SliderPrimitive.Thumb
|
|
71
|
+
key={index}
|
|
72
|
+
aria-label="Volume"
|
|
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
|
+
)}
|
|
83
|
+
data-slot="slider-thumb"
|
|
84
|
+
/>
|
|
85
|
+
))}
|
|
86
|
+
</SliderPrimitive.Root>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* -----------------------------------------------------------------------------
|
|
91
|
+
* Exports
|
|
92
|
+
* -------------------------------------------------------------------------- */
|
|
93
|
+
|
|
94
|
+
export { Slider };
|
|
95
|
+
export type { SliderProps };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "#/lib/utils";
|
|
4
|
+
import type { CSSProperties, JSX } from "react";
|
|
5
|
+
import type { ToasterProps as SonnerToasterProps } from "sonner";
|
|
6
|
+
|
|
7
|
+
import { useTheme } from "next-themes";
|
|
8
|
+
import { Toaster as Sonner } from "sonner";
|
|
9
|
+
|
|
10
|
+
/* -----------------------------------------------------------------------------
|
|
11
|
+
* Component: Sonner
|
|
12
|
+
* -------------------------------------------------------------------------- */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @since 0.3.16-canary.0
|
|
16
|
+
*/
|
|
17
|
+
type ToasterProps = SonnerToasterProps;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @since 0.3.16-canary.0
|
|
21
|
+
*/
|
|
22
|
+
function Toaster({ ...props }: ToasterProps): JSX.Element {
|
|
23
|
+
const { theme = "system" } = useTheme();
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Sonner
|
|
27
|
+
className={cn("group", "toaster")}
|
|
28
|
+
style={
|
|
29
|
+
{
|
|
30
|
+
"--normal-bg": "var(--popover)",
|
|
31
|
+
"--normal-border": "var(--border)",
|
|
32
|
+
"--normal-text": "var(--popover-foreground)",
|
|
33
|
+
} as CSSProperties
|
|
34
|
+
}
|
|
35
|
+
theme={theme as ToasterProps["theme"]}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* -----------------------------------------------------------------------------
|
|
42
|
+
* Exports
|
|
43
|
+
* -------------------------------------------------------------------------- */
|
|
44
|
+
|
|
45
|
+
export { toast, useSonner } from "sonner";
|
|
46
|
+
export { Toaster };
|
|
47
|
+
export type { ToasterProps };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ComponentProps, CSSProperties, ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "#/lib/utils";
|
|
6
|
+
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
|
|
7
|
+
|
|
8
|
+
/* -----------------------------------------------------------------------------
|
|
9
|
+
* Component: Spinner
|
|
10
|
+
* -------------------------------------------------------------------------- */
|
|
11
|
+
|
|
12
|
+
const SPINNER_COUNT = 8;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @since 0.3.16-canary.0
|
|
16
|
+
*/
|
|
17
|
+
interface SpinnerProps extends ComponentProps<"span"> {
|
|
18
|
+
loading?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @since 0.3.16-canary.0
|
|
23
|
+
*/
|
|
24
|
+
function Spinner({ children, className, loading = true, ...props }: SpinnerProps): ReactNode {
|
|
25
|
+
if (!loading) {
|
|
26
|
+
return children;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const spinner = (
|
|
30
|
+
<span
|
|
31
|
+
className={cn("relative flex size-4 items-center justify-center", "opacity-60", className)}
|
|
32
|
+
{...props}
|
|
33
|
+
>
|
|
34
|
+
{Array.from({ length: SPINNER_COUNT }, (_, index) => (
|
|
35
|
+
<span
|
|
36
|
+
key={index}
|
|
37
|
+
className={cn(
|
|
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
|
+
)}
|
|
42
|
+
style={
|
|
43
|
+
{
|
|
44
|
+
"--spinner-delay": `-${((SPINNER_COUNT - index) * 100).toString()}ms`,
|
|
45
|
+
"--spinner-duration": `${(SPINNER_COUNT * 100).toString()}ms`,
|
|
46
|
+
"--spinner-rotate": `${((360 / SPINNER_COUNT) * index).toString()}deg`,
|
|
47
|
+
width: `${(100 / SPINNER_COUNT).toString()}%`,
|
|
48
|
+
} as CSSProperties
|
|
49
|
+
}
|
|
50
|
+
/>
|
|
51
|
+
))}
|
|
52
|
+
</span>
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
if (children === undefined) {
|
|
56
|
+
return spinner;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<span className="relative">
|
|
61
|
+
<span aria-hidden className={cn("contents", "invisible")}>
|
|
62
|
+
{children}
|
|
63
|
+
</span>
|
|
64
|
+
<VisuallyHidden>{children}</VisuallyHidden>
|
|
65
|
+
<span className={cn("absolute flex items-center justify-center", "inset-0")}>{spinner}</span>
|
|
66
|
+
</span>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* -----------------------------------------------------------------------------
|
|
71
|
+
* Exports
|
|
72
|
+
* -------------------------------------------------------------------------- */
|
|
73
|
+
|
|
74
|
+
export { Spinner };
|
|
75
|
+
export type { SpinnerProps };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ComponentProps, JSX } from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "#/lib/utils";
|
|
6
|
+
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
7
|
+
|
|
8
|
+
/* -----------------------------------------------------------------------------
|
|
9
|
+
* Component: Switch
|
|
10
|
+
* -------------------------------------------------------------------------- */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @since 0.3.16-canary.0
|
|
14
|
+
*/
|
|
15
|
+
type SwitchProps = ComponentProps<typeof SwitchPrimitives.Root>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @since 0.3.16-canary.0
|
|
19
|
+
*/
|
|
20
|
+
function Switch({ className, ...props }: SwitchProps): JSX.Element {
|
|
21
|
+
return (
|
|
22
|
+
<SwitchPrimitives.Root
|
|
23
|
+
className={cn(
|
|
24
|
+
"peer group/switch inline-flex h-5 w-9 shrink-0 items-center p-0.75",
|
|
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",
|
|
37
|
+
className,
|
|
38
|
+
)}
|
|
39
|
+
data-slot="switch"
|
|
40
|
+
{...props}
|
|
41
|
+
>
|
|
42
|
+
<SwitchPrimitives.Thumb
|
|
43
|
+
className={cn(
|
|
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
|
+
)}
|
|
55
|
+
data-slot="switch-thumb"
|
|
56
|
+
/>
|
|
57
|
+
</SwitchPrimitives.Root>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* -----------------------------------------------------------------------------
|
|
62
|
+
* Exports
|
|
63
|
+
* -------------------------------------------------------------------------- */
|
|
64
|
+
|
|
65
|
+
export { Switch };
|
|
66
|
+
export type { SwitchProps };
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { ComponentProps, JSX } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "#/lib/utils";
|
|
4
|
+
|
|
5
|
+
/* -----------------------------------------------------------------------------
|
|
6
|
+
* Component: Table
|
|
7
|
+
* -------------------------------------------------------------------------- */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @since 0.3.16-canary.0
|
|
11
|
+
*/
|
|
12
|
+
type TableProps = ComponentProps<"table">;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @since 0.3.16-canary.0
|
|
16
|
+
*/
|
|
17
|
+
function Table({ className, ...props }: TableProps): JSX.Element {
|
|
18
|
+
return (
|
|
19
|
+
<div className={cn("relative", "w-full overflow-auto")} data-slot="table-cotainer">
|
|
20
|
+
<table
|
|
21
|
+
className={cn("w-full text-sm", "caption-bottom", className)}
|
|
22
|
+
data-slot="table"
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* -----------------------------------------------------------------------------
|
|
30
|
+
* Component: TableHeader
|
|
31
|
+
* -------------------------------------------------------------------------- */
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @since 0.3.16-canary.0
|
|
35
|
+
*/
|
|
36
|
+
type TableHeaderProps = ComponentProps<"thead">;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @since 0.3.16-canary.0
|
|
40
|
+
*/
|
|
41
|
+
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
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* -----------------------------------------------------------------------------
|
|
52
|
+
* Component: TableBody
|
|
53
|
+
* -------------------------------------------------------------------------- */
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @since 0.3.16-canary.0
|
|
57
|
+
*/
|
|
58
|
+
type TableBodyProps = ComponentProps<"tbody">;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @since 0.3.16-canary.0
|
|
62
|
+
*/
|
|
63
|
+
function TableBody({ className, ...props }: TableBodyProps): JSX.Element {
|
|
64
|
+
return (
|
|
65
|
+
<tbody className={cn("*:last-child:border-0", className)} data-slot="table-body" {...props} />
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* -----------------------------------------------------------------------------
|
|
70
|
+
* Component: TableFooter
|
|
71
|
+
* -------------------------------------------------------------------------- */
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @since 0.3.16-canary.0
|
|
75
|
+
*/
|
|
76
|
+
type TableFooterProps = ComponentProps<"tfoot">;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @since 0.3.16-canary.0
|
|
80
|
+
*/
|
|
81
|
+
function TableFooter({ className, ...props }: TableFooterProps): JSX.Element {
|
|
82
|
+
return (
|
|
83
|
+
<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
|
+
)}
|
|
90
|
+
data-slot="table-footer"
|
|
91
|
+
{...props}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* -----------------------------------------------------------------------------
|
|
97
|
+
* Component: TableRow
|
|
98
|
+
* -------------------------------------------------------------------------- */
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @since 0.3.16-canary.0
|
|
102
|
+
*/
|
|
103
|
+
type TableRowProps = ComponentProps<"tr">;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @since 0.3.16-canary.0
|
|
107
|
+
*/
|
|
108
|
+
function TableRow({ className, ...props }: TableRowProps): JSX.Element {
|
|
109
|
+
return (
|
|
110
|
+
<tr
|
|
111
|
+
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",
|
|
118
|
+
className,
|
|
119
|
+
)}
|
|
120
|
+
data-slot="table-row"
|
|
121
|
+
{...props}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* -----------------------------------------------------------------------------
|
|
127
|
+
* Component: TableHead
|
|
128
|
+
* -------------------------------------------------------------------------- */
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @since 0.3.16-canary.0
|
|
132
|
+
*/
|
|
133
|
+
type TableHeadProps = ComponentProps<"th">;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @since 0.3.16-canary.0
|
|
137
|
+
*/
|
|
138
|
+
function TableHead({ className, ...props }: TableHeadProps): JSX.Element {
|
|
139
|
+
return (
|
|
140
|
+
<th
|
|
141
|
+
className={cn("p-2", "text-left align-middle font-medium", className)}
|
|
142
|
+
data-slot="table-head"
|
|
143
|
+
{...props}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* -----------------------------------------------------------------------------
|
|
149
|
+
* Component: TableCell
|
|
150
|
+
* -------------------------------------------------------------------------- */
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @since 0.3.16-canary.0
|
|
154
|
+
*/
|
|
155
|
+
type TableCellProps = ComponentProps<"td">;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @since 0.3.16-canary.0
|
|
159
|
+
*/
|
|
160
|
+
function TableCell({ className, ...props }: TableCellProps): JSX.Element {
|
|
161
|
+
return <td className={cn("p-2", "align-middle", className)} data-slot="table-cell" {...props} />;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* -----------------------------------------------------------------------------
|
|
165
|
+
* Component: TableCaption
|
|
166
|
+
* -------------------------------------------------------------------------- */
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @since 0.3.16-canary.0
|
|
170
|
+
*/
|
|
171
|
+
type TableCaptionProps = ComponentProps<"caption">;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @since 0.3.16-canary.0
|
|
175
|
+
*/
|
|
176
|
+
function TableCaption({ className, ...props }: TableCaptionProps): JSX.Element {
|
|
177
|
+
return (
|
|
178
|
+
<caption
|
|
179
|
+
className={cn("mt-4", "text-sm text-muted-foreground", className)}
|
|
180
|
+
data-slot="table-caption"
|
|
181
|
+
{...props}
|
|
182
|
+
/>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* -----------------------------------------------------------------------------
|
|
187
|
+
* Exports
|
|
188
|
+
* -------------------------------------------------------------------------- */
|
|
189
|
+
|
|
190
|
+
export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow };
|
|
191
|
+
export type {
|
|
192
|
+
TableBodyProps,
|
|
193
|
+
TableCaptionProps,
|
|
194
|
+
TableCellProps,
|
|
195
|
+
TableFooterProps,
|
|
196
|
+
TableHeaderProps,
|
|
197
|
+
TableHeadProps,
|
|
198
|
+
TableProps,
|
|
199
|
+
TableRowProps,
|
|
200
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ComponentProps, JSX } from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "#/lib/utils";
|
|
6
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
7
|
+
|
|
8
|
+
/* -----------------------------------------------------------------------------
|
|
9
|
+
* Component: Tabs
|
|
10
|
+
* -------------------------------------------------------------------------- */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @since 0.3.16-canary.0
|
|
14
|
+
*/
|
|
15
|
+
type TabsProps = ComponentProps<typeof TabsPrimitive.Root>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @since 0.3.16-canary.0
|
|
19
|
+
*/
|
|
20
|
+
function Tabs({ className, ...props }: TabsProps): JSX.Element {
|
|
21
|
+
return (
|
|
22
|
+
<TabsPrimitive.Root
|
|
23
|
+
className={cn("flex flex-col gap-2", className)}
|
|
24
|
+
data-slot="tabs"
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* -----------------------------------------------------------------------------
|
|
31
|
+
* Component: TabsList
|
|
32
|
+
* -------------------------------------------------------------------------- */
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @since 0.3.16-canary.0
|
|
36
|
+
*/
|
|
37
|
+
type TabsListProps = ComponentProps<typeof TabsPrimitive.List>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @since 0.3.16-canary.0
|
|
41
|
+
*/
|
|
42
|
+
function TabsList({ className, ...props }: TabsListProps): JSX.Element {
|
|
43
|
+
return (
|
|
44
|
+
<TabsPrimitive.List
|
|
45
|
+
className={cn(
|
|
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
|
+
)}
|
|
51
|
+
data-slot="tabs-list"
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* -----------------------------------------------------------------------------
|
|
58
|
+
* Component: TabsTrigger
|
|
59
|
+
* -------------------------------------------------------------------------- */
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @since 0.3.16-canary.0
|
|
63
|
+
*/
|
|
64
|
+
type TabsTriggerProps = ComponentProps<typeof TabsPrimitive.Trigger>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @since 0.3.16-canary.0
|
|
68
|
+
*/
|
|
69
|
+
function TabsTrigger({ className, ...props }: TabsTriggerProps): JSX.Element {
|
|
70
|
+
return (
|
|
71
|
+
<TabsPrimitive.Trigger
|
|
72
|
+
className={cn(
|
|
73
|
+
"inline-flex items-center justify-center gap-1.5",
|
|
74
|
+
"px-2 py-1.5",
|
|
75
|
+
"rounded-lg",
|
|
76
|
+
"text-sm font-medium whitespace-nowrap text-muted-foreground",
|
|
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",
|
|
88
|
+
className,
|
|
89
|
+
)}
|
|
90
|
+
data-slot="tabs-trigger"
|
|
91
|
+
{...props}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* -----------------------------------------------------------------------------
|
|
97
|
+
* Component: TabsContent
|
|
98
|
+
* -------------------------------------------------------------------------- */
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @since 0.3.16-canary.0
|
|
102
|
+
*/
|
|
103
|
+
type TabsContentProps = ComponentProps<typeof TabsPrimitive.Content>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @since 0.3.16-canary.0
|
|
107
|
+
*/
|
|
108
|
+
function TabsContent({ className, ...props }: TabsContentProps): JSX.Element {
|
|
109
|
+
return (
|
|
110
|
+
<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
|
+
)}
|
|
117
|
+
data-slot="tabs-content"
|
|
118
|
+
{...props}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* -----------------------------------------------------------------------------
|
|
124
|
+
* Exports
|
|
125
|
+
* -------------------------------------------------------------------------- */
|
|
126
|
+
|
|
127
|
+
export { Tabs, TabsContent, TabsList, TabsTrigger };
|
|
128
|
+
export type { TabsContentProps, TabsListProps, TabsProps, TabsTriggerProps };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ComponentProps, JSX } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "#/lib/utils";
|
|
4
|
+
|
|
5
|
+
/* -----------------------------------------------------------------------------
|
|
6
|
+
* Component: Textarea
|
|
7
|
+
* -------------------------------------------------------------------------- */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @since 0.3.16-canary.0
|
|
11
|
+
*/
|
|
12
|
+
type TextareaProps = ComponentProps<"textarea">;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @since 0.3.16-canary.0
|
|
16
|
+
*/
|
|
17
|
+
function Textarea({ className, ...props }: TextareaProps): JSX.Element {
|
|
18
|
+
return (
|
|
19
|
+
<textarea
|
|
20
|
+
className={cn(
|
|
21
|
+
"flex min-h-16 w-full grow px-3 py-2",
|
|
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",
|
|
36
|
+
className,
|
|
37
|
+
)}
|
|
38
|
+
data-slot="textarea"
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* -----------------------------------------------------------------------------
|
|
45
|
+
* Exports
|
|
46
|
+
* -------------------------------------------------------------------------- */
|
|
47
|
+
|
|
48
|
+
export { Textarea };
|
|
49
|
+
export type { TextareaProps };
|