@anchrd/intel-ui 0.2.1 → 0.4.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.
Files changed (33) hide show
  1. package/components.json +7 -1
  2. package/package.json +3 -1
  3. package/src/app/app-sidebar/app-sidebar.tsx +56 -0
  4. package/src/app/app-tree/app-tree.tsx +427 -0
  5. package/src/app/app.tsx +84 -54
  6. package/src/app/header-actions/header-actions.tsx +15 -0
  7. package/src/app/header-search/header-search.tsx +291 -0
  8. package/src/app/sidebar-preferences/sidebar-preferences.ts +68 -0
  9. package/src/app/sidebar-preferences/sidebar-preferences.types.ts +15 -0
  10. package/src/app/sidebar-resize-handle/sidebar-resize-handle.tsx +85 -0
  11. package/src/app/user-footer/user-footer.tsx +76 -0
  12. package/src/components/ui/breadcrumb.tsx +102 -0
  13. package/src/components/ui/button.tsx +64 -0
  14. package/src/components/ui/collapsible.tsx +20 -0
  15. package/src/components/ui/command.tsx +160 -0
  16. package/src/components/ui/dialog.tsx +143 -0
  17. package/src/components/ui/dropdown-menu.tsx +84 -0
  18. package/src/components/ui/input.tsx +21 -0
  19. package/src/components/ui/separator.tsx +26 -0
  20. package/src/components/ui/sheet.tsx +136 -0
  21. package/src/components/ui/sidebar.tsx +693 -0
  22. package/src/components/ui/skeleton.tsx +13 -0
  23. package/src/components/ui/tooltip.tsx +51 -0
  24. package/src/data/intel-data-provider/intel-data-provider.ts +58 -39
  25. package/src/data/intel-data-provider/intel-data-provider.types.ts +17 -8
  26. package/src/flows/flows.tsx +59 -142
  27. package/src/hooks/use-mobile.ts +19 -0
  28. package/src/i18n/en.json +48 -29
  29. package/src/knowledge/knowledge.tsx +133 -423
  30. package/src/router/router.tsx +4 -0
  31. package/src/router/selection-search.ts +19 -0
  32. package/src/styles.css +54 -51
  33. package/src/tools/tools.tsx +175 -158
