@assistant-ui/react 0.15.35 → 0.15.36
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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +4 -10
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/useComposerRunStartFocusGuard.d.ts +19 -0
- package/dist/primitives/composer/useComposerRunStartFocusGuard.d.ts.map +1 -0
- package/dist/primitives/composer/useComposerRunStartFocusGuard.js +39 -0
- package/dist/primitives/composer/useComposerRunStartFocusGuard.js.map +1 -0
- package/dist/unstable/useComposerRunStartFocusGuard.d.ts +18 -0
- package/dist/unstable/useComposerRunStartFocusGuard.d.ts.map +1 -0
- package/dist/unstable/useComposerRunStartFocusGuard.js +17 -0
- package/dist/unstable/useComposerRunStartFocusGuard.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +6 -0
- package/src/primitives/composer/ComposerInput.tsx +4 -18
- package/src/primitives/composer/useComposerRunStartFocusGuard.ts +50 -0
- package/src/unstable/useComposerRunStartFocusGuard.ts +25 -0
package/dist/index.d.ts
CHANGED
|
@@ -144,6 +144,7 @@ export type { DirectiveFormatter, DirectiveSegment, TriggerAdapter, TriggerCateg
|
|
|
144
144
|
export { defaultDirectiveFormatter, unstable_defaultDirectiveFormatter, } from "@assistant-ui/core";
|
|
145
145
|
export { unstable_useComposerInputHistory, type Unstable_ComposerInputHistory, } from "./unstable/useComposerInputHistory.js";
|
|
146
146
|
export { unstable_useComposerInput, unstable_useTriggerPopoverAriaProps, type Unstable_UseComposerInputOptions, type Unstable_ComposerInput, type Unstable_TriggerPopoverAriaProps, } from "./unstable/useComposerInput.js";
|
|
147
|
+
export { unstable_useComposerRunStartFocusGuard, type Unstable_ComposerRunStartFocusGuard, } from "./unstable/useComposerRunStartFocusGuard.js";
|
|
147
148
|
export type { Assistant } from "./augmentations.js";
|
|
148
149
|
export { CloudRendererHost, type CloudRendererHostProps, } from "./cloud-renderer/CloudRendererHost.js";
|
|
149
150
|
export { McpAppRenderer, McpAppsRemoteHost, getMcpAppFromToolPart, } from "./mcp-apps/index.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,OAAO,EACL,MAAM,EACN,WAAW,EACX,SAAS,EACT,WAAW,EACX,WAAW,EACX,KAAK,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAG5E,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,EAC3B,0BAA0B,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
|
@@ -54,6 +54,7 @@ import { unstable_useSlashCommandAdapter } from "./unstable/useSlashCommandAdapt
|
|
|
54
54
|
import { unstable_useLiveCompletionAdapter } from "./unstable/useLiveCompletionAdapter.js";
|
|
55
55
|
import { unstable_useComposerInputHistory } from "./unstable/useComposerInputHistory.js";
|
|
56
56
|
import { unstable_useComposerInput, unstable_useTriggerPopoverAriaProps } from "./unstable/useComposerInput.js";
|
|
57
|
+
import { unstable_useComposerRunStartFocusGuard } from "./unstable/useComposerRunStartFocusGuard.js";
|
|
57
58
|
import { getMcpAppFromToolPart } from "./mcp-apps/utils.js";
|
|
58
59
|
import { McpAppRenderer } from "./mcp-apps/McpAppRenderer.js";
|
|
59
60
|
import { McpAppsRemoteHost } from "./mcp-apps/McpAppsRemoteHost.js";
|
|
@@ -64,4 +65,4 @@ import { ChainOfThoughtPartByIndexProvider, CloudFileAttachmentAdapter, DataRend
|
|
|
64
65
|
import { AuiConfig, AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
65
66
|
import { ChainOfThoughtClient, ExternalThread, InMemoryThreadList, ModelContext as ModelContextClient, RemoteThreadList, SingleThreadList, Suggestions } from "@assistant-ui/core/store";
|
|
66
67
|
import { AssistantCloud, readAnonymousRefreshToken } from "assistant-cloud";
|
|
67
|
-
export { actionBarMore_exports as ActionBarMorePrimitive, actionBar_exports as ActionBarPrimitive, AssistantCloud, AssistantFrameHost, AssistantFrameProvider, assistantModal_exports as AssistantModalPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiConfig, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, ChainOfThoughtPartByIndexProvider, chainOfThought_exports as ChainOfThoughtPrimitive, CloudFileAttachmentAdapter, CloudRendererHost, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, DevToolsHooks, DevToolsProviderApi, error_exports as ErrorPrimitive, ExportedMessageRepository, ExternalThread, FRAME_MESSAGE_CHANNEL, GeminiLiveVoiceAdapter, GenerativeUIRender, GenerativeUIRenderError, internal_exports as INTERNAL, InMemoryThreadList, InMemoryThreadListAdapter, Interactables, McpAppRenderer, McpAppsRemoteHost, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessageNotSentError, messagePart_exports as MessagePartPrimitive, message_exports as MessagePrimitive, MessageProvider, ModelContextClient, ModelContextRegistry, OpenAIRealtimeVoiceAdapter, PartByIndexProvider, queueItem_exports as QueueItemPrimitive, ReadonlyThreadProvider, RemoteThreadList, RuntimeAdapterProvider, selectionToolbar_exports as SelectionToolbarPrimitive, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItemMore_exports as ThreadListItemMorePrimitive, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSimpleTitleAdapter, createSuggestionAdapter, createThreadRowsSelector, createVoiceSession, defaultDirectiveFormatter, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, humanTool, isMessageNotSentError, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, readAnonymousRefreshToken, stubTool, tool, toolApprovalAcceptsText, unstable_Interactables, unstable_convertExternalMessages, unstable_createExternalMessageConversionCache, unstable_createMessageConverter, unstable_defaultDirectiveFormatter, defaultWebMcpFilter as unstable_defaultWebMcpFilter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useComposerInput, unstable_useComposerInputHistory, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useLiveCompletionAdapter, unstable_useMentionAdapter, unstable_useMessageStallDetection, unstable_useSlashCommandAdapter, unstable_useThreadMessageIds, unstable_useTriggerPopoverAriaProps, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, unstable_useWebMcpProvider, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useSmooth, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useToolCallElapsed, useVoiceControls, useVoiceState, useVoiceVolume };
|
|
68
|
+
export { actionBarMore_exports as ActionBarMorePrimitive, actionBar_exports as ActionBarPrimitive, AssistantCloud, AssistantFrameHost, AssistantFrameProvider, assistantModal_exports as AssistantModalPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiConfig, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, ChainOfThoughtPartByIndexProvider, chainOfThought_exports as ChainOfThoughtPrimitive, CloudFileAttachmentAdapter, CloudRendererHost, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, DevToolsHooks, DevToolsProviderApi, error_exports as ErrorPrimitive, ExportedMessageRepository, ExternalThread, FRAME_MESSAGE_CHANNEL, GeminiLiveVoiceAdapter, GenerativeUIRender, GenerativeUIRenderError, internal_exports as INTERNAL, InMemoryThreadList, InMemoryThreadListAdapter, Interactables, McpAppRenderer, McpAppsRemoteHost, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessageNotSentError, messagePart_exports as MessagePartPrimitive, message_exports as MessagePrimitive, MessageProvider, ModelContextClient, ModelContextRegistry, OpenAIRealtimeVoiceAdapter, PartByIndexProvider, queueItem_exports as QueueItemPrimitive, ReadonlyThreadProvider, RemoteThreadList, RuntimeAdapterProvider, selectionToolbar_exports as SelectionToolbarPrimitive, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItemMore_exports as ThreadListItemMorePrimitive, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSimpleTitleAdapter, createSuggestionAdapter, createThreadRowsSelector, createVoiceSession, defaultDirectiveFormatter, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, humanTool, isMessageNotSentError, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, readAnonymousRefreshToken, stubTool, tool, toolApprovalAcceptsText, unstable_Interactables, unstable_convertExternalMessages, unstable_createExternalMessageConversionCache, unstable_createMessageConverter, unstable_defaultDirectiveFormatter, defaultWebMcpFilter as unstable_defaultWebMcpFilter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useComposerInput, unstable_useComposerInputHistory, unstable_useComposerRunStartFocusGuard, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useLiveCompletionAdapter, unstable_useMentionAdapter, unstable_useMessageStallDetection, unstable_useSlashCommandAdapter, unstable_useThreadMessageIds, unstable_useTriggerPopoverAriaProps, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, unstable_useWebMcpProvider, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useSmooth, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useToolCallElapsed, useVoiceControls, useVoiceState, useVoiceVolume };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerInput.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerInput.tsx"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,YAAY,EAOlB,MAAM,OAAO,CAAC;AACf,OAAyB,EACvB,KAAK,qBAAqB,EAE3B,MAAM,yBAAyB,CAAC;AAoBjC,yBAAiB,sBAAsB,CAAC;IACtC,MAAM,MAAM,OAAO,GAAG,mBAAmB,CAAC;IAE1C,KAAK,SAAS,GAAG;QACf;;;WAGG;QACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC9B;;WAEG;QACH,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;QAClC;;;;;WAKG;QACH,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QACrC;;;;;;;;;WASG;QACH,wBAAwB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC/C;;;;;;WAMG;QACH,8BAA8B,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QACrD;;;;;;WAMG;QACH,8BAA8B,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QACrD;;;;;;;;;WASG;QACH,kCAAkC,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QACzD;;;WAGG;QACH,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KAC5C,CAAC;IAEF,KAAK,eAAe,GAChB;QACE;;;;;;WAMG;QACH,UAAU,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC;QACxD;;;WAGG;QACH,aAAa,CAAC,EAAE,KAAK,CAAC;KACvB,GACD;QACE,UAAU,CAAC,EAAE,KAAK,CAAC;QACnB;;;;WAIG;QACH,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KACrC,CAAC;IAEN,MAAM,MAAM,KAAK,GAAG,qBAAqB,GAAG,SAAS,GAAG,eAAe,CAAC;;CACzE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"ComposerInput.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerInput.tsx"],"names":[],"mappings":"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useOnScrollToBottom } from "../../utils/hooks/useOnScrollToBottom.js";
|
|
|
5
5
|
import { useMediaQuery } from "../../utils/hooks/useMediaQuery.js";
|
|
6
6
|
import { isCompositionKey } from "../../utils/isCompositionKey.js";
|
|
7
7
|
import { useComposerInputPluginRegistryOptional } from "./ComposerInputPluginContext.js";
|
|
8
|
-
import { useThreadRootElementRef } from "../thread/ThreadRootElementContext.js";
|
|
9
8
|
import { useComposerCancelWithFocus } from "./useComposerCancelWithFocus.js";
|
|
9
|
+
import { useComposerRunStartFocusGuard } from "./useComposerRunStartFocusGuard.js";
|
|
10
10
|
import { useComposerInputDisabled, useComposerInputValue, useTriggerPopoverAriaProps } from "./useComposerInputState.js";
|
|
11
11
|
import { forwardRef, isValidElement, useCallback, useEffect, useRef } from "@assistant-ui/tap/react-shim";
|
|
12
12
|
import { useAui } from "@assistant-ui/store";
|
|
@@ -53,7 +53,7 @@ const TOUCH_PRIMARY_QUERY = "(pointer: coarse) and (not (any-pointer: fine))";
|
|
|
53
53
|
*/
|
|
54
54
|
const ComposerPrimitiveInput = forwardRef(({ autoFocus = false, asChild, render, disabled: disabledProp, onChange, onKeyDown, onPaste, onSelect, submitOnEnter, submitMode, cancelOnEscape = true, unstable_focusOnRunStart = true, unstable_focusOnScrollToBottom = true, unstable_focusOnThreadSwitched = true, unstable_insertNewlineOnTouchEnter = false, addAttachmentOnPaste = true, onHeightChange, ...rest }, forwardedRef) => {
|
|
55
55
|
const aui = useAui();
|
|
56
|
-
const
|
|
56
|
+
const canTakeFocusOnRunStart = useComposerRunStartFocusGuard();
|
|
57
57
|
const pluginRegistry = useComposerInputPluginRegistryOptional();
|
|
58
58
|
const compactContext = useComposerCompactContextOptional();
|
|
59
59
|
const declaredSubmitMode = submitMode ?? (submitOnEnter === false ? "none" : "enter");
|
|
@@ -133,15 +133,9 @@ const ComposerPrimitiveInput = forwardRef(({ autoFocus = false, asChild, render,
|
|
|
133
133
|
}, [autoFocusEnabled]);
|
|
134
134
|
const focusOnRunStart = useCallback(() => {
|
|
135
135
|
const textarea_0 = textareaRef.current;
|
|
136
|
-
if (!textarea_0) return;
|
|
137
|
-
const doc = textarea_0.ownerDocument;
|
|
138
|
-
const active = doc.activeElement;
|
|
139
|
-
if (active === textarea_0) return;
|
|
140
|
-
const root = threadRootRef?.current;
|
|
141
|
-
const composerRoot = textarea_0.closest("[data-aui-composer-type]");
|
|
142
|
-
if (active && active !== doc.body && !composerRoot?.contains(active) && (!root?.contains(active) || active.closest("[data-aui-thread-root]") !== root)) return;
|
|
136
|
+
if (!textarea_0 || !canTakeFocusOnRunStart(textarea_0)) return;
|
|
143
137
|
focus();
|
|
144
|
-
}, [focus,
|
|
138
|
+
}, [focus, canTakeFocusOnRunStart]);
|
|
145
139
|
useEffect(() => focus(), [focus]);
|
|
146
140
|
useOnScrollToBottom(() => {
|
|
147
141
|
if (aui.composer.getState().type === "thread" && unstable_focusOnScrollToBottom) focus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerInput.js","names":["composeEventHandlers","useComposedRefs","Slot","ClipboardEvent","KeyboardEvent","ReactElement","ReactNode","forwardRef","useCallback","useEffect","useRef","isValidElement","TextareaAutosize","TextareaAutosizeProps","TextareaHeightChangeMeta","useEscapeKeydown","useOnScrollToBottom","useMediaQuery","renderSlot","isCompositionKey","useAui","flushTapSync","useComposerInputPluginRegistryOptional","useComposerCompactContextOptional","useComposerCancelWithFocus","useThreadRootElementRef","useComposerInputDisabled","useComposerInputValue","useTriggerPopoverAriaProps","TOUCH_PRIMARY_QUERY","ComposerPrimitiveInput","Element","HTMLTextAreaElement","BaseProps","asChild","render","cancelOnEscape","unstable_focusOnRunStart","unstable_focusOnScrollToBottom","unstable_focusOnThreadSwitched","unstable_insertNewlineOnTouchEnter","addAttachmentOnPaste","SubmitModeProps","submitMode","submitOnEnter","Props","autoFocus","disabled","disabledProp","onChange","onKeyDown","onPaste","onSelect","onHeightChange","rest","forwardedRef","aui","threadRootRef","pluginRegistry","compactContext","declaredSubmitMode","isTouchPrimary","effectiveSubmitMode","value","isDisabled","textareaRef","cancel","composer","ref","compositionRef","e","current","contains","target","Node","plugin","getPlugins","handleKeyDown","getState","canCancel","preventDefault","handleKeyPress","nativeEvent","key","threadState","thread","hasQueue","capabilities","queue","shiftKey","ctrlKey","metaKey","canSend","send","steer","isRunning","voice","undefined","shouldSubmit","closest","requestSubmit","handlePaste","threadCapabilities","files","Array","from","clipboardData","attachments","length","Promise","all","map","file","addAttachment","handleHeightChange","height","meta","el","cs","getComputedStyle","contentHeight","boxSizing","parseFloat","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth","Math","round","rowHeight","setMultiline","autoFocusEnabled","focus","textarea","preventScroll","setSelectionRange","focusOnRunStart","doc","ownerDocument","active","activeElement","root","composerRoot","body","type","on","optional","threads","ariaComboboxProps","inputProps","name","const","React","ForwardedRef","ChangeEvent","isEditing","nativeIsComposing","isComposing","setText","origin","pos","selectionStart","setCursorPosition","onCompositionStart","CompositionEventHandler","onCompositionEnd","CompositionEvent","SyntheticEvent","children","Component","Root","displayName"],"sources":["../../../src/primitives/composer/ComposerInput.tsx"],"sourcesContent":["\"use client\";\n\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { Slot } from \"radix-ui\";\nimport {\n type ClipboardEvent,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n isValidElement,\n} from \"react\";\nimport TextareaAutosize, {\n type TextareaAutosizeProps,\n type TextareaHeightChangeMeta,\n} from \"react-textarea-autosize\";\nimport { useEscapeKeydown } from \"radix-ui/internal\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { useMediaQuery } from \"../../utils/hooks/useMediaQuery\";\nimport { renderSlot } from \"../../utils/Primitive\";\nimport { isCompositionKey } from \"../../utils/isCompositionKey\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { flushTapSync } from \"@assistant-ui/tap\";\nimport { useComposerInputPluginRegistryOptional } from \"./ComposerInputPluginContext\";\nimport { useComposerCompactContextOptional } from \"./ComposerCompactContext\";\nimport { useComposerCancelWithFocus } from \"./useComposerCancelWithFocus\";\nimport { useThreadRootElementRef } from \"../thread/ThreadRootElementContext\";\nimport {\n useComposerInputDisabled,\n useComposerInputValue,\n useTriggerPopoverAriaProps,\n} from \"./useComposerInputState\";\n\nconst TOUCH_PRIMARY_QUERY = \"(pointer: coarse) and (not (any-pointer: fine))\";\n\nexport namespace ComposerPrimitiveInput {\n export type Element = HTMLTextAreaElement;\n\n type BaseProps = {\n /**\n * Whether to render as a child component using Slot.\n * When true, the component will merge its props with its child.\n */\n asChild?: boolean | undefined;\n /**\n * A React element to use as the input container, with props merged in.\n */\n render?: ReactElement | undefined;\n /**\n * Whether to cancel message composition when Escape is pressed.\n * After cancelling an edit, focus returns to the main thread composer when\n * available, unless a handler has moved focus elsewhere.\n * @default true\n */\n cancelOnEscape?: boolean | undefined;\n /**\n * Whether to focus the input when a new run starts if nothing is focused\n * or focus is already inside the same thread or composer. Keeps the current\n * selection when the input is already focused. Applies when `autoFocus` is\n * enabled.\n *\n * @deprecated Experimental since 2024-10-12. Not scheduled for removal; the API may change in any release.\n *\n * @default true\n */\n unstable_focusOnRunStart?: boolean | undefined;\n /**\n * Whether to automatically focus the input when scrolling to bottom.\n *\n * @deprecated Experimental since 2024-10-12. Not scheduled for removal; the API may change in any release.\n *\n * @default true\n */\n unstable_focusOnScrollToBottom?: boolean | undefined;\n /**\n * Whether to automatically focus the input when switching threads.\n *\n * @deprecated Experimental since 2024-10-12. Not scheduled for removal; the API may change in any release.\n *\n * @default true\n */\n unstable_focusOnThreadSwitched?: boolean | undefined;\n /**\n * Whether plain Enter on a touch-primary device should insert a newline\n * instead of submitting, detected via\n * `(pointer: coarse) and (not (any-pointer: fine))`. Only takes effect\n * when `submitMode` resolves to `\"enter\"`.\n *\n * @deprecated Experimental since 2026-05-24. Not scheduled for removal; the API may change in any release.\n *\n * @default false\n */\n unstable_insertNewlineOnTouchEnter?: boolean | undefined;\n /**\n * Whether to automatically add pasted files as attachments.\n * @default true\n */\n addAttachmentOnPaste?: boolean | undefined;\n };\n\n type SubmitModeProps =\n | {\n /**\n * Controls how the Enter key submits messages.\n * - \"enter\": Plain Enter submits (Shift+Enter for newline)\n * - \"ctrlEnter\": Ctrl/Cmd+Enter submits (plain Enter for newline)\n * - \"none\": Keyboard submission disabled\n * @default \"enter\"\n */\n submitMode?: \"enter\" | \"ctrlEnter\" | \"none\" | undefined;\n /**\n * @deprecated Use `submitMode` instead\n * @ignore\n */\n submitOnEnter?: never;\n }\n | {\n submitMode?: never;\n /**\n * Whether to submit the message when Enter is pressed (without Shift).\n * @default true\n * @deprecated Use `submitMode` instead. Will be removed in a future version.\n */\n submitOnEnter?: boolean | undefined;\n };\n\n export type Props = TextareaAutosizeProps & BaseProps & SubmitModeProps;\n}\n\n/**\n * A text input component for composing messages.\n *\n * This component provides a rich text input experience with automatic resizing,\n * keyboard shortcuts, file paste support, and intelligent focus management.\n * It integrates with the composer context to manage message state and submission.\n *\n * When rendered inside `TriggerPopoverRoot` and a popover is open, the\n * underlying `<textarea>` automatically receives `aria-controls`,\n * `aria-expanded`, `aria-haspopup`, and `aria-activedescendant` for the\n * combobox relationship. These computed attributes override user-provided\n * values for those four ARIA props while the popover is open.\n *\n * @example\n * ```tsx\n * // Ctrl/Cmd+Enter to submit (plain Enter inserts newline)\n * <ComposerPrimitive.Input\n * placeholder=\"Type your message...\"\n * submitMode=\"ctrlEnter\"\n * />\n *\n * // Insert a newline on Enter on touch-primary devices.\n * <ComposerPrimitive.Input\n * placeholder=\"Type your message...\"\n * unstable_insertNewlineOnTouchEnter\n * />\n *\n * // Old API (deprecated, still supported)\n * <ComposerPrimitive.Input\n * placeholder=\"Type your message...\"\n * submitOnEnter={true}\n * />\n * ```\n */\nexport const ComposerPrimitiveInput = forwardRef<\n ComposerPrimitiveInput.Element,\n ComposerPrimitiveInput.Props\n>(\n (\n {\n autoFocus = false,\n asChild,\n render,\n disabled: disabledProp,\n onChange,\n onKeyDown,\n onPaste,\n onSelect,\n submitOnEnter,\n submitMode,\n cancelOnEscape = true,\n unstable_focusOnRunStart = true,\n unstable_focusOnScrollToBottom = true,\n unstable_focusOnThreadSwitched = true,\n unstable_insertNewlineOnTouchEnter = false,\n addAttachmentOnPaste = true,\n onHeightChange,\n ...rest\n },\n forwardedRef,\n ) => {\n const aui = useAui();\n const threadRootRef = useThreadRootElementRef();\n const pluginRegistry = useComposerInputPluginRegistryOptional();\n const compactContext = useComposerCompactContextOptional();\n\n const declaredSubmitMode =\n submitMode ?? (submitOnEnter === false ? \"none\" : \"enter\");\n const isTouchPrimary = useMediaQuery(\n unstable_insertNewlineOnTouchEnter ? TOUCH_PRIMARY_QUERY : null,\n );\n const effectiveSubmitMode =\n unstable_insertNewlineOnTouchEnter &&\n isTouchPrimary &&\n declaredSubmitMode === \"enter\"\n ? \"none\"\n : declaredSubmitMode;\n\n const value = useComposerInputValue();\n const isDisabled = useComposerInputDisabled(disabledProp);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const cancel = useComposerCancelWithFocus(\n useCallback(() => aui.composer.cancel(), [aui]),\n );\n const ref = useComposedRefs(forwardedRef, textareaRef);\n // suppress text/cursor broadcasts during IME composition\n const compositionRef = useRef(false);\n\n useEscapeKeydown((e) => {\n // Only handle ESC if it originated from within this input\n if (!textareaRef.current?.contains(e.target as Node)) return;\n\n // ignore IME composition events\n if (isCompositionKey(e)) return;\n\n // Let registered plugins (mention, slash command, etc.) handle Escape first\n if (pluginRegistry) {\n for (const plugin of pluginRegistry.getPlugins()) {\n if (plugin.handleKeyDown(e)) return;\n }\n }\n\n if (!cancelOnEscape) return;\n\n const composer = aui.composer;\n if (composer.getState().canCancel) {\n cancel(textareaRef.current);\n e.preventDefault();\n }\n });\n\n const handleKeyPress = (e: KeyboardEvent) => {\n if (isDisabled) return;\n\n // ignore IME composition events\n if (isCompositionKey(e.nativeEvent)) return;\n\n // Let registered plugins (mention, slash command, etc.) handle keyboard events first\n if (pluginRegistry) {\n for (const plugin of pluginRegistry.getPlugins()) {\n if (plugin.handleKeyDown(e)) return;\n }\n }\n\n if (e.key === \"Enter\") {\n const threadState = aui.thread.getState();\n const hasQueue = threadState.capabilities.queue;\n\n // Steer hotkey: Cmd/Ctrl+Shift+Enter (respects submitMode=\"none\" and canSend)\n if (\n e.shiftKey &&\n (e.ctrlKey || e.metaKey) &&\n hasQueue &&\n declaredSubmitMode !== \"none\" &&\n aui.composer.getState().canSend\n ) {\n e.preventDefault();\n aui.composer.send({ steer: true });\n return;\n }\n\n // Regular newline: Shift+Enter\n if (e.shiftKey) return;\n\n // Block submission when running unless queue is supported; a voice\n // session leaves the decision to canSend\n if (\n threadState.isRunning &&\n !hasQueue &&\n threadState.voice === undefined\n )\n return;\n\n let shouldSubmit = false;\n if (effectiveSubmitMode === \"ctrlEnter\") {\n shouldSubmit = e.ctrlKey || e.metaKey;\n } else if (effectiveSubmitMode === \"enter\") {\n shouldSubmit = true;\n }\n\n if (shouldSubmit) {\n e.preventDefault();\n textareaRef.current?.closest(\"form\")?.requestSubmit();\n }\n }\n };\n\n const handlePaste = async (e: ClipboardEvent<HTMLTextAreaElement>) => {\n if (!addAttachmentOnPaste) return;\n const threadCapabilities = aui.thread.getState().capabilities;\n const files = Array.from(e.clipboardData?.files || []);\n\n if (threadCapabilities.attachments && files.length > 0) {\n e.preventDefault();\n await Promise.all(\n files.map(async (file) => {\n try {\n await aui.composer.addAttachment(file);\n } catch {\n // The composer runtime emits composer.attachmentAddError before rejecting.\n }\n }),\n );\n }\n };\n\n const handleHeightChange = (\n height: number,\n meta: TextareaHeightChangeMeta,\n ) => {\n onHeightChange?.(height, meta);\n if (!compactContext) return;\n const el = textareaRef.current;\n if (!el || el.value === \"\") return;\n const cs = getComputedStyle(el);\n const contentHeight =\n cs.boxSizing === \"border-box\"\n ? height -\n parseFloat(cs.paddingTop) -\n parseFloat(cs.paddingBottom) -\n parseFloat(cs.borderTopWidth) -\n parseFloat(cs.borderBottomWidth)\n : height;\n if (Math.round(contentHeight / meta.rowHeight) > 1) {\n compactContext.setMultiline(true);\n }\n };\n\n const autoFocusEnabled = autoFocus && !isDisabled;\n const focus = useCallback(() => {\n const textarea = textareaRef.current;\n if (!textarea || !autoFocusEnabled) return;\n\n textarea.focus({ preventScroll: true });\n textarea.setSelectionRange(textarea.value.length, textarea.value.length);\n }, [autoFocusEnabled]);\n\n const focusOnRunStart = useCallback(() => {\n const textarea = textareaRef.current;\n if (!textarea) return;\n const doc = textarea.ownerDocument;\n const active = doc.activeElement;\n if (active === textarea) return;\n\n const root = threadRootRef?.current;\n const composerRoot = textarea.closest(\"[data-aui-composer-type]\");\n if (\n active &&\n active !== doc.body &&\n !composerRoot?.contains(active) &&\n (!root?.contains(active) ||\n active.closest(\"[data-aui-thread-root]\") !== root)\n )\n return;\n\n focus();\n }, [focus, threadRootRef]);\n\n useEffect(() => focus(), [focus]);\n\n useOnScrollToBottom(() => {\n if (\n aui.composer.getState().type === \"thread\" &&\n unstable_focusOnScrollToBottom\n ) {\n focus();\n }\n });\n\n useEffect(() => {\n if (\n aui.composer.getState().type !== \"thread\" ||\n !unstable_focusOnRunStart\n )\n return undefined;\n\n return aui.on(\"thread.runStart\", focusOnRunStart);\n }, [unstable_focusOnRunStart, focusOnRunStart, aui]);\n\n useEffect(() => {\n if (\n aui.composer.getState().type !== \"thread\" ||\n !unstable_focusOnThreadSwitched ||\n !aui.optional.threads\n )\n return undefined;\n\n return aui.on(\"threads.selectionChanged\", focus);\n }, [unstable_focusOnThreadSwitched, focus, aui]);\n\n useEffect(() => {\n if (value === \"\") compactContext?.setMultiline(false);\n }, [value, compactContext]);\n\n const ariaComboboxProps = useTriggerPopoverAriaProps();\n\n const inputProps = {\n name: \"input\" as const,\n value,\n ...rest,\n ...ariaComboboxProps,\n ref: ref as React.ForwardedRef<HTMLTextAreaElement>,\n disabled: isDisabled,\n onChange: composeEventHandlers(\n onChange,\n (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (!aui.composer.getState().isEditing) return;\n const nativeIsComposing =\n (e.nativeEvent as { isComposing?: boolean }).isComposing === true;\n // recover stuck compositionRef when the browser drops compositionend\n if (compositionRef.current && !nativeIsComposing) {\n compositionRef.current = false;\n }\n const isComposing = nativeIsComposing || compositionRef.current;\n // Standalone tap roots need a synchronous flush while the input is composing.\n flushTapSync(() => {\n aui.composer.setText(e.target.value, { origin: \"user\" });\n });\n if (isComposing) return;\n const pos = e.target.selectionStart ?? e.target.value.length;\n if (pluginRegistry) {\n for (const plugin of pluginRegistry.getPlugins()) {\n plugin.setCursorPosition(pos);\n }\n }\n },\n ),\n onKeyDown: composeEventHandlers(onKeyDown, handleKeyPress),\n onCompositionStart: composeEventHandlers(\n (rest as { onCompositionStart?: React.CompositionEventHandler })\n .onCompositionStart,\n () => {\n compositionRef.current = true;\n },\n ),\n onCompositionEnd: composeEventHandlers(\n (rest as { onCompositionEnd?: React.CompositionEventHandler })\n .onCompositionEnd,\n (e: React.CompositionEvent<HTMLTextAreaElement>) => {\n compositionRef.current = false;\n if (!aui.composer.getState().isEditing) return;\n const target = e.target as HTMLTextAreaElement;\n flushTapSync(() => {\n aui.composer.setText(target.value, { origin: \"user\" });\n });\n const pos = target.selectionStart ?? target.value.length;\n if (pluginRegistry) {\n for (const plugin of pluginRegistry.getPlugins()) {\n plugin.setCursorPosition(pos);\n }\n }\n },\n ),\n onSelect: composeEventHandlers(\n onSelect,\n (e: React.SyntheticEvent<HTMLTextAreaElement>) => {\n if (compositionRef.current) return;\n const target = e.target as HTMLTextAreaElement;\n const pos = target.selectionStart ?? target.value.length;\n if (pluginRegistry) {\n for (const plugin of pluginRegistry.getPlugins()) {\n plugin.setCursorPosition(pos);\n }\n }\n },\n ),\n onPaste: composeEventHandlers(onPaste, handlePaste),\n ...(compactContext\n ? { onHeightChange: handleHeightChange }\n : onHeightChange !== undefined\n ? { onHeightChange }\n : {}),\n };\n\n if (render && isValidElement(render)) {\n return renderSlot(\n render,\n (rest as { children?: ReactNode }).children,\n inputProps,\n );\n }\n\n const Component = asChild ? Slot.Root : TextareaAutosize;\n return <Component {...inputProps} />;\n },\n);\n\nComposerPrimitiveInput.displayName = \"ComposerPrimitive.Input\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqCA,MAAM6B,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkI5B,MAAaC,yBAAyBvB,YAKlC,EACEuC,YAAY,OACZZ,SACAC,QACAY,UAAUC,cACVC,UACAC,WACAC,SACAC,UACAR,eACAD,YACAP,iBAAiB,MACjBC,2BAA2B,MAC3BC,iCAAiC,MACjCC,iCAAiC,MACjCC,qCAAqC,OACrCC,uBAAuB,MACvBY,gBACA,GAAGC,QAELC,iBACG;CACH,MAAMC,MAAMpC,OAAO;CACnB,MAAMqC,gBAAgBhC,wBAAwB;CAC9C,MAAMiC,iBAAiBpC,uCAAuC;CAC9D,MAAMqC,iBAAiBpC,kCAAkC;CAEzD,MAAMqC,qBACJjB,eAAeC,kBAAkB,QAAQ,SAAS;CACpD,MAAMiB,iBAAiB5C,cACrBuB,qCAAqCX,sBAAsB,IAC7D;CACA,MAAMiC,sBACJtB,sCACAqB,kBACAD,uBAAuB,UACnB,SACAA;CAEN,MAAMG,QAAQpC,sBAAsB;CACpC,MAAMqC,aAAatC,yBAAyBsB,YAAY;CACxD,MAAMiB,cAAcvD,OAA4B,IAAI;CACpD,MAAMwD,SAAS1C,2BACbhB,kBAAkBgD,IAAIW,SAASD,OAAO,GAAG,CAACV,GAAG,CAAC,CAChD;CACA,MAAMY,MAAMnE,gBAAgBsD,cAAcU,WAAW;CAErD,MAAMI,iBAAiB3D,OAAO,KAAK;CAEnCK,kBAAkBuD,MAAM;EAEtB,IAAI,CAACL,YAAYM,SAASC,SAASF,EAAEG,MAAc,GAAG;EAGtD,IAAItD,iBAAiBmD,CAAC,GAAG;EAGzB,IAA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,mBAAmB,IACrC7D,mBAAmB4C,KAAAA,IACjB,EAAE5C,eAAe,IACjB,CAAC;CACT;CAEA,IAAIlB,UAAUxB,eAAewB,MAAM,GACjC,OAAOjB,WACLiB,QACCmB,KAAkCkH,UACnCnB,UACF;CAGF,MAAMoB,YAAYvI,UAAUhC,KAAKwK,OAAO9J;CACxC,OAAO,oBAAC,WAAD,EAAW,GAAIyI,WAAW,CAAA;AACnC,CACF;AAEAvH,uBAAuB6I,cAAc"}
|
|
1
|
+
{"version":3,"file":"ComposerInput.js","names":["composeEventHandlers","useComposedRefs","Slot","ClipboardEvent","KeyboardEvent","ReactElement","ReactNode","forwardRef","useCallback","useEffect","useRef","isValidElement","TextareaAutosize","TextareaAutosizeProps","TextareaHeightChangeMeta","useEscapeKeydown","useOnScrollToBottom","useMediaQuery","renderSlot","isCompositionKey","useAui","flushTapSync","useComposerInputPluginRegistryOptional","useComposerCompactContextOptional","useComposerCancelWithFocus","useComposerRunStartFocusGuard","useComposerInputDisabled","useComposerInputValue","useTriggerPopoverAriaProps","TOUCH_PRIMARY_QUERY","ComposerPrimitiveInput","Element","HTMLTextAreaElement","BaseProps","asChild","render","cancelOnEscape","unstable_focusOnRunStart","unstable_focusOnScrollToBottom","unstable_focusOnThreadSwitched","unstable_insertNewlineOnTouchEnter","addAttachmentOnPaste","SubmitModeProps","submitMode","submitOnEnter","Props","autoFocus","disabled","disabledProp","onChange","onKeyDown","onPaste","onSelect","onHeightChange","rest","forwardedRef","aui","canTakeFocusOnRunStart","pluginRegistry","compactContext","declaredSubmitMode","isTouchPrimary","effectiveSubmitMode","value","isDisabled","textareaRef","cancel","composer","ref","compositionRef","e","current","contains","target","Node","plugin","getPlugins","handleKeyDown","getState","canCancel","preventDefault","handleKeyPress","nativeEvent","key","threadState","thread","hasQueue","capabilities","queue","shiftKey","ctrlKey","metaKey","canSend","send","steer","isRunning","voice","undefined","shouldSubmit","closest","requestSubmit","handlePaste","threadCapabilities","files","Array","from","clipboardData","attachments","length","Promise","all","map","file","addAttachment","handleHeightChange","height","meta","el","cs","getComputedStyle","contentHeight","boxSizing","parseFloat","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth","Math","round","rowHeight","setMultiline","autoFocusEnabled","focus","textarea","preventScroll","setSelectionRange","focusOnRunStart","type","on","optional","threads","ariaComboboxProps","inputProps","name","const","React","ForwardedRef","ChangeEvent","isEditing","nativeIsComposing","isComposing","setText","origin","pos","selectionStart","setCursorPosition","onCompositionStart","CompositionEventHandler","onCompositionEnd","CompositionEvent","SyntheticEvent","children","Component","Root","displayName"],"sources":["../../../src/primitives/composer/ComposerInput.tsx"],"sourcesContent":["\"use client\";\n\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { Slot } from \"radix-ui\";\nimport {\n type ClipboardEvent,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n isValidElement,\n} from \"react\";\nimport TextareaAutosize, {\n type TextareaAutosizeProps,\n type TextareaHeightChangeMeta,\n} from \"react-textarea-autosize\";\nimport { useEscapeKeydown } from \"radix-ui/internal\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { useMediaQuery } from \"../../utils/hooks/useMediaQuery\";\nimport { renderSlot } from \"../../utils/Primitive\";\nimport { isCompositionKey } from \"../../utils/isCompositionKey\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { flushTapSync } from \"@assistant-ui/tap\";\nimport { useComposerInputPluginRegistryOptional } from \"./ComposerInputPluginContext\";\nimport { useComposerCompactContextOptional } from \"./ComposerCompactContext\";\nimport { useComposerCancelWithFocus } from \"./useComposerCancelWithFocus\";\nimport { useComposerRunStartFocusGuard } from \"./useComposerRunStartFocusGuard\";\nimport {\n useComposerInputDisabled,\n useComposerInputValue,\n useTriggerPopoverAriaProps,\n} from \"./useComposerInputState\";\n\nconst TOUCH_PRIMARY_QUERY = \"(pointer: coarse) and (not (any-pointer: fine))\";\n\nexport namespace ComposerPrimitiveInput {\n export type Element = HTMLTextAreaElement;\n\n type BaseProps = {\n /**\n * Whether to render as a child component using Slot.\n * When true, the component will merge its props with its child.\n */\n asChild?: boolean | undefined;\n /**\n * A React element to use as the input container, with props merged in.\n */\n render?: ReactElement | undefined;\n /**\n * Whether to cancel message composition when Escape is pressed.\n * After cancelling an edit, focus returns to the main thread composer when\n * available, unless a handler has moved focus elsewhere.\n * @default true\n */\n cancelOnEscape?: boolean | undefined;\n /**\n * Whether to focus the input when a new run starts if nothing is focused\n * or focus is already inside the same thread or composer. Keeps the current\n * selection when the input is already focused. Applies when `autoFocus` is\n * enabled.\n *\n * @deprecated Experimental since 2024-10-12. Not scheduled for removal; the API may change in any release.\n *\n * @default true\n */\n unstable_focusOnRunStart?: boolean | undefined;\n /**\n * Whether to automatically focus the input when scrolling to bottom.\n *\n * @deprecated Experimental since 2024-10-12. Not scheduled for removal; the API may change in any release.\n *\n * @default true\n */\n unstable_focusOnScrollToBottom?: boolean | undefined;\n /**\n * Whether to automatically focus the input when switching threads.\n *\n * @deprecated Experimental since 2024-10-12. Not scheduled for removal; the API may change in any release.\n *\n * @default true\n */\n unstable_focusOnThreadSwitched?: boolean | undefined;\n /**\n * Whether plain Enter on a touch-primary device should insert a newline\n * instead of submitting, detected via\n * `(pointer: coarse) and (not (any-pointer: fine))`. Only takes effect\n * when `submitMode` resolves to `\"enter\"`.\n *\n * @deprecated Experimental since 2026-05-24. Not scheduled for removal; the API may change in any release.\n *\n * @default false\n */\n unstable_insertNewlineOnTouchEnter?: boolean | undefined;\n /**\n * Whether to automatically add pasted files as attachments.\n * @default true\n */\n addAttachmentOnPaste?: boolean | undefined;\n };\n\n type SubmitModeProps =\n | {\n /**\n * Controls how the Enter key submits messages.\n * - \"enter\": Plain Enter submits (Shift+Enter for newline)\n * - \"ctrlEnter\": Ctrl/Cmd+Enter submits (plain Enter for newline)\n * - \"none\": Keyboard submission disabled\n * @default \"enter\"\n */\n submitMode?: \"enter\" | \"ctrlEnter\" | \"none\" | undefined;\n /**\n * @deprecated Use `submitMode` instead\n * @ignore\n */\n submitOnEnter?: never;\n }\n | {\n submitMode?: never;\n /**\n * Whether to submit the message when Enter is pressed (without Shift).\n * @default true\n * @deprecated Use `submitMode` instead. Will be removed in a future version.\n */\n submitOnEnter?: boolean | undefined;\n };\n\n export type Props = TextareaAutosizeProps & BaseProps & SubmitModeProps;\n}\n\n/**\n * A text input component for composing messages.\n *\n * This component provides a rich text input experience with automatic resizing,\n * keyboard shortcuts, file paste support, and intelligent focus management.\n * It integrates with the composer context to manage message state and submission.\n *\n * When rendered inside `TriggerPopoverRoot` and a popover is open, the\n * underlying `<textarea>` automatically receives `aria-controls`,\n * `aria-expanded`, `aria-haspopup`, and `aria-activedescendant` for the\n * combobox relationship. These computed attributes override user-provided\n * values for those four ARIA props while the popover is open.\n *\n * @example\n * ```tsx\n * // Ctrl/Cmd+Enter to submit (plain Enter inserts newline)\n * <ComposerPrimitive.Input\n * placeholder=\"Type your message...\"\n * submitMode=\"ctrlEnter\"\n * />\n *\n * // Insert a newline on Enter on touch-primary devices.\n * <ComposerPrimitive.Input\n * placeholder=\"Type your message...\"\n * unstable_insertNewlineOnTouchEnter\n * />\n *\n * // Old API (deprecated, still supported)\n * <ComposerPrimitive.Input\n * placeholder=\"Type your message...\"\n * submitOnEnter={true}\n * />\n * ```\n */\nexport const ComposerPrimitiveInput = forwardRef<\n ComposerPrimitiveInput.Element,\n ComposerPrimitiveInput.Props\n>(\n (\n {\n autoFocus = false,\n asChild,\n render,\n disabled: disabledProp,\n onChange,\n onKeyDown,\n onPaste,\n onSelect,\n submitOnEnter,\n submitMode,\n cancelOnEscape = true,\n unstable_focusOnRunStart = true,\n unstable_focusOnScrollToBottom = true,\n unstable_focusOnThreadSwitched = true,\n unstable_insertNewlineOnTouchEnter = false,\n addAttachmentOnPaste = true,\n onHeightChange,\n ...rest\n },\n forwardedRef,\n ) => {\n const aui = useAui();\n const canTakeFocusOnRunStart = useComposerRunStartFocusGuard();\n const pluginRegistry = useComposerInputPluginRegistryOptional();\n const compactContext = useComposerCompactContextOptional();\n\n const declaredSubmitMode =\n submitMode ?? (submitOnEnter === false ? \"none\" : \"enter\");\n const isTouchPrimary = useMediaQuery(\n unstable_insertNewlineOnTouchEnter ? TOUCH_PRIMARY_QUERY : null,\n );\n const effectiveSubmitMode =\n unstable_insertNewlineOnTouchEnter &&\n isTouchPrimary &&\n declaredSubmitMode === \"enter\"\n ? \"none\"\n : declaredSubmitMode;\n\n const value = useComposerInputValue();\n const isDisabled = useComposerInputDisabled(disabledProp);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const cancel = useComposerCancelWithFocus(\n useCallback(() => aui.composer.cancel(), [aui]),\n );\n const ref = useComposedRefs(forwardedRef, textareaRef);\n // suppress text/cursor broadcasts during IME composition\n const compositionRef = useRef(false);\n\n useEscapeKeydown((e) => {\n // Only handle ESC if it originated from within this input\n if (!textareaRef.current?.contains(e.target as Node)) return;\n\n // ignore IME composition events\n if (isCompositionKey(e)) return;\n\n // Let registered plugins (mention, slash command, etc.) handle Escape first\n if (pluginRegistry) {\n for (const plugin of pluginRegistry.getPlugins()) {\n if (plugin.handleKeyDown(e)) return;\n }\n }\n\n if (!cancelOnEscape) return;\n\n const composer = aui.composer;\n if (composer.getState().canCancel) {\n cancel(textareaRef.current);\n e.preventDefault();\n }\n });\n\n const handleKeyPress = (e: KeyboardEvent) => {\n if (isDisabled) return;\n\n // ignore IME composition events\n if (isCompositionKey(e.nativeEvent)) return;\n\n // Let registered plugins (mention, slash command, etc.) handle keyboard events first\n if (pluginRegistry) {\n for (const plugin of pluginRegistry.getPlugins()) {\n if (plugin.handleKeyDown(e)) return;\n }\n }\n\n if (e.key === \"Enter\") {\n const threadState = aui.thread.getState();\n const hasQueue = threadState.capabilities.queue;\n\n // Steer hotkey: Cmd/Ctrl+Shift+Enter (respects submitMode=\"none\" and canSend)\n if (\n e.shiftKey &&\n (e.ctrlKey || e.metaKey) &&\n hasQueue &&\n declaredSubmitMode !== \"none\" &&\n aui.composer.getState().canSend\n ) {\n e.preventDefault();\n aui.composer.send({ steer: true });\n return;\n }\n\n // Regular newline: Shift+Enter\n if (e.shiftKey) return;\n\n // Block submission when running unless queue is supported; a voice\n // session leaves the decision to canSend\n if (\n threadState.isRunning &&\n !hasQueue &&\n threadState.voice === undefined\n )\n return;\n\n let shouldSubmit = false;\n if (effectiveSubmitMode === \"ctrlEnter\") {\n shouldSubmit = e.ctrlKey || e.metaKey;\n } else if (effectiveSubmitMode === \"enter\") {\n shouldSubmit = true;\n }\n\n if (shouldSubmit) {\n e.preventDefault();\n textareaRef.current?.closest(\"form\")?.requestSubmit();\n }\n }\n };\n\n const handlePaste = async (e: ClipboardEvent<HTMLTextAreaElement>) => {\n if (!addAttachmentOnPaste) return;\n const threadCapabilities = aui.thread.getState().capabilities;\n const files = Array.from(e.clipboardData?.files || []);\n\n if (threadCapabilities.attachments && files.length > 0) {\n e.preventDefault();\n await Promise.all(\n files.map(async (file) => {\n try {\n await aui.composer.addAttachment(file);\n } catch {\n // The composer runtime emits composer.attachmentAddError before rejecting.\n }\n }),\n );\n }\n };\n\n const handleHeightChange = (\n height: number,\n meta: TextareaHeightChangeMeta,\n ) => {\n onHeightChange?.(height, meta);\n if (!compactContext) return;\n const el = textareaRef.current;\n if (!el || el.value === \"\") return;\n const cs = getComputedStyle(el);\n const contentHeight =\n cs.boxSizing === \"border-box\"\n ? height -\n parseFloat(cs.paddingTop) -\n parseFloat(cs.paddingBottom) -\n parseFloat(cs.borderTopWidth) -\n parseFloat(cs.borderBottomWidth)\n : height;\n if (Math.round(contentHeight / meta.rowHeight) > 1) {\n compactContext.setMultiline(true);\n }\n };\n\n const autoFocusEnabled = autoFocus && !isDisabled;\n const focus = useCallback(() => {\n const textarea = textareaRef.current;\n if (!textarea || !autoFocusEnabled) return;\n\n textarea.focus({ preventScroll: true });\n textarea.setSelectionRange(textarea.value.length, textarea.value.length);\n }, [autoFocusEnabled]);\n\n const focusOnRunStart = useCallback(() => {\n const textarea = textareaRef.current;\n if (!textarea || !canTakeFocusOnRunStart(textarea)) return;\n\n focus();\n }, [focus, canTakeFocusOnRunStart]);\n\n useEffect(() => focus(), [focus]);\n\n useOnScrollToBottom(() => {\n if (\n aui.composer.getState().type === \"thread\" &&\n unstable_focusOnScrollToBottom\n ) {\n focus();\n }\n });\n\n useEffect(() => {\n if (\n aui.composer.getState().type !== \"thread\" ||\n !unstable_focusOnRunStart\n )\n return undefined;\n\n return aui.on(\"thread.runStart\", focusOnRunStart);\n }, [unstable_focusOnRunStart, focusOnRunStart, aui]);\n\n useEffect(() => {\n if (\n aui.composer.getState().type !== \"thread\" ||\n !unstable_focusOnThreadSwitched ||\n !aui.optional.threads\n )\n return undefined;\n\n return aui.on(\"threads.selectionChanged\", focus);\n }, [unstable_focusOnThreadSwitched, focus, aui]);\n\n useEffect(() => {\n if (value === \"\") compactContext?.setMultiline(false);\n }, [value, compactContext]);\n\n const ariaComboboxProps = useTriggerPopoverAriaProps();\n\n const inputProps = {\n name: \"input\" as const,\n value,\n ...rest,\n ...ariaComboboxProps,\n ref: ref as React.ForwardedRef<HTMLTextAreaElement>,\n disabled: isDisabled,\n onChange: composeEventHandlers(\n onChange,\n (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (!aui.composer.getState().isEditing) return;\n const nativeIsComposing =\n (e.nativeEvent as { isComposing?: boolean }).isComposing === true;\n // recover stuck compositionRef when the browser drops compositionend\n if (compositionRef.current && !nativeIsComposing) {\n compositionRef.current = false;\n }\n const isComposing = nativeIsComposing || compositionRef.current;\n // Standalone tap roots need a synchronous flush while the input is composing.\n flushTapSync(() => {\n aui.composer.setText(e.target.value, { origin: \"user\" });\n });\n if (isComposing) return;\n const pos = e.target.selectionStart ?? e.target.value.length;\n if (pluginRegistry) {\n for (const plugin of pluginRegistry.getPlugins()) {\n plugin.setCursorPosition(pos);\n }\n }\n },\n ),\n onKeyDown: composeEventHandlers(onKeyDown, handleKeyPress),\n onCompositionStart: composeEventHandlers(\n (rest as { onCompositionStart?: React.CompositionEventHandler })\n .onCompositionStart,\n () => {\n compositionRef.current = true;\n },\n ),\n onCompositionEnd: composeEventHandlers(\n (rest as { onCompositionEnd?: React.CompositionEventHandler })\n .onCompositionEnd,\n (e: React.CompositionEvent<HTMLTextAreaElement>) => {\n compositionRef.current = false;\n if (!aui.composer.getState().isEditing) return;\n const target = e.target as HTMLTextAreaElement;\n flushTapSync(() => {\n aui.composer.setText(target.value, { origin: \"user\" });\n });\n const pos = target.selectionStart ?? target.value.length;\n if (pluginRegistry) {\n for (const plugin of pluginRegistry.getPlugins()) {\n plugin.setCursorPosition(pos);\n }\n }\n },\n ),\n onSelect: composeEventHandlers(\n onSelect,\n (e: React.SyntheticEvent<HTMLTextAreaElement>) => {\n if (compositionRef.current) return;\n const target = e.target as HTMLTextAreaElement;\n const pos = target.selectionStart ?? target.value.length;\n if (pluginRegistry) {\n for (const plugin of pluginRegistry.getPlugins()) {\n plugin.setCursorPosition(pos);\n }\n }\n },\n ),\n onPaste: composeEventHandlers(onPaste, handlePaste),\n ...(compactContext\n ? { onHeightChange: handleHeightChange }\n : onHeightChange !== undefined\n ? { onHeightChange }\n : {}),\n };\n\n if (render && isValidElement(render)) {\n return renderSlot(\n render,\n (rest as { children?: ReactNode }).children,\n inputProps,\n );\n }\n\n const Component = asChild ? Slot.Root : TextareaAutosize;\n return <Component {...inputProps} />;\n },\n);\n\nComposerPrimitiveInput.displayName = \"ComposerPrimitive.Input\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqCA,MAAM6B,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkI5B,MAAaC,yBAAyBvB,YAKlC,EACEuC,YAAY,OACZZ,SACAC,QACAY,UAAUC,cACVC,UACAC,WACAC,SACAC,UACAR,eACAD,YACAP,iBAAiB,MACjBC,2BAA2B,MAC3BC,iCAAiC,MACjCC,iCAAiC,MACjCC,qCAAq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,CAAC;GACD,MAAMC,QAAMhF,OAAOiF,kBAAkBjF,OAAOV,MAAM6C;GAClD,IAAIlD,gBACF,KAAK,MAAMiB,YAAUjB,eAAekB,WAAW,GAC7CD,SAAOgF,kBAAkBF,KAAG;EAGlC,CACF;EACArG,UAAUpD,qBACRoD,WACCkB,QAAiD;GAChD,IAAID,eAAeE,SAAS;GAC5B,MAAME,WAASH,IAAEG;GACjB,MAAMgF,QAAMhF,SAAOiF,kBAAkBjF,SAAOV,MAAM6C;GAClD,IAAIlD,gBACF,KAAK,MAAMiB,YAAUjB,eAAekB,WAAW,GAC7CD,SAAOgF,kBAAkBF,KAAG;EAGlC,CACF;EACAtG,SAASnD,qBAAqBmD,SAASkD,WAAW;EAClD,GAAI1C,iBACA,EAAEN,gBAAgB6D,mBAAmB,IACrC7D,mBAAmB4C,KAAAA,IACjB,EAAE5C,eAAe,IACjB,CAAC;CACT;CAEA,IAAIlB,UAAUxB,eAAewB,MAAM,GACjC,OAAOjB,WACLiB,QACCmB,KAAkC2G,UACnCnB,UACF;CAGF,MAAMoB,YAAYhI,UAAUhC,KAAKiK,OAAOvJ;CACxC,OAAO,oBAAC,WAAD,EAAW,GAAIkI,WAAW,CAAA;AACnC,CACF;AAEAhH,uBAAuBsI,cAAc"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decides whether a run start may move focus into a composer, mirroring what
|
|
3
|
+
* `ComposerPrimitive.Input` does: focus moves only when it is not somewhere
|
|
4
|
+
* outside the composer and outside the composer's thread.
|
|
5
|
+
*/
|
|
6
|
+
export type ComposerRunStartFocusGuard = (composerElement: HTMLElement | null) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The run-start focus decision `ComposerPrimitive.Input` makes, for other
|
|
9
|
+
* composer implementations (`@assistant-ui/react-lexical`) that have to make the
|
|
10
|
+
* same call. The thread root comes from context, so a composer portaled outside
|
|
11
|
+
* `ThreadPrimitive.Root` still knows which thread it belongs to; reading the
|
|
12
|
+
* `data-aui-thread-root` attribute instead concludes that focus is elsewhere and
|
|
13
|
+
* leaves the keyboard where the thread put it.
|
|
14
|
+
*
|
|
15
|
+
* Returns `false` for a missing element, and for the element itself already
|
|
16
|
+
* holding focus.
|
|
17
|
+
*/
|
|
18
|
+
export declare const useComposerRunStartFocusGuard: () => ComposerRunStartFocusGuard;
|
|
19
|
+
//# sourceMappingURL=useComposerRunStartFocusGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useComposerRunStartFocusGuard.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/useComposerRunStartFocusGuard.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACvC,eAAe,EAAE,WAAW,GAAG,IAAI,KAChC,OAAO,CAAC;AAEb;;;;;;;;;;GAUG;AACH,eAAO,MAAM,6BAA6B,QAAO,0BAwBhD,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useThreadRootElementRef } from "../thread/ThreadRootElementContext.js";
|
|
3
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
|
+
import "@assistant-ui/tap/react-shim";
|
|
5
|
+
// src/primitives/composer/useComposerRunStartFocusGuard.ts
|
|
6
|
+
/**
|
|
7
|
+
* The run-start focus decision `ComposerPrimitive.Input` makes, for other
|
|
8
|
+
* composer implementations (`@assistant-ui/react-lexical`) that have to make the
|
|
9
|
+
* same call. The thread root comes from context, so a composer portaled outside
|
|
10
|
+
* `ThreadPrimitive.Root` still knows which thread it belongs to; reading the
|
|
11
|
+
* `data-aui-thread-root` attribute instead concludes that focus is elsewhere and
|
|
12
|
+
* leaves the keyboard where the thread put it.
|
|
13
|
+
*
|
|
14
|
+
* Returns `false` for a missing element, and for the element itself already
|
|
15
|
+
* holding focus.
|
|
16
|
+
*/
|
|
17
|
+
const useComposerRunStartFocusGuard = () => {
|
|
18
|
+
const $ = c(2);
|
|
19
|
+
const threadRootRef = useThreadRootElementRef();
|
|
20
|
+
let t0;
|
|
21
|
+
if ($[0] !== threadRootRef) {
|
|
22
|
+
t0 = (composerElement) => {
|
|
23
|
+
if (!composerElement) return false;
|
|
24
|
+
const doc = composerElement.ownerDocument;
|
|
25
|
+
const active = doc.activeElement;
|
|
26
|
+
if (!active || active === doc.body) return true;
|
|
27
|
+
if (active === composerElement) return false;
|
|
28
|
+
if (composerElement.closest("[data-aui-composer-type]")?.contains(active)) return true;
|
|
29
|
+
const threadRoot = threadRootRef?.current ?? null;
|
|
30
|
+
return threadRoot !== null && threadRoot.contains(active) && active.closest("[data-aui-thread-root]") === threadRoot;
|
|
31
|
+
};
|
|
32
|
+
$[0] = threadRootRef;
|
|
33
|
+
$[1] = t0;
|
|
34
|
+
} else t0 = $[1];
|
|
35
|
+
return t0;
|
|
36
|
+
};
|
|
37
|
+
export { useComposerRunStartFocusGuard };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=useComposerRunStartFocusGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useComposerRunStartFocusGuard.js","names":["c","_c","useCallback","useThreadRootElementRef","ComposerRunStartFocusGuard","composerElement","HTMLElement","useComposerRunStartFocusGuard","$","threadRootRef","t0","doc","ownerDocument","active","activeElement","body","composerRoot","closest","contains","threadRoot","current","_c"],"sources":["../../../src/primitives/composer/useComposerRunStartFocusGuard.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback } from \"react\";\nimport { useThreadRootElementRef } from \"../thread/ThreadRootElementContext\";\n\n/**\n * Decides whether a run start may move focus into a composer, mirroring what\n * `ComposerPrimitive.Input` does: focus moves only when it is not somewhere\n * outside the composer and outside the composer's thread.\n */\nexport type ComposerRunStartFocusGuard = (\n composerElement: HTMLElement | null,\n) => boolean;\n\n/**\n * The run-start focus decision `ComposerPrimitive.Input` makes, for other\n * composer implementations (`@assistant-ui/react-lexical`) that have to make the\n * same call. The thread root comes from context, so a composer portaled outside\n * `ThreadPrimitive.Root` still knows which thread it belongs to; reading the\n * `data-aui-thread-root` attribute instead concludes that focus is elsewhere and\n * leaves the keyboard where the thread put it.\n *\n * Returns `false` for a missing element, and for the element itself already\n * holding focus.\n */\nexport const useComposerRunStartFocusGuard = (): ComposerRunStartFocusGuard => {\n const threadRootRef = useThreadRootElementRef();\n\n return useCallback(\n (composerElement: HTMLElement | null) => {\n if (!composerElement) return false;\n\n const doc = composerElement.ownerDocument;\n const active = doc.activeElement;\n if (!active || active === doc.body) return true;\n if (active === composerElement) return false;\n\n const composerRoot = composerElement.closest(\"[data-aui-composer-type]\");\n if (composerRoot?.contains(active)) return true;\n\n const threadRoot = threadRootRef?.current ?? null;\n return (\n threadRoot !== null &&\n threadRoot.contains(active) &&\n active.closest(\"[data-aui-thread-root]\") === threadRoot\n );\n },\n [threadRootRef],\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,MAAaO,sCAAgC;CAAA,MAAAC,IAAAP,EAAA,CAAA;CAC3C,MAAAQ,gBAAsBN,wBAAwB;CAAE,IAAAO;CAAA,IAAAF,EAAA,OAAAC,eAAA;EAG9CC,MAAAL,oBAAA;GACE,IAAI,CAACA,iBAAe,OAAS;GAE7B,MAAAM,MAAYN,gBAAeO;GAC3B,MAAAC,SAAeF,IAAGG;GAClB,IAAI,CAACD,UAAUA,WAAWF,IAAGI,MAAK,OAAS;GAC3C,IAAIF,WAAWR,iBAAe,OAAS;GAGvC,IADqBA,gBAAeY,QAAS,0BACzCD,CAAY,EAAAE,SAAWL,MAAM,GAAC,OAAS;GAE3C,MAAAM,aAAmBV,eAAaW,WAAb;GAA+B,OAEhDD,eAAe,QACfA,WAAUD,SAAUL,MAAM,KAC1BA,OAAMI,QAAS,wBAAwB,MAAME;EAAU;EAE1DX,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAlBIE;AAoBN"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ComposerRunStartFocusGuard } from "../primitives/composer/useComposerRunStartFocusGuard.js";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Experimental since 2026-11-12. Not scheduled for removal; the API
|
|
4
|
+
* may change in any release.
|
|
5
|
+
*/
|
|
6
|
+
export type Unstable_ComposerRunStartFocusGuard = ComposerRunStartFocusGuard;
|
|
7
|
+
/**
|
|
8
|
+
* The decision `ComposerPrimitive.Input` makes when a run starts: whether the
|
|
9
|
+
* run may move focus into this composer. Alternative composer implementations
|
|
10
|
+
* (`@assistant-ui/react-lexical`) have to make the same call, and can only make
|
|
11
|
+
* it correctly with the thread root from context: a composer portaled outside
|
|
12
|
+
* `ThreadPrimitive.Root` has no `data-aui-thread-root` ancestor.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated Experimental since 2026-11-12. Not scheduled for removal; the API
|
|
15
|
+
* may change in any release.
|
|
16
|
+
*/
|
|
17
|
+
export declare const unstable_useComposerRunStartFocusGuard: () => Unstable_ComposerRunStartFocusGuard;
|
|
18
|
+
//# sourceMappingURL=useComposerRunStartFocusGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useComposerRunStartFocusGuard.d.ts","sourceRoot":"","sources":["../../src/unstable/useComposerRunStartFocusGuard.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,0BAA0B,EAEhC,gEAA6D;AAE9D;;;GAGG;AACH,MAAM,MAAM,mCAAmC,GAAG,0BAA0B,CAAC;AAE7E;;;;;;;;;GASG;AACH,eAAO,MAAM,sCAAsC,QAC7C,mCAAsE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useComposerRunStartFocusGuard } from "../primitives/composer/useComposerRunStartFocusGuard.js";
|
|
3
|
+
// src/unstable/useComposerRunStartFocusGuard.ts
|
|
4
|
+
/**
|
|
5
|
+
* The decision `ComposerPrimitive.Input` makes when a run starts: whether the
|
|
6
|
+
* run may move focus into this composer. Alternative composer implementations
|
|
7
|
+
* (`@assistant-ui/react-lexical`) have to make the same call, and can only make
|
|
8
|
+
* it correctly with the thread root from context: a composer portaled outside
|
|
9
|
+
* `ThreadPrimitive.Root` has no `data-aui-thread-root` ancestor.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Experimental since 2026-11-12. Not scheduled for removal; the API
|
|
12
|
+
* may change in any release.
|
|
13
|
+
*/
|
|
14
|
+
const unstable_useComposerRunStartFocusGuard = () => useComposerRunStartFocusGuard();
|
|
15
|
+
export { unstable_useComposerRunStartFocusGuard };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=useComposerRunStartFocusGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useComposerRunStartFocusGuard.js","names":["ComposerRunStartFocusGuard","useComposerRunStartFocusGuard","Unstable_ComposerRunStartFocusGuard","unstable_useComposerRunStartFocusGuard"],"sources":["../../src/unstable/useComposerRunStartFocusGuard.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ComposerRunStartFocusGuard,\n useComposerRunStartFocusGuard,\n} from \"../primitives/composer/useComposerRunStartFocusGuard\";\n\n/**\n * @deprecated Experimental since 2026-11-12. Not scheduled for removal; the API\n * may change in any release.\n */\nexport type Unstable_ComposerRunStartFocusGuard = ComposerRunStartFocusGuard;\n\n/**\n * The decision `ComposerPrimitive.Input` makes when a run starts: whether the\n * run may move focus into this composer. Alternative composer implementations\n * (`@assistant-ui/react-lexical`) have to make the same call, and can only make\n * it correctly with the thread root from context: a composer portaled outside\n * `ThreadPrimitive.Root` has no `data-aui-thread-root` ancestor.\n *\n * @deprecated Experimental since 2026-11-12. Not scheduled for removal; the API\n * may change in any release.\n */\nexport const unstable_useComposerRunStartFocusGuard =\n (): Unstable_ComposerRunStartFocusGuard => useComposerRunStartFocusGuard();\n"],"mappings":";;;;;;;;;;;;;AAuBA,MAAaG,+CACgCF,8BAA8B"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -570,6 +570,12 @@ export {
|
|
|
570
570
|
type Unstable_TriggerPopoverAriaProps,
|
|
571
571
|
} from "./unstable/useComposerInput";
|
|
572
572
|
|
|
573
|
+
// Unstable - the run-start focus decision shared by composer implementations
|
|
574
|
+
export {
|
|
575
|
+
unstable_useComposerRunStartFocusGuard,
|
|
576
|
+
type Unstable_ComposerRunStartFocusGuard,
|
|
577
|
+
} from "./unstable/useComposerRunStartFocusGuard";
|
|
578
|
+
|
|
573
579
|
export type { Assistant } from "./augmentations";
|
|
574
580
|
|
|
575
581
|
// --- mcp-apps ---
|
|
@@ -28,7 +28,7 @@ import { flushTapSync } from "@assistant-ui/tap";
|
|
|
28
28
|
import { useComposerInputPluginRegistryOptional } from "./ComposerInputPluginContext";
|
|
29
29
|
import { useComposerCompactContextOptional } from "./ComposerCompactContext";
|
|
30
30
|
import { useComposerCancelWithFocus } from "./useComposerCancelWithFocus";
|
|
31
|
-
import {
|
|
31
|
+
import { useComposerRunStartFocusGuard } from "./useComposerRunStartFocusGuard";
|
|
32
32
|
import {
|
|
33
33
|
useComposerInputDisabled,
|
|
34
34
|
useComposerInputValue,
|
|
@@ -193,7 +193,7 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
193
193
|
forwardedRef,
|
|
194
194
|
) => {
|
|
195
195
|
const aui = useAui();
|
|
196
|
-
const
|
|
196
|
+
const canTakeFocusOnRunStart = useComposerRunStartFocusGuard();
|
|
197
197
|
const pluginRegistry = useComposerInputPluginRegistryOptional();
|
|
198
198
|
const compactContext = useComposerCompactContextOptional();
|
|
199
199
|
|
|
@@ -350,24 +350,10 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
350
350
|
|
|
351
351
|
const focusOnRunStart = useCallback(() => {
|
|
352
352
|
const textarea = textareaRef.current;
|
|
353
|
-
if (!textarea) return;
|
|
354
|
-
const doc = textarea.ownerDocument;
|
|
355
|
-
const active = doc.activeElement;
|
|
356
|
-
if (active === textarea) return;
|
|
357
|
-
|
|
358
|
-
const root = threadRootRef?.current;
|
|
359
|
-
const composerRoot = textarea.closest("[data-aui-composer-type]");
|
|
360
|
-
if (
|
|
361
|
-
active &&
|
|
362
|
-
active !== doc.body &&
|
|
363
|
-
!composerRoot?.contains(active) &&
|
|
364
|
-
(!root?.contains(active) ||
|
|
365
|
-
active.closest("[data-aui-thread-root]") !== root)
|
|
366
|
-
)
|
|
367
|
-
return;
|
|
353
|
+
if (!textarea || !canTakeFocusOnRunStart(textarea)) return;
|
|
368
354
|
|
|
369
355
|
focus();
|
|
370
|
-
}, [focus,
|
|
356
|
+
}, [focus, canTakeFocusOnRunStart]);
|
|
371
357
|
|
|
372
358
|
useEffect(() => focus(), [focus]);
|
|
373
359
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import { useThreadRootElementRef } from "../thread/ThreadRootElementContext";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Decides whether a run start may move focus into a composer, mirroring what
|
|
8
|
+
* `ComposerPrimitive.Input` does: focus moves only when it is not somewhere
|
|
9
|
+
* outside the composer and outside the composer's thread.
|
|
10
|
+
*/
|
|
11
|
+
export type ComposerRunStartFocusGuard = (
|
|
12
|
+
composerElement: HTMLElement | null,
|
|
13
|
+
) => boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The run-start focus decision `ComposerPrimitive.Input` makes, for other
|
|
17
|
+
* composer implementations (`@assistant-ui/react-lexical`) that have to make the
|
|
18
|
+
* same call. The thread root comes from context, so a composer portaled outside
|
|
19
|
+
* `ThreadPrimitive.Root` still knows which thread it belongs to; reading the
|
|
20
|
+
* `data-aui-thread-root` attribute instead concludes that focus is elsewhere and
|
|
21
|
+
* leaves the keyboard where the thread put it.
|
|
22
|
+
*
|
|
23
|
+
* Returns `false` for a missing element, and for the element itself already
|
|
24
|
+
* holding focus.
|
|
25
|
+
*/
|
|
26
|
+
export const useComposerRunStartFocusGuard = (): ComposerRunStartFocusGuard => {
|
|
27
|
+
const threadRootRef = useThreadRootElementRef();
|
|
28
|
+
|
|
29
|
+
return useCallback(
|
|
30
|
+
(composerElement: HTMLElement | null) => {
|
|
31
|
+
if (!composerElement) return false;
|
|
32
|
+
|
|
33
|
+
const doc = composerElement.ownerDocument;
|
|
34
|
+
const active = doc.activeElement;
|
|
35
|
+
if (!active || active === doc.body) return true;
|
|
36
|
+
if (active === composerElement) return false;
|
|
37
|
+
|
|
38
|
+
const composerRoot = composerElement.closest("[data-aui-composer-type]");
|
|
39
|
+
if (composerRoot?.contains(active)) return true;
|
|
40
|
+
|
|
41
|
+
const threadRoot = threadRootRef?.current ?? null;
|
|
42
|
+
return (
|
|
43
|
+
threadRoot !== null &&
|
|
44
|
+
threadRoot.contains(active) &&
|
|
45
|
+
active.closest("[data-aui-thread-root]") === threadRoot
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
[threadRootRef],
|
|
49
|
+
);
|
|
50
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type ComposerRunStartFocusGuard,
|
|
5
|
+
useComposerRunStartFocusGuard,
|
|
6
|
+
} from "../primitives/composer/useComposerRunStartFocusGuard";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Experimental since 2026-11-12. Not scheduled for removal; the API
|
|
10
|
+
* may change in any release.
|
|
11
|
+
*/
|
|
12
|
+
export type Unstable_ComposerRunStartFocusGuard = ComposerRunStartFocusGuard;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The decision `ComposerPrimitive.Input` makes when a run starts: whether the
|
|
16
|
+
* run may move focus into this composer. Alternative composer implementations
|
|
17
|
+
* (`@assistant-ui/react-lexical`) have to make the same call, and can only make
|
|
18
|
+
* it correctly with the thread root from context: a composer portaled outside
|
|
19
|
+
* `ThreadPrimitive.Root` has no `data-aui-thread-root` ancestor.
|
|
20
|
+
*
|
|
21
|
+
* @deprecated Experimental since 2026-11-12. Not scheduled for removal; the API
|
|
22
|
+
* may change in any release.
|
|
23
|
+
*/
|
|
24
|
+
export const unstable_useComposerRunStartFocusGuard =
|
|
25
|
+
(): Unstable_ComposerRunStartFocusGuard => useComposerRunStartFocusGuard();
|