@cloudbase/agent-react-ui 0.0.23

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 (109) hide show
  1. package/README.md +135 -0
  2. package/components.json +21 -0
  3. package/dist/index.css +4241 -0
  4. package/dist/index.css.map +1 -0
  5. package/dist/index.d.mts +59 -0
  6. package/dist/index.d.ts +59 -0
  7. package/dist/index.js +2169 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/index.mjs +2182 -0
  10. package/dist/index.mjs.map +1 -0
  11. package/example/.env.sample +2 -0
  12. package/example/App.tsx +368 -0
  13. package/example/app.css +1 -0
  14. package/example/index.html +12 -0
  15. package/example/main.tsx +9 -0
  16. package/example/vite.config.ts +34 -0
  17. package/package.json +75 -0
  18. package/postcss.config.cjs +3 -0
  19. package/src/components/ai-elements/agent.tsx +140 -0
  20. package/src/components/ai-elements/artifact.tsx +147 -0
  21. package/src/components/ai-elements/attachments.tsx +421 -0
  22. package/src/components/ai-elements/audio-player.tsx +228 -0
  23. package/src/components/ai-elements/canvas.tsx +22 -0
  24. package/src/components/ai-elements/chain-of-thought.tsx +228 -0
  25. package/src/components/ai-elements/checkpoint.tsx +71 -0
  26. package/src/components/ai-elements/code-block.tsx +532 -0
  27. package/src/components/ai-elements/commit.tsx +448 -0
  28. package/src/components/ai-elements/confirmation.tsx +176 -0
  29. package/src/components/ai-elements/connection.tsx +28 -0
  30. package/src/components/ai-elements/context.tsx +408 -0
  31. package/src/components/ai-elements/controls.tsx +18 -0
  32. package/src/components/ai-elements/conversation.tsx +100 -0
  33. package/src/components/ai-elements/edge.tsx +140 -0
  34. package/src/components/ai-elements/environment-variables.tsx +295 -0
  35. package/src/components/ai-elements/file-tree.tsx +258 -0
  36. package/src/components/ai-elements/image.tsx +24 -0
  37. package/src/components/ai-elements/inline-citation.tsx +287 -0
  38. package/src/components/ai-elements/message.tsx +336 -0
  39. package/src/components/ai-elements/mic-selector.tsx +370 -0
  40. package/src/components/ai-elements/model-selector.tsx +211 -0
  41. package/src/components/ai-elements/node.tsx +71 -0
  42. package/src/components/ai-elements/open-in-chat.tsx +365 -0
  43. package/src/components/ai-elements/package-info.tsx +233 -0
  44. package/src/components/ai-elements/panel.tsx +15 -0
  45. package/src/components/ai-elements/persona.tsx +270 -0
  46. package/src/components/ai-elements/plan.tsx +142 -0
  47. package/src/components/ai-elements/prompt-input.tsx +1263 -0
  48. package/src/components/ai-elements/queue.tsx +274 -0
  49. package/src/components/ai-elements/reasoning.tsx +193 -0
  50. package/src/components/ai-elements/sandbox.tsx +126 -0
  51. package/src/components/ai-elements/schema-display.tsx +458 -0
  52. package/src/components/ai-elements/shimmer.tsx +64 -0
  53. package/src/components/ai-elements/snippet.tsx +139 -0
  54. package/src/components/ai-elements/sources.tsx +77 -0
  55. package/src/components/ai-elements/speech-input.tsx +301 -0
  56. package/src/components/ai-elements/stack-trace.tsx +482 -0
  57. package/src/components/ai-elements/suggestion.tsx +53 -0
  58. package/src/components/ai-elements/task.tsx +87 -0
  59. package/src/components/ai-elements/terminal.tsx +261 -0
  60. package/src/components/ai-elements/test-results.tsx +485 -0
  61. package/src/components/ai-elements/tool.tsx +174 -0
  62. package/src/components/ai-elements/toolbar.tsx +16 -0
  63. package/src/components/ai-elements/transcription.tsx +124 -0
  64. package/src/components/ai-elements/voice-selector.tsx +479 -0
  65. package/src/components/ai-elements/web-preview.tsx +263 -0
  66. package/src/components/chat/Chat.tsx +178 -0
  67. package/src/components/chat/Input.tsx +98 -0
  68. package/src/components/chat/Message.tsx +276 -0
  69. package/src/components/chat/index.ts +2 -0
  70. package/src/components/index.ts +1 -0
  71. package/src/components/ui/accordion.tsx +64 -0
  72. package/src/components/ui/alert.tsx +66 -0
  73. package/src/components/ui/avatar.tsx +107 -0
  74. package/src/components/ui/badge.tsx +48 -0
  75. package/src/components/ui/button-group.tsx +83 -0
  76. package/src/components/ui/button.tsx +64 -0
  77. package/src/components/ui/card.tsx +92 -0
  78. package/src/components/ui/carousel.tsx +239 -0
  79. package/src/components/ui/collapsible.tsx +31 -0
  80. package/src/components/ui/command.tsx +184 -0
  81. package/src/components/ui/dialog.tsx +158 -0
  82. package/src/components/ui/dropdown-menu.tsx +257 -0
  83. package/src/components/ui/hover-card.tsx +42 -0
  84. package/src/components/ui/input-group.tsx +168 -0
  85. package/src/components/ui/input.tsx +21 -0
  86. package/src/components/ui/popover.tsx +87 -0
  87. package/src/components/ui/progress.tsx +31 -0
  88. package/src/components/ui/scroll-area.tsx +56 -0
  89. package/src/components/ui/select.tsx +190 -0
  90. package/src/components/ui/separator.tsx +28 -0
  91. package/src/components/ui/spinner.tsx +16 -0
  92. package/src/components/ui/switch.tsx +33 -0
  93. package/src/components/ui/tabs.tsx +91 -0
  94. package/src/components/ui/textarea.tsx +18 -0
  95. package/src/components/ui/tooltip.tsx +61 -0
  96. package/src/css/global.css +123 -0
  97. package/src/css/index.css +1 -0
  98. package/src/hooks/index.ts +1 -0
  99. package/src/hooks/use-copy-to-clipboard.ts +31 -0
  100. package/src/index.ts +4 -0
  101. package/src/lib/utils.ts +6 -0
  102. package/src/locales/context.ts +8 -0
  103. package/src/locales/hooks.ts +20 -0
  104. package/src/locales/index.ts +3 -0
  105. package/src/locales/langs/en.ts +17 -0
  106. package/src/locales/langs/index.ts +12 -0
  107. package/src/locales/langs/zh-cn.ts +18 -0
  108. package/tsconfig.json +21 -0
  109. package/tsup.config.ts +21 -0
