@aomi-labs/widget-lib 1.0.0 → 1.1.1

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 (76) hide show
  1. package/dist/accordion.json +18 -0
  2. package/dist/alert.json +17 -0
  3. package/dist/aomi-frame.json +24 -0
  4. package/dist/assistant-thread-list.json +22 -0
  5. package/dist/assistant-thread.json +27 -0
  6. package/dist/assistant-threadlist-sidebar.json +20 -0
  7. package/dist/assistant-tool-fallback.json +20 -0
  8. package/dist/avatar.json +17 -0
  9. package/dist/badge.json +17 -0
  10. package/dist/breadcrumb.json +17 -0
  11. package/dist/button.json +18 -0
  12. package/dist/card.json +15 -0
  13. package/dist/collapsible.json +17 -0
  14. package/dist/command.json +21 -0
  15. package/dist/dialog.json +18 -0
  16. package/dist/drawer.json +17 -0
  17. package/dist/input.json +15 -0
  18. package/dist/label.json +15 -0
  19. package/dist/notification.json +20 -0
  20. package/dist/popover.json +17 -0
  21. package/dist/registry.json +429 -0
  22. package/dist/separator.json +17 -0
  23. package/dist/sheet.json +18 -0
  24. package/dist/sidebar.json +18 -0
  25. package/dist/skeleton.json +15 -0
  26. package/dist/sonner.json +17 -0
  27. package/dist/tooltip.json +17 -0
  28. package/package.json +27 -85
  29. package/src/components/aomi-frame.tsx +221 -0
  30. package/src/components/assistant-ui/attachment.tsx +235 -0
  31. package/src/components/assistant-ui/markdown-text.tsx +228 -0
  32. package/src/components/assistant-ui/thread-list.tsx +106 -0
  33. package/src/components/assistant-ui/thread.tsx +476 -0
  34. package/src/components/assistant-ui/threadlist-sidebar.tsx +66 -0
  35. package/src/components/assistant-ui/tool-fallback.tsx +48 -0
  36. package/src/components/assistant-ui/tooltip-icon-button.tsx +42 -0
  37. package/src/components/control-bar/api-key-input.tsx +122 -0
  38. package/src/components/control-bar/index.tsx +58 -0
  39. package/src/components/control-bar/model-select.tsx +120 -0
  40. package/src/components/control-bar/namespace-select.tsx +117 -0
  41. package/src/components/control-bar/wallet-connect.tsx +75 -0
  42. package/src/components/test/ThreadContextTest.tsx +204 -0
  43. package/src/components/tools/example-tool/ExampleTool.tsx +102 -0
  44. package/src/components/ui/accordion.tsx +58 -0
  45. package/src/components/ui/alert.tsx +62 -0
  46. package/src/components/ui/avatar.tsx +53 -0
  47. package/src/components/ui/badge.tsx +37 -0
  48. package/src/components/ui/breadcrumb.tsx +109 -0
  49. package/src/components/ui/button.tsx +59 -0
  50. package/src/components/ui/card.tsx +86 -0
  51. package/src/components/ui/collapsible.tsx +12 -0
  52. package/src/components/ui/command.tsx +156 -0
  53. package/src/components/ui/dialog.tsx +143 -0
  54. package/src/components/ui/drawer.tsx +118 -0
  55. package/src/components/ui/input.tsx +21 -0
  56. package/src/components/ui/label.tsx +20 -0
  57. package/src/components/ui/notification.tsx +57 -0
  58. package/src/components/ui/popover.tsx +33 -0
  59. package/src/components/ui/separator.tsx +28 -0
  60. package/src/components/ui/sheet.tsx +139 -0
  61. package/src/components/ui/sidebar.tsx +827 -0
  62. package/src/components/ui/skeleton.tsx +15 -0
  63. package/src/components/ui/sonner.tsx +29 -0
  64. package/src/components/ui/tooltip.tsx +61 -0
  65. package/src/hooks/use-mobile.ts +21 -0
  66. package/src/index.ts +26 -0
  67. package/src/registry.ts +218 -0
  68. package/{dist/styles.css → src/themes/default.css} +21 -3
  69. package/src/themes/tokens.config.ts +39 -0
  70. package/README.md +0 -41
  71. package/dist/index.cjs +0 -3780
  72. package/dist/index.cjs.map +0 -1
  73. package/dist/index.d.cts +0 -302
  74. package/dist/index.d.ts +0 -302
  75. package/dist/index.js +0 -3696
  76. package/dist/index.js.map +0 -1
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+
3
+ import { cn } from "@aomi-labs/react";
4
+
5
+ function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
6
+ return (
7
+ <div
8
+ data-slot="skeleton"
9
+ className={cn("bg-accent animate-pulse rounded-md", className)}
10
+ {...props}
11
+ />
12
+ );
13
+ }
14
+
15
+ export { Skeleton };
@@ -0,0 +1,29 @@
1
+ "use client";
2
+
3
+ import type { ComponentProps } from "react";
4
+ import { Toaster as Sonner } from "sonner";
5
+
6
+ import { cn } from "@aomi-labs/react";
7
+
8
+ type ToasterProps = ComponentProps<typeof Sonner>;
9
+
10
+ export function Toaster({ className, toastOptions, ...props }: ToasterProps) {
11
+ return (
12
+ <Sonner
13
+ className={cn("toaster group", className)}
14
+ toastOptions={{
15
+ classNames: {
16
+ toast:
17
+ "group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
18
+ description: "group-[.toast]:text-muted-foreground",
19
+ actionButton:
20
+ "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
21
+ cancelButton:
22
+ "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
23
+ },
24
+ ...toastOptions,
25
+ }}
26
+ {...props}
27
+ />
28
+ );
29
+ }
@@ -0,0 +1,61 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
5
+
6
+ import { cn } from "@aomi-labs/react";
7
+
8
+ function TooltipProvider({
9
+ delayDuration = 0,
10
+ ...props
11
+ }: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
12
+ return (
13
+ <TooltipPrimitive.Provider
14
+ data-slot="tooltip-provider"
15
+ delayDuration={delayDuration}
16
+ {...props}
17
+ />
18
+ );
19
+ }
20
+
21
+ function Tooltip({
22
+ ...props
23
+ }: React.ComponentProps<typeof TooltipPrimitive.Root>) {
24
+ return (
25
+ <TooltipProvider>
26
+ <TooltipPrimitive.Root data-slot="tooltip" {...props} />
27
+ </TooltipProvider>
28
+ );
29
+ }
30
+
31
+ function TooltipTrigger({
32
+ ...props
33
+ }: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
34
+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
35
+ }
36
+
37
+ function TooltipContent({
38
+ className,
39
+ sideOffset = 0,
40
+ children,
41
+ ...props
42
+ }: React.ComponentProps<typeof TooltipPrimitive.Content>) {
43
+ return (
44
+ <TooltipPrimitive.Portal>
45
+ <TooltipPrimitive.Content
46
+ data-slot="tooltip-content"
47
+ sideOffset={sideOffset}
48
+ className={cn(
49
+ "origin-(--radix-tooltip-content-transform-origin) animate-in bg-primary text-primary-foreground fade-in-0 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 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 z-50 w-fit text-balance rounded-md px-3 py-1.5 text-xs",
50
+ className,
51
+ )}
52
+ {...props}
53
+ >
54
+ {children}
55
+ <TooltipPrimitive.Arrow className="bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
56
+ </TooltipPrimitive.Content>
57
+ </TooltipPrimitive.Portal>
58
+ );
59
+ }
60
+
61
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
@@ -0,0 +1,21 @@
1
+ import * as React from "react";
2
+
3
+ const MOBILE_BREAKPOINT = 768;
4
+
5
+ export function useIsMobile() {
6
+ const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
7
+ undefined,
8
+ );
9
+
10
+ React.useEffect(() => {
11
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
12
+ const onChange = () => {
13
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
14
+ };
15
+ mql.addEventListener("change", onChange);
16
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
17
+ return () => mql.removeEventListener("change", onChange);
18
+ }, []);
19
+
20
+ return !!isMobile;
21
+ }
package/src/index.ts ADDED
@@ -0,0 +1,26 @@
1
+ // Main entry point for @aomi-labs/widget-lib
2
+ // Re-export the main AomiFrame component
3
+ export { AomiFrame } from "./components/aomi-frame";
4
+
5
+ // Notification UI
6
+ export { NotificationToaster } from "./components/ui/notification";
7
+
8
+ // UI Components
9
+ export { Button } from "./components/ui/button";
10
+ export {
11
+ Card,
12
+ CardContent,
13
+ CardDescription,
14
+ CardFooter,
15
+ CardHeader,
16
+ CardTitle,
17
+ } from "./components/ui/card";
18
+ export {
19
+ SidebarMenu,
20
+ SidebarMenuButton,
21
+ SidebarMenuItem,
22
+ } from "./components/ui/sidebar";
23
+
24
+ // Re-export types and utilities from @aomi-labs/react
25
+ export type { UserConfig } from "@aomi-labs/react";
26
+ export { formatAddress, getNetworkName } from "@aomi-labs/react";
@@ -0,0 +1,218 @@
1
+ export type RegistryComponent = {
2
+ name: string;
3
+ file: string;
4
+ dependencies?: string[];
5
+ registryDependencies?: string[];
6
+ description?: string;
7
+ };
8
+
9
+ const REGISTRY_BASE_URL = "https://widget.aomi.dev/r";
10
+
11
+ // Helper to create registry dependency URLs
12
+ const aomi = (name: string) => `${REGISTRY_BASE_URL}/${name}.json`;
13
+ const assistantUI = (name: string) => `https://r.assistant-ui.com/${name}.json`;
14
+
15
+ export const registry: RegistryComponent[] = [
16
+ // === AOMI CUSTOM COMPONENTS ===
17
+ {
18
+ name: "aomi-frame",
19
+ file: "components/aomi-frame.tsx",
20
+ dependencies: ["@aomi-labs/react"],
21
+ registryDependencies: [
22
+ // Internal aomi components (customized)
23
+ aomi("assistant-thread"),
24
+ aomi("assistant-threadlist-sidebar"),
25
+ aomi("notification"),
26
+ // shadcn primitives
27
+ "separator",
28
+ "breadcrumb",
29
+ "sidebar",
30
+ ],
31
+ description: "Full assistant shell with thread list and runtime wiring.",
32
+ },
33
+ {
34
+ name: "assistant-thread",
35
+ file: "components/assistant-ui/thread.tsx",
36
+ dependencies: [
37
+ "@aomi-labs/react",
38
+ "@assistant-ui/react",
39
+ "@assistant-ui/react-markdown",
40
+ "lucide-react",
41
+ "remark-gfm",
42
+ ],
43
+ registryDependencies: [
44
+ // From assistant-ui (unchanged)
45
+ assistantUI("markdown-text"),
46
+ assistantUI("tooltip-icon-button"),
47
+ assistantUI("attachment"),
48
+ // Internal aomi components (customized)
49
+ aomi("assistant-tool-fallback"),
50
+ // shadcn primitives
51
+ "button",
52
+ ],
53
+ description: "Chat surface built on @assistant-ui primitives.",
54
+ },
55
+ {
56
+ name: "assistant-thread-list",
57
+ file: "components/assistant-ui/thread-list.tsx",
58
+ dependencies: ["@assistant-ui/react", "lucide-react"],
59
+ registryDependencies: [
60
+ assistantUI("tooltip-icon-button"),
61
+ "button",
62
+ "skeleton",
63
+ ],
64
+ description: "Thread list wrapper wired to runtime adapter.",
65
+ },
66
+ {
67
+ name: "assistant-threadlist-sidebar",
68
+ file: "components/assistant-ui/threadlist-sidebar.tsx",
69
+ dependencies: ["lucide-react"],
70
+ registryDependencies: [aomi("assistant-thread-list"), "sidebar"],
71
+ description: "Sidebar shell for thread navigation and wallet footer slot.",
72
+ },
73
+
74
+ {
75
+ name: "assistant-tool-fallback",
76
+ file: "components/assistant-ui/tool-fallback.tsx",
77
+ dependencies: ["@assistant-ui/react", "lucide-react"],
78
+ registryDependencies: ["button"],
79
+ description: "Fallback renderer for assistant tool calls.",
80
+ },
81
+ {
82
+ name: "notification",
83
+ file: "components/ui/notification.tsx",
84
+ dependencies: ["@aomi-labs/react", "sonner"],
85
+ registryDependencies: [aomi("sonner")],
86
+ description:
87
+ "Notification toaster wired to the runtime notification store.",
88
+ },
89
+ {
90
+ name: "sonner",
91
+ file: "components/ui/sonner.tsx",
92
+ dependencies: ["sonner"],
93
+ description: "Shadcn wrapper for Sonner toasts.",
94
+ },
95
+ // === SHADCN UI PRIMITIVES ===
96
+ {
97
+ name: "button",
98
+ file: "components/ui/button.tsx",
99
+ dependencies: ["@radix-ui/react-slot", "class-variance-authority"],
100
+ description: "Displays a button or a component that looks like a button.",
101
+ },
102
+ {
103
+ name: "input",
104
+ file: "components/ui/input.tsx",
105
+ dependencies: [],
106
+ description:
107
+ "Displays a form input field or a component that looks like an input field.",
108
+ },
109
+ {
110
+ name: "label",
111
+ file: "components/ui/label.tsx",
112
+ dependencies: [],
113
+ description: "Renders an accessible label associated with controls.",
114
+ },
115
+ {
116
+ name: "card",
117
+ file: "components/ui/card.tsx",
118
+ dependencies: [],
119
+ description: "Displays a card with header, content, and footer.",
120
+ },
121
+ {
122
+ name: "badge",
123
+ file: "components/ui/badge.tsx",
124
+ dependencies: ["class-variance-authority"],
125
+ description: "Displays a badge or a component that looks like a badge.",
126
+ },
127
+ {
128
+ name: "avatar",
129
+ file: "components/ui/avatar.tsx",
130
+ dependencies: ["@radix-ui/react-avatar"],
131
+ description: "An image element with a fallback for representing the user.",
132
+ },
133
+ {
134
+ name: "skeleton",
135
+ file: "components/ui/skeleton.tsx",
136
+ dependencies: [],
137
+ description: "Use to show a placeholder while content is loading.",
138
+ },
139
+ {
140
+ name: "tooltip",
141
+ file: "components/ui/tooltip.tsx",
142
+ dependencies: ["@radix-ui/react-tooltip"],
143
+ description:
144
+ "A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.",
145
+ },
146
+ {
147
+ name: "separator",
148
+ file: "components/ui/separator.tsx",
149
+ dependencies: ["@radix-ui/react-separator"],
150
+ description: "Visually or semantically separates content.",
151
+ },
152
+ {
153
+ name: "breadcrumb",
154
+ file: "components/ui/breadcrumb.tsx",
155
+ dependencies: ["@radix-ui/react-slot"],
156
+ description:
157
+ "Displays the path to the current resource using a hierarchy of links.",
158
+ },
159
+ {
160
+ name: "sidebar",
161
+ file: "components/ui/sidebar.tsx",
162
+ dependencies: ["@radix-ui/react-slot", "class-variance-authority"],
163
+ description: "Displays a sidebar navigation component.",
164
+ },
165
+ {
166
+ name: "dialog",
167
+ file: "components/ui/dialog.tsx",
168
+ dependencies: ["@radix-ui/react-dialog", "lucide-react"],
169
+ description:
170
+ "A window overlaid on either the primary window or another dialog window.",
171
+ },
172
+ {
173
+ name: "sheet",
174
+ file: "components/ui/sheet.tsx",
175
+ dependencies: ["@radix-ui/react-dialog", "lucide-react"],
176
+ description:
177
+ "Extends the Dialog component to display content that complements the main content of the screen.",
178
+ },
179
+ {
180
+ name: "collapsible",
181
+ file: "components/ui/collapsible.tsx",
182
+ dependencies: ["@radix-ui/react-collapsible"],
183
+ description: "An interactive component which expands/collapses a panel.",
184
+ },
185
+ {
186
+ name: "command",
187
+ file: "components/ui/command.tsx",
188
+ dependencies: ["@radix-ui/react-dialog", "cmdk", "lucide-react"],
189
+ registryDependencies: ["dialog"],
190
+ description: "Fast, composable, unstyled command menu for React.",
191
+ },
192
+ {
193
+ name: "popover",
194
+ file: "components/ui/popover.tsx",
195
+ dependencies: ["@radix-ui/react-popover"],
196
+ description: "Displays rich content in a portal, triggered by a button.",
197
+ },
198
+ {
199
+ name: "alert",
200
+ file: "components/ui/alert.tsx",
201
+ dependencies: ["class-variance-authority"],
202
+ description: "Displays a callout for user attention.",
203
+ },
204
+ {
205
+ name: "accordion",
206
+ file: "components/ui/accordion.tsx",
207
+ dependencies: ["@radix-ui/react-accordion", "lucide-react"],
208
+ description:
209
+ "A vertically stacked set of interactive headings that each reveal a section of content.",
210
+ },
211
+ {
212
+ name: "drawer",
213
+ file: "components/ui/drawer.tsx",
214
+ dependencies: ["vaul"],
215
+ description:
216
+ "A drawer component for mobile navigation menus and similar interfaces.",
217
+ },
218
+ ];
@@ -1,5 +1,6 @@
1
- /* @aomi-labs/widget-lib - Theme Styles */
2
- /* Consumers should import this file: @import "@aomi-labs/widget-lib/styles.css" */
1
+ /* @aomi-labs/widget-lib - Default Theme (shadcn compatible) */
2
+ /* Import via: @import "@aomi-labs/widget-lib/styles.css" (alias) */
3
+ /* Or directly: @import "@aomi-labs/widget-lib/themes/default.css" */
3
4
 
