@superxd-studio/adptr 0.5.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 (221) hide show
  1. package/GENERATIVE.md +101 -0
  2. package/INTERACTIONS.md +51 -0
  3. package/LICENSE +21 -0
  4. package/README.md +57 -0
  5. package/REUSE.md +170 -0
  6. package/REVIEW.md +68 -0
  7. package/THIRD-PARTY-NOTICES.md +28 -0
  8. package/ai-sdk/index.js +96 -0
  9. package/assets/ibm-plex-mono-cyrillic-400-normal.woff2 +0 -0
  10. package/assets/ibm-plex-mono-cyrillic-500-normal.woff2 +0 -0
  11. package/assets/ibm-plex-mono-cyrillic-ext-400-normal.woff2 +0 -0
  12. package/assets/ibm-plex-mono-cyrillic-ext-500-normal.woff2 +0 -0
  13. package/assets/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  14. package/assets/ibm-plex-mono-latin-500-normal.woff2 +0 -0
  15. package/assets/ibm-plex-mono-latin-ext-400-normal.woff2 +0 -0
  16. package/assets/ibm-plex-mono-latin-ext-500-normal.woff2 +0 -0
  17. package/assets/ibm-plex-mono-vietnamese-400-normal.woff2 +0 -0
  18. package/assets/ibm-plex-mono-vietnamese-500-normal.woff2 +0 -0
  19. package/assets/instrument-sans-latin-ext-wght-normal.woff2 +0 -0
  20. package/assets/instrument-sans-latin-wght-normal.woff2 +0 -0
  21. package/assistant-ui/index.js +139 -0
  22. package/chunks/callout-DKMHSnjc.js +342 -0
  23. package/chunks/canvas-BJ15-XxE.js +598 -0
  24. package/chunks/controller-Cfpg0C7v.js +180 -0
  25. package/chunks/core-BCqVRLUy.js +312 -0
  26. package/chunks/text-field-BLtoaZFn.js +41 -0
  27. package/chunks/types-BGF7r1my.js +115 -0
  28. package/chunks/ui-9DyNsYXY.js +967 -0
  29. package/core/index.js +4 -0
  30. package/custom/index.js +64 -0
  31. package/examples/ai-sdk-backend/package.json +11 -0
  32. package/examples/ai-sdk-backend/server.mjs +316 -0
  33. package/examples/custom-backend/copy.mjs +7 -0
  34. package/examples/custom-backend/server.mjs +118 -0
  35. package/examples/generative/specs.json +2094 -0
  36. package/examples/review-backend/copy.mjs +27 -0
  37. package/examples/review-backend/package.json +11 -0
  38. package/examples/review-backend/server.mjs +276 -0
  39. package/examples/web-ai-sdk/index.html +12 -0
  40. package/examples/web-ai-sdk/package.json +21 -0
  41. package/examples/web-ai-sdk/src/copy.ts +1 -0
  42. package/examples/web-ai-sdk/src/main.tsx +64 -0
  43. package/examples/web-ai-sdk/tsconfig.json +13 -0
  44. package/examples/web-generative/index.html +12 -0
  45. package/examples/web-generative/package.json +23 -0
  46. package/examples/web-generative/src/copy.ts +42 -0
  47. package/examples/web-generative/src/main.tsx +74 -0
  48. package/examples/web-generative/tsconfig.json +14 -0
  49. package/examples/web-independent/index.html +12 -0
  50. package/examples/web-independent/package.json +20 -0
  51. package/examples/web-independent/src/main.tsx +32 -0
  52. package/examples/web-independent/tsconfig.json +14 -0
  53. package/examples/web-interactions/index.html +12 -0
  54. package/examples/web-interactions/package.json +21 -0
  55. package/examples/web-interactions/src/copy.ts +215 -0
  56. package/examples/web-interactions/src/examples.tsx +628 -0
  57. package/examples/web-interactions/src/main.tsx +116 -0
  58. package/examples/web-interactions/tsconfig.json +14 -0
  59. package/examples/web-review/index.html +12 -0
  60. package/examples/web-review/package.json +20 -0
  61. package/examples/web-review/src/main.tsx +59 -0
  62. package/examples/web-review/tsconfig.json +14 -0
  63. package/fonts.css +117 -0
  64. package/generative/index.js +1560 -0
  65. package/interactions/index.js +1591 -0
  66. package/langgraph-review/index.js +36 -0
  67. package/licenses/ai-sdk.txt +13 -0
  68. package/licenses/assistant-ui-generative.txt +21 -0
  69. package/licenses/assistant-ui.txt +23 -0
  70. package/licenses/ibm-plex-mono.txt +93 -0
  71. package/licenses/instrument-sans.txt +93 -0
  72. package/licenses/internationalized-date.txt +201 -0
  73. package/licenses/langgraph.txt +21 -0
  74. package/licenses/lucide.txt +43 -0
  75. package/licenses/react-markdown.txt +21 -0
  76. package/licenses/remark-gfm.txt +22 -0
  77. package/licenses/zod.txt +21 -0
  78. package/package.json +138 -0
  79. package/review/index.js +31 -0
  80. package/source/components/avatar.tsx +50 -0
  81. package/source/components/button.tsx +155 -0
  82. package/source/components/callout.tsx +65 -0
  83. package/source/components/canvas/connector.tsx +14 -0
  84. package/source/components/canvas/copy.ts +34 -0
  85. package/source/components/canvas/index.tsx +257 -0
  86. package/source/components/canvas/recorder.ts +36 -0
  87. package/source/components/date-time-field.tsx +77 -0
  88. package/source/components/flow-motion.tsx +109 -0
  89. package/source/components/icons.tsx +275 -0
  90. package/source/components/responsive-overlay.tsx +91 -0
  91. package/source/components/scenario-picker/copy.ts +5 -0
  92. package/source/components/scenario-picker/index.tsx +142 -0
  93. package/source/components/scroll-area.tsx +59 -0
  94. package/source/components/search-picker.tsx +127 -0
  95. package/source/components/segmented-control.tsx +123 -0
  96. package/source/components/skeleton.tsx +11 -0
  97. package/source/components/spinner.tsx +19 -0
  98. package/source/components/superxd-arrow.tsx +22 -0
  99. package/source/components/switch.tsx +45 -0
  100. package/source/components/text-field.tsx +81 -0
  101. package/source/components/thinking.tsx +16 -0
  102. package/source/components/ui/copy.ts +12 -0
  103. package/source/components/ui/display.tsx +276 -0
  104. package/source/components/ui/navigation.tsx +346 -0
  105. package/source/components/ui/portal-theme.tsx +28 -0
  106. package/source/components/ui/selection.tsx +336 -0
  107. package/source/lib/cn.ts +23 -0
  108. package/source/reusable/ai-sdk/index.ts +114 -0
  109. package/source/reusable/assistant-ui/index.tsx +266 -0
  110. package/source/reusable/core/attachments.ts +163 -0
  111. package/source/reusable/core/index.ts +417 -0
  112. package/source/reusable/custom/index.ts +90 -0
  113. package/source/reusable/generative/actions.ts +188 -0
  114. package/source/reusable/generative/copy.ts +47 -0
  115. package/source/reusable/generative/data.tsx +126 -0
  116. package/source/reusable/generative/index.tsx +517 -0
  117. package/source/reusable/generative/schema.ts +327 -0
  118. package/source/reusable/generative/timeline.tsx +214 -0
  119. package/source/reusable/generative/vocabulary.tsx +847 -0
  120. package/source/reusable/interactions/agent.ts +259 -0
  121. package/source/reusable/interactions/artifact.ts +236 -0
  122. package/source/reusable/interactions/context.tsx +38 -0
  123. package/source/reusable/interactions/copy.ts +117 -0
  124. package/source/reusable/interactions/feedback.ts +73 -0
  125. package/source/reusable/interactions/index.ts +11 -0
  126. package/source/reusable/interactions/presentation.tsx +483 -0
  127. package/source/reusable/interactions/store.ts +74 -0
  128. package/source/reusable/interactions/threads.ts +126 -0
  129. package/source/reusable/interactions/web.tsx +574 -0
  130. package/source/reusable/langgraph-review/index.ts +73 -0
  131. package/source/reusable/review/controller.ts +263 -0
  132. package/source/reusable/review/index.ts +47 -0
  133. package/source/reusable/review/types.ts +189 -0
  134. package/source/reusable/ui/index.ts +25 -0
  135. package/source/reusable/uploads/index.ts +48 -0
  136. package/source/reusable/web/attachments/copy.ts +23 -0
  137. package/source/reusable/web/attachments/index.tsx +233 -0
  138. package/source/reusable/web/copy.ts +22 -0
  139. package/source/reusable/web/index.tsx +470 -0
  140. package/source/reusable/web/message/copy.ts +26 -0
  141. package/source/reusable/web/message/index.tsx +388 -0
  142. package/source/reusable/web/message/streaming.ts +64 -0
  143. package/source/reusable/web/message/styles.css +21 -0
  144. package/source/reusable/web/review/copy.ts +78 -0
  145. package/source/reusable/web/review/flow.ts +24 -0
  146. package/source/reusable/web/review/index.tsx +506 -0
  147. package/source/reusable/web/styles.ts +2 -0
  148. package/source/styles/library.css +612 -0
  149. package/source/styles/theme.css +228 -0
  150. package/styles.css +3 -0
  151. package/styles.d.ts +1 -0
  152. package/types/components/avatar.d.ts +14 -0
  153. package/types/components/button.d.ts +36 -0
  154. package/types/components/callout.d.ts +19 -0
  155. package/types/components/canvas/connector.d.ts +2 -0
  156. package/types/components/canvas/copy.d.ts +34 -0
  157. package/types/components/canvas/index.d.ts +33 -0
  158. package/types/components/canvas/recorder.d.ts +10 -0
  159. package/types/components/date-time-field.d.ts +11 -0
  160. package/types/components/flow-motion.d.ts +38 -0
  161. package/types/components/icons.d.ts +138 -0
  162. package/types/components/responsive-overlay.d.ts +15 -0
  163. package/types/components/scenario-picker/copy.d.ts +5 -0
  164. package/types/components/scenario-picker/index.d.ts +14 -0
  165. package/types/components/scroll-area.d.ts +14 -0
  166. package/types/components/search-picker.d.ts +27 -0
  167. package/types/components/segmented-control.d.ts +23 -0
  168. package/types/components/skeleton.d.ts +4 -0
  169. package/types/components/spinner.d.ts +4 -0
  170. package/types/components/superxd-arrow.d.ts +5 -0
  171. package/types/components/switch.d.ts +8 -0
  172. package/types/components/text-field.d.ts +19 -0
  173. package/types/components/thinking.d.ts +8 -0
  174. package/types/components/ui/copy.d.ts +12 -0
  175. package/types/components/ui/display.d.ts +50 -0
  176. package/types/components/ui/navigation.d.ts +63 -0
  177. package/types/components/ui/portal-theme.d.ts +8 -0
  178. package/types/components/ui/selection.d.ts +37 -0
  179. package/types/lib/cn.d.ts +3 -0
  180. package/types/reusable/ai-sdk/index.d.ts +15 -0
  181. package/types/reusable/assistant-ui/index.d.ts +12 -0
  182. package/types/reusable/core/attachments.d.ts +54 -0
  183. package/types/reusable/core/index.d.ts +107 -0
  184. package/types/reusable/custom/index.d.ts +14 -0
  185. package/types/reusable/generative/actions.d.ts +45 -0
  186. package/types/reusable/generative/copy.d.ts +48 -0
  187. package/types/reusable/generative/data.d.ts +4 -0
  188. package/types/reusable/generative/index.d.ts +30 -0
  189. package/types/reusable/generative/schema.d.ts +303 -0
  190. package/types/reusable/generative/timeline.d.ts +21 -0
  191. package/types/reusable/generative/vocabulary.d.ts +34 -0
  192. package/types/reusable/interactions/agent.d.ts +98 -0
  193. package/types/reusable/interactions/artifact.d.ts +118 -0
  194. package/types/reusable/interactions/context.d.ts +130 -0
  195. package/types/reusable/interactions/copy.d.ts +115 -0
  196. package/types/reusable/interactions/feedback.d.ts +34 -0
  197. package/types/reusable/interactions/index.d.ts +10 -0
  198. package/types/reusable/interactions/presentation.d.ts +97 -0
  199. package/types/reusable/interactions/store.d.ts +29 -0
  200. package/types/reusable/interactions/threads.d.ts +38 -0
  201. package/types/reusable/interactions/web.d.ts +22 -0
  202. package/types/reusable/langgraph-review/index.d.ts +5 -0
  203. package/types/reusable/review/controller.d.ts +52 -0
  204. package/types/reusable/review/index.d.ts +12 -0
  205. package/types/reusable/review/types.d.ts +61 -0
  206. package/types/reusable/ui/index.d.ts +19 -0
  207. package/types/reusable/uploads/index.d.ts +11 -0
  208. package/types/reusable/web/attachments/copy.d.ts +25 -0
  209. package/types/reusable/web/attachments/index.d.ts +24 -0
  210. package/types/reusable/web/copy.d.ts +24 -0
  211. package/types/reusable/web/index.d.ts +41 -0
  212. package/types/reusable/web/message/copy.d.ts +27 -0
  213. package/types/reusable/web/message/index.d.ts +56 -0
  214. package/types/reusable/web/message/streaming.d.ts +27 -0
  215. package/types/reusable/web/review/copy.d.ts +72 -0
  216. package/types/reusable/web/review/flow.d.ts +3 -0
  217. package/types/reusable/web/review/index.d.ts +38 -0
  218. package/types/reusable/web/styles.d.ts +2 -0
  219. package/ui/index.js +4 -0
  220. package/uploads/index.js +34 -0
  221. package/web/index.js +931 -0