@@ -0,0 +1,123 @@
1
+ @import "tailwindcss";
2
+ @import "tw-animate-css";
3
+
4
+ @custom-variant dark (&:is(.dark *));
5
+
6
+ :root {
7
+ --background: oklch(1 0 0);
8
+ --foreground: oklch(0.145 0 0);
9
+ --card: oklch(1 0 0);
10
+ --card-foreground: oklch(0.145 0 0);
11
+ --popover: oklch(1 0 0);
12
+ --popover-foreground: oklch(0.145 0 0);
13
+ --primary: oklch(0.205 0 0);
14
+ --primary-foreground: oklch(0.985 0 0);
15
+ --secondary: oklch(0.97 0 0);
16
+ --secondary-foreground: oklch(0.205 0 0);
17
+ --muted: oklch(0.97 0 0);
18
+ --muted-foreground: oklch(0.556 0 0);
19
+ --accent: oklch(0.97 0 0);
20
+ --accent-foreground: oklch(0.205 0 0);
21
+ --destructive: oklch(0.577 0.245 27.325);
22
+ --destructive-foreground: oklch(0.577 0.245 27.325);
23
+ --border: oklch(0.922 0 0);
24
+ --input: oklch(0.922 0 0);
25
+ --ring: oklch(0.708 0 0);
26
+ --chart-1: oklch(0.646 0.222 41.116);
27
+ --chart-2: oklch(0.6 0.118 184.704);
28
+ --chart-3: oklch(0.398 0.07 227.392);
29
+ --chart-4: oklch(0.828 0.189 84.429);
30
+ --chart-5: oklch(0.769 0.188 70.08);
31
+ --radius: 0.625rem;
32
+ --sidebar: oklch(0.985 0 0);
33
+ --sidebar-foreground: oklch(0.145 0 0);
34
+ --sidebar-primary: oklch(0.205 0 0);
35
+ --sidebar-primary-foreground: oklch(0.985 0 0);
36
+ --sidebar-accent: oklch(0.97 0 0);
37
+ --sidebar-accent-foreground: oklch(0.205 0 0);
38
+ --sidebar-border: oklch(0.922 0 0);
39
+ --sidebar-ring: oklch(0.708 0 0);
40
+ }
41
+
42
+ .dark {
43
+ --background: oklch(0.145 0 0);
44
+ --foreground: oklch(0.985 0 0);
45
+ --card: oklch(0.145 0 0);
46
+ --card-foreground: oklch(0.985 0 0);
47
+ --popover: oklch(0.145 0 0);
48
+ --popover-foreground: oklch(0.985 0 0);
49
+ --primary: oklch(0.985 0 0);
50
+ --primary-foreground: oklch(0.205 0 0);
51
+ --secondary: oklch(0.269 0 0);
52
+ --secondary-foreground: oklch(0.985 0 0);
53
+ --muted: oklch(0.269 0 0);
54
+ --muted-foreground: oklch(0.708 0 0);
55
+ --accent: oklch(0.269 0 0);
56
+ --accent-foreground: oklch(0.985 0 0);
57
+ --destructive: oklch(0.396 0.141 25.723);
58
+ --destructive-foreground: oklch(0.637 0.237 25.331);
59
+ --border: oklch(0.269 0 0);
60
+ --input: oklch(0.269 0 0);
61
+ --ring: oklch(0.439 0 0);
62
+ --chart-1: oklch(0.488 0.243 264.376);
63
+ --chart-2: oklch(0.696 0.17 162.48);
64
+ --chart-3: oklch(0.769 0.188 70.08);
65
+ --chart-4: oklch(0.627 0.265 303.9);
66
+ --chart-5: oklch(0.645 0.246 16.439);
67
+ --sidebar: oklch(0.205 0 0);
68
+ --sidebar-foreground: oklch(0.985 0 0);
69
+ --sidebar-primary: oklch(0.488 0.243 264.376);
70
+ --sidebar-primary-foreground: oklch(0.985 0 0);
71
+ --sidebar-accent: oklch(0.269 0 0);
72
+ --sidebar-accent-foreground: oklch(0.985 0 0);
73
+ --sidebar-border: oklch(0.269 0 0);
74
+ --sidebar-ring: oklch(0.439 0 0);
75
+ }
76
+
77
+ @theme inline {
78
+ --color-background: var(--background);
79
+ --color-foreground: var(--foreground);
80
+ --color-card: var(--card);
81
+ --color-card-foreground: var(--card-foreground);
82
+ --color-popover: var(--popover);
83
+ --color-popover-foreground: var(--popover-foreground);
84
+ --color-primary: var(--primary);
85
+ --color-primary-foreground: var(--primary-foreground);
86
+ --color-secondary: var(--secondary);
87
+ --color-secondary-foreground: var(--secondary-foreground);
88
+ --color-muted: var(--muted);
89
+ --color-muted-foreground: var(--muted-foreground);
90
+ --color-accent: var(--accent);
91
+ --color-accent-foreground: var(--accent-foreground);
92
+ --color-destructive: var(--destructive);
93
+ --color-destructive-foreground: var(--destructive-foreground);
94
+ --color-border: var(--border);
95
+ --color-input: var(--input);
96
+ --color-ring: var(--ring);
97
+ --color-chart-1: var(--chart-1);
98
+ --color-chart-2: var(--chart-2);
99
+ --color-chart-3: var(--chart-3);
100
+ --color-chart-4: var(--chart-4);
101
+ --color-chart-5: var(--chart-5);
102
+ --radius-sm: calc(var(--radius) - 4px);
103
+ --radius-md: calc(var(--radius) - 2px);
104
+ --radius-lg: var(--radius);
105
+ --radius-xl: calc(var(--radius) + 4px);
106
+ --color-sidebar: var(--sidebar);
107
+ --color-sidebar-foreground: var(--sidebar-foreground);
108
+ --color-sidebar-primary: var(--sidebar-primary);
109
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
110
+ --color-sidebar-accent: var(--sidebar-accent);
111
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
112
+ --color-sidebar-border: var(--sidebar-border);
113
+ --color-sidebar-ring: var(--sidebar-ring);
114
+ }
115
+
116
+ @layer base {
117
+ * {
118
+ @apply border-border outline-ring/50;
119
+ }
120
+ body {
121
+ @apply bg-background text-foreground;
122
+ }
123
+ }
@@ -0,0 +1 @@
1
+ @import "./global.css";
@@ -0,0 +1 @@
1
+ export * from "./use-copy-to-clipboard";
@@ -0,0 +1,31 @@
1
+ import { useState } from "react";
2
+
3
+ export interface useCopyToClipboardProps {
4
+ timeout?: number;
5
+ }
6
+
7
+ export function useCopyToClipboard({
8
+ timeout = 2000,
9
+ }: useCopyToClipboardProps = {}) {
10
+ const [isCopied, setIsCopied] = useState<Boolean>(false);
11
+
12
+ const copyToClipboard = (value: string) => {
13
+ if (typeof window === "undefined" || !navigator.clipboard?.writeText) {
14
+ return;
15
+ }
16
+
17
+ if (!value) {
18
+ return;
19
+ }
20
+
21
+ navigator.clipboard.writeText(value).then(() => {
22
+ setIsCopied(true);
23
+
24
+ setTimeout(() => {
25
+ setIsCopied(false);
26
+ }, timeout);
27
+ });
28
+ };
29
+
30
+ return { isCopied, copyToClipboard };
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ import "./css/index.css";
2
+
3
+ export { AgKitUI, type AgKitUIProps } from "./components";
4
+ export { type LocaleCode } from "./locales";
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs));
6
+ }
@@ -0,0 +1,8 @@
1
+ import { createContext } from "react";
2
+ import { LocaleCode } from "./langs";
3
+
4
+ export type LocaleContextProps = { locale: LocaleCode };
5
+
6
+ export const LocaleContext = createContext<LocaleContextProps>({
7
+ locale: "zh-CN",
8
+ });
@@ -0,0 +1,20 @@
1
+ import { useContext, useMemo } from "react";
2
+ import { Locale, LocaleCode, LocaleComponentName, locales } from "./langs";
3
+ import { LocaleContext } from "./context";
4
+
5
+ export function useLocale(): { locale: Locale; localeCode: LocaleCode };
6
+ export function useLocale<T extends LocaleComponentName>(
7
+ name: T
8
+ ): { locale: Locale[T]; localeCode: LocaleCode };
9
+ export function useLocale<T extends LocaleComponentName>(
10
+ name?: T
11
+ ): { locale: Locale | Locale[T]; localeCode: LocaleCode } {
12
+ const { locale: localeCode } = useContext(LocaleContext);
13
+
14
+ const locale = useMemo(() => {
15
+ const fullLocale = locales[localeCode] ?? locales["zh-CN"];
16
+ return name ? fullLocale[name] : fullLocale;
17
+ }, [localeCode, name]);
18
+
19
+ return { locale: locale as any, localeCode };
20
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./context";
2
+ export * from "./hooks";
3
+ export * from "./langs";
@@ -0,0 +1,17 @@
1
+ import type { Locale } from ".";
2
+
3
+ export const en: Locale = {
4
+ chat: {
5
+ emptyTitle: "How can I help you?",
6
+ },
7
+ input: {
8
+ placeholder: "Type your message...",
9
+ disclaimer: "AI-generated content, for reference only",
10
+ },
11
+ message: {
12
+ copy: "Copy",
13
+ copied: "Copied!",
14
+ copyToClipboard: "Copy to clipboard",
15
+ paused: "Generation paused",
16
+ },
17
+ };
@@ -0,0 +1,12 @@
1
+ import type { Locale, LocaleComponentName } from "./zh-cn";
2
+ import { zhCN } from "./zh-cn";
3
+ import { en } from "./en";
4
+
5
+ export { Locale, LocaleComponentName };
6
+
7
+ export const locales = {
8
+ "zh-CN": zhCN,
9
+ "en-US": en,
10
+ };
11
+
12
+ export type LocaleCode = keyof typeof locales;
@@ -0,0 +1,18 @@
1
+ export const zhCN = {
2
+ chat: {
3
+ emptyTitle: "有什么我可以帮到你?",
4
+ },
5
+ input: {
6
+ placeholder: "请输入消息...",
7
+ disclaimer: "内容由 AI 生成,仅供参考",
8
+ },
9
+ message: {
10
+ copy: "复制",
11
+ copied: "已复制",
12
+ copyToClipboard: "复制",
13
+ paused: "已暂停生成",
14
+ },
15
+ };
16
+
17
+ export type Locale = typeof zhCN;
18
+ export type LocaleComponentName = keyof Locale;
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "declaration": true,
7
+ "jsx": "react-jsx",
8
+ "outDir": "dist",
9
+ "strict": true,
10
+ "skipLibCheck": true,
11
+ "resolveJsonModule": true,
12
+ "esModuleInterop": true,
13
+ "baseUrl": ".",
14
+ "paths": {
15
+ "@/*": ["./src/*"]
16
+ },
17
+ "types": ["vite/client"]
18
+ },
19
+ "include": ["src/**/*", "example/**/*"],
20
+ "exclude": ["dist", "node_modules"]
21
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig({
4
+ entry: ["src/index.ts"],
5
+ outDir: "dist",
6
+ dts: {
7
+ compilerOptions: {
8
+ jsx: "react-jsx",
9
+ moduleResolution: "bundler",
10
+ baseUrl: ".",
11
+ paths: {
12
+ "@/*": ["./src/*"]
13
+ }
14
+ }
15
+ },
16
+ format: ["esm", "cjs"],
17
+ sourcemap: true,
18
+ clean: true,
19
+ tsconfig: "tsconfig.json",
20
+ external: ["react", "react-dom", "zustand"],
21
+ });