@assistant-ui/react 0.15.16 → 0.15.17
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 +3 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -2
- package/dist/mcp-apps/McpAppRenderer.d.ts +6 -1
- package/dist/mcp-apps/McpAppRenderer.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.js +19 -12
- package/dist/mcp-apps/McpAppRenderer.js.map +1 -1
- package/dist/mcp-apps/McpAppsRemoteHost.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppsRemoteHost.js +20 -17
- package/dist/mcp-apps/McpAppsRemoteHost.js.map +1 -1
- package/dist/mcp-apps/app-frame.d.ts.map +1 -1
- package/dist/mcp-apps/app-frame.js +189 -94
- package/dist/mcp-apps/app-frame.js.map +1 -1
- package/dist/mcp-apps/index.d.ts +2 -2
- package/dist/model-context/frame/useAssistantFrameHost.d.ts +1 -1
- package/dist/model-context/frame/useAssistantFrameHost.js +10 -11
- package/dist/model-context/frame/useAssistantFrameHost.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +1 -1
- package/dist/model-context/makeAssistantVisible.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +3 -3
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js +3 -3
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +3 -3
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +3 -3
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js +3 -3
- package/dist/primitives/actionBar/ActionBarStopSpeaking.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.d.ts +2 -2
- package/dist/primitives/actionBarMore/scope.d.ts.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 +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/scope.d.ts +2 -2
- package/dist/primitives/assistantModal/scope.d.ts.map +1 -1
- package/dist/primitives/assistantModal/scope.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.js +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.js.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +1 -3
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerQuote.js +5 -5
- package/dist/primitives/composer/ComposerQuote.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js +3 -3
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts +5 -0
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.js +157 -130
- package/dist/primitives/composer/trigger/TriggerPopover.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverBack.js +3 -3
- package/dist/primitives/composer/trigger/TriggerPopoverBack.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.js +4 -4
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverItems.js +4 -4
- package/dist/primitives/composer/trigger/TriggerPopoverItems.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverResource.d.ts +2 -0
- package/dist/primitives/composer/trigger/TriggerPopoverResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverResource.js +63 -61
- package/dist/primitives/composer/trigger/TriggerPopoverResource.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.d.ts +2 -0
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js.map +1 -1
- package/dist/primitives/composer/trigger/detectTrigger.d.ts +21 -1
- package/dist/primitives/composer/trigger/detectTrigger.d.ts.map +1 -0
- package/dist/primitives/composer/trigger/detectTrigger.js +17 -3
- package/dist/primitives/composer/trigger/detectTrigger.js.map +1 -1
- package/dist/primitives/composer/trigger/index.d.ts +3 -1
- package/dist/primitives/composer/trigger/index.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/index.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerDetectionResource.d.ts +3 -4
- package/dist/primitives/composer/trigger/triggerDetectionResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerDetectionResource.js +15 -14
- package/dist/primitives/composer/trigger/triggerDetectionResource.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.js +18 -19
- package/dist/primitives/composer/trigger/triggerSelectionResource.js.map +1 -1
- package/dist/primitives/composer.d.ts +3 -2
- package/dist/primitives/composer.js.map +1 -1
- package/dist/primitives/error/ErrorMessage.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.js.map +1 -1
- package/dist/primitives/message/MessageRoot.js +4 -4
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/messagePart/MessagePartText.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js +3 -3
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js +3 -3
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadIf.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js +3 -3
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/ThreadViewportFooter.js +3 -3
- package/dist/primitives/thread/ThreadViewportFooter.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js +3 -3
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
- package/dist/primitives/threadListFocusGroup.d.ts +2 -1
- package/dist/primitives/threadListFocusGroup.d.ts.map +1 -1
- package/dist/primitives/threadListFocusGroup.js +2 -2
- package/dist/primitives/threadListFocusGroup.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js +3 -3
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js +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 +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 +1 -2
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js.map +1 -1
- package/dist/primitives/threadListItemMore/scope.d.ts +2 -2
- package/dist/primitives/threadListItemMore/scope.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/scope.js.map +1 -1
- package/dist/sandbox-host/SandboxHost.d.ts.map +1 -1
- package/dist/sandbox-host/SandboxHost.js +137 -70
- package/dist/sandbox-host/SandboxHost.js.map +1 -1
- package/dist/unstable/useLiveCompletionAdapter.js +3 -1
- package/dist/unstable/useLiveCompletionAdapter.js.map +1 -1
- package/dist/unstable/useSlashCommandAdapter.js +41 -27
- package/dist/unstable/useSlashCommandAdapter.js.map +1 -1
- package/dist/utils/Primitive.d.ts +2 -2
- package/dist/utils/Primitive.js +2 -2
- package/dist/utils/Primitive.js.map +1 -1
- package/dist/utils/createActionButton.js +3 -3
- package/dist/utils/createActionButton.js.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.js +1 -1
- package/dist/utils/hooks/useOnResizeContent.js.map +1 -1
- package/dist/utils/hooks/useOnScrollToBottom.js +1 -1
- package/dist/utils/hooks/useOnScrollToBottom.js.map +1 -1
- package/dist/utils/smooth/SmoothContext.d.ts +24 -0
- package/dist/utils/smooth/SmoothContext.d.ts.map +1 -1
- package/dist/utils/smooth/useSmooth.js +1 -1
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.d.ts +5 -1
- package/package.json +11 -19
- package/src/index.ts +9 -1
- package/src/mcp-apps/McpAppRenderer.test.tsx +133 -4
- package/src/mcp-apps/McpAppRenderer.tsx +28 -21
- package/src/mcp-apps/McpAppsRemoteHost.concurrent.test.tsx +215 -0
- package/src/mcp-apps/McpAppsRemoteHost.ts +28 -12
- package/src/mcp-apps/app-frame.test.tsx +102 -0
- package/src/mcp-apps/app-frame.tsx +17 -4
- package/src/mcp-apps/index.ts +1 -0
- package/src/model-context/frame/AssistantFrame.test.ts +3 -3
- package/src/model-context/frame/SPEC_AssistantFrame.md +1 -1
- package/src/model-context/frame/useAssistantFrameHost.ts +2 -2
- package/src/model-context/makeAssistantVisible.tsx +1 -1
- package/src/primitives/actionBar/ActionBarCopy.tsx +1 -1
- package/src/primitives/actionBar/ActionBarExportMarkdown.tsx +1 -1
- package/src/primitives/actionBar/ActionBarFeedbackNegative.tsx +1 -1
- package/src/primitives/actionBar/ActionBarFeedbackPositive.tsx +1 -1
- package/src/primitives/actionBar/ActionBarStopSpeaking.tsx +1 -1
- package/src/primitives/actionBarMore/scope.ts +2 -2
- package/src/primitives/assistantModal/AssistantModalContent.tsx +1 -1
- package/src/primitives/assistantModal/scope.ts +2 -2
- package/src/primitives/composer/ComposerAttachmentDropzone.tsx +1 -1
- package/src/primitives/composer/ComposerInput.test.tsx +2 -1
- package/src/primitives/composer/ComposerInput.tsx +3 -3
- package/src/primitives/composer/ComposerQuote.tsx +1 -1
- package/src/primitives/composer/ComposerRoot.tsx +1 -1
- package/src/primitives/composer/trigger/TriggerPopover.tsx +16 -1
- package/src/primitives/composer/trigger/TriggerPopoverBack.tsx +1 -1
- package/src/primitives/composer/trigger/TriggerPopoverCategories.tsx +1 -1
- package/src/primitives/composer/trigger/TriggerPopoverItems.tsx +1 -1
- package/src/primitives/composer/trigger/TriggerPopoverResource.ts +4 -1
- package/src/primitives/composer/trigger/TriggerPopoverRootContext.tsx +2 -0
- package/src/primitives/composer/trigger/detectTrigger.test.ts +88 -5
- package/src/primitives/composer/trigger/detectTrigger.ts +50 -9
- package/src/primitives/composer/trigger/index.ts +1 -0
- package/src/primitives/composer/trigger/triggerDetectionResource.ts +10 -7
- package/src/primitives/composer/trigger/triggerSelectionResource.test.ts +15 -3
- package/src/primitives/composer/trigger/triggerSelectionResource.ts +1 -4
- package/src/primitives/composer.ts +1 -0
- package/src/primitives/message/MessageRoot.tsx +1 -1
- package/src/primitives/selectionToolbar/SelectionToolbarQuote.tsx +1 -1
- package/src/primitives/selectionToolbar/SelectionToolbarRoot.tsx +1 -1
- package/src/primitives/thread/ThreadViewport.tsx +1 -1
- package/src/primitives/thread/ThreadViewportFooter.tsx +1 -1
- package/src/primitives/thread/useThreadViewportAutoScroll.ts +1 -1
- package/src/primitives/threadList/ThreadListNew.tsx +1 -1
- package/src/primitives/threadListFocusGroup.ts +2 -2
- package/src/primitives/threadListItem/ThreadListItemRoot.tsx +1 -1
- package/src/primitives/threadListItem/ThreadListItemTrigger.tsx +1 -1
- package/src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx +1 -1
- package/src/primitives/threadListItemMore/ThreadListItemMoreRoot.tsx +1 -1
- package/src/primitives/threadListItemMore/ThreadListItemMoreTrigger.tsx +2 -2
- package/src/primitives/threadListItemMore/scope.ts +2 -2
- package/src/sandbox-host/SandboxHost.test.tsx +45 -1
- package/src/sandbox-host/SandboxHost.tsx +16 -3
- package/src/tests/RemoteThreadListRuntime.adapterProvider.test.tsx +31 -1
- package/src/unstable/useLiveCompletionAdapter.test.tsx +60 -1
- package/src/unstable/useLiveCompletionAdapter.ts +4 -1
- package/src/unstable/useSlashCommandAdapter.test.tsx +141 -0
- package/src/unstable/useSlashCommandAdapter.ts +52 -17
- package/src/utils/Primitive.tsx +2 -2
- package/src/utils/createActionButton.tsx +1 -1
- package/src/utils/hooks/useOnResizeContent.ts +1 -1
- package/src/utils/hooks/useOnScrollToBottom.ts +1 -1
- package/src/utils/smooth/useSmooth.ts +1 -1
- package/dist/legacy-runtime/runtime/MessagePartRuntime.d.ts +0 -3
- package/dist/legacy-runtime/runtime/MessagePartRuntime.js +0 -2
- package/dist/legacy-runtime/runtime/MessageRuntime.d.ts +0 -3
- package/dist/legacy-runtime/runtime/MessageRuntime.js +0 -2
- package/dist/legacy-runtime/runtime/ThreadListRuntime.d.ts +0 -3
- package/dist/legacy-runtime/runtime/ThreadListRuntime.js +0 -2
- package/src/legacy-runtime/runtime/MessagePartRuntime.ts +0 -2
- package/src/legacy-runtime/runtime/MessageRuntime.ts +0 -3
- package/src/legacy-runtime/runtime/ThreadListRuntime.ts +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessagePartText.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","ElementType","useMessagePartText","useSmooth","SmoothOptions","MessagePartPrimitiveText","Element","span","Props","Omit","smooth","component","t0","forwardedRef","$","rest","t1","t2","undefined","Component","text","status","t3","type","displayName"],"sources":["../../../src/primitives/messagePart/MessagePartText.tsx"],"sourcesContent":["\"use client\";\n\nimport type { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementType,\n} from \"react\";\nimport { useMessagePartText } from \"./useMessagePartText\";\nimport { useSmooth, type SmoothOptions } from \"../../utils/smooth/useSmooth\";\n\nexport namespace MessagePartPrimitiveText {\n export type Element = ComponentRef<typeof Primitive.span>;\n export type Props = Omit<\n ComponentPropsWithoutRef<typeof Primitive.span>,\n \"children\" | \"asChild\"\n > & {\n /**\n * Whether to enable smooth text streaming animation.\n * When enabled, text appears with a typing effect as it streams in.\n * Pass a `SmoothOptions` object to tune the reveal rate.\n * Auto-disables under `prefers-reduced-motion: reduce`.\n * @default true\n */\n smooth?: boolean | SmoothOptions;\n /**\n * The HTML element or React component to render as.\n * @default \"span\"\n */\n component?: ElementType;\n };\n}\n\n/**\n * Renders the text content of a message part with optional smooth streaming.\n *\n * This component displays text content from the current message part context,\n * with support for smooth streaming animation that shows text appearing\n * character by character as it's generated.\n *\n * @example\n * ```tsx\n * <MessagePartPrimitive.Text\n * smooth={true}\n * component=\"p\"\n * className=\"message-text\"\n * />\n * ```\n */\nexport const MessagePartPrimitiveText = forwardRef<\n MessagePartPrimitiveText.Element,\n MessagePartPrimitiveText.Props\n>(({ smooth = true, component: Component = \"span\", ...rest }, forwardedRef) => {\n const { text, status } = useSmooth(useMessagePartText(), smooth);\n\n return (\n <Component data-status={status.type} {...rest} ref={forwardedRef}>\n {text}\n </Component>\n );\n});\n\nMessagePartPrimitiveText.displayName = \"MessagePartPrimitive.Text\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAaU,2BAA2BN,YAGtCa,IAAAC,iBAAA;CAAA,MAAAC,IAAAlB,EAAA,EAAA;CAAA,IAAAmB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAF,QAAAM,IAAAL,WAAAM,
|
|
1
|
+
{"version":3,"file":"MessagePartText.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","ElementType","useMessagePartText","useSmooth","SmoothOptions","MessagePartPrimitiveText","Element","span","Props","Omit","smooth","component","t0","forwardedRef","$","rest","t1","t2","undefined","Component","text","status","t3","type","displayName"],"sources":["../../../src/primitives/messagePart/MessagePartText.tsx"],"sourcesContent":["\"use client\";\n\nimport type { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementType,\n} from \"react\";\nimport { useMessagePartText } from \"./useMessagePartText\";\nimport { useSmooth, type SmoothOptions } from \"../../utils/smooth/useSmooth\";\n\nexport namespace MessagePartPrimitiveText {\n export type Element = ComponentRef<typeof Primitive.span>;\n export type Props = Omit<\n ComponentPropsWithoutRef<typeof Primitive.span>,\n \"children\" | \"asChild\"\n > & {\n /**\n * Whether to enable smooth text streaming animation.\n * When enabled, text appears with a typing effect as it streams in.\n * Pass a `SmoothOptions` object to tune the reveal rate.\n * Auto-disables under `prefers-reduced-motion: reduce`.\n * @default true\n */\n smooth?: boolean | SmoothOptions;\n /**\n * The HTML element or React component to render as.\n * @default \"span\"\n */\n component?: ElementType;\n };\n}\n\n/**\n * Renders the text content of a message part with optional smooth streaming.\n *\n * This component displays text content from the current message part context,\n * with support for smooth streaming animation that shows text appearing\n * character by character as it's generated.\n *\n * @example\n * ```tsx\n * <MessagePartPrimitive.Text\n * smooth={true}\n * component=\"p\"\n * className=\"message-text\"\n * />\n * ```\n */\nexport const MessagePartPrimitiveText = forwardRef<\n MessagePartPrimitiveText.Element,\n MessagePartPrimitiveText.Props\n>(({ smooth = true, component: Component = \"span\", ...rest }, forwardedRef) => {\n const { text, status } = useSmooth(useMessagePartText(), smooth);\n\n return (\n <Component data-status={status.type} {...rest} ref={forwardedRef}>\n {text}\n </Component>\n );\n});\n\nMessagePartPrimitiveText.displayName = \"MessagePartPrimitive.Text\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAaU,2BAA2BN,YAGtCa,IAAAC,iBAAA;CAAA,MAAAC,IAAAlB,EAAA,EAAA;CAAA,IAAAmB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAF,QAAAM,IAAAL,WAAAM,IAAA,GAAAF,QAAAH;EAAyDE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAF,OAAAD,EAAA;EAAAE,KAAAF,EAAA;EAAAG,KAAAH,EAAA;CAAA;CAAvD,MAAAJ,SAAAM,OAAAE,KAAAA,IAAA,OAAAF;CAA0B,MAAAG,YAAAF,OAAAC,KAAAA,IAAA,SAAAD;CAC7B,MAAA,EAAAG,MAAAC,WAAyBlB,UAAUD,mBAAmB,GAAGQ,MAAM;CAAE,IAAAY;CAAA,IAAAR,EAAA,OAAAK,aAAAL,EAAA,OAAAD,gBAAAC,EAAA,OAAAC,QAAAD,EAAA,OAAAO,OAAAE,QAAAT,EAAA,OAAAM,MAAA;EAG/DE,KAAA,oBAAC,WAAD;GAAwB,eAAAD,OAAME;GAAK,GAAMR;GAAWF,KAAAA;GACjDO,UAAAA;EADO,CAAA;EAEEN,EAAA,KAAAK;EAAAL,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAO,OAAAE;EAAAT,EAAA,KAAAM;EAAAN,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAFZQ;AAEY,CAEf;AAEDjB,yBAAyBmB,cAAc"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Primitive } from "../../utils/Primitive.js";
|
|
2
|
+
import { Primitive as Primitive$1 } from "../../utils/Primitive.js";
|
|
3
3
|
import { useSelectionToolbarInfo } from "./SelectionToolbarRoot.js";
|
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
5
|
import { useAui } from "@assistant-ui/store";
|
|
6
6
|
import { forwardRef } from "@assistant-ui/tap/react-shim";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import { composeEventHandlers } from "
|
|
8
|
+
import { composeEventHandlers } from "radix-ui/internal";
|
|
9
9
|
//#region src/primitives/selectionToolbar/SelectionToolbarQuote.tsx
|
|
10
10
|
/**
|
|
11
11
|
* A button that quotes the currently selected text.
|
|
@@ -64,7 +64,7 @@ const SelectionToolbarPrimitiveQuote = forwardRef((t0, forwardedRef) => {
|
|
|
64
64
|
} else t3 = $[9];
|
|
65
65
|
let t4;
|
|
66
66
|
if ($[10] !== forwardedRef || $[11] !== props || $[12] !== t2 || $[13] !== t3) {
|
|
67
|
-
t4 = /* @__PURE__ */ jsx(Primitive.button, {
|
|
67
|
+
t4 = /* @__PURE__ */ jsx(Primitive$1.button, {
|
|
68
68
|
type: "button",
|
|
69
69
|
...props,
|
|
70
70
|
ref: forwardedRef,
|
|
@@ -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 \"
|
|
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,oBAAA,YAAA,QAAA;GACO,MAAA;GAAQ,GACTf;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,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Primitive } from "../../utils/Primitive.js";
|
|
2
|
+
import { Primitive as Primitive$1 } from "../../utils/Primitive.js";
|
|
3
3
|
import { getSelectionMessageId } from "../../utils/getSelectionMessageId.js";
|
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
5
|
import { createContext, forwardRef, useContext, useEffect, useState } from "@assistant-ui/tap/react-shim";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import { composeEventHandlers } from "
|
|
7
|
+
import { composeEventHandlers } from "radix-ui/internal";
|
|
8
8
|
import { createPortal } from "react-dom";
|
|
9
9
|
//#region src/primitives/selectionToolbar/SelectionToolbarRoot.tsx
|
|
10
10
|
const SelectionToolbarContext = createContext(null);
|
|
@@ -124,7 +124,7 @@ const SelectionToolbarPrimitiveRoot = forwardRef((t0, forwardedRef) => {
|
|
|
124
124
|
} else t6 = $[11];
|
|
125
125
|
let t7;
|
|
126
126
|
if ($[12] !== forwardedRef || $[13] !== positionStyle || $[14] !== props || $[15] !== t6) {
|
|
127
|
-
t7 = /* @__PURE__ */ jsx(Primitive.div, {
|
|
127
|
+
t7 = /* @__PURE__ */ jsx(Primitive$1.div, {
|
|
128
128
|
...props,
|
|
129
129
|
ref: forwardedRef,
|
|
130
130
|
style: positionStyle,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionToolbarRoot.js","names":["c","_c","Primitive","composeEventHandlers","ComponentPropsWithoutRef","ComponentRef","createContext","forwardRef","useContext","useEffect","useState","createPortal","getSelectionMessageId","SelectionInfo","text","messageId","rect","DOMRect","SelectionToolbarContext","useSelectionToolbarInfo","SelectionToolbarPrimitiveRoot","Element","div","Props","t0","forwardedRef","$","onMouseDown","props","style","info","setInfo","t1","t2","Symbol","for","checkSelection","requestAnimationFrame","sel","window","getSelection","isCollapsed","toString","trim","range","getRangeAt","getBoundingClientRect","handleSelectionCollapse","sel_0","handleScroll","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 \"
|
|
1
|
+
{"version":3,"file":"SelectionToolbarRoot.js","names":["c","_c","Primitive","composeEventHandlers","ComponentPropsWithoutRef","ComponentRef","createContext","forwardRef","useContext","useEffect","useState","createPortal","getSelectionMessageId","SelectionInfo","text","messageId","rect","DOMRect","SelectionToolbarContext","useSelectionToolbarInfo","SelectionToolbarPrimitiveRoot","Element","div","Props","t0","forwardedRef","$","onMouseDown","props","style","info","setInfo","t1","t2","Symbol","for","checkSelection","requestAnimationFrame","sel","window","getSelection","isCollapsed","toString","trim","range","getRangeAt","getBoundingClientRect","handleSelectionCollapse","sel_0","handleScroll","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 useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { getSelectionMessageId } from \"../../utils/getSelectionMessageId\";\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 mouse and keyboard selection events, validates that the\n * selection is within a single message, and renders a positioned portal\n * near the 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\n useEffect(() => {\n const checkSelection = () => {\n requestAnimationFrame(() => {\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 const messageId = getSelectionMessageId(sel);\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 handleSelectionCollapse = () => {\n const sel = window.getSelection();\n if (!sel || sel.isCollapsed) {\n setInfo(null);\n }\n };\n\n const handleScroll = () => {\n setInfo(null);\n };\n\n document.addEventListener(\"mouseup\", checkSelection);\n document.addEventListener(\"keyup\", checkSelection);\n document.addEventListener(\"selectionchange\", handleSelectionCollapse);\n document.addEventListener(\"scroll\", handleScroll, true);\n\n return () => {\n document.removeEventListener(\"mouseup\", checkSelection);\n document.removeEventListener(\"keyup\", checkSelection);\n document.removeEventListener(\"selectionchange\", handleSelectionCollapse);\n document.removeEventListener(\"scroll\", handleScroll, true);\n };\n }, []);\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":";;;;;;;;;AAsBA,MAAMkB,0BAA0BZ,cAAoC,IAAI;AAExE,MAAaa,gCAA0B;CAAA,OACrCX,WAAWU,uBAAuB;AAAC;;;;;;;;;;;;;;;AAqBrC,MAAaE,gCAAgCb,YAG3CiB,IAAAC,iBAAA;CAAA,MAAAC,IAAAzB,EAAA,EAAA;CAAA,IAAA0B;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,WAAwBrB,SAA+B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;EAAAvC,EAAA,MAAAwC;CAAA,OAAAA,KAAAxC,EAAA;CAAA,OAbMwC;AAaN,CACF;AAED9C,8BAA8BgD,cAAc;AAjF1C,SAAAJ,MAAAK,GAAA;CAyEQA,EAACC,eAAgB;AAAC"}
|
|
@@ -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,
|
|
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,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useThreadViewport, useThreadViewportStore } from "../../context/react/ThreadViewportContext.js";
|
|
3
3
|
import { ThreadPrimitiveViewportProvider } from "../../context/providers/ThreadViewportProvider.js";
|
|
4
|
-
import { Primitive } from "../../utils/Primitive.js";
|
|
4
|
+
import { Primitive as Primitive$1 } from "../../utils/Primitive.js";
|
|
5
5
|
import { useManagedRef } from "../../utils/hooks/useManagedRef.js";
|
|
6
6
|
import { useThreadViewportAutoScroll } from "./useThreadViewportAutoScroll.js";
|
|
7
7
|
import { useSizeHandle } from "../../utils/hooks/useSizeHandle.js";
|
|
@@ -11,7 +11,7 @@ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
|
11
11
|
import { useAuiState } from "@assistant-ui/store";
|
|
12
12
|
import { forwardRef, useLayoutEffect } from "@assistant-ui/tap/react-shim";
|
|
13
13
|
import { jsx } from "react/jsx-runtime";
|
|
14
|
-
import { useComposedRefs } from "
|
|
14
|
+
import { useComposedRefs } from "radix-ui/internal";
|
|
15
15
|
//#region src/primitives/thread/ThreadViewport.tsx
|
|
16
16
|
const useViewportSizeRef = () => {
|
|
17
17
|
const register = useThreadViewport(_temp);
|
|
@@ -170,7 +170,7 @@ const ThreadPrimitiveViewportScrollable = forwardRef((t0, forwardedRef) => {
|
|
|
170
170
|
const ref = useComposedRefs(forwardedRef, autoScrollRef, viewportSizeRef, viewportElementRef);
|
|
171
171
|
let t3;
|
|
172
172
|
if ($[14] !== children || $[15] !== ref || $[16] !== rest) {
|
|
173
|
-
t3 = /* @__PURE__ */ jsx(Primitive.div, {
|
|
173
|
+
t3 = /* @__PURE__ */ jsx(Primitive$1.div, {
|
|
174
174
|
...rest,
|
|
175
175
|
ref,
|
|
176
176
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadViewport.js","names":["c","_c","useComposedRefs","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useCallback","useLayoutEffect","useMemo","useAuiState","useManagedRef","useThreadViewportAutoScroll","ThreadPrimitiveViewportProvider","useSizeHandle","useThreadViewport","useThreadViewportStore","useTopAnchorReserve","getActiveTopAnchorAnchorId","getActiveTopAnchorTargetId","isTopAnchorTurnValid","ThreadPrimitiveViewport","Element","div","Props","autoScroll","turnAnchor","topAnchorMessageClamp","tallerThan","visibleHeight","scrollToBottomOnRunStart","scrollToBottomOnInitialize","scrollToBottomOnThreadSwitch","useViewportSizeRef","register","_temp","getHeight","_temp2","useViewportElementRef","registerViewportElement","_temp3","useTopAnchorTurn","enabled","$","threadViewportStore","t0","s","thread","activeAnchorId","t1","s_0","activeTargetId","topAnchorTurn","_temp4","t2","bb0","t3","anchorId","targetId","activeTurn","s_2","messages","topAnchorTurnIsValid","t4","t5","getState","setTopAnchorTurn","t6","t7","state","current","ThreadPrimitiveViewportScrollable","forwardedRef","children","rest","autoScrollRef","viewportSizeRef","viewportElementRef","topAnchorEnabled","ref","displayName","props","registerViewport","el","clientHeight","s_1"],"sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n useCallback,\n useLayoutEffect,\n useMemo,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useThreadViewportAutoScroll } from \"./useThreadViewportAutoScroll\";\nimport { ThreadPrimitiveViewportProvider } from \"../../context/providers/ThreadViewportProvider\";\nimport { useSizeHandle } from \"../../utils/hooks/useSizeHandle\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\nimport { useTopAnchorReserve } from \"./topAnchor/useTopAnchorReserve\";\nimport {\n getActiveTopAnchorAnchorId,\n getActiveTopAnchorTargetId,\n isTopAnchorTurnValid,\n} from \"./topAnchor/topAnchorTurn\";\n\nexport namespace ThreadPrimitiveViewport {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div> & {\n /**\n * Whether to automatically scroll to the bottom when new messages are added.\n * When enabled, the viewport will automatically scroll to show the latest content.\n *\n * Default false if `turnAnchor` is \"top\", otherwise defaults to true.\n */\n autoScroll?: boolean | undefined;\n\n /**\n * Controls scroll anchoring behavior for new messages.\n * - \"bottom\" (default): Messages anchor at the bottom, classic chat behavior.\n * - \"top\": New user messages anchor at the top of the viewport for a focused reading experience.\n */\n turnAnchor?: \"top\" | \"bottom\" | undefined;\n\n /**\n * Clamps tall user messages so the assistant response stays in view.\n *\n * @default { tallerThan: \"10em\", visibleHeight: \"6em\" }\n */\n topAnchorMessageClamp?: {\n /**\n * Clamp messages taller than this. Supports `px`, `em`, and `rem`.\n *\n * @default \"10em\"\n */\n tallerThan?: string;\n /**\n * Visible portion of clamped messages. Supports `px`, `em`, and `rem`.\n *\n * @default \"6em\"\n */\n visibleHeight?: string;\n };\n\n /**\n * Whether to scroll to bottom when a new run starts.\n *\n * Defaults to true.\n */\n scrollToBottomOnRunStart?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when thread history is first loaded.\n *\n * Defaults to true.\n */\n scrollToBottomOnInitialize?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when switching to a different thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n };\n}\n\nconst useViewportSizeRef = () => {\n const register = useThreadViewport((s) => s.registerViewport);\n const getHeight = useCallback((el: HTMLElement) => el.clientHeight, []);\n return useSizeHandle(register, getHeight);\n};\n\nconst useViewportElementRef = () => {\n const registerViewportElement = useThreadViewport(\n (s) => s.registerViewportElement,\n );\n\n return useManagedRef(registerViewportElement);\n};\n\nconst useTopAnchorTurn = (enabled: boolean) => {\n const threadViewportStore = useThreadViewportStore();\n const activeAnchorId = useAuiState((s) => {\n if (!enabled) return undefined;\n return getActiveTopAnchorAnchorId(s.thread);\n });\n const activeTargetId = useAuiState((s) => {\n if (!enabled) return undefined;\n return getActiveTopAnchorTargetId(s.thread);\n });\n const topAnchorTurn = useThreadViewport((s) => s.topAnchorTurn);\n const activeTurn = useMemo(() => {\n if (!activeAnchorId || !activeTargetId) return null;\n return { anchorId: activeAnchorId, targetId: activeTargetId };\n }, [activeAnchorId, activeTargetId]);\n\n const topAnchorTurnIsValid = useAuiState(\n (s) =>\n enabled &&\n !!topAnchorTurn &&\n isTopAnchorTurnValid(topAnchorTurn, s.thread.messages),\n );\n\n useLayoutEffect(() => {\n if (!topAnchorTurn || topAnchorTurnIsValid) return;\n\n threadViewportStore.getState().setTopAnchorTurn(null);\n }, [threadViewportStore, topAnchorTurn, topAnchorTurnIsValid]);\n\n useLayoutEffect(() => {\n if (!activeTurn) return;\n\n const state = threadViewportStore.getState();\n const current = state.topAnchorTurn;\n if (\n current?.anchorId === activeTurn.anchorId &&\n current.targetId === activeTurn.targetId\n ) {\n return;\n }\n\n state.setTopAnchorTurn(activeTurn);\n }, [activeTurn, threadViewportStore]);\n};\n\nconst ThreadPrimitiveViewportScrollable = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(\n (\n {\n autoScroll,\n scrollToBottomOnRunStart,\n scrollToBottomOnInitialize,\n scrollToBottomOnThreadSwitch,\n children,\n ...rest\n },\n forwardedRef,\n ) => {\n const autoScrollRef = useThreadViewportAutoScroll<HTMLDivElement>({\n autoScroll,\n scrollToBottomOnRunStart,\n scrollToBottomOnInitialize,\n scrollToBottomOnThreadSwitch,\n });\n const viewportSizeRef = useViewportSizeRef();\n const viewportElementRef = useViewportElementRef();\n const threadViewportStore = useThreadViewportStore();\n const turnAnchor = threadViewportStore.getState().turnAnchor;\n const topAnchorEnabled = turnAnchor === \"top\";\n useTopAnchorTurn(topAnchorEnabled);\n useTopAnchorReserve(topAnchorEnabled);\n const ref = useComposedRefs(\n forwardedRef,\n autoScrollRef,\n viewportSizeRef,\n viewportElementRef,\n );\n\n return (\n <Primitive.div {...rest} ref={ref}>\n {children}\n </Primitive.div>\n );\n },\n);\n\nThreadPrimitiveViewportScrollable.displayName =\n \"ThreadPrimitive.ViewportScrollable\";\n\n/**\n * A scrollable viewport container for thread messages.\n *\n * This component provides a scrollable area for displaying thread messages with\n * automatic scrolling capabilities. It manages the viewport state and provides\n * context for child components to access viewport-related functionality.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Viewport turnAnchor=\"top\">\n * <ThreadPrimitive.Messages>\n * {() => <MyMessage />}\n * </ThreadPrimitive.Messages>\n * </ThreadPrimitive.Viewport>\n * ```\n */\nexport const ThreadPrimitiveViewport = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(({ turnAnchor, topAnchorMessageClamp, ...props }, ref) => {\n return (\n <ThreadPrimitiveViewportProvider\n options={{ turnAnchor, topAnchorMessageClamp }}\n >\n <ThreadPrimitiveViewportScrollable {...props} ref={ref} />\n </ThreadPrimitiveViewportProvider>\n );\n});\n\nThreadPrimitiveViewport.displayName = \"ThreadPrimitive.Viewport\";\n"],"mappings":";;;;;;;;;;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;CAAA,IAAAa;CAAA,IAAAb,EAAA,QAAAM,MAAAN,EAAA,QAAAW,IAAA;EAH5DE,KAAA,oBAAC,iCAAD;GACW,SAAAP;GAETK,UAAAA;EAH8B,CAAA;EAIEX,EAAA,MAAAM;EAAAN,EAAA,MAAAW;EAAAX,EAAA,MAAAa;CAAA,OAAAA,KAAAb,EAAA;CAAA,OAJlCa;AAIkC,CAErC;AAEDnC,wBAAwB2D,cAAc;AAtIX,SAAA7C,MAAAW,GAAA;CAAA,OACiBA,EAACoC;AAAiB;AADnC,SAAA7C,OAAA8C,IAAA;CAAA,OAE0BA,GAAEC;AAAa;AAItC,SAAA5C,OAAAM,GAAA;CAAA,OAEnBA,EAACP;AAAwB;AAMX,SAAAc,OAAAgC,KAAA;CAAA,OAUwBvC,IAACM;AAAc"}
|
|
1
|
+
{"version":3,"file":"ThreadViewport.js","names":["c","_c","useComposedRefs","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useCallback","useLayoutEffect","useMemo","useAuiState","useManagedRef","useThreadViewportAutoScroll","ThreadPrimitiveViewportProvider","useSizeHandle","useThreadViewport","useThreadViewportStore","useTopAnchorReserve","getActiveTopAnchorAnchorId","getActiveTopAnchorTargetId","isTopAnchorTurnValid","ThreadPrimitiveViewport","Element","div","Props","autoScroll","turnAnchor","topAnchorMessageClamp","tallerThan","visibleHeight","scrollToBottomOnRunStart","scrollToBottomOnInitialize","scrollToBottomOnThreadSwitch","useViewportSizeRef","register","_temp","getHeight","_temp2","useViewportElementRef","registerViewportElement","_temp3","useTopAnchorTurn","enabled","$","threadViewportStore","t0","s","thread","activeAnchorId","t1","s_0","activeTargetId","topAnchorTurn","_temp4","t2","bb0","t3","anchorId","targetId","activeTurn","s_2","messages","topAnchorTurnIsValid","t4","t5","getState","setTopAnchorTurn","t6","t7","state","current","ThreadPrimitiveViewportScrollable","forwardedRef","children","rest","autoScrollRef","viewportSizeRef","viewportElementRef","topAnchorEnabled","ref","displayName","props","registerViewport","el","clientHeight","s_1"],"sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n useCallback,\n useLayoutEffect,\n useMemo,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useThreadViewportAutoScroll } from \"./useThreadViewportAutoScroll\";\nimport { ThreadPrimitiveViewportProvider } from \"../../context/providers/ThreadViewportProvider\";\nimport { useSizeHandle } from \"../../utils/hooks/useSizeHandle\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\nimport { useTopAnchorReserve } from \"./topAnchor/useTopAnchorReserve\";\nimport {\n getActiveTopAnchorAnchorId,\n getActiveTopAnchorTargetId,\n isTopAnchorTurnValid,\n} from \"./topAnchor/topAnchorTurn\";\n\nexport namespace ThreadPrimitiveViewport {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div> & {\n /**\n * Whether to automatically scroll to the bottom when new messages are added.\n * When enabled, the viewport will automatically scroll to show the latest content.\n *\n * Default false if `turnAnchor` is \"top\", otherwise defaults to true.\n */\n autoScroll?: boolean | undefined;\n\n /**\n * Controls scroll anchoring behavior for new messages.\n * - \"bottom\" (default): Messages anchor at the bottom, classic chat behavior.\n * - \"top\": New user messages anchor at the top of the viewport for a focused reading experience.\n */\n turnAnchor?: \"top\" | \"bottom\" | undefined;\n\n /**\n * Clamps tall user messages so the assistant response stays in view.\n *\n * @default { tallerThan: \"10em\", visibleHeight: \"6em\" }\n */\n topAnchorMessageClamp?: {\n /**\n * Clamp messages taller than this. Supports `px`, `em`, and `rem`.\n *\n * @default \"10em\"\n */\n tallerThan?: string;\n /**\n * Visible portion of clamped messages. Supports `px`, `em`, and `rem`.\n *\n * @default \"6em\"\n */\n visibleHeight?: string;\n };\n\n /**\n * Whether to scroll to bottom when a new run starts.\n *\n * Defaults to true.\n */\n scrollToBottomOnRunStart?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when thread history is first loaded.\n *\n * Defaults to true.\n */\n scrollToBottomOnInitialize?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when switching to a different thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n };\n}\n\nconst useViewportSizeRef = () => {\n const register = useThreadViewport((s) => s.registerViewport);\n const getHeight = useCallback((el: HTMLElement) => el.clientHeight, []);\n return useSizeHandle(register, getHeight);\n};\n\nconst useViewportElementRef = () => {\n const registerViewportElement = useThreadViewport(\n (s) => s.registerViewportElement,\n );\n\n return useManagedRef(registerViewportElement);\n};\n\nconst useTopAnchorTurn = (enabled: boolean) => {\n const threadViewportStore = useThreadViewportStore();\n const activeAnchorId = useAuiState((s) => {\n if (!enabled) return undefined;\n return getActiveTopAnchorAnchorId(s.thread);\n });\n const activeTargetId = useAuiState((s) => {\n if (!enabled) return undefined;\n return getActiveTopAnchorTargetId(s.thread);\n });\n const topAnchorTurn = useThreadViewport((s) => s.topAnchorTurn);\n const activeTurn = useMemo(() => {\n if (!activeAnchorId || !activeTargetId) return null;\n return { anchorId: activeAnchorId, targetId: activeTargetId };\n }, [activeAnchorId, activeTargetId]);\n\n const topAnchorTurnIsValid = useAuiState(\n (s) =>\n enabled &&\n !!topAnchorTurn &&\n isTopAnchorTurnValid(topAnchorTurn, s.thread.messages),\n );\n\n useLayoutEffect(() => {\n if (!topAnchorTurn || topAnchorTurnIsValid) return;\n\n threadViewportStore.getState().setTopAnchorTurn(null);\n }, [threadViewportStore, topAnchorTurn, topAnchorTurnIsValid]);\n\n useLayoutEffect(() => {\n if (!activeTurn) return;\n\n const state = threadViewportStore.getState();\n const current = state.topAnchorTurn;\n if (\n current?.anchorId === activeTurn.anchorId &&\n current.targetId === activeTurn.targetId\n ) {\n return;\n }\n\n state.setTopAnchorTurn(activeTurn);\n }, [activeTurn, threadViewportStore]);\n};\n\nconst ThreadPrimitiveViewportScrollable = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(\n (\n {\n autoScroll,\n scrollToBottomOnRunStart,\n scrollToBottomOnInitialize,\n scrollToBottomOnThreadSwitch,\n children,\n ...rest\n },\n forwardedRef,\n ) => {\n const autoScrollRef = useThreadViewportAutoScroll<HTMLDivElement>({\n autoScroll,\n scrollToBottomOnRunStart,\n scrollToBottomOnInitialize,\n scrollToBottomOnThreadSwitch,\n });\n const viewportSizeRef = useViewportSizeRef();\n const viewportElementRef = useViewportElementRef();\n const threadViewportStore = useThreadViewportStore();\n const turnAnchor = threadViewportStore.getState().turnAnchor;\n const topAnchorEnabled = turnAnchor === \"top\";\n useTopAnchorTurn(topAnchorEnabled);\n useTopAnchorReserve(topAnchorEnabled);\n const ref = useComposedRefs(\n forwardedRef,\n autoScrollRef,\n viewportSizeRef,\n viewportElementRef,\n );\n\n return (\n <Primitive.div {...rest} ref={ref}>\n {children}\n </Primitive.div>\n );\n },\n);\n\nThreadPrimitiveViewportScrollable.displayName =\n \"ThreadPrimitive.ViewportScrollable\";\n\n/**\n * A scrollable viewport container for thread messages.\n *\n * This component provides a scrollable area for displaying thread messages with\n * automatic scrolling capabilities. It manages the viewport state and provides\n * context for child components to access viewport-related functionality.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Viewport turnAnchor=\"top\">\n * <ThreadPrimitive.Messages>\n * {() => <MyMessage />}\n * </ThreadPrimitive.Messages>\n * </ThreadPrimitive.Viewport>\n * ```\n */\nexport const ThreadPrimitiveViewport = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(({ turnAnchor, topAnchorMessageClamp, ...props }, ref) => {\n return (\n <ThreadPrimitiveViewportProvider\n options={{ turnAnchor, topAnchorMessageClamp }}\n >\n <ThreadPrimitiveViewportScrollable {...props} ref={ref} />\n </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AAYF;EAAG,CAAA;EAAIpC,EAAA,KAAAsC;EAAAtC,EAAA,KAAAoC;EAAApC,EAAA,KAAAW;CAAA,OAAAA,KAAAX,EAAA;CAAA,IAAAa;CAAA,IAAAb,EAAA,QAAAM,MAAAN,EAAA,QAAAW,IAAA;EAH5DE,KAAA,oBAAC,iCAAD;GACW,SAAAP;GAETK,UAAAA;EAH8B,CAAA;EAIEX,EAAA,MAAAM;EAAAN,EAAA,MAAAW;EAAAX,EAAA,MAAAa;CAAA,OAAAA,KAAAb,EAAA;CAAA,OAJlCa;AAIkC,CAErC;AAEDnC,wBAAwB2D,cAAc;AAtIX,SAAA7C,MAAAW,GAAA;CAAA,OACiBA,EAACoC;AAAiB;AADnC,SAAA7C,OAAA8C,IAAA;CAAA,OAE0BA,GAAEC;AAAa;AAItC,SAAA5C,OAAAM,GAAA;CAAA,OAEnBA,EAACP;AAAwB;AAMX,SAAAc,OAAAgC,KAAA;CAAA,OAUwBvC,IAACM;AAAc"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useThreadViewport } from "../../context/react/ThreadViewportContext.js";
|
|
3
|
-
import { Primitive } from "../../utils/Primitive.js";
|
|
3
|
+
import { Primitive as Primitive$1 } from "../../utils/Primitive.js";
|
|
4
4
|
import { useSizeHandle } from "../../utils/hooks/useSizeHandle.js";
|
|
5
5
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
6
6
|
import { forwardRef } from "@assistant-ui/tap/react-shim";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import { useComposedRefs } from "
|
|
8
|
+
import { useComposedRefs } from "radix-ui/internal";
|
|
9
9
|
//#region src/primitives/thread/ThreadViewportFooter.tsx
|
|
10
10
|
/**
|
|
11
11
|
* A footer container that measures its height for scroll calculations.
|
|
@@ -38,7 +38,7 @@ const ThreadPrimitiveViewportFooter = forwardRef((props, forwardedRef) => {
|
|
|
38
38
|
const ref = useComposedRefs(forwardedRef, resizeRef);
|
|
39
39
|
let t0;
|
|
40
40
|
if ($[0] !== props || $[1] !== ref) {
|
|
41
|
-
t0 = /* @__PURE__ */ jsx(Primitive.div, {
|
|
41
|
+
t0 = /* @__PURE__ */ jsx(Primitive$1.div, {
|
|
42
42
|
...props,
|
|
43
43
|
ref
|
|
44
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadViewportFooter.js","names":["c","_c","useComposedRefs","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useCallback","useSizeHandle","useThreadViewport","ThreadPrimitiveViewportFooter","Element","div","Props","props","forwardedRef","$","register","_temp","getHeight","_temp2","resizeRef","ref","t0","displayName","s","registerContentInset","el","marginTop","parseFloat","getComputedStyle","offsetHeight"],"sources":["../../../src/primitives/thread/ThreadViewportFooter.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"
|
|
1
|
+
{"version":3,"file":"ThreadViewportFooter.js","names":["c","_c","useComposedRefs","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useCallback","useSizeHandle","useThreadViewport","ThreadPrimitiveViewportFooter","Element","div","Props","props","forwardedRef","$","register","_temp","getHeight","_temp2","resizeRef","ref","t0","displayName","s","registerContentInset","el","marginTop","parseFloat","getComputedStyle","offsetHeight"],"sources":["../../../src/primitives/thread/ThreadViewportFooter.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n useCallback,\n} from \"react\";\nimport { useSizeHandle } from \"../../utils/hooks/useSizeHandle\";\nimport { useThreadViewport } from \"../../context/react/ThreadViewportContext\";\n\nexport namespace ThreadPrimitiveViewportFooter {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\n/**\n * A footer container that measures its height for scroll calculations.\n *\n * This component measures its height and provides it to the viewport context\n * so the auto-scroll system can account for any sticky footer overlapping the\n * message list.\n *\n * Multiple ViewportFooter components can be used - their heights are summed.\n *\n * Typically used with `className=\"sticky bottom-0\"` to keep the footer\n * visible at the bottom of the viewport while scrolling.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Viewport>\n * <ThreadPrimitive.Messages>\n * {() => <MyMessage />}\n * </ThreadPrimitive.Messages>\n * <ThreadPrimitive.ViewportFooter className=\"sticky bottom-0\">\n * <Composer />\n * </ThreadPrimitive.ViewportFooter>\n * </ThreadPrimitive.Viewport>\n * ```\n */\nexport const ThreadPrimitiveViewportFooter = forwardRef<\n ThreadPrimitiveViewportFooter.Element,\n ThreadPrimitiveViewportFooter.Props\n>((props, forwardedRef) => {\n const register = useThreadViewport((s) => s.registerContentInset);\n const getHeight = useCallback((el: HTMLElement) => {\n const marginTop = parseFloat(getComputedStyle(el).marginTop) || 0;\n return el.offsetHeight + marginTop;\n }, []);\n\n const resizeRef = useSizeHandle(register, getHeight);\n\n const ref = useComposedRefs(forwardedRef, resizeRef);\n\n return <Primitive.div {...props} ref={ref} />;\n});\n\nThreadPrimitiveViewportFooter.displayName = \"ThreadPrimitive.ViewportFooter\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAaU,gCAAgCL,YAG3CS,OAAAC,iBAAA;CAAA,MAAAC,IAAAf,EAAA,CAAA;CACA,MAAAgB,WAAiBR,kBAAkBS,KAA6B;CAMhE,MAAAG,YAAkBb,cAAcS,UAAUE,MAAS;CAEnD,MAAAG,MAAYpB,gBAAgBa,cAAcM,SAAS;CAAE,IAAAE;CAAA,IAAAP,EAAA,OAAAF,SAAAE,EAAA,OAAAM,KAAA;EAE9CC,KAAA,oBAAA,YAAA,KAAA;GAAA,GAAmBT;GAAYQ;EAAG,CAAA;EAAIN,EAAA,KAAAF;EAAAE,EAAA,KAAAM;EAAAN,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OAAtCO;AAAsC,CAC9C;AAEDb,8BAA8Bc,cAAc;AAd1C,SAAAN,MAAAO,GAAA;CAAA,OAC0CA,EAACC;AAAqB;AADhE,SAAAN,OAAAO,IAAA;CAGE,MAAAC,YAAkBC,WAAWC,iBAAiBH,EAAE,CAAC,CAAAC,SAAe,KAA9C;CAAgD,OAC3DD,GAAEI,eAAgBH;AAAS"}
|
|
@@ -6,7 +6,7 @@ import { useManagedRef } from "../../utils/hooks/useManagedRef.js";
|
|
|
6
6
|
import { useOnResizeContent } from "../../utils/hooks/useOnResizeContent.js";
|
|
7
7
|
import { useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
8
8
|
import { useCallback, useLayoutEffect, useRef } from "@assistant-ui/tap/react-shim";
|
|
9
|
-
import { useComposedRefs } from "
|
|
9
|
+
import { useComposedRefs } from "radix-ui/internal";
|
|
10
10
|
import { isUserScrollUp } from "@assistant-ui/store/client";
|
|
11
11
|
//#region src/primitives/thread/useThreadViewportAutoScroll.ts
|
|
12
12
|
const useThreadViewportAutoScroll = ({ autoScroll, scrollToBottomOnRunStart = true, scrollToBottomOnInitialize = true, scrollToBottomOnThreadSwitch = true }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThreadViewportAutoScroll.js","names":["useComposedRefs","useCallback","useLayoutEffect","useRef","RefCallback","useAuiEvent","useAuiState","isUserScrollUp","useOnResizeContent","useOnScrollToBottom","useManagedRef","writableStore","useThreadViewportStore","useThreadViewportAutoScroll","Options","autoScroll","scrollToBottomOnRunStart","scrollToBottomOnInitialize","scrollToBottomOnThreadSwitch","HTMLElement","TElement","divRef","hasMessages","s","thread","messages","length","isRunning","initializeScrollRequestedRef","scheduledFrameRef","threadViewportStore","undefined","getState","turnAnchor","lastScrollTop","lastScrollHeight","lastObservedScrollHeight","lastObservedClientHeight","scrollingToBottomBehaviorRef","ScrollBehavior","followBottomRef","scrollToBottom","behavior","div","current","scrollTo","top","scrollHeight","cancelScheduledFrame","cancelAnimationFrame","scheduleScrollToBottom","requestAnimationFrame","hasActiveTopAnchor","state","element","viewport","anchor","handleScroll","isAtBottom","newIsAtBottom","Math","abs","scrollTop","clientHeight","isInFlightDownwardScroll","userScrolledUp","viewportOverflows","shouldUpdate","setState","resizeRef","scrollBehavior","scrollRef","el","cancelPendingScrollToBottom","addEventListener","removeEventListener","autoScrollRef"],"sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.ts"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { useCallback, useLayoutEffect, useRef, type RefCallback } from \"react\";\nimport { useAuiEvent, useAuiState } from \"@assistant-ui/store\";\nimport { isUserScrollUp } from \"@assistant-ui/store/client\";\nimport { useOnResizeContent } from \"../../utils/hooks/useOnResizeContent\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { writableStore } from \"../../context/ReadonlyStore\";\nimport { useThreadViewportStore } from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadViewportAutoScroll {\n export type Options = {\n /**\n * Whether to automatically scroll to the bottom when new messages are added.\n * When enabled, the viewport will automatically scroll to show the latest content.\n *\n * Default false if `turnAnchor` is \"top\", otherwise defaults to true.\n */\n autoScroll?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when a new run starts.\n *\n * Defaults to true.\n */\n scrollToBottomOnRunStart?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when messages first appear in the thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnInitialize?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when switching to a different thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n };\n}\n\nexport const useThreadViewportAutoScroll = <TElement extends HTMLElement>({\n autoScroll,\n scrollToBottomOnRunStart = true,\n scrollToBottomOnInitialize = true,\n scrollToBottomOnThreadSwitch = true,\n}: useThreadViewportAutoScroll.Options): RefCallback<TElement> => {\n const divRef = useRef<TElement>(null);\n const hasMessages = useAuiState((s) => s.thread.messages.length > 0);\n const isRunning = useAuiState((s) => s.thread.isRunning);\n const initializeScrollRequestedRef = useRef(false);\n const scheduledFrameRef = useRef<number | null>(null);\n\n const threadViewportStore = useThreadViewportStore();\n if (autoScroll === undefined) {\n autoScroll = threadViewportStore.getState().turnAnchor !== \"top\";\n }\n\n const lastScrollTop = useRef<number>(0);\n const lastScrollHeight = useRef<number>(0);\n const lastObservedScrollHeight = useRef<number>(0);\n const lastObservedClientHeight = useRef<number>(0);\n\n // Pending bottom-scroll intent. Planted by initialize/run-start/switch/button\n // triggers, cleared when handleScroll confirms we reached bottom, or when the\n // user actively scrolls up while content size is stable.\n const scrollingToBottomBehaviorRef = useRef<ScrollBehavior | null>(null);\n const followBottomRef = useRef(autoScroll);\n\n const scrollToBottom = useCallback((behavior: ScrollBehavior) => {\n const div = divRef.current;\n if (!div) return;\n\n followBottomRef.current = true;\n scrollingToBottomBehaviorRef.current = behavior;\n div.scrollTo({ top: div.scrollHeight, behavior });\n }, []);\n\n const cancelScheduledFrame = useCallback(() => {\n if (scheduledFrameRef.current === null) return;\n cancelAnimationFrame(scheduledFrameRef.current);\n scheduledFrameRef.current = null;\n }, []);\n\n const scheduleScrollToBottom = useCallback(\n (behavior: ScrollBehavior) => {\n scrollingToBottomBehaviorRef.current = behavior;\n cancelScheduledFrame();\n scheduledFrameRef.current = requestAnimationFrame(() => {\n scheduledFrameRef.current = null;\n scrollToBottom(behavior);\n });\n },\n [cancelScheduledFrame, scrollToBottom],\n );\n\n useLayoutEffect(() => () => cancelScheduledFrame(), [cancelScheduledFrame]);\n\n const hasActiveTopAnchor = useCallback(() => {\n const state = threadViewportStore.getState();\n return (\n state.turnAnchor === \"top\" &&\n state.element.viewport === divRef.current &&\n state.element.anchor !== null\n );\n }, [threadViewportStore]);\n\n const handleScroll = () => {\n const div = divRef.current;\n if (!div) return;\n\n const isAtBottom = threadViewportStore.getState().isAtBottom;\n const newIsAtBottom =\n Math.abs(div.scrollHeight - div.scrollTop - div.clientHeight) <= 1 ||\n div.scrollHeight <= div.clientHeight;\n\n const isInFlightDownwardScroll =\n !newIsAtBottom && lastScrollTop.current < div.scrollTop;\n if (isInFlightDownwardScroll) {\n // no-op: a smooth scroll-to-bottom fires many midpoint scroll events\n // before landing, don't flicker isAtBottom or clear intent mid-animation\n } else {\n const userScrolledUp = isUserScrollUp(\n {\n scrollTop: lastScrollTop.current,\n scrollHeight: lastScrollHeight.current,\n },\n div,\n );\n\n if (newIsAtBottom) {\n // newIsAtBottom is ambiguous when the viewport doesn't overflow —\n // keep intent alive until content can actually scroll\n const viewportOverflows = div.scrollHeight > div.clientHeight + 1;\n if (viewportOverflows) {\n scrollingToBottomBehaviorRef.current = null;\n }\n if (autoScroll) followBottomRef.current = true;\n } else if (userScrolledUp) {\n cancelScheduledFrame();\n scrollingToBottomBehaviorRef.current = null;\n followBottomRef.current = false;\n }\n\n const shouldUpdate =\n newIsAtBottom || scrollingToBottomBehaviorRef.current === null;\n\n if (shouldUpdate && newIsAtBottom !== isAtBottom) {\n writableStore(threadViewportStore).setState({\n isAtBottom: newIsAtBottom,\n });\n }\n }\n\n lastScrollTop.current = div.scrollTop;\n lastScrollHeight.current = div.scrollHeight;\n };\n\n const resizeRef = useOnResizeContent(() => {\n const div = divRef.current;\n if (!div) return;\n\n const { scrollHeight, clientHeight } = div;\n if (\n scrollHeight === lastObservedScrollHeight.current &&\n clientHeight === lastObservedClientHeight.current\n ) {\n return;\n }\n lastObservedScrollHeight.current = scrollHeight;\n lastObservedClientHeight.current = clientHeight;\n\n const scrollBehavior = scrollingToBottomBehaviorRef.current;\n if (scrollBehavior && hasActiveTopAnchor()) {\n // Let the top-anchor reserve own scrolling while a run starts to avoid a bottom-scroll race.\n scrollingToBottomBehaviorRef.current = null;\n } else if (scrollBehavior) {\n scrollToBottom(scrollBehavior);\n } else if (\n autoScroll &&\n !(isRunning && hasActiveTopAnchor()) &&\n followBottomRef.current\n ) {\n scrollToBottom(\"instant\");\n }\n\n handleScroll();\n });\n\n const scrollRef = useManagedRef<HTMLElement>((el) => {\n // A pointer gesture invalidates pending bottom-scroll intent; otherwise an\n // intent kept alive by a non-overflowing thread (see handleScroll) hijacks\n // the next content growth, e.g. expanding a collapsible tool call.\n const cancelPendingScrollToBottom = () => {\n scrollingToBottomBehaviorRef.current = null;\n };\n el.addEventListener(\"scroll\", handleScroll);\n el.addEventListener(\"pointerdown\", cancelPendingScrollToBottom);\n return () => {\n el.removeEventListener(\"scroll\", handleScroll);\n el.removeEventListener(\"pointerdown\", cancelPendingScrollToBottom);\n };\n });\n\n useLayoutEffect(() => {\n if (!scrollToBottomOnInitialize) return;\n if (!hasMessages) {\n initializeScrollRequestedRef.current = false;\n return;\n }\n if (initializeScrollRequestedRef.current) return;\n\n initializeScrollRequestedRef.current = true;\n // defer to an in-flight run (e.g. first message on a new thread) that\n // already planted intent — otherwise we'd downgrade its \"auto\" to \"instant\"\n if (scrollingToBottomBehaviorRef.current !== null) return;\n scheduleScrollToBottom(\"instant\");\n }, [hasMessages, scheduleScrollToBottom, scrollToBottomOnInitialize]);\n\n useOnScrollToBottom(({ behavior }) => {\n scrollToBottom(behavior);\n });\n\n useAuiEvent(\"thread.runStart\", () => {\n if (!scrollToBottomOnRunStart) return;\n if (threadViewportStore.getState().turnAnchor === \"top\") return;\n scheduleScrollToBottom(\"auto\");\n });\n\n useAuiEvent(\"threads.selectionChanged\", () => {\n if (!scrollToBottomOnThreadSwitch) return;\n scheduleScrollToBottom(\"instant\");\n });\n\n const autoScrollRef = useComposedRefs<TElement>(resizeRef, scrollRef, divRef);\n return autoScrollRef as RefCallback<TElement>;\n};\n"],"mappings":";;;;;;;;;;;AA6CA,MAAaa,+BAA6D,EACxEE,YACAC,2BAA2B,MAC3BC,6BAA6B,MAC7BC,+BAA+B,WACiC;CAChE,MAAMG,SAASlB,OAAiB,IAAI;CACpC,MAAMmB,cAAchB,aAAaiB,MAAMA,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iBAAiBhC,6BAA6BM;EACpD,IAAI0B,kBAAkBlB,mBAAmB,GAEvCd,6BAA6BM,UAAU;OAClC,IAAI0B,gBACT7B,eAAe6B,cAAc;OACxB,IACLvD,cACA,EAAEY,aAAayB,mBAAmB,MAClCZ,gBAAgBI,SAEhBH,eAAe,SAAS;EAG1BgB,aAAa;CACf,CAAC;CAED,MAAMc,YAAY7D,eAA4B8D,OAAO;EAInD,MAAMC,oCAAoC;GACxCnC,6BAA6BM,UAAU;EACzC;EACA4B,GAAGE,iBAAiB,UAAUjB,YAAY;EAC1Ce,GAAGE,iBAAiB,eAAeD,2BAA2B;EAC9D,aAAa;GACXD,GAAGG,oBAAoB,UAAUlB,YAAY;GAC7Ce,GAAGG,oBAAoB,eAAeF,2BAA2B;EACnE;CACF,CAAC;CAEDvE,sBAAsB;EACpB,IAAI,CAACe,4BAA4B;EACjC,IAAI,CAACK,aAAa;GAChBM,6BAA6BgB,UAAU;GACvC;EACF;EACA,IAAIhB,6BAA6BgB,SAAS;EAE1ChB,6BAA6BgB,UAAU;EAGvC,IAAIN,6BAA6BM,YAAY,MAAM;EACnDM,uBAAuB,SAAS;CAClC,GAAG;EAAC5B;EAAa4B;EAAwBjC;CAA0B,CAAC;CAEpER,qBAAqB,EAAEiC,UAAAA,iBAAe;EACpCD,eAAeC,UAAQ;CACzB,CAAC;CAEDrC,YAAY,yBAAyB;EACnC,IAAI,CAACW,0BAA0B;EAC/B,IAAIc,oBAAoBE,SAAS,CAAC,CAACC,eAAe,OAAO;EACzDiB,uBAAuB,MAAM;CAC/B,CAAC;CAED7C,YAAY,kCAAkC;EAC5C,IAAI,CAACa,8BAA8B;EACnCgC,uBAAuB,SAAS;CAClC,CAAC;CAGD,OADsBlD,gBAA0BqE,WAAWE,WAAWlD,MAC/DuD;AACT"}
|
|
1
|
+
{"version":3,"file":"useThreadViewportAutoScroll.js","names":["useComposedRefs","useCallback","useLayoutEffect","useRef","RefCallback","useAuiEvent","useAuiState","isUserScrollUp","useOnResizeContent","useOnScrollToBottom","useManagedRef","writableStore","useThreadViewportStore","useThreadViewportAutoScroll","Options","autoScroll","scrollToBottomOnRunStart","scrollToBottomOnInitialize","scrollToBottomOnThreadSwitch","HTMLElement","TElement","divRef","hasMessages","s","thread","messages","length","isRunning","initializeScrollRequestedRef","scheduledFrameRef","threadViewportStore","undefined","getState","turnAnchor","lastScrollTop","lastScrollHeight","lastObservedScrollHeight","lastObservedClientHeight","scrollingToBottomBehaviorRef","ScrollBehavior","followBottomRef","scrollToBottom","behavior","div","current","scrollTo","top","scrollHeight","cancelScheduledFrame","cancelAnimationFrame","scheduleScrollToBottom","requestAnimationFrame","hasActiveTopAnchor","state","element","viewport","anchor","handleScroll","isAtBottom","newIsAtBottom","Math","abs","scrollTop","clientHeight","isInFlightDownwardScroll","userScrolledUp","viewportOverflows","shouldUpdate","setState","resizeRef","scrollBehavior","scrollRef","el","cancelPendingScrollToBottom","addEventListener","removeEventListener","autoScrollRef"],"sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.ts"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { useCallback, useLayoutEffect, useRef, type RefCallback } from \"react\";\nimport { useAuiEvent, useAuiState } from \"@assistant-ui/store\";\nimport { isUserScrollUp } from \"@assistant-ui/store/client\";\nimport { useOnResizeContent } from \"../../utils/hooks/useOnResizeContent\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { writableStore } from \"../../context/ReadonlyStore\";\nimport { useThreadViewportStore } from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadViewportAutoScroll {\n export type Options = {\n /**\n * Whether to automatically scroll to the bottom when new messages are added.\n * When enabled, the viewport will automatically scroll to show the latest content.\n *\n * Default false if `turnAnchor` is \"top\", otherwise defaults to true.\n */\n autoScroll?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when a new run starts.\n *\n * Defaults to true.\n */\n scrollToBottomOnRunStart?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when messages first appear in the thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnInitialize?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when switching to a different thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n };\n}\n\nexport const useThreadViewportAutoScroll = <TElement extends HTMLElement>({\n autoScroll,\n scrollToBottomOnRunStart = true,\n scrollToBottomOnInitialize = true,\n scrollToBottomOnThreadSwitch = true,\n}: useThreadViewportAutoScroll.Options): RefCallback<TElement> => {\n const divRef = useRef<TElement>(null);\n const hasMessages = useAuiState((s) => s.thread.messages.length > 0);\n const isRunning = useAuiState((s) => s.thread.isRunning);\n const initializeScrollRequestedRef = useRef(false);\n const scheduledFrameRef = useRef<number | null>(null);\n\n const threadViewportStore = useThreadViewportStore();\n if (autoScroll === undefined) {\n autoScroll = threadViewportStore.getState().turnAnchor !== \"top\";\n }\n\n const lastScrollTop = useRef<number>(0);\n const lastScrollHeight = useRef<number>(0);\n const lastObservedScrollHeight = useRef<number>(0);\n const lastObservedClientHeight = useRef<number>(0);\n\n // Pending bottom-scroll intent. Planted by initialize/run-start/switch/button\n // triggers, cleared when handleScroll confirms we reached bottom, or when the\n // user actively scrolls up while content size is stable.\n const scrollingToBottomBehaviorRef = useRef<ScrollBehavior | null>(null);\n const followBottomRef = useRef(autoScroll);\n\n const scrollToBottom = useCallback((behavior: ScrollBehavior) => {\n const div = divRef.current;\n if (!div) return;\n\n followBottomRef.current = true;\n scrollingToBottomBehaviorRef.current = behavior;\n div.scrollTo({ top: div.scrollHeight, behavior });\n }, []);\n\n const cancelScheduledFrame = useCallback(() => {\n if (scheduledFrameRef.current === null) return;\n cancelAnimationFrame(scheduledFrameRef.current);\n scheduledFrameRef.current = null;\n }, []);\n\n const scheduleScrollToBottom = useCallback(\n (behavior: ScrollBehavior) => {\n scrollingToBottomBehaviorRef.current = behavior;\n cancelScheduledFrame();\n scheduledFrameRef.current = requestAnimationFrame(() => {\n scheduledFrameRef.current = null;\n scrollToBottom(behavior);\n });\n },\n [cancelScheduledFrame, scrollToBottom],\n );\n\n useLayoutEffect(() => () => cancelScheduledFrame(), [cancelScheduledFrame]);\n\n const hasActiveTopAnchor = useCallback(() => {\n const state = threadViewportStore.getState();\n return (\n state.turnAnchor === \"top\" &&\n state.element.viewport === divRef.current &&\n state.element.anchor !== null\n );\n }, [threadViewportStore]);\n\n const handleScroll = () => {\n const div = divRef.current;\n if (!div) return;\n\n const isAtBottom = threadViewportStore.getState().isAtBottom;\n const newIsAtBottom =\n Math.abs(div.scrollHeight - div.scrollTop - div.clientHeight) <= 1 ||\n div.scrollHeight <= div.clientHeight;\n\n const isInFlightDownwardScroll =\n !newIsAtBottom && lastScrollTop.current < div.scrollTop;\n if (isInFlightDownwardScroll) {\n // no-op: a smooth scroll-to-bottom fires many midpoint scroll events\n // before landing, don't flicker isAtBottom or clear intent mid-animation\n } else {\n const userScrolledUp = isUserScrollUp(\n {\n scrollTop: lastScrollTop.current,\n scrollHeight: lastScrollHeight.current,\n },\n div,\n );\n\n if (newIsAtBottom) {\n // newIsAtBottom is ambiguous when the viewport doesn't overflow —\n // keep intent alive until content can actually scroll\n const viewportOverflows = div.scrollHeight > div.clientHeight + 1;\n if (viewportOverflows) {\n scrollingToBottomBehaviorRef.current = null;\n }\n if (autoScroll) followBottomRef.current = true;\n } else if (userScrolledUp) {\n cancelScheduledFrame();\n scrollingToBottomBehaviorRef.current = null;\n followBottomRef.current = false;\n }\n\n const shouldUpdate =\n newIsAtBottom || scrollingToBottomBehaviorRef.current === null;\n\n if (shouldUpdate && newIsAtBottom !== isAtBottom) {\n writableStore(threadViewportStore).setState({\n isAtBottom: newIsAtBottom,\n });\n }\n }\n\n lastScrollTop.current = div.scrollTop;\n lastScrollHeight.current = div.scrollHeight;\n };\n\n const resizeRef = useOnResizeContent(() => {\n const div = divRef.current;\n if (!div) return;\n\n const { scrollHeight, clientHeight } = div;\n if (\n scrollHeight === lastObservedScrollHeight.current &&\n clientHeight === lastObservedClientHeight.current\n ) {\n return;\n }\n lastObservedScrollHeight.current = scrollHeight;\n lastObservedClientHeight.current = clientHeight;\n\n const scrollBehavior = scrollingToBottomBehaviorRef.current;\n if (scrollBehavior && hasActiveTopAnchor()) {\n // Let the top-anchor reserve own scrolling while a run starts to avoid a bottom-scroll race.\n scrollingToBottomBehaviorRef.current = null;\n } else if (scrollBehavior) {\n scrollToBottom(scrollBehavior);\n } else if (\n autoScroll &&\n !(isRunning && hasActiveTopAnchor()) &&\n followBottomRef.current\n ) {\n scrollToBottom(\"instant\");\n }\n\n handleScroll();\n });\n\n const scrollRef = useManagedRef<HTMLElement>((el) => {\n // A pointer gesture invalidates pending bottom-scroll intent; otherwise an\n // intent kept alive by a non-overflowing thread (see handleScroll) hijacks\n // the next content growth, e.g. expanding a collapsible tool call.\n const cancelPendingScrollToBottom = () => {\n scrollingToBottomBehaviorRef.current = null;\n };\n el.addEventListener(\"scroll\", handleScroll);\n el.addEventListener(\"pointerdown\", cancelPendingScrollToBottom);\n return () => {\n el.removeEventListener(\"scroll\", handleScroll);\n el.removeEventListener(\"pointerdown\", cancelPendingScrollToBottom);\n };\n });\n\n useLayoutEffect(() => {\n if (!scrollToBottomOnInitialize) return;\n if (!hasMessages) {\n initializeScrollRequestedRef.current = false;\n return;\n }\n if (initializeScrollRequestedRef.current) return;\n\n initializeScrollRequestedRef.current = true;\n // defer to an in-flight run (e.g. first message on a new thread) that\n // already planted intent — otherwise we'd downgrade its \"auto\" to \"instant\"\n if (scrollingToBottomBehaviorRef.current !== null) return;\n scheduleScrollToBottom(\"instant\");\n }, [hasMessages, scheduleScrollToBottom, scrollToBottomOnInitialize]);\n\n useOnScrollToBottom(({ behavior }) => {\n scrollToBottom(behavior);\n });\n\n useAuiEvent(\"thread.runStart\", () => {\n if (!scrollToBottomOnRunStart) return;\n if (threadViewportStore.getState().turnAnchor === \"top\") return;\n scheduleScrollToBottom(\"auto\");\n });\n\n useAuiEvent(\"threads.selectionChanged\", () => {\n if (!scrollToBottomOnThreadSwitch) return;\n scheduleScrollToBottom(\"instant\");\n });\n\n const autoScrollRef = useComposedRefs<TElement>(resizeRef, scrollRef, divRef);\n return autoScrollRef as RefCallback<TElement>;\n};\n"],"mappings":";;;;;;;;;;;AA6CA,MAAaa,+BAA6D,EACxEE,YACAC,2BAA2B,MAC3BC,6BAA6B,MAC7BC,+BAA+B,WACiC;CAChE,MAAMG,SAASlB,OAAiB,IAAI;CACpC,MAAMmB,cAAchB,aAAaiB,MAAMA,EAAEC,OAAOC,SAASC,SAAS,CAAC;CACnE,MAAMC,YAAYrB,aAAaiB,QAAMA,IAAEC,OAAOG,SAAS;CACvD,MAAMC,+BAA+BzB,OAAO,KAAK;CACjD,MAAM0B,oBAAoB1B,OAAsB,IAAI;CAEpD,MAAM2B,sBAAsBlB,uBAAuB;CACnD,IAAIG,eAAegB,KAAAA,GACjBhB,aAAae,oBAAoBE,SAAS,CAAC,CAACC,eAAe;CAG7D,MAAMC,gBAAgB/B,OAAe,CAAC;CACtC,MAAMgC,mBAAmBhC,OAAe,CAAC;CACzC,MAAMiC,2BAA2BjC,OAAe,CAAC;CACjD,MAAMkC,2BAA2BlC,OAAe,CAAC;CAKjD,MAAMmC,+BAA+BnC,OAA8B,IAAI;CACvE,MAAMqC,kBAAkBrC,OAAOY,UAAU;CAEzC,MAAM0B,iBAAiBxC,aAAayC,aAA6B;EAC/D,MAAMC,MAAMtB,OAAOuB;EACnB,IAAI,CAACD,KAAK;EAEVH,gBAAgBI,UAAU;EAC1BN,6BAA6BM,UAAUF;EACvCC,IAAIE,SAAS;GAAEC,KAAKH,IAAII;GAAcL;EAAS,CAAC;CAClD,GAAG,CAAA,CAAE;CAEL,MAAMM,uBAAuB/C,kBAAkB;EAC7C,IAAI4B,kBAAkBe,YAAY,MAAM;EACxCK,qBAAqBpB,kBAAkBe,OAAO;EAC9Cf,kBAAkBe,UAAU;CAC9B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AI,CAACW,0BAA0B;EAC/B,IAAIc,oBAAoBE,SAAS,CAAC,CAACC,eAAe,OAAO;EACzDiB,uBAAuB,MAAM;CAC/B,CAAC;CAED7C,YAAY,kCAAkC;EAC5C,IAAI,CAACa,8BAA8B;EACnCgC,uBAAuB,SAAS;CAClC,CAAC;CAGD,OADsBlD,gBAA0BqE,WAAWE,WAAWlD,MAC/DuD;AACT"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Primitive } from "../../utils/Primitive.js";
|
|
2
|
+
import { Primitive as Primitive$1 } from "../../utils/Primitive.js";
|
|
3
3
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
4
|
import { useThreadListNew } from "@assistant-ui/core/react";
|
|
5
5
|
import { useAuiState } from "@assistant-ui/store";
|
|
6
6
|
import { forwardRef } from "@assistant-ui/tap/react-shim";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import { composeEventHandlers } from "
|
|
8
|
+
import { composeEventHandlers } from "radix-ui/internal";
|
|
9
9
|
//#region src/primitives/threadList/ThreadListNew.tsx
|
|
10
10
|
const ThreadListPrimitiveNew = forwardRef((t0, forwardedRef) => {
|
|
11
11
|
const $ = c(15);
|
|
@@ -43,7 +43,7 @@ const ThreadListPrimitiveNew = forwardRef((t0, forwardedRef) => {
|
|
|
43
43
|
} else t2 = $[8];
|
|
44
44
|
let t3;
|
|
45
45
|
if ($[9] !== disabled || $[10] !== forwardedRef || $[11] !== props || $[12] !== t1 || $[13] !== t2) {
|
|
46
|
-
t3 = /* @__PURE__ */ jsx(Primitive.button, {
|
|
46
|
+
t3 = /* @__PURE__ */ jsx(Primitive$1.button, {
|
|
47
47
|
type: "button",
|
|
48
48
|
...t1,
|
|
49
49
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListNew.js","names":["c","_c","ActionButtonElement","ActionButtonProps","forwardRef","Primitive","composeEventHandlers","useAuiState","useThreadListNew","useThreadListNewBehavior","ThreadListPrimitiveNew","Element","Props","t0","forwardedRef","$","disabled","onClick","props","isMain","_temp","switchToNewThread","t1","t2","t3","displayName","s","threads","newThreadId","mainThreadId"],"sources":["../../../src/primitives/threadList/ThreadListNew.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n ActionButtonElement,\n ActionButtonProps,\n} from \"../../utils/createActionButton\";\nimport { forwardRef } from \"react\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { composeEventHandlers } from \"
|
|
1
|
+
{"version":3,"file":"ThreadListNew.js","names":["c","_c","ActionButtonElement","ActionButtonProps","forwardRef","Primitive","composeEventHandlers","useAuiState","useThreadListNew","useThreadListNewBehavior","ThreadListPrimitiveNew","Element","Props","t0","forwardedRef","$","disabled","onClick","props","isMain","_temp","switchToNewThread","t1","t2","t3","displayName","s","threads","newThreadId","mainThreadId"],"sources":["../../../src/primitives/threadList/ThreadListNew.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n ActionButtonElement,\n ActionButtonProps,\n} from \"../../utils/createActionButton\";\nimport { forwardRef } from \"react\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useThreadListNew as useThreadListNewBehavior } from \"@assistant-ui/core/react\";\n\nexport namespace ThreadListPrimitiveNew {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<() => void>;\n}\n\nexport const ThreadListPrimitiveNew = forwardRef<\n ThreadListPrimitiveNew.Element,\n ThreadListPrimitiveNew.Props\n>(({ onClick, disabled, ...props }, forwardedRef) => {\n const isMain = useAuiState(\n (s) => s.threads.newThreadId === s.threads.mainThreadId,\n );\n\n const { switchToNewThread } = useThreadListNewBehavior();\n\n return (\n <Primitive.button\n type=\"button\"\n {...(isMain ? { \"data-active\": \"true\", \"aria-current\": \"true\" } : null)}\n {...props}\n ref={forwardedRef}\n disabled={disabled}\n onClick={composeEventHandlers(onClick, switch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AAA,MAAAQ;EAAAR,EAAA,MAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,OAPFS;AAOE,CAEL;AAEDd,uBAAuBe,cAAc;AAnBnC,SAAAL,MAAAM,GAAA;CAAA,OAESA,EAACC,QAAQC,gBAAiBF,EAACC,QAAQE;AAAa"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RefObject } from "react";
|
|
2
|
+
import { Collection } from "radix-ui/internal";
|
|
2
3
|
//#region src/primitives/threadListFocusGroup.d.ts
|
|
3
4
|
declare const useThreadListCollection: (scope: any) => () => {
|
|
4
5
|
ref: RefObject<HTMLButtonElement | null>;
|
|
@@ -8,7 +9,7 @@ declare const ThreadListCollection: {
|
|
|
8
9
|
children?: React.ReactNode;
|
|
9
10
|
scope: any;
|
|
10
11
|
}>;
|
|
11
|
-
readonly Slot: React.ForwardRefExoticComponent<
|
|
12
|
+
readonly Slot: React.ForwardRefExoticComponent<Collection.CollectionProps & React.RefAttributes<HTMLElement>>;
|
|
12
13
|
readonly ItemSlot: import("react").ForwardRefExoticComponent<{
|
|
13
14
|
children: React.ReactNode;
|
|
14
15
|
scope: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threadListFocusGroup.d.ts","names":[],"sources":["../../src/primitives/threadListFocusGroup.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"threadListFocusGroup.d.ts","names":[],"sources":["../../src/primitives/threadListFocusGroup.ts"],"mappings":";;;cAKmB,0BAAuB;OAAvB,UAAA;;cAGN;;IAKmB,WAAC,MAAA;;;;;;;;;KAF5B;EACH,YAAY,UAAU;EACtB,SAAS,UAAU;;cAOR,6CAA2B,SAAA;cAE3B,8BAA6B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, useContext } from "@assistant-ui/tap/react-shim";
|
|
3
|
-
import {
|
|
3
|
+
import { Collection } from "radix-ui/internal";
|
|
4
4
|
//#region src/primitives/threadListFocusGroup.ts
|
|
5
|
-
const [collection, useThreadListCollection] = createCollection("ThreadList");
|
|
5
|
+
const [collection, useThreadListCollection] = Collection.createCollection("ThreadList");
|
|
6
6
|
const ThreadListCollection = collection;
|
|
7
7
|
const ThreadListItemFocusContext = createContext(null);
|
|
8
8
|
const ThreadListItemFocusProvider = ThreadListItemFocusContext.Provider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threadListFocusGroup.js","names":["
|
|
1
|
+
{"version":3,"file":"threadListFocusGroup.js","names":["Collection","createContext","useContext","RefObject","collection","useThreadListCollection","createCollection","HTMLButtonElement","ThreadListCollection","ThreadListItemFocus","triggerRef","moreRef","ThreadListItemFocusContext","ThreadListItemFocusProvider","Provider","useThreadListItemFocus"],"sources":["../../src/primitives/threadListFocusGroup.ts"],"sourcesContent":["\"use client\";\n\nimport { Collection } from \"radix-ui/internal\";\nimport { createContext, useContext, type RefObject } from \"react\";\n\nconst [collection, useThreadListCollection] =\n Collection.createCollection<HTMLButtonElement>(\"ThreadList\");\n\nexport const ThreadListCollection = collection;\nexport { useThreadListCollection };\n\ntype ThreadListItemFocus = {\n triggerRef: RefObject<HTMLButtonElement | null>;\n moreRef: RefObject<HTMLButtonElement | null>;\n};\n\nconst ThreadListItemFocusContext = createContext<ThreadListItemFocus | null>(\n null,\n);\n\nexport const ThreadListItemFocusProvider = ThreadListItemFocusContext.Provider;\n\nexport const useThreadListItemFocus = (): ThreadListItemFocus | null =>\n useContext(ThreadListItemFocusContext);\n"],"mappings":";;;;AAKA,MAAM,CAACI,YAAYC,2BACjBL,WAAWM,iBAAoC,YAAY;AAE7D,MAAaE,uBAAuBJ;AAQpC,MAAMQ,6BAA6BX,cACjC,IACF;AAEA,MAAaY,8BAA8BD,2BAA2BE;AAEtE,MAAaC,+BAAyB;CAAA,OACpCb,WAAWU,0BAA0B;AAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Primitive } from "../../utils/Primitive.js";
|
|
2
|
+
import { Primitive as Primitive$1 } from "../../utils/Primitive.js";
|
|
3
3
|
import { ThreadListItemFocusProvider, useThreadListCollection } from "../threadListFocusGroup.js";
|
|
4
4
|
import { useAuiState } from "@assistant-ui/store";
|
|
5
5
|
import { forwardRef, useMemo, useRef } from "@assistant-ui/tap/react-shim";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import { composeEventHandlers } from "
|
|
7
|
+
import { composeEventHandlers } from "radix-ui/internal";
|
|
8
8
|
import { Direction } from "radix-ui";
|
|
9
9
|
//#region src/primitives/threadListItem/ThreadListItemRoot.tsx
|
|
10
10
|
const ThreadListItemPrimitiveRoot = forwardRef((props, ref) => {
|
|
@@ -41,7 +41,7 @@ const ThreadListItemPrimitiveRoot = forwardRef((props, ref) => {
|
|
|
41
41
|
};
|
|
42
42
|
return /* @__PURE__ */ jsx(ThreadListItemFocusProvider, {
|
|
43
43
|
value: focus,
|
|
44
|
-
children: /* @__PURE__ */ jsx(Primitive.div, {
|
|
44
|
+
children: /* @__PURE__ */ jsx(Primitive$1.div, {
|
|
45
45
|
...isMain ? {
|
|
46
46
|
"data-active": "true",
|
|
47
47
|
"aria-current": "true"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListItemRoot.js","names":["Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","KeyboardEvent","useMemo","useRef","useAuiState","composeEventHandlers","Direction","ThreadListItemFocusProvider","useThreadListCollection","PrimitiveDivProps","div","ThreadListItemPrimitiveRoot","Element","Props","props","ref","isMain","s","threads","mainThreadId","threadListItem","id","triggerRef","HTMLButtonElement","moreRef","focus","getItems","undefined","direction","useDirection","onKeyDown","event","HTMLDivElement","forwardKey","backKey","trigger","current","more","target","key","triggers","map","item","filter","node","next","indexOf","preventDefault","displayName"],"sources":["../../../src/primitives/threadListItem/ThreadListItemRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type KeyboardEvent,\n useMemo,\n useRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { composeEventHandlers } from \"
|
|
1
|
+
{"version":3,"file":"ThreadListItemRoot.js","names":["Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","KeyboardEvent","useMemo","useRef","useAuiState","composeEventHandlers","Direction","ThreadListItemFocusProvider","useThreadListCollection","PrimitiveDivProps","div","ThreadListItemPrimitiveRoot","Element","Props","props","ref","isMain","s","threads","mainThreadId","threadListItem","id","triggerRef","HTMLButtonElement","moreRef","focus","getItems","undefined","direction","useDirection","onKeyDown","event","HTMLDivElement","forwardKey","backKey","trigger","current","more","target","key","triggers","map","item","filter","node","next","indexOf","preventDefault","displayName"],"sources":["../../../src/primitives/threadListItem/ThreadListItemRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type KeyboardEvent,\n useMemo,\n useRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { Direction } from \"radix-ui\";\nimport {\n ThreadListItemFocusProvider,\n useThreadListCollection,\n} from \"../threadListFocusGroup\";\n\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport namespace ThreadListItemPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = PrimitiveDivProps;\n}\n\nexport const ThreadListItemPrimitiveRoot = forwardRef<\n ThreadListItemPrimitiveRoot.Element,\n ThreadListItemPrimitiveRoot.Props\n>((props, ref) => {\n const isMain = useAuiState(\n (s) => s.threads.mainThreadId === s.threadListItem.id,\n );\n\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const moreRef = useRef<HTMLButtonElement | null>(null);\n const focus = useMemo(() => ({ triggerRef, moreRef }), []);\n\n const getItems = useThreadListCollection(undefined);\n const direction = Direction.useDirection();\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const forwardKey = direction === \"rtl\" ? \"ArrowLeft\" : \"ArrowRight\";\n const backKey = direction === \"rtl\" ? \"ArrowRight\" : \"ArrowLeft\";\n const trigger = triggerRef.current;\n const more = moreRef.current;\n\n if (trigger && event.target === trigger) {\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n const triggers = getItems()\n .map((item) => item.ref.current)\n .filter((node): node is HTMLButtonElement => node !== null);\n const next =\n triggers[\n triggers.indexOf(trigger) + (event.key === \"ArrowDown\" ? 1 : -1)\n ];\n if (next) {\n next.focus();\n event.preventDefault();\n }\n } else if (event.key === forwardKey && more) {\n more.focus();\n event.preventDefault();\n }\n } else if (more && event.target === more && event.key === backKey) {\n trigger?.focus();\n event.preventDefault();\n }\n };\n\n return (\n <ThreadListItemFocusProvider value={focus}>\n <Primitive.div\n {...(isMain ? { \"data-active\": \"true\", \"aria-current\": \"true\" } : null)}\n {...props}\n onKeyDown={composeEventHandlers(props.onKeyDown, onKeyDown)}\n ref={ref}\n />\n </ThreadListItemFocusProvider>\n );\n});\n\nThreadListItemPrimitiveRoot.displayName = \"ThreadListItemPrimitive.Root\";\n"],"mappings":";;;;;;;;;AA0BA,MAAac,8BAA8BZ,YAGxCe,OAAOC,QAAQ;CAChB,MAAMC,SAASZ,aACZa,MAAMA,EAAEC,QAAQC,iBAAiBF,EAAEG,eAAeC,EACrD;CAEA,MAAMC,aAAanB,OAAiC,IAAI;CACxD,MAAMqB,UAAUrB,OAAiC,IAAI;CACrD,MAAMsB,QAAQvB,eAAe;EAAEoB;EAAYE;CAAQ,IAAI,CAAA,CAAE;CAEzD,MAAME,WAAWlB,wBAAwBmB,KAAAA,CAAS;CAClD,MAAMC,YAAYtB,UAAUuB,aAAa;CAEzC,MAAMC,aAAaC,UAAyC;EAC1D,MAAME,aAAaL,cAAc,QAAQ,cAAc;EACvD,MAAMM,UAAUN,cAAc,QAAQ,eAAe;EACrD,MAAMO,UAAUb,WAAWc;EAC3B,MAAMC,OAAOb,QAAQY;EAErB,IAAID,WAAWJ,MAAMO,WAAWH,SAAS;GACvC,IAAIJ,MAAMQ,QAAQ,eAAeR,MAAMQ,QAAQ,WAAW;IACxD,MAAMC,WAAWd,SAAS,CAAC,CACxBe,KAAKC,SAASA,KAAK3B,IAAIqB,OAAO,CAAC,CAC/BO,QAAQC,SAAoCA,SAAS,IAAI;IAC5D,MAAMC,OACJL,SACEA,SAASM,QAAQX,OAAO,KAAKJ,MAAMQ,QAAQ,cAAc,IAAI;IAEjE,IAAIM,MAAM;KACRA,KAAKpB,MAAM;KACXM,MAAMgB,eAAe;IACvB;GACF,OAAO,IAAIhB,MAAMQ,QAAQN,cAAcI,MAAM;IAC3CA,KAAKZ,MAAM;IACXM,MAAMgB,eAAe;GACvB;EACF,OAAO,IAAIV,QAAQN,MAAMO,WAAWD,QAAQN,MAAMQ,QAAQL,SAAS;GACjEC,SAASV,MAAM;GACfM,MAAMgB,eAAe;EACvB;CACF;CAEA,OACE,oBAAC,6BAAD;EAA6B,OAAOtB;EAClC,UAAA,oBAAC,YAAU,KAAX;GACE,GAAKT,SAAS;IAAE,eAAe;IAAQ,gBAAgB;GAAO,IAAI;GAClE,GAAIF;GACJ,WAAWT,qBAAqBS,MAAMgB,WAAWA,SAAS;GACrDf;EAAI,CAAA;CAEgB,CAAA;AAEjC,CAAC;AAEDJ,4BAA4BqC,cAAc"}
|
|
@@ -5,7 +5,7 @@ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
|
5
5
|
import { useThreadListItemTrigger } from "@assistant-ui/core/react";
|
|
6
6
|
import { forwardRef } from "@assistant-ui/tap/react-shim";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import { useComposedRefs } from "
|
|
8
|
+
import { useComposedRefs } from "radix-ui/internal";
|
|
9
9
|
//#region src/primitives/threadListItem/ThreadListItemTrigger.tsx
|
|
10
10
|
const useThreadListItemTrigger$1 = () => {
|
|
11
11
|
const { switchTo } = useThreadListItemTrigger();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListItemTrigger.js","names":["c","_c","forwardRef","useComposedRefs","ActionButtonElement","ActionButtonProps","createActionButton","useThreadListItemTrigger","useThreadListItemTriggerBehavior","ThreadListCollection","useThreadListItemFocus","switchTo","ThreadListItemPrimitiveTrigger","Element","Props","ThreadListItemTriggerButton","props","forwardedRef","$","focus","ref","triggerRef","t0","undefined","displayName"],"sources":["../../../src/primitives/threadListItem/ThreadListItemTrigger.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\nimport { useComposedRefs } from \"
|
|
1
|
+
{"version":3,"file":"ThreadListItemTrigger.js","names":["c","_c","forwardRef","useComposedRefs","ActionButtonElement","ActionButtonProps","createActionButton","useThreadListItemTrigger","useThreadListItemTriggerBehavior","ThreadListCollection","useThreadListItemFocus","switchTo","ThreadListItemPrimitiveTrigger","Element","Props","ThreadListItemTriggerButton","props","forwardedRef","$","focus","ref","triggerRef","t0","undefined","displayName"],"sources":["../../../src/primitives/threadListItem/ThreadListItemTrigger.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadListItemTrigger as useThreadListItemTriggerBehavior } from \"@assistant-ui/core/react\";\nimport {\n ThreadListCollection,\n useThreadListItemFocus,\n} from \"../threadListFocusGroup\";\n\nconst useThreadListItemTrigger = () => {\n const { switchTo } = useThreadListItemTriggerBehavior();\n return switchTo;\n};\n\nexport namespace ThreadListItemPrimitiveTrigger {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadListItemTrigger>;\n}\n\nconst ThreadListItemTriggerButton = createActionButton(\n \"ThreadListItemPrimitive.Trigger\",\n useThreadListItemTrigger,\n);\n\nexport const ThreadListItemPrimitiveTrigger = forwardRef<\n ThreadListItemPrimitiveTrigger.Element,\n ThreadListItemPrimitiveTrigger.Props\n>((props, forwardedRef) => {\n const focus = useThreadListItemFocus();\n const ref = useComposedRefs(forwardedRef, focus?.triggerRef);\n\n return (\n <ThreadListCollection.ItemSlot scope={undefined}>\n <ThreadListItemTriggerButton {...props} ref={ref} />\n </ThreadListCollection.ItemSlot>\n );\n});\n\nThreadListItemPrimitiveTrigger.displayName = \"ThreadListItemPrimitive.Trigger\";\n"],"mappings":";;;;;;;;;AAeA,MAAMO,mCAA2B;CAC/B,MAAA,EAAAI,aAAqBH,yBAAiC;CAAE,OACjDG;AAAQ;AAQjB,MAAMI,8BAA8BT,mBAClC,mCACAC,0BACF;AAEA,MAAaK,iCAAiCV,YAG5Cc,OAAAC,iBAAA;CAAA,MAAAC,IAAAjB,EAAA,CAAA;CACA,MAAAkB,QAAcT,uBAAuB;CACrC,MAAAU,MAAYjB,gBAAgBc,cAAcE,OAAKE,UAAY;CAAE,IAAAC;CAAA,IAAAJ,EAAA,OAAAF,SAAAE,EAAA,OAAAE,KAAA;EAG3DE,KAAA,oBAAA,qBAAA,UAAA;GAAsCC,OAAAA,KAAAA;GACpC,UAAA,oBAAC,6BAAD;IAA4B,GAAKP;IAAYI;GAAG,CAAA;EAClD,CAAA;EAAgCF,EAAA,KAAAF;EAAAE,EAAA,KAAAE;EAAAF,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OAFhCI;AAEgC,CAEnC;AAEDV,+BAA+BY,cAAc"}
|
|
@@ -6,7 +6,7 @@ import { useThreadListItemMoreSetOpen, useThreadListItemMoreSharedFocusGroup } f
|
|
|
6
6
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
7
7
|
import { forwardRef } from "@assistant-ui/tap/react-shim";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
import { composeEventHandlers } from "
|
|
9
|
+
import { composeEventHandlers } from "radix-ui/internal";
|
|
10
10
|
import { Direction, DropdownMenu } from "radix-ui";
|
|
11
11
|
//#region src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx
|
|
12
12
|
const ThreadListItemMorePrimitiveContent = forwardRef((t0, forwardedRef) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListItemMoreContent.js","names":["c","_c","ComponentPropsWithoutRef","ComponentRef","forwardRef","Direction","DropdownMenu","DropdownMenuPrimitive","composeEventHandlers","WithRenderPropProps","DropdownMenuRenderContent","useThreadListItemFocus","useThreadListItemMoreSharedFocusGroup","useThreadListItemMoreSetOpen","ScopedProps","useDropdownMenuScope","ThreadListItemMorePrimitiveContent","Element","Content","Props","portalProps","Portal","t0","forwardedRef","$","__scopeThreadListItemMore","sideOffset","t1","props","undefined","scope","setOpen","focus","sharedFocusGroup","direction","useDirection","closeKey","t2","T0","t3","moreRef","event","key","preventDefault","current","t4","onKeyDown","t5","t6","onEscapeKeyDown","t7","t8","displayName"],"sources":["../../../src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Direction, DropdownMenu as DropdownMenuPrimitive } from \"radix-ui\";\nimport { composeEventHandlers } from \"
|
|
1
|
+
{"version":3,"file":"ThreadListItemMoreContent.js","names":["c","_c","ComponentPropsWithoutRef","ComponentRef","forwardRef","Direction","DropdownMenu","DropdownMenuPrimitive","composeEventHandlers","WithRenderPropProps","DropdownMenuRenderContent","useThreadListItemFocus","useThreadListItemMoreSharedFocusGroup","useThreadListItemMoreSetOpen","ScopedProps","useDropdownMenuScope","ThreadListItemMorePrimitiveContent","Element","Content","Props","portalProps","Portal","t0","forwardedRef","$","__scopeThreadListItemMore","sideOffset","t1","props","undefined","scope","setOpen","focus","sharedFocusGroup","direction","useDirection","closeKey","t2","T0","t3","moreRef","event","key","preventDefault","current","t4","onKeyDown","t5","t6","onEscapeKeyDown","t7","t8","displayName"],"sources":["../../../src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Direction, DropdownMenu as DropdownMenuPrimitive } from \"radix-ui\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport type { WithRenderPropProps } from \"../../utils/Primitive\";\nimport { DropdownMenuRenderContent } from \"../dropdownMenuRenderPrimitives\";\nimport { useThreadListItemFocus } from \"../threadListFocusGroup\";\nimport {\n useThreadListItemMoreSharedFocusGroup,\n useThreadListItemMoreSetOpen,\n} from \"./ThreadListItemMoreRoot\";\nimport { type ScopedProps, useDropdownMenuScope } from \"./scope\";\n\nexport namespace ThreadListItemMorePrimitiveContent {\n export type Element = ComponentRef<typeof DropdownMenuPrimitive.Content>;\n export type Props = WithRenderPropProps<\n typeof DropdownMenuPrimitive.Content\n > & {\n portalProps?:\n | ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Portal>\n | undefined;\n };\n}\n\nexport const ThreadListItemMorePrimitiveContent = forwardRef<\n ThreadListItemMorePrimitiveContent.Element,\n ThreadListItemMorePrimitiveContent.Props\n>(\n (\n {\n __scopeThreadListItemMore,\n portalProps,\n sideOffset = 4,\n ...props\n }: ScopedProps<ThreadListItemMorePrimitiveContent.Props>,\n forwardedRef,\n ) => {\n const scope = useDropdownMenuScope(__scopeThreadListItemMore);\n const setOpen = useThreadListItemMoreSetOpen();\n const focus = useThreadListItemFocus();\n const sharedFocusGroup = useThreadListItemMoreSharedFocusGroup();\n const direction = Direction.useDirection();\n const closeKey = direction === \"rtl\" ? \"ArrowRight\" : \"ArrowLeft\";\n\n return (\n <DropdownMenuPrimitive.Portal {...scope} {...portalProps}>\n <DropdownMenuRenderContent\n {...scope}\n {...props}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (!sharedFocusGroup || event.key !== closeKey) return;\n event.preventDefault();\n setOpen(false);\n focus?.moreRef.current?.focus();\n })}\n onEscapeKeyDown={composeEventHandlers(props.onEscapeKeyDown, () => {\n if (!sharedFocusGroup) return;\n focus?.moreRef.current?.focus();\n })}\n ref={forwardedRef}\n sideOffset={sideOffset}\n />\n </DropdownMenuPrimitive.Portal>\n );\n },\n);\n\nThreadListItemMorePrimitiveContent.displayName =\n \"ThreadListItemMorePrimitive.Content\";\n"],"mappings":";;;;;;;;;;;AA6BA,MAAagB,qCAAqCZ,YAIhDkB,IAAAC,iBAAA;CAAA,MAAAC,IAAAvB,EAAA,EAAA;CACE,MAAA,EAAAwB,2BAAAL,aAAAM,YAAAC,IAAA,GAAAC,UAAAN;CAGE,MAAAI,aAAAC,OAAAE,KAAAA,IAAA,IAAAF;CAKF,MAAAG,QAAcf,qBAAqBU,yBAAyB;CAC5D,MAAAM,UAAgBlB,6BAA6B;CAC7C,MAAAmB,QAAcrB,uBAAuB;CACrC,MAAAsB,mBAAyBrB,sCAAsC;CAE/D,MAAAwB,WADkB/B,UAAS8B,aACVD,MAAc,QAAd,eAAA;CAGd,MAAAG,KAAA9B;CACE,MAAA+B,KAAA5B;CAAyB,IAAA6B;CAAA,IAAAf,EAAA,OAAAY,YAAAZ,EAAA,OAAAQ,OAAAQ,WAAAhB,EAAA,OAAAO,WAAAP,EAAA,OAAAS,kBAAA;EAGyBM,MAAAE,UAAA;GAC/C,IAAI,CAACR,oBAAoBQ,MAAKC,QAASN,UAAQ;GAC/CK,MAAKE,eAAgB;GACrBZ,QAAQ,KAAK;GACbC,OAAKQ,QAAiBI,SAAOZ,MAAC;EAAC;EAChCR,EAAA,KAAAY;EAAAZ,EAAA,KAAAQ,OAAAQ;EAAAhB,EAAA,KAAAO;EAAAP,EAAA,KAAAS;EAAAT,EAAA,KAAAe;CAAA,OAAAA,KAAAf,EAAA;CALU,MAAAqB,KAAArC,qBAAqBoB,MAAKkB,WAAYP,EAKhD;CAAC,IAAAQ;CAAA,IAAAvB,EAAA,OAAAQ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