@@ -0,0 +1,233 @@
1
+ import { useRef, useSyncExternalStore } from "react";
2
+ import { FileTrigger } from "react-aria-components";
3
+ import { Button } from "../../../components/button.js";
4
+ import { IconFile, IconPaperclip, IconRotate, IconX } from "../../../components/icons.js";
5
+ import { Spinner } from "../../../components/spinner.js";
6
+ import { cn } from "../../../lib/cn.js";
7
+ import { parseChatFile, type AttachmentController, type AttachmentItem } from "../../core/index.js";
8
+ import { attachmentCopy, type AttachmentCopy } from "./copy.js";
9
+
10
+ export function useAttachments<Data>(controller: AttachmentController<Data>) {
11
+ return useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
12
+ }
13
+ export interface AttachmentListProps {
14
+ items: readonly AttachmentItem[];
15
+ variant?: "list" | "grid" | "inline";
16
+ className?: string;
17
+ copy?: AttachmentCopy;
18
+ /** Explicit opt-in: host is responsible for trusting image origins. No PDFs/HTML are embedded. */
19
+ previewImages?: boolean;
20
+ onRemove?: (id: string) => void;
21
+ onRetry?: (id: string) => void;
22
+ onCancel?: (id: string) => void;
23
+ }
24
+ /** Standalone supplied-data display; no chat, upload or vendor provider is required. */
25
+ export function AttachmentList({
26
+ items,
27
+ variant = "list",
28
+ className,
29
+ copy = attachmentCopy,
30
+ previewImages = false,
31
+ onRemove,
32
+ onRetry,
33
+ onCancel,
34
+ }: AttachmentListProps) {
35
+ if (!items.length)
36
+ return <p className={cn("type-caption text-fg-subtle", className)}>{copy.empty}</p>;
37
+ return (
38
+ <ul
39
+ aria-label={copy.label}
40
+ className={cn(
41
+ "min-w-0 list-none p-0",
42
+ variant === "grid"
43
+ ? "flex flex-wrap gap-3"
44
+ : variant === "inline"
45
+ ? "flex flex-wrap gap-2"
46
+ : "flex flex-col gap-2",
47
+ className,
48
+ )}
49
+ >
50
+ {items.map((item) => {
51
+ const image = ["image/png", "image/jpeg"].includes(item.mediaType);
52
+ let preview: string | undefined;
53
+ if (previewImages && image && item.file) {
54
+ try {
55
+ preview = parseChatFile(item.file).url;
56
+ } catch {
57
+ /* Invalid supplied URL stays a non-interactive file card. */
58
+ }
59
+ }
60
+ const category = image
61
+ ? copy.image
62
+ : ["application/pdf", "text/plain"].includes(item.mediaType)
63
+ ? copy.document
64
+ : copy.file;
65
+ const size =
66
+ item.size < 1000
67
+ ? `${item.size} B`
68
+ : item.size < 1_000_000
69
+ ? `${Math.ceil(item.size / 1000)} KB`
70
+ : `${(item.size / 1_000_000).toFixed(1)} MB`;
71
+ return (
72
+ <li
73
+ key={item.id}
74
+ className={cn(
75
+ "flex min-w-0 flex-wrap gap-3 rounded-control border bg-surface px-control-md-x py-control-y",
76
+ variant === "inline" && "max-w-full",
77
+ variant === "grid" && "max-w-full grow basis-64 flex-col flex-nowrap",
78
+ ["error", "rejected"].includes(item.status)
79
+ ? "border-error-line"
80
+ : "border-line-subtle",
81
+ )}
82
+ >
83
+ {preview ? (
84
+ <img
85
+ src={preview}
86
+ alt=""
87
+ loading="lazy"
88
+ referrerPolicy="no-referrer"
89
+ className={cn(
90
+ "size-12 shrink-0 rounded-cell object-cover",
91
+ variant === "grid" && "h-32 w-full",
92
+ )}
93
+ />
94
+ ) : (
95
+ <span className="flex size-control-sm shrink-0 items-center justify-center rounded-cell bg-surface-muted text-fg-subtle">
96
+ <IconFile />
97
+ </span>
98
+ )}
99
+ <div
100
+ className={cn(
101
+ "flex min-w-32 flex-1 flex-col gap-1",
102
+ variant === "grid" && "w-full min-w-0",
103
+ )}
104
+ >
105
+ <p title={item.name} className="truncate type-label text-fg-emphasis">
106
+ {item.name}
107
+ </p>
108
+ <p className="type-caption text-fg-subtle">
109
+ {category} · {size}
110
+ </p>
111
+ <p className="flex items-center gap-2 type-caption text-fg-subtle">
112
+ {item.status === "uploading" ? <Spinner /> : null}
113
+ {copy[item.status]}
114
+ </p>
115
+ {item.issue ? (
116
+ <p className="type-caption wrap-anywhere text-error">{copy[item.issue]}</p>
117
+ ) : null}
118
+ </div>
119
+ {onRemove ||
120
+ (onRetry && ["error", "cancelled"].includes(item.status)) ||
121
+ (onCancel && item.status === "uploading") ? (
122
+ <div className="ml-auto flex shrink-0 items-start gap-1">
123
+ {onCancel && item.status === "uploading" ? (
124
+ <Button
125
+ size="sm"
126
+ variant="ghost"
127
+ aria-label={`${copy.cancel}: ${item.name}`}
128
+ onPress={() => onCancel(item.id)}
129
+ >
130
+ {copy.cancel}
131
+ </Button>
132
+ ) : null}
133
+ {onRetry && ["error", "cancelled"].includes(item.status) ? (
134
+ <Button
135
+ size="icon-sm"
136
+ variant="ghost"
137
+ aria-label={`${copy.retry}: ${item.name}`}
138
+ onPress={() => onRetry(item.id)}
139
+ >
140
+ <IconRotate />
141
+ </Button>
142
+ ) : null}
143
+ {onRemove ? (
144
+ <Button
145
+ size="icon-sm"
146
+ variant="ghost"
147
+ aria-label={`${copy.remove}: ${item.name}`}
148
+ onPress={() => onRemove(item.id)}
149
+ >
150
+ <IconX />
151
+ </Button>
152
+ ) : null}
153
+ </div>
154
+ ) : null}
155
+ </li>
156
+ );
157
+ })}
158
+ </ul>
159
+ );
160
+ }
161
+
162
+ export interface AttachmentPickerProps {
163
+ controller: AttachmentController<Blob>;
164
+ isDisabled?: boolean;
165
+ description: string;
166
+ copy?: AttachmentCopy;
167
+ className?: string;
168
+ }
169
+ export function AttachmentPicker({
170
+ controller,
171
+ isDisabled,
172
+ description,
173
+ copy = attachmentCopy,
174
+ className,
175
+ }: AttachmentPickerProps) {
176
+ const snapshot = useAttachments(controller);
177
+ const addRef = useRef<HTMLButtonElement>(null);
178
+ return (
179
+ <div className={cn("flex min-w-0 flex-col gap-3", className)}>
180
+ <div className="flex flex-wrap items-center gap-3">
181
+ <FileTrigger
182
+ acceptedFileTypes={[...controller.policy.mediaTypes]}
183
+ allowsMultiple
184
+ onSelect={(files) => {
185
+ if (!files || isDisabled) return;
186
+ controller.add(
187
+ Array.from(files).map((file) => ({
188
+ name: file.name,
189
+ mediaType: file.type,
190
+ size: file.size,
191
+ data: file,
192
+ })),
193
+ );
194
+ }}
195
+ >
196
+ <Button ref={addRef} size="sm" isDisabled={isDisabled}>
197
+ <IconPaperclip />
198
+ {copy.add}
199
+ </Button>
200
+ </FileTrigger>
201
+ <p className="type-caption text-fg-subtle">{description}</p>
202
+ </div>
203
+ {snapshot.items.length ? (
204
+ <AttachmentList
205
+ items={snapshot.items}
206
+ onRemove={(id) => {
207
+ controller.remove(id);
208
+ addRef.current?.focus();
209
+ }}
210
+ onRetry={(id) => {
211
+ controller.retry(id);
212
+ addRef.current?.focus();
213
+ }}
214
+ onCancel={(id) => {
215
+ controller.cancel(id);
216
+ addRef.current?.focus();
217
+ }}
218
+ />
219
+ ) : null}
220
+ <p
221
+ role="status"
222
+ aria-live="polite"
223
+ className={cn("type-caption text-error", !snapshot.issue && "sr-only")}
224
+ >
225
+ {snapshot.issue
226
+ ? copy[snapshot.issue]
227
+ : snapshot.items.length
228
+ ? `${snapshot.items.length} ${copy.selected}. ${snapshot.items.map((item) => `${item.name}: ${copy[item.status]}`).join(". ")}`
229
+ : ""}
230
+ </p>
231
+ </div>
232
+ );
233
+ }
@@ -0,0 +1,22 @@
1
+ export const chatCopy = {
2
+ label: "Conversation",
3
+ emptyTitle: "What are you working on?",
4
+ emptyNote: "Start with a question, an idea or something you want to make clearer.",
5
+ user: "You",
6
+ assistant: "Assistant",
7
+ input: "Message",
8
+ placeholder: "Ask a question or describe what you need",
9
+ send: "Send message",
10
+ stop: "Stop response",
11
+ retry: "Restart response",
12
+ hint: "Enter to send · Shift + Enter for a new line",
13
+ touchHint: "Use Send to submit your message",
14
+ idle: "",
15
+ waiting: "Preparing a response",
16
+ streaming: "Responding",
17
+ complete: "Response ready",
18
+ cancelled: "Response stopped. Your partial response is still here.",
19
+ error: "The response couldn’t finish. Your message is still here.",
20
+ interrupted: "The connection ended before the response finished. Restart to try again.",
21
+ } as const;
22
+ export type ChatCopy = { [Key in keyof typeof chatCopy]: string };