@anvia/react-ui 1.0.0-rc.9 → 1.0.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 (60) hide show
  1. package/README.md +46 -37
  2. package/dist/attachment/index.d.ts +2 -2
  3. package/dist/attachment/index.js +4 -4
  4. package/dist/chat/index.d.ts +4 -4
  5. package/dist/chat/index.js +10 -9
  6. package/dist/{chunk-OINUOCTO.js → chunk-647LAYRV.js} +90 -65
  7. package/dist/chunk-647LAYRV.js.map +1 -0
  8. package/dist/chunk-6XOJFLX4.js +22 -0
  9. package/dist/chunk-6XOJFLX4.js.map +1 -0
  10. package/dist/{chunk-JBKSJG5W.js → chunk-CRXNFZRW.js} +45 -80
  11. package/dist/chunk-CRXNFZRW.js.map +1 -0
  12. package/dist/{chunk-EWIHRMU6.js → chunk-CVXLQCDI.js} +13 -21
  13. package/dist/chunk-CVXLQCDI.js.map +1 -0
  14. package/dist/{chunk-ULGJLLZE.js → chunk-F6AKBUO3.js} +12 -12
  15. package/dist/chunk-F6AKBUO3.js.map +1 -0
  16. package/dist/{chunk-XAQA3JIG.js → chunk-HWJIMLHC.js} +41 -70
  17. package/dist/chunk-HWJIMLHC.js.map +1 -0
  18. package/dist/{chunk-BU4ZPDHQ.js → chunk-MISX4WUT.js} +10 -15
  19. package/dist/chunk-MISX4WUT.js.map +1 -0
  20. package/dist/{chunk-PSU4V23X.js → chunk-OQE6SHZE.js} +16 -30
  21. package/dist/chunk-OQE6SHZE.js.map +1 -0
  22. package/dist/{chunk-E5UNQCGM.js → chunk-S4XLE2RN.js} +6 -12
  23. package/dist/chunk-S4XLE2RN.js.map +1 -0
  24. package/dist/{chunk-F76H3VMN.js → chunk-SOG2GVE4.js} +45 -15
  25. package/dist/chunk-SOG2GVE4.js.map +1 -0
  26. package/dist/{chunk-ZPNAX4SA.js → chunk-UCBAG42A.js} +9 -21
  27. package/dist/chunk-UCBAG42A.js.map +1 -0
  28. package/dist/completion/index.d.ts +2 -2
  29. package/dist/completion/index.js +4 -4
  30. package/dist/human-input/index.d.ts +2 -2
  31. package/dist/human-input/index.js +4 -4
  32. package/dist/image/index.d.ts +2 -2
  33. package/dist/image/index.js +4 -4
  34. package/dist/index.d.ts +11 -11
  35. package/dist/index.js +58 -63
  36. package/dist/index.js.map +1 -1
  37. package/dist/message/index.d.ts +2 -2
  38. package/dist/message/index.js +7 -6
  39. package/dist/selection-toolbar/index.d.ts +2 -2
  40. package/dist/selection-toolbar/index.js +5 -4
  41. package/dist/shared.d.ts +1 -1
  42. package/dist/shared.js +1 -1
  43. package/dist/stream/index.d.ts +2 -0
  44. package/dist/stream/index.js +1 -1
  45. package/dist/{thread-uEm8hH0s.d.ts → thread-Bz6-1zaJ.d.ts} +1 -0
  46. package/dist/thread-list/index.d.ts +3 -3
  47. package/dist/thread-list/index.js +6 -6
  48. package/package.json +7 -9
  49. package/dist/chunk-BU4ZPDHQ.js.map +0 -1
  50. package/dist/chunk-E5UNQCGM.js.map +0 -1
  51. package/dist/chunk-EWIHRMU6.js.map +0 -1
  52. package/dist/chunk-F76H3VMN.js.map +0 -1
  53. package/dist/chunk-JBKSJG5W.js.map +0 -1
  54. package/dist/chunk-OINUOCTO.js.map +0 -1
  55. package/dist/chunk-PSU4V23X.js.map +0 -1
  56. package/dist/chunk-ULGJLLZE.js.map +0 -1
  57. package/dist/chunk-XAQA3JIG.js.map +0 -1
  58. package/dist/chunk-ZPNAX4SA.js.map +0 -1
  59. package/dist/stream/styles.css +0 -17
  60. package/dist/styles.css +0 -130
@@ -5,7 +5,7 @@ import {
5
5
  InternalCompletionInputProvider,
6
6
  useCompletionContext,
7
7
  useCompletionInput
8
- } from "./chunk-F76H3VMN.js";
8
+ } from "./chunk-SOG2GVE4.js";
9
9
 
10
10
  // src/completion/form.tsx
