@anvia/react-ui 0.2.0 → 0.4.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 (48) hide show
  1. package/README.md +14 -1
  2. package/dist/attachment/index.js +2 -2
  3. package/dist/chat/index.d.ts +39 -3
  4. package/dist/chat/index.js +4 -4
  5. package/dist/{chunk-RRINF6FN.js → chunk-32QFNRXR.js} +2 -2
  6. package/dist/chunk-657E5BPN.js +291 -0
  7. package/dist/chunk-657E5BPN.js.map +1 -0
  8. package/dist/{chunk-7AS6R7BB.js → chunk-BCCU3VT5.js} +93 -16
  9. package/dist/chunk-BCCU3VT5.js.map +1 -0
  10. package/dist/{chunk-AOZN3SWB.js → chunk-FZANAMWH.js} +4 -3
  11. package/dist/{chunk-AOZN3SWB.js.map → chunk-FZANAMWH.js.map} +1 -1
  12. package/dist/chunk-GXB4VINL.js +236 -0
  13. package/dist/chunk-GXB4VINL.js.map +1 -0
  14. package/dist/{chunk-WK33ER4Q.js → chunk-JUNV3MUR.js} +2 -2
  15. package/dist/chunk-KO36TK2O.js +1549 -0
  16. package/dist/chunk-KO36TK2O.js.map +1 -0
  17. package/dist/chunk-SE7I6ZXJ.js +432 -0
  18. package/dist/chunk-SE7I6ZXJ.js.map +1 -0
  19. package/dist/{chunk-LSHD67YK.js → chunk-TOBAQM2G.js} +2 -2
  20. package/dist/completion/index.js +2 -2
  21. package/dist/human-input/index.js +2 -2
  22. package/dist/image/index.d.ts +40 -0
  23. package/dist/image/index.js +12 -0
  24. package/dist/image/index.js.map +1 -0
  25. package/dist/image-DanUxcl2.d.ts +14 -0
  26. package/dist/index.d.ts +7 -1
  27. package/dist/index.js +32 -8
  28. package/dist/message/index.js +3 -3
  29. package/dist/selection-toolbar/index.d.ts +21 -0
  30. package/dist/selection-toolbar/index.js +12 -0
  31. package/dist/selection-toolbar/index.js.map +1 -0
  32. package/dist/selection-toolbar-Cwjbuv5S.d.ts +14 -0
  33. package/dist/shared.d.ts +4 -1
  34. package/dist/shared.js +13 -3
  35. package/dist/styles.css +42 -0
  36. package/dist/thread-C2-Xo08o.d.ts +102 -0
  37. package/dist/thread-list/index.d.ts +47 -0
  38. package/dist/thread-list/index.js +18 -0
  39. package/dist/thread-list/index.js.map +1 -0
  40. package/dist/thread-list-On8db4XL.d.ts +34 -0
  41. package/package.json +27 -4
  42. package/dist/chunk-7AS6R7BB.js.map +0 -1
  43. package/dist/chunk-AXZB6JSE.js +0 -813
  44. package/dist/chunk-AXZB6JSE.js.map +0 -1
  45. package/dist/thread-CluT3m5k.d.ts +0 -31
  46. /package/dist/{chunk-RRINF6FN.js.map → chunk-32QFNRXR.js.map} +0 -0
  47. /package/dist/{chunk-WK33ER4Q.js.map → chunk-JUNV3MUR.js.map} +0 -0
  48. /package/dist/{chunk-LSHD67YK.js.map → chunk-TOBAQM2G.js.map} +0 -0
@@ -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/react\";\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 Attachment.Root.\");\n }\n return value;\n}\n\nexport function useOptionalAttachment(): AttachmentContextValue | undefined {\n return useContext(AttachmentContext);\n}\n","import type { UseChatResult } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type ChatController<TEvent = unknown> = UseChatResult<TEvent>;\n\nexport type ChatProviderProps<TEvent = unknown> = {\n controller: ChatController<TEvent>;\n children?: ReactNode;\n};\n\nconst ChatContext = createContext<ChatController | undefined>(undefined);\n\nexport function ChatProvider<TEvent = unknown>({\n controller,\n children,\n}: ChatProviderProps<TEvent>): ReactElement {\n return createElement(ChatContext.Provider, { value: controller as ChatController }, children);\n}\n\nexport function useChatContext<TEvent = unknown>(): ChatController<TEvent> {\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 ChatController<TEvent>;\n}\n\nexport function useHumanInput(): ChatController[\"humanInput\"] {\n return useChatContext().humanInput;\n}\n","import type { UseCompletionResult } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type CompletionController<TEvent = unknown> = UseCompletionResult<TEvent>;\n\nexport type CompletionProviderProps<TEvent = unknown> = {\n controller: CompletionController<TEvent>;\n children?: ReactNode;\n};\n\nconst CompletionContext = createContext<CompletionController | undefined>(undefined);\n\nexport function CompletionProvider<TEvent = unknown>({\n controller,\n children,\n}: CompletionProviderProps<TEvent>): ReactElement {\n return createElement(\n CompletionContext.Provider,\n { value: controller as CompletionController },\n children,\n );\n}\n\nexport function useCompletionContext<TEvent = unknown>(): CompletionController<TEvent> {\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 CompletionController<TEvent>;\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 Completion.Form.\");\n }\n return value;\n}\n","import type { CreateUIAttachment, UIAttachment } from \"@anvia/react\";\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 | ComposerEntityData[]\n | { [key: string]: ComposerEntityData | undefined };\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};\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 Composer.Root.\");\n }\n return value;\n}\n","import type {\n ToolApproval,\n ToolQuestion,\n ToolQuestionAnswer,\n ToolQuestionPrompt,\n} from \"@anvia/react\";\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: ToolApproval;\n reason: string;\n setReason(reason: string): void;\n};\n\nexport type QuestionContextValue = {\n question: ToolQuestion;\n answers: Record<string, ToolQuestionAnswer>;\n setAnswer(prompt: ToolQuestionPrompt, answer: ToolQuestionAnswer): void;\n};\n\nexport type QuestionPromptContextValue = {\n prompt: ToolQuestionPrompt;\n};\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: ToolApproval;\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: ToolQuestionPrompt;\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 HumanInput.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 HumanInput.Question.\");\n }\n return value;\n}\n\nexport function useQuestionPrompt(): QuestionPromptContextValue {\n const value = useContext(QuestionPromptContext);\n if (value === undefined) {\n throw new Error(\"Question choice primitives must be used inside HumanInput.QuestionPrompt.\");\n }\n return value;\n}\n","import type { UIAttachment } from \"@anvia/react\";\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 Image.Root.\");\n }\n return value;\n}\n","import type { UIMessage, UIMessagePart } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type MessageContextValue = {\n message: UIMessage;\n};\n\nexport type MessagePartContextValue = {\n part: UIMessagePart;\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 children,\n}: {\n part: UIMessagePart;\n children?: ReactNode;\n}): ReactElement {\n return createElement(MessagePartContext.Provider, { value: { part } }, children);\n}\n\nexport function useMessage(): MessageContextValue {\n const value = useContext(MessageContext);\n if (value === undefined) {\n throw new Error(\"Message primitives must be used inside Message.Root or Thread.Messages.\");\n }\n return value;\n}\n\nexport function useMessagePart(): MessagePartContextValue {\n const value = useContext(MessagePartContext);\n if (value === undefined) {\n throw new Error(\"Message part primitives must be used inside Message.Parts or Message.Part.\");\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(\"SelectionToolbar primitives must be used inside SelectionToolbar.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 ThreadContextValue = {\n viewportRef: 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 Thread.Root.\");\n }\n return value;\n}\n","import { createContext, createElement, type ReactElement, type ReactNode, useContext } 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\nconst ThreadListContext = createContext<ThreadListController | undefined>(undefined);\nconst ThreadListItemContext = createContext<ThreadListItemContextValue | undefined>(undefined);\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 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 ThreadList.Items.\");\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,4DAA4D;AAAA,EAC9E;AACA,SAAO;AACT;AAEO,SAAS,wBAA4D;AAC1E,SAAO,WAAW,iBAAiB;AACrC;;;AC7BA,SAAS,iBAAAA,gBAAe,iBAAAC,gBAAkD,cAAAC,mBAAkB;AAS5F,IAAM,cAAcF,eAA0C,MAAS;AAEhE,SAAS,aAA+B;AAAA,EAC7C;AAAA,EACA;AACF,GAA4C;AAC1C,SAAOC,eAAc,YAAY,UAAU,EAAE,OAAO,WAA6B,GAAG,QAAQ;AAC9F;AAEO,SAAS,iBAA2D;AACzE,QAAM,QAAQC,Y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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,6 +1,6 @@
1
1
  import {
2
2
  Attachment
3
- } from "./chunk-RRINF6FN.js";
3
+ } from "./chunk-32QFNRXR.js";
4
4
  import {
5
5
  renderPrimitive
6
6
  } from "./chunk-T3ZFZ3NP.js";