@@ -0,0 +1,64 @@
1
+ import { cva, type VariantProps } from "class-variance-authority";
2
+ import { Slot } from "radix-ui";
3
+ import type * as React from "react";
4
+
5
+ import { cn } from "@/lib/utils";
6
+
7
+ const buttonVariants = cva(
8
+ "inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
13
+ // The registry hard-codes the destructive label colour. `--destructive-foreground` exists
14
+ // and a customer theme has to be able to move it, so the token replaces the fixed colour.
15
+ destructive:
16
+ "bg-destructive text-destructive-foreground hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
17
+ outline:
18
+ "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
19
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
20
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
21
+ link: "text-primary underline-offset-4 hover:underline",
22
+ },
23
+ size: {
24
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
25
+ xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
26
+ sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
27
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
28
+ icon: "size-9",
29
+ "icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
30
+ "icon-sm": "size-8",
31
+ "icon-lg": "size-10",
32
+ },
33
+ },
34
+ defaultVariants: {
35
+ variant: "default",
36
+ size: "default",
37
+ },
38
+ },
39
+ );
40
+
41
+ function Button({
42
+ className,
43
+ variant = "default",
44
+ size = "default",
45
+ asChild = false,
46
+ ...props
47
+ }: React.ComponentProps<"button"> &
48
+ VariantProps<typeof buttonVariants> & {
49
+ asChild?: boolean;
50
+ }) {
51
+ const Comp = asChild ? Slot.Root : "button";
52
+
53
+ return (
54
+ <Comp
55
+ data-slot="button"
56
+ data-variant={variant}
57
+ data-size={size}
58
+ className={cn(buttonVariants({ variant, size, className }))}
59
+ {...props}
60
+ />
61
+ );
62
+ }
63
+
64
+ export { Button, buttonVariants };
@@ -0,0 +1,20 @@
1
+ import { Collapsible as CollapsiblePrimitive } from "radix-ui";
2
+ import type * as React from "react";
3
+
4
+ function Collapsible({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
5
+ return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
6
+ }
7
+
8
+ function CollapsibleTrigger({
9
+ ...props
10
+ }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
11
+ return <CollapsiblePrimitive.CollapsibleTrigger data-slot="collapsible-trigger" {...props} />;
12
+ }
13
+
14
+ function CollapsibleContent({
15
+ ...props
16
+ }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
17
+ return <CollapsiblePrimitive.CollapsibleContent data-slot="collapsible-content" {...props} />;
18
+ }
19
+
20
+ export { Collapsible, CollapsibleContent, CollapsibleTrigger };
@@ -0,0 +1,160 @@
1
+ "use client";
2
+
3
+ import { Command as CommandPrimitive } from "cmdk";
4
+ import { SearchIcon } from "lucide-react";
5
+ import type * as React from "react";
6
+ import {
7
+ Dialog,
8
+ DialogContent,
9
+ DialogDescription,
10
+ DialogHeader,
11
+ DialogTitle,
12
+ } from "@/components/ui/dialog";
13
+ import { cn } from "@/lib/utils";
14
+
15
+ function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {
16
+ return (
17
+ <CommandPrimitive
18
+ data-slot="command"
19
+ className={cn(
20
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
21
+ className,
22
+ )}
23
+ {...props}
24
+ />
25
+ );
26
+ }
27
+
28
+ function CommandDialog({
29
+ title = "Command Palette",
30
+ description = "Search for a command to run...",
31
+ children,
32
+ className,
33
+ showCloseButton = true,
34
+ ...props
35
+ }: React.ComponentProps<typeof Dialog> & {
36
+ title?: string;
37
+ description?: string;
38
+ className?: string;
39
+ showCloseButton?: boolean;
40
+ }) {
41
+ return (
42
+ <Dialog {...props}>
43
+ <DialogHeader className="sr-only">
44
+ <DialogTitle>{title}</DialogTitle>
45
+ <DialogDescription>{description}</DialogDescription>
46
+ </DialogHeader>
47
+ <DialogContent
48
+ className={cn("overflow-hidden p-0", className)}
49
+ showCloseButton={showCloseButton}
50
+ >
51
+ <Command className="**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
52
+ {children}
53
+ </Command>
54
+ </DialogContent>
55
+ </Dialog>
56
+ );
57
+ }
58
+
59
+ function CommandInput({
60
+ className,
61
+ ...props
62
+ }: React.ComponentProps<typeof CommandPrimitive.Input>) {
63
+ return (
64
+ <div data-slot="command-input-wrapper" className="flex h-9 items-center gap-2 border-b px-3">
65
+ <SearchIcon className="size-4 shrink-0 opacity-50" />
66
+ <CommandPrimitive.Input
67
+ data-slot="command-input"
68
+ className={cn(
69
+ "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
70
+ className,
71
+ )}
72
+ {...props}
73
+ />
74
+ </div>
75
+ );
76
+ }
77
+
78
+ function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {
79
+ return (
80
+ <CommandPrimitive.List
81
+ data-slot="command-list"
82
+ className={cn("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto", className)}
83
+ {...props}
84
+ />
85
+ );
86
+ }
87
+
88
+ function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
89
+ return (
90
+ <CommandPrimitive.Empty
91
+ data-slot="command-empty"
92
+ className="py-6 text-center text-sm"
93
+ {...props}
94
+ />
95
+ );
96
+ }
97
+
98
+ function CommandGroup({
99
+ className,
100
+ ...props
101
+ }: React.ComponentProps<typeof CommandPrimitive.Group>) {
102
+ return (
103
+ <CommandPrimitive.Group
104
+ data-slot="command-group"
105
+ className={cn(
106
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
107
+ className,
108
+ )}
109
+ {...props}
110
+ />
111
+ );
112
+ }
113
+
114
+ function CommandSeparator({
115
+ className,
116
+ ...props
117
+ }: React.ComponentProps<typeof CommandPrimitive.Separator>) {
118
+ return (
119
+ <CommandPrimitive.Separator
120
+ data-slot="command-separator"
121
+ className={cn("-mx-1 h-px bg-border", className)}
122
+ {...props}
123
+ />
124
+ );
125
+ }
126
+
127
+ function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>) {
128
+ return (
129
+ <CommandPrimitive.Item
130
+ data-slot="command-item"
131
+ className={cn(
132
+ "relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
133
+ className,
134
+ )}
135
+ {...props}
136
+ />
137
+ );
138
+ }
139
+
140
+ function CommandShortcut({ className, ...props }: React.ComponentProps<"span">) {
141
+ return (
142
+ <span
143
+ data-slot="command-shortcut"
144
+ className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)}
145
+ {...props}
146
+ />
147
+ );
148
+ }
149
+
150
+ export {
151
+ Command,
152
+ CommandDialog,
153
+ CommandEmpty,
154
+ CommandGroup,
155
+ CommandInput,
156
+ CommandItem,
157
+ CommandList,
158
+ CommandSeparator,
159
+ CommandShortcut,
160
+ };
@@ -0,0 +1,143 @@
1
+ import { XIcon } from "lucide-react";
2
+ import { Dialog as DialogPrimitive } from "radix-ui";
3
+ import type * as React from "react";
4
+ import { Button } from "@/components/ui/button";
5
+ import { cn } from "@/lib/utils";
6
+
7
+ function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>) {
8
+ return <DialogPrimitive.Root data-slot="dialog" {...props} />;
9
+ }
10
+
11
+ function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
12
+ return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
13
+ }
14
+
15
+ function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>) {
16
+ return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
17
+ }
18
+
19
+ function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>) {
20
+ return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
21
+ }
22
+
23
+ function DialogOverlay({
24
+ className,
25
+ ...props
26
+ }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
27
+ return (
28
+ <DialogPrimitive.Overlay
29
+ data-slot="dialog-overlay"
30
+ className={cn(
31
+ // The registry dims with a literal black. Intel has no palette colours, so the overlay is
32
+ // the same semantic scrim the sheet and the modal already use.
33
+ "fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
34
+ className,
35
+ )}
36
+ {...props}
37
+ />
38
+ );
39
+ }
40
+
41
+ function DialogContent({
42
+ className,
43
+ children,
44
+ showCloseButton = true,
45
+ ...props
46
+ }: React.ComponentProps<typeof DialogPrimitive.Content> & {
47
+ showCloseButton?: boolean;
48
+ }) {
49
+ return (
50
+ <DialogPortal data-slot="dialog-portal">
51
+ <DialogOverlay />
52
+ <DialogPrimitive.Content
53
+ data-slot="dialog-content"
54
+ className={cn(
55
+ "fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
56
+ className,
57
+ )}
58
+ {...props}
59
+ >
60
+ {children}
61
+ {showCloseButton && (
62
+ <DialogPrimitive.Close
63
+ data-slot="dialog-close"
64
+ className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
65
+ >
66
+ <XIcon />
67
+ <span className="sr-only">Close</span>
68
+ </DialogPrimitive.Close>
69
+ )}
70
+ </DialogPrimitive.Content>
71
+ </DialogPortal>
72
+ );
73
+ }
74
+
75
+ function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
76
+ return (
77
+ <div
78
+ data-slot="dialog-header"
79
+ className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
80
+ {...props}
81
+ />
82
+ );
83
+ }
84
+
85
+ function DialogFooter({
86
+ className,
87
+ showCloseButton = false,
88
+ children,
89
+ ...props
90
+ }: React.ComponentProps<"div"> & {
91
+ showCloseButton?: boolean;
92
+ }) {
93
+ return (
94
+ <div
95
+ data-slot="dialog-footer"
96
+ className={cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)}
97
+ {...props}
98
+ >
99
+ {children}
100
+ {showCloseButton && (
101
+ <DialogPrimitive.Close asChild>
102
+ <Button variant="outline">Close</Button>
103
+ </DialogPrimitive.Close>
104
+ )}
105
+ </div>
106
+ );
107
+ }
108
+
109
+ function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>) {
110
+ return (
111
+ <DialogPrimitive.Title
112
+ data-slot="dialog-title"
113
+ className={cn("text-lg leading-none font-semibold", className)}
114
+ {...props}
115
+ />
116
+ );
117
+ }
118
+
119
+ function DialogDescription({
120
+ className,
121
+ ...props
122
+ }: React.ComponentProps<typeof DialogPrimitive.Description>) {
123
+ return (
124
+ <DialogPrimitive.Description
125
+ data-slot="dialog-description"
126
+ className={cn("text-sm text-muted-foreground", className)}
127
+ {...props}
128
+ />
129
+ );
130
+ }
131
+
132
+ export {
133
+ Dialog,
134
+ DialogClose,
135
+ DialogContent,
136
+ DialogDescription,
137
+ DialogFooter,
138
+ DialogHeader,
139
+ DialogOverlay,
140
+ DialogPortal,
141
+ DialogTitle,
142
+ DialogTrigger,
143
+ };
@@ -0,0 +1,84 @@
1
+ import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
2
+ import type * as React from "react";
3
+ import { cn } from "@/lib/utils";
4
+
5
+ function DropdownMenu({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
6
+ return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
7
+ }
8
+
9
+ function DropdownMenuTrigger({
10
+ ...props
11
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
12
+ return <DropdownMenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />;
13
+ }
14
+
15
+ function DropdownMenuContent({
16
+ className,
17
+ sideOffset = 4,
18
+ ...props
19
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
20
+ return (
21
+ <DropdownMenuPrimitive.Portal>
22
+ <DropdownMenuPrimitive.Content
23
+ data-slot="dropdown-menu-content"
24
+ sideOffset={sideOffset}
25
+ className={cn(
26
+ "z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
27
+ className,
28
+ )}
29
+ {...props}
30
+ />
31
+ </DropdownMenuPrimitive.Portal>
32
+ );
33
+ }
34
+
35
+ function DropdownMenuLabel({
36
+ className,
37
+ ...props
38
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Label>) {
39
+ return (
40
+ <DropdownMenuPrimitive.Label
41
+ data-slot="dropdown-menu-label"
42
+ className={cn("px-2 py-1.5 text-sm font-medium", className)}
43
+ {...props}
44
+ />
45
+ );
46
+ }
47
+
48
+ function DropdownMenuItem({
49
+ className,
50
+ ...props
51
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Item>) {
52
+ return (
53
+ <DropdownMenuPrimitive.Item
54
+ data-slot="dropdown-menu-item"
55
+ className={cn(
56
+ "relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",
57
+ className,
58
+ )}
59
+ {...props}
60
+ />
61
+ );
62
+ }
63
+
64
+ function DropdownMenuSeparator({
65
+ className,
66
+ ...props
67
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
68
+ return (
69
+ <DropdownMenuPrimitive.Separator
70
+ data-slot="dropdown-menu-separator"
71
+ className={cn("-mx-1 my-1 h-px bg-border", className)}
72
+ {...props}
73
+ />
74
+ );
75
+ }
76
+
77
+ export {
78
+ DropdownMenu,
79
+ DropdownMenuContent,
80
+ DropdownMenuItem,
81
+ DropdownMenuLabel,
82
+ DropdownMenuSeparator,
83
+ DropdownMenuTrigger,
84
+ };
@@ -0,0 +1,21 @@
1
+ import type * as React from "react";
2
+
3
+ import { cn } from "@/lib/utils";
4
+
5
+ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
6
+ return (
7
+ <input
8
+ type={type}
9
+ data-slot="input"
10
+ className={cn(
11
+ "h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30",
12
+ "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
13
+ "aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
14
+ className,
15
+ )}
16
+ {...props}
17
+ />
18
+ );
19
+ }
20
+
21
+ export { Input };
@@ -0,0 +1,26 @@
1
+ import { Separator as SeparatorPrimitive } from "radix-ui";
2
+ import type * as React from "react";
3
+
4
+ import { cn } from "@/lib/utils";
5
+
6
+ function Separator({
7
+ className,
8
+ orientation = "horizontal",
9
+ decorative = true,
10
+ ...props
11
+ }: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
12
+ return (
13
+ <SeparatorPrimitive.Root
14
+ data-slot="separator"
15
+ decorative={decorative}
16
+ orientation={orientation}
17
+ className={cn(
18
+ "shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
19
+ className,
20
+ )}
21
+ {...props}
22
+ />
23
+ );
24
+ }
25
+
26
+ export { Separator };
@@ -0,0 +1,136 @@
1
+ "use client";
2
+
3
+ import { XIcon } from "lucide-react";
4
+ import { Dialog as SheetPrimitive } from "radix-ui";
5
+ import type * as React from "react";
6
+
7
+ import { cn } from "@/lib/utils";
8
+
9
+ function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
10
+ return <SheetPrimitive.Root data-slot="sheet" {...props} />;
11
+ }
12
+
13
+ function SheetTrigger({ ...props }: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
14
+ return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />;
15
+ }
16
+
17
+ function SheetClose({ ...props }: React.ComponentProps<typeof SheetPrimitive.Close>) {
18
+ return <SheetPrimitive.Close data-slot="sheet-close" {...props} />;
19
+ }
20
+
21
+ function SheetPortal({ ...props }: React.ComponentProps<typeof SheetPrimitive.Portal>) {
22
+ return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />;
23
+ }
24
+
25
+ function SheetOverlay({
26
+ className,
27
+ ...props
28
+ }: React.ComponentProps<typeof SheetPrimitive.Overlay>) {
29
+ return (
30
+ <SheetPrimitive.Overlay
31
+ data-slot="sheet-overlay"
32
+ className={cn(
33
+ // The registry ships a hard palette scrim here. It is not themeable and the token regex
34
+ // rejects it, so the overlay is drawn from the customer's own background token instead.
35
+ "fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
36
+ className,
37
+ )}
38
+ {...props}
39
+ />
40
+ );
41
+ }
42
+
43
+ function SheetContent({
44
+ className,
45
+ children,
46
+ side = "right",
47
+ showCloseButton = true,
48
+ ...props
49
+ }: React.ComponentProps<typeof SheetPrimitive.Content> & {
50
+ side?: "top" | "right" | "bottom" | "left";
51
+ showCloseButton?: boolean;
52
+ }) {
53
+ return (
54
+ <SheetPortal>
55
+ <SheetOverlay />
56
+ <SheetPrimitive.Content
57
+ data-slot="sheet-content"
58
+ className={cn(
59
+ "fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500",
60
+ side === "right" &&
61
+ "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",
62
+ side === "left" &&
63
+ "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",
64
+ side === "top" &&
65
+ "inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
66
+ side === "bottom" &&
67
+ "inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
68
+ className,
69
+ )}
70
+ {...props}
71
+ >
72
+ {children}
73
+ {showCloseButton && (
74
+ <SheetPrimitive.Close className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary">
75
+ <XIcon className="size-4" />
76
+ <span className="sr-only">Close</span>
77
+ </SheetPrimitive.Close>
78
+ )}
79
+ </SheetPrimitive.Content>
80
+ </SheetPortal>
81
+ );
82
+ }
83
+
84
+ function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
85
+ return (
86
+ <div
87
+ data-slot="sheet-header"
88
+ className={cn("flex flex-col gap-1.5 p-4", className)}
89
+ {...props}
90
+ />
91
+ );
92
+ }
93
+
94
+ function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
95
+ return (
96
+ <div
97
+ data-slot="sheet-footer"
98
+ className={cn("mt-auto flex flex-col gap-2 p-4", className)}
99
+ {...props}
100
+ />
101
+ );
102
+ }
103
+
104
+ function SheetTitle({ className, ...props }: React.ComponentProps<typeof SheetPrimitive.Title>) {
105
+ return (
106
+ <SheetPrimitive.Title
107
+ data-slot="sheet-title"
108
+ className={cn("font-semibold text-foreground", className)}
109
+ {...props}
110
+ />
111
+ );
112
+ }
113
+
114
+ function SheetDescription({
115
+ className,
116
+ ...props
117
+ }: React.ComponentProps<typeof SheetPrimitive.Description>) {
118
+ return (
119
+ <SheetPrimitive.Description
120
+ data-slot="sheet-description"
121
+ className={cn("text-sm text-muted-foreground", className)}
122
+ {...props}
123
+ />
124
+ );
125
+ }
126
+
127
+ export {
128
+ Sheet,
129
+ SheetClose,
130
+ SheetContent,
131
+ SheetDescription,
132
+ SheetFooter,
133
+ SheetHeader,
134
+ SheetTitle,
135
+ SheetTrigger,
136
+ };