11
11
  import {
@@ -61,7 +61,6 @@ var CompletionForm = forwardRef(function CompletionForm2({ onSubmit, ...props },
61
61
  {
62
62
  ...props,
63
63
  onSubmit: handleSubmit,
64
- "data-anvia-completion-form": "",
65
64
  "data-state": completion.status
66
65
  },
67
66
  ref
@@ -98,8 +97,7 @@ var CompletionInput = forwardRef(
98
97
  disabled: props.disabled ?? (input.status === "submitted" || input.status === "streaming"),
99
98
  onChange: handleChange,
100
99
  onKeyDown: handleKeyDown,
101
- value: input.input,
102
- "data-anvia-completion-input": ""
100
+ value: input.input
103
101
  },
104
102
  ref
105
103
  );
@@ -116,7 +114,6 @@ var CompletionSubmit = forwardRef(
116
114
  children: props.children ?? "Complete",
117
115
  disabled,
118
116
  type: props.type ?? "submit",
119
- "data-anvia-completion-submit": "",
120
117
  "data-state": disabled ? "disabled" : "enabled"
121
118
  },
122
119
  ref
@@ -145,7 +142,6 @@ var CompletionStop = forwardRef(
145
142
  disabled,
146
143
  onClick: handleClick,
147
144
  type: props.type ?? "button",
148
- "data-anvia-completion-stop": "",
149
145
  "data-state": disabled ? "disabled" : "enabled"
150
146
  },
151
147
  ref
@@ -162,7 +158,6 @@ var CompletionRoot = forwardRef2(
162
158
  "div",
163
159
  {
164
160
  ...props,
165
- "data-anvia-completion": "",
166
161
  "data-state": completion.status
167
162
  },
168
163
  ref
@@ -177,8 +172,7 @@ var CompletionOutput = forwardRef2(
177
172
  "div",
178
173
  {
179
174
  ...props,
180
- children: renderedChildren ?? completion.completion,
181
- "data-anvia-completion-output": ""
175
+ children: renderedChildren ?? completion.completion
182
176
  },
183
177
  ref
184
178
  );
@@ -186,7 +180,7 @@ var CompletionOutput = forwardRef2(
186
180
  );
187
181
 
188
182
  // src/completion/index.ts
189
- var Completion = {
183
+ var CompletionPrimitive = {
190
184
  Root: CompletionRoot,
191
185
  Output: CompletionOutput,
192
186
  Form: CompletionForm,
@@ -196,6 +190,6 @@ var Completion = {
196
190
  };
197
191
 
198
192
  export {
199
- Completion
193
+ CompletionPrimitive
200
194
  };
201
- //# sourceMappingURL=chunk-E5UNQCGM.js.map
195
+ //# sourceMappingURL=chunk-S4XLE2RN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/completion/form.tsx","../src/completion/root.tsx","../src/completion/index.ts"],"sourcesContent":["import {\n type ChangeEvent,\n type FormEvent,\n forwardRef,\n type KeyboardEvent,\n type MouseEvent,\n useCallback,\n useMemo,\n} from \"react\";\n\nimport {\n type CompletionInputContextValue,\n InternalCompletionInputProvider,\n useCompletionContext,\n useCompletionInput,\n} from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\nconst CompletionForm = forwardRef<HTMLFormElement, PrimitiveProps<\"form\">>(function CompletionForm(\n { onSubmit, ...props },\n ref,\n) {\n const completion = useCompletionContext();\n const active = completion.status === \"submitted\" || completion.status === \"streaming\";\n const canSubmit = completion.input.trim().length > 0 && !active;\n const canStop = active;\n\n const submit = useCallback(async () => {\n if (!canSubmit) {\n return;\n }\n await completion.submit();\n }, [canSubmit, completion]);\n\n const value = useMemo<CompletionInputContextValue>(\n () => ({\n input: completion.input,\n setInput: completion.setInput,\n submit,\n stop: completion.stop,\n status: completion.status,\n canSubmit,\n canStop,\n }),\n [\n canStop,\n canSubmit,\n completion.input,\n completion.setInput,\n completion.status,\n completion.stop,\n submit,\n ],\n );\n\n const handleSubmit = useCallback(\n (event: FormEvent<HTMLFormElement>) => {\n (onSubmit as ((event: FormEvent<HTMLFormElement>) => void) | undefined)?.(event);\n if (event.defaultPrevented) {\n return;\n }\n event.preventDefault();\n void submit();\n },\n [onSubmit, submit],\n );\n\n return (\n <InternalCompletionInputProvider value={value}>\n {renderPrimitive(\n \"form\",\n {\n ...props,\n onSubmit: handleSubmit,\n \"data-state\": completion.status,\n } as PrimitiveProps<\"form\">,\n ref,\n )}\n </InternalCompletionInputProvider>\n );\n});\n\nconst CompletionInput = forwardRef<HTMLTextAreaElement, PrimitiveProps<\"textarea\">>(\n function CompletionInput({ onChange, onKeyDown, ...props }, ref) {\n const input = useCompletionInput();\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLTextAreaElement>) => {\n onChange?.(event);\n if (!event.defaultPrevented) {\n input.setInput(event.currentTarget.value);\n }\n },\n [input, onChange],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLTextAreaElement>) => {\n onKeyDown?.(event);\n if (\n event.defaultPrevented ||\n event.key !== \"Enter\" ||\n event.shiftKey ||\n event.nativeEvent.isComposing\n ) {\n return;\n }\n event.preventDefault();\n void input.submit();\n },\n [input, onKeyDown],\n );\n\n return renderPrimitive(\n \"textarea\",\n {\n ...props,\n \"aria-label\": props[\"aria-label\"] ?? \"Prompt\",\n disabled: props.disabled ?? (input.status === \"submitted\" || input.status === \"streaming\"),\n onChange: handleChange,\n onKeyDown: handleKeyDown,\n value: input.input,\n } as PrimitiveProps<\"textarea\">,\n ref,\n );\n },\n);\n\nconst CompletionSubmit = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function CompletionSubmit(props, ref) {\n const input = useCompletionInput();\n const disabled = props.disabled ?? !input.canSubmit;\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Complete\",\n disabled,\n type: props.type ?? \"submit\",\n \"data-state\": disabled ? \"disabled\" : \"enabled\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nconst CompletionStop = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function CompletionStop({ onClick, ...props }, ref) {\n const input = useCompletionInput();\n const disabled = props.disabled ?? !input.canStop;\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n input.stop();\n },\n [disabled, input, onClick],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Stop\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-state\": disabled ? \"disabled\" : \"enabled\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nexport { CompletionForm, CompletionInput, CompletionStop, CompletionSubmit };\n","import { forwardRef, type ReactNode } from \"react\";\n\nimport { useCompletionContext } from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype CompletionOutputChildren = ReactNode | ((completion: string) => ReactNode);\n\nconst CompletionRoot = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function CompletionRoot(props, ref) {\n const completion = useCompletionContext();\n return renderPrimitive(\n \"div\",\n {\n ...props,\n \"data-state\": completion.status,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype CompletionOutputProps = PrimitiveProps<\"div\"> & {\n children?: CompletionOutputChildren;\n};\n\nconst CompletionOutput = forwardRef<HTMLDivElement, CompletionOutputProps>(\n function CompletionOutput({ children, ...props }, ref) {\n const completion = useCompletionContext();\n const renderedChildren =\n typeof children === \"function\" ? children(completion.completion) : children;\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren ?? completion.completion,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport { CompletionOutput, CompletionRoot };\n","import { CompletionForm, CompletionInput, CompletionStop, CompletionSubmit } from \"./form\";\nimport { CompletionOutput, CompletionRoot } from \"./root\";\n\nexport const CompletionPrimitive = {\n Root: CompletionRoot,\n Output: CompletionOutput,\n Form: CompletionForm,\n Input: CompletionInput,\n Submit: CompletionSubmit,\n Stop: CompletionStop,\n} as const;\n\nexport type {\n CompletionController,\n CompletionInputContextValue,\n CompletionProviderProps,\n} from \"../contexts\";\nexport { CompletionProvider, useCompletionContext, useCompletionInput } from \"../contexts\";\n"],"mappings":";;;;;;;;;;AAAA;AAAA,EAGE;AAAA,EAGA;AAAA,EACA;AAAA,OACK;AA4DH;AAlDJ,IAAM,iBAAiB,WAAoD,SAASA,gBAClF,EAAE,UAAU,GAAG,MAAM,GACrB,KACA;AACA,QAAM,aAAa,qBAAqB;AACxC,QAAM,SAAS,WAAW,WAAW,eAAe,WAAW,WAAW;AAC1E,QAAM,YAAY,WAAW,MAAM,KAAK,EAAE,SAAS,KAAK,CAAC;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A,QACpB,cAAc,WAAW,aAAa;AAAA,MACxC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;;;AChLA,SAAS,cAAAC,mBAAkC;AAO3C,IAAM,iBAAiBC;AAAA,EACrB,SAASC,gBAAe,OAAO,KAAK;AAClC,UAAM,aAAa,qBAAqB;AACxC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,cAAc,WAAW;AAAA,MAC3B;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAMA,IAAM,mBAAmBD;AAAA,EACvB,SAASE,kBAAiB,EAAE,UAAU,GAAG,MAAM,GAAG,KAAK;AACrD,UAAM,aAAa,qBAAqB;AACxC,UAAM,mBACJ,OAAO,aAAa,aAAa,SAAS,WAAW,UAAU,IAAI;AAErE,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,UAAU,oBAAoB,WAAW;AAAA,MAC3C;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;;;ACrCO,IAAM,sBAAsB;AAAA,EACjC,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACR;","names":["CompletionForm","CompletionInput","CompletionSubmit","CompletionStop","forwardRef","forwardRef","CompletionRoot","CompletionOutput"]}
@@ -10,7 +10,7 @@ function InternalAttachmentProvider({
10
10
  function useAttachment() {
11
11
  const value = useContext(AttachmentContext);
12
12
  if (value === void 0) {
13
- throw new Error("Attachment primitives must be used inside Attachment.Root.");
13
+ throw new Error("Attachment primitives must be used inside AttachmentPrimitive.Root.");
14
14
  }
15
15
  return value;
16
16
  }
@@ -85,7 +85,7 @@ function InternalCompletionInputProvider({
85
85
  function useCompletionInput() {
86
86
  const value = useContext4(CompletionInputContext);
87
87
  if (value === void 0) {
88
- throw new Error("Completion input primitives must be used inside Completion.Form.");
88
+ throw new Error("Completion input primitives must be used inside CompletionPrimitive.Form.");
89
89
  }
90
90
  return value;
91
91
  }
@@ -102,7 +102,7 @@ function InternalComposerProvider({
102
102
  function useComposer() {
103
103
  const value = useContext5(ComposerContext);
104
104
  if (value === void 0) {
105
- throw new Error("Composer primitives must be used inside Composer.Root.");
105
+ throw new Error("Composer primitives must be used inside ComposerPrimitive.Root.");
106
106
  }
107
107
  return value;
108
108
  }
@@ -144,21 +144,23 @@ function InternalQuestionPromptProvider({
144
144
  function useApproval() {
145
145
  const value = useContext6(ApprovalContext);
146
146
  if (value === void 0) {
147
- throw new Error("Approval primitives must be used inside HumanInput.Approval.");
147
+ throw new Error("Approval primitives must be used inside HumanInputPrimitive.Approval.");
148
148
  }
149
149
  return value;
150
150
  }
151
151
  function useQuestion() {
152
152
  const value = useContext6(QuestionContext);
153
153
  if (value === void 0) {
154
- throw new Error("Question primitives must be used inside HumanInput.Question.");
154
+ throw new Error("Question primitives must be used inside HumanInputPrimitive.Question.");
155
155
  }
156
156
  return value;
157
157
  }
158
158
  function useQuestionPrompt() {
159
159
  const value = useContext6(QuestionPromptContext);
160
160
  if (value === void 0) {
161
- throw new Error("Question choice primitives must be used inside HumanInput.QuestionPrompt.");
161
+ throw new Error(
162
+ "Question choice primitives must be used inside HumanInputPrimitive.QuestionPrompt."
163
+ );
162
164
  }
163
165
  return value;
164
166
  }
@@ -175,7 +177,7 @@ function InternalImageProvider({
175
177
  function useImage() {
176
178
  const value = useContext7(ImageContext);
177
179
  if (value === void 0) {
178
- throw new Error("Image primitives must be used inside Image.Root.");
180
+ throw new Error("Image primitives must be used inside ImagePrimitive.Root.");
179
181
  }
180
182
  return value;
181
183
  }
@@ -205,14 +207,18 @@ function InternalMessagePartProvider({
205
207
  function useMessage() {
206
208
  const value = useContext8(MessageContext);
207
209
  if (value === void 0) {
208
- throw new Error("Message primitives must be used inside Message.Root or Thread.Messages.");
210
+ throw new Error(
211
+ "Message primitives must be used inside MessagePrimitive.Root or ThreadPrimitive.Messages."
212
+ );
209
213
  }
210
214
  return value;
211
215
  }
212
216
  function useMessagePart() {
213
217
  const value = useContext8(MessagePartContext);
214
218
  if (value === void 0) {
215
- throw new Error("Message part primitives must be used inside Message.Parts or Message.Part.");
219
+ throw new Error(
220
+ "Message part primitives must be used inside MessagePrimitive.Parts or MessagePrimitive.Part."
221
+ );
216
222
  }
217
223
  return value;
218
224
  }
@@ -232,7 +238,9 @@ function InternalSelectionToolbarProvider({
232
238
  function useSelectionToolbar() {
233
239
  const value = useContext9(SelectionToolbarContext);
234
240
  if (value === void 0) {
235
- throw new Error("SelectionToolbar primitives must be used inside SelectionToolbar.Root.");
241
+ throw new Error(
242
+ "SelectionToolbar primitives must be used inside SelectionToolbarPrimitive.Root."
243
+ );
236
244
  }
237
245
  return value;
238
246
  }
@@ -253,15 +261,22 @@ function InternalThreadProvider({
253
261
  function useThread() {
254
262
  const value = useContext10(ThreadContext);
255
263
  if (value === void 0) {
256
- throw new Error("Thread primitives must be used inside Thread.Root.");
264
+ throw new Error("Thread primitives must be used inside ThreadPrimitive.Root.");
257
265
  }
258
266
  return value;
259
267
  }
260
268
 
261
269
  // src/contexts/thread-list.tsx
262
- import { createContext as createContext11, createElement as createElement11, useContext as useContext11 } from "react";
270
+ import {
271
+ createContext as createContext11,
272
+ createElement as createElement11,
273
+ useContext as useContext11
274
+ } from "react";
263
275
  var ThreadListContext = createContext11(void 0);
264
276
  var ThreadListItemContext = createContext11(void 0);
277
+ var ThreadListRootContext = createContext11(
278
+ void 0
279
+ );
265
280
  function ThreadListProvider({
266
281
  controller,
267
282
  children
@@ -274,6 +289,12 @@ function InternalThreadListItemProvider({
274
289
  }) {
275
290
  return createElement11(ThreadListItemContext.Provider, { value }, children);
276
291
  }
292
+ function InternalThreadListRootProvider({
293
+ value,
294
+ children
295
+ }) {
296
+ return createElement11(ThreadListRootContext.Provider, { value }, children);
297
+ }
277
298
  function useThreadList() {
278
299
  const value = useContext11(ThreadListContext);
279
300
  if (value === void 0) {
@@ -284,7 +305,14 @@ function useThreadList() {
284
305
  function useThreadListItem() {
285
306
  const value = useContext11(ThreadListItemContext);
286
307
  if (value === void 0) {
287
- throw new Error("ThreadListItem primitives must be used inside ThreadList.Items.");
308
+ throw new Error("ThreadListItem primitives must be used inside ThreadListPrimitive.Items.");
309
+ }
310
+ return value;
311
+ }
312
+ function useInternalThreadListRoot() {
313
+ const value = useContext11(ThreadListRootContext);
314
+ if (value === void 0) {
315
+ throw new Error("Thread-list primitives must be used inside ThreadListPrimitive.Root.");
288
316
  }
289
317
  return value;
290
318
  }
@@ -321,7 +349,9 @@ export {
321
349
  useThread,
322
350
  ThreadListProvider,
323
351
  InternalThreadListItemProvider,
352
+ InternalThreadListRootProvider,
324
353
  useThreadList,
325
- useThreadListItem
354
+ useThreadListItem,
355
+ useInternalThreadListRoot
326
356
  };
327
- //# sourceMappingURL=chunk-F76H3VMN.js.map
357
+ //# sourceMappingURL=chunk-SOG2GVE4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/contexts/attachment.tsx","../src/contexts/chat.tsx","../src/contexts/completion.tsx","../src/contexts/completion-input.tsx","../src/contexts/composer.tsx","../src/contexts/human-input.tsx","../src/contexts/image.tsx","../src/contexts/message.tsx","../src/contexts/selection-toolbar.tsx","../src/contexts/thread.tsx","../src/contexts/thread-list.tsx"],"sourcesContent":["import type { UIAttachment } from \"@anvia/client\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type AttachmentContextValue = {\n attachment: UIAttachment;\n remove?(): void;\n};\n\nconst AttachmentContext = createContext<AttachmentContextValue | undefined>(undefined);\n\nexport function InternalAttachmentProvider({\n value,\n children,\n}: {\n value: AttachmentContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(AttachmentContext.Provider, { value }, children);\n}\n\nexport function useAttachment(): AttachmentContextValue {\n const value = useContext(AttachmentContext);\n if (value === undefined) {\n throw new Error(\"Attachment primitives must be used inside AttachmentPrimitive.Root.\");\n }\n return value;\n}\n\nexport function useOptionalAttachment(): AttachmentContextValue | undefined {\n return useContext(AttachmentContext);\n}\n","import type {\n ClientDataMap,\n ClientMetadata,\n ClientStreamRequest,\n ClientTransport,\n} from \"@anvia/client\";\nimport type {\n AgentToolApprovalRequest,\n AgentToolQuestionRequest,\n} from \"@anvia/core/agent/interactions\";\nimport type { UseChatResult } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type ChatController<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n> = UseChatResult<ClientTransport<ClientStreamRequest, Data, Metadata>>;\n\nexport type ChatProviderProps<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n> = {\n controller: ChatController<Metadata, Data>;\n children?: ReactNode;\n};\n\nconst ChatContext = createContext<ChatController | undefined>(undefined);\n\nexport function ChatProvider<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n>({ controller, children }: ChatProviderProps<Metadata, Data>): ReactElement {\n return createElement(\n ChatContext.Provider,\n { value: controller as unknown as ChatController },\n children,\n );\n}\n\nexport function useChatContext<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n>(): ChatController<Metadata, Data> {\n const value = useContext(ChatContext);\n if (value === undefined) {\n throw new Error(\"Anvia chat primitives must be used inside ChatProvider.\");\n }\n return value as unknown as ChatController<Metadata, Data>;\n}\n\nexport function useHumanInput() {\n const interactions = useChatContext().interactions;\n const approvals = interactions.all.filter(\n (item): item is typeof item & { request: AgentToolApprovalRequest } =>\n item.request.type === \"tool-approval\",\n );\n const questions = interactions.all.filter(\n (item): item is typeof item & { request: AgentToolQuestionRequest } =>\n item.request.type === \"tool-question\",\n );\n return {\n approvals: {\n all: approvals,\n pending: approvals.filter((item) => item.status === \"pending\"),\n },\n questions: {\n all: questions,\n pending: questions.filter((item) => item.status === \"pending\"),\n },\n };\n}\n","import type { ClientDataMap, ClientMetadata } from \"@anvia/client\";\nimport type { UseCompletionResult } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type CompletionController<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n> = UseCompletionResult<Metadata, Data>;\n\nexport type CompletionProviderProps<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n> = {\n controller: CompletionController<Metadata, Data>;\n children?: ReactNode;\n};\n\nconst CompletionContext = createContext<CompletionController | undefined>(undefined);\n\nexport function CompletionProvider<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n>({ controller, children }: CompletionProviderProps<Metadata, Data>): ReactElement {\n return createElement(\n CompletionContext.Provider,\n { value: controller as unknown as CompletionController },\n children,\n );\n}\n\nexport function useCompletionContext<\n Metadata extends ClientMetadata = ClientMetadata,\n Data extends ClientDataMap = ClientDataMap,\n>(): CompletionController<Metadata, Data> {\n const value = useContext(CompletionContext);\n if (value === undefined) {\n throw new Error(\"Anvia completion primitives must be used inside CompletionProvider.\");\n }\n return value as unknown as CompletionController<Metadata, Data>;\n}\n","import { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nimport type { CompletionController } from \"./completion\";\n\nexport type CompletionInputContextValue = {\n input: string;\n setInput(input: string): void;\n submit(): Promise<void>;\n stop(): void;\n status: CompletionController[\"status\"];\n canSubmit: boolean;\n canStop: boolean;\n};\n\nconst CompletionInputContext = createContext<CompletionInputContextValue | undefined>(undefined);\n\nexport function InternalCompletionInputProvider({\n value,\n children,\n}: {\n value: CompletionInputContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(CompletionInputContext.Provider, { value }, children);\n}\n\nexport function useCompletionInput(): CompletionInputContextValue {\n const value = useContext(CompletionInputContext);\n if (value === undefined) {\n throw new Error(\"Completion input primitives must be used inside CompletionPrimitive.Form.\");\n }\n return value;\n}\n","import type { ClientMetadata, CreateUIAttachment, UIAttachment } from \"@anvia/client\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\nimport type { ChatController } from \"./chat\";\n\nexport type ComposerEntityData =\n | string\n | number\n | boolean\n | null\n | readonly ComposerEntityData[]\n | { [key: string]: ComposerEntityData };\n\nexport type ComposerAttachmentInput = File | CreateUIAttachment;\nexport type ComposerAttachmentsUpdate =\n | UIAttachment[]\n | ((attachments: UIAttachment[]) => UIAttachment[]);\nexport type ComposerEntitiesUpdate =\n | ComposerEntity[]\n | ((entities: ComposerEntity[]) => ComposerEntity[]);\nexport type ComposerQuote = {\n text: string;\n messageId: string;\n};\nexport type ComposerTriggerItem = {\n id: string;\n label: string;\n text?: string | undefined;\n detail?: ReactNode | undefined;\n data?: ComposerEntityData | undefined;\n disabled?: boolean | undefined;\n};\nexport type ComposerTriggerItemsArgs = {\n trigger: ComposerTriggerDefinition;\n query: string;\n input: string;\n entities: ComposerEntity[];\n signal: AbortSignal;\n};\nexport type ComposerTriggerItems =\n | ComposerTriggerItem[]\n | ((args: ComposerTriggerItemsArgs) => ComposerTriggerItem[] | Promise<ComposerTriggerItem[]>);\nexport type ComposerTriggerDefinition = {\n id: string;\n char: string;\n items: ComposerTriggerItems;\n minQueryLength?: number | undefined;\n allowedPrefixes?: string[] | null | undefined;\n startOfLine?: boolean | undefined;\n allowSpaces?: boolean | undefined;\n};\nexport type ComposerEntity = {\n id: string;\n triggerId: string;\n trigger: string;\n label: string;\n text: string;\n range: {\n from: number;\n to: number;\n };\n data?: ComposerEntityData | undefined;\n};\ntype ComposerMessageEntity = ClientMetadata & {\n id: string;\n triggerId: string;\n trigger: string;\n label: string;\n text: string;\n range: ClientMetadata & {\n from: number;\n to: number;\n };\n data?: ComposerEntityData | undefined;\n};\nexport type ComposerMessageMetadata = ClientMetadata & {\n composer: ClientMetadata & {\n entities: readonly ComposerMessageEntity[];\n };\n};\nexport type ComposerTriggerState = {\n trigger: ComposerTriggerDefinition;\n query: string;\n items: ComposerTriggerItem[];\n loading: boolean;\n selectedIndex: number;\n rect?: {\n top: number;\n right: number;\n bottom: number;\n left: number;\n width: number;\n height: number;\n };\n selectItem(item: ComposerTriggerItem): void;\n setSelectedIndex(index: number): void;\n};\nexport type ComposerTriggerStateUpdate =\n | ComposerTriggerState\n | undefined\n | ((state: ComposerTriggerState | undefined) => ComposerTriggerState | undefined);\n\nexport type ComposerContextValue = {\n input: string;\n setInput(input: string): void;\n attachments: UIAttachment[];\n setAttachments(update: ComposerAttachmentsUpdate): void;\n addAttachment(attachment: ComposerAttachmentInput): Promise<void>;\n removeAttachment(id: string): void;\n clearAttachments(): void;\n entities: ComposerEntity[];\n setEntities(update: ComposerEntitiesUpdate): void;\n quote?: ComposerQuote | undefined;\n setQuote(quote: ComposerQuote | undefined): void;\n clearQuote(): void;\n triggers: ComposerTriggerDefinition[];\n activeTrigger?: ComposerTriggerState | undefined;\n setActiveTrigger(update: ComposerTriggerStateUpdate): void;\n submit(): Promise<void>;\n stop(): void;\n status: ChatController[\"status\"];\n canSubmit: boolean;\n canStop: boolean;\n};\n\nconst ComposerContext = createContext<ComposerContextValue | undefined>(undefined);\n\nexport function InternalComposerProvider({\n value,\n children,\n}: {\n value: ComposerContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ComposerContext.Provider, { value }, children);\n}\n\nexport function useComposer(): ComposerContextValue {\n const value = useContext(ComposerContext);\n if (value === undefined) {\n throw new Error(\"Composer primitives must be used inside ComposerPrimitive.Root.\");\n }\n return value;\n}\n","import type { ClientInteraction } from \"@anvia/client\";\nimport type {\n AgentQuestionAnswer,\n AgentQuestionPrompt,\n AgentToolApprovalRequest,\n AgentToolQuestionRequest,\n} from \"@anvia/core/agent/interactions\";\nimport {\n createContext,\n createElement,\n type ReactElement,\n type ReactNode,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nexport type ApprovalContextValue = {\n approval: ApprovalInteraction;\n reason: string;\n setReason(reason: string): void;\n};\n\nexport type QuestionContextValue = {\n question: QuestionInteraction;\n answers: Record<string, AgentQuestionAnswer>;\n setAnswer(prompt: AgentQuestionPrompt, answer: AgentQuestionAnswer): void;\n};\n\nexport type QuestionPromptContextValue = {\n prompt: AgentQuestionPrompt;\n};\n\nexport type ApprovalInteraction = ClientInteraction & { request: AgentToolApprovalRequest };\nexport type QuestionInteraction = ClientInteraction & { request: AgentToolQuestionRequest };\n\nconst ApprovalContext = createContext<ApprovalContextValue | undefined>(undefined);\nconst QuestionContext = createContext<QuestionContextValue | undefined>(undefined);\nconst QuestionPromptContext = createContext<QuestionPromptContextValue | undefined>(undefined);\n\nexport function InternalApprovalProvider({\n approval,\n children,\n}: {\n approval: ApprovalInteraction;\n children?: ReactNode;\n}): ReactElement {\n const [reason, setReason] = useState(\"\");\n const value = useMemo<ApprovalContextValue>(\n () => ({ approval, reason, setReason }),\n [approval, reason],\n );\n\n return createElement(ApprovalContext.Provider, { value }, children);\n}\n\nexport function InternalQuestionProvider({\n value,\n children,\n}: {\n value: QuestionContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(QuestionContext.Provider, { value }, children);\n}\n\nexport function InternalQuestionPromptProvider({\n prompt,\n children,\n}: {\n prompt: AgentQuestionPrompt;\n children?: ReactNode;\n}): ReactElement {\n return createElement(QuestionPromptContext.Provider, { value: { prompt } }, children);\n}\n\nexport function useApproval(): ApprovalContextValue {\n const value = useContext(ApprovalContext);\n if (value === undefined) {\n throw new Error(\"Approval primitives must be used inside HumanInputPrimitive.Approval.\");\n }\n return value;\n}\n\nexport function useQuestion(): QuestionContextValue {\n const value = useContext(QuestionContext);\n if (value === undefined) {\n throw new Error(\"Question primitives must be used inside HumanInputPrimitive.Question.\");\n }\n return value;\n}\n\nexport function useQuestionPrompt(): QuestionPromptContextValue {\n const value = useContext(QuestionPromptContext);\n if (value === undefined) {\n throw new Error(\n \"Question choice primitives must be used inside HumanInputPrimitive.QuestionPrompt.\",\n );\n }\n return value;\n}\n","import type { UIAttachment } from \"@anvia/client\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type ImageContextValue = {\n attachment: UIAttachment;\n src?: string;\n name?: string;\n mediaType?: string;\n isImage: boolean;\n zoomOpen: boolean;\n setZoomOpen(open: boolean): void;\n};\n\nconst ImageContext = createContext<ImageContextValue | undefined>(undefined);\n\nexport function InternalImageProvider({\n value,\n children,\n}: {\n value: ImageContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ImageContext.Provider, { value }, children);\n}\n\nexport function useImage(): ImageContextValue {\n const value = useContext(ImageContext);\n if (value === undefined) {\n throw new Error(\"Image primitives must be used inside ImagePrimitive.Root.\");\n }\n return value;\n}\n","import type { UIMessage, UIMessagePart } from \"@anvia/client\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type MessageContextValue = {\n message: UIMessage;\n};\n\nexport type MessagePartContextValue = {\n isLive: boolean;\n part: UIMessagePart;\n streamControlled: boolean;\n};\n\nconst MessageContext = createContext<MessageContextValue | undefined>(undefined);\nconst MessagePartContext = createContext<MessagePartContextValue | undefined>(undefined);\n\nexport function InternalMessageProvider({\n message,\n children,\n}: {\n message: UIMessage;\n children?: ReactNode;\n}): ReactElement {\n return createElement(MessageContext.Provider, { value: { message } }, children);\n}\n\nexport function InternalMessagePartProvider({\n part,\n isLive = false,\n streamControlled = false,\n children,\n}: {\n part: UIMessagePart;\n isLive?: boolean;\n streamControlled?: boolean;\n children?: ReactNode;\n}): ReactElement {\n return createElement(\n MessagePartContext.Provider,\n { value: { isLive, part, streamControlled } },\n children,\n );\n}\n\nexport function useMessage(): MessageContextValue {\n const value = useContext(MessageContext);\n if (value === undefined) {\n throw new Error(\n \"Message primitives must be used inside MessagePrimitive.Root or ThreadPrimitive.Messages.\",\n );\n }\n return value;\n}\n\nexport function useMessagePart(): MessagePartContextValue {\n const value = useContext(MessagePartContext);\n if (value === undefined) {\n throw new Error(\n \"Message part primitives must be used inside MessagePrimitive.Parts or MessagePrimitive.Part.\",\n );\n }\n return value;\n}\n\nexport function useOptionalMessagePart(): MessagePartContextValue | undefined {\n return useContext(MessagePartContext);\n}\n","import { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type SelectionToolbarSelection = {\n text: string;\n messageId: string;\n rect: DOMRect;\n};\n\nexport type SelectionToolbarContextValue = {\n selection?: SelectionToolbarSelection;\n quote(): void;\n copy(): Promise<void>;\n clear(): void;\n};\n\nconst SelectionToolbarContext = createContext<SelectionToolbarContextValue | undefined>(undefined);\n\nexport function InternalSelectionToolbarProvider({\n value,\n children,\n}: {\n value: SelectionToolbarContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(SelectionToolbarContext.Provider, { value }, children);\n}\n\nexport function useSelectionToolbar(): SelectionToolbarContextValue {\n const value = useContext(SelectionToolbarContext);\n if (value === undefined) {\n throw new Error(\n \"SelectionToolbar primitives must be used inside SelectionToolbarPrimitive.Root.\",\n );\n }\n return value;\n}\n","import {\n createContext,\n createElement,\n type MutableRefObject,\n type ReactElement,\n type ReactNode,\n useContext,\n} from \"react\";\n\nexport type ThreadContextValue = {\n viewportRef: MutableRefObject<HTMLElement | null>;\n messagesRef: MutableRefObject<HTMLElement | null>;\n atBottom: boolean;\n setAtBottom(atBottom: boolean): void;\n scrollToBottom(behavior?: ScrollBehavior): void;\n};\n\nconst ThreadContext = createContext<ThreadContextValue | undefined>(undefined);\n\nexport function InternalThreadProvider({\n value,\n children,\n}: {\n value: ThreadContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ThreadContext.Provider, { value }, children);\n}\n\nexport function useThread(): ThreadContextValue {\n const value = useContext(ThreadContext);\n if (value === undefined) {\n throw new Error(\"Thread primitives must be used inside ThreadPrimitive.Root.\");\n }\n return value;\n}\n","import {\n createContext,\n createElement,\n type MutableRefObject,\n type ReactElement,\n type ReactNode,\n useContext,\n} from \"react\";\n\nexport type ThreadListRecord = {\n id: string;\n title?: string;\n createdAt?: string | Date;\n updatedAt?: string | Date;\n archived?: boolean;\n metadata?: unknown;\n};\n\nexport type ThreadListController = {\n threads: ThreadListRecord[];\n activeThreadId?: string;\n status?: \"idle\" | \"loading\" | \"error\";\n error?: unknown;\n createThread(): Promise<void> | void;\n switchThread(threadId: string): Promise<void> | void;\n archiveThread?(threadId: string): Promise<void> | void;\n unarchiveThread?(threadId: string): Promise<void> | void;\n deleteThread?(threadId: string): Promise<void> | void;\n};\n\nexport type ThreadListItemContextValue = {\n thread: ThreadListRecord;\n active: boolean;\n};\n\nexport type ThreadListProviderProps = {\n controller: ThreadListController;\n children?: ReactNode;\n};\n\nexport type InternalThreadListRootContextValue = {\n rootRef: MutableRefObject<HTMLDivElement | null>;\n newButtonRef: MutableRefObject<HTMLButtonElement | null>;\n itemElements: MutableRefObject<Map<string, HTMLDivElement>>;\n triggerElements: MutableRefObject<Map<string, HTMLButtonElement>>;\n registerItem(threadId: string, element: HTMLDivElement | null): void;\n registerTrigger(threadId: string, element: HTMLButtonElement | null): void;\n};\n\nconst ThreadListContext = createContext<ThreadListController | undefined>(undefined);\nconst ThreadListItemContext = createContext<ThreadListItemContextValue | undefined>(undefined);\nconst ThreadListRootContext = createContext<InternalThreadListRootContextValue | undefined>(\n undefined,\n);\n\nexport function ThreadListProvider({\n controller,\n children,\n}: ThreadListProviderProps): ReactElement {\n return createElement(ThreadListContext.Provider, { value: controller }, children);\n}\n\nexport function InternalThreadListItemProvider({\n value,\n children,\n}: {\n value: ThreadListItemContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ThreadListItemContext.Provider, { value }, children);\n}\n\nexport function InternalThreadListRootProvider({\n value,\n children,\n}: {\n value: InternalThreadListRootContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ThreadListRootContext.Provider, { value }, children);\n}\n\nexport function useThreadList(): ThreadListController {\n const value = useContext(ThreadListContext);\n if (value === undefined) {\n throw new Error(\"ThreadList primitives must be used inside ThreadListProvider.\");\n }\n return value;\n}\n\nexport function useThreadListItem(): ThreadListItemContextValue {\n const value = useContext(ThreadListItemContext);\n if (value === undefined) {\n throw new Error(\"ThreadListItem primitives must be used inside ThreadListPrimitive.Items.\");\n }\n return value;\n}\n\nexport function useInternalThreadListRoot(): InternalThreadListRootContextValue {\n const value = useContext(ThreadListRootContext);\n if (value === undefined) {\n throw new Error(\"Thread-list primitives must be used inside ThreadListPrimitive.Root.\");\n }\n return value;\n}\n"],"mappings":";AACA,SAAS,eAAe,eAAkD,kBAAkB;AAO5F,IAAM,oBAAoB,cAAkD,MAAS;AAE9E,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAGiB;AACf,SAAO,cAAc,kBAAkB,UAAU,EAAE,MAAM,GAAG,QAAQ;AACtE;AAEO,SAAS,gBAAwC;AACtD,QAAM,QAAQ,WAAW,iBAAiB;AAC1C,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,qEAAqE;AAAA,EACvF;AACA,SAAO;AACT;AAEO,SAAS,wBAA4D;AAC1E,SAAO,WAAW,iBAAiB;AACrC;;;ACnBA,SAAS,iBAAAA,gBAAe,iBAAAC,gBAAkD,cAAAC,mBAAkB;AAe5F,IAAM,cAAcF,eAA0C,MAAS;AAEhE,SAAS,aAGd,EAAE,YAAY,SAAS,GAAoD;AAC3E,SAAOC;AAAA,IACL,YAAY;AAAA,IACZ,EAAE,OAAO,WAAwC;AAAA,IACjD;AAAA,EACF;AACF;AAEO,SAAS,iBAGoB;AAClC,QAAM,QAAQC,YAAW,WAAW;AACpC,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AACA,SAAO;AACT;AAEO,SAAS,gBAAgB;AAC9B,QAAM,eAAe,eAAe,EAAE;AACtC,QAAM,YAAY,aAAa,IAAI;AAAA,IACjC,CAAC,SACC,KAAK,QAAQ,SAAS;AAAA,EAC1B;AACA,QAAM,YAAY,aAAa,IAAI;AAAA,IACjC,CAAC,SACC,KAAK,QAAQ,SAAS;AAAA,EAC1B;AACA,SAAO;AAAA,IACL,WAAW;AAAA,M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C1E;AAEO,SAAS,gBAAsC;AACpD,QAAM,QAAQC,aAAW,iBAAiB;AAC1C,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,+DAA+D;AAAA,EACjF;AACA,SAAO;AACT;AAEO,SAAS,oBAAgD;AAC9D,QAAM,QAAQA,aAAW,qBAAqB;AAC9C,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,0EAA0E;AAAA,EAC5F;AACA,SAAO;AACT;AAEO,SAAS,4BAAgE;AAC9E,QAAM,QAAQA,aAAW,qBAAqB;AAC9C,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,sEAAsE;AAAA,EACxF;AACA,SAAO;AACT;","names":["createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext"]}
@@ -1,10 +1,13 @@
1
+ import {
2
+ messageElementFromNode
3
+ } from "./chunk-6XOJFLX4.js";
1
4
  import {
2
5
  renderPrimitive
3
6
  } from "./chunk-T3ZFZ3NP.js";
4
7
  import {
5
8
  InternalSelectionToolbarProvider,
6
9
  useSelectionToolbar
7
- } from "./chunk-F76H3VMN.js";
10
+ } from "./chunk-SOG2GVE4.js";
8
11
 
9
12
  // src/selection-toolbar/parts.tsx
10
13
  import {
@@ -93,8 +96,6 @@ var SelectionToolbarRoot = forwardRef(
93
96
  /* @__PURE__ */ jsx(SelectionToolbarCopy, {})
94
97
  ] }),
95
98
  style: toolbarStyle,
96
- "data-anvia-selection-toolbar": "",
97
- "data-message-id": selection.messageId,
98
99
  role: props.role ?? "toolbar"
99
100
  },
100
101
  ref
@@ -113,7 +114,6 @@ var SelectionToolbarQuote = forwardRef(
113
114
  disabled,
114
115
  onClick: handleClick,
115
116
  type: props.type ?? "button",
116
- "data-anvia-selection-quote": "",
117
117
  "data-state": disabled ? "disabled" : "enabled"
118
118
  },
119
119
  ref
@@ -131,7 +131,6 @@ var SelectionToolbarCopy = forwardRef(
131
131
  disabled,
132
132
  onClick: handleClick,
133
133
  type: props.type ?? "button",
134
- "data-anvia-selection-copy": "",
135
134
  "data-state": disabled ? "disabled" : "enabled"
136
135
  },
137
136
  ref
@@ -165,27 +164,16 @@ function selectionFromDocument(document) {
165
164
  }
166
165
  const anchorMessage = messageElementFromNode(selection.anchorNode);
167
166
  const focusMessage = messageElementFromNode(selection.focusNode);
168
- if (anchorMessage === void 0 || focusMessage === void 0 || anchorMessage !== focusMessage) {
169
- return void 0;
170
- }
171
- const messageId = anchorMessage.getAttribute("data-anvia-message-id");
172
- if (messageId === null || messageId.length === 0) {
167
+ if (anchorMessage === void 0 || focusMessage === void 0 || anchorMessage.element !== focusMessage.element) {
173
168
  return void 0;
174
169
  }
175
170
  const range = selection.getRangeAt(0);
176
171
  return {
177
172
  text,
178
- messageId,
173
+ messageId: anchorMessage.messageId,
179
174
  rect: selectionRect(range)
180
175
  };
181
176
  }
182
- function messageElementFromNode(node) {
183
- if (node === null) {
184
- return void 0;
185
- }
186
- const element = node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement;
187
- return element?.closest("[data-anvia-message-id]") ?? void 0;
188
- }
189
177
  function selectionRect(range) {
190
178
  const rangeWithRect = range;
191
179
  const rect = rangeWithRect.getBoundingClientRect?.();
@@ -220,13 +208,13 @@ function sameSelection(currentSelection, nextSelection) {
220
208
  }
221
209
 
222
210
  // src/selection-toolbar/index.ts
223
- var SelectionToolbar = {
211
+ var SelectionToolbarPrimitive = {
224
212
  Root: SelectionToolbarRoot,
225
213
  Quote: SelectionToolbarQuote,
226
214
  Copy: SelectionToolbarCopy
227
215
  };
228
216
 
229
217
  export {
230
- SelectionToolbar
218
+ SelectionToolbarPrimitive
231
219
  };
232
- //# sourceMappingURL=chunk-ZPNAX4SA.js.map
220
+ //# sourceMappingURL=chunk-UCBAG42A.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/selection-toolbar/parts.tsx","../src/selection-toolbar/index.ts"],"sourcesContent":["import {\n type CSSProperties,\n forwardRef,\n type MouseEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport {\n InternalSelectionToolbarProvider,\n type SelectionToolbarContextValue,\n type SelectionToolbarSelection,\n useSelectionToolbar,\n} from \"../contexts\";\nimport { messageElementFromNode } from \"../message/elements\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype SelectionToolbarRootProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: ReactNode;\n container?: Element | DocumentFragment;\n onQuote?: (selection: SelectionToolbarSelection) => void;\n onSelectionChange?: (selection: SelectionToolbarSelection | undefined) => void;\n};\n\nconst SelectionToolbarRoot = forwardRef<HTMLDivElement, SelectionToolbarRootProps>(\n function SelectionToolbarRoot(\n { children, container, onQuote, onSelectionChange, style, ...props },\n ref,\n ) {\n const [selection, setSelectionState] = useState<SelectionToolbarSelection | undefined>();\n const portalContainer = container ?? globalThis.document?.body;\n\n const setSelection = useCallback(\n (nextSelection: SelectionToolbarSelection | undefined) => {\n setSelectionState((currentSelection) => {\n if (sameSelection(currentSelection, nextSelection)) {\n return currentSelection;\n }\n onSelectionChange?.(nextSelection);\n return nextSelection;\n });\n },\n [onSelectionChange],\n );\n\n const clear = useCallback(() => {\n globalThis.document?.getSelection()?.removeAllRanges();\n setSelection(undefined);\n }, [setSelection]);\n\n const copy = useCallback(async () => {\n if (selection === undefined) {\n return;\n }\n await globalThis.navigator?.clipboard?.writeText(selection.text);\n clear();\n }, [clear, selection]);\n\n const quote = useCallback(() => {\n if (selection === undefined) {\n return;\n }\n onQuote?.(selection);\n clear();\n }, [clear, onQuote, selection]);\n\n const value = useMemo<SelectionToolbarContextValue>(() => {\n const context: SelectionToolbarContextValue = { quote, copy, clear };\n if (selection !== undefined) context.selection = selection;\n return context;\n }, [clear, copy, quote, selection]);\n\n useEffect(() => {\n const document = globalThis.document;\n if (document === undefined) {\n return;\n }\n\n const handleSelectionChange = () => {\n setSelection(selectionFromDocument(document));\n };\n\n document.addEventListener(\"selectionchange\", handleSelectionChange);\n document.addEventListener(\"mouseup\", handleSelectionChange);\n document.addEventListener(\"keyup\", handleSelectionChange);\n document.addEventListener(\"scroll\", handleSelectionChange, true);\n return () => {\n document.removeEventListener(\"selectionchange\", handleSelectionChange);\n document.removeEventListener(\"mouseup\", handleSelectionChange);\n document.removeEventListener(\"keyup\", handleSelectionChange);\n document.removeEventListener(\"scroll\", handleSelectionChange, true);\n };\n }, [setSelection]);\n\n if (selection === undefined || portalContainer === undefined) {\n return null;\n }\n\n const toolbarStyle: CSSProperties = {\n position: \"fixed\",\n top: selection.rect.top,\n left: selection.rect.left + selection.rect.width / 2,\n transform: \"translate(-50%, calc(-100% - 8px))\",\n ...style,\n };\n\n const toolbar = (\n <InternalSelectionToolbarProvider value={value}>\n {renderPrimitive(\n \"div\",\n {\n ...props,\n children: children ?? (\n <>\n <SelectionToolbarQuote />\n <SelectionToolbarCopy />\n </>\n ),\n style: toolbarStyle,\n role: props.role ?? \"toolbar\",\n } as PrimitiveProps<\"div\">,\n ref,\n )}\n </InternalSelectionToolbarProvider>\n );\n\n return createPortal(toolbar, portalContainer);\n },\n);\n\nconst SelectionToolbarQuote = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function SelectionToolbarQuote({ onClick, ...props }, ref) {\n const { disabled, handleClick } = useSelectionToolbarAction(\"quote\", props.disabled, onClick);\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Quote\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-state\": disabled ? \"disabled\" : \"enabled\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nconst SelectionToolbarCopy = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function SelectionToolbarCopy({ onClick, ...props }, ref) {\n const { disabled, handleClick } = useSelectionToolbarAction(\"copy\", props.disabled, onClick);\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Copy\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-state\": disabled ? \"disabled\" : \"enabled\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\ntype SelectionToolbarAction = \"copy\" | \"quote\";\n\nfunction useSelectionToolbarAction(\n actionName: SelectionToolbarAction,\n disabledProp: boolean | undefined,\n onClick: ((event: MouseEvent<HTMLButtonElement>) => void) | undefined,\n): {\n disabled: boolean;\n handleClick(event: MouseEvent<HTMLButtonElement>): void;\n} {\n const toolbar = useSelectionToolbar();\n const disabled = disabledProp ?? toolbar.selection === undefined;\n const action = toolbar[actionName];\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n void action();\n },\n [action, disabled, onClick],\n );\n return { disabled, handleClick };\n}\n\nfunction selectionFromDocument(document: Document): SelectionToolbarSelection | undefined {\n const selection = document.getSelection();\n if (selection === null || selection.rangeCount === 0) {\n return undefined;\n }\n const text = selection.toString();\n if (text.trim().length === 0) {\n return undefined;\n }\n\n const anchorMessage = messageElementFromNode(selection.anchorNode);\n const focusMessage = messageElementFromNode(selection.focusNode);\n if (\n anchorMessage === undefined ||\n focusMessage === undefined ||\n anchorMessage.element !== focusMessage.element\n ) {\n return undefined;\n }\n\n const range = selection.getRangeAt(0);\n return {\n text,\n messageId: anchorMessage.messageId,\n rect: selectionRect(range),\n };\n}\n\nfunction selectionRect(range: Range): DOMRect {\n const rangeWithRect = range as Range & {\n getBoundingClientRect?: () => DOMRect;\n };\n const rect = rangeWithRect.getBoundingClientRect?.();\n if (rect !== undefined && (rect.width > 0 || rect.height > 0)) {\n return rect;\n }\n const firstRect = range.getClientRects().item(0);\n if (firstRect !== null) {\n return firstRect;\n }\n const DOMRectConstructor = globalThis.DOMRect;\n if (DOMRectConstructor !== undefined) {\n return new DOMRectConstructor(0, 0, 0, 0);\n }\n return {\n bottom: 0,\n height: 0,\n left: 0,\n right: 0,\n top: 0,\n width: 0,\n x: 0,\n y: 0,\n toJSON: () => ({}),\n } as DOMRect;\n}\n\nfunction sameSelection(\n currentSelection: SelectionToolbarSelection | undefined,\n nextSelection: SelectionToolbarSelection | undefined,\n): boolean {\n if (currentSelection === undefined || nextSelection === undefined) {\n return currentSelection === nextSelection;\n }\n return (\n currentSelection.text === nextSelection.text &&\n currentSelection.messageId === nextSelection.messageId &&\n currentSelection.rect.left === nextSelection.rect.left &&\n currentSelection.rect.top === nextSelection.rect.top &&\n currentSelection.rect.width === nextSelection.rect.width &&\n currentSelection.rect.height === nextSelection.rect.height\n );\n}\n\nexport { SelectionToolbarCopy, SelectionToolbarQuote, SelectionToolbarRoot };\n","import { SelectionToolbarCopy, SelectionToolbarQuote, SelectionToolbarRoot } from \"./parts\";\n\nexport const SelectionToolbarPrimitive = {\n Root: SelectionToolbarRoot,\n Quote: SelectionToolbarQuote,\n Copy: SelectionToolbarCopy,\n} as const;\n\nexport type { SelectionToolbarContextValue, SelectionToolbarSelection } from \"../contexts\";\nexport { useSelectionToolbar } from \"../contexts\";\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA,EAEE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AA2Gf,mBACE,KADF;AAzFd,IAAM,uBAAuB;AAAA,EAC3B,SAASA,sBACP,EAAE,UAAU,WAAW,SAAS,mBAAmB,OAAO,GAAG,MAAM,GACnE,KACA;AACA,UAAM,CAAC,WAAW,iBAAiB,IAAI,SAAgD;AACvF,UAAM,kBAAkB,aAAa,WAAW,UAAU;AAE1D,UAAM,eAAe;AAAA,MACnB,CAAC,kBAAyD;AACxD,0BAAkB,CAAC,qBAAqB;AACtC,cAAI,cAAc,kBAAkB,aAAa,GAAG;AAClD,mBAAO;AAAA,UACT;AACA,8BAAoB,aAAa;AACjC,iBA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C,WAAO,IAAI,mBAAmB,GAAG,GAAG,GAAG,CAAC;AAAA,EAC1C;AACA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL,OAAO;AAAA,IACP,GAAG;AAAA,IACH,GAAG;AAAA,IACH,QAAQ,OAAO,CAAC;AAAA,EAClB;AACF;AAEA,SAAS,cACP,kBACA,eACS;AACT,MAAI,qBAAqB,UAAa,kBAAkB,QAAW;AACjE,WAAO,qBAAqB;AAAA,EAC9B;AACA,SACE,iBAAiB,SAAS,cAAc,QACxC,iBAAiB,cAAc,cAAc,aAC7C,iBAAiB,KAAK,SAAS,cAAc,KAAK,QAClD,iBAAiB,KAAK,QAAQ,cAAc,KAAK,OACjD,iBAAiB,KAAK,UAAU,cAAc,KAAK,SACnD,iBAAiB,KAAK,WAAW,cAAc,KAAK;AAExD;;;AC5QO,IAAM,4BAA4B;AAAA,EACvC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACR;","names":["SelectionToolbarRoot","SelectionToolbarQuote","SelectionToolbarCopy"]}
@@ -3,7 +3,7 @@ export { C as CompletionController, a as CompletionInputContextValue, b as Compl
3
3
  import '@anvia/client';
4
4
  import '@anvia/react';
5
5
 
6
- declare const Completion: {
6
+ declare const CompletionPrimitive: {
7
7
  readonly Root: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
8
8
  asChild?: boolean;
9
9
  } & react.RefAttributes<HTMLDivElement>>;
@@ -26,4 +26,4 @@ declare const Completion: {
26
26
  } & react.RefAttributes<HTMLButtonElement>>;
27
27
  };
28
28
 
29
- export { Completion };
29
+ export { CompletionPrimitive };
@@ -1,14 +1,14 @@
1
1
  import {
2
- Completion
3
- } from "../chunk-E5UNQCGM.js";
2
+ CompletionPrimitive
3
+ } from "../chunk-S4XLE2RN.js";
4
4
  import "../chunk-T3ZFZ3NP.js";
5
5
  import {
6
6
  CompletionProvider,
7
7
  useCompletionContext,
8
8
  useCompletionInput
9
- } from "../chunk-F76H3VMN.js";
9
+ } from "../chunk-SOG2GVE4.js";
10
10
  export {
11
- Completion,
11
+ CompletionPrimitive,
12
12
  CompletionProvider,
13
13
  useCompletionContext,
14
14
  useCompletionInput
@@ -13,7 +13,7 @@ type HumanInputFilter = "pending" | "all";
13
13
 
14
14
  type QuestionChildren = ReactNode | ((question: QuestionInteraction) => ReactNode);
15
15
 
16
- declare const HumanInput: {
16
+ declare const HumanInputPrimitive: {
17
17
  readonly Panel: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
18
18
  asChild?: boolean;
19
19
  } & {
@@ -75,4 +75,4 @@ declare const HumanInput: {
75
75
  } & react.RefAttributes<HTMLButtonElement>>;
76
76
  };
77
77
 
78
- export { HumanInput, useHumanInput };
78
+ export { HumanInputPrimitive, useHumanInput };
@@ -1,6 +1,6 @@
1
1
  import {
2
- HumanInput
3
- } from "../chunk-PSU4V23X.js";
2
+ HumanInputPrimitive
3
+ } from "../chunk-OQE6SHZE.js";
4
4
  import "../chunk-CKA4CE26.js";
5
5
  import "../chunk-T3ZFZ3NP.js";
6
6
  import {
@@ -9,9 +9,9 @@ import {
9
9
  useHumanInput,
10
10
  useQuestion,
11
11
  useQuestionPrompt
12
- } from "../chunk-F76H3VMN.js";
12
+ } from "../chunk-SOG2GVE4.js";
13
13
  export {
14
- HumanInput,
14
+ HumanInputPrimitive,
15
15
  useApproval,
16
16
  useChatContext,
17
17
  useHumanInput,
@@ -4,7 +4,7 @@ import { I as ImageContextValue } from '../image-VZv6Ddsn.js';
4
4
  export { u as useImage } from '../image-VZv6Ddsn.js';
5
5
  import { P as PrimitiveProps } from '../render-CRKWam2v.js';
6
6
 
7
- declare const Image: {
7
+ declare const ImagePrimitive: {
8
8
  readonly Root: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"figure">, "children"> & {
9
9
  attachment?: _anvia_client.UIAttachment;
10
10
  children?: react.ReactNode | ((image: ImageContextValue) => react.ReactNode);
@@ -37,4 +37,4 @@ declare const Image: {
37
37
  } & react.RefAttributes<HTMLDivElement>>;
38
38
  };
39
39
 
40
- export { Image, ImageContextValue };
40
+ export { ImageContextValue, ImagePrimitive };
@@ -1,12 +1,12 @@
1
1
  import {
2
- Image
3
- } from "../chunk-EWIHRMU6.js";
2
+ ImagePrimitive
3
+ } from "../chunk-CVXLQCDI.js";
4
4
  import "../chunk-T3ZFZ3NP.js";
5
5
  import {
6
6
  useImage
7
- } from "../chunk-F76H3VMN.js";
7
+ } from "../chunk-SOG2GVE4.js";
8
8
  export {
9
- Image,
9
+ ImagePrimitive,
10
10
  useImage
11
11
  };
12
12
  //# sourceMappingURL=index.js.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Attachment } from './attachment/index.js';
1
+ export { AttachmentPrimitive } from './attachment/index.js';
2
2
  export { A as AttachmentContextValue, u as useAttachment } from './attachment-mbjsroli.js';
3
3
  export { C as ChatController, a as ChatProvider, b as ChatProviderProps, u as useChatContext, c as useHumanInput } from './chat-tfA570mg.js';
4
4
  export { C as CompletionController, a as CompletionInputContextValue, b as CompletionProvider, c as CompletionProviderProps, u as useCompletionContext, d as useCompletionInput } from './completion-input-DHlwrhxB.js';
@@ -7,21 +7,21 @@ export { A as ApprovalContextValue, Q as QuestionContextValue, a as QuestionProm
7
7
  export { I as ImageContextValue, u as useImage } from './image-VZv6Ddsn.js';
8
8
  export { M as MessageContextValue, a as MessagePartContextValue, u as useMessage, b as useMessagePart } from './message-CNRnZQwU.js';
9
9
  export { S as SelectionToolbarContextValue, a as SelectionToolbarSelection, u as useSelectionToolbar } from './selection-toolbar-Cwjbuv5S.js';
10
- export { T as ThreadContextValue, u as useThread } from './thread-uEm8hH0s.js';
10
+ export { T as ThreadContextValue, u as useThread } from './thread-Bz6-1zaJ.js';
11
11
  export { T as ThreadListController, a as ThreadListItemContextValue, b as ThreadListProvider, c as ThreadListProviderProps, d as ThreadListRecord, u as useThreadList, e as useThreadListItem } from './thread-list-On8db4XL.js';
12
- export { Composer, ComposerSubmitMessage, ComposerSubmitMessageArgs, Thread } from './chat/index.js';
13
- export { Completion } from './completion/index.js';
12
+ export { ComposerPrimitive, ComposerSubmitMessage, ComposerSubmitMessageArgs, ThreadPrimitive } from './chat/index.js';
13
+ export { CompletionPrimitive } from './completion/index.js';
14
14
  import * as react from 'react';
15
15
  import { ReactNode } from 'react';
16
16
  import { UseChatResult } from '@anvia/react';
17
17
  import { P as PrimitiveProps } from './render-CRKWam2v.js';
18
18
  export { a as PrimitiveRef } from './render-CRKWam2v.js';
19
- export { HumanInput } from './human-input/index.js';
20
- export { Image } from './image/index.js';
21
- export { Message, MessageAttachmentPart, MessageEntityProps, MessagePartsFilter, MessageStreamOptions, MessageToolPart, MessageToolRenderWhen } from './message/index.js';
22
- export { SelectionToolbar } from './selection-toolbar/index.js';
19
+ export { HumanInputPrimitive } from './human-input/index.js';
20
+ export { ImagePrimitive } from './image/index.js';
21
+ export { MessageAttachmentPart, MessageEntityProps, MessagePartsFilter, MessagePrimitive, MessageStreamOptions, MessageToolPart, MessageToolRenderWhen } from './message/index.js';
22
+ export { SelectionToolbarPrimitive } from './selection-toolbar/index.js';
23
23
  export { StreamMarkdown, StreamMarkdownProps } from './stream/index.js';
24
- export { ThreadList, ThreadListItem } from './thread-list/index.js';
24
+ export { ThreadListItemPrimitive, ThreadListPrimitive } from './thread-list/index.js';
25
25
  import '@anvia/client';
26
26
  import 'react-markdown';
27
27
 
@@ -31,10 +31,10 @@ type ContextMeterProps = Omit<PrimitiveProps<"div">, "children"> & {
31
31
  display?: "remaining" | "used";
32
32
  children?: ReactNode | ((usage: ContextUsage) => ReactNode);
33
33
  };
34
- declare const ContextMeter: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"div">, "children"> & {
34
+ declare const ContextMeterPrimitive: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"div">, "children"> & {
35
35
  usage?: ContextUsage;
36
36
  display?: "remaining" | "used";
37
37
  children?: ReactNode | ((usage: ContextUsage) => ReactNode);
38
38
  } & react.RefAttributes<HTMLDivElement>>;
39
39
 
40
- export { ContextMeter, type ContextMeterProps, PrimitiveProps };
40
+ export { ContextMeterPrimitive, type ContextMeterProps, PrimitiveProps };