@assistant-ui/react 0.15.23 → 0.15.25
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.
- package/README.md +44 -23
- package/dist/assistant-transport.js.map +1 -1
- package/dist/cloud-renderer/CloudRendererHost.js.map +1 -1
- package/dist/context/providers/MessageProvider.js.map +1 -1
- package/dist/context/providers/ThreadViewportProvider.js.map +1 -1
- package/dist/hooks/useToolCallElapsed.d.ts +3 -1
- package/dist/hooks/useToolCallElapsed.d.ts.map +1 -1
- package/dist/hooks/useToolCallElapsed.js +7 -8
- package/dist/hooks/useToolCallElapsed.js.map +1 -1
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/mcp-apps/app-frame.js.map +1 -1
- package/dist/model-context/frame/useAssistantFrameHost.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.d.ts +1 -0
- package/dist/model-context/makeAssistantVisible.d.ts.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +31 -12
- package/dist/model-context/makeAssistantVisible.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreContent.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreItem.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreRoot.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreSeparator.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreTrigger.js.map +1 -1
- package/dist/primitives/actionBarMore/scope.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
- package/dist/primitives/assistantModal/popoverRenderPrimitives.js.map +1 -1
- package/dist/primitives/assistantModal/scope.js.map +1 -1
- package/dist/primitives/attachment/AttachmentName.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerDictate.js.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +4 -3
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerInputPluginContext.js.map +1 -1
- package/dist/primitives/composer/ComposerQuote.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/primitives/composer/ComposerStopDictation.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts +11 -11
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.js +62 -60
- package/dist/primitives/composer/trigger/TriggerPopover.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverAction.d.ts +8 -8
- package/dist/primitives/composer/trigger/TriggerPopoverAction.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js +6 -6
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverBack.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.d.ts +3 -3
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.d.ts +9 -9
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.js +7 -7
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverItems.d.ts +5 -5
- package/dist/primitives/composer/trigger/TriggerPopoverItems.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverItems.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverResource.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.d.ts +8 -8
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js +8 -8
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js.map +1 -1
- package/dist/primitives/composer/trigger/index.d.ts +1 -1
- package/dist/primitives/composer/trigger/index.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerDetectionResource.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerKeyboardResource.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerNavigationResource.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.js.map +1 -1
- package/dist/primitives/composer/useComposerInputState.js.map +1 -1
- package/dist/primitives/composer.d.ts +20 -1
- package/dist/primitives/composer.d.ts.map +1 -1
- package/dist/primitives/composer.js +8 -1
- package/dist/primitives/composer.js.map +1 -1
- package/dist/primitives/dropdownMenuRenderPrimitives.js.map +1 -1
- package/dist/primitives/error/ErrorMessage.js.map +1 -1
- package/dist/primitives/error/ErrorRoot.js.map +1 -1
- package/dist/primitives/message/MessageIf.js.map +1 -1
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js +42 -17
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/messagePart/MessagePartImage.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemRemove.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemSteer.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemText.js.map +1 -1
- package/dist/primitives/reasoning/useScrollLock.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionDescription.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionTitle.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.js.map +1 -1
- package/dist/primitives/thread/ThreadIf.js.map +1 -1
- package/dist/primitives/thread/ThreadLoadEarlier.d.ts +19 -0
- package/dist/primitives/thread/ThreadLoadEarlier.d.ts.map +1 -0
- package/dist/primitives/thread/ThreadLoadEarlier.js +36 -0
- package/dist/primitives/thread/ThreadLoadEarlier.js.map +1 -0
- package/dist/primitives/thread/ThreadMessages.d.ts +1 -1
- package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js +2 -2
- package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js +2 -0
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/ThreadViewportFooter.js.map +1 -1
- package/dist/primitives/thread/topAnchor/useTopAnchorReserve.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +111 -2
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitives/thread.d.ts +2 -0
- package/dist/primitives/thread.d.ts.map +1 -1
- package/dist/primitives/thread.js +5 -2
- package/dist/primitives/thread.js.map +1 -1
- package/dist/primitives/threadList/ThreadListLoadMore.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
- package/dist/primitives/threadList/ThreadListRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js.map +1 -1
- package/dist/primitives/threadListItemMore/scope.js.map +1 -1
- package/dist/sandbox-host/SandboxHost.d.ts.map +1 -1
- package/dist/sandbox-host/SandboxHost.js +6 -1
- package/dist/sandbox-host/SandboxHost.js.map +1 -1
- package/dist/unstable/useMessageStallDetection.d.ts.map +1 -1
- package/dist/unstable/useMessageStallDetection.js +10 -6
- package/dist/unstable/useMessageStallDetection.js.map +1 -1
- package/dist/unstable/useModelContextSnapshot.js.map +1 -1
- package/dist/unstable/webmcp/WebMcpRegistrationResource.js.map +1 -1
- package/dist/unstable/webmcp/useWebMcpProvider.js.map +1 -1
- package/dist/utils/Primitive.js.map +1 -1
- package/dist/utils/createActionButton.js.map +1 -1
- package/dist/utils/hooks/useManagedRef.js.map +1 -1
- package/dist/utils/hooks/useMediaQuery.js.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.js.map +1 -1
- package/dist/utils/hooks/useOnScrollToBottom.js.map +1 -1
- package/dist/utils/hooks/useSizeHandle.js.map +1 -1
- package/dist/utils/isCompositionKey.d.ts +2 -0
- package/dist/utils/isCompositionKey.d.ts.map +1 -0
- package/dist/utils/isCompositionKey.js +6 -0
- package/dist/utils/isCompositionKey.js.map +1 -0
- package/dist/utils/smooth/SmoothContext.js.map +1 -1
- package/dist/utils/smooth/useSmooth.js +6 -6
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/package.json +12 -11
- package/src/hooks/useToolCallElapsed.test.tsx +35 -0
- package/src/hooks/useToolCallElapsed.ts +9 -7
- package/src/index.ts +28 -3
- package/src/model-context/makeAssistantVisible.test.tsx +315 -5
- package/src/model-context/makeAssistantVisible.tsx +43 -7
- package/src/primitives/composer/ComposerInput.test.tsx +33 -1
- package/src/primitives/composer/ComposerInput.tsx +4 -3
- package/src/primitives/composer/trigger/TriggerPopover.tsx +11 -11
- package/src/primitives/composer/trigger/TriggerPopoverAction.tsx +10 -13
- package/src/primitives/composer/trigger/TriggerPopoverCategories.tsx +2 -2
- package/src/primitives/composer/trigger/TriggerPopoverDirective.tsx +11 -14
- package/src/primitives/composer/trigger/TriggerPopoverExports.test.ts +61 -0
- package/src/primitives/composer/trigger/TriggerPopoverItems.tsx +3 -3
- package/src/primitives/composer/trigger/TriggerPopoverRootContext.tsx +8 -8
- package/src/primitives/composer.ts +21 -1
- package/src/primitives/message/MessagePartsGrouped.test.tsx +271 -1
- package/src/primitives/message/MessagePartsGrouped.tsx +14 -6
- package/src/primitives/message/MessageRoot.test.tsx +125 -2
- package/src/primitives/thread/ThreadLoadEarlier.tsx +35 -0
- package/src/primitives/thread/ThreadMessages.tsx +1 -0
- package/src/primitives/thread/ThreadRoot.test.tsx +33 -0
- package/src/primitives/thread/ThreadRoot.tsx +3 -0
- package/src/primitives/thread/useThreadViewportAutoScroll.test.tsx +256 -5
- package/src/primitives/thread/useThreadViewportAutoScroll.ts +147 -1
- package/src/primitives/thread.ts +2 -0
- package/src/sandbox-host/SandboxHost.test.tsx +34 -0
- package/src/sandbox-host/SandboxHost.tsx +8 -4
- package/src/tests/toolCallTiming.test.tsx +19 -2
- package/src/unstable/useMessageStallDetection.test.tsx +40 -0
- package/src/unstable/useMessageStallDetection.ts +10 -6
- package/src/utils/isCompositionKey.ts +5 -0
- package/src/utils/smooth/useSmooth.test.tsx +16 -5
- package/src/utils/smooth/useSmooth.ts +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","ForwardedRef","useCallback","useAui","useAuiState","useManagedRef","useComposedRefs","useThreadViewport","useThreadViewportStore","parseCssLength","ThreadViewportStore","NonNullable","ReturnType","useIsHoveringRef","$","aui","t0","message","t1","el","active","handleMouseEnter","setIsHovering","handleMouseLeave","addEventListener","matches","queueMicrotask","removeEventListener","callbackRef","useIsTopAnchorUser","activeAnchorId","_temp","s_0","s","role","index","thread","messages","length","at","id","isRunning","useIsTopAnchorTarget","activeTargetId","_temp2","isLast","useTopAnchorUserRef","threadViewportStore","getState","registerAnchorElement","callback","useTopAnchorTargetRef","state","clamp","topAnchorMessageClamp","registerAnchorTargetElement","tallerThan","visibleHeight","targetRefCallback","MessagePrimitiveRoot","Element","div","Props","MessagePrimitiveRootInternalProps","forwardedRef","MessagePrimitiveRootDefault","props","isHoveringRef","ref","messageId","_temp3","MessagePrimitiveRootTopAnchor","isTopAnchorUser","isTopAnchorTarget","topAnchorUserRef","topAnchorTargetRef","_temp4","t2","undefined","t3","t4","turnAnchor","displayName","topAnchorTurn","anchorId","targetId"],"sources":["../../../src/primitives/message/MessageRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type ForwardedRef,\n useCallback,\n} from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\nimport { parseCssLength } from \"../thread/topAnchor/topAnchorUtils\";\n\ntype ThreadViewportStore = NonNullable<\n ReturnType<typeof useThreadViewportStore>\n>;\n\nconst useIsHoveringRef = () => {\n const aui = useAui();\n const message = useAuiState(() => aui.message);\n\n const callbackRef = useCallback(\n (el: HTMLElement) => {\n let active = true;\n const handleMouseEnter = () => {\n message.setIsHovering(true);\n };\n const handleMouseLeave = () => {\n message.setIsHovering(false);\n };\n\n el.addEventListener(\"mouseenter\", handleMouseEnter);\n el.addEventListener(\"mouseleave\", handleMouseLeave);\n\n if (el.matches(\":hover\")) {\n // TODO this is needed for SSR to work, figure out why\n queueMicrotask(() => {\n if (active) message.setIsHovering(true);\n });\n }\n\n return () => {\n active = false;\n el.removeEventListener(\"mouseenter\", handleMouseEnter);\n el.removeEventListener(\"mouseleave\", handleMouseLeave);\n message.setIsHovering(false);\n };\n },\n [message],\n );\n\n return useManagedRef(callbackRef);\n};\n\nconst useIsTopAnchorUser = () => {\n const activeAnchorId = useThreadViewport((s) => s.topAnchorTurn?.anchorId);\n return useAuiState(\n (s) =>\n s.message.role === \"user\" &&\n s.message.index > 0 &&\n s.message.index === s.thread.messages.length - 2 &&\n s.thread.messages.at(-1)?.role === \"assistant\" &&\n (s.message.id === activeAnchorId || s.thread.isRunning),\n );\n};\n\nconst useIsTopAnchorTarget = () => {\n const activeTargetId = useThreadViewport((s) => s.topAnchorTurn?.targetId);\n return useAuiState(\n (s) =>\n s.message.isLast &&\n s.message.role === \"assistant\" &&\n s.message.index >= 1 &&\n s.thread.messages.at(s.message.index - 1)?.role === \"user\" &&\n (s.message.id === activeTargetId || s.thread.isRunning),\n );\n};\n\nconst useTopAnchorUserRef = (\n active: boolean,\n threadViewportStore: ThreadViewportStore,\n) => {\n const callback = useCallback(\n (el: HTMLElement) => {\n if (!active) return;\n return threadViewportStore.getState().registerAnchorElement(el);\n },\n [active, threadViewportStore],\n );\n\n return useManagedRef<HTMLElement>(callback);\n};\n\nconst useTopAnchorTargetRef = ({\n active,\n threadViewportStore,\n}: {\n active: boolean;\n threadViewportStore: ThreadViewportStore;\n}) => {\n const targetRefCallback = useCallback(\n (el: HTMLElement) => {\n if (!active) return;\n const state = threadViewportStore.getState();\n const clamp = state.topAnchorMessageClamp;\n\n return state.registerAnchorTargetElement(el, {\n tallerThan: parseCssLength(clamp.tallerThan, el),\n visibleHeight: parseCssLength(clamp.visibleHeight, el),\n });\n },\n [active, threadViewportStore],\n );\n\n return useManagedRef<HTMLElement>(targetRefCallback);\n};\n\nexport namespace MessagePrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\ntype MessagePrimitiveRootInternalProps = MessagePrimitiveRoot.Props & {\n forwardedRef: ForwardedRef<MessagePrimitiveRoot.Element>;\n};\n\nconst MessagePrimitiveRootDefault = ({\n forwardedRef,\n ...props\n}: MessagePrimitiveRootInternalProps) => {\n const isHoveringRef = useIsHoveringRef();\n const ref = useComposedRefs<HTMLDivElement>(forwardedRef, isHoveringRef);\n const messageId = useAuiState((s) => s.message.id);\n\n return <Primitive.div {...props} ref={ref} data-message-id={messageId} />;\n};\n\nconst MessagePrimitiveRootTopAnchor = ({\n forwardedRef,\n threadViewportStore,\n ...props\n}: MessagePrimitiveRootInternalProps & {\n threadViewportStore: ThreadViewportStore;\n}) => {\n const isHoveringRef = useIsHoveringRef();\n const isTopAnchorUser = useIsTopAnchorUser();\n const isTopAnchorTarget = useIsTopAnchorTarget();\n const topAnchorUserRef = useTopAnchorUserRef(\n isTopAnchorUser,\n threadViewportStore,\n );\n const topAnchorTargetRef = useTopAnchorTargetRef({\n active: isTopAnchorTarget,\n threadViewportStore,\n });\n const ref = useComposedRefs<HTMLDivElement>(\n forwardedRef,\n isHoveringRef,\n topAnchorUserRef,\n topAnchorTargetRef,\n );\n const messageId = useAuiState((s) => s.message.id);\n\n return (\n <Primitive.div\n {...props}\n ref={ref}\n data-message-id={messageId}\n data-aui-top-anchor-user={isTopAnchorUser ? \"\" : undefined}\n data-aui-top-anchor-target={isTopAnchorTarget ? \"\" : undefined}\n />\n );\n};\n\n/**\n * The root container component for a message.\n *\n * This component provides the foundational wrapper for message content and handles\n * hover state management for the message. It automatically tracks when the user\n * is hovering over the message, which can be used by child components like action bars.\n *\n * When `turnAnchor=\"top\"` is set on the viewport, this component automatically\n * registers itself as the top-anchor user message (when it's the previous user\n * message) or as the top-anchor target (when it's the streaming assistant\n * response). No additional component is required.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.Root>\n * <MessagePrimitive.Content />\n * <ActionBarPrimitive.Root>\n * <ActionBarPrimitive.Copy />\n * <ActionBarPrimitive.Edit />\n * </ActionBarPrimitive.Root>\n * </MessagePrimitive.Root>\n * ```\n */\nexport const MessagePrimitiveRoot = forwardRef<\n MessagePrimitiveRoot.Element,\n MessagePrimitiveRoot.Props\n>((props, forwardedRef) => {\n const threadViewportStore = useThreadViewportStore();\n // turnAnchor is initial-only viewport config (see ThreadViewportProvider).\n const turnAnchor = threadViewportStore.getState().turnAnchor;\n\n if (turnAnchor === \"top\") {\n return (\n <MessagePrimitiveRootTopAnchor\n {...props}\n forwardedRef={forwardedRef}\n threadViewportStore={threadViewportStore}\n />\n );\n }\n return <MessagePrimitiveRootDefault {...props} forwardedRef={forwardedRef} />;\n});\n\nMessagePrimitiveRoot.displayName = \"MessagePrimitive.Root\";\n"],"mappings":";;;;;;;;;;;AAuBA,MAAMkB,yBAAmB;CAAA,MAAAC,IAAAlB,EAAA,CAAA;CACvB,MAAAmB,MAAYZ,OAAO;CAAE,IAAAa;CAAA,IAAAF,EAAA,OAAAC,IAAAE,SAAA;EACOD,WAAMD,IAAGE;EAAQH,EAAA,KAAAC,IAAAE;EAAAH,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAA7C,MAAAG,UAAgBb,YAAYY,EAAiB;CAAE,IAAAE;CAAA,IAAAJ,EAAA,OAAAG,SAAA;EAG7CC,MAAAC,OAAA;GACE,IAAAC,SAAa;GACb,MAAAC,yBAAyB;IACvBJ,QAAOK,cAAe,IAAI;GAAC;GAE7B,MAAAC,yBAAyB;IACvBN,QAAOK,cAAe,KAAK;GAAC;GAG9BH,GAAEK,iBAAkB,cAAcH,gBAAgB;GAClDF,GAAEK,iBAAkB,cAAcD,gBAAgB;GAElD,IAAIJ,GAAEM,QAAS,QAAQ,GAErBC,qBAAe;IACb,IAAIN,QAAQH,QAAOK,cAAe,IAAI;GAAE,CACzC;GACF,aAEM;IACLF,SAASA;IACTD,GAAEQ,oBAAqB,cAAcN,gBAAgB;IACrDF,GAAEQ,oBAAqB,cAAcJ,gBAAgB;IACrDN,QAAOK,cAAe,KAAK;GAAC;EAC7B;EACFR,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAED,OAEKT,cAAcuB,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AAA,OACqBA,EAACkD,eAAwBE;AAAA;AA2DvC,SAAAf,OAAArC,GAAA;CAAA,OAMGA,EAAChB,QAAQuB;AAAG;AAKb,SAAAoC,OAAA3C,GAAA;CAAA,OAwBCA,EAAChB,QAAQuB;AAAG"}
|
|
1
|
+
{"version":3,"file":"MessageRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","ForwardedRef","useCallback","useAui","useAuiState","useManagedRef","useComposedRefs","useThreadViewport","useThreadViewportStore","parseCssLength","ThreadViewportStore","NonNullable","ReturnType","useIsHoveringRef","$","aui","t0","message","t1","el","active","handleMouseEnter","setIsHovering","handleMouseLeave","addEventListener","matches","queueMicrotask","removeEventListener","callbackRef","useIsTopAnchorUser","activeAnchorId","_temp","s_0","s","role","index","thread","messages","length","at","id","isRunning","useIsTopAnchorTarget","activeTargetId","_temp2","isLast","useTopAnchorUserRef","threadViewportStore","getState","registerAnchorElement","callback","useTopAnchorTargetRef","state","clamp","topAnchorMessageClamp","registerAnchorTargetElement","tallerThan","visibleHeight","targetRefCallback","MessagePrimitiveRoot","Element","div","Props","MessagePrimitiveRootInternalProps","forwardedRef","MessagePrimitiveRootDefault","props","isHoveringRef","ref","messageId","_temp3","MessagePrimitiveRootTopAnchor","isTopAnchorUser","isTopAnchorTarget","topAnchorUserRef","topAnchorTargetRef","_temp4","t2","undefined","t3","t4","turnAnchor","displayName","topAnchorTurn","anchorId","targetId","_c","callbackRef","callback","targetRefCallback","Primitive"],"sources":["../../../src/primitives/message/MessageRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type ForwardedRef,\n useCallback,\n} from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\nimport { parseCssLength } from \"../thread/topAnchor/topAnchorUtils\";\n\ntype ThreadViewportStore = NonNullable<\n ReturnType<typeof useThreadViewportStore>\n>;\n\nconst useIsHoveringRef = () => {\n const aui = useAui();\n const message = useAuiState(() => aui.message);\n\n const callbackRef = useCallback(\n (el: HTMLElement) => {\n let active = true;\n const handleMouseEnter = () => {\n message.setIsHovering(true);\n };\n const handleMouseLeave = () => {\n message.setIsHovering(false);\n };\n\n el.addEventListener(\"mouseenter\", handleMouseEnter);\n el.addEventListener(\"mouseleave\", handleMouseLeave);\n\n if (el.matches(\":hover\")) {\n // TODO this is needed for SSR to work, figure out why\n queueMicrotask(() => {\n if (active) message.setIsHovering(true);\n });\n }\n\n return () => {\n active = false;\n el.removeEventListener(\"mouseenter\", handleMouseEnter);\n el.removeEventListener(\"mouseleave\", handleMouseLeave);\n message.setIsHovering(false);\n };\n },\n [message],\n );\n\n return useManagedRef(callbackRef);\n};\n\nconst useIsTopAnchorUser = () => {\n const activeAnchorId = useThreadViewport((s) => s.topAnchorTurn?.anchorId);\n return useAuiState(\n (s) =>\n s.message.role === \"user\" &&\n s.message.index > 0 &&\n s.message.index === s.thread.messages.length - 2 &&\n s.thread.messages.at(-1)?.role === \"assistant\" &&\n (s.message.id === activeAnchorId || s.thread.isRunning),\n );\n};\n\nconst useIsTopAnchorTarget = () => {\n const activeTargetId = useThreadViewport((s) => s.topAnchorTurn?.targetId);\n return useAuiState(\n (s) =>\n s.message.isLast &&\n s.message.role === \"assistant\" &&\n s.message.index >= 1 &&\n s.thread.messages.at(s.message.index - 1)?.role === \"user\" &&\n (s.message.id === activeTargetId || s.thread.isRunning),\n );\n};\n\nconst useTopAnchorUserRef = (\n active: boolean,\n threadViewportStore: ThreadViewportStore,\n) => {\n const callback = useCallback(\n (el: HTMLElement) => {\n if (!active) return;\n return threadViewportStore.getState().registerAnchorElement(el);\n },\n [active, threadViewportStore],\n );\n\n return useManagedRef<HTMLElement>(callback);\n};\n\nconst useTopAnchorTargetRef = ({\n active,\n threadViewportStore,\n}: {\n active: boolean;\n threadViewportStore: ThreadViewportStore;\n}) => {\n const targetRefCallback = useCallback(\n (el: HTMLElement) => {\n if (!active) return;\n const state = threadViewportStore.getState();\n const clamp = state.topAnchorMessageClamp;\n\n return state.registerAnchorTargetElement(el, {\n tallerThan: parseCssLength(clamp.tallerThan, el),\n visibleHeight: parseCssLength(clamp.visibleHeight, el),\n });\n },\n [active, threadViewportStore],\n );\n\n return useManagedRef<HTMLElement>(targetRefCallback);\n};\n\nexport namespace MessagePrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\ntype MessagePrimitiveRootInternalProps = MessagePrimitiveRoot.Props & {\n forwardedRef: ForwardedRef<MessagePrimitiveRoot.Element>;\n};\n\nconst MessagePrimitiveRootDefault = ({\n forwardedRef,\n ...props\n}: MessagePrimitiveRootInternalProps) => {\n const isHoveringRef = useIsHoveringRef();\n const ref = useComposedRefs<HTMLDivElement>(forwardedRef, isHoveringRef);\n const messageId = useAuiState((s) => s.message.id);\n\n return <Primitive.div {...props} ref={ref} data-message-id={messageId} />;\n};\n\nconst MessagePrimitiveRootTopAnchor = ({\n forwardedRef,\n threadViewportStore,\n ...props\n}: MessagePrimitiveRootInternalProps & {\n threadViewportStore: ThreadViewportStore;\n}) => {\n const isHoveringRef = useIsHoveringRef();\n const isTopAnchorUser = useIsTopAnchorUser();\n const isTopAnchorTarget = useIsTopAnchorTarget();\n const topAnchorUserRef = useTopAnchorUserRef(\n isTopAnchorUser,\n threadViewportStore,\n );\n const topAnchorTargetRef = useTopAnchorTargetRef({\n active: isTopAnchorTarget,\n threadViewportStore,\n });\n const ref = useComposedRefs<HTMLDivElement>(\n forwardedRef,\n isHoveringRef,\n topAnchorUserRef,\n topAnchorTargetRef,\n );\n const messageId = useAuiState((s) => s.message.id);\n\n return (\n <Primitive.div\n {...props}\n ref={ref}\n data-message-id={messageId}\n data-aui-top-anchor-user={isTopAnchorUser ? \"\" : undefined}\n data-aui-top-anchor-target={isTopAnchorTarget ? \"\" : undefined}\n />\n );\n};\n\n/**\n * The root container component for a message.\n *\n * This component provides the foundational wrapper for message content and handles\n * hover state management for the message. It automatically tracks when the user\n * is hovering over the message, which can be used by child components like action bars.\n *\n * When `turnAnchor=\"top\"` is set on the viewport, this component automatically\n * registers itself as the top-anchor user message (when it's the previous user\n * message) or as the top-anchor target (when it's the streaming assistant\n * response). No additional component is required.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.Root>\n * <MessagePrimitive.Content />\n * <ActionBarPrimitive.Root>\n * <ActionBarPrimitive.Copy />\n * <ActionBarPrimitive.Edit />\n * </ActionBarPrimitive.Root>\n * </MessagePrimitive.Root>\n * ```\n */\nexport const MessagePrimitiveRoot = forwardRef<\n MessagePrimitiveRoot.Element,\n MessagePrimitiveRoot.Props\n>((props, forwardedRef) => {\n const threadViewportStore = useThreadViewportStore();\n // turnAnchor is initial-only viewport config (see ThreadViewportProvider).\n const turnAnchor = threadViewportStore.getState().turnAnchor;\n\n if (turnAnchor === \"top\") {\n return (\n <MessagePrimitiveRootTopAnchor\n {...props}\n forwardedRef={forwardedRef}\n threadViewportStore={threadViewportStore}\n />\n );\n }\n return <MessagePrimitiveRootDefault {...props} forwardedRef={forwardedRef} />;\n});\n\nMessagePrimitiveRoot.displayName = \"MessagePrimitive.Root\";\n"],"mappings":";;;;;;;;;;;AAuBA,MAAMkB,yBAAmB;CAAA,MAAAC,IAAAlB,EAAA,CAAA;CACvB,MAAAmB,MAAYZ,OAAO;CAAE,IAAAa;CAAA,IAAAF,EAAA,OAAAC,IAAAE,SAAA;EACOD,WAAMD,IAAGE;EAAQH,EAAA,KAAAC,IAAAE;EAAAH,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAA7C,MAAAG,UAAgBb,YAAYY,EAAiB;CAAE,IAAAE;CAAA,IAAAJ,EAAA,OAAAG,SAAA;EAG7CC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AD;IAA8B,GACxBkD;IACUF;IACOjB;GAAmB,CAAA;GACxCjC,EAAA,KAAAkD;GAAAlD,EAAA,KAAAoD;GAAApD,EAAA,KAAAiC;GAAAjC,EAAA,KAAAE;EAAA,OAAAA,KAAAF,EAAA;EAAA,OAJFE;CAIE;CAEL,IAAAA;CAAA,IAAAF,EAAA,OAAAkD,gBAAAlD,EAAA,OAAAoD,OAAA;EACMlD,KAAA,oBAAC,6BAAD;GAA4B,GAAKkD;GAAqBF;EAAY,CAAA;EAAIlD,EAAA,KAAAkD;EAAAlD,EAAA,KAAAoD;EAAApD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAAtEE;AAAsE,CAC9E;AAED2C,qBAAqBuB,cAAc;AAnKR,SAAAnD,MAAAE,GAAA;CAAA,OACuBA,EAACkD,eAAwBC;AAAA;AAW9C,SAAAxC,OAAAX,GAAA;CAAA,OACqBA,EAACkD,eAAwBE;AAAA;AA2DvC,SAAAf,OAAArC,GAAA;CAAA,OAMGA,EAAChB,QAAQuB;AAAG;AAKb,SAAAoC,OAAA3C,GAAA;CAAA,OAwBCA,EAAChB,QAAQuB;AAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessagePartImage.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useMessagePartImage","MessagePartPrimitiveImage","Element","img","Props","props","forwardedRef","$","image","t0","displayName"],"sources":["../../../src/primitives/messagePart/MessagePartImage.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useMessagePartImage } from \"./useMessagePartImage\";\n\nexport namespace MessagePartPrimitiveImage {\n export type Element = ComponentRef<typeof Primitive.img>;\n /**\n * Props for the MessagePartPrimitive.Image component.\n * Accepts all standard img element props.\n */\n export type Props = ComponentPropsWithoutRef<typeof Primitive.img>;\n}\n\n/**\n * Renders an image from the current message part context.\n *\n * This component displays image content from the current message part,\n * automatically setting the src attribute from the message part's image data.\n *\n * @example\n * ```tsx\n * <MessagePartPrimitive.Image\n * alt=\"Generated image\"\n * className=\"message-image\"\n * style={{ maxWidth: '100%' }}\n * />\n * ```\n */\nexport const MessagePartPrimitiveImage = forwardRef<\n MessagePartPrimitiveImage.Element,\n MessagePartPrimitiveImage.Props\n>((props, forwardedRef) => {\n const { image } = useMessagePartImage();\n return <Primitive.img src={image} {...props} ref={forwardedRef} />;\n});\n\nMessagePartPrimitiveImage.displayName = \"MessagePartPrimitive.Image\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAaO,4BAA4BH,YAGvCO,OAAAC,iBAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAA,EAAAa,UAAkBR,oBAAoB;CAAE,IAAAS;CAAA,IAAAF,EAAA,OAAAD,gBAAAC,EAAA,OAAAC,SAAAD,EAAA,OAAAF,OAAA;EACjCI,KAAA,oBAAA,UAAA,KAAA;GAAoBD,KAAAA;GAAK,GAAMH;GAAYC,KAAAA;EAAY,CAAA;EAAIC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAF;EAAAE,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAA3DE;AAA2D,CACnE;AAEDR,0BAA0BS,cAAc"}
|
|
1
|
+
{"version":3,"file":"MessagePartImage.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useMessagePartImage","MessagePartPrimitiveImage","Element","img","Props","props","forwardedRef","$","image","t0","displayName","_c"],"sources":["../../../src/primitives/messagePart/MessagePartImage.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useMessagePartImage } from \"./useMessagePartImage\";\n\nexport namespace MessagePartPrimitiveImage {\n export type Element = ComponentRef<typeof Primitive.img>;\n /**\n * Props for the MessagePartPrimitive.Image component.\n * Accepts all standard img element props.\n */\n export type Props = ComponentPropsWithoutRef<typeof Primitive.img>;\n}\n\n/**\n * Renders an image from the current message part context.\n *\n * This component displays image content from the current message part,\n * automatically setting the src attribute from the message part's image data.\n *\n * @example\n * ```tsx\n * <MessagePartPrimitive.Image\n * alt=\"Generated image\"\n * className=\"message-image\"\n * style={{ maxWidth: '100%' }}\n * />\n * ```\n */\nexport const MessagePartPrimitiveImage = forwardRef<\n MessagePartPrimitiveImage.Element,\n MessagePartPrimitiveImage.Props\n>((props, forwardedRef) => {\n const { image } = useMessagePartImage();\n return <Primitive.img src={image} {...props} ref={forwardedRef} />;\n});\n\nMessagePartPrimitiveImage.displayName = \"MessagePartPrimitive.Image\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAaO,4BAA4BH,YAGvCO,OAAAC,iBAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAA,EAAAa,UAAkBR,oBAAoB;CAAE,IAAAS;CAAA,IAAAF,EAAA,OAAAD,gBAAAC,EAAA,OAAAC,SAAAD,EAAA,OAAAF,OAAA;EACjCI,KAAA,oBAAA,UAAA,KAAA;GAAoBD,KAAAA;GAAK,GAAMH;GAAYC,KAAAA;EAAY,CAAA;EAAIC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAF;EAAAE,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAA3DE;AAA2D,CACnE;AAEDR,0BAA0BS,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueItemRemove.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAui","useCallback","useQueueItemRemove","$","aui","t0","queueItem","remove","callback","QueueItemPrimitiveRemove","Element","Props"],"sources":["../../../src/primitives/queueItem/QueueItemRemove.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useCallback } from \"react\";\n\nconst useQueueItemRemove = () => {\n const aui = useAui();\n\n const callback = useCallback(() => {\n aui.queueItem.remove();\n }, [aui]);\n\n return callback;\n};\n\nexport namespace QueueItemPrimitiveRemove {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useQueueItemRemove>;\n}\n\n/**\n * A button that removes this item from the queue.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Remove>×</QueueItemPrimitive.Remove>\n * ```\n */\nexport const QueueItemPrimitiveRemove = createActionButton(\n \"QueueItemPrimitive.Remove\",\n useQueueItemRemove,\n);\n"],"mappings":";;;;;;AAUA,MAAMO,2BAAqB;CAAA,MAAAC,IAAAP,EAAA,CAAA;CACzB,MAAAQ,MAAYJ,OAAO;CAAE,IAAAK;CAAA,IAAAF,EAAA,OAAAC,IAAAE,WAAA;EAEQD,WAAA;GAC3BD,IAAGE,UAAUC,OAAQ;EAAC;EACvBJ,EAAA,KAAAC,IAAAE;EAAAH,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAS,OAEHK;AAAQ;;;;;;;;;AAgBjB,MAAaC,2BAA2BV,mBACtC,6BACAG,kBACF"}
|
|
1
|
+
{"version":3,"file":"QueueItemRemove.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAui","useCallback","useQueueItemRemove","$","aui","t0","queueItem","remove","callback","QueueItemPrimitiveRemove","Element","Props","_c","callback"],"sources":["../../../src/primitives/queueItem/QueueItemRemove.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useCallback } from \"react\";\n\nconst useQueueItemRemove = () => {\n const aui = useAui();\n\n const callback = useCallback(() => {\n aui.queueItem.remove();\n }, [aui]);\n\n return callback;\n};\n\nexport namespace QueueItemPrimitiveRemove {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useQueueItemRemove>;\n}\n\n/**\n * A button that removes this item from the queue.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Remove>×</QueueItemPrimitive.Remove>\n * ```\n */\nexport const QueueItemPrimitiveRemove = createActionButton(\n \"QueueItemPrimitive.Remove\",\n useQueueItemRemove,\n);\n"],"mappings":";;;;;;AAUA,MAAMO,2BAAqB;CAAA,MAAAC,IAAAP,EAAA,CAAA;CACzB,MAAAQ,MAAYJ,OAAO;CAAE,IAAAK;CAAA,IAAAF,EAAA,OAAAC,IAAAE,WAAA;EAEQD,WAAA;GAC3BD,IAAGE,UAAUC,OAAQ;EAAC;EACvBJ,EAAA,KAAAC,IAAAE;EAAAH,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAS,OAEHK;AAAQ;;;;;;;;;AAgBjB,MAAaC,2BAA2BV,mBACtC,6BACAG,kBACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueItemSteer.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAui","useCallback","useQueueItemSteer","$","aui","t0","queueItem","steer","callback","QueueItemPrimitiveSteer","Element","Props"],"sources":["../../../src/primitives/queueItem/QueueItemSteer.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useCallback } from \"react\";\n\nconst useQueueItemSteer = () => {\n const aui = useAui();\n\n const callback = useCallback(() => {\n aui.queueItem.steer();\n }, [aui]);\n\n return callback;\n};\n\nexport namespace QueueItemPrimitiveSteer {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useQueueItemSteer>;\n}\n\n/**\n * A button that steers the current run to process this queue item immediately.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>\n * ```\n */\nexport const QueueItemPrimitiveSteer = createActionButton(\n \"QueueItemPrimitive.Steer\",\n useQueueItemSteer,\n);\n"],"mappings":";;;;;;AAUA,MAAMO,0BAAoB;CAAA,MAAAC,IAAAP,EAAA,CAAA;CACxB,MAAAQ,MAAYJ,OAAO;CAAE,IAAAK;CAAA,IAAAF,EAAA,OAAAC,IAAAE,WAAA;EAEQD,WAAA;GAC3BD,IAAGE,UAAUC,MAAO;EAAC;EACtBJ,EAAA,KAAAC,IAAAE;EAAAH,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAS,OAEHK;AAAQ;;;;;;;;;AAgBjB,MAAaC,0BAA0BV,mBACrC,4BACAG,iBACF"}
|
|
1
|
+
{"version":3,"file":"QueueItemSteer.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAui","useCallback","useQueueItemSteer","$","aui","t0","queueItem","steer","callback","QueueItemPrimitiveSteer","Element","Props","_c","callback"],"sources":["../../../src/primitives/queueItem/QueueItemSteer.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useCallback } from \"react\";\n\nconst useQueueItemSteer = () => {\n const aui = useAui();\n\n const callback = useCallback(() => {\n aui.queueItem.steer();\n }, [aui]);\n\n return callback;\n};\n\nexport namespace QueueItemPrimitiveSteer {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useQueueItemSteer>;\n}\n\n/**\n * A button that steers the current run to process this queue item immediately.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>\n * ```\n */\nexport const QueueItemPrimitiveSteer = createActionButton(\n \"QueueItemPrimitive.Steer\",\n useQueueItemSteer,\n);\n"],"mappings":";;;;;;AAUA,MAAMO,0BAAoB;CAAA,MAAAC,IAAAP,EAAA,CAAA;CACxB,MAAAQ,MAAYJ,OAAO;CAAE,IAAAK;CAAA,IAAAF,EAAA,OAAAC,IAAAE,WAAA;EAEQD,WAAA;GAC3BD,IAAGE,UAAUC,MAAO;EAAC;EACtBJ,EAAA,KAAAC,IAAAE;EAAAH,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAS,OAEHK;AAAQ;;;;;;;;;AAgBjB,MAAaC,0BAA0BV,mBACrC,4BACAG,iBACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueItemText.js","names":["c","_c","Primitive","ComponentRef","ComponentPropsWithoutRef","forwardRef","useAuiState","QueueItemPrimitiveText","Element","span","Props","props","ref","$","text","_temp3","t0","children","t1","displayName","_temp","part","type","_temp2","part_0","s","queueItem","parts","filter","map","join"],"sources":["../../../src/primitives/queueItem/QueueItemText.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n type ComponentPropsWithoutRef,\n forwardRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace QueueItemPrimitiveText {\n export type Element = ComponentRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\n/**\n * Renders the prompt text of a queue item.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Text />\n * ```\n */\nexport const QueueItemPrimitiveText = forwardRef<\n QueueItemPrimitiveText.Element,\n QueueItemPrimitiveText.Props\n>((props, ref) => {\n const text = useAuiState((s) =>\n // hosts on the pre-parts adapter shape may omit the field at runtime\n (s.queueItem.parts ?? [])\n .filter((part) => part.type === \"text\")\n .map((part) => part.text)\n .join(\"\\n\\n\"),\n );\n\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? text}\n </Primitive.span>\n );\n});\n\nQueueItemPrimitiveText.displayName = \"QueueItemPrimitive.Text\";\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAaO,yBAAyBF,YAGpCM,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAAa,OAAaR,YAAYS,MAMzB;CAIK,MAAAC,KAAAL,MAAKM,YAALH;CAAsB,IAAAI;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EADzBE,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBP;GAAYC;GAC7BI,UAAAA;EACH,CAAA;EAAiBH,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFjBK;AAEiB,CAEpB;AAEDX,uBAAuBY,cAAc;AAhBnC,SAAAC,MAAAC,MAAA;CAAA,OAIsBA,KAAIC,SAAU;AAAM;AAJ1C,SAAAC,OAAAC,QAAA;CAAA,OAKmBH,OAAIP;AAAK;AAL5B,SAAAC,OAAAU,GAAA;CAAA,QAGGA,EAACC,UAAUC,SAAX,CAAA,EAAA,CAAuBC,OACdR,KAA8B,CAAC,CAAAS,IAClCN,MAAmB,CAAC,CAAAO,KACnB,MAAM;AAAC"}
|
|
1
|
+
{"version":3,"file":"QueueItemText.js","names":["c","_c","Primitive","ComponentRef","ComponentPropsWithoutRef","forwardRef","useAuiState","QueueItemPrimitiveText","Element","span","Props","props","ref","$","text","_temp3","t0","children","t1","displayName","_temp","part","type","_temp2","part_0","s","queueItem","parts","filter","map","join","_c"],"sources":["../../../src/primitives/queueItem/QueueItemText.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n type ComponentPropsWithoutRef,\n forwardRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace QueueItemPrimitiveText {\n export type Element = ComponentRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\n/**\n * Renders the prompt text of a queue item.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Text />\n * ```\n */\nexport const QueueItemPrimitiveText = forwardRef<\n QueueItemPrimitiveText.Element,\n QueueItemPrimitiveText.Props\n>((props, ref) => {\n const text = useAuiState((s) =>\n // hosts on the pre-parts adapter shape may omit the field at runtime\n (s.queueItem.parts ?? [])\n .filter((part) => part.type === \"text\")\n .map((part) => part.text)\n .join(\"\\n\\n\"),\n );\n\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? text}\n </Primitive.span>\n );\n});\n\nQueueItemPrimitiveText.displayName = \"QueueItemPrimitive.Text\";\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAaO,yBAAyBF,YAGpCM,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAAa,OAAaR,YAAYS,MAMzB;CAIK,MAAAC,KAAAL,MAAKM,YAALH;CAAsB,IAAAI;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EADzBE,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBP;GAAYC;GAC7BI,UAAAA;EACH,CAAA;EAAiBH,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFjBK;AAEiB,CAEpB;AAEDX,uBAAuBY,cAAc;AAhBnC,SAAAC,MAAAC,MAAA;CAAA,OAIsBA,KAAIC,SAAU;AAAM;AAJ1C,SAAAC,OAAAC,QAAA;CAAA,OAKmBH,OAAIP;AAAK;AAL5B,SAAAC,OAAAU,GAAA;CAAA,QAGGA,EAACC,UAAUC,SAAX,CAAA,EAAA,CAAuBC,OACdR,KAA8B,CAAC,CAAAS,IAClCN,MAAmB,CAAC,CAAAO,KACnB,MAAM;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollLock.js","names":["c","_c","RefObject","useCallback","useEffect","useRef","findScrollableAncestor","element","HTMLElement","current","overflowY","getComputedStyle","parentElement","useScrollLock","animatedElementRef","animationDuration","$","cleanupRef","t0","t1","Symbol","for","t2","scrollContainer","scrollPosition","scrollTop","scrollbarWidth","style","computed","paddingSide","direction","previousPadding","elementScrollbarSize","offsetWidth","clientWidth","parseFloat","borderLeftWidth","borderRightWidth","ownerDocument","isRootScroller","documentElement","body","scrollbarSize","defaultView","innerWidth","restoreStyles","resetPosition","addEventListener","timeoutId","setTimeout","removeEventListener","clearTimeout","lockScroll"],"sources":["../../../src/primitives/reasoning/useScrollLock.ts"],"sourcesContent":["\"use client\";\n\nimport { type RefObject, useCallback, useEffect, useRef } from \"react\";\n\nconst findScrollableAncestor = (element: HTMLElement | null) => {\n let current = element;\n while (current) {\n const { overflowY } = getComputedStyle(current);\n if (overflowY === \"scroll\" || overflowY === \"auto\") return current;\n current = current.parentElement;\n }\n return null;\n};\n\n/**\n * Locks scroll position during collapsible/height animations and hides scrollbar.\n *\n * This utility prevents page jumps when content height changes during animations,\n * providing a smooth user experience. It finds the nearest scrollable ancestor and\n * temporarily locks its scroll position while the animation completes.\n *\n * - Prevents forced reflows: no layout reads, mutations scoped to scrollable parent only\n * - Reactive: only intercepts scroll events when browser actually adjusts\n * - Cleans up automatically after animation duration\n *\n * @param animatedElementRef - Ref to the animated element\n * @param animationDuration - Lock duration in milliseconds\n * @returns Function to activate the scroll lock\n *\n * @example\n * ```tsx\n * const collapsibleRef = useRef<HTMLDivElement>(null);\n * const lockScroll = useScrollLock(collapsibleRef, 200);\n *\n * const handleCollapse = () => {\n * lockScroll(); // Lock scroll before collapsing\n * setIsOpen(false);\n * };\n * ```\n */\nexport const useScrollLock = <T extends HTMLElement = HTMLElement>(\n animatedElementRef: RefObject<T | null>,\n animationDuration: number,\n) => {\n const cleanupRef = useRef<(() => void) | null>(null);\n\n useEffect(() => {\n return () => {\n cleanupRef.current?.();\n };\n }, []);\n\n const lockScroll = useCallback(() => {\n cleanupRef.current?.();\n\n const scrollContainer = findScrollableAncestor(animatedElementRef.current);\n if (!scrollContainer) {\n cleanupRef.current = null;\n return;\n }\n\n const scrollPosition = scrollContainer.scrollTop;\n const scrollbarWidth = scrollContainer.style.scrollbarWidth;\n\n // Hiding the scrollbar collapses its gutter on classic scrollbars, which\n // shifts centered content horizontally; compensate with padding on the\n // side the scrollbar occupies (the left side in RTL).\n const computed = getComputedStyle(scrollContainer);\n const paddingSide =\n computed.direction === \"rtl\" ? \"paddingLeft\" : \"paddingRight\";\n const previousPadding = scrollContainer.style[paddingSide];\n const elementScrollbarSize =\n scrollContainer.offsetWidth -\n scrollContainer.clientWidth -\n parseFloat(computed.borderLeftWidth) -\n parseFloat(computed.borderRightWidth);\n // A root element's offsetWidth already excludes the viewport scrollbar, so\n // the element formula reports zero once the scroll propagates to the\n // viewport, and only then does the viewport measure apply. A body that\n // scrolls in its own right is measured by the element formula like any\n // other scroller, whether or not the viewport is scrolling too.\n const ownerDocument = scrollContainer.ownerDocument;\n const isRootScroller =\n scrollContainer === ownerDocument.documentElement ||\n scrollContainer === ownerDocument.body;\n const scrollbarSize =\n isRootScroller && elementScrollbarSize <= 0\n ? (ownerDocument.defaultView?.innerWidth ?? 0) -\n ownerDocument.documentElement.clientWidth\n : elementScrollbarSize;\n\n scrollContainer.style.scrollbarWidth = \"none\";\n if (scrollbarSize > 0) {\n scrollContainer.style[paddingSide] = `${\n parseFloat(computed[paddingSide]) + scrollbarSize\n }px`;\n }\n\n const restoreStyles = () => {\n scrollContainer.style.scrollbarWidth = scrollbarWidth;\n scrollContainer.style[paddingSide] = previousPadding;\n };\n\n const resetPosition = () => (scrollContainer.scrollTop = scrollPosition);\n scrollContainer.addEventListener(\"scroll\", resetPosition);\n\n const timeoutId = setTimeout(() => {\n scrollContainer.removeEventListener(\"scroll\", resetPosition);\n restoreStyles();\n cleanupRef.current = null;\n }, animationDuration);\n\n cleanupRef.current = () => {\n clearTimeout(timeoutId);\n scrollContainer.removeEventListener(\"scroll\", resetPosition);\n restoreStyles();\n };\n }, [animationDuration, animatedElementRef]);\n\n return lockScroll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Be,cAAaG,SAEfT,wBAAwB,KACrCM,cAAaK,aAAwBC,cAArC,KACDN,cAAaE,gBAAgBN,cAFjCF;GAKFT,gBAAeI,MAAMD,iBAAkB;GACvC,IAAIgB,gBAAgB,GAClBnB,gBAAeI,MAAOE,eAAe,GACnCM,WAAWP,SAASC,YAAY,IAAIa,cAAa;GAIrD,MAAAG,sBAAsB;IACpBtB,gBAAeI,MAAMD,iBAAkBA;IACvCH,gBAAeI,MAAOE,eAAeE;GAAH;GAGpC,MAAAe,sBAA6BvB,gBAAeE,YAAaD;GACzDD,gBAAewB,iBAAkB,UAAUD,aAAa;GAExD,MAAAE,YAAkBC,iBAAW;IAC3B1B,gBAAe2B,oBAAqB,UAAUJ,aAAa;IAC3DD,cAAc;IACd5B,WAAUR,UAAW;GAAH,GACjBM,iBAAiB;GAEpBE,WAAUR,gBAAW;IACnB0C,aAAaH,SAAS;IACtBzB,gBAAe2B,oBAAqB,UAAUJ,aAAa;IAC3DD,cAAc;GAAC;EAHC;EAKnB7B,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAA2C,OAErCoC;AAAU"}
|
|
1
|
+
{"version":3,"file":"useScrollLock.js","names":["c","_c","RefObject","useCallback","useEffect","useRef","findScrollableAncestor","element","HTMLElement","current","overflowY","getComputedStyle","parentElement","useScrollLock","animatedElementRef","animationDuration","$","cleanupRef","t0","t1","Symbol","for","t2","scrollContainer","scrollPosition","scrollTop","scrollbarWidth","style","computed","paddingSide","direction","previousPadding","elementScrollbarSize","offsetWidth","clientWidth","parseFloat","borderLeftWidth","borderRightWidth","ownerDocument","isRootScroller","documentElement","body","scrollbarSize","defaultView","innerWidth","restoreStyles","resetPosition","addEventListener","timeoutId","setTimeout","removeEventListener","clearTimeout","lockScroll","_c","lockScroll"],"sources":["../../../src/primitives/reasoning/useScrollLock.ts"],"sourcesContent":["\"use client\";\n\nimport { type RefObject, useCallback, useEffect, useRef } from \"react\";\n\nconst findScrollableAncestor = (element: HTMLElement | null) => {\n let current = element;\n while (current) {\n const { overflowY } = getComputedStyle(current);\n if (overflowY === \"scroll\" || overflowY === \"auto\") return current;\n current = current.parentElement;\n }\n return null;\n};\n\n/**\n * Locks scroll position during collapsible/height animations and hides scrollbar.\n *\n * This utility prevents page jumps when content height changes during animations,\n * providing a smooth user experience. It finds the nearest scrollable ancestor and\n * temporarily locks its scroll position while the animation completes.\n *\n * - Prevents forced reflows: no layout reads, mutations scoped to scrollable parent only\n * - Reactive: only intercepts scroll events when browser actually adjusts\n * - Cleans up automatically after animation duration\n *\n * @param animatedElementRef - Ref to the animated element\n * @param animationDuration - Lock duration in milliseconds\n * @returns Function to activate the scroll lock\n *\n * @example\n * ```tsx\n * const collapsibleRef = useRef<HTMLDivElement>(null);\n * const lockScroll = useScrollLock(collapsibleRef, 200);\n *\n * const handleCollapse = () => {\n * lockScroll(); // Lock scroll before collapsing\n * setIsOpen(false);\n * };\n * ```\n */\nexport const useScrollLock = <T extends HTMLElement = HTMLElement>(\n animatedElementRef: RefObject<T | null>,\n animationDuration: number,\n) => {\n const cleanupRef = useRef<(() => void) | null>(null);\n\n useEffect(() => {\n return () => {\n cleanupRef.current?.();\n };\n }, []);\n\n const lockScroll = useCallback(() => {\n cleanupRef.current?.();\n\n const scrollContainer = findScrollableAncestor(animatedElementRef.current);\n if (!scrollContainer) {\n cleanupRef.current = null;\n return;\n }\n\n const scrollPosition = scrollContainer.scrollTop;\n const scrollbarWidth = scrollContainer.style.scrollbarWidth;\n\n // Hiding the scrollbar collapses its gutter on classic scrollbars, which\n // shifts centered content horizontally; compensate with padding on the\n // side the scrollbar occupies (the left side in RTL).\n const computed = getComputedStyle(scrollContainer);\n const paddingSide =\n computed.direction === \"rtl\" ? \"paddingLeft\" : \"paddingRight\";\n const previousPadding = scrollContainer.style[paddingSide];\n const elementScrollbarSize =\n scrollContainer.offsetWidth -\n scrollContainer.clientWidth -\n parseFloat(computed.borderLeftWidth) -\n parseFloat(computed.borderRightWidth);\n // A root element's offsetWidth already excludes the viewport scrollbar, so\n // the element formula reports zero once the scroll propagates to the\n // viewport, and only then does the viewport measure apply. A body that\n // scrolls in its own right is measured by the element formula like any\n // other scroller, whether or not the viewport is scrolling too.\n const ownerDocument = scrollContainer.ownerDocument;\n const isRootScroller =\n scrollContainer === ownerDocument.documentElement ||\n scrollContainer === ownerDocument.body;\n const scrollbarSize =\n isRootScroller && elementScrollbarSize <= 0\n ? (ownerDocument.defaultView?.innerWidth ?? 0) -\n ownerDocument.documentElement.clientWidth\n : elementScrollbarSize;\n\n scrollContainer.style.scrollbarWidth = \"none\";\n if (scrollbarSize > 0) {\n scrollContainer.style[paddingSide] = `${\n parseFloat(computed[paddingSide]) + scrollbarSize\n }px`;\n }\n\n const restoreStyles = () => {\n scrollContainer.style.scrollbarWidth = scrollbarWidth;\n scrollContainer.style[paddingSide] = previousPadding;\n };\n\n const resetPosition = () => (scrollContainer.scrollTop = scrollPosition);\n scrollContainer.addEventListener(\"scroll\", resetPosition);\n\n const timeoutId = setTimeout(() => {\n scrollContainer.removeEventListener(\"scroll\", resetPosition);\n restoreStyles();\n cleanupRef.current = null;\n }, animationDuration);\n\n cleanupRef.current = () => {\n clearTimeout(timeoutId);\n scrollContainer.removeEventListener(\"scroll\", resetPosition);\n restoreStyles();\n };\n }, [animationDuration, animatedElementRef]);\n\n return lockScroll;\n};\n"],"mappings":";;;;AAIA,MAAMM,0BAA0BC,YAAgC;CAC9D,IAAIE,UAAUF;CACd,OAAOE,SAAS;EACd,MAAM,EAAEC,cAAcC,iBAAiBF,OAAO;EAC9C,IAAIC,cAAc,YAAYA,cAAc,QAAQ,OAAOD;EAC3DA,UAAUA,QAAQG;CACpB;CACA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAaC,iBAAgBC,oBAAAC,sBAAA;CAAA,MAAAC,IAAAf,EAAA,CAAA;CAI3B,MAAAgB,aAAmBZ,OAA4B,IAAI;CAAE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AUD,aAAa;GAExD,MAAAE,YAAkBC,iBAAW;IAC3B1B,gBAAe2B,oBAAqB,UAAUJ,aAAa;IAC3DD,cAAc;IACd5B,WAAUR,UAAW;GAAH,GACjBM,iBAAiB;GAEpBE,WAAUR,gBAAW;IACnB0C,aAAaH,SAAS;IACtBzB,gBAAe2B,oBAAqB,UAAUJ,aAAa;IAC3DD,cAAc;GAAC;EAHC;EAKnB7B,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAA2C,OAErCoC;AAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionToolbarQuote.js","names":["c","_c","Primitive","composeEventHandlers","ComponentPropsWithoutRef","ComponentRef","forwardRef","useCallback","useAui","useSelectionToolbarInfo","SelectionToolbarPrimitiveQuote","Element","button","Props","t0","forwardedRef","$","disabled","onClick","props","aui","info","t1","thread","composer","setQuote","text","messageId","window","getSelection","removeAllRanges","handleClick","t2","t3","t4","displayName"],"sources":["../../../src/primitives/selectionToolbar/SelectionToolbarQuote.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n useCallback,\n} from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useSelectionToolbarInfo } from \"./SelectionToolbarRoot\";\n\nexport namespace SelectionToolbarPrimitiveQuote {\n export type Element = ComponentRef<typeof Primitive.button>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.button>;\n}\n\n/**\n * A button that quotes the currently selected text.\n *\n * Must be placed inside `SelectionToolbarPrimitive.Root`. Reads the\n * selection info from context (captured by the Root), sets it as a\n * quote in the thread composer, and clears the selection.\n *\n * @example\n * ```tsx\n * <SelectionToolbarPrimitive.Quote>\n * <QuoteIcon /> Quote\n * </SelectionToolbarPrimitive.Quote>\n * ```\n */\nexport const SelectionToolbarPrimitiveQuote = forwardRef<\n SelectionToolbarPrimitiveQuote.Element,\n SelectionToolbarPrimitiveQuote.Props\n>(({ onClick, disabled, ...props }, forwardedRef) => {\n const aui = useAui();\n const info = useSelectionToolbarInfo();\n\n const handleClick = useCallback(() => {\n if (!info) return;\n\n aui.thread.composer().setQuote({\n text: info.text,\n messageId: info.messageId,\n });\n\n window.getSelection()?.removeAllRanges();\n }, [aui, info]);\n\n return (\n <Primitive.button\n type=\"button\"\n {...props}\n ref={forwardedRef}\n disabled={disabled || !info}\n onClick={composeEventHandlers(onClick, handleClick)}\n />\n );\n});\n\nSelectionToolbarPrimitiveQuote.displayName = \"SelectionToolbarPrimitive.Quote\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAaU,iCAAiCJ,YAG5CQ,IAAAC,iBAAA;CAAA,MAAAC,IAAAf,EAAA,EAAA;CAAA,IAAAgB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAI,SAAAD,UAAA,GAAAE,SAAAL;EAA+BE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAF,WAAAD,EAAA;EAAAE,UAAAF,EAAA;EAAAG,QAAAH,EAAA;CAAA;CAChC,MAAAI,MAAYZ,OAAO;CACnB,MAAAa,OAAaZ,wBAAwB;CAAE,IAAAa;CAAA,IAAAN,EAAA,OAAAI,OAAAJ,EAAA,OAAAK,MAAA;EAEPC,WAAA;GAC9B,IAAI,CAACD,MAAI;GAETD,IAAGG,OAAOC,SAAU,CAAC,CAAAC,SAAU;IAAAC,MACvBL,KAAIK;IAAKC,WACJN,KAAIM;GACjB,CAAC;GAEDC,OAAMC,aAA+B,CAAC,EAAAC,gBAAC;EAAC;EACzCd,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CATD,MAAAe,cAAoBT;CAgBN,MAAAU,KAAAf,YAAA,CAAaI;CAAI,IAAAY;CAAA,IAAAjB,EAAA,OAAAe,eAAAf,EAAA,OAAAE,SAAA;EAClBe,KAAA9B,qBAAqBe,SAASa,WAAW;EAACf,EAAA,KAAAe;EAAAf,EAAA,KAAAE;EAAAF,EAAA,KAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAAA,IAAAkB;CAAA,IAAAlB,EAAA,QAAAD,gBAAAC,EAAA,QAAAG,SAAAH,EAAA,QAAAgB,MAAAhB,EAAA,QAAAiB,IAAA;EALrDC,KAAA,
|
|
1
|
+
{"version":3,"file":"SelectionToolbarQuote.js","names":["c","_c","Primitive","composeEventHandlers","ComponentPropsWithoutRef","ComponentRef","forwardRef","useCallback","useAui","useSelectionToolbarInfo","SelectionToolbarPrimitiveQuote","Element","button","Props","t0","forwardedRef","$","disabled","onClick","props","aui","info","t1","thread","composer","setQuote","text","messageId","window","getSelection","removeAllRanges","handleClick","t2","t3","t4","displayName","_c","Primitive"],"sources":["../../../src/primitives/selectionToolbar/SelectionToolbarQuote.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n useCallback,\n} from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useSelectionToolbarInfo } from \"./SelectionToolbarRoot\";\n\nexport namespace SelectionToolbarPrimitiveQuote {\n export type Element = ComponentRef<typeof Primitive.button>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.button>;\n}\n\n/**\n * A button that quotes the currently selected text.\n *\n * Must be placed inside `SelectionToolbarPrimitive.Root`. Reads the\n * selection info from context (captured by the Root), sets it as a\n * quote in the thread composer, and clears the selection.\n *\n * @example\n * ```tsx\n * <SelectionToolbarPrimitive.Quote>\n * <QuoteIcon /> Quote\n * </SelectionToolbarPrimitive.Quote>\n * ```\n */\nexport const SelectionToolbarPrimitiveQuote = forwardRef<\n SelectionToolbarPrimitiveQuote.Element,\n SelectionToolbarPrimitiveQuote.Props\n>(({ onClick, disabled, ...props }, forwardedRef) => {\n const aui = useAui();\n const info = useSelectionToolbarInfo();\n\n const handleClick = useCallback(() => {\n if (!info) return;\n\n aui.thread.composer().setQuote({\n text: info.text,\n messageId: info.messageId,\n });\n\n window.getSelection()?.removeAllRanges();\n }, [aui, info]);\n\n return (\n <Primitive.button\n type=\"button\"\n {...props}\n ref={forwardedRef}\n disabled={disabled || !info}\n onClick={composeEventHandlers(onClick, handleClick)}\n />\n );\n});\n\nSelectionToolbarPrimitiveQuote.displayName = \"SelectionToolbarPrimitive.Quote\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAaU,iCAAiCJ,YAG5CQ,IAAAC,iBAAA;CAAA,MAAAC,IAAAf,EAAA,EAAA;CAAA,IAAAgB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAI,SAAAD,UAAA,GAAAE,SAAAL;EAA+BE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAF,WAAAD,EAAA;EAAAE,UAAAF,EAAA;EAAAG,QAAAH,EAAA;CAAA;CAChC,MAAAI,MAAYZ,OAAO;CACnB,MAAAa,OAAaZ,wBAAwB;CAAE,IAAAa;CAAA,IAAAN,EAAA,OAAAI,OAAAJ,EAAA,OAAAK,MAAA;EAEPC,WAAA;GAC9B,IAAI,CAACD,MAAI;GAETD,IAAGG,OAAOC,SAAU,CAAC,CAAAC,SAAU;IAAAC,MACvBL,KAAIK;IAAKC,WACJN,KAAIM;GACjB,CAAC;GAEDC,OAAMC,aAA+B,CAAC,EAAAC,gBAAC;EAAC;EACzCd,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CATD,MAAAe,cAAoBT;CAgBN,MAAAU,KAAAf,YAAA,CAAaI;CAAI,IAAAY;CAAA,IAAAjB,EAAA,OAAAe,eAAAf,EAAA,OAAAE,SAAA;EAClBe,KAAA9B,qBAAqBe,SAASa,WAAW;EAACf,EAAA,KAAAe;EAAAf,EAAA,KAAAE;EAAAF,EAAA,KAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAAA,IAAAkB;CAAA,IAAAlB,EAAA,QAAAD,gBAAAC,EAAA,QAAAG,SAAAH,EAAA,QAAAgB,MAAAhB,EAAA,QAAAiB,IAAA;EALrDC,KAAA,oBAAAG,YAAA,QAAA;GACO,MAAA;GAAQ,GACTlB;GACCJ,KAAAA;GACK,UAAAiB;GACD,SAAAC;EAA0C,CAAA;EACnDjB,EAAA,MAAAD;EAAAC,EAAA,MAAAG;EAAAH,EAAA,MAAAgB;EAAAhB,EAAA,MAAAiB;EAAAjB,EAAA,MAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAAA,OANFkB;AAME,CAEL;AAEDxB,+BAA+ByB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionToolbarRoot.js","names":["c","_c","Primitive","composeEventHandlers","ComponentPropsWithoutRef","ComponentRef","createContext","forwardRef","useContext","useEffect","useRef","useState","createPortal","getSelectionMessageId","useThreadRootElementRef","SelectionInfo","text","messageId","rect","DOMRect","SelectionToolbarContext","useSelectionToolbarInfo","SelectionToolbarPrimitiveRoot","Element","div","Props","t0","forwardedRef","$","onMouseDown","props","style","info","setInfo","threadRootRef","warnedAboutMissingThreadRootRef","t1","t2","pendingFrame","isMouseDragging","checkSelection","cancelAnimationFrame","requestAnimationFrame","sel","window","getSelection","isCollapsed","toString","trim","current","process","env","NODE_ENV","console","warn","range","getRangeAt","getBoundingClientRect","handleSelectionChange","sel_0","handleScroll","handleMouseDown","handleMouseUp","handleMouseCancel","document","addEventListener","removeEventListener","t3","top","t4","left","width","t5","position","transform","zIndex","positionStyle","t6","_temp","t7","t8","body","displayName","e","preventDefault"],"sources":["../../../src/primitives/selectionToolbar/SelectionToolbarRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n createContext,\n forwardRef,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { getSelectionMessageId } from \"../../utils/getSelectionMessageId\";\nimport { useThreadRootElementRef } from \"../thread/ThreadRootElementContext\";\n\ntype SelectionInfo = {\n text: string;\n messageId: string;\n rect: DOMRect;\n};\n\nconst SelectionToolbarContext = createContext<SelectionInfo | null>(null);\n\nexport const useSelectionToolbarInfo = () =>\n useContext(SelectionToolbarContext);\n\nexport namespace SelectionToolbarPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\n/**\n * A floating toolbar that appears when text is selected within a message.\n *\n * Listens for browser selection changes, validates that the selection is\n * within a single message, and renders a positioned portal near the\n * selection. Prevents mousedown from clearing the selection.\n *\n * @example\n * ```tsx\n * <SelectionToolbarPrimitive.Root>\n * <SelectionToolbarPrimitive.Quote>Quote</SelectionToolbarPrimitive.Quote>\n * </SelectionToolbarPrimitive.Root>\n * ```\n */\nexport const SelectionToolbarPrimitiveRoot = forwardRef<\n SelectionToolbarPrimitiveRoot.Element,\n SelectionToolbarPrimitiveRoot.Props\n>(({ onMouseDown, style, ...props }, forwardedRef) => {\n const [info, setInfo] = useState<SelectionInfo | null>(null);\n const threadRootRef = useThreadRootElementRef();\n const warnedAboutMissingThreadRootRef = useRef(false);\n\n useEffect(() => {\n // Read the selection on the next frame so the browser has settled it.\n let pendingFrame: number | null = null;\n let isMouseDragging = false;\n\n const checkSelection = () => {\n if (pendingFrame !== null) cancelAnimationFrame(pendingFrame);\n pendingFrame = requestAnimationFrame(() => {\n pendingFrame = null;\n const sel = window.getSelection();\n if (!sel || sel.isCollapsed) {\n setInfo(null);\n return;\n }\n\n const text = sel.toString().trim();\n if (!text) {\n setInfo(null);\n return;\n }\n\n if (threadRootRef && !threadRootRef.current) {\n if (\n process.env.NODE_ENV !== \"production\" &&\n !warnedAboutMissingThreadRootRef.current\n ) {\n warnedAboutMissingThreadRootRef.current = true;\n console.warn(\n \"[SelectionToolbarPrimitive.Root] ThreadPrimitive.Root did not provide a DOM element, so the selection cannot be scoped to its thread. Ensure a custom root child forwards its ref.\",\n );\n }\n }\n\n const messageId = getSelectionMessageId(sel, threadRootRef?.current);\n if (!messageId) {\n setInfo(null);\n return;\n }\n\n const range = sel.getRangeAt(0);\n const rect = range.getBoundingClientRect();\n setInfo({ text, messageId, rect });\n });\n };\n\n const handleSelectionChange = () => {\n const sel = window.getSelection();\n if (!sel || sel.isCollapsed) {\n if (pendingFrame !== null) {\n cancelAnimationFrame(pendingFrame);\n pendingFrame = null;\n }\n setInfo(null);\n return;\n }\n\n if (!isMouseDragging) checkSelection();\n };\n\n const handleScroll = () => {\n if (pendingFrame !== null) {\n cancelAnimationFrame(pendingFrame);\n pendingFrame = null;\n }\n setInfo(null);\n };\n\n const handleMouseDown = () => {\n isMouseDragging = true;\n };\n\n const handleMouseUp = () => {\n isMouseDragging = false;\n checkSelection();\n };\n\n const handleMouseCancel = () => {\n isMouseDragging = false;\n };\n\n document.addEventListener(\"mousedown\", handleMouseDown, true);\n document.addEventListener(\"mouseup\", handleMouseUp, true);\n document.addEventListener(\"dragend\", handleMouseUp, true);\n // A context menu can consume the mouseup of the press that opened it.\n document.addEventListener(\"contextmenu\", handleMouseCancel, true);\n window.addEventListener(\"blur\", handleMouseCancel);\n document.addEventListener(\"selectionchange\", handleSelectionChange);\n document.addEventListener(\"scroll\", handleScroll, true);\n\n return () => {\n if (pendingFrame !== null) cancelAnimationFrame(pendingFrame);\n document.removeEventListener(\"mousedown\", handleMouseDown, true);\n document.removeEventListener(\"mouseup\", handleMouseUp, true);\n document.removeEventListener(\"dragend\", handleMouseUp, true);\n document.removeEventListener(\"contextmenu\", handleMouseCancel, true);\n window.removeEventListener(\"blur\", handleMouseCancel);\n document.removeEventListener(\"selectionchange\", handleSelectionChange);\n document.removeEventListener(\"scroll\", handleScroll, true);\n };\n }, [threadRootRef]);\n\n if (!info) return null;\n\n const positionStyle: React.CSSProperties = {\n position: \"fixed\",\n top: `${info.rect.top - 8}px`,\n left: `${info.rect.left + info.rect.width / 2}px`,\n transform: \"translate(-50%, -100%)\",\n zIndex: 50,\n ...style,\n };\n\n return createPortal(\n <SelectionToolbarContext.Provider value={info}>\n <Primitive.div\n {...props}\n ref={forwardedRef}\n style={positionStyle}\n onMouseDown={composeEventHandlers(onMouseDown, (e) => {\n // Prevent mousedown from clearing the text selection\n e.preventDefault();\n })}\n />\n </SelectionToolbarContext.Provider>,\n document.body,\n );\n});\n\nSelectionToolbarPrimitiveRoot.displayName = \"SelectionToolbarPrimitive.Root\";\n"],"mappings":";;;;;;;;;;AAwBA,MAAMoB,0BAA0Bd,cAAoC,IAAI;AAExE,MAAae,gCAA0B;CAAA,OACrCb,WAAWY,uBAAuB;AAAC;;;;;;;;;;;;;;;AAqBrC,MAAaE,gCAAgCf,YAG3CmB,IAAAC,iBAAA;CAAA,MAAAC,IAAA3B,EAAA,EAAA;CAAA,IAAA4B;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAG,aAAAE,OAAA,GAAAD,SAAAJ;EAAgCE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAF,cAAAD,EAAA;EAAAE,QAAAF,EAAA;EAAAG,QAAAH,EAAA;CAAA;CACjC,MAAA,CAAAI,MAAAC,WAAwBtB,SAA+B,IAAI;CAC3D,MAAAuB,gBAAsBpB,wBAAwB;CAC9C,MAAAq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ComponentPropsWithoutRef","ComponentRef","createContext","forwardRef","useContext","useEffect","useRef","useState","createPortal","getSelectionMessageId","useThreadRootElementRef","SelectionInfo","text","messageId","rect","DOMRect","SelectionToolbarContext","useSelectionToolbarInfo","SelectionToolbarPrimitiveRoot","Element","div","Props","t0","forwardedRef","$","onMouseDown","props","style","info","setInfo","threadRootRef","warnedAboutMissingThreadRootRef","t1","t2","pendingFrame","isMouseDragging","checkSelection","cancelAnimationFrame","requestAnimationFrame","sel","window","getSelection","isCollapsed","toString","trim","current","process","env","NODE_ENV","console","warn","range","getRangeAt","getBoundingClientRect","handleSelectionChange","sel_0","handleScroll","handleMouseDown","handleMouseUp","handleMouseCancel","document","addEventListener","removeEventListener","t3","top","t4","left","width","t5","position","transform","zIndex","positionStyle","t6","_temp","t7","t8","body","displayName","e","preventDefault","_c","Primitive"],"sources":["../../../src/primitives/selectionToolbar/SelectionToolbarRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n createContext,\n forwardRef,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { getSelectionMessageId } from \"../../utils/getSelectionMessageId\";\nimport { useThreadRootElementRef } from \"../thread/ThreadRootElementContext\";\n\ntype SelectionInfo = {\n text: string;\n messageId: string;\n rect: DOMRect;\n};\n\nconst SelectionToolbarContext = createContext<SelectionInfo | null>(null);\n\nexport const useSelectionToolbarInfo = () =>\n useContext(SelectionToolbarContext);\n\nexport namespace SelectionToolbarPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\n/**\n * A floating toolbar that appears when text is selected within a message.\n *\n * Listens for browser selection changes, validates that the selection is\n * within a single message, and renders a positioned portal near the\n * selection. Prevents mousedown from clearing the selection.\n *\n * @example\n * ```tsx\n * <SelectionToolbarPrimitive.Root>\n * <SelectionToolbarPrimitive.Quote>Quote</SelectionToolbarPrimitive.Quote>\n * </SelectionToolbarPrimitive.Root>\n * ```\n */\nexport const SelectionToolbarPrimitiveRoot = forwardRef<\n SelectionToolbarPrimitiveRoot.Element,\n SelectionToolbarPrimitiveRoot.Props\n>(({ onMouseDown, style, ...props }, forwardedRef) => {\n const [info, setInfo] = useState<SelectionInfo | null>(null);\n const threadRootRef = useThreadRootElementRef();\n const warnedAboutMissingThreadRootRef = useRef(false);\n\n useEffect(() => {\n // Read the selection on the next frame so the browser has settled it.\n let pendingFrame: number | null = null;\n let isMouseDragging = false;\n\n const checkSelection = () => {\n if (pendingFrame !== null) cancelAnimationFrame(pendingFrame);\n pendingFrame = requestAnimationFrame(() => {\n pendingFrame = null;\n const sel = window.getSelection();\n if (!sel || sel.isCollapsed) {\n setInfo(null);\n return;\n }\n\n const text = sel.toString().trim();\n if (!text) {\n setInfo(null);\n return;\n }\n\n if (threadRootRef && !threadRootRef.current) {\n if (\n process.env.NODE_ENV !== \"production\" &&\n !warnedAboutMissingThreadRootRef.current\n ) {\n warnedAboutMissingThreadRootRef.current = true;\n console.warn(\n \"[SelectionToolbarPrimitive.Root] ThreadPrimitive.Root did not provide a DOM element, so the selection cannot be scoped to its thread. Ensure a custom root child forwards its ref.\",\n );\n }\n }\n\n const messageId = getSelectionMessageId(sel, threadRootRef?.current);\n if (!messageId) {\n setInfo(null);\n return;\n }\n\n const range = sel.getRangeAt(0);\n const rect = range.getBoundingClientRect();\n setInfo({ text, messageId, rect });\n });\n };\n\n const handleSelectionChange = () => {\n const sel = window.getSelection();\n if (!sel || sel.isCollapsed) {\n if (pendingFrame !== null) {\n cancelAnimationFrame(pendingFrame);\n pendingFrame = null;\n }\n setInfo(null);\n return;\n }\n\n if (!isMouseDragging) checkSelection();\n };\n\n const handleScroll = () => {\n if (pendingFrame !== null) {\n cancelAnimationFrame(pendingFrame);\n pendingFrame = null;\n }\n setInfo(null);\n };\n\n const handleMouseDown = () => {\n isMouseDragging = true;\n };\n\n const handleMouseUp = () => {\n isMouseDragging = false;\n checkSelection();\n };\n\n const handleMouseCancel = () => {\n isMouseDragging = false;\n };\n\n document.addEventListener(\"mousedown\", handleMouseDown, true);\n document.addEventListener(\"mouseup\", handleMouseUp, true);\n document.addEventListener(\"dragend\", handleMouseUp, true);\n // A context menu can consume the mouseup of the press that opened it.\n document.addEventListener(\"contextmenu\", handleMouseCancel, true);\n window.addEventListener(\"blur\", handleMouseCancel);\n document.addEventListener(\"selectionchange\", handleSelectionChange);\n document.addEventListener(\"scroll\", handleScroll, true);\n\n return () => {\n if (pendingFrame !== null) cancelAnimationFrame(pendingFrame);\n document.removeEventListener(\"mousedown\", handleMouseDown, true);\n document.removeEventListener(\"mouseup\", handleMouseUp, true);\n document.removeEventListener(\"dragend\", handleMouseUp, true);\n document.removeEventListener(\"contextmenu\", handleMouseCancel, true);\n window.removeEventListener(\"blur\", handleMouseCancel);\n document.removeEventListener(\"selectionchange\", handleSelectionChange);\n document.removeEventListener(\"scroll\", handleScroll, true);\n };\n }, [threadRootRef]);\n\n if (!info) return null;\n\n const positionStyle: React.CSSProperties = {\n position: \"fixed\",\n top: `${info.rect.top - 8}px`,\n left: `${info.rect.left + info.rect.width / 2}px`,\n transform: \"translate(-50%, -100%)\",\n zIndex: 50,\n ...style,\n };\n\n return createPortal(\n <SelectionToolbarContext.Provider value={info}>\n <Primitive.div\n {...props}\n ref={forwardedRef}\n style={positionStyle}\n onMouseDown={composeEventHandlers(onMouseDown, (e) => {\n // Prevent mousedown from clearing the text selection\n e.preventDefault();\n })}\n />\n </SelectionToolbarContext.Provider>,\n document.body,\n );\n});\n\nSelectionToolbarPrimitiveRoot.displayName = \"SelectionToolbarPrimitive.Root\";\n"],"mappings":";;;;;;;;;;AAwBA,MAAMoB,0BAA0Bd,cAAoC,IAAI;AAExE,MAAae,gCAA0B;CAAA,OACrCb,WAAWY,uBAAuB;AAAC;;;;;;;;;;;;;;;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A,OAAAA,KAAAnD,EAAA;CAAA,IAAAoD;CAAA,IAAApD,EAAA,QAAAI,QAAAJ,EAAA,QAAAmD,IAAA;EAVCC,KAAApE,aACL,oBAAA,wBAAA,UAAA;GAAyCoB,OAAAA;GACvC+C,UAAAA;EASF,CAAA,GACAf,SAAQiB,IACV;EAACrD,EAAA,MAAAI;EAAAJ,EAAA,MAAAmD;EAAAnD,EAAA,MAAAoD;CAAA,OAAAA,KAAApD,EAAA;CAAA,OAbMoD;AAaN,CACF;AAED1D,8BAA8B4D,cAAc;AArI1C,SAAAJ,MAAAK,GAAA;CA6HQA,EAACC,eAAgB;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestionDescription.js","names":["c","_c","Primitive","ElementRef","forwardRef","ComponentPropsWithoutRef","useAuiState","SuggestionPrimitiveDescription","Element","span","Props","props","ref","$","label","_temp","t0","children","t1","displayName","s","suggestion"],"sources":["../../../src/primitives/suggestion/SuggestionDescription.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ElementRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace SuggestionPrimitiveDescription {\n export type Element = ElementRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\n/**\n * Renders the description/label of the suggestion.\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Description />\n * ```\n */\nexport const SuggestionPrimitiveDescription = forwardRef<\n SuggestionPrimitiveDescription.Element,\n SuggestionPrimitiveDescription.Props\n>((props, ref) => {\n const label = useAuiState((s) => s.suggestion.label);\n\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? label}\n </Primitive.span>\n );\n});\n\nSuggestionPrimitiveDescription.displayName = \"SuggestionPrimitive.Description\";\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAaO,iCAAiCH,YAG5CO,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAAa,QAAcR,YAAYS,KAAyB;CAI9C,MAAAC,KAAAL,MAAKM,YAALH;CAAuB,IAAAI;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EAD1BE,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBP;GAAYC;GAC7BI,UAAAA;EACH,CAAA;EAAiBH,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFjBK;AAEiB,CAEpB;AAEDX,+BAA+BY,cAAc;AAV3C,SAAAJ,MAAAK,GAAA;CAAA,OACiCA,EAACC,WAAWP;AAAM"}
|
|
1
|
+
{"version":3,"file":"SuggestionDescription.js","names":["c","_c","Primitive","ElementRef","forwardRef","ComponentPropsWithoutRef","useAuiState","SuggestionPrimitiveDescription","Element","span","Props","props","ref","$","label","_temp","t0","children","t1","displayName","s","suggestion","_c"],"sources":["../../../src/primitives/suggestion/SuggestionDescription.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ElementRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace SuggestionPrimitiveDescription {\n export type Element = ElementRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\n/**\n * Renders the description/label of the suggestion.\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Description />\n * ```\n */\nexport const SuggestionPrimitiveDescription = forwardRef<\n SuggestionPrimitiveDescription.Element,\n SuggestionPrimitiveDescription.Props\n>((props, ref) => {\n const label = useAuiState((s) => s.suggestion.label);\n\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? label}\n </Primitive.span>\n );\n});\n\nSuggestionPrimitiveDescription.displayName = \"SuggestionPrimitive.Description\";\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAaO,iCAAiCH,YAG5CO,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAAa,QAAcR,YAAYS,KAAyB;CAI9C,MAAAC,KAAAL,MAAKM,YAALH;CAAuB,IAAAI;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EAD1BE,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBP;GAAYC;GAC7BI,UAAAA;EACH,CAAA;EAAiBH,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFjBK;AAEiB,CAEpB;AAEDX,+BAA+BY,cAAc;AAV3C,SAAAJ,MAAAK,GAAA;CAAA,OACiCA,EAACC,WAAWP;AAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestionTitle.js","names":["c","_c","Primitive","ElementRef","forwardRef","ComponentPropsWithoutRef","useAuiState","SuggestionPrimitiveTitle","Element","span","Props","props","ref","$","title","_temp","t0","children","t1","displayName","s","suggestion"],"sources":["../../../src/primitives/suggestion/SuggestionTitle.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ElementRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace SuggestionPrimitiveTitle {\n export type Element = ElementRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\n/**\n * Renders the title of the suggestion.\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Title />\n * ```\n */\nexport const SuggestionPrimitiveTitle = forwardRef<\n SuggestionPrimitiveTitle.Element,\n SuggestionPrimitiveTitle.Props\n>((props, ref) => {\n const title = useAuiState((s) => s.suggestion.title);\n\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? title}\n </Primitive.span>\n );\n});\n\nSuggestionPrimitiveTitle.displayName = \"SuggestionPrimitive.Title\";\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAaO,2BAA2BH,YAGtCO,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAAa,QAAcR,YAAYS,KAAyB;CAI9C,MAAAC,KAAAL,MAAKM,YAALH;CAAuB,IAAAI;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EAD1BE,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBP;GAAYC;GAC7BI,UAAAA;EACH,CAAA;EAAiBH,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFjBK;AAEiB,CAEpB;AAEDX,yBAAyBY,cAAc;AAVrC,SAAAJ,MAAAK,GAAA;CAAA,OACiCA,EAACC,WAAWP;AAAM"}
|
|
1
|
+
{"version":3,"file":"SuggestionTitle.js","names":["c","_c","Primitive","ElementRef","forwardRef","ComponentPropsWithoutRef","useAuiState","SuggestionPrimitiveTitle","Element","span","Props","props","ref","$","title","_temp","t0","children","t1","displayName","s","suggestion","_c"],"sources":["../../../src/primitives/suggestion/SuggestionTitle.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ElementRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace SuggestionPrimitiveTitle {\n export type Element = ElementRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\n/**\n * Renders the title of the suggestion.\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Title />\n * ```\n */\nexport const SuggestionPrimitiveTitle = forwardRef<\n SuggestionPrimitiveTitle.Element,\n SuggestionPrimitiveTitle.Props\n>((props, ref) => {\n const title = useAuiState((s) => s.suggestion.title);\n\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? title}\n </Primitive.span>\n );\n});\n\nSuggestionPrimitiveTitle.displayName = \"SuggestionPrimitive.Title\";\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAaO,2BAA2BH,YAGtCO,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAAa,QAAcR,YAAYS,KAAyB;CAI9C,MAAAC,KAAAL,MAAKM,YAALH;CAAuB,IAAAI;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EAD1BE,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBP;GAAYC;GAC7BI,UAAAA;EACH,CAAA;EAAiBH,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFjBK;AAEiB,CAEpB;AAEDX,yBAAyBY,cAAc;AAVrC,SAAAJ,MAAAK,GAAA;CAAA,OACiCA,EAACC,WAAWP;AAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestionTrigger.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAuiState","useSuggestionTrigger","useSuggestionTriggerBehavior","t0","$","send","clearComposer","prompt","_temp","t1","trigger","disabled","SuggestionPrimitiveTrigger","Element","Props","s","suggestion"],"sources":["../../../src/primitives/suggestion/SuggestionTrigger.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useSuggestionTrigger as useSuggestionTriggerBehavior } from \"@assistant-ui/core/react\";\n\nconst useSuggestionTrigger = ({\n send,\n clearComposer,\n}: {\n /**\n * When true, automatically sends the message.\n * When false, replaces or appends the composer text with the suggestion - depending on the value of `clearComposer`.\n */\n send?: boolean | undefined;\n\n /**\n * Whether to clear the composer after sending. A send queued while a run is\n * in progress never clears the composer.\n * When send is set to false, determines if composer text is replaced with suggestion (true, default),\n * or if it's appended to the composer text (false).\n *\n * @default true\n */\n clearComposer?: boolean | undefined;\n}) => {\n const prompt = useAuiState((s) => s.suggestion.prompt);\n const { trigger, disabled } = useSuggestionTriggerBehavior({\n prompt,\n send,\n clearComposer,\n });\n\n if (disabled) return null;\n return trigger;\n};\n\nexport namespace SuggestionPrimitiveTrigger {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useSuggestionTrigger>;\n}\n\n/**\n * A button that triggers the suggestion action (send or insert into composer).\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Trigger send>\n * Click me\n * </SuggestionPrimitive.Trigger>\n * ```\n */\nexport const SuggestionPrimitiveTrigger = createActionButton(\n \"SuggestionPrimitive.Trigger\",\n useSuggestionTrigger,\n [\"send\", \"clearComposer\"],\n);\n"],"mappings":";;;;;;AAUA,MAAMM,0BAAuBE,OAAA;CAAA,MAAAC,IAAAR,EAAA,CAAA;CAAC,MAAA,EAAAS,MAAAC,kBAAAH;CAoB5B,MAAAI,SAAeP,YAAYQ,KAA0B;CAAE,IAAAC;CAAA,IAAAL,EAAA,OAAAE,iBAAAF,EAAA,OAAAG,UAAAH,EAAA,OAAAC,MAAA;EACII,KAAA;GAAAF;GAAAF;GAAAC;EAI3D;EAACF,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAC;EAAAD,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAJD,MAAA,EAAAM,SAAAC,aAA8BT,qBAA6BO,EAI1D;CAED,IAAIE,UAAQ,OAAS;CAAK,OACnBD;AAAO;;;;;;;;;;;AAkBhB,MAAaE,6BAA6Bb,mBACxC,+BACAE,wBACA,CAAC,QAAQ,eAAe,CAC1B;AAlD6B,SAAAO,MAAAO,GAAA;CAAA,OAoBOA,EAACC,WAAWT;AAAO"}
|
|
1
|
+
{"version":3,"file":"SuggestionTrigger.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAuiState","useSuggestionTrigger","useSuggestionTriggerBehavior","t0","$","send","clearComposer","prompt","_temp","t1","trigger","disabled","SuggestionPrimitiveTrigger","Element","Props","s","suggestion","useSuggestionTrigger","_c","useSuggestionTriggerBehavior"],"sources":["../../../src/primitives/suggestion/SuggestionTrigger.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useSuggestionTrigger as useSuggestionTriggerBehavior } from \"@assistant-ui/core/react\";\n\nconst useSuggestionTrigger = ({\n send,\n clearComposer,\n}: {\n /**\n * When true, automatically sends the message.\n * When false, replaces or appends the composer text with the suggestion - depending on the value of `clearComposer`.\n */\n send?: boolean | undefined;\n\n /**\n * Whether to clear the composer after sending. A send queued while a run is\n * in progress never clears the composer.\n * When send is set to false, determines if composer text is replaced with suggestion (true, default),\n * or if it's appended to the composer text (false).\n *\n * @default true\n */\n clearComposer?: boolean | undefined;\n}) => {\n const prompt = useAuiState((s) => s.suggestion.prompt);\n const { trigger, disabled } = useSuggestionTriggerBehavior({\n prompt,\n send,\n clearComposer,\n });\n\n if (disabled) return null;\n return trigger;\n};\n\nexport namespace SuggestionPrimitiveTrigger {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useSuggestionTrigger>;\n}\n\n/**\n * A button that triggers the suggestion action (send or insert into composer).\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Trigger send>\n * Click me\n * </SuggestionPrimitive.Trigger>\n * ```\n */\nexport const SuggestionPrimitiveTrigger = createActionButton(\n \"SuggestionPrimitive.Trigger\",\n useSuggestionTrigger,\n [\"send\", \"clearComposer\"],\n);\n"],"mappings":";;;;;;AAUA,MAAMM,0BAAuBE,OAAA;CAAA,MAAAC,IAAAR,EAAA,CAAA;CAAC,MAAA,EAAAS,MAAAC,kBAAAH;CAoB5B,MAAAI,SAAeP,YAAYQ,KAA0B;CAAE,IAAAC;CAAA,IAAAL,EAAA,OAAAE,iBAAAF,EAAA,OAAAG,UAAAH,EAAA,OAAAC,MAAA;EACII,KAAA;GAAAF;GAAAF;GAAAC;EAI3D;EAACF,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAC;EAAAD,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAJD,MAAA,EAAAM,SAAAC,aAA8BT,qBAA6BO,EAI1D;CAED,IAAIE,UAAQ,OAAS;CAAK,OACnBD;AAAO;;;;;;;;;;;AAkBhB,MAAaE,6BAA6Bb,mBACxC,+BACAE,wBACA,CAAC,QAAQ,eAAe,CAC1B;AAlD6B,SAAAO,MAAAO,GAAA;CAAA,OAoBOA,EAACC,WAAWT;AAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadIf.js","names":["c","_c","FC","PropsWithChildren","useAuiState","RequireAtLeastOne","ThreadIfFilters","empty","running","disabled","UseThreadIfProps","useThreadIf","props","$","t0","s","thread","isEmpty","isRunning","isDisabled","ThreadPrimitiveIf","Props","children","query","result","displayName"],"sources":["../../../src/primitives/thread/ThreadIf.ts"],"sourcesContent":["\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type { RequireAtLeastOne } from \"../../utils/RequireAtLeastOne\";\n\ntype ThreadIfFilters = {\n empty: boolean | undefined;\n running: boolean | undefined;\n disabled: boolean | undefined;\n};\n\ntype UseThreadIfProps = RequireAtLeastOne<ThreadIfFilters>;\n\nconst useThreadIf = (props: UseThreadIfProps) => {\n return useAuiState((s) => {\n if (props.empty === true && !s.thread.isEmpty) return false;\n if (props.empty === false && s.thread.isEmpty) return false;\n\n if (props.running === true && !s.thread.isRunning) return false;\n if (props.running === false && s.thread.isRunning) return false;\n if (props.disabled === true && !s.thread.isDisabled) return false;\n if (props.disabled === false && s.thread.isDisabled) return false;\n\n return true;\n });\n};\n\nexport namespace ThreadPrimitiveIf {\n export type Props = PropsWithChildren<UseThreadIfProps>;\n}\n\n/**\n * @deprecated Use `<AuiIf condition={(s) => s.thread...} />` instead.\n */\nexport const ThreadPrimitiveIf: FC<ThreadPrimitiveIf.Props> = ({\n children,\n ...query\n}) => {\n const result = useThreadIf(query);\n return result ? children : null;\n};\n\nThreadPrimitiveIf.displayName = \"ThreadPrimitive.If\";\n"],"mappings":";;;;AAcA,MAAMW,eAAcC,UAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CAAA,IAAAa;CAAA,IAAAD,EAAA,OAAAD,MAAAH,YAAAI,EAAA,OAAAD,MAAAL,SAAAM,EAAA,OAAAD,MAAAJ,SAAA;EACCM,MAAAC,MAAA;GACjB,IAAIH,MAAKL,UAAW,QAAhB,CAAyBQ,EAACC,OAAOC,SAAQ,OAAS;GACtD,IAAIL,MAAKL,UAAW,SAASQ,EAACC,OAAOC,SAAQ,OAAS;GAEtD,IAAIL,MAAKJ,YAAa,QAAlB,CAA2BO,EAACC,OAAOE,WAAU,OAAS;GAC1D,IAAIN,MAAKJ,YAAa,SAASO,EAACC,OAAOE,WAAU,OAAS;GAC1D,IAAIN,MAAKH,aAAc,QAAnB,CAA4BM,EAACC,OAAOG,YAAW,OAAS;GAC5D,IAAIP,MAAKH,aAAc,SAASM,EAACC,OAAOG,YAAW,OAAS;GAAM,OAE3D;EAAI;EACZN,EAAA,KAAAD,MAAAH;EAAAI,EAAA,KAAAD,MAAAL;EAAAM,EAAA,KAAAD,MAAAJ;EAAAK,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAAA,OAVMT,YAAYU,EAUlB;AAAC;;;;AAUJ,MAAaM,qBAAiDN,OAAA;CAAA,MAAAD,IAAAZ,EAAA,CAAA;CAAA,IAAAqB;CAAA,IAAAC;CAAA,IAAAV,EAAA,OAAAC,IAAA;EAAC,CAAA,CAAAQ,UAAA,GAAAC,SAAAT;EAG9DD,EAAA,KAAAC;EAAAD,EAAA,KAAAS;EAAAT,EAAA,KAAAU;CAAA,OAAA;EAAAD,WAAAT,EAAA;EAAAU,QAAAV,EAAA;CAAA;CACmC,OAAnBF,YAAYY,KACpBC,IAAAF,WAAA;AAAwB;AAGjCF,kBAAkBK,cAAc"}
|
|
1
|
+
{"version":3,"file":"ThreadIf.js","names":["c","_c","FC","PropsWithChildren","useAuiState","RequireAtLeastOne","ThreadIfFilters","empty","running","disabled","UseThreadIfProps","useThreadIf","props","$","t0","s","thread","isEmpty","isRunning","isDisabled","ThreadPrimitiveIf","Props","children","query","result","displayName","_c"],"sources":["../../../src/primitives/thread/ThreadIf.ts"],"sourcesContent":["\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type { RequireAtLeastOne } from \"../../utils/RequireAtLeastOne\";\n\ntype ThreadIfFilters = {\n empty: boolean | undefined;\n running: boolean | undefined;\n disabled: boolean | undefined;\n};\n\ntype UseThreadIfProps = RequireAtLeastOne<ThreadIfFilters>;\n\nconst useThreadIf = (props: UseThreadIfProps) => {\n return useAuiState((s) => {\n if (props.empty === true && !s.thread.isEmpty) return false;\n if (props.empty === false && s.thread.isEmpty) return false;\n\n if (props.running === true && !s.thread.isRunning) return false;\n if (props.running === false && s.thread.isRunning) return false;\n if (props.disabled === true && !s.thread.isDisabled) return false;\n if (props.disabled === false && s.thread.isDisabled) return false;\n\n return true;\n });\n};\n\nexport namespace ThreadPrimitiveIf {\n export type Props = PropsWithChildren<UseThreadIfProps>;\n}\n\n/**\n * @deprecated Use `<AuiIf condition={(s) => s.thread...} />` instead.\n */\nexport const ThreadPrimitiveIf: FC<ThreadPrimitiveIf.Props> = ({\n children,\n ...query\n}) => {\n const result = useThreadIf(query);\n return result ? children : null;\n};\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ement, type ActionButtonProps } from "../../utils/createActionButton.js";
|
|
2
|
+
declare const useThreadLoadEarlier: () => (() => void) | null;
|
|
3
|
+
export declare namespace ThreadPrimitiveLoadEarlier {
|
|
4
|
+
type Element = ActionButtonElement;
|
|
5
|
+
type Props = ActionButtonProps<typeof useThreadLoadEarlier>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A button that loads the page before the first loaded message. Disabled
|
|
9
|
+
* while the runtime reports no earlier messages. A press while a page is
|
|
10
|
+
* loading joins that load, so the button stays enabled and keeps keyboard
|
|
11
|
+
* focus until the page lands; read `thread.isLoadingEarlier` to show progress.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ThreadPrimitiveLoadEarlier: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
14
|
+
asChild?: boolean;
|
|
15
|
+
}, "ref"> & {
|
|
16
|
+
render?: import("react").ReactElement | undefined;
|
|
17
|
+
} & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=ThreadLoadEarlier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThreadLoadEarlier.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadLoadEarlier.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EAEvB,0CAAuC;AAExC,QAAA,MAAM,oBAAoB,2BAQzB,CAAC;AAEF,yBAAiB,0BAA0B,CAAC;IAC1C,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,CAAC;CACpE;AAED;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B;;;;gHAGtC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createActionButton } from "../../utils/createActionButton.js";
|
|
3
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
|
+
import "@assistant-ui/tap/react-shim";
|
|
5
|
+
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
6
|
+
//#region src/primitives/thread/ThreadLoadEarlier.tsx
|
|
7
|
+
const useThreadLoadEarlier = () => {
|
|
8
|
+
const $ = c(2);
|
|
9
|
+
const aui = useAui();
|
|
10
|
+
const hasEarlier = useAuiState(_temp);
|
|
11
|
+
let t0;
|
|
12
|
+
if ($[0] !== aui.thread) {
|
|
13
|
+
t0 = () => {
|
|
14
|
+
aui.thread.loadEarlier();
|
|
15
|
+
};
|
|
16
|
+
$[0] = aui.thread;
|
|
17
|
+
$[1] = t0;
|
|
18
|
+
} else t0 = $[1];
|
|
19
|
+
const loadEarlier = t0;
|
|
20
|
+
if (!hasEarlier) return null;
|
|
21
|
+
return loadEarlier;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A button that loads the page before the first loaded message. Disabled
|
|
25
|
+
* while the runtime reports no earlier messages. A press while a page is
|
|
26
|
+
* loading joins that load, so the button stays enabled and keeps keyboard
|
|
27
|
+
* focus until the page lands; read `thread.isLoadingEarlier` to show progress.
|
|
28
|
+
*/
|
|
29
|
+
const ThreadPrimitiveLoadEarlier = createActionButton("ThreadPrimitive.LoadEarlier", useThreadLoadEarlier);
|
|
30
|
+
function _temp(s) {
|
|
31
|
+
return s.thread.hasEarlier;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { ThreadPrimitiveLoadEarlier };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=ThreadLoadEarlier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThreadLoadEarlier.js","names":["c","_c","useCallback","useAui","useAuiState","ActionButtonElement","ActionButtonProps","createActionButton","useThreadLoadEarlier","$","aui","hasEarlier","_temp","t0","thread","loadEarlier","ThreadPrimitiveLoadEarlier","Element","Props","s","_c"],"sources":["../../../src/primitives/thread/ThreadLoadEarlier.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCallback } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\n\nconst useThreadLoadEarlier = () => {\n const aui = useAui();\n const hasEarlier = useAuiState((s) => s.thread.hasEarlier);\n const loadEarlier = useCallback(() => {\n void aui.thread.loadEarlier();\n }, [aui]);\n if (!hasEarlier) return null;\n return loadEarlier;\n};\n\nexport namespace ThreadPrimitiveLoadEarlier {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadLoadEarlier>;\n}\n\n/**\n * A button that loads the page before the first loaded message. Disabled\n * while the runtime reports no earlier messages. A press while a page is\n * loading joins that load, so the button stays enabled and keeps keyboard\n * focus until the page lands; read `thread.isLoadingEarlier` to show progress.\n */\nexport const ThreadPrimitiveLoadEarlier = createActionButton(\n \"ThreadPrimitive.LoadEarlier\",\n useThreadLoadEarlier,\n);\n"],"mappings":";;;;;;AAUA,MAAMQ,6BAAuB;CAAA,MAAAC,IAAAR,EAAA,CAAA;CAC3B,MAAAS,MAAYP,OAAO;CACnB,MAAAQ,aAAmBP,YAAYQ,KAA0B;CAAE,IAAAC;CAAA,IAAAJ,EAAA,OAAAC,IAAAI,QAAA;EAC3BD,WAAA;GACzBH,IAAGI,OAAOC,YAAa;EAAC;EAC9BN,EAAA,KAAAC,IAAAI;EAAAL,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAFD,MAAAM,cAAoBF;CAGpB,IAAI,CAACF,YAAU,OAAS;CAAK,OACtBI;AAAW;;;;;;;AAcpB,MAAaC,6BAA6BT,mBACxC,+BACAC,oBACF;AAxB6B,SAAAI,MAAAO,GAAA;CAAA,OAEWA,EAACL,OAAOH;AAAW"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveMessageByIndex, ThreadPrimitiveUnstable_MessageById, } from "@assistant-ui/core/react";
|
|
1
|
+
export { ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveMessageByIndex, ThreadPrimitiveUnstable_MessageById, ThreadPrimitiveRow, } from "@assistant-ui/core/react";
|
|
2
2
|
//# sourceMappingURL=ThreadMessages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadMessages.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadMessages.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,6BAA6B,EAC7B,mCAAmC,
|
|
1
|
+
{"version":3,"file":"ThreadMessages.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadMessages.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,6BAA6B,EAC7B,mCAAmC,EACnC,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveUnstable_MessageById } from "@assistant-ui/core/react";
|
|
3
|
-
export { ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveUnstable_MessageById };
|
|
2
|
+
import { ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveRow, ThreadPrimitiveUnstable_MessageById } from "@assistant-ui/core/react";
|
|
3
|
+
export { ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveRow, ThreadPrimitiveUnstable_MessageById };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAA8B;
|
|
1
|
+
{"version":3,"file":"ThreadRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAA8B;AAElD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,wBAAwB,EAI9B,MAAM,OAAO,CAAC;AAOf,yBAAiB,mBAAmB,CAAC;IACnC,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACzD;;;OAGG;IACH,KAAY,KAAK,GAAG,wBAAwB,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;CACpE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,mBAAmB;;;;0GAgE9B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Primitive as Primitive$1 } from "../../utils/Primitive.js";
|
|
3
|
+
import { isCompositionKey } from "../../utils/isCompositionKey.js";
|
|
3
4
|
import { ThreadRootElementContext } from "./ThreadRootElementContext.js";
|
|
4
5
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
6
|
import { forwardRef, useEffect, useRef } from "@assistant-ui/tap/react-shim";
|
|
@@ -50,6 +51,7 @@ const ThreadPrimitiveRoot = forwardRef((props, ref) => {
|
|
|
50
51
|
t1 = () => {
|
|
51
52
|
const handleKeyDown = (event_0) => {
|
|
52
53
|
if (event_0.key !== "Escape") return;
|
|
54
|
+
if (isCompositionKey(event_0)) return;
|
|
53
55
|
if (event_0.defaultPrevented || aui.thread.source === null) return;
|
|
54
56
|
const eventThreadRoot = escapeEventThreadRoots.get(event_0) ?? event_0.composedPath().find(_temp);
|
|
55
57
|
if (eventThreadRoot && eventThreadRoot !== rootRef.current) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","KeyboardEventHandler","useEffect","useRef","useAui","useComposedRefs","ThreadRootElementContext","escapeEventThreadRoots","WeakMap","KeyboardEvent","Element","ThreadPrimitiveRoot","div","Props","props","ref","$","aui","rootRef","composedRef","t0","event","key","current","set","nativeEvent","onKeyDown","handleRootKeyDown","t1","t2","handleKeyDown","event_0","defaultPrevented","thread","source","eventThreadRoot","get","composedPath","find","_temp","getState","speech","preventDefault","stopSpeaking","t3","error","Error","message","document","addEventListener","removeEventListener","displayName","target","hasAttribute"],"sources":["../../../src/primitives/thread/ThreadRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type KeyboardEventHandler,\n useEffect,\n useRef,\n} from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { ThreadRootElementContext } from \"./ThreadRootElementContext\";\n\nconst escapeEventThreadRoots = new WeakMap<KeyboardEvent, Element>();\n\nexport namespace ThreadPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n /**\n * Props for the ThreadPrimitive.Root component.\n * Accepts all standard div element props.\n */\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\n/**\n * The root container component for a thread.\n *\n * This component serves as the foundational wrapper for all thread-related components.\n * It provides the basic structure and context needed for thread functionality.\n *\n * While this component is mounted, an unhandled Escape keydown inside this thread stops its\n * active speech, even if the action bar that started it is no longer mounted. Escape outside\n * every thread retains the document-level fallback.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Root>\n * <ThreadPrimitive.Viewport>\n * <ThreadPrimitive.Messages>\n * {() => <MyMessage />}\n * </ThreadPrimitive.Messages>\n * </ThreadPrimitive.Viewport>\n * </ThreadPrimitive.Root>\n * ```\n */\nexport const ThreadPrimitiveRoot = forwardRef<\n ThreadPrimitiveRoot.Element,\n ThreadPrimitiveRoot.Props\n>((props, ref) => {\n const aui = useAui();\n const rootRef = useRef<ThreadPrimitiveRoot.Element>(null);\n const composedRef = useComposedRefs(ref, rootRef);\n const handleRootKeyDown: KeyboardEventHandler<ThreadPrimitiveRoot.Element> = (\n event,\n ) => {\n if (event.key === \"Escape\" && rootRef.current) {\n escapeEventThreadRoots.set(event.nativeEvent, rootRef.current);\n }\n props.onKeyDown?.(event);\n };\n\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\") return;\n if (event.defaultPrevented || aui.thread.source === null) return;\n const eventThreadRoot =\n escapeEventThreadRoots.get(event) ??\n event\n .composedPath()\n .find(\n (target) =>\n target instanceof Element &&\n target.hasAttribute(\"data-aui-thread-root\"),\n );\n if (eventThreadRoot && eventThreadRoot !== rootRef.current) return;\n if (aui.thread.getState().speech == null) return;\n event.preventDefault();\n try {\n aui.thread.stopSpeaking();\n } catch (error) {\n // getState() is the last rendered snapshot, so speech can finish before this call.\n if (\n !(error instanceof Error) ||\n error.message !== \"No message is being spoken\"\n ) {\n throw error;\n }\n }\n };\n\n // Bubble phase lets capture-phase Escape handlers consume the event first.\n document.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [aui]);\n\n return (\n <ThreadRootElementContext.Provider value={rootRef}>\n <Primitive.div\n {...props}\n data-aui-thread-root=\"\"\n ref={composedRef}\n onKeyDown={handleRootKeyDown}\n />\n </ThreadRootElementContext.Provider>\n );\n});\n\nThreadPrimitiveRoot.displayName = \"ThreadPrimitive.Root\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ThreadRoot.js","names":["c","_c","Primitive","isCompositionKey","ComponentRef","forwardRef","ComponentPropsWithoutRef","KeyboardEventHandler","useEffect","useRef","useAui","useComposedRefs","ThreadRootElementContext","escapeEventThreadRoots","WeakMap","KeyboardEvent","Element","ThreadPrimitiveRoot","div","Props","props","ref","$","aui","rootRef","composedRef","t0","event","key","current","set","nativeEvent","onKeyDown","handleRootKeyDown","t1","t2","handleKeyDown","event_0","defaultPrevented","thread","source","eventThreadRoot","get","composedPath","find","_temp","getState","speech","preventDefault","stopSpeaking","t3","error","Error","message","document","addEventListener","removeEventListener","displayName","target","hasAttribute","_c","Primitive"],"sources":["../../../src/primitives/thread/ThreadRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport { isCompositionKey } from \"../../utils/isCompositionKey\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type KeyboardEventHandler,\n useEffect,\n useRef,\n} from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { ThreadRootElementContext } from \"./ThreadRootElementContext\";\n\nconst escapeEventThreadRoots = new WeakMap<KeyboardEvent, Element>();\n\nexport namespace ThreadPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n /**\n * Props for the ThreadPrimitive.Root component.\n * Accepts all standard div element props.\n */\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\n/**\n * The root container component for a thread.\n *\n * This component serves as the foundational wrapper for all thread-related components.\n * It provides the basic structure and context needed for thread functionality.\n *\n * While this component is mounted, an unhandled Escape keydown inside this thread stops its\n * active speech, even if the action bar that started it is no longer mounted. Escape outside\n * every thread retains the document-level fallback.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Root>\n * <ThreadPrimitive.Viewport>\n * <ThreadPrimitive.Messages>\n * {() => <MyMessage />}\n * </ThreadPrimitive.Messages>\n * </ThreadPrimitive.Viewport>\n * </ThreadPrimitive.Root>\n * ```\n */\nexport const ThreadPrimitiveRoot = forwardRef<\n ThreadPrimitiveRoot.Element,\n ThreadPrimitiveRoot.Props\n>((props, ref) => {\n const aui = useAui();\n const rootRef = useRef<ThreadPrimitiveRoot.Element>(null);\n const composedRef = useComposedRefs(ref, rootRef);\n const handleRootKeyDown: KeyboardEventHandler<ThreadPrimitiveRoot.Element> = (\n event,\n ) => {\n if (event.key === \"Escape\" && rootRef.current) {\n escapeEventThreadRoots.set(event.nativeEvent, rootRef.current);\n }\n props.onKeyDown?.(event);\n };\n\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\") return;\n // An Escape that ends an IME composition belongs to the input method.\n if (isCompositionKey(event)) return;\n if (event.defaultPrevented || aui.thread.source === null) return;\n const eventThreadRoot =\n escapeEventThreadRoots.get(event) ??\n event\n .composedPath()\n .find(\n (target) =>\n target instanceof Element &&\n target.hasAttribute(\"data-aui-thread-root\"),\n );\n if (eventThreadRoot && eventThreadRoot !== rootRef.current) return;\n if (aui.thread.getState().speech == null) return;\n event.preventDefault();\n try {\n aui.thread.stopSpeaking();\n } catch (error) {\n // getState() is the last rendered snapshot, so speech can finish before this call.\n if (\n !(error instanceof Error) ||\n error.message !== \"No message is being spoken\"\n ) {\n throw error;\n }\n }\n };\n\n // Bubble phase lets capture-phase Escape handlers consume the event first.\n document.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [aui]);\n\n return (\n <ThreadRootElementContext.Provider value={rootRef}>\n <Primitive.div\n {...props}\n data-aui-thread-root=\"\"\n ref={composedRef}\n onKeyDown={handleRootKeyDown}\n />\n </ThreadRootElementContext.Provider>\n );\n});\n\nThreadPrimitiveRoot.displayName = \"ThreadPrimitive.Root\";\n"],"mappings":";;;;;;;;;;AAgBA,MAAMa,yCAAyB,IAAIC,QAAgC;;;;;;;;;;;;;;;;;;;;;;AAgCnE,MAAaG,sBAAsBZ,YAGjCe,OAAAC,QAAA;CAAA,MAAAC,IAAArB,EAAA,CAAA;CACA,MAAAsB,MAAYb,OAAO;CACnB,MAAAc,UAAgBf,OAA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,EAAK;CAAC,IAAAe;CAAA,IAAA5B,EAAA,OAAAG,eAAAH,EAAA,OAAAW,qBAAAX,EAAA,OAAAF,OAAA;EAGP8B,KAAA,oBAAA,yBAAA,UAAA;GAA0C1B,OAAAA;GACxC,UAAA,oBAAAqC,YAAA,KAAA;IAAA,GACMzC;IACiB,wBAAA;IAChBK,KAAAA;IACMQ,WAAAA;GAAiB,CAAA;EAEhC,CAAA;EAAoCX,EAAA,KAAAG;EAAAH,EAAA,KAAAW;EAAAX,EAAA,KAAAF;EAAAE,EAAA,KAAA4B;CAAA,OAAAA,KAAA5B,EAAA;CAAA,OAPpC4B;AAOoC,CAEvC;AAEDjC,oBAAoBwC,cAAc;AA/DhC,SAAAZ,MAAAa,QAAA;CAAA,OAyBYA,kBAAkB1C,WAClB0C,OAAMC,aAAc,sBAAsB;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadScrollToBottom.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useCallback","useThreadViewport","useThreadViewportStore","useThreadScrollToBottom","Options","behavior","ScrollBehavior","t0","$","t1","undefined","isAtBottom","_temp","threadViewportStore","t2","getState","scrollToBottom","handleScrollToBottom","ThreadPrimitiveScrollToBottom","Element","Props","s"],"sources":["../../../src/primitives/thread/ThreadScrollToBottom.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadScrollToBottom {\n export type Options = {\n behavior?: ScrollBehavior | undefined;\n };\n}\n\nconst useThreadScrollToBottom = ({\n behavior,\n}: useThreadScrollToBottom.Options = {}) => {\n const isAtBottom = useThreadViewport((s) => s.isAtBottom);\n\n const threadViewportStore = useThreadViewportStore();\n\n const handleScrollToBottom = useCallback(() => {\n threadViewportStore.getState().scrollToBottom({ behavior });\n }, [threadViewportStore, behavior]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n\nexport namespace ThreadPrimitiveScrollToBottom {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadScrollToBottom>;\n}\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n [\"behavior\"],\n);\n"],"mappings":";;;;;;AAmBA,MAAMQ,2BAA0BI,OAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CAAA,IAAAa;CAAA,IAAAD,EAAA,OAAAD,IAAA;EAACE,KAAAF,OAAAG,KAAAA,IAAA,CAEK,IAFLH;EAEMC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAFN,MAAA,EAAAH,aAAAI;CAG/B,MAAAE,aAAmBV,kBAAkBW,KAAmB;CAExD,MAAAC,sBAA4BX,uBAAuB;CAAE,IAAAY;CAAA,IAAAN,EAAA,OAAAH,YAAAG,EAAA,OAAAK,qBAAA;EAEZC,WAAA;GACvCD,oBAAmBE,SAAU,CAAC,CAAAC,eAAgB,EAAAX,SAAW,CAAC;EAAC;EAC5DG,EAAA,KAAAH;EAAAG,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAFD,MAAAS,uBAA6BH;CAI7B,IAAIH,YAAU,OAAS;CAAK,OACrBM;AAAoB;AAQ7B,MAAaC,gCAAgCnB,mBAC3C,kCACAI,yBACA,CAAC,UAAU,CACb;AAxBgC,SAAAS,MAAAS,GAAA;CAAA,OAGcA,EAACV;AAAW"}
|
|
1
|
+
{"version":3,"file":"ThreadScrollToBottom.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useCallback","useThreadViewport","useThreadViewportStore","useThreadScrollToBottom","Options","behavior","ScrollBehavior","t0","$","t1","undefined","isAtBottom","_temp","threadViewportStore","t2","getState","scrollToBottom","handleScrollToBottom","ThreadPrimitiveScrollToBottom","Element","Props","s","_c"],"sources":["../../../src/primitives/thread/ThreadScrollToBottom.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadScrollToBottom {\n export type Options = {\n behavior?: ScrollBehavior | undefined;\n };\n}\n\nconst useThreadScrollToBottom = ({\n behavior,\n}: useThreadScrollToBottom.Options = {}) => {\n const isAtBottom = useThreadViewport((s) => s.isAtBottom);\n\n const threadViewportStore = useThreadViewportStore();\n\n const handleScrollToBottom = useCallback(() => {\n threadViewportStore.getState().scrollToBottom({ behavior });\n }, [threadViewportStore, behavior]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n\nexport namespace ThreadPrimitiveScrollToBottom {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadScrollToBottom>;\n}\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n [\"behavior\"],\n);\n"],"mappings":";;;;;;AAmBA,MAAMQ,2BAA0BI,OAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CAAA,IAAAa;CAAA,IAAAD,EAAA,OAAAD,IAAA;EAACE,KAAAF,OAAAG,KAAAA,IAAA,CAEK,IAFLH;EAEMC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAFN,MAAA,EAAAH,aAAAI;CAG/B,MAAAE,aAAmBV,kBAAkBW,KAAmB;CAExD,MAAAC,sBAA4BX,uBAAuB;CAAE,IAAAY;CAAA,IAAAN,EAAA,OAAAH,YAAAG,EAAA,OAAAK,qBAAA;EAEZC,WAAA;GACvCD,oBAAmBE,SAAU,CAAC,CAAAC,eAAgB,EAAAX,SAAW,CAAC;EAAC;EAC5DG,EAAA,KAAAH;EAAAG,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAFD,MAAAS,uBAA6BH;CAI7B,IAAIH,YAAU,OAAS;CAAK,OACrBM;AAAoB;AAQ7B,MAAaC,gCAAgCnB,mBAC3C,kCACAI,yBACA,CAAC,UAAU,CACb;AAxBgC,SAAAS,MAAAS,GAAA;CAAA,OAGcA,EAACV;AAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadSuggestion.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useSuggestionTrigger","useSuggestionTriggerBehavior","useThreadSuggestion","t0","$","prompt","send","clearComposer","autoSend","resolvedSend","t1","disabled","trigger","ThreadPrimitiveSuggestion","Element","Props"],"sources":["../../../src/primitives/thread/ThreadSuggestion.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useSuggestionTrigger as useSuggestionTriggerBehavior } from \"@assistant-ui/core/react\";\n\nconst useThreadSuggestion = ({\n prompt,\n send,\n clearComposer,\n autoSend,\n method: _method,\n}: {\n /** The suggestion prompt. */\n prompt: string;\n\n /**\n * When true, automatically sends the message.\n * When false, replaces or appends the composer text with the suggestion - depending on the value of `clearComposer`.\n */\n send?: boolean | undefined;\n\n /**\n * Whether to clear the composer after sending. A send queued while a run is\n * in progress never clears the composer.\n * When send is set to false, determines if composer text is replaced with suggestion (true, default),\n * or if it's appended to the composer text (false).\n *\n * @default true\n */\n clearComposer?: boolean | undefined;\n\n /** @deprecated Use `send` instead. */\n autoSend?: boolean | undefined;\n\n /** @deprecated Use `clearComposer` instead. */\n method?: \"replace\";\n}) => {\n const resolvedSend = send ?? autoSend ?? false;\n\n const { disabled, trigger } = useSuggestionTriggerBehavior({\n prompt,\n send: resolvedSend,\n clearComposer,\n });\n if (disabled) return null;\n return trigger;\n};\n\nexport namespace ThreadPrimitiveSuggestion {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadSuggestion>;\n}\n\nexport const ThreadPrimitiveSuggestion = createActionButton(\n \"ThreadPrimitive.Suggestion\",\n useThreadSuggestion,\n [\"prompt\", \"send\", \"clearComposer\", \"autoSend\", \"method\"],\n);\n"],"mappings":";;;;;AASA,MAAMO,uBAAsBC,OAAA;CAAA,MAAAC,IAAAR,EAAA,CAAA;CAAC,MAAA,EAAAS,QAAAC,MAAAC,eAAAC,aAAAL;CAgC3B,MAAAM,eAAqBH,QAAAE,YAAA;CAA0B,IAAAE;CAAA,IAAAN,EAAA,OAAAG,iBAAAH,EAAA,OAAAC,UAAAD,EAAA,OAAAK,cAAA;EAEYC,KAAA;GAAAL;GAAAC,MAEnDG;GAAYF;EAEpB;EAACH,EAAA,KAAAG;EAAAH,EAAA,KAAAC;EAAAD,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAJD,MAAA,EAAAO,UAAAC,YAA8BX,qBAA6BS,EAI1D;CACD,IAAIC,UAAQ,OAAS;CAAK,OACnBC;AAAO;AAQhB,MAAaC,4BAA4Bd,mBACvC,8BACAG,qBACA;CAAC;CAAU;CAAQ;CAAiB;CAAY;AAAQ,CAC1D"}
|
|
1
|
+
{"version":3,"file":"ThreadSuggestion.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useSuggestionTrigger","useSuggestionTriggerBehavior","useThreadSuggestion","t0","$","prompt","send","clearComposer","autoSend","resolvedSend","t1","disabled","trigger","ThreadPrimitiveSuggestion","Element","Props","_c","useSuggestionTriggerBehavior"],"sources":["../../../src/primitives/thread/ThreadSuggestion.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useSuggestionTrigger as useSuggestionTriggerBehavior } from \"@assistant-ui/core/react\";\n\nconst useThreadSuggestion = ({\n prompt,\n send,\n clearComposer,\n autoSend,\n method: _method,\n}: {\n /** The suggestion prompt. */\n prompt: string;\n\n /**\n * When true, automatically sends the message.\n * When false, replaces or appends the composer text with the suggestion - depending on the value of `clearComposer`.\n */\n send?: boolean | undefined;\n\n /**\n * Whether to clear the composer after sending. A send queued while a run is\n * in progress never clears the composer.\n * When send is set to false, determines if composer text is replaced with suggestion (true, default),\n * or if it's appended to the composer text (false).\n *\n * @default true\n */\n clearComposer?: boolean | undefined;\n\n /** @deprecated Use `send` instead. */\n autoSend?: boolean | undefined;\n\n /** @deprecated Use `clearComposer` instead. */\n method?: \"replace\";\n}) => {\n const resolvedSend = send ?? autoSend ?? false;\n\n const { disabled, trigger } = useSuggestionTriggerBehavior({\n prompt,\n send: resolvedSend,\n clearComposer,\n });\n if (disabled) return null;\n return trigger;\n};\n\nexport namespace ThreadPrimitiveSuggestion {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadSuggestion>;\n}\n\nexport const ThreadPrimitiveSuggestion = createActionButton(\n \"ThreadPrimitive.Suggestion\",\n useThreadSuggestion,\n [\"prompt\", \"send\", \"clearComposer\", \"autoSend\", \"method\"],\n);\n"],"mappings":";;;;;AASA,MAAMO,uBAAsBC,OAAA;CAAA,MAAAC,IAAAR,EAAA,CAAA;CAAC,MAAA,EAAAS,QAAAC,MAAAC,eAAAC,aAAAL;CAgC3B,MAAAM,eAAqBH,QAAAE,YAAA;CAA0B,IAAAE;CAAA,IAAAN,EAAA,OAAAG,iBAAAH,EAAA,OAAAC,UAAAD,EAAA,OAAAK,cAAA;EAEYC,KAAA;GAAAL;GAAAC,MAEnDG;GAAYF;EAEpB;EAACH,EAAA,KAAAG;EAAAH,EAAA,KAAAC;EAAAD,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAJD,MAAA,EAAAO,UAAAC,YAA8BX,qBAA6BS,EAI1D;CACD,IAAIC,UAAQ,OAAS;CAAK,OACnBC;AAAO;AAQhB,MAAaC,4BAA4Bd,mBACvC,8BACAG,qBACA;CAAC;CAAU;CAAQ;CAAiB;CAAY;AAAQ,CAC1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadViewport.js","names":["c","_c","useComposedRefs","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useCallback","useLayoutEffect","useMemo","useAuiState","useManagedRef","useThreadViewportAutoScroll","ThreadPrimitiveViewportProvider","useSizeHandle","useThreadViewport","useThreadViewportStore","useTopAnchorReserve","getActiveTopAnchorAnchorId","getActiveTopAnchorTargetId","isTopAnchorTurnValid","ThreadPrimitiveViewport","Element","div","Props","autoScroll","turnAnchor","topAnchorMessageClamp","tallerThan","visibleHeight","scrollToBottomOnRunStart","scrollToBottomOnInitialize","scrollToBottomOnThreadSwitch","useViewportSizeRef","register","_temp","getHeight","_temp2","useViewportElementRef","registerViewportElement","_temp3","useTopAnchorTurn","enabled","$","threadViewportStore","t0","s","thread","activeAnchorId","t1","s_0","activeTargetId","topAnchorTurn","_temp4","t2","bb0","t3","anchorId","targetId","activeTurn","s_2","messages","topAnchorTurnIsValid","t4","t5","getState","setTopAnchorTurn","t6","t7","state","current","ThreadPrimitiveViewportScrollable","forwardedRef","children","rest","autoScrollRef","viewportSizeRef","viewportElementRef","topAnchorEnabled","ref","displayName","props","registerViewport","el","clientHeight","s_1"],"sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n useCallback,\n useLayoutEffect,\n useMemo,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useThreadViewportAutoScroll } from \"./useThreadViewportAutoScroll\";\nimport { ThreadPrimitiveViewportProvider } from \"../../context/providers/ThreadViewportProvider\";\nimport { useSizeHandle } from \"../../utils/hooks/useSizeHandle\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\nimport { useTopAnchorReserve } from \"./topAnchor/useTopAnchorReserve\";\nimport {\n getActiveTopAnchorAnchorId,\n getActiveTopAnchorTargetId,\n isTopAnchorTurnValid,\n} from \"./topAnchor/topAnchorTurn\";\n\nexport namespace ThreadPrimitiveViewport {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div> & {\n /**\n * Whether to automatically scroll to the bottom when new messages are added.\n * When enabled, the viewport will automatically scroll to show the latest content.\n *\n * Default false if `turnAnchor` is \"top\", otherwise defaults to true.\n */\n autoScroll?: boolean | undefined;\n\n /**\n * Controls scroll anchoring behavior for new messages.\n * - \"bottom\" (default): Messages anchor at the bottom, classic chat behavior.\n * - \"top\": New user messages anchor at the top of the viewport for a focused reading experience.\n */\n turnAnchor?: \"top\" | \"bottom\" | undefined;\n\n /**\n * Clamps tall user messages so the assistant response stays in view.\n *\n * @default { tallerThan: \"10em\", visibleHeight: \"6em\" }\n */\n topAnchorMessageClamp?: {\n /**\n * Clamp messages taller than this. Supports `px`, `em`, and `rem`.\n *\n * @default \"10em\"\n */\n tallerThan?: string;\n /**\n * Visible portion of clamped messages. Supports `px`, `em`, and `rem`.\n *\n * @default \"6em\"\n */\n visibleHeight?: string;\n };\n\n /**\n * Whether to scroll to bottom when a new run starts.\n *\n * Defaults to true.\n */\n scrollToBottomOnRunStart?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when thread history is first loaded.\n *\n * Defaults to true.\n */\n scrollToBottomOnInitialize?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when switching to a different thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n };\n}\n\nconst useViewportSizeRef = () => {\n const register = useThreadViewport((s) => s.registerViewport);\n const getHeight = useCallback((el: HTMLElement) => el.clientHeight, []);\n return useSizeHandle(register, getHeight);\n};\n\nconst useViewportElementRef = () => {\n const registerViewportElement = useThreadViewport(\n (s) => s.registerViewportElement,\n );\n\n return useManagedRef(registerViewportElement);\n};\n\nconst useTopAnchorTurn = (enabled: boolean) => {\n const threadViewportStore = useThreadViewportStore();\n const activeAnchorId = useAuiState((s) => {\n if (!enabled) return undefined;\n return getActiveTopAnchorAnchorId(s.thread);\n });\n const activeTargetId = useAuiState((s) => {\n if (!enabled) return undefined;\n return getActiveTopAnchorTargetId(s.thread);\n });\n const topAnchorTurn = useThreadViewport((s) => s.topAnchorTurn);\n const activeTurn = useMemo(() => {\n if (!activeAnchorId || !activeTargetId) return null;\n return { anchorId: activeAnchorId, targetId: activeTargetId };\n }, [activeAnchorId, activeTargetId]);\n\n const topAnchorTurnIsValid = useAuiState(\n (s) =>\n enabled &&\n !!topAnchorTurn &&\n isTopAnchorTurnValid(topAnchorTurn, s.thread.messages),\n );\n\n useLayoutEffect(() => {\n if (!topAnchorTurn || topAnchorTurnIsValid) return;\n\n threadViewportStore.getState().setTopAnchorTurn(null);\n }, [threadViewportStore, topAnchorTurn, topAnchorTurnIsValid]);\n\n useLayoutEffect(() => {\n if (!activeTurn) return;\n\n const state = threadViewportStore.getState();\n const current = state.topAnchorTurn;\n if (\n current?.anchorId === activeTurn.anchorId &&\n current.targetId === activeTurn.targetId\n ) {\n return;\n }\n\n state.setTopAnchorTurn(activeTurn);\n }, [activeTurn, threadViewportStore]);\n};\n\nconst ThreadPrimitiveViewportScrollable = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(\n (\n {\n autoScroll,\n scrollToBottomOnRunStart,\n scrollToBottomOnInitialize,\n scrollToBottomOnThreadSwitch,\n children,\n ...rest\n },\n forwardedRef,\n ) => {\n const autoScrollRef = useThreadViewportAutoScroll<HTMLDivElement>({\n autoScroll,\n scrollToBottomOnRunStart,\n scrollToBottomOnInitialize,\n scrollToBottomOnThreadSwitch,\n });\n const viewportSizeRef = useViewportSizeRef();\n const viewportElementRef = useViewportElementRef();\n const threadViewportStore = useThreadViewportStore();\n const turnAnchor = threadViewportStore.getState().turnAnchor;\n const topAnchorEnabled = turnAnchor === \"top\";\n useTopAnchorTurn(topAnchorEnabled);\n useTopAnchorReserve(topAnchorEnabled);\n const ref = useComposedRefs(\n forwardedRef,\n autoScrollRef,\n viewportSizeRef,\n viewportElementRef,\n );\n\n return (\n <Primitive.div {...rest} ref={ref}>\n {children}\n </Primitive.div>\n );\n },\n);\n\nThreadPrimitiveViewportScrollable.displayName =\n \"ThreadPrimitive.ViewportScrollable\";\n\n/**\n * A scrollable viewport container for thread messages.\n *\n * This component provides a scrollable area for displaying thread messages with\n * automatic scrolling capabilities. It manages the viewport state and provides\n * context for child components to access viewport-related functionality.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Viewport turnAnchor=\"top\">\n * <ThreadPrimitive.Messages>\n * {() => <MyMessage />}\n * </ThreadPrimitive.Messages>\n * </ThreadPrimitive.Viewport>\n * ```\n */\nexport const ThreadPrimitiveViewport = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(({ turnAnchor, topAnchorMessageClamp, ...props }, ref) => {\n return (\n <ThreadPrimitiveViewportProvider\n options={{ turnAnchor, topAnchorMessageClamp }}\n >\n <ThreadPrimitiveViewportScrollable {...props} ref={ref} />\n </ThreadPrimitiveViewportProvider>\n );\n});\n\nThreadPrimitiveViewport.displayName = \"ThreadPrimitive.Viewport\";\n"],"mappings":";;;;;;;;;;;;;;;AAyFA,MAAMiC,2BAAqB;CACzB,MAAAC,WAAiBnB,kBAAkBoB,KAAyB;CACY,OACjErB,cAAcoB,UAAUE,MAAS;AAAC;AAG3C,MAAME,8BAAwB;CAC5B,MAAAC,0BAAgCxB,kBAC9ByB,MACF;CAAE,OAEK7B,cAAc4B,uBAAuB;AAAC;AAG/C,MAAME,oBAAmBC,YAAA;CAAA,MAAAC,IAAA1C,EAAA,EAAA;CACvB,MAAA2C,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AAtIX,SAAA7C,MAAAW,GAAA;CAAA,OACiBA,EAACoC;AAAiB;AADnC,SAAA7C,OAAA8C,IAAA;CAAA,OAE0BA,GAAEC;AAAa;AAItC,SAAA5C,OAAAM,GAAA;CAAA,OAEnBA,EAACP;AAAwB;AAMX,SAAAc,OAAAgC,KAAA;CAAA,OAUwBvC,IAACM;AAAc"}
|
|
1
|
+
{"version":3,"file":"ThreadViewport.js","names":["c","_c","useComposedRefs","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useCallback","useLayoutEffect","useMemo","useAuiState","useManagedRef","useThreadViewportAutoScroll","ThreadPrimitiveViewportProvider","useSizeHandle","useThreadViewport","useThreadViewportStore","useTopAnchorReserve","getActiveTopAnchorAnchorId","getActiveTopAnchorTargetId","isTopAnchorTurnValid","ThreadPrimitiveViewport","Element","div","Props","autoScroll","turnAnchor","topAnchorMessageClamp","tallerThan","visibleHeight","scrollToBottomOnRunStart","scrollToBottomOnInitialize","scrollToBottomOnThreadSwitch","useViewportSizeRef","register","_temp","getHeight","_temp2","useViewportElementRef","registerViewportElement","_temp3","useTopAnchorTurn","enabled","$","threadViewportStore","t0","s","thread","activeAnchorId","t1","s_0","activeTargetId","topAnchorTurn","_temp4","t2","bb0","t3","anchorId","targetId","activeTurn","s_2","messages","topAnchorTurnIsValid","t4","t5","getState","setTopAnchorTurn","t6","t7","state","current","ThreadPrimitiveViewportScrollable","forwardedRef","children","rest","autoScrollRef","viewportSizeRef","viewportElementRef","topAnchorEnabled","ref","displayName","props","registerViewport","el","clientHeight","s_1","getHeight","_c","Primitive"],"sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n useCallback,\n useLayoutEffect,\n useMemo,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useThreadViewportAutoScroll } from \"./useThreadViewportAutoScroll\";\nimport { ThreadPrimitiveViewportProvider } from \"../../context/providers/ThreadViewportProvider\";\nimport { useSizeHandle } from \"../../utils/hooks/useSizeHandle\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\nimport { useTopAnchorReserve } from \"./topAnchor/useTopAnchorReserve\";\nimport {\n getActiveTopAnchorAnchorId,\n getActiveTopAnchorTargetId,\n isTopAnchorTurnValid,\n} from \"./topAnchor/topAnchorTurn\";\n\nexport namespace ThreadPrimitiveViewport {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div> & {\n /**\n * Whether to automatically scroll to the bottom when new messages are added.\n * When enabled, the viewport will automatically scroll to show the latest content.\n *\n * Default false if `turnAnchor` is \"top\", otherwise defaults to true.\n */\n autoScroll?: boolean | undefined;\n\n /**\n * Controls scroll anchoring behavior for new messages.\n * - \"bottom\" (default): Messages anchor at the bottom, classic chat behavior.\n * - \"top\": New user messages anchor at the top of the viewport for a focused reading experience.\n */\n turnAnchor?: \"top\" | \"bottom\" | undefined;\n\n /**\n * Clamps tall user messages so the assistant response stays in view.\n *\n * @default { tallerThan: \"10em\", visibleHeight: \"6em\" }\n */\n topAnchorMessageClamp?: {\n /**\n * Clamp messages taller than this. Supports `px`, `em`, and `rem`.\n *\n * @default \"10em\"\n */\n tallerThan?: string;\n /**\n * Visible portion of clamped messages. Supports `px`, `em`, and `rem`.\n *\n * @default \"6em\"\n */\n visibleHeight?: string;\n };\n\n /**\n * Whether to scroll to bottom when a new run starts.\n *\n * Defaults to true.\n */\n scrollToBottomOnRunStart?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when thread history is first loaded.\n *\n * Defaults to true.\n */\n scrollToBottomOnInitialize?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when switching to a different thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n };\n}\n\nconst useViewportSizeRef = () => {\n const register = useThreadViewport((s) => s.registerViewport);\n const getHeight = useCallback((el: HTMLElement) => el.clientHeight, []);\n return useSizeHandle(register, getHeight);\n};\n\nconst useViewportElementRef = () => {\n const registerViewportElement = useThreadViewport(\n (s) => s.registerViewportElement,\n );\n\n return useManagedRef(registerViewportElement);\n};\n\nconst useTopAnchorTurn = (enabled: boolean) => {\n const threadViewportStore = useThreadViewportStore();\n const activeAnchorId = useAuiState((s) => {\n if (!enabled) return undefined;\n return getActiveTopAnchorAnchorId(s.thread);\n });\n const activeTargetId = useAuiState((s) => {\n if (!enabled) return undefined;\n return getActiveTopAnchorTargetId(s.thread);\n });\n const topAnchorTurn = useThreadViewport((s) => s.topAnchorTurn);\n const activeTurn = useMemo(() => {\n if (!activeAnchorId || !activeTargetId) return null;\n return { anchorId: activeAnchorId, targetId: activeTargetId };\n }, [activeAnchorId, activeTargetId]);\n\n const topAnchorTurnIsValid = useAuiState(\n (s) =>\n enabled &&\n !!topAnchorTurn &&\n isTopAnchorTurnValid(topAnchorTurn, s.thread.messages),\n );\n\n useLayoutEffect(() => {\n if (!topAnchorTurn || topAnchorTurnIsValid) return;\n\n threadViewportStore.getState().setTopAnchorTurn(null);\n }, [threadViewportStore, topAnchorTurn, topAnchorTurnIsValid]);\n\n useLayoutEffect(() => {\n if (!activeTurn) return;\n\n const state = threadViewportStore.getState();\n const current = state.topAnchorTurn;\n if (\n current?.anchorId === activeTurn.anchorId &&\n current.targetId === activeTurn.targetId\n ) {\n return;\n }\n\n state.setTopAnchorTurn(activeTurn);\n }, [activeTurn, threadViewportStore]);\n};\n\nconst ThreadPrimitiveViewportScrollable = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(\n (\n {\n autoScroll,\n scrollToBottomOnRunStart,\n scrollToBottomOnInitialize,\n scrollToBottomOnThreadSwitch,\n children,\n ...rest\n },\n forwardedRef,\n ) => {\n const autoScrollRef = useThreadViewportAutoScroll<HTMLDivElement>({\n autoScroll,\n scrollToBottomOnRunStart,\n scrollToBottomOnInitialize,\n scrollToBottomOnThreadSwitch,\n });\n const viewportSizeRef = useViewportSizeRef();\n const viewportElementRef = useViewportElementRef();\n const threadViewportStore = useThreadViewportStore();\n const turnAnchor = threadViewportStore.getState().turnAnchor;\n const topAnchorEnabled = turnAnchor === \"top\";\n useTopAnchorTurn(topAnchorEnabled);\n useTopAnchorReserve(topAnchorEnabled);\n const ref = useComposedRefs(\n forwardedRef,\n autoScrollRef,\n viewportSizeRef,\n viewportElementRef,\n );\n\n return (\n <Primitive.div {...rest} ref={ref}>\n {children}\n </Primitive.div>\n );\n },\n);\n\nThreadPrimitiveViewportScrollable.displayName =\n \"ThreadPrimitive.ViewportScrollable\";\n\n/**\n * A scrollable viewport container for thread messages.\n *\n * This component provides a scrollable area for displaying thread messages with\n * automatic scrolling capabilities. It manages the viewport state and provides\n * context for child components to access viewport-related functionality.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Viewport turnAnchor=\"top\">\n * <ThreadPrimitive.Messages>\n * {() => <MyMessage />}\n * </ThreadPrimitive.Messages>\n * </ThreadPrimitive.Viewport>\n * ```\n */\nexport const ThreadPrimitiveViewport = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(({ turnAnchor, topAnchorMessageClamp, ...props }, ref) => {\n return (\n <ThreadPrimitiveViewportProvider\n options={{ turnAnchor, topAnchorMessageClamp }}\n >\n <ThreadPrimitiveViewportScrollable {...props} ref={ref} />\n </ThreadPrimitiveViewportProvider>\n );\n});\n\nThreadPrimitiveViewport.displayName = \"ThreadPrimitive.Viewport\";\n"],"mappings":";;;;;;;;;;;;;;;AAyFA,MAAMiC,2BAAqB;CACzB,MAAAC,WAAiBnB,kBAAkBoB,KAAyB;CACY,OACjErB,cAAcoB,UAAUE,MAAS;AAAC;AAG3C,MAAME,8BAAwB;CAC5B,MAAAC,0BAAgCxB,kBAC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