@c-rex/ui 0.1.19 → 0.1.21
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 +19 -19
- package/package.json +207 -205
- package/src/alert.tsx +58 -58
- package/src/avatar.tsx +47 -47
- package/src/badge.tsx +46 -46
- package/src/breadcrumb.tsx +113 -113
- package/src/button.tsx +69 -69
- package/src/card.tsx +92 -92
- package/src/checkbox.tsx +30 -30
- package/src/collapsible.tsx +31 -31
- package/src/command.tsx +151 -151
- package/src/context-menu.tsx +250 -250
- package/src/dialog.tsx +122 -122
- package/src/drawer.tsx +133 -133
- package/src/dropdown-hover-item.tsx +27 -27
- package/src/dropdown-menu.tsx +273 -273
- package/src/hooks/index.tsx +27 -27
- package/src/input-group.tsx +189 -189
- package/src/input.tsx +42 -42
- package/src/label.tsx +22 -22
- package/src/navigation-menu.tsx +169 -168
- package/src/pagination.tsx +124 -124
- package/src/popover.tsx +31 -31
- package/src/radio-group.tsx +43 -43
- package/src/select.tsx +157 -157
- package/src/separator.tsx +29 -29
- package/src/sheet.tsx +140 -140
- package/src/sidebar.tsx +833 -835
- package/src/skeleton.tsx +15 -15
- package/src/sonner.tsx +10 -10
- package/src/switch.tsx +29 -29
- package/src/table.tsx +120 -120
- package/src/tabs.tsx +64 -64
- package/src/textarea.tsx +18 -18
- package/src/toggle-group.tsx +71 -71
- package/src/toggle.tsx +47 -47
- package/src/tooltip.tsx +30 -30
package/src/avatar.tsx
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
import * as AvatarPrimitive from "@radix-ui/react-avatar"
|
|
3
|
-
|
|
4
|
-
import { cn } from "@c-rex/utils"
|
|
5
|
-
|
|
6
|
-
function Avatar({
|
|
7
|
-
className,
|
|
8
|
-
...props
|
|
9
|
-
}: React.ComponentProps<typeof AvatarPrimitive.Root>) {
|
|
10
|
-
return (
|
|
11
|
-
<AvatarPrimitive.Root
|
|
12
|
-
data-slot="avatar"
|
|
13
|
-
className={cn(
|
|
14
|
-
"relative flex size-8 shrink-0 overflow-hidden rounded-full",
|
|
15
|
-
className
|
|
16
|
-
)}
|
|
17
|
-
{...props}
|
|
18
|
-
/>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function AvatarImage({ ...props }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
|
|
23
|
-
return (
|
|
24
|
-
<AvatarPrimitive.Image
|
|
25
|
-
data-slot="avatar-image"
|
|
26
|
-
{...props}
|
|
27
|
-
/>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function AvatarFallback({
|
|
32
|
-
className,
|
|
33
|
-
...props
|
|
34
|
-
}: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
|
|
35
|
-
return (
|
|
36
|
-
<AvatarPrimitive.Fallback
|
|
37
|
-
data-slot="avatar-fallback"
|
|
38
|
-
className={cn(
|
|
39
|
-
"bg-muted flex size-full items-center justify-center rounded-full",
|
|
40
|
-
className
|
|
41
|
-
)}
|
|
42
|
-
{...props}
|
|
43
|
-
/>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export { Avatar, AvatarImage, AvatarFallback }
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as AvatarPrimitive from "@radix-ui/react-avatar"
|
|
3
|
+
|
|
4
|
+
import { cn } from "@c-rex/utils"
|
|
5
|
+
|
|
6
|
+
function Avatar({
|
|
7
|
+
className,
|
|
8
|
+
...props
|
|
9
|
+
}: React.ComponentProps<typeof AvatarPrimitive.Root>) {
|
|
10
|
+
return (
|
|
11
|
+
<AvatarPrimitive.Root
|
|
12
|
+
data-slot="avatar"
|
|
13
|
+
className={cn(
|
|
14
|
+
"relative flex size-8 shrink-0 overflow-hidden rounded-full",
|
|
15
|
+
className
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function AvatarImage({ ...props }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
|
|
23
|
+
return (
|
|
24
|
+
<AvatarPrimitive.Image
|
|
25
|
+
data-slot="avatar-image"
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function AvatarFallback({
|
|
32
|
+
className,
|
|
33
|
+
...props
|
|
34
|
+
}: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
|
|
35
|
+
return (
|
|
36
|
+
<AvatarPrimitive.Fallback
|
|
37
|
+
data-slot="avatar-fallback"
|
|
38
|
+
className={cn(
|
|
39
|
+
"bg-muted flex size-full items-center justify-center rounded-full",
|
|
40
|
+
className
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { Avatar, AvatarImage, AvatarFallback }
|
package/src/badge.tsx
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
import { Slot } from "@radix-ui/react-slot"
|
|
3
|
-
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
|
-
|
|
5
|
-
import { cn } from "@c-rex/utils"
|
|
6
|
-
|
|
7
|
-
const badgeVariants = cva(
|
|
8
|
-
"inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
|
|
9
|
-
{
|
|
10
|
-
variants: {
|
|
11
|
-
variant: {
|
|
12
|
-
default:
|
|
13
|
-
"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
14
|
-
secondary:
|
|
15
|
-
"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
|
16
|
-
destructive:
|
|
17
|
-
"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
18
|
-
outline:
|
|
19
|
-
"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
defaultVariants: {
|
|
23
|
-
variant: "default",
|
|
24
|
-
},
|
|
25
|
-
}
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
function Badge({
|
|
29
|
-
className,
|
|
30
|
-
variant,
|
|
31
|
-
asChild = false,
|
|
32
|
-
...props
|
|
33
|
-
}: React.ComponentProps<"span"> &
|
|
34
|
-
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
|
35
|
-
const Comp = asChild ? Slot : "span"
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Comp
|
|
39
|
-
data-slot="badge"
|
|
40
|
-
className={cn(badgeVariants({ variant }), className)}
|
|
41
|
-
{...props}
|
|
42
|
-
/>
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export { Badge, badgeVariants }
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot"
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@c-rex/utils"
|
|
6
|
+
|
|
7
|
+
const badgeVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default:
|
|
13
|
+
"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
14
|
+
secondary:
|
|
15
|
+
"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
|
16
|
+
destructive:
|
|
17
|
+
"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
18
|
+
outline:
|
|
19
|
+
"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "default",
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
function Badge({
|
|
29
|
+
className,
|
|
30
|
+
variant,
|
|
31
|
+
asChild = false,
|
|
32
|
+
...props
|
|
33
|
+
}: React.ComponentProps<"span"> &
|
|
34
|
+
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
|
35
|
+
const Comp = asChild ? Slot : "span"
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Comp
|
|
39
|
+
data-slot="badge"
|
|
40
|
+
className={cn(badgeVariants({ variant }), className)}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Badge, badgeVariants }
|
package/src/breadcrumb.tsx
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
-
import { ChevronRight, MoreHorizontal } from "lucide-react";
|
|
4
|
-
|
|
5
|
-
import { cn } from "@c-rex/utils";
|
|
6
|
-
|
|
7
|
-
const Breadcrumb = React.forwardRef<
|
|
8
|
-
HTMLElement,
|
|
9
|
-
React.ComponentPropsWithoutRef<"nav"> & {
|
|
10
|
-
separator?: React.ReactNode;
|
|
11
|
-
}
|
|
12
|
-
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />);
|
|
13
|
-
Breadcrumb.displayName = "Breadcrumb";
|
|
14
|
-
|
|
15
|
-
const BreadcrumbList = React.forwardRef<
|
|
16
|
-
HTMLOListElement,
|
|
17
|
-
React.ComponentPropsWithoutRef<"ol">
|
|
18
|
-
>(({ className, ...props }, ref) => (
|
|
19
|
-
<ol
|
|
20
|
-
ref={ref}
|
|
21
|
-
className={cn(
|
|
22
|
-
"flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",
|
|
23
|
-
className,
|
|
24
|
-
)}
|
|
25
|
-
{...props}
|
|
26
|
-
/>
|
|
27
|
-
));
|
|
28
|
-
BreadcrumbList.displayName = "BreadcrumbList";
|
|
29
|
-
|
|
30
|
-
const BreadcrumbItem = React.forwardRef<
|
|
31
|
-
HTMLLIElement,
|
|
32
|
-
React.ComponentPropsWithoutRef<"li">
|
|
33
|
-
>(({ className, ...props }, ref) => (
|
|
34
|
-
<li
|
|
35
|
-
ref={ref}
|
|
36
|
-
className={cn("inline-flex items-center gap-1.5", className)}
|
|
37
|
-
{...props}
|
|
38
|
-
/>
|
|
39
|
-
));
|
|
40
|
-
BreadcrumbItem.displayName = "BreadcrumbItem";
|
|
41
|
-
|
|
42
|
-
const BreadcrumbLink = React.forwardRef<
|
|
43
|
-
HTMLAnchorElement,
|
|
44
|
-
React.ComponentPropsWithoutRef<"a"> & {
|
|
45
|
-
asChild?: boolean;
|
|
46
|
-
}
|
|
47
|
-
>(({ asChild, className, ...props }, ref) => {
|
|
48
|
-
const Comp = asChild ? Slot : "a";
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<Comp
|
|
52
|
-
ref={ref}
|
|
53
|
-
className={cn("transition-colors hover:text-foreground", className)}
|
|
54
|
-
{...props}
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
});
|
|
58
|
-
BreadcrumbLink.displayName = "BreadcrumbLink";
|
|
59
|
-
|
|
60
|
-
const BreadcrumbPage = React.forwardRef<
|
|
61
|
-
HTMLSpanElement,
|
|
62
|
-
React.ComponentPropsWithoutRef<"span">
|
|
63
|
-
>(({ className, ...props }, ref) => (
|
|
64
|
-
<span
|
|
65
|
-
ref={ref}
|
|
66
|
-
role="link"
|
|
67
|
-
aria-disabled="true"
|
|
68
|
-
aria-current="page"
|
|
69
|
-
className={cn("font-normal text-foreground", className)}
|
|
70
|
-
{...props}
|
|
71
|
-
/>
|
|
72
|
-
));
|
|
73
|
-
BreadcrumbPage.displayName = "BreadcrumbPage";
|
|
74
|
-
|
|
75
|
-
const BreadcrumbSeparator = ({
|
|
76
|
-
children,
|
|
77
|
-
className,
|
|
78
|
-
...props
|
|
79
|
-
}: React.ComponentProps<"li">) => (
|
|
80
|
-
<li
|
|
81
|
-
role="presentation"
|
|
82
|
-
className={cn("[&>svg]:w-3.5 [&>svg]:h-3.5", className)}
|
|
83
|
-
{...props}
|
|
84
|
-
>
|
|
85
|
-
{children ?? <ChevronRight />}
|
|
86
|
-
</li>
|
|
87
|
-
);
|
|
88
|
-
BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
|
|
89
|
-
|
|
90
|
-
const BreadcrumbEllipsis = ({
|
|
91
|
-
className,
|
|
92
|
-
...props
|
|
93
|
-
}: React.ComponentProps<"span">) => (
|
|
94
|
-
<span
|
|
95
|
-
role="presentation"
|
|
96
|
-
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
|
97
|
-
{...props}
|
|
98
|
-
>
|
|
99
|
-
<MoreHorizontal className="h-4 w-4" />
|
|
100
|
-
<span className="sr-only">More</span>
|
|
101
|
-
</span>
|
|
102
|
-
);
|
|
103
|
-
BreadcrumbEllipsis.displayName = "BreadcrumbElipssis";
|
|
104
|
-
|
|
105
|
-
export {
|
|
106
|
-
Breadcrumb,
|
|
107
|
-
BreadcrumbList,
|
|
108
|
-
BreadcrumbItem,
|
|
109
|
-
BreadcrumbLink,
|
|
110
|
-
BreadcrumbPage,
|
|
111
|
-
BreadcrumbSeparator,
|
|
112
|
-
BreadcrumbEllipsis,
|
|
113
|
-
};
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { ChevronRight, MoreHorizontal } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@c-rex/utils";
|
|
6
|
+
|
|
7
|
+
const Breadcrumb = React.forwardRef<
|
|
8
|
+
HTMLElement,
|
|
9
|
+
React.ComponentPropsWithoutRef<"nav"> & {
|
|
10
|
+
separator?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />);
|
|
13
|
+
Breadcrumb.displayName = "Breadcrumb";
|
|
14
|
+
|
|
15
|
+
const BreadcrumbList = React.forwardRef<
|
|
16
|
+
HTMLOListElement,
|
|
17
|
+
React.ComponentPropsWithoutRef<"ol">
|
|
18
|
+
>(({ className, ...props }, ref) => (
|
|
19
|
+
<ol
|
|
20
|
+
ref={ref}
|
|
21
|
+
className={cn(
|
|
22
|
+
"flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",
|
|
23
|
+
className,
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
));
|
|
28
|
+
BreadcrumbList.displayName = "BreadcrumbList";
|
|
29
|
+
|
|
30
|
+
const BreadcrumbItem = React.forwardRef<
|
|
31
|
+
HTMLLIElement,
|
|
32
|
+
React.ComponentPropsWithoutRef<"li">
|
|
33
|
+
>(({ className, ...props }, ref) => (
|
|
34
|
+
<li
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn("inline-flex items-center gap-1.5", className)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
));
|
|
40
|
+
BreadcrumbItem.displayName = "BreadcrumbItem";
|
|
41
|
+
|
|
42
|
+
const BreadcrumbLink = React.forwardRef<
|
|
43
|
+
HTMLAnchorElement,
|
|
44
|
+
React.ComponentPropsWithoutRef<"a"> & {
|
|
45
|
+
asChild?: boolean;
|
|
46
|
+
}
|
|
47
|
+
>(({ asChild, className, ...props }, ref) => {
|
|
48
|
+
const Comp = asChild ? Slot : "a";
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Comp
|
|
52
|
+
ref={ref}
|
|
53
|
+
className={cn("transition-colors hover:text-foreground", className)}
|
|
54
|
+
{...props}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
BreadcrumbLink.displayName = "BreadcrumbLink";
|
|
59
|
+
|
|
60
|
+
const BreadcrumbPage = React.forwardRef<
|
|
61
|
+
HTMLSpanElement,
|
|
62
|
+
React.ComponentPropsWithoutRef<"span">
|
|
63
|
+
>(({ className, ...props }, ref) => (
|
|
64
|
+
<span
|
|
65
|
+
ref={ref}
|
|
66
|
+
role="link"
|
|
67
|
+
aria-disabled="true"
|
|
68
|
+
aria-current="page"
|
|
69
|
+
className={cn("font-normal text-foreground", className)}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
));
|
|
73
|
+
BreadcrumbPage.displayName = "BreadcrumbPage";
|
|
74
|
+
|
|
75
|
+
const BreadcrumbSeparator = ({
|
|
76
|
+
children,
|
|
77
|
+
className,
|
|
78
|
+
...props
|
|
79
|
+
}: React.ComponentProps<"li">) => (
|
|
80
|
+
<li
|
|
81
|
+
role="presentation"
|
|
82
|
+
className={cn("[&>svg]:w-3.5 [&>svg]:h-3.5", className)}
|
|
83
|
+
{...props}
|
|
84
|
+
>
|
|
85
|
+
{children ?? <ChevronRight />}
|
|
86
|
+
</li>
|
|
87
|
+
);
|
|
88
|
+
BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
|
|
89
|
+
|
|
90
|
+
const BreadcrumbEllipsis = ({
|
|
91
|
+
className,
|
|
92
|
+
...props
|
|
93
|
+
}: React.ComponentProps<"span">) => (
|
|
94
|
+
<span
|
|
95
|
+
role="presentation"
|
|
96
|
+
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
|
97
|
+
{...props}
|
|
98
|
+
>
|
|
99
|
+
<MoreHorizontal className="h-4 w-4" />
|
|
100
|
+
<span className="sr-only">More</span>
|
|
101
|
+
</span>
|
|
102
|
+
);
|
|
103
|
+
BreadcrumbEllipsis.displayName = "BreadcrumbElipssis";
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
Breadcrumb,
|
|
107
|
+
BreadcrumbList,
|
|
108
|
+
BreadcrumbItem,
|
|
109
|
+
BreadcrumbLink,
|
|
110
|
+
BreadcrumbPage,
|
|
111
|
+
BreadcrumbSeparator,
|
|
112
|
+
BreadcrumbEllipsis,
|
|
113
|
+
};
|
package/src/button.tsx
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
-
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
|
-
|
|
7
|
-
import { cn } from "@c-rex/utils";
|
|
8
|
-
|
|
9
|
-
const buttonVariants = cva(
|
|
10
|
-
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
11
|
-
{
|
|
12
|
-
variants: {
|
|
13
|
-
variant: {
|
|
14
|
-
default:
|
|
15
|
-
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
16
|
-
destructive:
|
|
17
|
-
"border border-destructive text-destructive shadow-sm hover:bg-destructive/90 hover:text-destructive-foreground",
|
|
18
|
-
outline:
|
|
19
|
-
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
20
|
-
secondary:
|
|
21
|
-
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
22
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
23
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
24
|
-
},
|
|
25
|
-
size: {
|
|
26
|
-
default: "h-9 px-4 py-2",
|
|
27
|
-
sm: "h-8 rounded-md px-3 text-xs",
|
|
28
|
-
xs: "h-5 w-5 rounded text-xs",
|
|
29
|
-
lg: "h-10 rounded-md px-8",
|
|
30
|
-
icon: "h-9 w-9",
|
|
31
|
-
},
|
|
32
|
-
rounded: {
|
|
33
|
-
default: "rounded-md",
|
|
34
|
-
sm: "rounded-sm",
|
|
35
|
-
lg: "rounded-lg",
|
|
36
|
-
xl: "rounded-xl",
|
|
37
|
-
"2xl": "rounded-2xl",
|
|
38
|
-
full: "rounded-full",
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
defaultVariants: {
|
|
42
|
-
variant: "default",
|
|
43
|
-
size: "default",
|
|
44
|
-
rounded: "default",
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
export interface ButtonProps
|
|
50
|
-
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
51
|
-
VariantProps<typeof buttonVariants> {
|
|
52
|
-
asChild?: boolean;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
56
|
-
({ className, variant, size, rounded, asChild = false, ...props }, ref) => {
|
|
57
|
-
const Comp = asChild ? Slot : "button";
|
|
58
|
-
return (
|
|
59
|
-
<Comp
|
|
60
|
-
className={cn(buttonVariants({ variant, size, rounded, className }))}
|
|
61
|
-
ref={ref}
|
|
62
|
-
{...props}
|
|
63
|
-
/>
|
|
64
|
-
);
|
|
65
|
-
},
|
|
66
|
-
);
|
|
67
|
-
Button.displayName = "Button";
|
|
68
|
-
|
|
69
|
-
export { Button, buttonVariants };
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@c-rex/utils";
|
|
8
|
+
|
|
9
|
+
const buttonVariants = cva(
|
|
10
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
11
|
+
{
|
|
12
|
+
variants: {
|
|
13
|
+
variant: {
|
|
14
|
+
default:
|
|
15
|
+
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
16
|
+
destructive:
|
|
17
|
+
"border border-destructive text-destructive shadow-sm hover:bg-destructive/90 hover:text-destructive-foreground",
|
|
18
|
+
outline:
|
|
19
|
+
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
20
|
+
secondary:
|
|
21
|
+
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
22
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
23
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
24
|
+
},
|
|
25
|
+
size: {
|
|
26
|
+
default: "h-9 px-4 py-2",
|
|
27
|
+
sm: "h-8 rounded-md px-3 text-xs",
|
|
28
|
+
xs: "h-5 w-5 rounded text-xs",
|
|
29
|
+
lg: "h-10 rounded-md px-8",
|
|
30
|
+
icon: "h-9 w-9",
|
|
31
|
+
},
|
|
32
|
+
rounded: {
|
|
33
|
+
default: "rounded-md",
|
|
34
|
+
sm: "rounded-sm",
|
|
35
|
+
lg: "rounded-lg",
|
|
36
|
+
xl: "rounded-xl",
|
|
37
|
+
"2xl": "rounded-2xl",
|
|
38
|
+
full: "rounded-full",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
variant: "default",
|
|
43
|
+
size: "default",
|
|
44
|
+
rounded: "default",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export interface ButtonProps
|
|
50
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
51
|
+
VariantProps<typeof buttonVariants> {
|
|
52
|
+
asChild?: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
56
|
+
({ className, variant, size, rounded, asChild = false, ...props }, ref) => {
|
|
57
|
+
const Comp = asChild ? Slot : "button";
|
|
58
|
+
return (
|
|
59
|
+
<Comp
|
|
60
|
+
className={cn(buttonVariants({ variant, size, rounded, className }))}
|
|
61
|
+
ref={ref}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
Button.displayName = "Button";
|
|
68
|
+
|
|
69
|
+
export { Button, buttonVariants };
|