4
5
  /* ============================================
5
6
  Theme Configuration (Tailwind v4 compatible)
@@ -45,6 +46,17 @@
45
46
  --radius-md: calc(var(--radius) - 2px);
46
47
  --radius-lg: var(--radius);
47
48
  --radius-xl: calc(var(--radius) + 4px);
49
+
50
+ @keyframes shimmer-sweep {
51
+ from {
52
+ background-position: 150% 0;
53
+ }
54
+ to {
55
+ background-position: -100% 0;
56
+ }
57
+ }
58
+ --animate-shimmer: shimmer-sweep var(--shimmer-duration, 1000ms) linear
59
+ infinite both;
48
60
  }
49
61
 
50
62
  /* ============================================
@@ -52,6 +64,12 @@
52
64
  ============================================ */
53
65
 
54
66
  :root {
67
+ --font-geist-sans:
68
+ "Geist", "Inter", "SF Pro Display", "Segoe UI", system-ui, -apple-system,
69
+ BlinkMacSystemFont, sans-serif;
70
+ --font-geist-mono:
71
+ "Geist Mono", "JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", Menlo,
72
+ Monaco, Consolas, "Liberation Mono", monospace;
55
73
  --radius: 0.625rem;
56
74
  --background: oklch(1 0 0);
57
75
  --foreground: oklch(0.141 0.005 285.823);
@@ -107,7 +125,7 @@
107
125
  --accent-foreground: oklch(0.985 0 0);
108
126
  --destructive: oklch(0.704 0.191 22.216);
109
127
  --border: oklch(1 0 0 / 10%);
110
- --input: oklch(1 0 0 / 15%);
128
+ --input: oklch(0.6 0 0 / 15%);
111
129
  --ring: oklch(0.552 0.016 285.938);
112
130
  --chart-1: oklch(0.488 0.243 264.376);
113
131
  --chart-2: oklch(0.696 0.17 162.48);
@@ -0,0 +1,39 @@
1
+ export type ThemeMetadata = {
2
+ /** File name without extension, e.g. `default` */
3
+ id: string;
4
+ /** Human friendly name to show in docs or CLIs. */
5
+ label: string;
6
+ /** Short marketing blurb for selection menus. */
7
+ description: string;
8
+ /** Relative CSS path emitted to `dist/`. */
9
+ cssPath: string;
10
+ /** Preview colors so docs can render swatches. */
11
+ preview: {
12
+ background: string;
13
+ foreground: string;
14
+ };
15
+ /** Whether this theme should be copied to `dist/styles.css`. */
16
+ isDefault?: boolean;
17
+ };
18
+
19
+ export const themes: ThemeMetadata[] = [
20
+ {
21
+ id: "default",
22
+ label: "Default",
23
+ description:
24
+ "Neutral finance-friendly palette with soft gradients and AppKit-friendly overrides.",
25
+ cssPath: "./themes/default.css",
26
+ preview: {
27
+ background: "oklch(1 0 0)",
28
+ foreground: "oklch(0.21 0.006 285.885)",
29
+ },
30
+ isDefault: true,
31
+ },
32
+ ];
33
+
34
+ export const DEFAULT_THEME =
35
+ themes.find((theme) => theme.isDefault) ?? themes[0];
36
+
37
+ export function getTheme(id: string): ThemeMetadata | undefined {
38
+ return themes.find((theme) => theme.id === id);
39
+ }
package/README.md DELETED
@@ -1,41 +0,0 @@
1
- AI assistant + onchain widget library and demo landing page for `@aomi-labs/widget-lib`.
2
-
3
- ## Library usage
4
-
5
- ```bash
6
- pnpm install @aomi-labs/widget-lib
7
- ```
8
-
9
- Drop the frame into your app:
10
-
11
- ```tsx
12
- import { AomiFrame } from "@aomi-labs/widget-lib";
13
-
14
- export function Assistant() {
15
- return (
16
- <AomiFrame height="640px" width="100%">
17
- {/* optional slots like WalletSystemMessenger */}
18
- </AomiFrame>
19
- );
20
- }
21
- ```
22
-
23
- ## Develop this repo
24
-
25
- ```bash
26
- pnpm install
27
- pnpm run build:lib # build the published bundle
28
- pnpm --filter example dev # run the landing/demo (http://localhost:3000)
29
- pnpm run dev:example:live # watch the library and run the example together
30
- pnpm lint # lint library + example source
31
- ```
32
-
33
- The example app lives in `example/` and imports the built library. Re-run `pnpm run build:lib` after changing code in `src/`.
34
-
35
- ## Env
36
-
37
- Create `.env` with your Web3 Project ID from https://docs.reown.com/ and URL endpoint of your backend:
38
- ```
39
- NEXT_PUBLIC_PROJECT_ID=000000000000000000000000
40
- NEXT_PUBLIC_BACKEND_URL=http://example.app.com
41
- ```