@assistant-ui/react 0.7.90 → 0.8.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 (298) hide show
  1. package/dist/cloud/auiV0.js.map +1 -1
  2. package/dist/cloud/auiV0.mjs.map +1 -1
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -3
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +0 -1
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/internal.d.ts +0 -1
  10. package/dist/internal.d.ts.map +1 -1
  11. package/dist/internal.js +0 -3
  12. package/dist/internal.js.map +1 -1
  13. package/dist/internal.mjs +0 -2
  14. package/dist/internal.mjs.map +1 -1
  15. package/dist/model-context/ModelContextTypes.d.ts +11 -0
  16. package/dist/model-context/ModelContextTypes.d.ts.map +1 -1
  17. package/dist/model-context/ModelContextTypes.js.map +1 -1
  18. package/dist/model-context/ModelContextTypes.mjs.map +1 -1
  19. package/dist/model-context/makeAssistantVisible.d.ts.map +1 -1
  20. package/dist/model-context/makeAssistantVisible.js +7 -3
  21. package/dist/model-context/makeAssistantVisible.js.map +1 -1
  22. package/dist/model-context/makeAssistantVisible.mjs +7 -3
  23. package/dist/model-context/makeAssistantVisible.mjs.map +1 -1
  24. package/dist/primitives/contentPart/index.d.ts +0 -1
  25. package/dist/primitives/contentPart/index.d.ts.map +1 -1
  26. package/dist/primitives/contentPart/index.js +0 -3
  27. package/dist/primitives/contentPart/index.js.map +1 -1
  28. package/dist/primitives/contentPart/index.mjs +0 -2
  29. package/dist/primitives/contentPart/index.mjs.map +1 -1
  30. package/dist/primitives/index.d.ts +0 -1
  31. package/dist/primitives/index.d.ts.map +1 -1
  32. package/dist/primitives/index.js +0 -3
  33. package/dist/primitives/index.js.map +1 -1
  34. package/dist/primitives/index.mjs +0 -2
  35. package/dist/primitives/index.mjs.map +1 -1
  36. package/dist/primitives/message/MessageContent.d.ts +1 -2
  37. package/dist/primitives/message/MessageContent.d.ts.map +1 -1
  38. package/dist/primitives/message/MessageContent.js +2 -7
  39. package/dist/primitives/message/MessageContent.js.map +1 -1
  40. package/dist/primitives/message/MessageContent.mjs +2 -7
  41. package/dist/primitives/message/MessageContent.mjs.map +1 -1
  42. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
  43. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +1 -3
  44. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
  45. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +1 -3
  46. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
  47. package/dist/runtimes/edge/converters/toCoreMessages.d.ts.map +1 -1
  48. package/dist/runtimes/edge/converters/toCoreMessages.js +1 -6
  49. package/dist/runtimes/edge/converters/toCoreMessages.js.map +1 -1
  50. package/dist/runtimes/edge/converters/toCoreMessages.mjs +1 -6
  51. package/dist/runtimes/edge/converters/toCoreMessages.mjs.map +1 -1
  52. package/dist/runtimes/edge/converters/toLanguageModelMessages.js.map +1 -1
  53. package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs.map +1 -1
  54. package/dist/runtimes/external-store/ThreadMessageLike.d.ts +2 -2
  55. package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
  56. package/dist/runtimes/external-store/ThreadMessageLike.js +0 -3
  57. package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
  58. package/dist/runtimes/external-store/ThreadMessageLike.mjs +0 -3
  59. package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
  60. package/dist/types/AssistantTypes.d.ts +3 -7
  61. package/dist/types/AssistantTypes.d.ts.map +1 -1
  62. package/dist/types/AssistantTypes.js.map +1 -1
  63. package/dist/types/ContentPartComponentTypes.d.ts +1 -3
  64. package/dist/types/ContentPartComponentTypes.d.ts.map +1 -1
  65. package/dist/types/ContentPartComponentTypes.js.map +1 -1
  66. package/dist/types/index.d.ts +1 -1
  67. package/dist/types/index.d.ts.map +1 -1
  68. package/dist/types/index.js.map +1 -1
  69. package/package.json +1 -21
  70. package/src/cloud/auiV0.ts +1 -1
  71. package/src/index.ts +0 -1
  72. package/src/internal.ts +0 -1
  73. package/src/model-context/ModelContextTypes.ts +19 -0
  74. package/src/model-context/makeAssistantVisible.tsx +9 -3
  75. package/src/primitives/contentPart/index.ts +0 -1
  76. package/src/primitives/index.ts +0 -1
  77. package/src/primitives/message/MessageContent.tsx +0 -9
  78. package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +1 -3
  79. package/src/runtimes/edge/converters/toCoreMessages.ts +11 -14
  80. package/src/runtimes/edge/converters/toLanguageModelMessages.ts +2 -2
  81. package/src/runtimes/external-store/ThreadMessageLike.tsx +0 -6
  82. package/src/types/AssistantTypes.ts +4 -9
  83. package/src/types/ContentPartComponentTypes.tsx +0 -4
  84. package/src/types/index.ts +0 -2
  85. package/dist/primitives/contentPart/ContentPartDisplay.d.ts +0 -9
  86. package/dist/primitives/contentPart/ContentPartDisplay.d.ts.map +0 -1
  87. package/dist/primitives/contentPart/ContentPartDisplay.js +0 -37
  88. package/dist/primitives/contentPart/ContentPartDisplay.js.map +0 -1
  89. package/dist/primitives/contentPart/ContentPartDisplay.mjs +0 -13
  90. package/dist/primitives/contentPart/ContentPartDisplay.mjs.map +0 -1
  91. package/dist/primitives/contentPart/useContentPartDisplay.d.ts +0 -8
  92. package/dist/primitives/contentPart/useContentPartDisplay.d.ts.map +0 -1
  93. package/dist/primitives/contentPart/useContentPartDisplay.js +0 -42
  94. package/dist/primitives/contentPart/useContentPartDisplay.js.map +0 -1
  95. package/dist/primitives/contentPart/useContentPartDisplay.mjs +0 -18
  96. package/dist/primitives/contentPart/useContentPartDisplay.mjs.map +0 -1
  97. package/dist/styles/index.css +0 -1261
  98. package/dist/styles/index.css.map +0 -1
  99. package/dist/styles/modal.css +0 -143
  100. package/dist/styles/modal.css.map +0 -1
  101. package/dist/styles/tailwindcss/base-components.css +0 -69
  102. package/dist/styles/tailwindcss/base-components.css.json +0 -48
  103. package/dist/styles/tailwindcss/modal.css +0 -29
  104. package/dist/styles/tailwindcss/modal.css.json +0 -26
  105. package/dist/styles/tailwindcss/thread.css +0 -262
  106. package/dist/styles/tailwindcss/thread.css.json +0 -183
  107. package/dist/styles/themes/default.css +0 -64
  108. package/dist/styles/themes/default.css.json +0 -46
  109. package/dist/styles/themes/shadcn-extras.css +0 -4
  110. package/dist/styles/themes/shadcn-extras.css.json +0 -5
  111. package/dist/tailwindcss/index.d.ts +0 -49
  112. package/dist/tailwindcss/index.d.ts.map +0 -1
  113. package/dist/tailwindcss/index.js +0 -189
  114. package/dist/tailwindcss/index.js.map +0 -1
  115. package/dist/tailwindcss/index.mjs +0 -181
  116. package/dist/tailwindcss/index.mjs.map +0 -1
  117. package/dist/ui/assistant-action-bar.d.ts +0 -24
  118. package/dist/ui/assistant-action-bar.d.ts.map +0 -1
  119. package/dist/ui/assistant-action-bar.js +0 -193
  120. package/dist/ui/assistant-action-bar.js.map +0 -1
  121. package/dist/ui/assistant-action-bar.mjs +0 -181
  122. package/dist/ui/assistant-action-bar.mjs.map +0 -1
  123. package/dist/ui/assistant-message.d.ts +0 -13
  124. package/dist/ui/assistant-message.d.ts.map +0 -1
  125. package/dist/ui/assistant-message.js +0 -107
  126. package/dist/ui/assistant-message.js.map +0 -1
  127. package/dist/ui/assistant-message.mjs +0 -77
  128. package/dist/ui/assistant-message.mjs.map +0 -1
  129. package/dist/ui/assistant-modal.d.ts +0 -23
  130. package/dist/ui/assistant-modal.d.ts.map +0 -1
  131. package/dist/ui/assistant-modal.js +0 -126
  132. package/dist/ui/assistant-modal.js.map +0 -1
  133. package/dist/ui/assistant-modal.mjs +0 -99
  134. package/dist/ui/assistant-modal.mjs.map +0 -1
  135. package/dist/ui/attachment-ui.d.ts +0 -12
  136. package/dist/ui/attachment-ui.d.ts.map +0 -1
  137. package/dist/ui/attachment-ui.js +0 -170
  138. package/dist/ui/attachment-ui.js.map +0 -1
  139. package/dist/ui/attachment-ui.mjs +0 -160
  140. package/dist/ui/attachment-ui.mjs.map +0 -1
  141. package/dist/ui/base/CircleStopIcon.d.ts +0 -3
  142. package/dist/ui/base/CircleStopIcon.d.ts.map +0 -1
  143. package/dist/ui/base/CircleStopIcon.js +0 -45
  144. package/dist/ui/base/CircleStopIcon.js.map +0 -1
  145. package/dist/ui/base/CircleStopIcon.mjs +0 -20
  146. package/dist/ui/base/CircleStopIcon.mjs.map +0 -1
  147. package/dist/ui/base/avatar.d.ts +0 -12
  148. package/dist/ui/base/avatar.d.ts.map +0 -1
  149. package/dist/ui/base/avatar.js +0 -69
  150. package/dist/ui/base/avatar.js.map +0 -1
  151. package/dist/ui/base/avatar.mjs +0 -31
  152. package/dist/ui/base/avatar.mjs.map +0 -1
  153. package/dist/ui/base/button.d.ts +0 -16
  154. package/dist/ui/base/button.d.ts.map +0 -1
  155. package/dist/ui/base/button.js +0 -66
  156. package/dist/ui/base/button.js.map +0 -1
  157. package/dist/ui/base/button.mjs +0 -40
  158. package/dist/ui/base/button.mjs.map +0 -1
  159. package/dist/ui/base/dialog.d.ts +0 -9
  160. package/dist/ui/base/dialog.d.ts.map +0 -1
  161. package/dist/ui/base/dialog.js +0 -80
  162. package/dist/ui/base/dialog.js.map +0 -1
  163. package/dist/ui/base/dialog.mjs +0 -40
  164. package/dist/ui/base/dialog.mjs.map +0 -1
  165. package/dist/ui/base/index.d.ts +0 -6
  166. package/dist/ui/base/index.d.ts.map +0 -1
  167. package/dist/ui/base/index.js +0 -55
  168. package/dist/ui/base/index.js.map +0 -1
  169. package/dist/ui/base/index.mjs +0 -25
  170. package/dist/ui/base/index.mjs.map +0 -1
  171. package/dist/ui/base/tooltip-icon-button.d.ts +0 -17
  172. package/dist/ui/base/tooltip-icon-button.d.ts.map +0 -1
  173. package/dist/ui/base/tooltip-icon-button.js +0 -44
  174. package/dist/ui/base/tooltip-icon-button.js.map +0 -1
  175. package/dist/ui/base/tooltip-icon-button.mjs +0 -19
  176. package/dist/ui/base/tooltip-icon-button.mjs.map +0 -1
  177. package/dist/ui/base/tooltip.d.ts +0 -6
  178. package/dist/ui/base/tooltip.d.ts.map +0 -1
  179. package/dist/ui/base/tooltip.js +0 -57
  180. package/dist/ui/base/tooltip.js.map +0 -1
  181. package/dist/ui/base/tooltip.mjs +0 -20
  182. package/dist/ui/base/tooltip.mjs.map +0 -1
  183. package/dist/ui/branch-picker.d.ts +0 -15
  184. package/dist/ui/branch-picker.d.ts.map +0 -1
  185. package/dist/ui/branch-picker.js +0 -89
  186. package/dist/ui/branch-picker.js.map +0 -1
  187. package/dist/ui/branch-picker.mjs +0 -69
  188. package/dist/ui/branch-picker.mjs.map +0 -1
  189. package/dist/ui/composer.d.ts +0 -25
  190. package/dist/ui/composer.d.ts.map +0 -1
  191. package/dist/ui/composer.js +0 -168
  192. package/dist/ui/composer.js.map +0 -1
  193. package/dist/ui/composer.mjs +0 -138
  194. package/dist/ui/composer.mjs.map +0 -1
  195. package/dist/ui/content-part.d.ts +0 -7
  196. package/dist/ui/content-part.d.ts.map +0 -1
  197. package/dist/ui/content-part.js +0 -61
  198. package/dist/ui/content-part.js.map +0 -1
  199. package/dist/ui/content-part.mjs +0 -27
  200. package/dist/ui/content-part.mjs.map +0 -1
  201. package/dist/ui/edit-composer.d.ts +0 -22
  202. package/dist/ui/edit-composer.d.ts.map +0 -1
  203. package/dist/ui/edit-composer.js +0 -77
  204. package/dist/ui/edit-composer.js.map +0 -1
  205. package/dist/ui/edit-composer.mjs +0 -57
  206. package/dist/ui/edit-composer.mjs.map +0 -1
  207. package/dist/ui/index.d.ts +0 -75
  208. package/dist/ui/index.d.ts.map +0 -1
  209. package/dist/ui/index.js +0 -86
  210. package/dist/ui/index.js.map +0 -1
  211. package/dist/ui/index.mjs +0 -38
  212. package/dist/ui/index.mjs.map +0 -1
  213. package/dist/ui/thread-config.d.ts +0 -162
  214. package/dist/ui/thread-config.d.ts.map +0 -1
  215. package/dist/ui/thread-config.js +0 -63
  216. package/dist/ui/thread-config.js.map +0 -1
  217. package/dist/ui/thread-config.mjs +0 -41
  218. package/dist/ui/thread-config.mjs.map +0 -1
  219. package/dist/ui/thread-list-item.d.ts +0 -13
  220. package/dist/ui/thread-list-item.d.ts.map +0 -1
  221. package/dist/ui/thread-list-item.js +0 -94
  222. package/dist/ui/thread-list-item.js.map +0 -1
  223. package/dist/ui/thread-list-item.mjs +0 -64
  224. package/dist/ui/thread-list-item.mjs.map +0 -1
  225. package/dist/ui/thread-list.d.ts +0 -27
  226. package/dist/ui/thread-list.d.ts.map +0 -1
  227. package/dist/ui/thread-list.js +0 -91
  228. package/dist/ui/thread-list.js.map +0 -1
  229. package/dist/ui/thread-list.mjs +0 -61
  230. package/dist/ui/thread-list.mjs.map +0 -1
  231. package/dist/ui/thread-welcome.d.ts +0 -21
  232. package/dist/ui/thread-welcome.d.ts.map +0 -1
  233. package/dist/ui/thread-welcome.js +0 -101
  234. package/dist/ui/thread-welcome.js.map +0 -1
  235. package/dist/ui/thread-welcome.mjs +0 -81
  236. package/dist/ui/thread-welcome.mjs.map +0 -1
  237. package/dist/ui/thread.d.ts +0 -30
  238. package/dist/ui/thread.d.ts.map +0 -1
  239. package/dist/ui/thread.js +0 -152
  240. package/dist/ui/thread.js.map +0 -1
  241. package/dist/ui/thread.mjs +0 -125
  242. package/dist/ui/thread.mjs.map +0 -1
  243. package/dist/ui/user-action-bar.d.ts +0 -16
  244. package/dist/ui/user-action-bar.d.ts.map +0 -1
  245. package/dist/ui/user-action-bar.js +0 -63
  246. package/dist/ui/user-action-bar.js.map +0 -1
  247. package/dist/ui/user-action-bar.mjs +0 -43
  248. package/dist/ui/user-action-bar.mjs.map +0 -1
  249. package/dist/ui/user-message.d.ts +0 -13
  250. package/dist/ui/user-message.d.ts.map +0 -1
  251. package/dist/ui/user-message.js +0 -96
  252. package/dist/ui/user-message.js.map +0 -1
  253. package/dist/ui/user-message.mjs +0 -65
  254. package/dist/ui/user-message.mjs.map +0 -1
  255. package/dist/ui/utils/withDefaults.d.ts +0 -7
  256. package/dist/ui/utils/withDefaults.d.ts.map +0 -1
  257. package/dist/ui/utils/withDefaults.js +0 -66
  258. package/dist/ui/utils/withDefaults.js.map +0 -1
  259. package/dist/ui/utils/withDefaults.mjs +0 -30
  260. package/dist/ui/utils/withDefaults.mjs.map +0 -1
  261. package/src/primitives/contentPart/ContentPartDisplay.tsx +0 -20
  262. package/src/primitives/contentPart/useContentPartDisplay.tsx +0 -21
  263. package/src/styles/base.css +0 -37
  264. package/src/styles/index.css +0 -4
  265. package/src/styles/modal.css +0 -1
  266. package/src/styles/tailwindcss/base-components.css +0 -69
  267. package/src/styles/tailwindcss/modal.css +0 -29
  268. package/src/styles/tailwindcss/thread.css +0 -262
  269. package/src/styles/themes/default.css +0 -64
  270. package/src/styles/themes/shadcn-extras.css +0 -4
  271. package/src/tailwindcss/index.ts +0 -149
  272. package/src/ui/assistant-action-bar.tsx +0 -301
  273. package/src/ui/assistant-message.tsx +0 -96
  274. package/src/ui/assistant-modal.tsx +0 -146
  275. package/src/ui/attachment-ui.tsx +0 -211
  276. package/src/ui/base/CircleStopIcon.tsx +0 -17
  277. package/src/ui/base/avatar.tsx +0 -41
  278. package/src/ui/base/button.tsx +0 -42
  279. package/src/ui/base/dialog.tsx +0 -113
  280. package/src/ui/base/index.ts +0 -15
  281. package/src/ui/base/tooltip-icon-button.tsx +0 -29
  282. package/src/ui/base/tooltip.tsx +0 -22
  283. package/src/ui/branch-picker.tsx +0 -117
  284. package/src/ui/composer.tsx +0 -210
  285. package/src/ui/content-part.tsx +0 -23
  286. package/src/ui/edit-composer.tsx +0 -98
  287. package/src/ui/index.ts +0 -98
  288. package/src/ui/thread-config.tsx +0 -246
  289. package/src/ui/thread-list-item.tsx +0 -91
  290. package/src/ui/thread-list.tsx +0 -78
  291. package/src/ui/thread-welcome.tsx +0 -140
  292. package/src/ui/thread.tsx +0 -176
  293. package/src/ui/user-action-bar.tsx +0 -66
  294. package/src/ui/user-message.tsx +0 -92
  295. package/src/ui/utils/withDefaults.tsx +0 -35
  296. package/tailwindcss/README.md +0 -1
  297. package/tailwindcss/package-lock.json +0 -6
  298. package/tailwindcss/package.json +0 -5
