@assistant-ui/react 0.15.23 → 0.15.24
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.js.map +1 -1
- 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.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.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +3 -2
- 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.js.map +1 -1
- 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.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.js.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.js.map +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/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/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/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.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/package.json +11 -11
- package/src/primitives/composer/ComposerInput.test.tsx +33 -1
- package/src/primitives/composer/ComposerInput.tsx +3 -2
- package/src/primitives/message/MessagePartsGrouped.test.tsx +271 -1
- package/src/primitives/message/MessagePartsGrouped.tsx +14 -6
- package/src/primitives/thread/ThreadRoot.test.tsx +33 -0
- package/src/primitives/thread/ThreadRoot.tsx +3 -0
- package/src/utils/isCompositionKey.ts +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessagePartsGrouped.js","names":["c","_c","ComponentType","FC","memo","PropsWithChildren","useMemo","useAuiState","useAui","PartByIndexProvider","TextMessagePartProvider","MessagePartPrimitiveText","MessagePartPrimitiveImage","Unstable_AudioMessagePartComponent","DataMessagePartComponent","DataMessagePartProps","EmptyMessagePartComponent","TextMessagePartComponent","ImageMessagePartComponent","SourceMessagePartComponent","ToolCallMessagePartComponent","ToolCallMessagePartProps","FileMessagePartComponent","ReasoningMessagePartComponent","MessagePartPrimitiveInProgress","MessagePartStatus","MessagePartGroup","groupKey","indices","GroupingFunction","parts","groupMessagePartsByParentId","groupMap","Map","i","length","part","parentId","groupId","get","push","set","groups","undefined","useMessagePartsGrouped","groupingFunction","$","_temp","t0","bb0","t1","Symbol","for","MessagePrimitiveUnstable_PartsGrouped","Props","components","Empty","Text","Reasoning","Source","Image","File","Unstable_Audio","data","by_name","Record","Fallback","tools","Override","Group","ToolUIDisplay","props","toolName","s","toolUIs","render","Render","t2","DataUIDisplay","name","named","dataRenderers","renderers","fallbacks","defaultComponents","whiteSpace","fontFamily","children","MessagePartComponentProps","MessagePartComponent","t3","t4","t5","t6","t7","t8","t9","Audio","t10","aui","_temp2","type","addResult","addToolResult","resume","resumeToolCall","respondToApproval","respondToToolApproval","unstable_recordInteraction","t11","t12","Object","hasOwn","Tool","t13","status","Error","Data","console","warn","MessagePartProps","partIndex","MessagePartImpl","MessagePart","prev","next","EmptyPartFallback","component","Component","COMPLETE_STATUS","freeze","EmptyPartsImpl","_temp3","EmptyParts","contentLength","_temp4","messageGroups","group","groupIndex","GroupComponent","map","partsElements","displayName","MessagePrimitiveUnstable_PartsGroupedByParentId","Omit","message"],"sources":["../../../src/primitives/message/MessagePartsGrouped.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentType,\n type FC,\n memo,\n type PropsWithChildren,\n useMemo,\n} from \"react\";\nimport { useAuiState, useAui } from \"@assistant-ui/store\";\nimport { PartByIndexProvider } from \"../../context/providers/PartByIndexProvider\";\nimport { TextMessagePartProvider } from \"../../context/providers/TextMessagePartProvider\";\nimport { MessagePartPrimitiveText } from \"../messagePart/MessagePartText\";\nimport { MessagePartPrimitiveImage } from \"../messagePart/MessagePartImage\";\nimport type {\n Unstable_AudioMessagePartComponent,\n DataMessagePartComponent,\n DataMessagePartProps,\n EmptyMessagePartComponent,\n TextMessagePartComponent,\n ImageMessagePartComponent,\n SourceMessagePartComponent,\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n FileMessagePartComponent,\n ReasoningMessagePartComponent,\n} from \"@assistant-ui/core/react\";\nimport { MessagePartPrimitiveInProgress } from \"../messagePart/MessagePartInProgress\";\nimport type { MessagePartStatus } from \"@assistant-ui/core\";\n\ntype MessagePartGroup = {\n groupKey: string | undefined;\n indices: number[];\n};\n\nexport type GroupingFunction = (parts: readonly any[]) => MessagePartGroup[];\n\n/**\n * Groups message parts by their parent ID.\n * Parts without a parent ID appear in their chronological position as individual groups.\n * Parts with the same parent ID are grouped together at the position of their first occurrence.\n */\nconst groupMessagePartsByParentId: GroupingFunction = (\n parts: readonly any[],\n): MessagePartGroup[] => {\n // Map maintains insertion order, so groups appear in order of first occurrence\n const groupMap = new Map<string | number, number[]>();\n\n // Process each part in order\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n const parentId = part?.parentId as string | undefined;\n\n // For parts without parentId, assign a unique group ID to maintain their position\n const groupId = parentId ?? i;\n\n // Get or create the indices array for this group\n const indices = groupMap.get(groupId) ?? [];\n indices.push(i);\n groupMap.set(groupId, indices);\n }\n\n // Convert map to array of groups\n const groups: MessagePartGroup[] = [];\n for (const [groupId, indices] of groupMap) {\n // Extract parentId (undefined for ungrouped parts)\n const groupKey = typeof groupId === \"string\" ? groupId : undefined;\n groups.push({ groupKey, indices });\n }\n\n return groups;\n};\n\nconst useMessagePartsGrouped = (\n groupingFunction: GroupingFunction,\n): MessagePartGroup[] => {\n const parts = useAuiState((s) => s.message.parts);\n\n return useMemo(() => {\n if (parts.length === 0) {\n return [];\n }\n return groupingFunction(parts);\n }, [parts, groupingFunction]);\n};\n\nexport namespace MessagePrimitiveUnstable_PartsGrouped {\n export type Props = {\n /**\n * Function that takes an array of message parts and returns an array of groups.\n * Each group contains a key (for identification) and an array of indices.\n *\n * @example\n * ```tsx\n * // Group by parent ID (default behavior)\n * groupingFunction={(parts) => {\n * const groups = new Map<string | number, number[]>();\n * parts.forEach((part, i) => {\n * const key = part.parentId ?? i;\n * const indices = groups.get(key) ?? [];\n * indices.push(i);\n * groups.set(key, indices);\n * });\n * return Array.from(groups.entries()).map(([key, indices]) => ({\n * groupKey: typeof key === \"string\" ? key : undefined,\n * indices\n * }));\n * }}\n * ```\n *\n * @example\n * ```tsx\n * // Group by tool name\n * import { groupMessagePartsByToolName } from \"@assistant-ui/react\";\n *\n * <MessagePrimitive.Unstable_PartsGrouped\n * groupingFunction={groupMessagePartsByToolName}\n * components={{\n * Group: ({ key, indices, children }) => {\n * if (!key) return <>{children}</>;\n * return (\n * <div className=\"tool-group\">\n * <h4>Tool: {key}</h4>\n * {children}\n * </div>\n * );\n * }\n * }}\n * />\n * ```\n */\n groupingFunction: GroupingFunction;\n\n /**\n * Component configuration for rendering different types of message content.\n *\n * You can provide custom components for each content type (text, image, file, etc.)\n * and configure tool rendering behavior. If not provided, default components will be used.\n */\n components:\n | {\n /** Component for rendering empty messages */\n Empty?: EmptyMessagePartComponent | undefined;\n /** Component for rendering text content */\n Text?: TextMessagePartComponent | undefined;\n /** Component for rendering reasoning content (typically hidden) */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Component for rendering source content */\n Source?: SourceMessagePartComponent | undefined;\n /** Component for rendering image content */\n Image?: ImageMessagePartComponent | undefined;\n /** Component for rendering file content */\n File?: FileMessagePartComponent | undefined;\n /**\n * Component for rendering audio content.\n *\n * @deprecated Render audio through the `File` slot instead, branching\n * on an `audio/*` mime type.\n */\n Unstable_Audio?: Unstable_AudioMessagePartComponent | undefined;\n /** Configuration for data part rendering */\n data?:\n | {\n /** Map data event names to specific components */\n by_name?:\n | Record<string, DataMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unmatched data events */\n Fallback?: DataMessagePartComponent | undefined;\n }\n | undefined;\n /** Configuration for tool call rendering */\n tools?:\n | {\n /** Map of tool names to their specific components */\n by_name?:\n | Record<string, ToolCallMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unregistered tools */\n Fallback?: ComponentType<ToolCallMessagePartProps> | undefined;\n }\n | {\n /** Override component that handles all tool calls */\n Override: ComponentType<ToolCallMessagePartProps>;\n }\n | undefined;\n\n /**\n * Component for rendering grouped message parts.\n *\n * When provided, this component will automatically wrap message parts that share\n * the same group key as determined by the groupingFunction.\n *\n * The component receives:\n * - `groupKey`: The group key (or undefined for ungrouped parts)\n * - `indices`: Array of indices for the parts in this group\n * - `children`: The rendered message part components\n *\n * @example\n * ```tsx\n * // Collapsible group\n * Group: ({ groupKey, indices, children }) => {\n * if (!groupKey) return <>{children}</>;\n * return (\n * <details className=\"message-group\">\n * <summary>\n * Group {groupKey} ({indices.length} parts)\n * </summary>\n * <div className=\"group-content\">\n * {children}\n * </div>\n * </details>\n * );\n * }\n * ```\n *\n * @param groupKey - The group key (undefined for ungrouped parts)\n * @param indices - Array of indices for the parts in this group\n * @param children - Rendered message part components to display within the group\n */\n Group?: ComponentType<\n PropsWithChildren<{\n groupKey: string | undefined;\n indices: number[];\n }>\n >;\n }\n | undefined;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallMessagePartComponent | undefined;\n} & ToolCallMessagePartProps) => {\n const Render = useAuiState(\n (s) => s.tools.toolUIs[props.toolName]?.[0]?.render ?? Fallback,\n );\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst DataUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: DataMessagePartComponent | undefined;\n} & DataMessagePartProps) => {\n const Render = useAuiState((s) => {\n const named = s.dataRenderers.renderers[props.name]?.[0];\n if (named) return named;\n return s.dataRenderers.fallbacks[0] ?? Fallback;\n });\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <MessagePartPrimitiveText />\n <MessagePartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </MessagePartPrimitiveInProgress>\n </p>\n ),\n Reasoning: () => null,\n Source: () => null,\n Image: () => <MessagePartPrimitiveImage />,\n File: () => null,\n Unstable_Audio: () => null,\n Group: ({ children }) => children,\n} satisfies MessagePrimitiveUnstable_PartsGrouped.Props[\"components\"];\n\ntype MessagePartComponentProps = {\n components: MessagePrimitiveUnstable_PartsGrouped.Props[\"components\"];\n};\n\nconst MessagePartComponent: FC<MessagePartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n Source = defaultComponents.Source,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n tools = {},\n data,\n } = {},\n}) => {\n const aui = useAui();\n const part = useAuiState((s) => s.part);\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = aui.part.addToolResult;\n const resume = aui.part.resumeToolCall;\n const respondToApproval = aui.part.respondToToolApproval;\n const unstable_recordInteraction = aui.part.unstable_recordInteraction;\n if (\"Override\" in tools)\n return (\n <tools.Override\n {...part}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n {...(unstable_recordInteraction && { unstable_recordInteraction })}\n />\n );\n const Tool =\n (tools.by_name && Object.hasOwn(tools.by_name, part.toolName)\n ? tools.by_name[part.toolName]\n : undefined) ?? tools.Fallback;\n return (\n <ToolUIDisplay\n {...part}\n Fallback={Tool}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n {...(unstable_recordInteraction && { unstable_recordInteraction })}\n />\n );\n }\n\n if (part.status?.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"source\":\n return <Source {...part} />;\n\n case \"image\":\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"data\": {\n const Data =\n (data?.by_name && Object.hasOwn(data.by_name, part.name)\n ? data.by_name[part.name]\n : undefined) ?? data?.Fallback;\n return <DataUIDisplay {...part} Fallback={Data} />;\n }\n\n default:\n console.warn(`Unknown message part type: ${type}`);\n return null;\n }\n};\n\ntype MessagePartProps = {\n partIndex: number;\n components: MessagePrimitiveUnstable_PartsGrouped.Props[\"components\"];\n};\n\nconst MessagePartImpl: FC<MessagePartProps> = ({ partIndex, components }) => {\n return (\n <PartByIndexProvider index={partIndex}>\n <MessagePartComponent components={components} />\n </PartByIndexProvider>\n );\n};\n\nconst MessagePart = memo(\n MessagePartImpl,\n (prev, next) =>\n prev.partIndex === next.partIndex &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Source === next.components?.Source &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.tools === next.components?.tools &&\n prev.components?.data === next.components?.data &&\n prev.components?.Group === next.components?.Group,\n);\n\nconst EmptyPartFallback: FC<{\n status: MessagePartStatus;\n component: TextMessagePartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextMessagePartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextMessagePartProvider>\n );\n};\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst EmptyPartsImpl: FC<MessagePartComponentProps> = ({ components }) => {\n const status = useAuiState(\n (s) => (s.message.status ?? COMPLETE_STATUS) as MessagePartStatus,\n );\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n return (\n <EmptyPartFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyParts = memo(\n EmptyPartsImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\n/**\n * Renders the parts of a message grouped by a custom grouping function.\n *\n * This component allows you to group message parts based on any criteria you define.\n * The grouping function receives all message parts and returns an array of groups,\n * where each group has a key and an array of part indices.\n *\n * @deprecated Prefer `<MessagePrimitive.GroupedParts>` for adjacent\n * grouping — it dispatches all rendering through one `switch (part.type)`\n * and supports nested group paths. Keep this primitive only for\n * non-adjacent clustering (e.g., gathering parts with the same parent-id\n * across the message).\n *\n * @example\n * ```tsx\n * // Group by parent ID (default behavior)\n * <MessagePrimitive.Unstable_PartsGrouped\n * components={{\n * Text: ({ text }) => <p className=\"message-text\">{text}</p>,\n * Image: ({ image }) => <img src={image} alt=\"Message image\" />,\n * Group: ({ groupKey, indices, children }) => {\n * if (!groupKey) return <>{children}</>;\n * return (\n * <div className=\"parent-group border rounded p-4\">\n * <h4>Parent ID: {groupKey}</h4>\n * {children}\n * </div>\n * );\n * }\n * }}\n * />\n * ```\n */\nexport const MessagePrimitiveUnstable_PartsGrouped: FC<\n MessagePrimitiveUnstable_PartsGrouped.Props\n> = ({ groupingFunction, components }) => {\n const contentLength = useAuiState((s) => s.message.parts.length);\n const messageGroups = useMessagePartsGrouped(groupingFunction);\n\n const partsElements = useMemo(() => {\n if (contentLength === 0) {\n return <EmptyParts components={components} />;\n }\n\n return messageGroups.map((group, groupIndex) => {\n const GroupComponent = components?.Group ?? defaultComponents.Group;\n\n return (\n <GroupComponent\n key={`group-${groupIndex}-${group.groupKey ?? \"ungrouped\"}`}\n groupKey={group.groupKey}\n indices={group.indices}\n >\n {group.indices.map((partIndex) => (\n <MessagePart\n key={partIndex}\n partIndex={partIndex}\n components={components}\n />\n ))}\n </GroupComponent>\n );\n });\n }, [messageGroups, components, contentLength]);\n\n return <>{partsElements}</>;\n};\n\nMessagePrimitiveUnstable_PartsGrouped.displayName =\n \"MessagePrimitive.Unstable_PartsGrouped\";\n\n/**\n * Renders the parts of a message grouped by their parent ID.\n * This is a convenience wrapper around Unstable_PartsGrouped with parent ID grouping.\n *\n * @deprecated Use MessagePrimitive.Unstable_PartsGrouped instead for more flexibility\n */\nexport const MessagePrimitiveUnstable_PartsGroupedByParentId: FC<\n Omit<MessagePrimitiveUnstable_PartsGrouped.Props, \"groupingFunction\">\n> = ({ components, ...props }) => {\n return (\n <MessagePrimitiveUnstable_PartsGrouped\n {...props}\n components={components}\n groupingFunction={groupMessagePartsByParentId}\n />\n );\n};\n\nMessagePrimitiveUnstable_PartsGroupedByParentId.displayName =\n \"MessagePrimitive.Unstable_PartsGroupedByParentId\";\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,MAAM+B,+BACJD,UACuB;CAEvB,MAAME,2BAAW,IAAIC,IAA+B;CAGpD,KAAK,IAAIC,IAAI,GAAGA,IAAIJ,MAAMK,QAAQD,KAAK;EAKrC,MAAMI,UAJOR,MAAMI,EACE,EAAEG,YAGKH;EAG5B,MAAMN,UAAUI,SAASO,IAAID,OAA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AG7BxB,sCAAsCyF,cACpC;;;;;;;AAQF,MAAaC,mDAET/F,OAAA;CAAA,MAAAF,IAAA7C,EAAA,CAAA;CAAA,IAAAsD;CAAA,IAAAgB;CAAA,IAAAzB,EAAA,OAAAE,IAAA;EAAC,CAAA,CAAAO,YAAA,GAAAgB,SAAAvB;EAAwBF,EAAA,KAAAE;EAAAF,EAAA,KAAAS;EAAAT,EAAA,KAAAyB;CAAA,OAAA;EAAAhB,aAAAT,EAAA;EAAAyB,QAAAzB,EAAA;CAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAS,cAAAT,EAAA,OAAAyB,OAAA;EAEzBrB,KAAA,oBAAC,uCAAD;GAAsC,GAChCqB;GACQhB;GACMxB,kBAAAA;EAA2B,CAAA;EAC7Ce,EAAA,KAAAS;EAAAT,EAAA,KAAAyB;EAAAzB,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OAJFI;AAIE;AAIN6F,gDAAgDD,cAC9C;AA7b6B,SAAA/F,MAAA0B,GAAA;CAAA,OAGIA,EAACwE,QAAQnH;AAAM;AA4MU,SAAAsE,OAAA3B,GAAA;CAAA,OAa1BA,EAACrC;AAAK;AAiHc,SAAAgG,OAAA3D,GAAA;CAAA,OAE1CA,EAACwE,QAAQ9B,UAATc;AAAyD;AAuDjE,SAAAM,OAAA9D,GAAA;CAAA,OACuCA,EAACwE,QAAQnH,MAAMK;AAAO"}
|
|
1
|
+
{"version":3,"file":"MessagePartsGrouped.js","names":["c","_c","ComponentType","FC","memo","PropsWithChildren","useMemo","useAuiState","useAui","PartByIndexProvider","TextMessagePartProvider","MessagePartPrimitiveText","MessagePartPrimitiveImage","Unstable_AudioMessagePartComponent","DataMessagePartComponent","DataMessagePartProps","EmptyMessagePartComponent","TextMessagePartComponent","ImageMessagePartComponent","SourceMessagePartComponent","ToolCallMessagePartComponent","ToolCallMessagePartProps","FileMessagePartComponent","ReasoningMessagePartComponent","MessagePartPrimitiveInProgress","MessagePartStatus","getMessagePartKeys","MessagePartGroup","groupKey","indices","GroupingFunction","parts","groupMessagePartsByParentId","groupMap","Map","i","length","part","parentId","groupId","get","push","set","groups","undefined","useMessagePartsGrouped","groupingFunction","$","_temp","t0","bb0","t1","Symbol","for","t2","partKeys","MessagePrimitiveUnstable_PartsGrouped","Props","components","Empty","Text","Reasoning","Source","Image","File","Unstable_Audio","data","by_name","Record","Fallback","tools","Override","Group","ToolUIDisplay","props","toolName","s","toolUIs","render","Render","DataUIDisplay","name","named","dataRenderers","renderers","fallbacks","defaultComponents","whiteSpace","fontFamily","children","MessagePartComponentProps","MessagePartComponent","t3","t4","t5","t6","t7","t8","t9","Audio","t10","aui","_temp2","type","addResult","addToolResult","resume","resumeToolCall","respondToApproval","respondToToolApproval","unstable_recordInteraction","t11","t12","Object","hasOwn","Tool","t13","status","Error","Data","console","warn","MessagePartProps","partIndex","MessagePartImpl","MessagePart","prev","next","EmptyPartFallback","component","Component","COMPLETE_STATUS","freeze","EmptyPartsImpl","_temp3","EmptyParts","contentLength","_temp4","messageGroups","group","groupIndex","GroupComponent","identity","JSON","stringify","includes","map","partsElements","displayName","MessagePrimitiveUnstable_PartsGroupedByParentId","Omit","message","_c"],"sources":["../../../src/primitives/message/MessagePartsGrouped.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentType,\n type FC,\n memo,\n type PropsWithChildren,\n useMemo,\n} from \"react\";\nimport { useAuiState, useAui } from \"@assistant-ui/store\";\nimport { PartByIndexProvider } from \"../../context/providers/PartByIndexProvider\";\nimport { TextMessagePartProvider } from \"../../context/providers/TextMessagePartProvider\";\nimport { MessagePartPrimitiveText } from \"../messagePart/MessagePartText\";\nimport { MessagePartPrimitiveImage } from \"../messagePart/MessagePartImage\";\nimport type {\n Unstable_AudioMessagePartComponent,\n DataMessagePartComponent,\n DataMessagePartProps,\n EmptyMessagePartComponent,\n TextMessagePartComponent,\n ImageMessagePartComponent,\n SourceMessagePartComponent,\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n FileMessagePartComponent,\n ReasoningMessagePartComponent,\n} from \"@assistant-ui/core/react\";\nimport { MessagePartPrimitiveInProgress } from \"../messagePart/MessagePartInProgress\";\nimport type { MessagePartStatus } from \"@assistant-ui/core\";\nimport { getMessagePartKeys } from \"@assistant-ui/core/internal\";\n\ntype MessagePartGroup = {\n groupKey: string | undefined;\n indices: number[];\n};\n\nexport type GroupingFunction = (parts: readonly any[]) => MessagePartGroup[];\n\n/**\n * Groups message parts by their parent ID.\n * Parts without a parent ID appear in their chronological position as individual groups.\n * Parts with the same parent ID are grouped together at the position of their first occurrence.\n */\nconst groupMessagePartsByParentId: GroupingFunction = (\n parts: readonly any[],\n): MessagePartGroup[] => {\n // Map maintains insertion order, so groups appear in order of first occurrence\n const groupMap = new Map<string | number, number[]>();\n\n // Process each part in order\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n const parentId = part?.parentId as string | undefined;\n\n // For parts without parentId, assign a unique group ID to maintain their position\n const groupId = parentId ?? i;\n\n // Get or create the indices array for this group\n const indices = groupMap.get(groupId) ?? [];\n indices.push(i);\n groupMap.set(groupId, indices);\n }\n\n // Convert map to array of groups\n const groups: MessagePartGroup[] = [];\n for (const [groupId, indices] of groupMap) {\n // Extract parentId (undefined for ungrouped parts)\n const groupKey = typeof groupId === \"string\" ? groupId : undefined;\n groups.push({ groupKey, indices });\n }\n\n return groups;\n};\n\nconst useMessagePartsGrouped = (\n groupingFunction: GroupingFunction,\n): { groups: MessagePartGroup[]; partKeys: string[] } => {\n const parts = useAuiState((s) => s.message.parts);\n\n const groups = useMemo(() => {\n if (parts.length === 0) {\n return [];\n }\n return groupingFunction(parts);\n }, [parts, groupingFunction]);\n return { groups, partKeys: getMessagePartKeys(parts) };\n};\n\nexport namespace MessagePrimitiveUnstable_PartsGrouped {\n export type Props = {\n /**\n * Function that takes an array of message parts and returns an array of groups.\n * Each group contains a key (for identification) and an array of indices.\n *\n * @example\n * ```tsx\n * // Group by parent ID (default behavior)\n * groupingFunction={(parts) => {\n * const groups = new Map<string | number, number[]>();\n * parts.forEach((part, i) => {\n * const key = part.parentId ?? i;\n * const indices = groups.get(key) ?? [];\n * indices.push(i);\n * groups.set(key, indices);\n * });\n * return Array.from(groups.entries()).map(([key, indices]) => ({\n * groupKey: typeof key === \"string\" ? key : undefined,\n * indices\n * }));\n * }}\n * ```\n *\n * @example\n * ```tsx\n * // Group by tool name\n * import { groupMessagePartsByToolName } from \"@assistant-ui/react\";\n *\n * <MessagePrimitive.Unstable_PartsGrouped\n * groupingFunction={groupMessagePartsByToolName}\n * components={{\n * Group: ({ key, indices, children }) => {\n * if (!key) return <>{children}</>;\n * return (\n * <div className=\"tool-group\">\n * <h4>Tool: {key}</h4>\n * {children}\n * </div>\n * );\n * }\n * }}\n * />\n * ```\n */\n groupingFunction: GroupingFunction;\n\n /**\n * Component configuration for rendering different types of message content.\n *\n * You can provide custom components for each content type (text, image, file, etc.)\n * and configure tool rendering behavior. If not provided, default components will be used.\n */\n components:\n | {\n /** Component for rendering empty messages */\n Empty?: EmptyMessagePartComponent | undefined;\n /** Component for rendering text content */\n Text?: TextMessagePartComponent | undefined;\n /** Component for rendering reasoning content (typically hidden) */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Component for rendering source content */\n Source?: SourceMessagePartComponent | undefined;\n /** Component for rendering image content */\n Image?: ImageMessagePartComponent | undefined;\n /** Component for rendering file content */\n File?: FileMessagePartComponent | undefined;\n /**\n * Component for rendering audio content.\n *\n * @deprecated Render audio through the `File` slot instead, branching\n * on an `audio/*` mime type.\n */\n Unstable_Audio?: Unstable_AudioMessagePartComponent | undefined;\n /** Configuration for data part rendering */\n data?:\n | {\n /** Map data event names to specific components */\n by_name?:\n | Record<string, DataMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unmatched data events */\n Fallback?: DataMessagePartComponent | undefined;\n }\n | undefined;\n /** Configuration for tool call rendering */\n tools?:\n | {\n /** Map of tool names to their specific components */\n by_name?:\n | Record<string, ToolCallMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unregistered tools */\n Fallback?: ComponentType<ToolCallMessagePartProps> | undefined;\n }\n | {\n /** Override component that handles all tool calls */\n Override: ComponentType<ToolCallMessagePartProps>;\n }\n | undefined;\n\n /**\n * Component for rendering grouped message parts.\n *\n * When provided, this component will automatically wrap message parts that share\n * the same group key as determined by the groupingFunction.\n *\n * The component receives:\n * - `groupKey`: The group key (or undefined for ungrouped parts)\n * - `indices`: Array of indices for the parts in this group\n * - `children`: The rendered message part components\n *\n * @example\n * ```tsx\n * // Collapsible group\n * Group: ({ groupKey, indices, children }) => {\n * if (!groupKey) return <>{children}</>;\n * return (\n * <details className=\"message-group\">\n * <summary>\n * Group {groupKey} ({indices.length} parts)\n * </summary>\n * <div className=\"group-content\">\n * {children}\n * </div>\n * </details>\n * );\n * }\n * ```\n *\n * @param groupKey - The group key (undefined for ungrouped parts)\n * @param indices - Array of indices for the parts in this group\n * @param children - Rendered message part components to display within the group\n */\n Group?: ComponentType<\n PropsWithChildren<{\n groupKey: string | undefined;\n indices: number[];\n }>\n >;\n }\n | undefined;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallMessagePartComponent | undefined;\n} & ToolCallMessagePartProps) => {\n const Render = useAuiState(\n (s) => s.tools.toolUIs[props.toolName]?.[0]?.render ?? Fallback,\n );\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst DataUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: DataMessagePartComponent | undefined;\n} & DataMessagePartProps) => {\n const Render = useAuiState((s) => {\n const named = s.dataRenderers.renderers[props.name]?.[0];\n if (named) return named;\n return s.dataRenderers.fallbacks[0] ?? Fallback;\n });\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <MessagePartPrimitiveText />\n <MessagePartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </MessagePartPrimitiveInProgress>\n </p>\n ),\n Reasoning: () => null,\n Source: () => null,\n Image: () => <MessagePartPrimitiveImage />,\n File: () => null,\n Unstable_Audio: () => null,\n Group: ({ children }) => children,\n} satisfies MessagePrimitiveUnstable_PartsGrouped.Props[\"components\"];\n\ntype MessagePartComponentProps = {\n components: MessagePrimitiveUnstable_PartsGrouped.Props[\"components\"];\n};\n\nconst MessagePartComponent: FC<MessagePartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n Source = defaultComponents.Source,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n tools = {},\n data,\n } = {},\n}) => {\n const aui = useAui();\n const part = useAuiState((s) => s.part);\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = aui.part.addToolResult;\n const resume = aui.part.resumeToolCall;\n const respondToApproval = aui.part.respondToToolApproval;\n const unstable_recordInteraction = aui.part.unstable_recordInteraction;\n if (\"Override\" in tools)\n return (\n <tools.Override\n {...part}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n {...(unstable_recordInteraction && { unstable_recordInteraction })}\n />\n );\n const Tool =\n (tools.by_name && Object.hasOwn(tools.by_name, part.toolName)\n ? tools.by_name[part.toolName]\n : undefined) ?? tools.Fallback;\n return (\n <ToolUIDisplay\n {...part}\n Fallback={Tool}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n {...(unstable_recordInteraction && { unstable_recordInteraction })}\n />\n );\n }\n\n if (part.status?.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"source\":\n return <Source {...part} />;\n\n case \"image\":\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"data\": {\n const Data =\n (data?.by_name && Object.hasOwn(data.by_name, part.name)\n ? data.by_name[part.name]\n : undefined) ?? data?.Fallback;\n return <DataUIDisplay {...part} Fallback={Data} />;\n }\n\n default:\n console.warn(`Unknown message part type: ${type}`);\n return null;\n }\n};\n\ntype MessagePartProps = {\n partIndex: number;\n components: MessagePrimitiveUnstable_PartsGrouped.Props[\"components\"];\n};\n\nconst MessagePartImpl: FC<MessagePartProps> = ({ partIndex, components }) => {\n return (\n <PartByIndexProvider index={partIndex}>\n <MessagePartComponent components={components} />\n </PartByIndexProvider>\n );\n};\n\nconst MessagePart = memo(\n MessagePartImpl,\n (prev, next) =>\n prev.partIndex === next.partIndex &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Source === next.components?.Source &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.tools === next.components?.tools &&\n prev.components?.data === next.components?.data &&\n prev.components?.Group === next.components?.Group,\n);\n\nconst EmptyPartFallback: FC<{\n status: MessagePartStatus;\n component: TextMessagePartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextMessagePartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextMessagePartProvider>\n );\n};\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst EmptyPartsImpl: FC<MessagePartComponentProps> = ({ components }) => {\n const status = useAuiState(\n (s) => (s.message.status ?? COMPLETE_STATUS) as MessagePartStatus,\n );\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n return (\n <EmptyPartFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyParts = memo(\n EmptyPartsImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\n/**\n * Renders the parts of a message grouped by a custom grouping function.\n *\n * This component allows you to group message parts based on any criteria you define.\n * The grouping function receives all message parts and returns an array of groups,\n * where each group has a key and an array of part indices.\n *\n * @deprecated Prefer `<MessagePrimitive.GroupedParts>` for adjacent\n * grouping — it dispatches all rendering through one `switch (part.type)`\n * and supports nested group paths. Keep this primitive only for\n * non-adjacent clustering (e.g., gathering parts with the same parent-id\n * across the message).\n *\n * @example\n * ```tsx\n * // Group by parent ID (default behavior)\n * <MessagePrimitive.Unstable_PartsGrouped\n * components={{\n * Text: ({ text }) => <p className=\"message-text\">{text}</p>,\n * Image: ({ image }) => <img src={image} alt=\"Message image\" />,\n * Group: ({ groupKey, indices, children }) => {\n * if (!groupKey) return <>{children}</>;\n * return (\n * <div className=\"parent-group border rounded p-4\">\n * <h4>Parent ID: {groupKey}</h4>\n * {children}\n * </div>\n * );\n * }\n * }}\n * />\n * ```\n */\nexport const MessagePrimitiveUnstable_PartsGrouped: FC<\n MessagePrimitiveUnstable_PartsGrouped.Props\n> = ({ groupingFunction, components }) => {\n const contentLength = useAuiState((s) => s.message.parts.length);\n const { groups: messageGroups, partKeys } =\n useMessagePartsGrouped(groupingFunction);\n\n const partsElements = useMemo(() => {\n if (contentLength === 0) {\n return <EmptyParts components={components} />;\n }\n\n return messageGroups.map((group, groupIndex) => {\n const GroupComponent = components?.Group ?? defaultComponents.Group;\n const identity = partKeys[group.indices[0]!];\n\n return (\n <GroupComponent\n key={JSON.stringify([\n \"group\",\n group.groupKey ?? null,\n identity?.includes(\":\") ? `id:${identity}` : groupIndex,\n ])}\n groupKey={group.groupKey}\n indices={group.indices}\n >\n {group.indices.map((partIndex) => (\n <MessagePart\n key={partKeys[partIndex]}\n partIndex={partIndex}\n components={components}\n />\n ))}\n </GroupComponent>\n );\n });\n }, [messageGroups, components, contentLength, partKeys]);\n\n return <>{partsElements}</>;\n};\n\nMessagePrimitiveUnstable_PartsGrouped.displayName =\n \"MessagePrimitive.Unstable_PartsGrouped\";\n\n/**\n * Renders the parts of a message grouped by their parent ID.\n * This is a convenience wrapper around Unstable_PartsGrouped with parent ID grouping.\n *\n * @deprecated Use MessagePrimitive.Unstable_PartsGrouped instead for more flexibility\n */\nexport const MessagePrimitiveUnstable_PartsGroupedByParentId: FC<\n Omit<MessagePrimitiveUnstable_PartsGrouped.Props, \"groupingFunction\">\n> = ({ components, ...props }) => {\n return (\n <MessagePrimitiveUnstable_PartsGrouped\n {...props}\n components={components}\n groupingFunction={groupMessagePartsByParentId}\n />\n );\n};\n\nMessagePrimitiveUnstable_PartsGroupedByParentId.displayName =\n \"MessagePrimitive.Unstable_PartsGroupedByParentId\";\n"],"mappings":";;;;;;;;;;;;;;;;;AA2CA,MAAMgC,+BACJD,UACuB;CAEvB,MAAME,2BAAW,IAAIC,IAA+B;CAGpD,KAAK,IAAIC,IAAI,GAAGA,IAAIJ,MAAMK,QAAQD,KAAK;EAKrC,MAAMI,UAJOR,MAAMI,EACE,EAAEG,YAGKH;EAG5B,MAAMN,UAAUI,SAASO,IAAID,OAAO,KAAK,CAAA;EACzCV,QAAQY,KAAKN,CAAC;EACdF,SAASS,IAAIH,SAASV,OAAO;CAC/B;CAGA,MAAMc,SAA6B,CAAA;CACnC,KAAK,MAAM,CAACJ,SAASV,YAAYI,UAAU;EAEzC,MAAML,WAAW,OAAOW,YAAY,WAAWA,UAAUK,KAAAA;EACzDD,OAAOF,KAAK;GAAEb;GAAUC;EAAQ,CAAC;CACnC;CAEA,OAAOc;AACT;AAEA,MAAME,0BAAyBC,qBAAA;CAAA,MAAAC,IAAA9C,EAAA,CAAA;CAG7B,MAAA8B,QAAcxB,YAAYyC,KAAsB;CAAE,IAAAC;CAAAC,KAAA;EAGhD,IAAInB,MAAKK,WAAY,GAAC;GAAA,IAAAe;GAAA,IAAAJ,EAAA,OAAAK,OAAAC,IAAA,2BAAA,GAAA;IACbF,KAAA,CAAA;IAAEJ,EAAA,KAAAI;GAAA,OAAAA,KAAAJ,EAAA;GAATE,KAAOE;GAAP,MAAAD;EAAU;EACX,IAAAC;EAAA,IA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ETpG,OAAA;CAAA,MAAAF,IAAA9C,EAAA,CAAA;CAAA,IAAAyD;CAAA,IAAAgB;CAAA,IAAA3B,EAAA,OAAAE,IAAA;EAAC,CAAA,CAAAS,YAAA,GAAAgB,SAAAzB;EAAwBF,EAAA,KAAAE;EAAAF,EAAA,KAAAW;EAAAX,EAAA,KAAA2B;CAAA,OAAA;EAAAhB,aAAAX,EAAA;EAAA2B,QAAA3B,EAAA;CAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAW,cAAAX,EAAA,OAAA2B,OAAA;EAEzBvB,KAAA,oBAAC,uCAAD;GAAsC,GAChCuB;GACQhB;GACM1B,kBAAAA;EAA2B,CAAA;EAC7Ce,EAAA,KAAAW;EAAAX,EAAA,KAAA2B;EAAA3B,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OAJFI;AAIE;AAINkG,gDAAgDD,cAC9C;AApc6B,SAAApG,MAAA4B,GAAA;CAAA,OAGIA,EAAC2E,QAAQxH;AAAM;AA6MU,SAAAuE,OAAA1B,GAAA;CAAA,OAa1BA,EAACvC;AAAK;AAiHc,SAAAiG,OAAA1D,GAAA;CAAA,OAE1CA,EAAC2E,QAAQlC,UAATc;AAAyD;AAuDjE,SAAAM,OAAA7D,GAAA;CAAA,OACuCA,EAAC2E,QAAQxH,MAAMK;AAAO"}
|
|
@@ -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,EAAW;AAAC;AAGnC,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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,MAAAC,OAAA;GACE,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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;\n};\n"],"mappings":";;;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BAAwB,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,IAAAa;CAAA,IAAA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AAE,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,MAAAqB,kCAAwCzB,OAAO,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entRef","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;;;;;;;;;;;;;;;AAqBrC,MAAaE,gCA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AAA;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};\n\nThreadPrimitiveIf.displ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"","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,OAAoC,IAAI;CACxD,MAAAgB,cAAoBd,gBAAgBU,KAAKG,OAAO;CA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AA,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"}
|