|
1 |
| -"use client" |
| 1 | +"use client"; |
2 | 2 |
|
3 |
| -import * as React from "react" |
4 |
| -import * as SheetPrimitive from "@radix-ui/react-dialog" |
5 |
| -import { cva, type VariantProps } from "class-variance-authority" |
6 |
| -import { X } from "lucide-react" |
| 3 | +import * as React from "react"; |
| 4 | +import * as SheetPrimitive from "@radix-ui/react-dialog"; |
| 5 | +import { cva } from "class-variance-authority"; |
| 6 | +import type { VariantProps } from "class-variance-authority"; |
| 7 | +import { X } from "lucide-react"; |
7 | 8 |
|
8 |
| -import { cn } from "@/lib/utils" |
| 9 | +import { cn } from "@/lib/utils"; |
9 | 10 |
|
10 |
| -const Sheet = SheetPrimitive.Root |
| 11 | +const Sheet = SheetPrimitive.Root; |
11 | 12 |
|
12 |
| -const SheetTrigger = SheetPrimitive.Trigger |
| 13 | +const SheetTrigger = SheetPrimitive.Trigger; |
13 | 14 |
|
14 |
| -const SheetClose = SheetPrimitive.Close |
| 15 | +const SheetClose = SheetPrimitive.Close; |
15 | 16 |
|
16 |
| -const SheetPortal = SheetPrimitive.Portal |
| 17 | +const SheetPortal = SheetPrimitive.Portal; |
17 | 18 |
|
18 | 19 | const SheetOverlay = React.forwardRef<
|
19 |
| - React.ElementRef<typeof SheetPrimitive.Overlay>, |
20 |
| - React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay> |
| 20 | + React.ElementRef<typeof SheetPrimitive.Overlay>, |
| 21 | + React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay> |
21 | 22 | >(({ className, ...props }, ref) => (
|
22 |
| - <SheetPrimitive.Overlay |
23 |
| - className={cn( |
24 |
| - "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", |
25 |
| - className |
26 |
| - )} |
27 |
| - {...props} |
28 |
| - ref={ref} |
29 |
| - /> |
30 |
| -)) |
31 |
| -SheetOverlay.displayName = SheetPrimitive.Overlay.displayName |
| 23 | + <SheetPrimitive.Overlay |
| 24 | + className={cn( |
| 25 | + "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", |
| 26 | + className, |
| 27 | + )} |
| 28 | + {...props} |
| 29 | + ref={ref} |
| 30 | + /> |
| 31 | +)); |
| 32 | +SheetOverlay.displayName = SheetPrimitive.Overlay.displayName; |
32 | 33 |
|
33 | 34 | const sheetVariants = cva(
|
34 |
| - "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500", |
35 |
| - { |
36 |
| - variants: { |
37 |
| - side: { |
38 |
| - top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top", |
39 |
| - bottom: |
40 |
| - "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom", |
41 |
| - left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm", |
42 |
| - right: |
43 |
| - "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm", |
44 |
| - }, |
| 35 | + "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500", |
| 36 | + { |
| 37 | + variants: { |
| 38 | + side: { |
| 39 | + top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top", |
| 40 | + bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom", |
| 41 | + left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm", |
| 42 | + right: "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm", |
| 43 | + }, |
| 44 | + }, |
| 45 | + defaultVariants: { |
| 46 | + side: "right", |
| 47 | + }, |
45 | 48 | },
|
46 |
| - defaultVariants: { |
47 |
| - side: "right", |
48 |
| - }, |
49 |
| - } |
50 |
| -) |
| 49 | +); |
51 | 50 |
|
52 | 51 | interface SheetContentProps
|
53 |
| - extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>, |
54 |
| - VariantProps<typeof sheetVariants> {} |
| 52 | + extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>, |
| 53 | + VariantProps<typeof sheetVariants> {} |
55 | 54 |
|
56 | 55 | const SheetContent = React.forwardRef<
|
57 |
| - React.ElementRef<typeof SheetPrimitive.Content>, |
58 |
| - SheetContentProps |
| 56 | + React.ElementRef<typeof SheetPrimitive.Content>, |
| 57 | + SheetContentProps |
59 | 58 | >(({ side = "right", className, children, ...props }, ref) => (
|
60 |
| - <SheetPortal> |
61 |
| - <SheetOverlay /> |
62 |
| - <SheetPrimitive.Content |
63 |
| - ref={ref} |
64 |
| - className={cn(sheetVariants({ side }), className)} |
65 |
| - {...props} |
66 |
| - > |
67 |
| - {children} |
68 |
| - <SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary"> |
69 |
| - <X className="h-4 w-4" /> |
70 |
| - <span className="sr-only">Close</span> |
71 |
| - </SheetPrimitive.Close> |
72 |
| - </SheetPrimitive.Content> |
73 |
| - </SheetPortal> |
74 |
| -)) |
75 |
| -SheetContent.displayName = SheetPrimitive.Content.displayName |
| 59 | + <SheetPortal> |
| 60 | + <SheetOverlay /> |
| 61 | + <SheetPrimitive.Content |
| 62 | + ref={ref} |
| 63 | + className={cn(sheetVariants({ side }), className)} |
| 64 | + {...props} |
| 65 | + > |
| 66 | + {children} |
| 67 | + <SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary"> |
| 68 | + <X className="h-4 w-4" /> |
| 69 | + <span className="sr-only">Close</span> |
| 70 | + </SheetPrimitive.Close> |
| 71 | + </SheetPrimitive.Content> |
| 72 | + </SheetPortal> |
| 73 | +)); |
| 74 | +SheetContent.displayName = SheetPrimitive.Content.displayName; |
76 | 75 |
|
77 | 76 | const SheetHeader = ({
|
78 |
| - className, |
79 |
| - ...props |
| 77 | + className, |
| 78 | + ...props |
80 | 79 | }: React.HTMLAttributes<HTMLDivElement>) => (
|
81 |
| - <div |
82 |
| - className={cn( |
83 |
| - "flex flex-col space-y-2 text-center sm:text-left", |
84 |
| - className |
85 |
| - )} |
86 |
| - {...props} |
87 |
| - /> |
88 |
| -) |
89 |
| -SheetHeader.displayName = "SheetHeader" |
| 80 | + <div |
| 81 | + className={cn( |
| 82 | + "flex flex-col space-y-2 text-center sm:text-left", |
| 83 | + className, |
| 84 | + )} |
| 85 | + {...props} |
| 86 | + /> |
| 87 | +); |
| 88 | +SheetHeader.displayName = "SheetHeader"; |
90 | 89 |
|
91 | 90 | const SheetFooter = ({
|
92 |
| - className, |
93 |
| - ...props |
| 91 | + className, |
| 92 | + ...props |
94 | 93 | }: React.HTMLAttributes<HTMLDivElement>) => (
|
95 |
| - <div |
96 |
| - className={cn( |
97 |
| - "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", |
98 |
| - className |
99 |
| - )} |
100 |
| - {...props} |
101 |
| - /> |
102 |
| -) |
103 |
| -SheetFooter.displayName = "SheetFooter" |
| 94 | + <div |
| 95 | + className={cn( |
| 96 | + "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", |
| 97 | + className, |
| 98 | + )} |
| 99 | + {...props} |
| 100 | + /> |
| 101 | +); |
| 102 | +SheetFooter.displayName = "SheetFooter"; |
104 | 103 |
|
105 | 104 | const SheetTitle = React.forwardRef<
|
106 |
| - React.ElementRef<typeof SheetPrimitive.Title>, |
107 |
| - React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title> |
| 105 | + React.ElementRef<typeof SheetPrimitive.Title>, |
| 106 | + React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title> |
108 | 107 | >(({ className, ...props }, ref) => (
|
109 |
| - <SheetPrimitive.Title |
110 |
| - ref={ref} |
111 |
| - className={cn("text-lg font-semibold text-foreground", className)} |
112 |
| - {...props} |
113 |
| - /> |
114 |
| -)) |
115 |
| -SheetTitle.displayName = SheetPrimitive.Title.displayName |
| 108 | + <SheetPrimitive.Title |
| 109 | + ref={ref} |
| 110 | + className={cn("text-lg font-semibold text-foreground", className)} |
| 111 | + {...props} |
| 112 | + /> |
| 113 | +)); |
| 114 | +SheetTitle.displayName = SheetPrimitive.Title.displayName; |
116 | 115 |
|
117 | 116 | const SheetDescription = React.forwardRef<
|
118 |
| - React.ElementRef<typeof SheetPrimitive.Description>, |
119 |
| - React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description> |
| 117 | + React.ElementRef<typeof SheetPrimitive.Description>, |
| 118 | + React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description> |
120 | 119 | >(({ className, ...props }, ref) => (
|
121 |
| - <SheetPrimitive.Description |
122 |
| - ref={ref} |
123 |
| - className={cn("text-sm text-muted-foreground", className)} |
124 |
| - {...props} |
125 |
| - /> |
126 |
| -)) |
127 |
| -SheetDescription.displayName = SheetPrimitive.Description.displayName |
| 120 | + <SheetPrimitive.Description |
| 121 | + ref={ref} |
| 122 | + className={cn("text-sm text-muted-foreground", className)} |
| 123 | + {...props} |
| 124 | + /> |
| 125 | +)); |
| 126 | +SheetDescription.displayName = SheetPrimitive.Description.displayName; |
128 | 127 |
|
129 | 128 | export {
|
130 |
| - Sheet, |
131 |
| - SheetPortal, |
132 |
| - SheetOverlay, |
133 |
| - SheetTrigger, |
134 |
| - SheetClose, |
135 |
| - SheetContent, |
136 |
| - SheetHeader, |
137 |
| - SheetFooter, |
138 |
| - SheetTitle, |
139 |
| - SheetDescription, |
140 |
| -} |
| 129 | + Sheet, |
| 130 | + SheetPortal, |
| 131 | + SheetOverlay, |
| 132 | + SheetTrigger, |
| 133 | + SheetClose, |
| 134 | + SheetContent, |
| 135 | + SheetHeader, |
| 136 | + SheetFooter, |
| 137 | + SheetTitle, |
| 138 | + SheetDescription, |
| 139 | +}; |
0 commit comments