@codefast/ui 0.3.16-canary.2 → 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 +21 -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 +168 -20
- 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,295 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { VariantProps } from "#/lib/utils";
|
|
4
|
+
import type { ComponentProps, JSX } from "react";
|
|
5
|
+
|
|
6
|
+
import { cn } from "#/lib/utils";
|
|
7
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
8
|
+
import { XIcon } from "lucide-react";
|
|
9
|
+
|
|
10
|
+
import { buttonVariants } from "#/variants/button";
|
|
11
|
+
|
|
12
|
+
/* -----------------------------------------------------------------------------
|
|
13
|
+
* Component: Dialog
|
|
14
|
+
* -------------------------------------------------------------------------- */
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @since 0.3.16-canary.0
|
|
18
|
+
*/
|
|
19
|
+
type DialogProps = ComponentProps<typeof DialogPrimitive.Root>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @since 0.3.16-canary.0
|
|
23
|
+
*/
|
|
24
|
+
function Dialog({ ...props }: DialogProps): JSX.Element {
|
|
25
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* -----------------------------------------------------------------------------
|
|
29
|
+
* Component: DialogTrigger
|
|
30
|
+
* -------------------------------------------------------------------------- */
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @since 0.3.16-canary.0
|
|
34
|
+
*/
|
|
35
|
+
type DialogTriggerProps = ComponentProps<typeof DialogPrimitive.Trigger>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @since 0.3.16-canary.0
|
|
39
|
+
*/
|
|
40
|
+
function DialogTrigger({ ...props }: DialogTriggerProps): JSX.Element {
|
|
41
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* -----------------------------------------------------------------------------
|
|
45
|
+
* Component: DialogContent
|
|
46
|
+
* -------------------------------------------------------------------------- */
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @since 0.3.16-canary.0
|
|
50
|
+
*/
|
|
51
|
+
interface DialogContentProps extends ComponentProps<typeof DialogPrimitive.Content> {
|
|
52
|
+
classNames?: {
|
|
53
|
+
close?: string;
|
|
54
|
+
content?: string;
|
|
55
|
+
overlay?: string;
|
|
56
|
+
wrapper?: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @since 0.3.16-canary.0
|
|
62
|
+
*/
|
|
63
|
+
function DialogContent({
|
|
64
|
+
children,
|
|
65
|
+
className,
|
|
66
|
+
classNames,
|
|
67
|
+
...props
|
|
68
|
+
}: DialogContentProps): JSX.Element {
|
|
69
|
+
return (
|
|
70
|
+
<DialogPrimitive.Portal>
|
|
71
|
+
<DialogPrimitive.Overlay
|
|
72
|
+
className={cn(
|
|
73
|
+
"fixed inset-0 z-50",
|
|
74
|
+
"bg-black/40 backdrop-blur-sm",
|
|
75
|
+
"ease-gentle data-open:animate-in data-open:duration-300 data-open:fade-in-0",
|
|
76
|
+
"data-closed:animate-out data-closed:duration-200 data-closed:fade-out-0",
|
|
77
|
+
"motion-reduce:animate-none motion-reduce:transition-none motion-reduce:duration-0",
|
|
78
|
+
classNames?.overlay,
|
|
79
|
+
)}
|
|
80
|
+
data-slot="dialog-overlay"
|
|
81
|
+
/>
|
|
82
|
+
<DialogPrimitive.Content
|
|
83
|
+
className={cn(
|
|
84
|
+
"fixed inset-0 z-50 grid grid-rows-[1fr_auto] justify-items-center overflow-auto",
|
|
85
|
+
"sm:grid-rows-[1fr_auto_3fr] sm:p-4",
|
|
86
|
+
"ease-gentle data-open:animate-in data-open:duration-300",
|
|
87
|
+
"max-sm:data-open:animation-duration-380 max-sm:data-open:slide-in-from-bottom",
|
|
88
|
+
"sm:data-open:fade-in-0 sm:data-open:zoom-in-95",
|
|
89
|
+
"data-closed:animate-out data-closed:duration-200",
|
|
90
|
+
"max-sm:data-closed:animation-duration-280 max-sm:data-closed:slide-out-to-bottom",
|
|
91
|
+
"sm:data-closed:fade-out-0 sm:data-closed:zoom-out-95",
|
|
92
|
+
"motion-reduce:animate-none motion-reduce:transition-none motion-reduce:duration-0",
|
|
93
|
+
classNames?.wrapper,
|
|
94
|
+
)}
|
|
95
|
+
data-slot="dialog-content-wrapper"
|
|
96
|
+
{...props}
|
|
97
|
+
>
|
|
98
|
+
<div
|
|
99
|
+
className={cn(
|
|
100
|
+
"relative row-start-2 flex w-full flex-col",
|
|
101
|
+
"rounded-t-2xl border",
|
|
102
|
+
"bg-popover text-popover-foreground shadow-lg",
|
|
103
|
+
"sm:max-w-lg sm:rounded-2xl",
|
|
104
|
+
classNames?.content,
|
|
105
|
+
className,
|
|
106
|
+
)}
|
|
107
|
+
data-slot="dialog-content"
|
|
108
|
+
>
|
|
109
|
+
{children}
|
|
110
|
+
<DialogPrimitive.Close
|
|
111
|
+
className={buttonVariants({
|
|
112
|
+
className: ["absolute top-2.5 right-2.5 size-7", classNames?.close],
|
|
113
|
+
size: "icon",
|
|
114
|
+
variant: "ghost",
|
|
115
|
+
})}
|
|
116
|
+
data-slot="dialog-close"
|
|
117
|
+
>
|
|
118
|
+
<XIcon className="size-4" />
|
|
119
|
+
<span className="sr-only">Close</span>
|
|
120
|
+
</DialogPrimitive.Close>
|
|
121
|
+
</div>
|
|
122
|
+
</DialogPrimitive.Content>
|
|
123
|
+
</DialogPrimitive.Portal>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* -----------------------------------------------------------------------------
|
|
128
|
+
* Component: DialogHeader
|
|
129
|
+
* -------------------------------------------------------------------------- */
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @since 0.3.16-canary.0
|
|
133
|
+
*/
|
|
134
|
+
type DialogHeaderProps = ComponentProps<"div">;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @since 0.3.16-canary.0
|
|
138
|
+
*/
|
|
139
|
+
function DialogHeader({ className, ...props }: DialogHeaderProps): JSX.Element {
|
|
140
|
+
return (
|
|
141
|
+
<header
|
|
142
|
+
className={cn(
|
|
143
|
+
"flex shrink-0 flex-col gap-1.5 px-6 pt-6 pb-2 text-center",
|
|
144
|
+
"sm:text-left",
|
|
145
|
+
className,
|
|
146
|
+
)}
|
|
147
|
+
data-slot="dialog-header"
|
|
148
|
+
{...props}
|
|
149
|
+
/>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* -----------------------------------------------------------------------------
|
|
154
|
+
* Component: DialogBody
|
|
155
|
+
* -------------------------------------------------------------------------- */
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @since 0.3.16-canary.0
|
|
159
|
+
*/
|
|
160
|
+
type DialogBodyProps = ComponentProps<"div">;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @since 0.3.16-canary.0
|
|
164
|
+
*/
|
|
165
|
+
function DialogBody({ className, ...props }: DialogBodyProps): JSX.Element {
|
|
166
|
+
return (
|
|
167
|
+
<main
|
|
168
|
+
className={cn("overflow-auto", "px-6 py-2", className)}
|
|
169
|
+
data-slot="dialog-body"
|
|
170
|
+
{...props}
|
|
171
|
+
/>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* -----------------------------------------------------------------------------
|
|
176
|
+
* Component: DialogFooter
|
|
177
|
+
* -------------------------------------------------------------------------- */
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @since 0.3.16-canary.0
|
|
181
|
+
*/
|
|
182
|
+
type DialogFooterProps = ComponentProps<"div">;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @since 0.3.16-canary.0
|
|
186
|
+
*/
|
|
187
|
+
function DialogFooter({ className, ...props }: DialogFooterProps): JSX.Element {
|
|
188
|
+
return (
|
|
189
|
+
<footer
|
|
190
|
+
className={cn(
|
|
191
|
+
"flex shrink-0 flex-col-reverse gap-2 px-6 pt-2 pb-6",
|
|
192
|
+
"sm:flex-row sm:justify-end",
|
|
193
|
+
className,
|
|
194
|
+
)}
|
|
195
|
+
data-slot="dialog-footer"
|
|
196
|
+
{...props}
|
|
197
|
+
/>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/* -----------------------------------------------------------------------------
|
|
202
|
+
* Component: DialogTitle
|
|
203
|
+
* -------------------------------------------------------------------------- */
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @since 0.3.16-canary.0
|
|
207
|
+
*/
|
|
208
|
+
type DialogTitleProps = ComponentProps<typeof DialogPrimitive.Title>;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @since 0.3.16-canary.0
|
|
212
|
+
*/
|
|
213
|
+
function DialogTitle({ className, ...props }: DialogTitleProps): JSX.Element {
|
|
214
|
+
return (
|
|
215
|
+
<DialogPrimitive.Title
|
|
216
|
+
className={cn("text-lg leading-none font-semibold tracking-tight", className)}
|
|
217
|
+
data-slot="dialog-title"
|
|
218
|
+
{...props}
|
|
219
|
+
/>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/* -----------------------------------------------------------------------------
|
|
224
|
+
* Component: DialogDescription
|
|
225
|
+
* -------------------------------------------------------------------------- */
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @since 0.3.16-canary.0
|
|
229
|
+
*/
|
|
230
|
+
type DialogDescriptionProps = ComponentProps<typeof DialogPrimitive.Description>;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* @since 0.3.16-canary.0
|
|
234
|
+
*/
|
|
235
|
+
function DialogDescription({ className, ...props }: DialogDescriptionProps): JSX.Element {
|
|
236
|
+
return (
|
|
237
|
+
<DialogPrimitive.Description
|
|
238
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
239
|
+
data-slot="dialog-description"
|
|
240
|
+
{...props}
|
|
241
|
+
/>
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/* -----------------------------------------------------------------------------
|
|
246
|
+
* Component: DialogClose
|
|
247
|
+
* -------------------------------------------------------------------------- */
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* @since 0.3.16-canary.0
|
|
251
|
+
*/
|
|
252
|
+
interface DialogCloseProps extends Omit<ComponentProps<typeof DialogPrimitive.Close>, "ref"> {
|
|
253
|
+
size?: VariantProps<typeof buttonVariants>["size"];
|
|
254
|
+
variant?: VariantProps<typeof buttonVariants>["variant"];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @since 0.3.16-canary.0
|
|
259
|
+
*/
|
|
260
|
+
function DialogClose({ className, size, variant, ...props }: DialogCloseProps): JSX.Element {
|
|
261
|
+
return (
|
|
262
|
+
<DialogPrimitive.Close
|
|
263
|
+
className={buttonVariants({ className, size, variant })}
|
|
264
|
+
data-slot="dialog-close"
|
|
265
|
+
{...props}
|
|
266
|
+
/>
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/* -----------------------------------------------------------------------------
|
|
271
|
+
* Exports
|
|
272
|
+
* -------------------------------------------------------------------------- */
|
|
273
|
+
|
|
274
|
+
export {
|
|
275
|
+
Dialog,
|
|
276
|
+
DialogBody,
|
|
277
|
+
DialogClose,
|
|
278
|
+
DialogContent,
|
|
279
|
+
DialogDescription,
|
|
280
|
+
DialogFooter,
|
|
281
|
+
DialogHeader,
|
|
282
|
+
DialogTitle,
|
|
283
|
+
DialogTrigger,
|
|
284
|
+
};
|
|
285
|
+
export type {
|
|
286
|
+
DialogBodyProps,
|
|
287
|
+
DialogCloseProps,
|
|
288
|
+
DialogContentProps,
|
|
289
|
+
DialogDescriptionProps,
|
|
290
|
+
DialogFooterProps,
|
|
291
|
+
DialogHeaderProps,
|
|
292
|
+
DialogProps,
|
|
293
|
+
DialogTitleProps,
|
|
294
|
+
DialogTriggerProps,
|
|
295
|
+
};
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { VariantProps } from "#/lib/utils";
|
|
4
|
+
import type { ComponentProps, JSX } from "react";
|
|
5
|
+
|
|
6
|
+
import { cn } from "#/lib/utils";
|
|
7
|
+
import { Drawer as DrawerPrimitive } from "vaul";
|
|
8
|
+
|
|
9
|
+
import { buttonVariants } from "#/variants/button";
|
|
10
|
+
|
|
11
|
+
/* -----------------------------------------------------------------------------
|
|
12
|
+
* Component: Drawer
|
|
13
|
+
* -------------------------------------------------------------------------- */
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @since 0.3.16-canary.0
|
|
17
|
+
*/
|
|
18
|
+
type DrawerProps = ComponentProps<typeof DrawerPrimitive.Root>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @since 0.3.16-canary.0
|
|
22
|
+
*/
|
|
23
|
+
function Drawer({ shouldScaleBackground = true, ...props }: DrawerProps): JSX.Element {
|
|
24
|
+
return (
|
|
25
|
+
<DrawerPrimitive.Root
|
|
26
|
+
data-slot="drawer"
|
|
27
|
+
shouldScaleBackground={shouldScaleBackground}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* -----------------------------------------------------------------------------
|
|
34
|
+
* Component: DrawerTrigger
|
|
35
|
+
* -------------------------------------------------------------------------- */
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @since 0.3.16-canary.0
|
|
39
|
+
*/
|
|
40
|
+
type DrawerTriggerProps = ComponentProps<typeof DrawerPrimitive.Trigger>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @since 0.3.16-canary.0
|
|
44
|
+
*/
|
|
45
|
+
function DrawerTrigger({ ...props }: DrawerTriggerProps): JSX.Element {
|
|
46
|
+
return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* -----------------------------------------------------------------------------
|
|
50
|
+
* Component: DrawerContent
|
|
51
|
+
* -------------------------------------------------------------------------- */
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @since 0.3.16-canary.0
|
|
55
|
+
*/
|
|
56
|
+
interface DrawerContentProps extends ComponentProps<typeof DrawerPrimitive.Content> {
|
|
57
|
+
classNames?: {
|
|
58
|
+
content?: string;
|
|
59
|
+
handle?: string;
|
|
60
|
+
overlay?: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @since 0.3.16-canary.0
|
|
66
|
+
*/
|
|
67
|
+
function DrawerContent({
|
|
68
|
+
children,
|
|
69
|
+
className,
|
|
70
|
+
classNames,
|
|
71
|
+
...props
|
|
72
|
+
}: DrawerContentProps): JSX.Element {
|
|
73
|
+
return (
|
|
74
|
+
<DrawerPrimitive.Portal>
|
|
75
|
+
<DrawerPrimitive.Overlay
|
|
76
|
+
className={cn("fixed inset-0 z-50", "bg-black/50", classNames?.overlay)}
|
|
77
|
+
data-slot="drawer-overlay"
|
|
78
|
+
/>
|
|
79
|
+
<DrawerPrimitive.Content
|
|
80
|
+
className={cn(
|
|
81
|
+
"group/drawer-content fixed z-50 flex h-auto flex-col",
|
|
82
|
+
"bg-background",
|
|
83
|
+
"data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-2xl",
|
|
84
|
+
"data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4",
|
|
85
|
+
"data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4",
|
|
86
|
+
"data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-2xl",
|
|
87
|
+
"data-[vaul-drawer-direction=left]:sm:max-w-sm",
|
|
88
|
+
"data-[vaul-drawer-direction=right]:sm:max-w-sm",
|
|
89
|
+
classNames?.content,
|
|
90
|
+
className,
|
|
91
|
+
)}
|
|
92
|
+
data-slot="drawer-content"
|
|
93
|
+
{...props}
|
|
94
|
+
>
|
|
95
|
+
<div
|
|
96
|
+
className={cn(
|
|
97
|
+
"hidden",
|
|
98
|
+
"mx-auto mt-4 h-1.5 w-12 shrink-0",
|
|
99
|
+
"rounded-full",
|
|
100
|
+
"bg-muted",
|
|
101
|
+
"group-data-[vaul-drawer-direction=bottom]/drawer-content:block",
|
|
102
|
+
classNames?.handle,
|
|
103
|
+
)}
|
|
104
|
+
/>
|
|
105
|
+
{children}
|
|
106
|
+
</DrawerPrimitive.Content>
|
|
107
|
+
</DrawerPrimitive.Portal>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* -----------------------------------------------------------------------------
|
|
112
|
+
* Component: DrawerHeader
|
|
113
|
+
* -------------------------------------------------------------------------- */
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @since 0.3.16-canary.0
|
|
117
|
+
*/
|
|
118
|
+
type DrawerHeaderProps = ComponentProps<"div">;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @since 0.3.16-canary.0
|
|
122
|
+
*/
|
|
123
|
+
function DrawerHeader({ className, ...props }: DrawerHeaderProps): JSX.Element {
|
|
124
|
+
return (
|
|
125
|
+
<div
|
|
126
|
+
className={cn("flex flex-col gap-1.5", "p-4", className)}
|
|
127
|
+
data-slot="drawer-header"
|
|
128
|
+
{...props}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* -----------------------------------------------------------------------------
|
|
134
|
+
* Component: DrawerBody
|
|
135
|
+
* -------------------------------------------------------------------------- */
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @since 0.3.16-canary.0
|
|
139
|
+
*/
|
|
140
|
+
type DrawerBodyProps = ComponentProps<"div">;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @since 0.3.16-canary.0
|
|
144
|
+
*/
|
|
145
|
+
function DrawerBody({ className, ...props }: DrawerBodyProps): JSX.Element {
|
|
146
|
+
return (
|
|
147
|
+
<main
|
|
148
|
+
className={cn("overflow-auto", "px-6 py-2", className)}
|
|
149
|
+
data-slot="drawer-body"
|
|
150
|
+
{...props}
|
|
151
|
+
/>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* -----------------------------------------------------------------------------
|
|
156
|
+
* Component: DrawerFooter
|
|
157
|
+
* -------------------------------------------------------------------------- */
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @since 0.3.16-canary.0
|
|
161
|
+
*/
|
|
162
|
+
type DrawerFooterProps = ComponentProps<"div">;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @since 0.3.16-canary.0
|
|
166
|
+
*/
|
|
167
|
+
function DrawerFooter({ className, ...props }: DrawerFooterProps): JSX.Element {
|
|
168
|
+
return (
|
|
169
|
+
<div
|
|
170
|
+
className={cn("flex flex-col gap-2", "mt-auto p-4", className)}
|
|
171
|
+
data-slot="drawer-footer"
|
|
172
|
+
{...props}
|
|
173
|
+
/>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* -----------------------------------------------------------------------------
|
|
178
|
+
* Component: DrawerTitle
|
|
179
|
+
* -------------------------------------------------------------------------- */
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @since 0.3.16-canary.0
|
|
183
|
+
*/
|
|
184
|
+
type DrawerTitleProps = ComponentProps<typeof DrawerPrimitive.Title>;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @since 0.3.16-canary.0
|
|
188
|
+
*/
|
|
189
|
+
function DrawerTitle({ className, ...props }: DrawerTitleProps): JSX.Element {
|
|
190
|
+
return (
|
|
191
|
+
<DrawerPrimitive.Title
|
|
192
|
+
className={cn("font-semibold text-foreground", className)}
|
|
193
|
+
data-slot="drawer-title"
|
|
194
|
+
{...props}
|
|
195
|
+
/>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* -----------------------------------------------------------------------------
|
|
200
|
+
* Component: DrawerDescription
|
|
201
|
+
* -------------------------------------------------------------------------- */
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* @since 0.3.16-canary.0
|
|
205
|
+
*/
|
|
206
|
+
type DrawerDescriptionProps = ComponentProps<typeof DrawerPrimitive.Description>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @since 0.3.16-canary.0
|
|
210
|
+
*/
|
|
211
|
+
function DrawerDescription({ className, ...props }: DrawerDescriptionProps): JSX.Element {
|
|
212
|
+
return (
|
|
213
|
+
<DrawerPrimitive.Description
|
|
214
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
215
|
+
data-slot="drawer-description"
|
|
216
|
+
{...props}
|
|
217
|
+
/>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* -----------------------------------------------------------------------------
|
|
222
|
+
* Component: DrawerClose
|
|
223
|
+
* -------------------------------------------------------------------------- */
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @since 0.3.16-canary.0
|
|
227
|
+
*/
|
|
228
|
+
interface DrawerCloseProps extends ComponentProps<typeof DrawerPrimitive.Close> {
|
|
229
|
+
size?: VariantProps<typeof buttonVariants>["size"];
|
|
230
|
+
variant?: VariantProps<typeof buttonVariants>["variant"];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @since 0.3.16-canary.0
|
|
235
|
+
*/
|
|
236
|
+
function DrawerClose({ className, size, variant, ...props }: DrawerCloseProps): JSX.Element {
|
|
237
|
+
return (
|
|
238
|
+
<DrawerPrimitive.Close
|
|
239
|
+
className={buttonVariants({ className, size, variant })}
|
|
240
|
+
data-slot="drawer-close"
|
|
241
|
+
{...props}
|
|
242
|
+
/>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/* -----------------------------------------------------------------------------
|
|
247
|
+
* Exports
|
|
248
|
+
* -------------------------------------------------------------------------- */
|
|
249
|
+
|
|
250
|
+
export {
|
|
251
|
+
Drawer,
|
|
252
|
+
DrawerBody,
|
|
253
|
+
DrawerClose,
|
|
254
|
+
DrawerContent,
|
|
255
|
+
DrawerDescription,
|
|
256
|
+
DrawerFooter,
|
|
257
|
+
DrawerHeader,
|
|
258
|
+
DrawerTitle,
|
|
259
|
+
DrawerTrigger,
|
|
260
|
+
};
|
|
261
|
+
export type {
|
|
262
|
+
DrawerBodyProps,
|
|
263
|
+
DrawerCloseProps,
|
|
264
|
+
DrawerContentProps,
|
|
265
|
+
DrawerDescriptionProps,
|
|
266
|
+
DrawerFooterProps,
|
|
267
|
+
DrawerHeaderProps,
|
|
268
|
+
DrawerProps,
|
|
269
|
+
DrawerTitleProps,
|
|
270
|
+
DrawerTriggerProps,
|
|
271
|
+
};
|