@aomi-labs/widget-lib 1.0.0 → 1.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.
- package/SHADCN-FETCH-GUIDE.md +105 -0
- package/components.json +10 -0
- package/dist/accordion.json +18 -0
- package/dist/alert.json +17 -0
- package/dist/aomi-frame.json +24 -0
- package/dist/assistant-thread-list.json +22 -0
- package/dist/assistant-thread.json +27 -0
- package/dist/assistant-threadlist-collapsible.json +23 -0
- package/dist/assistant-threadlist-sidebar.json +20 -0
- package/dist/assistant-tool-fallback.json +20 -0
- package/dist/avatar.json +17 -0
- package/dist/badge.json +17 -0
- package/dist/breadcrumb.json +17 -0
- package/dist/button.json +18 -0
- package/dist/card.json +15 -0
- package/dist/collapsible.json +17 -0
- package/dist/command.json +21 -0
- package/dist/dialog.json +18 -0
- package/dist/drawer.json +17 -0
- package/dist/input.json +15 -0
- package/dist/label.json +15 -0
- package/dist/notification.json +20 -0
- package/dist/popover.json +17 -0
- package/dist/registry.json +429 -0
- package/dist/separator.json +17 -0
- package/dist/sheet.json +18 -0
- package/dist/sidebar.json +18 -0
- package/dist/skeleton.json +15 -0
- package/dist/sonner.json +17 -0
- package/dist/tooltip.json +17 -0
- package/package.json +24 -88
- package/scripts/build-registry.js +74 -0
- package/src/components/aomi-frame.tsx +128 -0
- package/src/components/assistant-ui/attachment.tsx +235 -0
- package/src/components/assistant-ui/markdown-text.tsx +228 -0
- package/src/components/assistant-ui/thread-list.tsx +106 -0
- package/src/components/assistant-ui/thread.tsx +457 -0
- package/src/components/assistant-ui/threadlist-sidebar.tsx +71 -0
- package/src/components/assistant-ui/tool-fallback.tsx +48 -0
- package/src/components/assistant-ui/tooltip-icon-button.tsx +42 -0
- package/src/components/test/ThreadContextTest.tsx +204 -0
- package/src/components/tools/example-tool/ExampleTool.tsx +102 -0
- package/src/components/ui/accordion.tsx +58 -0
- package/src/components/ui/alert.tsx +62 -0
- package/src/components/ui/avatar.tsx +53 -0
- package/src/components/ui/badge.tsx +37 -0
- package/src/components/ui/breadcrumb.tsx +109 -0
- package/src/components/ui/button.tsx +59 -0
- package/src/components/ui/card.tsx +86 -0
- package/src/components/ui/collapsible.tsx +12 -0
- package/src/components/ui/command.tsx +156 -0
- package/src/components/ui/dialog.tsx +143 -0
- package/src/components/ui/drawer.tsx +118 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +20 -0
- package/src/components/ui/notification.tsx +57 -0
- package/src/components/ui/popover.tsx +33 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/sheet.tsx +139 -0
- package/src/components/ui/sidebar.tsx +820 -0
- package/src/components/ui/skeleton.tsx +15 -0
- package/src/components/ui/sonner.tsx +29 -0
- package/src/components/ui/tooltip.tsx +61 -0
- package/src/hooks/use-mobile.ts +21 -0
- package/src/index.ts +26 -0
- package/src/registry.ts +218 -0
- package/{dist/styles.css → src/themes/default.css} +21 -3
- package/src/themes/tokens.config.ts +39 -0
- package/tsconfig.json +19 -0
- package/README.md +0 -41
- package/dist/index.cjs +0 -3780
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -302
- package/dist/index.d.ts +0 -302
- package/dist/index.js +0 -3696
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@aomi-labs/react";
|
|
4
|
+
|
|
5
|
+
const Card = React.forwardRef<
|
|
6
|
+
HTMLDivElement,
|
|
7
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<div
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn(
|
|
12
|
+
"bg-card text-card-foreground rounded-lg border shadow-sm",
|
|
13
|
+
className,
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
));
|
|
18
|
+
Card.displayName = "Card";
|
|
19
|
+
|
|
20
|
+
const CardHeader = React.forwardRef<
|
|
21
|
+
HTMLDivElement,
|
|
22
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
23
|
+
>(({ className, ...props }, ref) => (
|
|
24
|
+
<div
|
|
25
|
+
ref={ref}
|
|
26
|
+
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
));
|
|
30
|
+
CardHeader.displayName = "CardHeader";
|
|
31
|
+
|
|
32
|
+
const CardTitle = React.forwardRef<
|
|
33
|
+
HTMLParagraphElement,
|
|
34
|
+
React.HTMLAttributes<HTMLHeadingElement>
|
|
35
|
+
>(({ className, ...props }, ref) => (
|
|
36
|
+
<h3
|
|
37
|
+
ref={ref}
|
|
38
|
+
className={cn(
|
|
39
|
+
"text-2xl font-semibold leading-none tracking-tight",
|
|
40
|
+
className,
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
));
|
|
45
|
+
CardTitle.displayName = "CardTitle";
|
|
46
|
+
|
|
47
|
+
const CardDescription = React.forwardRef<
|
|
48
|
+
HTMLParagraphElement,
|
|
49
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
50
|
+
>(({ className, ...props }, ref) => (
|
|
51
|
+
<p
|
|
52
|
+
ref={ref}
|
|
53
|
+
className={cn("text-muted-foreground text-sm", className)}
|
|
54
|
+
{...props}
|
|
55
|
+
/>
|
|
56
|
+
));
|
|
57
|
+
CardDescription.displayName = "CardDescription";
|
|
58
|
+
|
|
59
|
+
const CardContent = React.forwardRef<
|
|
60
|
+
HTMLDivElement,
|
|
61
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
62
|
+
>(({ className, ...props }, ref) => (
|
|
63
|
+
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
|
64
|
+
));
|
|
65
|
+
CardContent.displayName = "CardContent";
|
|
66
|
+
|
|
67
|
+
const CardFooter = React.forwardRef<
|
|
68
|
+
HTMLDivElement,
|
|
69
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
70
|
+
>(({ className, ...props }, ref) => (
|
|
71
|
+
<div
|
|
72
|
+
ref={ref}
|
|
73
|
+
className={cn("flex items-center p-6 pt-0", className)}
|
|
74
|
+
{...props}
|
|
75
|
+
/>
|
|
76
|
+
));
|
|
77
|
+
CardFooter.displayName = "CardFooter";
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
Card,
|
|
81
|
+
CardHeader,
|
|
82
|
+
CardFooter,
|
|
83
|
+
CardTitle,
|
|
84
|
+
CardDescription,
|
|
85
|
+
CardContent,
|
|
86
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
5
|
+
|
|
6
|
+
const Collapsible = CollapsiblePrimitive.Root;
|
|
7
|
+
|
|
8
|
+
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
|
|
9
|
+
|
|
10
|
+
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
|
|
11
|
+
|
|
12
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { type DialogProps } from "@radix-ui/react-dialog";
|
|
5
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
6
|
+
import { Search } from "lucide-react";
|
|
7
|
+
|
|
8
|
+
import { cn } from "@aomi-labs/react";
|
|
9
|
+
import { Dialog, DialogContent } from "./dialog";
|
|
10
|
+
|
|
11
|
+
const Command = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof CommandPrimitive>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
|
|
14
|
+
>(({ className, ...props }, ref) => (
|
|
15
|
+
<CommandPrimitive
|
|
16
|
+
ref={ref}
|
|
17
|
+
className={cn(
|
|
18
|
+
"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
));
|
|
24
|
+
Command.displayName = CommandPrimitive.displayName;
|
|
25
|
+
|
|
26
|
+
interface CommandDialogProps extends DialogProps {}
|
|
27
|
+
|
|
28
|
+
const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
|
|
29
|
+
return (
|
|
30
|
+
<Dialog {...props}>
|
|
31
|
+
<DialogContent className="overflow-hidden p-0 shadow-lg">
|
|
32
|
+
<Command className="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[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">
|
|
33
|
+
{children}
|
|
34
|
+
</Command>
|
|
35
|
+
</DialogContent>
|
|
36
|
+
</Dialog>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const CommandInput = React.forwardRef<
|
|
41
|
+
React.ElementRef<typeof CommandPrimitive.Input>,
|
|
42
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
|
|
43
|
+
>(({ className, ...props }, ref) => (
|
|
44
|
+
// eslint-disable-next-line react/no-unknown-property
|
|
45
|
+
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
|
|
46
|
+
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
|
|
47
|
+
<CommandPrimitive.Input
|
|
48
|
+
ref={ref}
|
|
49
|
+
className={cn(
|
|
50
|
+
"placeholder:text-muted-foreground flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
51
|
+
className,
|
|
52
|
+
)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
));
|
|
57
|
+
|
|
58
|
+
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
|
59
|
+
|
|
60
|
+
const CommandList = React.forwardRef<
|
|
61
|
+
React.ElementRef<typeof CommandPrimitive.List>,
|
|
62
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
|
63
|
+
>(({ className, ...props }, ref) => (
|
|
64
|
+
<CommandPrimitive.List
|
|
65
|
+
ref={ref}
|
|
66
|
+
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
));
|
|
70
|
+
|
|
71
|
+
CommandList.displayName = CommandPrimitive.List.displayName;
|
|
72
|
+
|
|
73
|
+
const CommandEmpty = React.forwardRef<
|
|
74
|
+
React.ElementRef<typeof CommandPrimitive.Empty>,
|
|
75
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
|
76
|
+
>((props, ref) => (
|
|
77
|
+
<CommandPrimitive.Empty
|
|
78
|
+
ref={ref}
|
|
79
|
+
className="py-6 text-center text-sm"
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
));
|
|
83
|
+
|
|
84
|
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
85
|
+
|
|
86
|
+
const CommandGroup = React.forwardRef<
|
|
87
|
+
React.ElementRef<typeof CommandPrimitive.Group>,
|
|
88
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
|
89
|
+
>(({ className, ...props }, ref) => (
|
|
90
|
+
<CommandPrimitive.Group
|
|
91
|
+
ref={ref}
|
|
92
|
+
className={cn(
|
|
93
|
+
"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
|
|
94
|
+
className,
|
|
95
|
+
)}
|
|
96
|
+
{...props}
|
|
97
|
+
/>
|
|
98
|
+
));
|
|
99
|
+
|
|
100
|
+
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
|
101
|
+
|
|
102
|
+
const CommandSeparator = React.forwardRef<
|
|
103
|
+
React.ElementRef<typeof CommandPrimitive.Separator>,
|
|
104
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
|
105
|
+
>(({ className, ...props }, ref) => (
|
|
106
|
+
<CommandPrimitive.Separator
|
|
107
|
+
ref={ref}
|
|
108
|
+
className={cn("bg-border -mx-1 h-px", className)}
|
|
109
|
+
{...props}
|
|
110
|
+
/>
|
|
111
|
+
));
|
|
112
|
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
|
113
|
+
|
|
114
|
+
const CommandItem = React.forwardRef<
|
|
115
|
+
React.ElementRef<typeof CommandPrimitive.Item>,
|
|
116
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
|
|
117
|
+
>(({ className, ...props }, ref) => (
|
|
118
|
+
<CommandPrimitive.Item
|
|
119
|
+
ref={ref}
|
|
120
|
+
className={cn(
|
|
121
|
+
"aria-selected:bg-accent aria-selected:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
122
|
+
className,
|
|
123
|
+
)}
|
|
124
|
+
{...props}
|
|
125
|
+
/>
|
|
126
|
+
));
|
|
127
|
+
|
|
128
|
+
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
|
129
|
+
|
|
130
|
+
const CommandShortcut = ({
|
|
131
|
+
className,
|
|
132
|
+
...props
|
|
133
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
134
|
+
return (
|
|
135
|
+
<span
|
|
136
|
+
className={cn(
|
|
137
|
+
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
138
|
+
className,
|
|
139
|
+
)}
|
|
140
|
+
{...props}
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
CommandShortcut.displayName = "CommandShortcut";
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
Command,
|
|
148
|
+
CommandDialog,
|
|
149
|
+
CommandInput,
|
|
150
|
+
CommandList,
|
|
151
|
+
CommandEmpty,
|
|
152
|
+
CommandGroup,
|
|
153
|
+
CommandItem,
|
|
154
|
+
CommandSeparator,
|
|
155
|
+
CommandShortcut,
|
|
156
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
5
|
+
import { XIcon } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@aomi-labs/react";
|
|
8
|
+
|
|
9
|
+
function Dialog({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
12
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function DialogTrigger({
|
|
16
|
+
...props
|
|
17
|
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
18
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function DialogPortal({
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
24
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function DialogClose({
|
|
28
|
+
...props
|
|
29
|
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
30
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function DialogOverlay({
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
37
|
+
return (
|
|
38
|
+
<DialogPrimitive.Overlay
|
|
39
|
+
data-slot="dialog-overlay"
|
|
40
|
+
className={cn(
|
|
41
|
+
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function DialogContent({
|
|
50
|
+
className,
|
|
51
|
+
children,
|
|
52
|
+
showCloseButton = true,
|
|
53
|
+
...props
|
|
54
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
55
|
+
showCloseButton?: boolean;
|
|
56
|
+
}) {
|
|
57
|
+
return (
|
|
58
|
+
<DialogPortal data-slot="dialog-portal">
|
|
59
|
+
<DialogOverlay />
|
|
60
|
+
<DialogPrimitive.Content
|
|
61
|
+
data-slot="dialog-content"
|
|
62
|
+
className={cn(
|
|
63
|
+
"bg-background 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 fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
64
|
+
className,
|
|
65
|
+
)}
|
|
66
|
+
{...props}
|
|
67
|
+
>
|
|
68
|
+
{children}
|
|
69
|
+
{showCloseButton && (
|
|
70
|
+
<DialogPrimitive.Close
|
|
71
|
+
data-slot="dialog-close"
|
|
72
|
+
className="rounded-xs ring-offset-background focus:ring-ring focus:outline-hidden data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-4 top-4 opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
73
|
+
>
|
|
74
|
+
<XIcon />
|
|
75
|
+
<span className="sr-only">Close</span>
|
|
76
|
+
</DialogPrimitive.Close>
|
|
77
|
+
)}
|
|
78
|
+
</DialogPrimitive.Content>
|
|
79
|
+
</DialogPortal>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
data-slot="dialog-header"
|
|
87
|
+
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
data-slot="dialog-footer"
|
|
97
|
+
className={cn(
|
|
98
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
99
|
+
className,
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function DialogTitle({
|
|
107
|
+
className,
|
|
108
|
+
...props
|
|
109
|
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
110
|
+
return (
|
|
111
|
+
<DialogPrimitive.Title
|
|
112
|
+
data-slot="dialog-title"
|
|
113
|
+
className={cn("text-lg font-semibold leading-none", 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-muted-foreground text-sm", 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,118 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Drawer as DrawerPrimitive } from "vaul";
|
|
5
|
+
|
|
6
|
+
import { cn } from "@aomi-labs/react";
|
|
7
|
+
|
|
8
|
+
const Drawer = ({
|
|
9
|
+
shouldScaleBackground = true,
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
|
|
12
|
+
<DrawerPrimitive.Root
|
|
13
|
+
shouldScaleBackground={shouldScaleBackground}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
Drawer.displayName = "Drawer";
|
|
18
|
+
|
|
19
|
+
const DrawerTrigger = DrawerPrimitive.Trigger;
|
|
20
|
+
|
|
21
|
+
const DrawerPortal = DrawerPrimitive.Portal;
|
|
22
|
+
|
|
23
|
+
const DrawerClose = DrawerPrimitive.Close;
|
|
24
|
+
|
|
25
|
+
const DrawerOverlay = React.forwardRef<
|
|
26
|
+
React.ElementRef<typeof DrawerPrimitive.Overlay>,
|
|
27
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
|
|
28
|
+
>(({ className, ...props }, ref) => (
|
|
29
|
+
<DrawerPrimitive.Overlay
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={cn("fixed inset-0 z-50 bg-black/80", className)}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
));
|
|
35
|
+
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
|
|
36
|
+
|
|
37
|
+
const DrawerContent = React.forwardRef<
|
|
38
|
+
React.ElementRef<typeof DrawerPrimitive.Content>,
|
|
39
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
|
|
40
|
+
>(({ className, children, ...props }, ref) => (
|
|
41
|
+
<DrawerPortal>
|
|
42
|
+
<DrawerOverlay />
|
|
43
|
+
<DrawerPrimitive.Content
|
|
44
|
+
ref={ref}
|
|
45
|
+
className={cn(
|
|
46
|
+
"bg-background fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border",
|
|
47
|
+
className,
|
|
48
|
+
)}
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
<div className="bg-muted mx-auto mt-4 h-2 w-[100px] rounded-full" />
|
|
52
|
+
{children}
|
|
53
|
+
</DrawerPrimitive.Content>
|
|
54
|
+
</DrawerPortal>
|
|
55
|
+
));
|
|
56
|
+
DrawerContent.displayName = "DrawerContent";
|
|
57
|
+
|
|
58
|
+
const DrawerHeader = ({
|
|
59
|
+
className,
|
|
60
|
+
...props
|
|
61
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
62
|
+
<div
|
|
63
|
+
className={cn("grid gap-1.5 p-4 text-center sm:text-left", className)}
|
|
64
|
+
{...props}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
DrawerHeader.displayName = "DrawerHeader";
|
|
68
|
+
|
|
69
|
+
const DrawerFooter = ({
|
|
70
|
+
className,
|
|
71
|
+
...props
|
|
72
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
73
|
+
<div
|
|
74
|
+
className={cn("mt-auto flex flex-col gap-2 p-4", className)}
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
DrawerFooter.displayName = "DrawerFooter";
|
|
79
|
+
|
|
80
|
+
const DrawerTitle = React.forwardRef<
|
|
81
|
+
React.ElementRef<typeof DrawerPrimitive.Title>,
|
|
82
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
|
|
83
|
+
>(({ className, ...props }, ref) => (
|
|
84
|
+
<DrawerPrimitive.Title
|
|
85
|
+
ref={ref}
|
|
86
|
+
className={cn(
|
|
87
|
+
"text-lg font-semibold leading-none tracking-tight",
|
|
88
|
+
className,
|
|
89
|
+
)}
|
|
90
|
+
{...props}
|
|
91
|
+
/>
|
|
92
|
+
));
|
|
93
|
+
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
|
|
94
|
+
|
|
95
|
+
const DrawerDescription = React.forwardRef<
|
|
96
|
+
React.ElementRef<typeof DrawerPrimitive.Description>,
|
|
97
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
|
|
98
|
+
>(({ className, ...props }, ref) => (
|
|
99
|
+
<DrawerPrimitive.Description
|
|
100
|
+
ref={ref}
|
|
101
|
+
className={cn("text-muted-foreground text-sm", className)}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
));
|
|
105
|
+
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
Drawer,
|
|
109
|
+
DrawerPortal,
|
|
110
|
+
DrawerOverlay,
|
|
111
|
+
DrawerTrigger,
|
|
112
|
+
DrawerClose,
|
|
113
|
+
DrawerContent,
|
|
114
|
+
DrawerHeader,
|
|
115
|
+
DrawerFooter,
|
|
116
|
+
DrawerTitle,
|
|
117
|
+
DrawerDescription,
|
|
118
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@aomi-labs/react";
|
|
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
|
+
"border-sm border-input shadow-xs selection:bg-primary selection:text-primary-foreground file:text-foreground placeholder:text-muted-foreground dark:bg-input/30 flex h-9 w-full min-w-0 rounded-md bg-transparent px-3 py-1 text-base outline-none transition-[color,box-shadow] file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
12
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
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,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@aomi-labs/react";
|
|
4
|
+
|
|
5
|
+
const Label = React.forwardRef<
|
|
6
|
+
HTMLLabelElement,
|
|
7
|
+
React.LabelHTMLAttributes<HTMLLabelElement>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<label
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn(
|
|
12
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
13
|
+
className,
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
));
|
|
18
|
+
Label.displayName = "Label";
|
|
19
|
+
|
|
20
|
+
export { Label };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { toast } from "sonner";
|
|
5
|
+
|
|
6
|
+
import { useNotification } from "@aomi-labs/react";
|
|
7
|
+
import type { Notification } from "@aomi-labs/react";
|
|
8
|
+
|
|
9
|
+
import { Toaster } from "./sonner";
|
|
10
|
+
|
|
11
|
+
export function NotificationToaster() {
|
|
12
|
+
const { notifications, dismissNotification } = useNotification();
|
|
13
|
+
const shownRef = useRef<Set<string>>(new Set());
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const activeIds = new Set(
|
|
17
|
+
notifications.map((notification) => notification.id),
|
|
18
|
+
);
|
|
19
|
+
for (const id of shownRef.current) {
|
|
20
|
+
if (!activeIds.has(id)) {
|
|
21
|
+
shownRef.current.delete(id);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const notification of notifications) {
|
|
26
|
+
if (shownRef.current.has(notification.id)) continue;
|
|
27
|
+
shownRef.current.add(notification.id);
|
|
28
|
+
showToast(notification, dismissNotification);
|
|
29
|
+
}
|
|
30
|
+
}, [notifications, dismissNotification]);
|
|
31
|
+
|
|
32
|
+
return <Toaster position="top-right" />;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function showToast(
|
|
36
|
+
notification: Notification,
|
|
37
|
+
dismissNotification: (id: string) => void,
|
|
38
|
+
) {
|
|
39
|
+
const options = {
|
|
40
|
+
id: notification.id,
|
|
41
|
+
description: notification.title,
|
|
42
|
+
duration: Infinity,
|
|
43
|
+
onDismiss: () => dismissNotification(notification.id),
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
if (notification.type === "success") {
|
|
47
|
+
toast.success(notification.title, options);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (notification.type === "error") {
|
|
52
|
+
toast.error(notification.title, options);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
toast(notification.title, options);
|
|
57
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
5
|
+
|
|
6
|
+
import { cn } from "@aomi-labs/react";
|
|
7
|
+
|
|
8
|
+
const Popover = PopoverPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
11
|
+
|
|
12
|
+
const PopoverAnchor = PopoverPrimitive.Anchor;
|
|
13
|
+
|
|
14
|
+
const PopoverContent = React.forwardRef<
|
|
15
|
+
React.ElementRef<typeof PopoverPrimitive.Content>,
|
|
16
|
+
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
|
17
|
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
|
18
|
+
<PopoverPrimitive.Portal>
|
|
19
|
+
<PopoverPrimitive.Content
|
|
20
|
+
ref={ref}
|
|
21
|
+
align={align}
|
|
22
|
+
sideOffset={sideOffset}
|
|
23
|
+
className={cn(
|
|
24
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 rounded-md border p-4 shadow-md outline-none",
|
|
25
|
+
className,
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
</PopoverPrimitive.Portal>
|
|
30
|
+
));
|
|
31
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
32
|
+
|
|
33
|
+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
5
|
+
|
|
6
|
+
import { cn } from "@aomi-labs/react";
|
|
7
|
+
|
|
8
|
+
function Separator({
|
|
9
|
+
className,
|
|
10
|
+
orientation = "horizontal",
|
|
11
|
+
decorative = true,
|
|
12
|
+
...props
|
|
13
|
+
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
|
|
14
|
+
return (
|
|
15
|
+
<SeparatorPrimitive.Root
|
|
16
|
+
data-slot="separator"
|
|
17
|
+
decorative={decorative}
|
|
18
|
+
orientation={orientation}
|
|
19
|
+
className={cn(
|
|
20
|
+
"shrink-0 data-[orientation=horizontal]:h-px data-[orientation=vertical]:h-full data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px",
|
|
21
|
+
className,
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { Separator };
|