@@ -1,211 +0,0 @@
1
- "use client";
2
-
3
- import {
4
- forwardRef,
5
- PropsWithChildren,
6
- useEffect,
7
- useState,
8
- type FC,
9
- } from "react";
10
- import { CircleXIcon, FileIcon } from "lucide-react";
11
- import { withDefaults } from "./utils/withDefaults";
12
- import { useThreadConfig } from "./thread-config";
13
- import { TooltipIconButton } from "./base/tooltip-icon-button";
14
- import { AttachmentPrimitive } from "../primitives";
15
- import { useAttachment } from "../context/react/AttachmentContext";
16
- import {
17
- AvatarImage,
18
- AvatarRoot,
19
- Tooltip,
20
- TooltipContent,
21
- TooltipTrigger,
22
- } from "./base";
23
- import { Dialog, DialogTrigger, DialogContent } from "./base/dialog";
24
- import { AvatarFallback } from "@radix-ui/react-avatar";
25
- import { useShallow } from "zustand/shallow";
26
- import { DialogTitle } from "@radix-ui/react-dialog";
27
-
28
- const AttachmentRoot = withDefaults(AttachmentPrimitive.Root, {
29
- className: "aui-attachment-root",
30
- });
31
-
32
- const AttachmentContent = withDefaults("div", {
33
- className: "aui-attachment-content",
34
- });
35
-
36
- AttachmentRoot.displayName = "AttachmentRoot";
37
-
38
- const useFileSrc = (file: File | undefined) => {
39
- const [src, setSrc] = useState<string | undefined>(undefined);
40
-
41
- useEffect(() => {
42
- if (!file) {
43
- setSrc(undefined);
44
- return;
45
- }
46
-
47
- const objectUrl = URL.createObjectURL(file);
48
- setSrc(objectUrl);
49
-
50
- return () => {
51
- URL.revokeObjectURL(objectUrl);
52
- };
53
- }, [file]);
54
-
55
- return src;
56
- };
57
-
58
- const useAttachmentSrc = () => {
59
- const { file, src } = useAttachment(
60
- useShallow((a): { file?: File; src?: string } => {
61
- if (a.type !== "image") return {};
62
- if (a.file) return { file: a.file };
63
- const src = a.content?.filter((c) => c.type === "image")[0]?.image;
64
- if (!src) return {};
65
- return { src };
66
- }),
67
- );
68
-
69
- return useFileSrc(file) ?? src;
70
- };
71
-
72
- type AttachmentPreviewProps = {
73
- src: string;
74
- };
75
-
76
- const AttachmentPreview: FC<AttachmentPreviewProps> = ({ src }) => {
77
- const [isLoaded, setIsLoaded] = useState(false);
78
-
79
- return (
80
- // eslint-disable-next-line @next/next/no-img-element
81
- <img
82
- src={src}
83
- style={{
84
- width: "auto",
85
- height: "auto",
86
- maxWidth: "75dvh",
87
- maxHeight: "75dvh",
88
- display: isLoaded ? "block" : "none",
89
- overflow: "clip",
90
- }}
91
- onLoad={() => setIsLoaded(true)}
92
- alt="Image Preview"
93
- />
94
- );
95
- };
96
-
97
- const AttachmentPreviewDialog: FC<PropsWithChildren> = ({ children }) => {
98
- const src = useAttachmentSrc();
99
-
100
- if (!src) return children;
101
-
102
- return (
103
- <Dialog>
104
- <DialogTrigger className="aui-attachment-preview-trigger" asChild>
105
- {children}
106
- </DialogTrigger>
107
- <DialogContent>
108
- <DialogTitle className="aui-sr-only">
109
- Image Attachment Preview
110
- </DialogTitle>
111
- <AttachmentPreview src={src} />
112
- </DialogContent>
113
- </Dialog>
114
- );
115
- };
116
-
117
- const AttachmentThumb: FC = () => {
118
- const isImage = useAttachment((a) => a.type === "image");
119
- const src = useAttachmentSrc();
120
- return (
121
- <AvatarRoot className="aui-attachment-thumb">
122
- <AvatarFallback delayMs={isImage ? 200 : 0}>
123
- <FileIcon />
124
- </AvatarFallback>
125
- <AvatarImage src={src}></AvatarImage>
126
- </AvatarRoot>
127
- );
128
- };
129
-
130
- const AttachmentUI: FC = () => {
131
- const canRemove = useAttachment((a) => a.source !== "message");
132
- const typeLabel = useAttachment((a) => {
133
- const type = a.type;
134
- switch (type) {
135
- case "image":
136
- return "Image";
137
- case "document":
138
- return "Document";
139
- case "file":
140
- return "File";
141
- default:
142
- const _exhaustiveCheck: never = type;
143
- throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
144
- }
145
- });
146
- return (
147
- <Tooltip>
148
- <AttachmentRoot>
149
- <AttachmentPreviewDialog>
150
- <TooltipTrigger asChild>
151
- <AttachmentContent>
152
- <AttachmentThumb />
153
- <div className="aui-attachment-text">
154
- <p className="aui-attachment-name">
155
- <AttachmentPrimitive.Name />
156
- </p>
157
- <p className="aui-attachment-type">{typeLabel}</p>
158
- </div>
159
- </AttachmentContent>
160
- </TooltipTrigger>
161
- </AttachmentPreviewDialog>
162
- {canRemove && <AttachmentRemove />}
163
- </AttachmentRoot>
164
- <TooltipContent side="top">
165
- <AttachmentPrimitive.Name />
166
- </TooltipContent>
167
- </Tooltip>
168
- );
169
- };
170
-
171
- AttachmentUI.displayName = "Attachment";
172
-
173
- namespace AttachmentRemove {
174
- export type Element = HTMLButtonElement;
175
- export type Props = Partial<TooltipIconButton.Props>;
176
- }
177
-
178
- const AttachmentRemove = forwardRef<
179
- AttachmentRemove.Element,
180
- AttachmentRemove.Props
181
- >((props, ref) => {
182
- const {
183
- strings: {
184
- composer: { removeAttachment: { tooltip = "Remove file" } = {} } = {},
185
- } = {},
186
- } = useThreadConfig();
187
-
188
- return (
189
- <AttachmentPrimitive.Remove asChild>
190
- <TooltipIconButton
191
- tooltip={tooltip}
192
- className="aui-attachment-remove"
193
- side="top"
194
- {...props}
195
- ref={ref}
196
- >
197
- {props.children ?? <CircleXIcon />}
198
- </TooltipIconButton>
199
- </AttachmentPrimitive.Remove>
200
- );
201
- });
202
-
203
- AttachmentRemove.displayName = "AttachmentRemove";
204
-
205
- const exports = {
206
- Root: AttachmentRoot,
207
- Remove: AttachmentRemove,
208
- };
209
-
210
- export default Object.assign(AttachmentUI, exports) as typeof AttachmentUI &
211
- typeof exports;
@@ -1,17 +0,0 @@
1
- import { FC } from "react";
2
-
3
- export const CircleStopIcon: FC = () => {
4
- return (
5
- <svg
6
- xmlns="http://www.w3.org/2000/svg"
7
- viewBox="0 0 16 16"
8
- fill="currentColor"
9
- width="16"
10
- height="16"
11
- >
12
- <rect width="10" height="10" x="3" y="3" rx="2" />
13
- </svg>
14
- );
15
- };
16
-
17
- CircleStopIcon.displayName = "CircleStopIcon";
@@ -1,41 +0,0 @@
1
- import type { FC } from "react";
2
- import * as AvatarPrimitive from "@radix-ui/react-avatar";
3
-
4
- import { withDefaults } from "../utils/withDefaults";
5
-
6
- export type AvatarProps = {
7
- src?: string | undefined;
8
- alt?: string | undefined;
9
- fallback?: string | undefined;
10
- };
11
-
12
- export const Avatar: FC<AvatarProps> = ({ src, alt, fallback }) => {
13
- if (src == null && fallback == null) return null;
14
-
15
- return (
16
- <AvatarRoot>
17
- {src != null && <AvatarImage src={src} alt={alt} />}
18
- {fallback != null && <AvatarFallback>{fallback}</AvatarFallback>}
19
- </AvatarRoot>
20
- );
21
- };
22
-
23
- Avatar.displayName = "Avatar";
24
-
25
- export const AvatarRoot = withDefaults(AvatarPrimitive.Root, {
26
- className: "aui-avatar-root",
27
- });
28
-
29
- AvatarRoot.displayName = "AvatarRoot";
30
-
31
- export const AvatarImage = withDefaults(AvatarPrimitive.Image, {
32
- className: "aui-avatar-image",
33
- });
34
-
35
- AvatarImage.displayName = "AvatarImage";
36
-
37
- export const AvatarFallback = withDefaults(AvatarPrimitive.Fallback, {
38
- className: "aui-avatar-fallback",
39
- });
40
-
41
- AvatarFallback.displayName = "AvatarFallback";
@@ -1,42 +0,0 @@
1
- import { cva, type VariantProps } from "class-variance-authority";
2
- import { Primitive } from "@radix-ui/react-primitive";
3
- import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from "react";
4
-
5
- const buttonVariants = cva("aui-button", {
6
- variants: {
7
- variant: {
8
- default: "aui-button-primary",
9
- outline: "aui-button-outline",
10
- ghost: "aui-button-ghost",
11
- },
12
- size: {
13
- default: "aui-button-medium",
14
- icon: "aui-button-icon",
15
- },
16
- },
17
- defaultVariants: {
18
- variant: "default",
19
- size: "default",
20
- },
21
- });
22
-
23
- type ButtonElement = ComponentRef<typeof Primitive.button>;
24
-
25
- export type ButtonProps = ComponentPropsWithoutRef<typeof Primitive.button> &
26
- VariantProps<typeof buttonVariants>;
27
-
28
- const Button = forwardRef<ButtonElement, ButtonProps>(
29
- ({ className, variant, size, ...props }, ref) => {
30
- return (
31
- <Primitive.button
32
- className={buttonVariants({ variant, size, className })}
33
- {...props}
34
- ref={ref}
35
- />
36
- );
37
- },
38
- );
39
-
40
- Button.displayName = "Button";
41
-
42
- export { Button, buttonVariants };
@@ -1,113 +0,0 @@
1
- import * as DialogPrimitive from "@radix-ui/react-dialog";
2
-
3
- import classNames from "classnames";
4
- import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from "react";
5
-
6
- const Dialog = DialogPrimitive.Root;
7
-
8
- const DialogTrigger = DialogPrimitive.Trigger;
9
-
10
- const DialogPortal = DialogPrimitive.Portal;
11
-
12
- const DialogClose = DialogPrimitive.Close;
13
-
14
- const DialogOverlay = forwardRef<
15
- ComponentRef<typeof DialogPrimitive.Overlay>,
16
- ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
17
- >(({ className, ...props }, ref) => (
18
- <DialogPrimitive.Overlay
19
- ref={ref}
20
- className={classNames("aui-dialog-overlay", className)}
21
- {...props}
22
- />
23
- ));
24
- DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
25
-
26
- const DialogContent = forwardRef<
27
- ComponentRef<typeof DialogPrimitive.Content>,
28
- ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
29
- >(({ className, children, ...props }, ref) => (
30
- <DialogPortal>
31
- <DialogOverlay />
32
- <DialogPrimitive.Content
33
- ref={ref}
34
- className={classNames("aui-dialog-content", className)}
35
- {...props}
36
- >
37
- {children}
38
- {/* <DialogPrimitive.Close className="ring-offset-aui-background focus:ring-aui-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none">
39
- <XIcon className="h-4 w-4" />
40
- <span className="sr-only">Close</span>
41
- </DialogPrimitive.Close> */}
42
- </DialogPrimitive.Content>
43
- </DialogPortal>
44
- ));
45
- DialogContent.displayName = DialogPrimitive.Content.displayName;
46
-
47
- // const DialogHeader = ({
48
- // className,
49
- // ...props
50
- // }: HTMLAttributes<HTMLDivElement>) => (
51
- // <div
52
- // className={classNames(
53
- // "flex flex-col space-y-1.5 text-center sm:text-left",
54
- // className,
55
- // )}
56
- // {...props}
57
- // />
58
- // );
59
- // DialogHeader.displayName = "DialogHeader";
60
-
61
- // const DialogFooter = ({
62
- // className,
63
- // ...props
64
- // }: HTMLAttributes<HTMLDivElement>) => (
65
- // <div
66
- // className={classNames(
67
- // "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
68
- // className,
69
- // )}
70
- // {...props}
71
- // />
72
- // );
73
- // DialogFooter.displayName = "DialogFooter";
74
-
75
- // const DialogTitle = forwardRef<
76
- // ComponentRef<typeof DialogPrimitive.Title>,
77
- // ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
78
- // >(({ className, ...props }, ref) => (
79
- // <DialogPrimitive.Title
80
- // ref={ref}
81
- // className={classNames(
82
- // "text-lg font-semibold leading-none tracking-tight",
83
- // className,
84
- // )}
85
- // {...props}
86
- // />
87
- // ));
88
- // DialogTitle.displayName = DialogPrimitive.Title.displayName;
89
-
90
- // const DialogDescription = forwardRef<
91
- // ComponentRef<typeof DialogPrimitive.Description>,
92
- // ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
93
- // >(({ className, ...props }, ref) => (
94
- // <DialogPrimitive.Description
95
- // ref={ref}
96
- // className={classNames("text-muted-foreground text-sm", className)}
97
- // {...props}
98
- // />
99
- // ));
100
- // DialogDescription.displayName = DialogPrimitive.Description.displayName;
101
-
102
- export {
103
- Dialog,
104
- DialogPortal,
105
- DialogOverlay,
106
- DialogTrigger,
107
- DialogClose,
108
- DialogContent,
109
- // DialogHeader,
110
- // DialogFooter,
111
- // DialogTitle,
112
- // DialogDescription,
113
- };
@@ -1,15 +0,0 @@
1
- export {
2
- Avatar,
3
- AvatarRoot,
4
- AvatarImage,
5
- AvatarFallback,
6
- type AvatarProps,
7
- } from "./avatar";
8
-
9
- export { Button, buttonVariants, type ButtonProps } from "./button";
10
-
11
- export { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
12
-
13
- export { TooltipIconButton } from "./tooltip-icon-button";
14
-
15
- export { CircleStopIcon } from "./CircleStopIcon";
@@ -1,29 +0,0 @@
1
- import { forwardRef } from "react";
2
- import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
3
- import { Button, ButtonProps } from "./button";
4
-
5
- export namespace TooltipIconButton {
6
- export type Props = ButtonProps & {
7
- tooltip: string;
8
- side?: "top" | "bottom" | "left" | "right";
9
- };
10
- }
11
-
12
- export const TooltipIconButton = forwardRef<
13
- HTMLButtonElement,
14
- TooltipIconButton.Props
15
- >(({ children, tooltip, side = "bottom", ...rest }, ref) => {
16
- return (
17
- <Tooltip>
18
- <TooltipTrigger asChild>
19
- <Button variant="ghost" size="icon" {...rest} ref={ref}>
20
- {children}
21
- <span className="aui-sr-only">{tooltip}</span>
22
- </Button>
23
- </TooltipTrigger>
24
- <TooltipContent side={side}>{tooltip}</TooltipContent>
25
- </Tooltip>
26
- );
27
- });
28
-
29
- TooltipIconButton.displayName = "TooltipIconButton";
@@ -1,22 +0,0 @@
1
- import * as TooltipPrimitive from "@radix-ui/react-tooltip";
2
- import { withDefaults } from "../utils/withDefaults";
3
- import { FC } from "react";
4
-
5
- export const Tooltip: FC<TooltipPrimitive.TooltipProps> = (props) => {
6
- return (
7
- <TooltipPrimitive.Provider>
8
- <TooltipPrimitive.Root {...props} />
9
- </TooltipPrimitive.Provider>
10
- );
11
- };
12
-
13
- Tooltip.displayName = "Tooltip";
14
-
15
- export const TooltipTrigger = TooltipPrimitive.Trigger;
16
-
17
- export const TooltipContent = withDefaults(TooltipPrimitive.Content, {
18
- sideOffset: 4,
19
- className: "aui-tooltip-content",
20
- });
21
-
22
- TooltipContent.displayName = "TooltipContent";
@@ -1,117 +0,0 @@
1
- "use client";
2
-
3
- import { ComponentPropsWithoutRef, forwardRef, type FC } from "react";
4
- import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
5
-
6
- import { TooltipIconButton } from "./base/tooltip-icon-button";
7
- import { withDefaults } from "./utils/withDefaults";
8
- import { useThreadConfig } from "./thread-config";
9
- import { BranchPickerPrimitive } from "../primitives";
10
- import { useThread } from "../context";
11
-
12
- const useAllowBranchPicker = (ensureCapability = false) => {
13
- const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
14
- const branchPickerSupported = useThread((t) => t.capabilities.edit);
15
- return allowBranchPicker && (!ensureCapability || branchPickerSupported);
16
- };
17
-
18
- const BranchPicker: FC = () => {
19
- const allowBranchPicker = useAllowBranchPicker(true);
20
- if (!allowBranchPicker) return null;
21
- return (
22
- <BranchPickerRoot hideWhenSingleBranch>
23
- <BranchPickerPrevious />
24
- <BranchPickerState />
25
- <BranchPickerNext />
26
- </BranchPickerRoot>
27
- );
28
- };
29
-
30
- BranchPicker.displayName = "BranchPicker";
31
-
32
- const BranchPickerRoot = withDefaults(BranchPickerPrimitive.Root, {
33
- className: "aui-branch-picker-root",
34
- });
35
-
36
- BranchPickerRoot.displayName = "BranchPickerRoot";
37
-
38
- namespace BranchPickerPrevious {
39
- export type Element = BranchPickerPrimitive.Previous.Element;
40
- export type Props = Partial<TooltipIconButton.Props>;
41
- }
42
-
43
- const BranchPickerPrevious = forwardRef<
44
- BranchPickerPrevious.Element,
45
- BranchPickerPrevious.Props
46
- >((props, ref) => {
47
- const {
48
- strings: {
49
- branchPicker: { previous: { tooltip = "Previous" } = {} } = {},
50
- } = {},
51
- } = useThreadConfig();
52
- const allowBranchPicker = useAllowBranchPicker();
53
- return (
54
- <BranchPickerPrimitive.Previous disabled={!allowBranchPicker} asChild>
55
- <TooltipIconButton tooltip={tooltip} {...props} ref={ref}>
56
- {props.children ?? <ChevronLeftIcon />}
57
- </TooltipIconButton>
58
- </BranchPickerPrimitive.Previous>
59
- );
60
- });
61
-
62
- BranchPickerPrevious.displayName = "BranchPickerPrevious";
63
-
64
- const BranchPickerStateWrapper = withDefaults("span", {
65
- className: "aui-branch-picker-state",
66
- });
67
-
68
- namespace BranchPickerState {
69
- export type Element = HTMLSpanElement;
70
- export type Props = ComponentPropsWithoutRef<"span">;
71
- }
72
-
73
- const BranchPickerState = forwardRef<
74
- BranchPickerState.Element,
75
- BranchPickerState.Props
76
- >((props, ref) => {
77
- return (
78
- <BranchPickerStateWrapper {...props} ref={ref}>
79
- <BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />
80
- </BranchPickerStateWrapper>
81
- );
82
- });
83
-
84
- BranchPickerState.displayName = "BranchPickerState";
85
-
86
- namespace BranchPickerNext {
87
- export type Element = BranchPickerPrimitive.Next.Element;
88
- export type Props = Partial<TooltipIconButton.Props>;
89
- }
90
-
91
- const BranchPickerNext = forwardRef<
92
- BranchPickerNext.Element,
93
- BranchPickerNext.Props
94
- >((props, ref) => {
95
- const {
96
- strings: { branchPicker: { next: { tooltip = "Next" } = {} } = {} } = {},
97
- } = useThreadConfig();
98
- const allowBranchPicker = useAllowBranchPicker();
99
- return (
100
- <BranchPickerPrimitive.Next disabled={!allowBranchPicker} asChild>
101
- <TooltipIconButton tooltip={tooltip} {...props} ref={ref}>
102
- {props.children ?? <ChevronRightIcon />}
103
- </TooltipIconButton>
104
- </BranchPickerPrimitive.Next>
105
- );
106
- });
107
-
108
- BranchPickerNext.displayName = "BranchPickerNext";
109
-
110
- const exports = {
111
- Root: BranchPickerRoot,
112
- Previous: BranchPickerPrevious,
113
- Next: BranchPickerNext,
114
- };
115
-
116
- export default Object.assign(BranchPicker, exports) as typeof BranchPicker &
117
- typeof exports;