cooterlabs 1.0.2 → 2.1.0
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 +228 -45
- package/bin/index.js +376 -22
- package/package.json +12 -4
- package/templates/_lib/utils.ts +28 -0
- package/templates/action-sheet/action-sheet.tsx +108 -0
- package/templates/alert/alert.tsx +146 -0
- package/templates/avatar/avatar.tsx +20 -8
- package/templates/badge/badge.tsx +114 -25
- package/templates/breadcrumb/breadcrumb.tsx +108 -0
- package/templates/button/button.tsx +39 -6
- package/templates/button-group/button-group.tsx +88 -0
- package/templates/card/card.tsx +31 -24
- package/templates/checkbox/checkbox.tsx +5 -9
- package/templates/context-menu/context-menu.tsx +172 -0
- package/templates/dialog/dialog.tsx +122 -0
- package/templates/dropdown/dropdown.tsx +175 -0
- package/templates/input/input.tsx +80 -14
- package/templates/label/label.tsx +2 -7
- package/templates/list/list.tsx +91 -0
- package/templates/loader/loader.tsx +33 -0
- package/templates/navbar-bottom/navbar-bottom.tsx +71 -0
- package/templates/navbar-top/navbar-top.tsx +79 -0
- package/templates/page-control/page-control.tsx +50 -0
- package/templates/pagination/pagination.tsx +104 -0
- package/templates/progress/progress.tsx +64 -0
- package/templates/radio/radio.tsx +36 -0
- package/templates/select/select.tsx +113 -0
- package/templates/stepper/stepper.tsx +88 -0
- package/templates/tabs/tabs.tsx +52 -0
- package/templates/textarea/textarea.tsx +2 -7
- package/templates/toggle/toggle.tsx +22 -0
- package/templates/tooltip/tooltip.tsx +32 -0
package/templates/card/card.tsx
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
import * as React from "react"
|
|
2
|
-
|
|
3
|
-
import { cn } from "./button" // Assuming they have cn utility somewhere accessible, or we'll rewrite it to inline
|
|
4
|
-
|
|
5
|
-
export function cnFallback(...classes: (string | undefined | null | false)[]) {
|
|
6
|
-
return classes.filter(Boolean).join(" ")
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// In a real scenario you'd import 'cn' from a library or a utils file.
|
|
10
|
-
// We'll provide an inline cn for fallback or rely on the user having ones installed:
|
|
11
|
-
import { clsx, type ClassValue } from "clsx"
|
|
12
|
-
import { twMerge } from "tailwind-merge"
|
|
13
|
-
|
|
14
|
-
function localCn(...inputs: ClassValue[]) {
|
|
15
|
-
return twMerge(clsx(inputs))
|
|
16
|
-
}
|
|
2
|
+
import { cn } from "../../lib/utils"
|
|
17
3
|
|
|
18
4
|
const Card = React.forwardRef<
|
|
19
5
|
HTMLDivElement,
|
|
@@ -21,8 +7,8 @@ const Card = React.forwardRef<
|
|
|
21
7
|
>(({ className, ...props }, ref) => (
|
|
22
8
|
<div
|
|
23
9
|
ref={ref}
|
|
24
|
-
className={
|
|
25
|
-
"rounded-
|
|
10
|
+
className={cn(
|
|
11
|
+
"overflow-hidden rounded-md border border-grey-100 bg-card text-foreground shadow-200",
|
|
26
12
|
className
|
|
27
13
|
)}
|
|
28
14
|
{...props}
|
|
@@ -30,25 +16,38 @@ const Card = React.forwardRef<
|
|
|
30
16
|
))
|
|
31
17
|
Card.displayName = "Card"
|
|
32
18
|
|
|
19
|
+
const CardImage = React.forwardRef<
|
|
20
|
+
HTMLImageElement,
|
|
21
|
+
React.ImgHTMLAttributes<HTMLImageElement>
|
|
22
|
+
>(({ className, alt = "", ...props }, ref) => (
|
|
23
|
+
<img
|
|
24
|
+
ref={ref}
|
|
25
|
+
alt={alt}
|
|
26
|
+
className={cn("h-50 w-full object-cover", className)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
))
|
|
30
|
+
CardImage.displayName = "CardImage"
|
|
31
|
+
|
|
33
32
|
const CardHeader = React.forwardRef<
|
|
34
33
|
HTMLDivElement,
|
|
35
34
|
React.HTMLAttributes<HTMLDivElement>
|
|
36
35
|
>(({ className, ...props }, ref) => (
|
|
37
36
|
<div
|
|
38
37
|
ref={ref}
|
|
39
|
-
className={
|
|
38
|
+
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
|
40
39
|
{...props}
|
|
41
40
|
/>
|
|
42
41
|
))
|
|
43
42
|
CardHeader.displayName = "CardHeader"
|
|
44
43
|
|
|
45
44
|
const CardTitle = React.forwardRef<
|
|
46
|
-
|
|
45
|
+
HTMLHeadingElement,
|
|
47
46
|
React.HTMLAttributes<HTMLHeadingElement>
|
|
48
47
|
>(({ className, ...props }, ref) => (
|
|
49
48
|
<h3
|
|
50
49
|
ref={ref}
|
|
51
|
-
className={
|
|
50
|
+
className={cn("text-s2 text-foreground", className)}
|
|
52
51
|
{...props}
|
|
53
52
|
/>
|
|
54
53
|
))
|
|
@@ -60,7 +59,7 @@ const CardDescription = React.forwardRef<
|
|
|
60
59
|
>(({ className, ...props }, ref) => (
|
|
61
60
|
<p
|
|
62
61
|
ref={ref}
|
|
63
|
-
className={
|
|
62
|
+
className={cn("text-b3 text-muted-foreground", className)}
|
|
64
63
|
{...props}
|
|
65
64
|
/>
|
|
66
65
|
))
|
|
@@ -70,7 +69,7 @@ const CardContent = React.forwardRef<
|
|
|
70
69
|
HTMLDivElement,
|
|
71
70
|
React.HTMLAttributes<HTMLDivElement>
|
|
72
71
|
>(({ className, ...props }, ref) => (
|
|
73
|
-
<div ref={ref} className={
|
|
72
|
+
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
|
74
73
|
))
|
|
75
74
|
CardContent.displayName = "CardContent"
|
|
76
75
|
|
|
@@ -80,10 +79,18 @@ const CardFooter = React.forwardRef<
|
|
|
80
79
|
>(({ className, ...props }, ref) => (
|
|
81
80
|
<div
|
|
82
81
|
ref={ref}
|
|
83
|
-
className={
|
|
82
|
+
className={cn("flex items-center p-6 pt-0", className)}
|
|
84
83
|
{...props}
|
|
85
84
|
/>
|
|
86
85
|
))
|
|
87
86
|
CardFooter.displayName = "CardFooter"
|
|
88
87
|
|
|
89
|
-
export {
|
|
88
|
+
export {
|
|
89
|
+
Card,
|
|
90
|
+
CardImage,
|
|
91
|
+
CardHeader,
|
|
92
|
+
CardFooter,
|
|
93
|
+
CardTitle,
|
|
94
|
+
CardDescription,
|
|
95
|
+
CardContent,
|
|
96
|
+
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import * as React from "react"
|
|
2
2
|
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
|
|
3
|
-
import { Check } from "lucide-react"
|
|
4
|
-
import {
|
|
5
|
-
import { twMerge } from "tailwind-merge"
|
|
6
|
-
|
|
7
|
-
export function cn(...inputs: ClassValue[]) {
|
|
8
|
-
return twMerge(clsx(inputs))
|
|
9
|
-
}
|
|
3
|
+
import { Check, Minus } from "lucide-react"
|
|
4
|
+
import { cn } from "../../lib/utils"
|
|
10
5
|
|
|
11
6
|
const Checkbox = React.forwardRef<
|
|
12
7
|
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
|
@@ -15,7 +10,7 @@ const Checkbox = React.forwardRef<
|
|
|
15
10
|
<CheckboxPrimitive.Root
|
|
16
11
|
ref={ref}
|
|
17
12
|
className={cn(
|
|
18
|
-
"peer
|
|
13
|
+
"group peer size-5 shrink-0 rounded-xxs border border-grey-300 bg-background transition-colors hover:border-grey-400 focus-visible:outline-none focus-visible:shadow-focus disabled:pointer-events-none disabled:border-grey-200 disabled:bg-muted data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground",
|
|
19
14
|
className
|
|
20
15
|
)}
|
|
21
16
|
{...props}
|
|
@@ -23,7 +18,8 @@ const Checkbox = React.forwardRef<
|
|
|
23
18
|
<CheckboxPrimitive.Indicator
|
|
24
19
|
className={cn("flex items-center justify-center text-current")}
|
|
25
20
|
>
|
|
26
|
-
<Check className="
|
|
21
|
+
<Check className="size-4 group-data-[state=indeterminate]:hidden" />
|
|
22
|
+
<Minus className="size-4 group-data-[state=checked]:hidden" />
|
|
27
23
|
</CheckboxPrimitive.Indicator>
|
|
28
24
|
</CheckboxPrimitive.Root>
|
|
29
25
|
))
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu"
|
|
3
|
+
import { Check, ChevronRight } from "lucide-react"
|
|
4
|
+
import { cn } from "../../lib/utils"
|
|
5
|
+
|
|
6
|
+
const surfaceClasses =
|
|
7
|
+
"z-50 min-w-48 overflow-hidden bg-popover text-popover-foreground rounded-xs shadow-400 border border-grey-100 p-1"
|
|
8
|
+
|
|
9
|
+
const itemClasses =
|
|
10
|
+
"relative flex h-10 cursor-default select-none items-center gap-2 px-3 rounded-xxs text-b3 outline-none transition-colors data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0"
|
|
11
|
+
|
|
12
|
+
const ContextMenu = ContextMenuPrimitive.Root
|
|
13
|
+
|
|
14
|
+
const ContextMenuTrigger = ContextMenuPrimitive.Trigger
|
|
15
|
+
|
|
16
|
+
const ContextMenuGroup = ContextMenuPrimitive.Group
|
|
17
|
+
|
|
18
|
+
const ContextMenuPortal = ContextMenuPrimitive.Portal
|
|
19
|
+
|
|
20
|
+
const ContextMenuSub = ContextMenuPrimitive.Sub
|
|
21
|
+
|
|
22
|
+
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup
|
|
23
|
+
|
|
24
|
+
const ContextMenuContent = React.forwardRef<
|
|
25
|
+
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
|
26
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
|
|
27
|
+
>(({ className, ...props }, ref) => (
|
|
28
|
+
<ContextMenuPrimitive.Portal>
|
|
29
|
+
<ContextMenuPrimitive.Content
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={cn(surfaceClasses, className)}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
</ContextMenuPrimitive.Portal>
|
|
35
|
+
))
|
|
36
|
+
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName
|
|
37
|
+
|
|
38
|
+
export interface ContextMenuItemProps
|
|
39
|
+
extends React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> {
|
|
40
|
+
variant?: "default" | "destructive"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const ContextMenuItem = React.forwardRef<
|
|
44
|
+
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
|
45
|
+
ContextMenuItemProps
|
|
46
|
+
>(({ className, variant = "default", ...props }, ref) => (
|
|
47
|
+
<ContextMenuPrimitive.Item
|
|
48
|
+
ref={ref}
|
|
49
|
+
className={cn(
|
|
50
|
+
itemClasses,
|
|
51
|
+
variant === "destructive" &&
|
|
52
|
+
"text-error data-[highlighted]:bg-error-50 data-[highlighted]:text-error",
|
|
53
|
+
className
|
|
54
|
+
)}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
))
|
|
58
|
+
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName
|
|
59
|
+
|
|
60
|
+
const ContextMenuCheckboxItem = React.forwardRef<
|
|
61
|
+
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
|
62
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
|
|
63
|
+
>(({ className, children, checked, ...props }, ref) => (
|
|
64
|
+
<ContextMenuPrimitive.CheckboxItem
|
|
65
|
+
ref={ref}
|
|
66
|
+
className={cn(itemClasses, "pl-8", className)}
|
|
67
|
+
checked={checked}
|
|
68
|
+
{...props}
|
|
69
|
+
>
|
|
70
|
+
<span className="absolute left-2 flex size-4 items-center justify-center">
|
|
71
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
72
|
+
<Check className="size-4" />
|
|
73
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
74
|
+
</span>
|
|
75
|
+
{children}
|
|
76
|
+
</ContextMenuPrimitive.CheckboxItem>
|
|
77
|
+
))
|
|
78
|
+
ContextMenuCheckboxItem.displayName =
|
|
79
|
+
ContextMenuPrimitive.CheckboxItem.displayName
|
|
80
|
+
|
|
81
|
+
const ContextMenuRadioItem = React.forwardRef<
|
|
82
|
+
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
|
|
83
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
|
|
84
|
+
>(({ className, children, ...props }, ref) => (
|
|
85
|
+
<ContextMenuPrimitive.RadioItem
|
|
86
|
+
ref={ref}
|
|
87
|
+
className={cn(itemClasses, "pl-8", className)}
|
|
88
|
+
{...props}
|
|
89
|
+
>
|
|
90
|
+
<span className="absolute left-2 flex size-4 items-center justify-center">
|
|
91
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
92
|
+
<span className="block size-2 rounded-full bg-current" />
|
|
93
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
94
|
+
</span>
|
|
95
|
+
{children}
|
|
96
|
+
</ContextMenuPrimitive.RadioItem>
|
|
97
|
+
))
|
|
98
|
+
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName
|
|
99
|
+
|
|
100
|
+
const ContextMenuLabel = React.forwardRef<
|
|
101
|
+
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
|
102
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label>
|
|
103
|
+
>(({ className, ...props }, ref) => (
|
|
104
|
+
<ContextMenuPrimitive.Label
|
|
105
|
+
ref={ref}
|
|
106
|
+
className={cn("px-3 py-2 text-label text-muted-foreground", className)}
|
|
107
|
+
{...props}
|
|
108
|
+
/>
|
|
109
|
+
))
|
|
110
|
+
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName
|
|
111
|
+
|
|
112
|
+
const ContextMenuSeparator = React.forwardRef<
|
|
113
|
+
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
|
114
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
|
|
115
|
+
>(({ className, ...props }, ref) => (
|
|
116
|
+
<ContextMenuPrimitive.Separator
|
|
117
|
+
ref={ref}
|
|
118
|
+
className={cn("-mx-1 my-1 h-px bg-grey-100", className)}
|
|
119
|
+
{...props}
|
|
120
|
+
/>
|
|
121
|
+
))
|
|
122
|
+
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName
|
|
123
|
+
|
|
124
|
+
const ContextMenuSubTrigger = React.forwardRef<
|
|
125
|
+
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
|
126
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger>
|
|
127
|
+
>(({ className, children, ...props }, ref) => (
|
|
128
|
+
<ContextMenuPrimitive.SubTrigger
|
|
129
|
+
ref={ref}
|
|
130
|
+
className={cn(
|
|
131
|
+
itemClasses,
|
|
132
|
+
"data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
133
|
+
className
|
|
134
|
+
)}
|
|
135
|
+
{...props}
|
|
136
|
+
>
|
|
137
|
+
{children}
|
|
138
|
+
<ChevronRight className="ml-auto size-4" />
|
|
139
|
+
</ContextMenuPrimitive.SubTrigger>
|
|
140
|
+
))
|
|
141
|
+
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName
|
|
142
|
+
|
|
143
|
+
const ContextMenuSubContent = React.forwardRef<
|
|
144
|
+
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
|
145
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
|
|
146
|
+
>(({ className, ...props }, ref) => (
|
|
147
|
+
<ContextMenuPrimitive.Portal>
|
|
148
|
+
<ContextMenuPrimitive.SubContent
|
|
149
|
+
ref={ref}
|
|
150
|
+
className={cn(surfaceClasses, className)}
|
|
151
|
+
{...props}
|
|
152
|
+
/>
|
|
153
|
+
</ContextMenuPrimitive.Portal>
|
|
154
|
+
))
|
|
155
|
+
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName
|
|
156
|
+
|
|
157
|
+
export {
|
|
158
|
+
ContextMenu,
|
|
159
|
+
ContextMenuTrigger,
|
|
160
|
+
ContextMenuContent,
|
|
161
|
+
ContextMenuItem,
|
|
162
|
+
ContextMenuCheckboxItem,
|
|
163
|
+
ContextMenuRadioGroup,
|
|
164
|
+
ContextMenuRadioItem,
|
|
165
|
+
ContextMenuLabel,
|
|
166
|
+
ContextMenuSeparator,
|
|
167
|
+
ContextMenuGroup,
|
|
168
|
+
ContextMenuPortal,
|
|
169
|
+
ContextMenuSub,
|
|
170
|
+
ContextMenuSubTrigger,
|
|
171
|
+
ContextMenuSubContent,
|
|
172
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog"
|
|
3
|
+
import { X } from "lucide-react"
|
|
4
|
+
import { cn } from "../../lib/utils"
|
|
5
|
+
|
|
6
|
+
const Dialog = DialogPrimitive.Root
|
|
7
|
+
|
|
8
|
+
const DialogTrigger = DialogPrimitive.Trigger
|
|
9
|
+
|
|
10
|
+
const DialogPortal = DialogPrimitive.Portal
|
|
11
|
+
|
|
12
|
+
const DialogClose = DialogPrimitive.Close
|
|
13
|
+
|
|
14
|
+
const DialogOverlay = React.forwardRef<
|
|
15
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
16
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
17
|
+
>(({ className, ...props }, ref) => (
|
|
18
|
+
<DialogPrimitive.Overlay
|
|
19
|
+
ref={ref}
|
|
20
|
+
className={cn(
|
|
21
|
+
"fixed inset-0 z-50 bg-black/50 transition-opacity data-[state=closed]:opacity-0",
|
|
22
|
+
className
|
|
23
|
+
)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
))
|
|
27
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
|
|
28
|
+
|
|
29
|
+
const DialogContent = React.forwardRef<
|
|
30
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
31
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
32
|
+
>(({ className, children, ...props }, ref) => (
|
|
33
|
+
<DialogPortal>
|
|
34
|
+
<DialogOverlay />
|
|
35
|
+
<DialogPrimitive.Content
|
|
36
|
+
ref={ref}
|
|
37
|
+
className={cn(
|
|
38
|
+
"fixed left-1/2 top-1/2 z-50 grid w-full max-w-md -translate-x-1/2 -translate-y-1/2 gap-4 bg-background p-6 rounded-md shadow-600 transition-opacity data-[state=closed]:opacity-0",
|
|
39
|
+
className
|
|
40
|
+
)}
|
|
41
|
+
{...props}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-xxs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:shadow-focus disabled:pointer-events-none">
|
|
45
|
+
<X className="size-5" />
|
|
46
|
+
<span className="sr-only">Close</span>
|
|
47
|
+
</DialogPrimitive.Close>
|
|
48
|
+
</DialogPrimitive.Content>
|
|
49
|
+
</DialogPortal>
|
|
50
|
+
))
|
|
51
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName
|
|
52
|
+
|
|
53
|
+
const DialogHeader = ({
|
|
54
|
+
className,
|
|
55
|
+
...props
|
|
56
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
57
|
+
<div
|
|
58
|
+
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
61
|
+
)
|
|
62
|
+
DialogHeader.displayName = "DialogHeader"
|
|
63
|
+
|
|
64
|
+
export interface DialogFooterProps
|
|
65
|
+
extends React.HTMLAttributes<HTMLDivElement> {
|
|
66
|
+
orientation?: "horizontal" | "vertical"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const DialogFooter = ({
|
|
70
|
+
className,
|
|
71
|
+
orientation = "horizontal",
|
|
72
|
+
...props
|
|
73
|
+
}: DialogFooterProps) => (
|
|
74
|
+
<div
|
|
75
|
+
className={cn(
|
|
76
|
+
"flex gap-2",
|
|
77
|
+
orientation === "vertical"
|
|
78
|
+
? "flex-col"
|
|
79
|
+
: "flex-row justify-end [&>*]:flex-1 sm:[&>*]:flex-none",
|
|
80
|
+
className
|
|
81
|
+
)}
|
|
82
|
+
{...props}
|
|
83
|
+
/>
|
|
84
|
+
)
|
|
85
|
+
DialogFooter.displayName = "DialogFooter"
|
|
86
|
+
|
|
87
|
+
const DialogTitle = React.forwardRef<
|
|
88
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
89
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
90
|
+
>(({ className, ...props }, ref) => (
|
|
91
|
+
<DialogPrimitive.Title
|
|
92
|
+
ref={ref}
|
|
93
|
+
className={cn("text-s1 text-foreground", className)}
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
))
|
|
97
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName
|
|
98
|
+
|
|
99
|
+
const DialogDescription = React.forwardRef<
|
|
100
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
101
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
102
|
+
>(({ className, ...props }, ref) => (
|
|
103
|
+
<DialogPrimitive.Description
|
|
104
|
+
ref={ref}
|
|
105
|
+
className={cn("text-b3 text-muted-foreground", className)}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
))
|
|
109
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
Dialog,
|
|
113
|
+
DialogTrigger,
|
|
114
|
+
DialogPortal,
|
|
115
|
+
DialogOverlay,
|
|
116
|
+
DialogContent,
|
|
117
|
+
DialogHeader,
|
|
118
|
+
DialogFooter,
|
|
119
|
+
DialogTitle,
|
|
120
|
+
DialogDescription,
|
|
121
|
+
DialogClose,
|
|
122
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
|
3
|
+
import { Check, ChevronRight } from "lucide-react"
|
|
4
|
+
import { cn } from "../../lib/utils"
|
|
5
|
+
|
|
6
|
+
const surfaceClasses =
|
|
7
|
+
"z-50 min-w-48 overflow-hidden bg-popover text-popover-foreground rounded-xs shadow-400 border border-grey-100 p-1"
|
|
8
|
+
|
|
9
|
+
const itemClasses =
|
|
10
|
+
"relative flex h-10 cursor-default select-none items-center gap-2 px-3 rounded-xxs text-b3 outline-none transition-colors data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0"
|
|
11
|
+
|
|
12
|
+
const DropdownMenu = DropdownMenuPrimitive.Root
|
|
13
|
+
|
|
14
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
|
|
15
|
+
|
|
16
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group
|
|
17
|
+
|
|
18
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal
|
|
19
|
+
|
|
20
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub
|
|
21
|
+
|
|
22
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
|
|
23
|
+
|
|
24
|
+
const DropdownMenuContent = React.forwardRef<
|
|
25
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
26
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
|
27
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
28
|
+
<DropdownMenuPrimitive.Portal>
|
|
29
|
+
<DropdownMenuPrimitive.Content
|
|
30
|
+
ref={ref}
|
|
31
|
+
sideOffset={sideOffset}
|
|
32
|
+
className={cn(surfaceClasses, className)}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
</DropdownMenuPrimitive.Portal>
|
|
36
|
+
))
|
|
37
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
|
|
38
|
+
|
|
39
|
+
export interface DropdownMenuItemProps
|
|
40
|
+
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> {
|
|
41
|
+
variant?: "default" | "destructive"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const DropdownMenuItem = React.forwardRef<
|
|
45
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
46
|
+
DropdownMenuItemProps
|
|
47
|
+
>(({ className, variant = "default", ...props }, ref) => (
|
|
48
|
+
<DropdownMenuPrimitive.Item
|
|
49
|
+
ref={ref}
|
|
50
|
+
className={cn(
|
|
51
|
+
itemClasses,
|
|
52
|
+
variant === "destructive" &&
|
|
53
|
+
"text-error data-[highlighted]:bg-error-50 data-[highlighted]:text-error",
|
|
54
|
+
className
|
|
55
|
+
)}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
))
|
|
59
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
|
|
60
|
+
|
|
61
|
+
const DropdownMenuCheckboxItem = React.forwardRef<
|
|
62
|
+
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
63
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
|
64
|
+
>(({ className, children, checked, ...props }, ref) => (
|
|
65
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
66
|
+
ref={ref}
|
|
67
|
+
className={cn(itemClasses, "pl-8", className)}
|
|
68
|
+
checked={checked}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
<span className="absolute left-2 flex size-4 items-center justify-center">
|
|
72
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
73
|
+
<Check className="size-4" />
|
|
74
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
75
|
+
</span>
|
|
76
|
+
{children}
|
|
77
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
78
|
+
))
|
|
79
|
+
DropdownMenuCheckboxItem.displayName =
|
|
80
|
+
DropdownMenuPrimitive.CheckboxItem.displayName
|
|
81
|
+
|
|
82
|
+
const DropdownMenuRadioItem = React.forwardRef<
|
|
83
|
+
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
84
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
|
85
|
+
>(({ className, children, ...props }, ref) => (
|
|
86
|
+
<DropdownMenuPrimitive.RadioItem
|
|
87
|
+
ref={ref}
|
|
88
|
+
className={cn(itemClasses, "pl-8", className)}
|
|
89
|
+
{...props}
|
|
90
|
+
>
|
|
91
|
+
<span className="absolute left-2 flex size-4 items-center justify-center">
|
|
92
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
93
|
+
<span className="block size-2 rounded-full bg-current" />
|
|
94
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
95
|
+
</span>
|
|
96
|
+
{children}
|
|
97
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
98
|
+
))
|
|
99
|
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
|
|
100
|
+
|
|
101
|
+
const DropdownMenuLabel = React.forwardRef<
|
|
102
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
103
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label>
|
|
104
|
+
>(({ className, ...props }, ref) => (
|
|
105
|
+
<DropdownMenuPrimitive.Label
|
|
106
|
+
ref={ref}
|
|
107
|
+
className={cn("px-3 py-2 text-label text-muted-foreground", className)}
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
))
|
|
111
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
|
|
112
|
+
|
|
113
|
+
const DropdownMenuSeparator = React.forwardRef<
|
|
114
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
115
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
|
116
|
+
>(({ className, ...props }, ref) => (
|
|
117
|
+
<DropdownMenuPrimitive.Separator
|
|
118
|
+
ref={ref}
|
|
119
|
+
className={cn("-mx-1 my-1 h-px bg-grey-100", className)}
|
|
120
|
+
{...props}
|
|
121
|
+
/>
|
|
122
|
+
))
|
|
123
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
|
|
124
|
+
|
|
125
|
+
const DropdownMenuSubTrigger = React.forwardRef<
|
|
126
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
127
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger>
|
|
128
|
+
>(({ className, children, ...props }, ref) => (
|
|
129
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
130
|
+
ref={ref}
|
|
131
|
+
className={cn(
|
|
132
|
+
itemClasses,
|
|
133
|
+
"data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
134
|
+
className
|
|
135
|
+
)}
|
|
136
|
+
{...props}
|
|
137
|
+
>
|
|
138
|
+
{children}
|
|
139
|
+
<ChevronRight className="ml-auto size-4" />
|
|
140
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
141
|
+
))
|
|
142
|
+
DropdownMenuSubTrigger.displayName =
|
|
143
|
+
DropdownMenuPrimitive.SubTrigger.displayName
|
|
144
|
+
|
|
145
|
+
const DropdownMenuSubContent = React.forwardRef<
|
|
146
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
147
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
|
148
|
+
>(({ className, ...props }, ref) => (
|
|
149
|
+
<DropdownMenuPrimitive.Portal>
|
|
150
|
+
<DropdownMenuPrimitive.SubContent
|
|
151
|
+
ref={ref}
|
|
152
|
+
className={cn(surfaceClasses, className)}
|
|
153
|
+
{...props}
|
|
154
|
+
/>
|
|
155
|
+
</DropdownMenuPrimitive.Portal>
|
|
156
|
+
))
|
|
157
|
+
DropdownMenuSubContent.displayName =
|
|
158
|
+
DropdownMenuPrimitive.SubContent.displayName
|
|
159
|
+
|
|
160
|
+
export {
|
|
161
|
+
DropdownMenu,
|
|
162
|
+
DropdownMenuTrigger,
|
|
163
|
+
DropdownMenuContent,
|
|
164
|
+
DropdownMenuItem,
|
|
165
|
+
DropdownMenuCheckboxItem,
|
|
166
|
+
DropdownMenuRadioGroup,
|
|
167
|
+
DropdownMenuRadioItem,
|
|
168
|
+
DropdownMenuLabel,
|
|
169
|
+
DropdownMenuSeparator,
|
|
170
|
+
DropdownMenuGroup,
|
|
171
|
+
DropdownMenuPortal,
|
|
172
|
+
DropdownMenuSub,
|
|
173
|
+
DropdownMenuSubTrigger,
|
|
174
|
+
DropdownMenuSubContent,
|
|
175
|
+
}
|