bmj-ui 1.0.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
+ import * as React from "react";
2
+ import { Dialog as SheetPrimitive } from "@base-ui/react/dialog";
3
+
4
+ import { cn } from "../../lib/utils";
5
+ import { Button } from "./button";
6
+ import { XIcon } from "lucide-react";
7
+
8
+ function Sheet({ ...props }: SheetPrimitive.Root.Props) {
9
+ return <SheetPrimitive.Root data-slot="sheet" {...props} />;
10
+ }
11
+
12
+ function SheetTrigger({ ...props }: SheetPrimitive.Trigger.Props) {
13
+ return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />;
14
+ }
15
+
16
+ function SheetClose({ ...props }: SheetPrimitive.Close.Props) {
17
+ return <SheetPrimitive.Close data-slot="sheet-close" {...props} />;
18
+ }
19
+
20
+ function SheetPortal({ ...props }: SheetPrimitive.Portal.Props) {
21
+ return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />;
22
+ }
23
+
24
+ function SheetOverlay({ className, ...props }: SheetPrimitive.Backdrop.Props) {
25
+ return (
26
+ <SheetPrimitive.Backdrop
27
+ data-slot="sheet-overlay"
28
+ className={cn(
29
+ "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",
30
+ className,
31
+ )}
32
+ {...props}
33
+ />
34
+ );
35
+ }
36
+
37
+ function SheetContent({
38
+ className,
39
+ children,
40
+ side = "right",
41
+ showCloseButton = true,
42
+ ...props
43
+ }: SheetPrimitive.Popup.Props & {
44
+ side?: "top" | "right" | "bottom" | "left";
45
+ showCloseButton?: boolean;
46
+ }) {
47
+ return (
48
+ <SheetPortal>
49
+ <SheetOverlay />
50
+ <SheetPrimitive.Popup
51
+ data-slot="sheet-content"
52
+ data-side={side}
53
+ className={cn(
54
+ "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-10 data-[side=bottom]:data-starting-style:translate-y-10 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-10 data-[side=left]:data-starting-style:-translate-x-10 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-10 data-[side=right]:data-starting-style:translate-x-10 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-10 data-[side=top]:data-starting-style:-translate-y-10 data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",
55
+ className,
56
+ )}
57
+ {...props}
58
+ >
59
+ {children}
60
+ {showCloseButton && (
61
+ <SheetPrimitive.Close
62
+ data-slot="sheet-close"
63
+ render={
64
+ <Button
65
+ variant="ghost"
66
+ className="absolute top-3 right-3"
67
+ size="icon-sm"
68
+ />
69
+ }
70
+ >
71
+ <XIcon />
72
+ <span className="sr-only">Close</span>
73
+ </SheetPrimitive.Close>
74
+ )}
75
+ </SheetPrimitive.Popup>
76
+ </SheetPortal>
77
+ );
78
+ }
79
+
80
+ function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
81
+ return (
82
+ <div
83
+ data-slot="sheet-header"
84
+ className={cn("flex flex-col gap-0.5 p-4", className)}
85
+ {...props}
86
+ />
87
+ );
88
+ }
89
+
90
+ function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
91
+ return (
92
+ <div
93
+ data-slot="sheet-footer"
94
+ className={cn("mt-auto flex flex-col gap-2 p-4", className)}
95
+ {...props}
96
+ />
97
+ );
98
+ }
99
+
100
+ function SheetTitle({ className, ...props }: SheetPrimitive.Title.Props) {
101
+ return (
102
+ <SheetPrimitive.Title
103
+ data-slot="sheet-title"
104
+ className={cn(
105
+ "font-heading text-base font-medium text-foreground",
106
+ className,
107
+ )}
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
+ };