@@ -11,7 +11,7 @@ import {
11
11
  useMessage,
12
12
  useMessagePart,
13
13
  useOptionalMessagePart
14
- } from "./chunk-7AS6R7BB.js";
14
+ } from "./chunk-BCCU3VT5.js";
15
15
 
16
16
  // src/message/actions.tsx
17
17
  import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
@@ -481,6 +481,7 @@ var MessageRoot = forwardRef3(function MessageRoot2({ children, ...props }, ref)
481
481
  ...props,
482
482
  children: renderedChildren,
483
483
  "data-anvia-message": "",
484
+ "data-anvia-message-id": message.id,
484
485
  "data-role": message.role
485
486
  },
486
487
  ref
@@ -526,4 +527,4 @@ var Message = {
526
527
  export {
527
528
  Message
528
529
  };
529
- //# sourceMappingURL=chunk-AOZN3SWB.js.map
530
+ //# sourceMappingURL=chunk-FZANAMWH.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/message/actions.tsx","../src/format/message.ts","../src/format/value.ts","../src/message/parts.tsx","../src/message/root.tsx","../src/message/index.ts"],"sourcesContent":["import { forwardRef, type MouseEvent, useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useChatContext, useMessage } from \"../contexts\";\nimport { messageText } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\nconst MessageActions = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageActions(props, ref) {\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? (\n <>\n <MessageCopy />\n <MessageRegenerate />\n </>\n ),\n \"data-anvia-message-actions\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageCopyState = \"idle\" | \"copied\" | \"error\";\n\nconst MessageCopy = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(function MessageCopy(\n { onClick, ...props },\n ref,\n) {\n const { message } = useMessage();\n const [copyState, setCopyState] = useState<MessageCopyState>(\"idle\");\n const text = messageText(message);\n const previousTextRef = useRef(text);\n const disabled = props.disabled ?? text.length === 0;\n\n useEffect(() => {\n if (previousTextRef.current !== text) {\n previousTextRef.current = text;\n setCopyState(\"idle\");\n }\n }, [text]);\n\n const handleClick = useCallback(\n async (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n const writeText = navigator.clipboard?.writeText;\n if (writeText === undefined) {\n setCopyState(\"error\");\n return;\n }\n try {\n await writeText.call(navigator.clipboard, text);\n setCopyState(\"copied\");\n } catch {\n setCopyState(\"error\");\n }\n },\n [disabled, onClick, text],\n );\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-anvia-copy\": \"\",\n \"data-state\": copyState,\n } as PrimitiveProps<\"button\">,\n ref,\n );\n});\n\nconst MessageRegenerate = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function MessageRegenerate({ onClick, ...props }, ref) {\n const chat = useChatContext();\n const { message } = useMessage();\n const latestAssistantMessage = [...chat.messages]\n .reverse()\n .find((item) => item.role === \"assistant\");\n const disabled =\n props.disabled ??\n (chat.status === \"streaming\" ||\n message.role !== \"assistant\" ||\n latestAssistantMessage?.id !== message.id);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n void chat.regenerate();\n },\n [chat, disabled, onClick],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Regenerate\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-regenerate\": \"\",\n \"data-state\": disabled ? \"disabled\" : \"idle\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nexport { MessageActions, MessageCopy, MessageRegenerate };\n","import type { UIMessage, UIMessagePart } from \"@anvia/react\";\n\nexport function messageText(message: UIMessage): string {\n return message.parts\n .filter((part): part is Extract<UIMessagePart, { type: \"text\" }> => part.type === \"text\")\n .map((part) => part.text)\n .join(\"\");\n}\n","export function stringifyValue(value: unknown): string {\n if (value === undefined) {\n return \"\";\n }\n if (typeof value === \"string\") {\n return value;\n }\n try {\n return JSON.stringify(value, null, 2);\n } catch {\n return String(value);\n }\n}\n","import type { UIAttachment, UIMessagePart } from \"@anvia/react\";\nimport { type ComponentPropsWithoutRef, forwardRef, type ReactNode } from \"react\";\nimport ReactMarkdown, {\n type Components,\n type Options as ReactMarkdownOptions,\n} from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\n\nimport { Attachment } from \"../attachment/index\";\nimport {\n InternalAttachmentProvider,\n InternalMessagePartProvider,\n useMessage,\n useMessagePart,\n useOptionalMessagePart,\n} from \"../contexts\";\nimport { stringifyValue } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype MessagePartChildren = ReactNode | ((part: UIMessagePart) => ReactNode);\nexport type MessagePartsFilter = (part: UIMessagePart) => boolean;\nexport type MessageToolPart = Extract<UIMessagePart, { type: \"tool\" }>;\ntype MessageToolChildren = ReactNode | ((part: MessageToolPart) => ReactNode);\nexport type MessageToolRenderWhen = \"always\" | \"pending\" | \"settled\";\nexport type MessageAttachmentPart = Extract<UIMessagePart, { type: \"attachment\" }>;\ntype MessageAttachmentChildren = ReactNode | ((attachment: UIAttachment) => ReactNode);\n\ntype MessagePartsProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessagePartChildren;\n filter?: MessagePartsFilter;\n};\n\nconst MessageParts = forwardRef<HTMLDivElement, MessagePartsProps>(function MessageParts(\n { children, filter, ...props },\n ref,\n) {\n const { message } = useMessage();\n const parts = filter === undefined ? message.parts : message.parts.filter(filter);\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: parts.map((part) => (\n <InternalMessagePartProvider key={part.id} part={part}>\n {typeof children === \"function\" ? children(part) : (children ?? <MessagePart />)}\n </InternalMessagePartProvider>\n )),\n \"data-anvia-message-parts\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype MessagePartProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessagePartChildren;\n};\n\nconst MessagePart = forwardRef<HTMLDivElement, MessagePartProps>(function MessagePart(\n { children, ...props },\n ref,\n) {\n const { part } = useMessagePart();\n const renderedChildren =\n typeof children === \"function\" ? children(part) : (children ?? defaultPart(part));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-part\": \"\",\n \"data-part\": part.type,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst MessageText = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageText(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"text\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? part.text,\n \"data-anvia-text\": \"\",\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\ntype MessageMarkdownProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: string;\n components?: Components;\n remarkPlugins?: ReactMarkdownOptions[\"remarkPlugins\"];\n};\n\nconst MessageMarkdown = forwardRef<HTMLDivElement, MessageMarkdownProps>(function MessageMarkdown(\n { children, components, remarkPlugins, ...props },\n ref,\n) {\n const { message } = useMessage();\n const partContext = useOptionalMessagePart();\n const part = partContext?.part;\n if (part !== undefined && part.type !== \"text\") {\n return null;\n }\n\n const markdown =\n children ??\n (part?.type === \"text\"\n ? part.text\n : message.parts.flatMap((item) => (item.type === \"text\" ? [item.text] : [])).join(\"\\n\\n\"));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: (\n <ReactMarkdown\n components={{ code: defaultCodeComponent, pre: defaultPreComponent, ...components }}\n remarkPlugins={remarkPlugins ?? [remarkGfm]}\n >\n {markdown}\n </ReactMarkdown>\n ),\n \"data-anvia-markdown\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype MessageCodeBlockProps = Omit<PrimitiveProps<\"pre\">, \"children\"> & {\n children?: ReactNode;\n code?: string;\n language?: string;\n};\n\nconst MessageCodeBlock = forwardRef<HTMLPreElement, MessageCodeBlockProps>(\n function MessageCodeBlock({ children, code, language, ...props }, ref) {\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: children ?? (\n <code data-anvia-code=\"\" data-language={language}>\n {code ?? \"\"}\n </code>\n ),\n \"data-anvia-code-block\": \"\",\n \"data-language\": language,\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageReasoning = forwardRef<HTMLDetailsElement, PrimitiveProps<\"details\">>(\n function MessageReasoning(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"reasoning\") {\n return null;\n }\n\n return renderPrimitive(\n \"details\",\n {\n ...props,\n children: props.children ?? (\n <>\n <summary>Reasoning</summary>\n <pre>{part.text}</pre>\n </>\n ),\n \"data-anvia-reasoning\": \"\",\n } as PrimitiveProps<\"details\">,\n ref,\n );\n },\n);\n\ntype MessageToolProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessageToolChildren;\n renderWhen?: MessageToolRenderWhen;\n};\n\nconst MessageTool = forwardRef<HTMLDivElement, MessageToolProps>(function MessageTool(\n { children, renderWhen = \"always\", ...props },\n ref,\n) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || !shouldRenderTool(part, renderWhen)) {\n return null;\n }\n const renderedChildren =\n typeof children === \"function\" ? children(part) : (children ?? defaultToolContent());\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-tool\": \"\",\n \"data-state\": part.state,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst MessageToolName = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageToolName(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? part.toolName,\n \"data-anvia-tool-name\": \"\",\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\nconst MessageToolStatus = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageToolStatus(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? toolStateLabel(part.state),\n \"data-anvia-tool-status\": \"\",\n \"data-state\": part.state,\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\nconst MessageToolInput = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageToolInput(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.input === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.input),\n \"data-anvia-tool-input\": \"\",\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageToolOutput = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageToolOutput(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.output === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.output),\n \"data-anvia-tool-output\": \"\",\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageToolError = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageToolError(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.error === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? part.error.message,\n \"data-anvia-tool-error\": \"\",\n role: props.role ?? \"alert\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageAttachmentProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessageAttachmentChildren;\n};\n\nconst MessageAttachment = forwardRef<HTMLDivElement, MessageAttachmentProps>(\n function MessageAttachment({ children, ...props }, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"attachment\") {\n return null;\n }\n const renderedChildren =\n typeof children === \"function\"\n ? children(part.attachment)\n : (children ?? <Attachment.Root />);\n\n return (\n <InternalAttachmentProvider value={{ attachment: part.attachment }}>\n {renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-message-attachment\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n )}\n </InternalAttachmentProvider>\n );\n },\n);\n\nconst MessageData = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageData(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"data\") {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.data),\n \"data-anvia-data\": \"\",\n \"data-name\": part.name,\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageError = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageError(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"error\") {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? part.error.message,\n \"data-anvia-error\": \"\",\n role: props.role ?? \"alert\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nfunction defaultPart(part: UIMessagePart): ReactNode {\n if (part.type === \"text\") {\n return <MessageText />;\n }\n if (part.type === \"reasoning\") {\n return <MessageReasoning />;\n }\n if (part.type === \"tool\") {\n return <MessageTool />;\n }\n if (part.type === \"attachment\") {\n return <MessageAttachment />;\n }\n if (part.type === \"data\") {\n return <MessageData />;\n }\n return <MessageError />;\n}\n\nfunction defaultToolContent(): ReactNode {\n return (\n <>\n <MessageToolName />\n <MessageToolStatus />\n <MessageToolInput />\n <MessageToolOutput />\n <MessageToolError />\n </>\n );\n}\n\nfunction defaultCodeComponent({\n children,\n className,\n node: _node,\n ...props\n}: ComponentPropsWithoutRef<\"code\"> & { node?: unknown }): ReactNode {\n const language = /language-(\\S+)/.exec(className ?? \"\")?.[1];\n\n return (\n <code\n className={className}\n data-anvia-code=\"\"\n data-anvia-inline-code={language === undefined ? \"\" : undefined}\n data-language={language}\n {...props}\n >\n {children}\n </code>\n );\n}\n\nfunction defaultPreComponent({\n children,\n node: _node,\n ...props\n}: ComponentPropsWithoutRef<\"pre\"> & { node?: unknown }): ReactNode {\n return <MessageCodeBlock {...props}>{children}</MessageCodeBlock>;\n}\n\nfunction shouldRenderTool(part: MessageToolPart, renderWhen: MessageToolRenderWhen): boolean {\n if (renderWhen === \"always\") {\n return true;\n }\n if (renderWhen === \"pending\") {\n return part.state === \"input-streaming\" || part.state === \"input-available\";\n }\n return part.state === \"output-available\" || part.state === \"error\";\n}\n\nfunction toolStateLabel(state: MessageToolPart[\"state\"]): string {\n if (state === \"output-available\") {\n return \"Done\";\n }\n if (state === \"error\") {\n return \"Error\";\n }\n return \"Running\";\n}\n\nexport {\n MessageAttachment,\n MessageCodeBlock,\n MessageData,\n MessageError,\n MessageMarkdown,\n MessagePart,\n MessageParts,\n MessageReasoning,\n MessageText,\n MessageTool,\n MessageToolError,\n MessageToolInput,\n MessageToolName,\n MessageToolOutput,\n MessageToolStatus,\n};\n","import type { UIMessage } from \"@anvia/react\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nimport { useMessage } from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype MessageChildren = ReactNode | ((message: UIMessage) => ReactNode);\n\ntype MessageRootProps = Omit<PrimitiveProps<\"article\">, \"children\"> & {\n children?: MessageChildren;\n};\n\nconst MessageRoot = forwardRef<HTMLElement, MessageRootProps>(function MessageRoot(\n { children, ...props },\n ref,\n) {\n const { message } = useMessage();\n const renderedChildren = typeof children === \"function\" ? children(message) : children;\n\n return renderPrimitive(\n \"article\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-message\": \"\",\n \"data-role\": message.role,\n } as PrimitiveProps<\"article\">,\n ref,\n );\n});\n\nconst MessageContent = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageContent(props, ref) {\n return renderPrimitive(\n \"div\",\n {\n ...props,\n \"data-anvia-message-content\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport { MessageContent, MessageRoot };\n","import { MessageActions, MessageCopy, MessageRegenerate } from \"./actions\";\nimport {\n MessageAttachment,\n MessageCodeBlock,\n MessageData,\n MessageError,\n MessageMarkdown,\n MessagePart,\n MessageParts,\n MessageReasoning,\n MessageText,\n MessageTool,\n MessageToolError,\n MessageToolInput,\n MessageToolName,\n MessageToolOutput,\n MessageToolStatus,\n} from \"./parts\";\nimport { MessageContent, MessageRoot } from \"./root\";\n\nexport const Message = {\n Root: MessageRoot,\n Content: MessageContent,\n Parts: MessageParts,\n Part: MessagePart,\n Text: MessageText,\n Markdown: MessageMarkdown,\n CodeBlock: MessageCodeBlock,\n Reasoning: MessageReasoning,\n Tool: MessageTool,\n ToolName: MessageToolName,\n ToolInput: MessageToolInput,\n ToolOutput: MessageToolOutput,\n ToolError: MessageToolError,\n ToolStatus: MessageToolStatus,\n Attachment: MessageAttachment,\n Data: MessageData,\n Error: MessageError,\n Actions: MessageActions,\n Copy: MessageCopy,\n Regenerate: MessageRegenerate,\n} as const;\n\nexport type { MessageContextValue, MessagePartContextValue } from \"../contexts\";\nexport { useChatContext, useMessage, useMessagePart } from \"../contexts\";\nexport type {\n MessageAttachmentPart,\n MessagePartsFilter,\n MessageToolPart,\n MessageToolRenderWhen,\n} from \"./parts\";\n"],"mappings":";;;;;;;;;;;;;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UAAU,oBAAoB;AAChC,WAAO;AAAA,EACT;AACA,MAAI,UAAU,SAAS;AACrB,WAAO;AAAA,EACT;AACA,SAAO;AACT;;;AC5cA,SAAS,cAAAkB,mBAAkC;AAW3C,IAAM,cAAcC,YAA0C,SAASC,aACrE,EAAE,UAAU,GAAG,MAAM,GACrB,KACA;AACA,QAAM,EAAE,QAAQ,IAAI,WAAW;AAC/B,QAAM,mBAAmB,OAAO,aAAa,aAAa,SAAS,OAAO,IAAI;AAE9E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,UAAU;AAAA,MACV,sBAAsB;AAAA,MACtB,aAAa,QAAQ;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACF,CAAC;AAED,IAAM,iBAAiBD;AAAA,EACrB,SAASE,gBAAe,OAAO,KAAK;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,8BAA8B;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;;;ACtBO,IAAM,UAAU;AAAA,EACrB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,YAAY;AACd;","names":["MessageActions","MessageCopy","MessageRegenerate","forwardRef","Fragment","jsx","jsxs","forwardRef","MessageParts","MessagePart","MessageText","MessageMarkdown","MessageCodeBlock","MessageReasoning","MessageTool","MessageToolName","MessageToolStatus","MessageToolInput","MessageToolOutput","MessageToolError","MessageAttachment","MessageData","MessageError","forwardRef","forwardRef","MessageRoot","MessageContent"]}
1
+ {"version":3,"sources":["../src/message/actions.tsx","../src/format/message.ts","../src/format/value.ts","../src/message/parts.tsx","../src/message/root.tsx","../src/message/index.ts"],"sourcesContent":["import { forwardRef, type MouseEvent, useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useChatContext, useMessage } from \"../contexts\";\nimport { messageText } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\nconst MessageActions = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageActions(props, ref) {\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? (\n <>\n <MessageCopy />\n <MessageRegenerate />\n </>\n ),\n \"data-anvia-message-actions\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageCopyState = \"idle\" | \"copied\" | \"error\";\n\nconst MessageCopy = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(function MessageCopy(\n { onClick, ...props },\n ref,\n) {\n const { message } = useMessage();\n const [copyState, setCopyState] = useState<MessageCopyState>(\"idle\");\n const text = messageText(message);\n const previousTextRef = useRef(text);\n const disabled = props.disabled ?? text.length === 0;\n\n useEffect(() => {\n if (previousTextRef.current !== text) {\n previousTextRef.current = text;\n setCopyState(\"idle\");\n }\n }, [text]);\n\n const handleClick = useCallback(\n async (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n const writeText = navigator.clipboard?.writeText;\n if (writeText === undefined) {\n setCopyState(\"error\");\n return;\n }\n try {\n await writeText.call(navigator.clipboard, text);\n setCopyState(\"copied\");\n } catch {\n setCopyState(\"error\");\n }\n },\n [disabled, onClick, text],\n );\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-anvia-copy\": \"\",\n \"data-state\": copyState,\n } as PrimitiveProps<\"button\">,\n ref,\n );\n});\n\nconst MessageRegenerate = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function MessageRegenerate({ onClick, ...props }, ref) {\n const chat = useChatContext();\n const { message } = useMessage();\n const latestAssistantMessage = [...chat.messages]\n .reverse()\n .find((item) => item.role === \"assistant\");\n const disabled =\n props.disabled ??\n (chat.status === \"streaming\" ||\n message.role !== \"assistant\" ||\n latestAssistantMessage?.id !== message.id);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n void chat.regenerate();\n },\n [chat, disabled, onClick],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Regenerate\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-regenerate\": \"\",\n \"data-state\": disabled ? \"disabled\" : \"idle\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nexport { MessageActions, MessageCopy, MessageRegenerate };\n","import type { UIMessage, UIMessagePart } from \"@anvia/react\";\n\nexport function messageText(message: UIMessage): string {\n return message.parts\n .filter((part): part is Extract<UIMessagePart, { type: \"text\" }> => part.type === \"text\")\n .map((part) => part.text)\n .join(\"\");\n}\n","export function stringifyValue(value: unknown): string {\n if (value === undefined) {\n return \"\";\n }\n if (typeof value === \"string\") {\n return value;\n }\n try {\n return JSON.stringify(value, null, 2);\n } catch {\n return String(value);\n }\n}\n","import type { UIAttachment, UIMessagePart } from \"@anvia/react\";\nimport { type ComponentPropsWithoutRef, forwardRef, type ReactNode } from \"react\";\nimport ReactMarkdown, {\n type Components,\n type Options as ReactMarkdownOptions,\n} from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\n\nimport { Attachment } from \"../attachment/index\";\nimport {\n InternalAttachmentProvider,\n InternalMessagePartProvider,\n useMessage,\n useMessagePart,\n useOptionalMessagePart,\n} from \"../contexts\";\nimport { stringifyValue } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype MessagePartChildren = ReactNode | ((part: UIMessagePart) => ReactNode);\nexport type MessagePartsFilter = (part: UIMessagePart) => boolean;\nexport type MessageToolPart = Extract<UIMessagePart, { type: \"tool\" }>;\ntype MessageToolChildren = ReactNode | ((part: MessageToolPart) => ReactNode);\nexport type MessageToolRenderWhen = \"always\" | \"pending\" | \"settled\";\nexport type MessageAttachmentPart = Extract<UIMessagePart, { type: \"attachment\" }>;\ntype MessageAttachmentChildren = ReactNode | ((attachment: UIAttachment) => ReactNode);\n\ntype MessagePartsProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessagePartChildren;\n filter?: MessagePartsFilter;\n};\n\nconst MessageParts = forwardRef<HTMLDivElement, MessagePartsProps>(function MessageParts(\n { children, filter, ...props },\n ref,\n) {\n const { message } = useMessage();\n const parts = filter === undefined ? message.parts : message.parts.filter(filter);\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: parts.map((part) => (\n <InternalMessagePartProvider key={part.id} part={part}>\n {typeof children === \"function\" ? children(part) : (children ?? <MessagePart />)}\n </InternalMessagePartProvider>\n )),\n \"data-anvia-message-parts\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype MessagePartProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessagePartChildren;\n};\n\nconst MessagePart = forwardRef<HTMLDivElement, MessagePartProps>(function MessagePart(\n { children, ...props },\n ref,\n) {\n const { part } = useMessagePart();\n const renderedChildren =\n typeof children === \"function\" ? children(part) : (children ?? defaultPart(part));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-part\": \"\",\n \"data-part\": part.type,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst MessageText = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageText(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"text\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? part.text,\n \"data-anvia-text\": \"\",\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\ntype MessageMarkdownProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: string;\n components?: Components;\n remarkPlugins?: ReactMarkdownOptions[\"remarkPlugins\"];\n};\n\nconst MessageMarkdown = forwardRef<HTMLDivElement, MessageMarkdownProps>(function MessageMarkdown(\n { children, components, remarkPlugins, ...props },\n ref,\n) {\n const { message } = useMessage();\n const partContext = useOptionalMessagePart();\n const part = partContext?.part;\n if (part !== undefined && part.type !== \"text\") {\n return null;\n }\n\n const markdown =\n children ??\n (part?.type === \"text\"\n ? part.text\n : message.parts.flatMap((item) => (item.type === \"text\" ? [item.text] : [])).join(\"\\n\\n\"));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: (\n <ReactMarkdown\n components={{ code: defaultCodeComponent, pre: defaultPreComponent, ...components }}\n remarkPlugins={remarkPlugins ?? [remarkGfm]}\n >\n {markdown}\n </ReactMarkdown>\n ),\n \"data-anvia-markdown\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype MessageCodeBlockProps = Omit<PrimitiveProps<\"pre\">, \"children\"> & {\n children?: ReactNode;\n code?: string;\n language?: string;\n};\n\nconst MessageCodeBlock = forwardRef<HTMLPreElement, MessageCodeBlockProps>(\n function MessageCodeBlock({ children, code, language, ...props }, ref) {\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: children ?? (\n <code data-anvia-code=\"\" data-language={language}>\n {code ?? \"\"}\n </code>\n ),\n \"data-anvia-code-block\": \"\",\n \"data-language\": language,\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageReasoning = forwardRef<HTMLDetailsElement, PrimitiveProps<\"details\">>(\n function MessageReasoning(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"reasoning\") {\n return null;\n }\n\n return renderPrimitive(\n \"details\",\n {\n ...props,\n children: props.children ?? (\n <>\n <summary>Reasoning</summary>\n <pre>{part.text}</pre>\n </>\n ),\n \"data-anvia-reasoning\": \"\",\n } as PrimitiveProps<\"details\">,\n ref,\n );\n },\n);\n\ntype MessageToolProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessageToolChildren;\n renderWhen?: MessageToolRenderWhen;\n};\n\nconst MessageTool = forwardRef<HTMLDivElement, MessageToolProps>(function MessageTool(\n { children, renderWhen = \"always\", ...props },\n ref,\n) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || !shouldRenderTool(part, renderWhen)) {\n return null;\n }\n const renderedChildren =\n typeof children === \"function\" ? children(part) : (children ?? defaultToolContent());\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-tool\": \"\",\n \"data-state\": part.state,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst MessageToolName = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageToolName(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? part.toolName,\n \"data-anvia-tool-name\": \"\",\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\nconst MessageToolStatus = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageToolStatus(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? toolStateLabel(part.state),\n \"data-anvia-tool-status\": \"\",\n \"data-state\": part.state,\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\nconst MessageToolInput = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageToolInput(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.input === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.input),\n \"data-anvia-tool-input\": \"\",\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageToolOutput = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageToolOutput(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.output === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.output),\n \"data-anvia-tool-output\": \"\",\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageToolError = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageToolError(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.error === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? part.error.message,\n \"data-anvia-tool-error\": \"\",\n role: props.role ?? \"alert\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageAttachmentProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessageAttachmentChildren;\n};\n\nconst MessageAttachment = forwardRef<HTMLDivElement, MessageAttachmentProps>(\n function MessageAttachment({ children, ...props }, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"attachment\") {\n return null;\n }\n const renderedChildren =\n typeof children === \"function\"\n ? children(part.attachment)\n : (children ?? <Attachment.Root />);\n\n return (\n <InternalAttachmentProvider value={{ attachment: part.attachment }}>\n {renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-message-attachment\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n )}\n </InternalAttachmentProvider>\n );\n },\n);\n\nconst MessageData = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageData(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"data\") {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.data),\n \"data-anvia-data\": \"\",\n \"data-name\": part.name,\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageError = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageError(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"error\") {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? part.error.message,\n \"data-anvia-error\": \"\",\n role: props.role ?? \"alert\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nfunction defaultPart(part: UIMessagePart): ReactNode {\n if (part.type === \"text\") {\n return <MessageText />;\n }\n if (part.type === \"reasoning\") {\n return <MessageReasoning />;\n }\n if (part.type === \"tool\") {\n return <MessageTool />;\n }\n if (part.type === \"attachment\") {\n return <MessageAttachment />;\n }\n if (part.type === \"data\") {\n return <MessageData />;\n }\n return <MessageError />;\n}\n\nfunction defaultToolContent(): ReactNode {\n return (\n <>\n <MessageToolName />\n <MessageToolStatus />\n <MessageToolInput />\n <MessageToolOutput />\n <MessageToolError />\n </>\n );\n}\n\nfunction defaultCodeComponent({\n children,\n className,\n node: _node,\n ...props\n}: ComponentPropsWithoutRef<\"code\"> & { node?: unknown }): ReactNode {\n const language = /language-(\\S+)/.exec(className ?? \"\")?.[1];\n\n return (\n <code\n className={className}\n data-anvia-code=\"\"\n data-anvia-inline-code={language === undefined ? \"\" : undefined}\n data-language={language}\n {...props}\n >\n {children}\n </code>\n );\n}\n\nfunction defaultPreComponent({\n children,\n node: _node,\n ...props\n}: ComponentPropsWithoutRef<\"pre\"> & { node?: unknown }): ReactNode {\n return <MessageCodeBlock {...props}>{children}</MessageCodeBlock>;\n}\n\nfunction shouldRenderTool(part: MessageToolPart, renderWhen: MessageToolRenderWhen): boolean {\n if (renderWhen === \"always\") {\n return true;\n }\n if (renderWhen === \"pending\") {\n return part.state === \"input-streaming\" || part.state === \"input-available\";\n }\n return part.state === \"output-available\" || part.state === \"error\";\n}\n\nfunction toolStateLabel(state: MessageToolPart[\"state\"]): string {\n if (state === \"output-available\") {\n return \"Done\";\n }\n if (state === \"error\") {\n return \"Error\";\n }\n return \"Running\";\n}\n\nexport {\n MessageAttachment,\n MessageCodeBlock,\n MessageData,\n MessageError,\n MessageMarkdown,\n MessagePart,\n MessageParts,\n MessageReasoning,\n MessageText,\n MessageTool,\n MessageToolError,\n MessageToolInput,\n MessageToolName,\n MessageToolOutput,\n MessageToolStatus,\n};\n","import type { UIMessage } from \"@anvia/react\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nimport { useMessage } from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype MessageChildren = ReactNode | ((message: UIMessage) => ReactNode);\n\ntype MessageRootProps = Omit<PrimitiveProps<\"article\">, \"children\"> & {\n children?: MessageChildren;\n};\n\nconst MessageRoot = forwardRef<HTMLElement, MessageRootProps>(function MessageRoot(\n { children, ...props },\n ref,\n) {\n const { message } = useMessage();\n const renderedChildren = typeof children === \"function\" ? children(message) : children;\n\n return renderPrimitive(\n \"article\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-message\": \"\",\n \"data-anvia-message-id\": message.id,\n \"data-role\": message.role,\n } as PrimitiveProps<\"article\">,\n ref,\n );\n});\n\nconst MessageContent = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageContent(props, ref) {\n return renderPrimitive(\n \"div\",\n {\n ...props,\n \"data-anvia-message-content\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport { MessageContent, MessageRoot };\n","import { MessageActions, MessageCopy, MessageRegenerate } from \"./actions\";\nimport {\n MessageAttachment,\n MessageCodeBlock,\n MessageData,\n MessageError,\n MessageMarkdown,\n MessagePart,\n MessageParts,\n MessageReasoning,\n MessageText,\n MessageTool,\n MessageToolError,\n MessageToolInput,\n MessageToolName,\n MessageToolOutput,\n MessageToolStatus,\n} from \"./parts\";\nimport { MessageContent, MessageRoot } from \"./root\";\n\nexport const Message = {\n Root: MessageRoot,\n Content: MessageContent,\n Parts: MessageParts,\n Part: MessagePart,\n Text: MessageText,\n Markdown: MessageMarkdown,\n CodeBlock: MessageCodeBlock,\n Reasoning: MessageReasoning,\n Tool: MessageTool,\n ToolName: MessageToolName,\n ToolInput: MessageToolInput,\n ToolOutput: MessageToolOutput,\n ToolError: MessageToolError,\n ToolStatus: MessageToolStatus,\n Attachment: MessageAttachment,\n Data: MessageData,\n Error: MessageError,\n Actions: MessageActions,\n Copy: MessageCopy,\n Regenerate: MessageRegenerate,\n} as const;\n\nexport type { MessageContextValue, MessagePartContextValue } from \"../contexts\";\nexport { useChatContext, useMessage, useMessagePart } from \"../contexts\";\nexport type {\n MessageAttachmentPart,\n MessagePartsFilter,\n MessageToolPart,\n MessageToolRenderWhen,\n} from \"./parts\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,YAA6B,aAAa,WAAW,QAAQ,gBAAgB;;;ACE/E,SAAS,YAAY,SAA4B;AACtD,SAAO,QAAQ,MACZ,OAAO,CAAC,SAA2D,KAAK,SAAS,MAAM,EACvF,IAAI,CAAC,SAAS,KAAK,IAAI,EACvB,KAAK,EAAE;AACZ;;;ACPO,SAAS,eAAe,OAAwB;AACrD,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,MAAI;AACF,WAAO,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,EACtC,QAAQ;AACN,WAAO,OAAO,KAAK;AAAA,EACrB;AACF;;;AFCU,mBACE,KADF;AAPV,IAAM,iBAAiB;AAAA,EACrB,SAASA,gBAAe,OAAO,KAAK;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,UAAU,MAAM,YACd,iCACE;AAAA,8BAAC,eAAY;AAAA,UACb,oBAAC,qBAAkB;AAAA,WACrB;AAAA,QAEF,8BAA8B;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAIA,IAAM,cAAc,WAAwD,SAASC,aACnF,EA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AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,YAAY;AACd;","names":["MessageActions","MessageCopy","MessageRegenerate","forwardRef","Fragment","jsx","jsxs","forwardRef","MessageParts","MessagePart","MessageText","MessageMarkdown","MessageCodeBlock","MessageReasoning","MessageTool","MessageToolName","MessageToolStatus","MessageToolInput","MessageToolOutput","MessageToolError","MessageAttachment","MessageData","MessageError","forwardRef","forwardRef","MessageRoot","MessageContent"]}
@@ -0,0 +1,236 @@
1
+ import {
2
+ renderPrimitive
3
+ } from "./chunk-T3ZFZ3NP.js";
4
+ import {
5
+ InternalSelectionToolbarProvider,
6
+ useSelectionToolbar
7
+ } from "./chunk-BCCU3VT5.js";
8
+
9
+ // src/selection-toolbar/parts.tsx
10
+ import {
11
+ forwardRef,
12
+ useCallback,
13
+ useEffect,
14
+ useMemo,
15
+ useState
16
+ } from "react";
17
+ import { createPortal } from "react-dom";
18
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
19
+ var SelectionToolbarRoot = forwardRef(
20
+ function SelectionToolbarRoot2({ children, container, onQuote, onSelectionChange, style, ...props }, ref) {
21
+ const [selection, setSelectionState] = useState();
22
+ const portalContainer = container ?? globalThis.document?.body;
23
+ const setSelection = useCallback(
24
+ (nextSelection) => {
25
+ setSelectionState((currentSelection) => {
26
+ if (sameSelection(currentSelection, nextSelection)) {
27
+ return currentSelection;
28
+ }
29
+ onSelectionChange?.(nextSelection);
30
+ return nextSelection;
31
+ });
32
+ },
33
+ [onSelectionChange]
34
+ );
35
+ const clear = useCallback(() => {
36
+ globalThis.document?.getSelection()?.removeAllRanges();
37
+ setSelection(void 0);
38
+ }, [setSelection]);
39
+ const copy = useCallback(async () => {
40
+ if (selection === void 0) {
41
+ return;
42
+ }
43
+ await globalThis.navigator?.clipboard?.writeText(selection.text);
44
+ clear();
45
+ }, [clear, selection]);
46
+ const quote = useCallback(() => {
47
+ if (selection === void 0) {
48
+ return;
49
+ }
50
+ onQuote?.(selection);
51
+ clear();
52
+ }, [clear, onQuote, selection]);
53
+ const value = useMemo(
54
+ () => ({
55
+ ...selection === void 0 ? {} : { selection },
56
+ quote,
57
+ copy,
58
+ clear
59
+ }),
60
+ [clear, copy, quote, selection]
61
+ );
62
+ useEffect(() => {
63
+ const document = globalThis.document;
64
+ if (document === void 0) {
65
+ return;
66
+ }
67
+ const handleSelectionChange = () => {
68
+ setSelection(selectionFromDocument(document));
69
+ };
70
+ document.addEventListener("selectionchange", handleSelectionChange);
71
+ document.addEventListener("mouseup", handleSelectionChange);
72
+ document.addEventListener("keyup", handleSelectionChange);
73
+ document.addEventListener("scroll", handleSelectionChange, true);
74
+ return () => {
75
+ document.removeEventListener("selectionchange", handleSelectionChange);
76
+ document.removeEventListener("mouseup", handleSelectionChange);
77
+ document.removeEventListener("keyup", handleSelectionChange);
78
+ document.removeEventListener("scroll", handleSelectionChange, true);
79
+ };
80
+ }, [setSelection]);
81
+ if (selection === void 0 || portalContainer === void 0) {
82
+ return null;
83
+ }
84
+ const toolbarStyle = {
85
+ position: "fixed",
86
+ top: selection.rect.top,
87
+ left: selection.rect.left + selection.rect.width / 2,
88
+ transform: "translate(-50%, calc(-100% - 8px))",
89
+ ...style
90
+ };
91
+ const toolbar = /* @__PURE__ */ jsx(InternalSelectionToolbarProvider, { value, children: renderPrimitive(
92
+ "div",
93
+ {
94
+ ...props,
95
+ children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
96
+ /* @__PURE__ */ jsx(SelectionToolbarQuote, {}),
97
+ /* @__PURE__ */ jsx(SelectionToolbarCopy, {})
98
+ ] }),
99
+ style: toolbarStyle,
100
+ "data-anvia-selection-toolbar": "",
101
+ "data-message-id": selection.messageId,
102
+ role: props.role ?? "toolbar"
103
+ },
104
+ ref
105
+ ) });
106
+ return createPortal(toolbar, portalContainer);
107
+ }
108
+ );
109
+ var SelectionToolbarQuote = forwardRef(
110
+ function SelectionToolbarQuote2({ onClick, ...props }, ref) {
111
+ const { disabled, handleClick } = useSelectionToolbarAction("quote", props.disabled, onClick);
112
+ return renderPrimitive(
113
+ "button",
114
+ {
115
+ ...props,
116
+ children: props.children ?? "Quote",
117
+ disabled,
118
+ onClick: handleClick,
119
+ type: props.type ?? "button",
120
+ "data-anvia-selection-quote": "",
121
+ "data-state": disabled ? "disabled" : "enabled"
122
+ },
123
+ ref
124
+ );
125
+ }
126
+ );
127
+ var SelectionToolbarCopy = forwardRef(
128
+ function SelectionToolbarCopy2({ onClick, ...props }, ref) {
129
+ const { disabled, handleClick } = useSelectionToolbarAction("copy", props.disabled, onClick);
130
+ return renderPrimitive(
131
+ "button",
132
+ {
133
+ ...props,
134
+ children: props.children ?? "Copy",
135
+ disabled,
136
+ onClick: handleClick,
137
+ type: props.type ?? "button",
138
+ "data-anvia-selection-copy": "",
139
+ "data-state": disabled ? "disabled" : "enabled"
140
+ },
141
+ ref
142
+ );
143
+ }
144
+ );
145
+ function useSelectionToolbarAction(actionName, disabledProp, onClick) {
146
+ const toolbar = useSelectionToolbar();
147
+ const disabled = disabledProp ?? toolbar.selection === void 0;
148
+ const action = toolbar[actionName];
149
+ const handleClick = useCallback(
150
+ (event) => {
151
+ onClick?.(event);
152
+ if (event.defaultPrevented || disabled) {
153
+ return;
154
+ }
155
+ void action();
156
+ },
157
+ [action, disabled, onClick]
158
+ );
159
+ return { disabled, handleClick };
160
+ }
161
+ function selectionFromDocument(document) {
162
+ const selection = document.getSelection();
163
+ if (selection === null || selection.rangeCount === 0) {
164
+ return void 0;
165
+ }
166
+ const text = selection.toString();
167
+ if (text.trim().length === 0) {
168
+ return void 0;
169
+ }
170
+ const anchorMessage = messageElementFromNode(selection.anchorNode);
171
+ const focusMessage = messageElementFromNode(selection.focusNode);
172
+ if (anchorMessage === void 0 || focusMessage === void 0 || anchorMessage !== focusMessage) {
173
+ return void 0;
174
+ }
175
+ const messageId = anchorMessage.getAttribute("data-anvia-message-id");
176
+ if (messageId === null || messageId.length === 0) {
177
+ return void 0;
178
+ }
179
+ const range = selection.getRangeAt(0);
180
+ return {
181
+ text,
182
+ messageId,
183
+ rect: selectionRect(range)
184
+ };
185
+ }
186
+ function messageElementFromNode(node) {
187
+ if (node === null) {
188
+ return void 0;
189
+ }
190
+ const element = node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement;
191
+ return element?.closest("[data-anvia-message-id]") ?? void 0;
192
+ }
193
+ function selectionRect(range) {
194
+ const rangeWithRect = range;
195
+ const rect = rangeWithRect.getBoundingClientRect?.();
196
+ if (rect !== void 0 && (rect.width > 0 || rect.height > 0)) {
197
+ return rect;
198
+ }
199
+ const firstRect = range.getClientRects().item(0);
200
+ if (firstRect !== null) {
201
+ return firstRect;
202
+ }
203
+ const DOMRectConstructor = globalThis.DOMRect;
204
+ if (DOMRectConstructor !== void 0) {
205
+ return new DOMRectConstructor(0, 0, 0, 0);
206
+ }
207
+ return {
208
+ bottom: 0,
209
+ height: 0,
210
+ left: 0,
211
+ right: 0,
212
+ top: 0,
213
+ width: 0,
214
+ x: 0,
215
+ y: 0,
216
+ toJSON: () => ({})
217
+ };
218
+ }
219
+ function sameSelection(currentSelection, nextSelection) {
220
+ if (currentSelection === void 0 || nextSelection === void 0) {
221
+ return currentSelection === nextSelection;
222
+ }
223
+ return currentSelection.text === nextSelection.text && currentSelection.messageId === nextSelection.messageId && currentSelection.rect.left === nextSelection.rect.left && currentSelection.rect.top === nextSelection.rect.top && currentSelection.rect.width === nextSelection.rect.width && currentSelection.rect.height === nextSelection.rect.height;
224
+ }
225
+
226
+ // src/selection-toolbar/index.ts
227
+ var SelectionToolbar = {
228
+ Root: SelectionToolbarRoot,
229
+ Quote: SelectionToolbarQuote,
230
+ Copy: SelectionToolbarCopy
231
+ };
232
+
233
+ export {
234
+ SelectionToolbar
235
+ };
236
+ //# sourceMappingURL=chunk-GXB4VINL.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 { 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 () => ({\n ...(selection === undefined ? {} : { selection }),\n quote,\n copy,\n clear,\n }),\n [clear, copy, quote, selection],\n );\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 \"data-anvia-selection-toolbar\": \"\",\n \"data-message-id\": selection.messageId,\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-anvia-selection-quote\": \"\",\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-anvia-selection-copy\": \"\",\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 (anchorMessage === undefined || focusMessage === undefined || anchorMessage !== focusMessage) {\n return undefined;\n }\n\n const messageId = anchorMessage.getAttribute(\"data-anvia-message-id\");\n if (messageId === null || messageId.length === 0) {\n return undefined;\n }\n\n const range = selection.getRangeAt(0);\n return {\n text,\n messageId,\n rect: selectionRect(range),\n };\n}\n\nfunction messageElementFromNode(node: Node | null): HTMLElement | undefined {\n if (node === null) {\n return undefined;\n }\n const element = node.nodeType === Node.ELEMENT_NODE ? (node as Element) : node.parentElement;\n return element?.closest<HTMLElement>(\"[data-anvia-message-id]\") ?? undefined;\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 SelectionToolbar = {\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,S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AQ,cAAc,KAAK,OACjD,iBAAiB,KAAK,UAAU,cAAc,KAAK,SACnD,iBAAiB,KAAK,WAAW,cAAc,KAAK;AAExD;;;AC5RO,IAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACR;","names":["SelectionToolbarRoot","SelectionToolbarQuote","SelectionToolbarCopy"]}
@@ -10,7 +10,7 @@ import {
10
10
  useHumanInput,
11
11
  useQuestion,
12
12
  useQuestionPrompt
13
- } from "./chunk-7AS6R7BB.js";
13
+ } from "./chunk-BCCU3VT5.js";
14
14
 
15
15
  // src/human-input/approvals.tsx
16
16
  import { forwardRef, useCallback } from "react";
@@ -408,4 +408,4 @@ var HumanInput = {
408
408
  export {
409
409
  HumanInput
410
410
  };
411
- //# sourceMappingURL=chunk-WK33ER4Q.js.map
411
+ //# sourceMappingURL=chunk-JUNV3MUR.js.map