@silicajs/ui 0.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.
@@ -0,0 +1,135 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Dialog as SheetPrimitive } from "@base-ui/react/dialog"
5
+
6
+ import { cn } from "@silicajs/ui/lib/utils"
7
+ import { Button } from "@silicajs/ui/components/button"
8
+ import { XIcon } from "lucide-react"
9
+
10
+ function Sheet({ ...props }: SheetPrimitive.Root.Props) {
11
+ return <SheetPrimitive.Root data-slot="sheet" {...props} />
12
+ }
13
+
14
+ function SheetTrigger({ ...props }: SheetPrimitive.Trigger.Props) {
15
+ return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />
16
+ }
17
+
18
+ function SheetClose({ ...props }: SheetPrimitive.Close.Props) {
19
+ return <SheetPrimitive.Close data-slot="sheet-close" {...props} />
20
+ }
21
+
22
+ function SheetPortal({ ...props }: SheetPrimitive.Portal.Props) {
23
+ return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />
24
+ }
25
+
26
+ function SheetOverlay({ className, ...props }: SheetPrimitive.Backdrop.Props) {
27
+ return (
28
+ <SheetPrimitive.Backdrop
29
+ data-slot="sheet-overlay"
30
+ className={cn(
31
+ "fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",
32
+ className
33
+ )}
34
+ {...props}
35
+ />
36
+ )
37
+ }
38
+
39
+ function SheetContent({
40
+ className,
41
+ children,
42
+ side = "right",
43
+ showCloseButton = true,
44
+ ...props
45
+ }: SheetPrimitive.Popup.Props & {
46
+ side?: "top" | "right" | "bottom" | "left"
47
+ showCloseButton?: boolean
48
+ }) {
49
+ return (
50
+ <SheetPortal>
51
+ <SheetOverlay />
52
+ <SheetPrimitive.Popup
53
+ data-slot="sheet-content"
54
+ data-side={side}
55
+ className={cn(
56
+ "fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",
57
+ className
58
+ )}
59
+ {...props}
60
+ >
61
+ {children}
62
+ {showCloseButton && (
63
+ <SheetPrimitive.Close
64
+ data-slot="sheet-close"
65
+ render={
66
+ <Button
67
+ variant="ghost"
68
+ className="absolute top-4 right-4"
69
+ size="icon-sm"
70
+ />
71
+ }
72
+ >
73
+ <XIcon
74
+ />
75
+ <span className="sr-only">Close</span>
76
+ </SheetPrimitive.Close>
77
+ )}
78
+ </SheetPrimitive.Popup>
79
+ </SheetPortal>
80
+ )
81
+ }
82
+
83
+ function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
84
+ return (
85
+ <div
86
+ data-slot="sheet-header"
87
+ className={cn("flex flex-col gap-1.5 p-4", className)}
88
+ {...props}
89
+ />
90
+ )
91
+ }
92
+
93
+ function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
94
+ return (
95
+ <div
96
+ data-slot="sheet-footer"
97
+ className={cn("mt-auto flex flex-col gap-2 p-4", className)}
98
+ {...props}
99
+ />
100
+ )
101
+ }
102
+
103
+ function SheetTitle({ className, ...props }: SheetPrimitive.Title.Props) {
104
+ return (
105
+ <SheetPrimitive.Title
106
+ data-slot="sheet-title"
107
+ className={cn("font-heading font-medium text-foreground", className)}
108
+ {...props}
109
+ />
110
+ )
111
+ }
112
+
113
+ function SheetDescription({
114
+ className,
115
+ ...props
116
+ }: SheetPrimitive.Description.Props) {
117
+ return (
118
+ <SheetPrimitive.Description
119
+ data-slot="sheet-description"
120
+ className={cn("text-sm text-muted-foreground", className)}
121
+ {...props}
122
+ />
123
+ )
124
+ }
125
+
126
+ export {
127
+ Sheet,
128
+ SheetTrigger,
129
+ SheetClose,
130
+ SheetContent,
131
+ SheetHeader,
132
+ SheetFooter,
133
+ SheetTitle,
134
+ SheetDescription,
135
+ }