@mcp-b/react-components 0.48.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentChatQueue-C_Jaw3Ia.d.ts +48 -0
- package/dist/AgentToolRunsContext-GMe_hSnD.d.ts +35 -0
- package/dist/Avatar-o2NO1fCG.d.ts +124 -0
- package/dist/{Button-CZt3yywF.d.ts → Button-DjONW5UW.d.ts} +1 -1
- package/dist/{CodeBlock-C380GD5t.d.ts → CodeBlock--r6GS8YV.d.ts} +8 -2
- package/dist/{CodeBlock-BSJl682D.js → CodeBlock-g8sADidM.js} +8 -8
- package/dist/{FileTree-DvE0hNZu.js → FileTree-H8mMg4rV.js} +21 -30
- package/dist/{IconButton-BAUFhUk8.d.ts → IconButton-ByiyjkYE.d.ts} +2 -2
- package/dist/{Message-D_vCVEGB.d.ts → Message-DyaTBiV7.d.ts} +17 -4
- package/dist/MessageScrollerVirtual-D4afYwVB.d.ts +84 -0
- package/dist/{PromptInput-DtJHyp0S.d.ts → PromptInput-C4Mofitz.d.ts} +44 -31
- package/dist/PromptInputApproval-D2hpn54U.d.ts +44 -0
- package/dist/Separator-CzhtLYE1.d.ts +41 -0
- package/dist/Toolbar-CGY004u0.d.ts +155 -0
- package/dist/{Workspace-LIoU30n7.d.ts → Workspace-HzGrWDX3.d.ts} +1 -1
- package/dist/{WorkspaceFile-Dq-GC0_T.d.ts → WorkspaceFile-Bouauobc.d.ts} +1 -1
- package/dist/{WorkspaceFileView-C_WnYm-a.js → WorkspaceFileView-DYPtRVpM.js} +5 -4
- package/dist/{WorkspaceLink-B1d2GIGl.js → WorkspaceLink-BYZG-V_I.js} +8 -91
- package/dist/{WorkspaceMessageResponse-BqOezptB.js → WorkspaceMessageResponse-CUJk9_P5.js} +2 -2
- package/dist/components/agents-sdk/AgentActivity.js +1 -1
- package/dist/components/agents-sdk/AgentChat.d.ts +198 -2
- package/dist/components/agents-sdk/AgentChat.js +527 -672
- package/dist/components/agents-sdk/AgentChatQueue.d.ts +2 -0
- package/dist/components/agents-sdk/AgentChatQueue.js +206 -0
- package/dist/components/agents-sdk/AgentEvent.js +2 -2
- package/dist/components/agents-sdk/AgentToolRunsContext.d.ts +2 -2
- package/dist/components/agents-sdk/AgentToolRunsContext.js +1 -36
- package/dist/components/agents-sdk/BrowserLiveScreen.js +22 -14
- package/dist/components/agents-sdk/BrowserLiveView.js +1 -1
- package/dist/components/agents-sdk/BrowserReplay.d.ts +1 -1
- package/dist/components/agents-sdk/BrowserReplay.js +1 -1
- package/dist/components/agents-sdk/BrowserRunPanel.d.ts +3 -0
- package/dist/components/agents-sdk/BrowserRunPanel.js +32 -31
- package/dist/components/agents-sdk/EmployeeChrome.d.ts +212 -0
- package/dist/components/agents-sdk/EmployeeChrome.js +555 -0
- package/dist/components/agents-sdk/ManagerOffice.d.ts +79 -40
- package/dist/components/agents-sdk/ManagerOffice.js +291 -281
- package/dist/components/agents-sdk/McpConnectionRequest.d.ts +4 -4
- package/dist/components/agents-sdk/McpConnectionRequest.js +4 -3
- package/dist/components/agents-sdk/McpConnectorForm.d.ts +38 -1
- package/dist/components/agents-sdk/McpConnectorForm.js +1 -1
- package/dist/components/agents-sdk/McpPluginCatalog.d.ts +93 -1
- package/dist/components/agents-sdk/McpPluginCatalog.js +5 -4
- package/dist/components/agents-sdk/McpServerIcon.d.ts +17 -0
- package/dist/components/agents-sdk/McpServerIcon.js +25 -0
- package/dist/components/agents-sdk/McpServerPicker.d.ts +4 -3
- package/dist/components/agents-sdk/McpServerPicker.js +4 -3
- package/dist/components/agents-sdk/ModelSelector.d.ts +4 -4
- package/dist/components/agents-sdk/ModelSelector.js +4 -4
- package/dist/components/agents-sdk/PromptInputApproval.d.ts +1 -43
- package/dist/components/agents-sdk/PromptInputApproval.js +1 -1
- package/dist/components/agents-sdk/PromptInputCommands.d.ts +1 -1
- package/dist/components/agents-sdk/PromptInputCommands.js +2 -3
- package/dist/components/agents-sdk/SessionCompaction.d.ts +88 -1
- package/dist/components/agents-sdk/SessionCompaction.js +2 -2
- package/dist/components/agents-sdk/SubagentRunDetails.d.ts +30 -1
- package/dist/components/agents-sdk/SubagentRunDetails.js +57 -1
- package/dist/components/agents-sdk/SubagentRunIndicator.d.ts +9 -9
- package/dist/components/agents-sdk/SubagentRunIndicator.js +19 -24
- package/dist/components/agents-sdk/SubagentRunList.d.ts +6 -3
- package/dist/components/agents-sdk/SubagentRunList.js +4 -2
- package/dist/components/agents-sdk/SubagentRunPanel.d.ts +60 -0
- package/dist/components/agents-sdk/SubagentRunPanel.js +255 -0
- package/dist/components/agents-sdk/SubagentRunSelector.d.ts +8 -4
- package/dist/components/agents-sdk/SubagentRunSelector.js +5 -3
- package/dist/components/agents-sdk/ThinkChat.d.ts +102 -2
- package/dist/components/agents-sdk/ThinkChat.js +233 -2
- package/dist/components/agents-sdk/ThinkChatActivity.d.ts +76 -1
- package/dist/components/agents-sdk/ThinkChatActivity.js +18 -10
- package/dist/components/agents-sdk/ThinkChatContext.d.ts +27 -1
- package/dist/components/agents-sdk/ThinkChatContext.js +1 -1
- package/dist/components/agents-sdk/ThinkChatToolPanels.js +24 -19
- package/dist/components/agents-sdk/ThinkExecutionDetail.js +2 -2
- package/dist/components/agents-sdk/ThinkExecutionStatus.d.ts +1 -1
- package/dist/components/agents-sdk/ThinkExecutionStatus.js +1 -1
- package/dist/components/agents-sdk/ThinkExecutionWorkbench.d.ts +85 -28
- package/dist/components/agents-sdk/ThinkExecutionWorkbench.js +159 -102
- package/dist/components/agents-sdk/ThinkFullApp.d.ts +40 -158
- package/dist/components/agents-sdk/ThinkFullApp.js +71 -290
- package/dist/components/agents-sdk/ThinkRecoveryNotice.d.ts +18 -1
- package/dist/components/agents-sdk/ThinkRecoveryNotice.js +1 -1
- package/dist/components/agents-sdk/ThinkRoutineActions.d.ts +51 -0
- package/dist/components/agents-sdk/ThinkRoutineActions.js +201 -0
- package/dist/components/agents-sdk/ThinkRoutineBrowser.d.ts +4 -1
- package/dist/components/agents-sdk/ThinkRoutineBrowser.js +17 -15
- package/dist/components/agents-sdk/ThinkRoutineDetail.js +11 -11
- package/dist/components/agents-sdk/ThinkRoutineForm.d.ts +2 -1
- package/dist/components/agents-sdk/ThinkRoutineForm.js +14 -14
- package/dist/components/agents-sdk/ThinkRoutineRuns.js +7 -7
- package/dist/components/agents-sdk/ThinkThreadPicker.d.ts +90 -1
- package/dist/components/agents-sdk/ThinkThreadPicker.js +3 -3
- package/dist/components/agents-sdk/Workspace.d.ts +1 -1
- package/dist/components/agents-sdk/Workspace.js +7 -13
- package/dist/components/agents-sdk/WorkspaceBrowser.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceBrowser.js +1 -1
- package/dist/components/agents-sdk/WorkspaceConcept.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceCorrespondence.d.ts +10 -1
- package/dist/components/agents-sdk/WorkspaceCorrespondence.js +10 -7
- package/dist/components/agents-sdk/WorkspaceExecution.d.ts +5 -14
- package/dist/components/agents-sdk/WorkspaceExecution.js +24 -38
- package/dist/components/agents-sdk/WorkspaceExplorer.d.ts +5 -2
- package/dist/components/agents-sdk/WorkspaceExplorer.js +3 -2
- package/dist/components/agents-sdk/WorkspaceFile.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceFileView.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceFileView.js +1 -1
- package/dist/components/agents-sdk/WorkspaceHeader.js +1 -1
- package/dist/components/agents-sdk/WorkspaceLink.js +1 -1
- package/dist/components/agents-sdk/WorkspaceLive.d.ts +60 -1
- package/dist/components/agents-sdk/WorkspaceMessageResponse.d.ts +47 -1
- package/dist/components/agents-sdk/WorkspaceMessageResponse.js +1 -1
- package/dist/components/agents-sdk/WorkspaceMountManager.d.ts +3 -2
- package/dist/components/agents-sdk/WorkspaceMountManager.js +6 -9
- package/dist/components/agents-sdk/WorkspaceNavigationRestoration.d.ts +38 -0
- package/dist/components/agents-sdk/WorkspaceNavigationRestoration.js +86 -0
- package/dist/components/agents-sdk/WorkspaceProject.d.ts +5 -14
- package/dist/components/agents-sdk/WorkspaceProject.js +21 -35
- package/dist/components/agents-sdk/WorkspaceUserScript.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceUserScript.js +8 -5
- package/dist/components/ai-sdk/Activity.d.ts +1 -1
- package/dist/components/ai-sdk/Activity.js +1 -1
- package/dist/components/ai-sdk/AgentAttention.d.ts +2 -2
- package/dist/components/ai-sdk/AgentChatStartScreen.d.ts +89 -2
- package/dist/components/ai-sdk/AgentChatStartScreen.js +64 -43
- package/dist/components/ai-sdk/AgentMessageParts.d.ts +45 -1
- package/dist/components/ai-sdk/Approval.d.ts +1 -1
- package/dist/components/ai-sdk/Approval.js +2 -2
- package/dist/components/ai-sdk/Artifact.d.ts +2 -2
- package/dist/components/ai-sdk/Artifact.js +1 -1
- package/dist/components/ai-sdk/ChainOfThought.d.ts +1 -1
- package/dist/components/ai-sdk/ChainOfThought.js +1 -1
- package/dist/components/ai-sdk/Checkpoint.js +1 -1
- package/dist/components/ai-sdk/CodeBlock.d.ts +1 -1
- package/dist/components/ai-sdk/CodeBlock.js +1 -1
- package/dist/components/ai-sdk/ComposerLink.js +2 -3
- package/dist/components/ai-sdk/ConnectedAppCards.d.ts +9 -1
- package/dist/components/ai-sdk/ConnectedAppCards.js +28 -21
- package/dist/components/ai-sdk/Context.d.ts +7 -3
- package/dist/components/ai-sdk/Context.js +7 -17
- package/dist/components/ai-sdk/Conversation.d.ts +2 -2
- package/dist/components/ai-sdk/Conversation.js +1 -1
- package/dist/components/ai-sdk/Goal.d.ts +3 -3
- package/dist/components/ai-sdk/Goal.js +3 -3
- package/dist/components/ai-sdk/InlineCitation.d.ts +1 -1
- package/dist/components/ai-sdk/MediaPreviewCard.d.ts +1 -1
- package/dist/components/ai-sdk/MediaPreviewCard.js +1 -1
- package/dist/components/ai-sdk/Message.d.ts +2 -2
- package/dist/components/ai-sdk/Message.js +12 -3
- package/dist/components/ai-sdk/MessageScroller.d.ts +1 -1
- package/dist/components/ai-sdk/MessageScroller.js +1 -1
- package/dist/components/ai-sdk/MessageScrollerVirtual.d.ts +2 -76
- package/dist/components/ai-sdk/MessageScrollerVirtual.js +39 -5
- package/dist/components/ai-sdk/Plan.d.ts +1 -1
- package/dist/components/ai-sdk/Plan.js +1 -1
- package/dist/components/ai-sdk/PromptInput.d.ts +2 -2
- package/dist/components/ai-sdk/PromptInput.js +175 -231
- package/dist/components/ai-sdk/PromptInputComposerEditor.js +32 -9
- package/dist/components/ai-sdk/Queue.d.ts +28 -5
- package/dist/components/ai-sdk/Queue.js +20 -5
- package/dist/components/ai-sdk/Reasoning.d.ts +1 -1
- package/dist/components/ai-sdk/Reasoning.js +5 -5
- package/dist/components/ai-sdk/Sources.d.ts +1 -1
- package/dist/components/ai-sdk/Sources.js +1 -1
- package/dist/components/ai-sdk/Task.d.ts +1 -1
- package/dist/components/ai-sdk/Task.js +1 -1
- package/dist/components/extension/ChatGptSignInScreen.d.ts +1 -1
- package/dist/components/extension/ChatGptSignInScreen.js +1 -1
- package/dist/components/extension/CodexModelSelector.d.ts +5 -0
- package/dist/components/extension/CodexModelSelector.js +2 -2
- package/dist/components/extension/ConversationTabPicker.d.ts +1 -0
- package/dist/components/extension/ConversationTabPicker.js +2 -2
- package/dist/components/foundations/AlertDialog.d.ts +1 -1
- package/dist/components/foundations/AppIcon.d.ts +3 -2
- package/dist/components/foundations/Autocomplete.js +6 -1
- package/dist/components/foundations/Avatar.d.ts +1 -121
- package/dist/components/foundations/Button.d.ts +1 -1
- package/dist/components/foundations/Card.d.ts +22 -27
- package/dist/components/foundations/Card.js +51 -32
- package/dist/components/foundations/Checkbox.js +1 -1
- package/dist/components/foundations/CheckboxGroup.d.ts +1 -1
- package/dist/components/foundations/Collapsible.d.ts +1 -1
- package/dist/components/foundations/Collapsible.js +1 -1
- package/dist/components/foundations/Combobox.js +6 -1
- package/dist/components/foundations/ContextMenu.js +1 -1
- package/dist/components/foundations/Dialog.d.ts +106 -1
- package/dist/components/foundations/EmptyState.d.ts +1 -1
- package/dist/components/foundations/Field.d.ts +2 -1
- package/dist/components/foundations/Fieldset.d.ts +1 -1
- package/dist/components/foundations/Form.d.ts +4 -4
- package/dist/components/foundations/IconButton.d.ts +1 -1
- package/dist/components/foundations/Label.d.ts +1 -1
- package/dist/components/foundations/LinkButton.d.ts +2 -2
- package/dist/components/foundations/Menubar.js +1 -1
- package/dist/components/foundations/Meter.d.ts +1 -1
- package/dist/components/foundations/NumberField.d.ts +1 -1
- package/dist/components/foundations/ScrollArea.d.ts +1 -1
- package/dist/components/foundations/SearchField.d.ts +1 -1
- package/dist/components/foundations/SearchField.js +1 -1
- package/dist/components/foundations/Select.js +7 -2
- package/dist/components/foundations/Separator.d.ts +1 -40
- package/dist/components/foundations/Stepper.d.ts +1 -1
- package/dist/components/foundations/Stepper.js +1 -1
- package/dist/components/foundations/Textarea.d.ts +1 -1
- package/dist/components/foundations/Toast.d.ts +5 -1
- package/dist/components/foundations/Toast.js +1 -1
- package/dist/components/foundations/Toggle.d.ts +70 -1
- package/dist/components/foundations/ToggleGroup.d.ts +4 -3
- package/dist/components/foundations/ToggleGroup.js +1 -1
- package/dist/components/foundations/Toolbar.d.ts +1 -151
- package/dist/components/foundations/TransitionSurface.d.ts +1 -1
- package/dist/components/foundations/icons.js +1 -1
- package/dist/components/general-purpose/ActionGuide.d.ts +10 -26
- package/dist/components/general-purpose/ActionGuide.js +4 -18
- package/dist/components/general-purpose/AppTopBar.d.ts +4 -2
- package/dist/components/general-purpose/Commit.d.ts +2 -2
- package/dist/components/general-purpose/Commit.js +2 -2
- package/dist/components/general-purpose/EnvironmentVariables.d.ts +2 -2
- package/dist/components/general-purpose/EnvironmentVariables.js +2 -2
- package/dist/components/general-purpose/FileTree.d.ts +1 -7
- package/dist/components/general-purpose/FileTree.js +1 -1
- package/dist/components/general-purpose/PricingPlanCard.d.ts +4 -0
- package/dist/components/general-purpose/PricingPlanCard.js +2 -2
- package/dist/components/general-purpose/PricingUsageCalculator.js +2 -2
- package/dist/components/general-purpose/ResizableSidePanel.d.ts +2 -2
- package/dist/components/general-purpose/ResponsiveSidebarShell.d.ts +128 -2
- package/dist/components/general-purpose/ResponsiveSidebarShell.js +120 -102
- package/dist/components/general-purpose/SettingsFormDialog.d.ts +14 -27
- package/dist/components/general-purpose/SettingsFormDialog.js +42 -72
- package/dist/components/general-purpose/SetupChecklist.d.ts +1 -0
- package/dist/components/general-purpose/SetupChecklist.js +76 -1
- package/dist/components/general-purpose/Terminal.d.ts +3 -3
- package/dist/components/general-purpose/Terminal.js +11 -6
- package/dist/components/general-purpose/TestResults.d.ts +23 -11
- package/dist/components/general-purpose/TestResults.js +49 -51
- package/dist/components/general-purpose/ThemeModeControl.d.ts +2 -0
- package/dist/components/general-purpose/ThemeModeControl.js +2 -2
- package/dist/components/general-purpose/WebPreview.d.ts +29 -4
- package/dist/components/general-purpose/WebPreview.js +39 -14
- package/dist/components/nanites/AgentConnection.js +2 -2
- package/dist/components/nanites/AgentToolDetail.d.ts +13 -11
- package/dist/components/nanites/AgentToolDetail.js +21 -42
- package/dist/{copy-button-Dk2vRe9j.js → copy-button-CSDuDfdP.js} +1 -1
- package/dist/{copy-button-C0JyjClr.d.ts → copy-button-OUwOdgEm.d.ts} +1 -1
- package/dist/mcp-server-mAErsxHU.js +27 -0
- package/dist/styles/activity.css +1 -96
- package/dist/styles/agent-chat.css +75 -102
- package/dist/styles/agent-tool-detail.css +0 -16
- package/dist/styles/base.css +1 -1
- package/dist/styles/browser-run-panel.css +1 -15
- package/dist/styles/button.css +7 -1
- package/dist/styles/code-block.css +12 -0
- package/dist/styles/composition-motion.css +0 -2
- package/dist/styles/employee-chrome.css +43 -0
- package/dist/styles/file-tree.css +5 -0
- package/dist/styles/index.css +4 -2
- package/dist/styles/message.css +2 -10
- package/dist/styles/queue.css +71 -0
- package/dist/styles/subagent-run.css +122 -6
- package/dist/styles/test-results.css +2 -5
- package/dist/styles/think-chat-activity.css +13 -0
- package/dist/styles/think-chat-tool-panels.css +81 -0
- package/dist/styles/think-execution-workbench.css +2 -8
- package/dist/styles/think-full-app.css +42 -251
- package/dist/styles/{think-routine-library.css → think-routine.css} +64 -80
- package/dist/styles/web-preview.css +15 -1
- package/dist/utils/mcp-server-catalog.d.ts +1112 -2
- package/dist/utils/mcp-server-catalog.js +28 -9
- package/dist/utils/structured-code.d.ts +1 -1
- package/dist/{workspace-assets-GqsCYxqT.js → workspace-assets-Bg7XhPsk.js} +2 -2
- package/package.json +7 -3
- package/dist/AgentChat-BLmQghkt.d.ts +0 -327
- package/dist/AgentChatStartScreen-Bkv7Avni.d.ts +0 -84
- package/dist/AgentMessageParts-C7L-Mv9U.d.ts +0 -46
- package/dist/AgentToolRunsContext-jtmveaRE.d.ts +0 -57
- package/dist/Dialog-B_FhRWaz.d.ts +0 -107
- package/dist/McpConnectorForm-CeYNY0MI.d.ts +0 -39
- package/dist/McpPluginCatalog-3qWu8oK1.d.ts +0 -92
- package/dist/ResponsiveSidebarShell-BTVPxLJK.d.ts +0 -123
- package/dist/SessionCompaction-CmTJFpzj.d.ts +0 -89
- package/dist/SetupChecklist-DeTU9YpW.js +0 -77
- package/dist/ThinkChat-CwMdEum8.d.ts +0 -185
- package/dist/ThinkChat-DiI6hhDP.js +0 -332
- package/dist/ThinkChatActivity-B3lGVS-6.d.ts +0 -77
- package/dist/ThinkChatContext-COIgzkYp.d.ts +0 -28
- package/dist/ThinkRecoveryNotice-DGWr94rk.d.ts +0 -19
- package/dist/ThinkThreadPicker-yFz4vvIf.d.ts +0 -91
- package/dist/Toggle-DLrIf5YH.d.ts +0 -69
- package/dist/WorkspaceLive-DfjH1Ypm.d.ts +0 -61
- package/dist/WorkspaceMessageResponse-kJYU8Onj.d.ts +0 -48
- package/dist/components/agents-sdk/ThinkFullAppViewSwitch.d.ts +0 -31
- package/dist/components/agents-sdk/ThinkFullAppViewSwitch.js +0 -34
- package/dist/components/agents-sdk/ThinkRoutineLibrary.d.ts +0 -80
- package/dist/components/agents-sdk/ThinkRoutineLibrary.js +0 -159
- package/dist/components/agents-sdk/ThinkSidepanel.d.ts +0 -200
- package/dist/components/agents-sdk/ThinkSidepanel.js +0 -775
- package/dist/mcp-server-7NR24ASj.js +0 -69
- package/dist/mcp-server-catalog-C_g7C-9o.d.ts +0 -1108
- package/dist/styles/think-sidepanel.css +0 -78
- package/dist/think-agent-Cip5KAPj.d.ts +0 -7
- package/dist/{icons-CeGfXO21.js → icons-cuEtsgj9.js} +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as cx } from "../../class-names-BiMDVpUo.js";
|
|
2
|
-
import { _ as DotIcon, d as CheckIcon, i as ArrowRightIcon } from "../../icons-
|
|
2
|
+
import { _ as DotIcon, d as CheckIcon, i as ArrowRightIcon } from "../../icons-cuEtsgj9.js";
|
|
3
3
|
import { Popover } from "../foundations/Popover.js";
|
|
4
4
|
import { t as ProgressRing } from "../../progress-ring-Cgii90dC.js";
|
|
5
5
|
import * as React from "react";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { AttachmentsContext, PermissionMode, PromptInput, PromptInputActionAddAttachments, PromptInputActionAddAttachmentsProps, PromptInputActionAddScreenshot, PromptInputActionAddScreenshotProps, PromptInputActionMenu, PromptInputActionMenuContent, PromptInputActionMenuContentProps, PromptInputActionMenuItem, PromptInputActionMenuItemProps, PromptInputActionMenuProps, PromptInputActionMenuTrigger, PromptInputActionMenuTriggerProps, PromptInputAttachment, PromptInputAttachmentProps, PromptInputAttachments, PromptInputAttachmentsProps, PromptInputBody, PromptInputBodyProps, PromptInputButton, PromptInputButtonProps, PromptInputButtonTooltip, PromptInputCommandComposer, PromptInputCommandComposerProps, PromptInputCommandDefinition, PromptInputCommandTrigger, PromptInputContextAction, PromptInputContextItem, PromptInputContextSelector, PromptInputContextSelectorProps, PromptInputControllerProps, PromptInputDictation, PromptInputDictationProps, PromptInputFooter, PromptInputFooterProps, PromptInputHeader, PromptInputHeaderProps, PromptInputHoverCard, PromptInputHoverCardContent, PromptInputHoverCardContentProps, PromptInputHoverCardProps, PromptInputHoverCardTrigger, PromptInputHoverCardTriggerProps, PromptInputMessage, PromptInputPermissionSelector, PromptInputPermissionSelectorProps, PromptInputProps, PromptInputProvider, PromptInputProviderProps, PromptInputReference, PromptInputSubmit, PromptInputSubmitProps, PromptInputTab, PromptInputTabBody, PromptInputTabBodyProps, PromptInputTabItem, PromptInputTabItemProps, PromptInputTabLabel, PromptInputTabLabelProps, PromptInputTabProps, PromptInputTabsList, PromptInputTabsListProps, PromptInputTextarea, PromptInputTextareaProps, PromptInputTools, PromptInputToolsProps, PromptInputTooltipConfig, PromptInputTray, PromptInputTrayProps, PromptInputVoiceInput, TextInputContext, TooltipSide, composerLinksToReferences, usePromptInputAttachments, usePromptInputController
|
|
1
|
+
import { $ as PromptInputProviderProps, A as PromptInputContextItem, B as PromptInputHeader, C as PromptInputButtonProps, Ct as composerLinksToReferences, D as PromptInputCommandDefinition, E as PromptInputCommandComposerProps, F as PromptInputDictationProps, G as PromptInputHoverCardProps, H as PromptInputHoverCard, I as PromptInputFooter, J as PromptInputMessage, K as PromptInputHoverCardTrigger, L as PromptInputFooterEnd, M as PromptInputContextSelectorProps, N as PromptInputControllerProps, O as PromptInputCommandTrigger, P as PromptInputDictation, Q as PromptInputProvider, R as PromptInputFooterEndProps, S as PromptInputButton, St as TooltipSide, T as PromptInputCommandComposer, Tt as usePromptInputController, U as PromptInputHoverCardContent, V as PromptInputHeaderProps, W as PromptInputHoverCardContentProps, X as PromptInputPermissionSelectorProps, Y as PromptInputPermissionSelector, Z as PromptInputProps, _ as PromptInputAttachmentProps, _t as PromptInputTooltipConfig, a as PromptInputActionAddAttachmentsProps, at as PromptInputTabBodyProps, b as PromptInputBody, bt as PromptInputVoiceInput, c as PromptInputActionMenu, ct as PromptInputTabLabel, d as PromptInputActionMenuItem, dt as PromptInputTabsList, et as PromptInputReference, f as PromptInputActionMenuItemProps, ft as PromptInputTabsListProps, g as PromptInputAttachment, gt as PromptInputToolsProps, h as PromptInputActionMenuTriggerProps, ht as PromptInputTools, i as PromptInputActionAddAttachments, it as PromptInputTabBody, j as PromptInputContextSelector, k as PromptInputContextAction, l as PromptInputActionMenuContent, lt as PromptInputTabLabelProps, m as PromptInputActionMenuTrigger, mt as PromptInputTextareaProps, n as PermissionMode, nt as PromptInputSubmitProps, o as PromptInputActionAddScreenshot, ot as PromptInputTabItem, p as PromptInputActionMenuProps, pt as PromptInputTextarea, q as PromptInputHoverCardTriggerProps, r as PromptInput, rt as PromptInputTab, s as PromptInputActionAddScreenshotProps, st as PromptInputTabItemProps, t as AttachmentsContext, tt as PromptInputSubmit, u as PromptInputActionMenuContentProps, ut as PromptInputTabProps, v as PromptInputAttachments, vt as PromptInputTray, w as PromptInputButtonTooltip, wt as usePromptInputAttachments, x as PromptInputBodyProps, xt as TextInputContext, y as PromptInputAttachmentsProps, yt as PromptInputTrayProps, z as PromptInputFooterProps } from "../../PromptInput-C4Mofitz.js";
|
|
2
|
+
export { AttachmentsContext, PermissionMode, PromptInput, PromptInputActionAddAttachments, PromptInputActionAddAttachmentsProps, PromptInputActionAddScreenshot, PromptInputActionAddScreenshotProps, PromptInputActionMenu, PromptInputActionMenuContent, PromptInputActionMenuContentProps, PromptInputActionMenuItem, PromptInputActionMenuItemProps, PromptInputActionMenuProps, PromptInputActionMenuTrigger, PromptInputActionMenuTriggerProps, PromptInputAttachment, PromptInputAttachmentProps, PromptInputAttachments, PromptInputAttachmentsProps, PromptInputBody, PromptInputBodyProps, PromptInputButton, PromptInputButtonProps, PromptInputButtonTooltip, PromptInputCommandComposer, PromptInputCommandComposerProps, PromptInputCommandDefinition, PromptInputCommandTrigger, PromptInputContextAction, PromptInputContextItem, PromptInputContextSelector, PromptInputContextSelectorProps, PromptInputControllerProps, PromptInputDictation, PromptInputDictationProps, PromptInputFooter, PromptInputFooterEnd, PromptInputFooterEndProps, PromptInputFooterProps, PromptInputHeader, PromptInputHeaderProps, PromptInputHoverCard, PromptInputHoverCardContent, PromptInputHoverCardContentProps, PromptInputHoverCardProps, PromptInputHoverCardTrigger, PromptInputHoverCardTriggerProps, PromptInputMessage, PromptInputPermissionSelector, PromptInputPermissionSelectorProps, PromptInputProps, PromptInputProvider, PromptInputProviderProps, PromptInputReference, PromptInputSubmit, PromptInputSubmitProps, PromptInputTab, PromptInputTabBody, PromptInputTabBodyProps, PromptInputTabItem, PromptInputTabItemProps, PromptInputTabLabel, PromptInputTabLabelProps, PromptInputTabProps, PromptInputTabsList, PromptInputTabsListProps, PromptInputTextarea, PromptInputTextareaProps, PromptInputTools, PromptInputToolsProps, PromptInputTooltipConfig, PromptInputTray, PromptInputTrayProps, PromptInputVoiceInput, TextInputContext, TooltipSide, composerLinksToReferences, usePromptInputAttachments, usePromptInputController };
|
|
@@ -1,102 +1,171 @@
|
|
|
1
1
|
import { composerTriggerMatch, parseComposerLinks, replaceComposerTrigger } from "../../utils/composer-link.js";
|
|
2
2
|
import { n as mergeBaseClassName, t as cx } from "../../class-names-BiMDVpUo.js";
|
|
3
|
-
import { B as PlusIcon, C as FolderIcon, I as PaperclipIcon, J as StopIcon, K as SpinnerIcon, M as MicrophoneIcon, P as MonitorIcon, S as FileIcon, a as ArrowUpIcon, d as CheckIcon, et as WarningIcon, f as ChevronDownIcon, nt as XIcon, q as SquareIcon, tt as WrenchIcon } from "../../icons-
|
|
3
|
+
import { B as PlusIcon, C as FolderIcon, I as PaperclipIcon, J as StopIcon, K as SpinnerIcon, M as MicrophoneIcon, P as MonitorIcon, S as FileIcon, a as ArrowUpIcon, d as CheckIcon, et as WarningIcon, f as ChevronDownIcon, nt as XIcon, q as SquareIcon, tt as WrenchIcon } from "../../icons-cuEtsgj9.js";
|
|
4
4
|
import { Button } from "../foundations/Button.js";
|
|
5
5
|
import { Tooltip } from "../foundations/Tooltip.js";
|
|
6
6
|
import { IconButton } from "../foundations/IconButton.js";
|
|
7
|
+
import { t as AttachmentPreview } from "../../attachment-preview-1CXJvrmb.js";
|
|
8
|
+
import { a as formatErrorMessage, i as formatClock, n as clamp } from "../../format-COCyV98Z.js";
|
|
9
|
+
import { n as mergeRefs } from "../../merge-refs-DF_7w2x_.js";
|
|
10
|
+
import { ComposerLink } from "./ComposerLink.js";
|
|
7
11
|
import { Autocomplete } from "../foundations/Autocomplete.js";
|
|
8
12
|
import { Kbd } from "../foundations/Kbd.js";
|
|
9
13
|
import { Menu } from "../foundations/Menu.js";
|
|
10
14
|
import { PreviewCard } from "../foundations/PreviewCard.js";
|
|
11
15
|
import { Tabs } from "../foundations/Tabs.js";
|
|
12
|
-
import {
|
|
13
|
-
import { a as formatErrorMessage, i as formatClock, n as clamp } from "../../format-COCyV98Z.js";
|
|
14
|
-
import { n as mergeRefs } from "../../merge-refs-DF_7w2x_.js";
|
|
15
|
-
import { ComposerLink } from "./ComposerLink.js";
|
|
16
|
-
import { PromptInputComposerEditor, readComposerDom, writeComposerDom } from "./PromptInputComposerEditor.js";
|
|
16
|
+
import { PromptInputComposerEditor } from "./PromptInputComposerEditor.js";
|
|
17
17
|
import * as React from "react";
|
|
18
18
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
19
|
//#region src/components/ai-sdk/PromptInput.tsx
|
|
20
20
|
const PromptInputController = React.createContext(null);
|
|
21
|
-
const
|
|
22
|
-
function
|
|
21
|
+
const PromptInputSubmissionContext = React.createContext(null);
|
|
22
|
+
function usePromptInputController() {
|
|
23
|
+
const ctx = React.useContext(PromptInputController);
|
|
24
|
+
if (!ctx) throw new Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
|
|
25
|
+
return ctx;
|
|
26
|
+
}
|
|
27
|
+
function usePromptInputAttachments() {
|
|
28
|
+
return usePromptInputController().attachments;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Owns one draft and file picker across composer layouts. Keep this boundary
|
|
32
|
+
* mounted when switching between a welcome view and a conversation, and compose
|
|
33
|
+
* PromptInput forms, starters, attachments, and dictation beneath it.
|
|
34
|
+
*/
|
|
35
|
+
function PromptInputProvider({ initialInput = "", value, onValueChange, accept, multiple, maxFiles, maxFileSize, onError, children }) {
|
|
36
|
+
const [uncontrolledInput, setUncontrolledInput] = React.useState(initialInput);
|
|
23
37
|
const [files, setFiles] = React.useState([]);
|
|
24
38
|
const filesRef = React.useRef(files);
|
|
25
|
-
React.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
React.
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
const fileInputRef = React.useRef(null);
|
|
40
|
+
const text = value ?? uncontrolledInput;
|
|
41
|
+
const textRevision = React.useRef(0);
|
|
42
|
+
const serializing = React.useRef(false);
|
|
43
|
+
React.useLayoutEffect(() => {
|
|
44
|
+
textRevision.current += 1;
|
|
45
|
+
}, [text]);
|
|
46
|
+
const setInput = React.useCallback((next) => {
|
|
47
|
+
textRevision.current += 1;
|
|
48
|
+
if (value === void 0) setUncontrolledInput(next);
|
|
49
|
+
onValueChange?.(next);
|
|
50
|
+
}, [onValueChange, value]);
|
|
51
|
+
React.useEffect(() => () => revokeFileUrls(filesRef.current), []);
|
|
31
52
|
const add = React.useCallback((incomingFiles) => {
|
|
32
|
-
const incoming = Array.from(incomingFiles)
|
|
33
|
-
|
|
34
|
-
|
|
53
|
+
const incoming = Array.from(incomingFiles);
|
|
54
|
+
const patterns = accept?.toLowerCase().split(",").map((part) => part.trim()).filter(Boolean);
|
|
55
|
+
const accepted = incoming.filter((file) => !patterns?.length || patterns.some((pattern) => pattern.startsWith(".") ? file.name.toLowerCase().endsWith(pattern) : pattern.endsWith("/*") ? file.type.toLowerCase().startsWith(pattern.slice(0, -1)) : file.type.toLowerCase() === pattern));
|
|
56
|
+
if (incoming.length && accepted.length === 0) {
|
|
57
|
+
onError?.({
|
|
58
|
+
code: "accept",
|
|
59
|
+
message: "No files match the accepted types."
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const sized = accepted.filter((file) => maxFileSize === void 0 || file.size <= maxFileSize);
|
|
64
|
+
if (accepted.length && sized.length === 0) {
|
|
65
|
+
onError?.({
|
|
66
|
+
code: "max_file_size",
|
|
67
|
+
message: "All files exceed the maximum size."
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const capacity = maxFiles === void 0 ? sized.length : Math.max(0, maxFiles - filesRef.current.length);
|
|
72
|
+
const capped = sized.slice(0, capacity);
|
|
73
|
+
if (sized.length > capacity) onError?.({
|
|
74
|
+
code: "max_files",
|
|
75
|
+
message: "Too many files. Some were not added."
|
|
76
|
+
});
|
|
77
|
+
if (!capped.length) return;
|
|
78
|
+
const next = [...filesRef.current, ...capped.map(fileToPart)];
|
|
79
|
+
filesRef.current = next;
|
|
80
|
+
setFiles(next);
|
|
81
|
+
}, [
|
|
82
|
+
accept,
|
|
83
|
+
maxFileSize,
|
|
84
|
+
maxFiles,
|
|
85
|
+
onError
|
|
86
|
+
]);
|
|
35
87
|
const remove = React.useCallback((id) => {
|
|
36
88
|
const found = filesRef.current.find((file) => file.id === id);
|
|
37
89
|
if (found) revokeFileObjectUrl(found);
|
|
38
|
-
|
|
90
|
+
const next = filesRef.current.filter((file) => file.id !== id);
|
|
91
|
+
filesRef.current = next;
|
|
92
|
+
setFiles(next);
|
|
39
93
|
}, []);
|
|
40
94
|
const clear = React.useCallback(() => {
|
|
41
95
|
revokeFileUrls(filesRef.current);
|
|
96
|
+
filesRef.current = [];
|
|
42
97
|
setFiles([]);
|
|
43
98
|
}, []);
|
|
44
|
-
|
|
99
|
+
const submitDraft = React.useCallback(async (onSubmit, event) => {
|
|
100
|
+
if (serializing.current) return;
|
|
101
|
+
serializing.current = true;
|
|
102
|
+
const revision = textRevision.current;
|
|
103
|
+
const snapshot = filesRef.current;
|
|
104
|
+
let submission;
|
|
105
|
+
try {
|
|
106
|
+
const submittedFiles = await Promise.all(snapshot.map(resolveSubmittedFile));
|
|
107
|
+
submission = onSubmit?.({
|
|
108
|
+
text: text.trim(),
|
|
109
|
+
files: submittedFiles
|
|
110
|
+
}, event);
|
|
111
|
+
if (textRevision.current === revision) setInput("");
|
|
112
|
+
const submittedIds = new Set(snapshot.map((file) => file.id));
|
|
113
|
+
const remaining = filesRef.current.filter((file) => !submittedIds.has(file.id));
|
|
114
|
+
revokeFileUrls(filesRef.current.filter((file) => submittedIds.has(file.id)));
|
|
115
|
+
filesRef.current = remaining;
|
|
116
|
+
setFiles(remaining);
|
|
117
|
+
} catch {
|
|
118
|
+
return;
|
|
119
|
+
} finally {
|
|
120
|
+
serializing.current = false;
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
await submission;
|
|
124
|
+
} catch {}
|
|
125
|
+
}, [text, setInput]);
|
|
126
|
+
const attachments = React.useMemo(() => ({
|
|
45
127
|
add,
|
|
128
|
+
remove,
|
|
46
129
|
clear,
|
|
47
130
|
files,
|
|
48
|
-
|
|
131
|
+
fileInputRef,
|
|
132
|
+
openFileDialog: () => fileInputRef.current?.click()
|
|
49
133
|
}), [
|
|
50
134
|
add,
|
|
135
|
+
remove,
|
|
51
136
|
clear,
|
|
52
|
-
files
|
|
53
|
-
remove
|
|
137
|
+
files
|
|
54
138
|
]);
|
|
55
|
-
}
|
|
56
|
-
function usePromptInputController() {
|
|
57
|
-
const ctx = React.useContext(PromptInputController);
|
|
58
|
-
if (!ctx) throw new Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
|
|
59
|
-
return ctx;
|
|
60
|
-
}
|
|
61
|
-
function useOptionalPromptInputController() {
|
|
62
|
-
return React.useContext(PromptInputController);
|
|
63
|
-
}
|
|
64
|
-
function useProviderAttachments() {
|
|
65
|
-
const controller = useOptionalPromptInputController();
|
|
66
|
-
if (!controller) throw new Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
|
|
67
|
-
return controller.attachments;
|
|
68
|
-
}
|
|
69
|
-
function usePromptInputAttachments() {
|
|
70
|
-
const controller = useOptionalPromptInputController();
|
|
71
|
-
const context = React.useContext(LocalAttachmentsContext) ?? controller?.attachments;
|
|
72
|
-
if (!context) throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider.");
|
|
73
|
-
return context;
|
|
74
|
-
}
|
|
75
|
-
function PromptInputProvider({ initialInput = "", children }) {
|
|
76
|
-
const [textInput, setTextInput] = React.useState(initialInput);
|
|
77
|
-
const attachmentStore = useAttachmentStore();
|
|
78
|
-
const fileInputRef = React.useRef(null);
|
|
79
|
-
const openRef = React.useRef(() => {});
|
|
80
|
-
const attachments = React.useMemo(() => ({
|
|
81
|
-
...attachmentStore,
|
|
82
|
-
fileInputRef,
|
|
83
|
-
openFileDialog: () => openRef.current()
|
|
84
|
-
}), [attachmentStore]);
|
|
85
139
|
const controller = React.useMemo(() => ({
|
|
86
|
-
__registerFileInput: (ref, open) => {
|
|
87
|
-
fileInputRef.current = ref.current;
|
|
88
|
-
openRef.current = open;
|
|
89
|
-
},
|
|
90
140
|
attachments,
|
|
91
141
|
textInput: {
|
|
92
|
-
value:
|
|
93
|
-
setInput
|
|
94
|
-
clear: () =>
|
|
142
|
+
value: text,
|
|
143
|
+
setInput,
|
|
144
|
+
clear: () => setInput("")
|
|
95
145
|
}
|
|
96
|
-
}), [
|
|
146
|
+
}), [
|
|
147
|
+
attachments,
|
|
148
|
+
text,
|
|
149
|
+
setInput
|
|
150
|
+
]);
|
|
97
151
|
return /* @__PURE__ */ jsx(PromptInputController.Provider, {
|
|
98
152
|
value: controller,
|
|
99
|
-
children
|
|
153
|
+
children: /* @__PURE__ */ jsxs(PromptInputSubmissionContext.Provider, {
|
|
154
|
+
value: submitDraft,
|
|
155
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
156
|
+
ref: fileInputRef,
|
|
157
|
+
accept,
|
|
158
|
+
"aria-label": "Upload files",
|
|
159
|
+
className: "prompt-input__file-input",
|
|
160
|
+
multiple,
|
|
161
|
+
onChange: (event) => {
|
|
162
|
+
if (event.currentTarget.files?.length) add(event.currentTarget.files);
|
|
163
|
+
event.currentTarget.value = "";
|
|
164
|
+
},
|
|
165
|
+
tabIndex: -1,
|
|
166
|
+
type: "file"
|
|
167
|
+
}), children]
|
|
168
|
+
})
|
|
100
169
|
});
|
|
101
170
|
}
|
|
102
171
|
/**
|
|
@@ -115,6 +184,7 @@ function PromptInputProvider({ initialInput = "", children }) {
|
|
|
115
184
|
*
|
|
116
185
|
* @example
|
|
117
186
|
* ```tsx
|
|
187
|
+
* <PromptInputProvider>
|
|
118
188
|
* <PromptInput onSubmit={({ text, files }) => sendMessage({ text, files })}>
|
|
119
189
|
* <PromptInputBody>
|
|
120
190
|
* <PromptInputTextarea placeholder="Ask Sigvelo..." />
|
|
@@ -126,83 +196,17 @@ function PromptInputProvider({ initialInput = "", children }) {
|
|
|
126
196
|
* <PromptInputSubmit status="ready" />
|
|
127
197
|
* </PromptInputFooter>
|
|
128
198
|
* </PromptInput>
|
|
199
|
+
* </PromptInputProvider>
|
|
129
200
|
* ```
|
|
130
201
|
*
|
|
131
202
|
* @see {@link https://elements.ai-sdk.dev/components/prompt-input | AI Elements Prompt Input}
|
|
132
203
|
*/
|
|
133
|
-
function PromptInput({ className,
|
|
134
|
-
const controller =
|
|
204
|
+
function PromptInput({ className, globalDrop, onSubmit, children, ref, ...props }) {
|
|
205
|
+
const controller = usePromptInputController();
|
|
206
|
+
const submitDraft = React.useContext(PromptInputSubmissionContext);
|
|
207
|
+
if (!submitDraft) throw new Error("PromptInput requires PromptInputProvider.");
|
|
135
208
|
const formRef = React.useRef(null);
|
|
136
|
-
const
|
|
137
|
-
const { add: addLocalFiles, clear: clearLocalFiles, files: localFiles, remove: removeLocalFile } = useAttachmentStore();
|
|
138
|
-
const files = controller?.attachments.files ?? localFiles;
|
|
139
|
-
const filesRef = React.useRef(files);
|
|
140
|
-
React.useEffect(() => {
|
|
141
|
-
filesRef.current = files;
|
|
142
|
-
}, [files]);
|
|
143
|
-
React.useImperativeHandle(ref, () => formRef.current, []);
|
|
144
|
-
const matchesAccept = React.useCallback((file) => {
|
|
145
|
-
if (!accept?.trim()) return true;
|
|
146
|
-
return accept.split(",").map((pattern) => pattern.trim()).filter(Boolean).some((pattern) => pattern.endsWith("/*") ? file.type.startsWith(pattern.slice(0, -1)) : file.type === pattern);
|
|
147
|
-
}, [accept]);
|
|
148
|
-
const add = React.useCallback((fileList) => {
|
|
149
|
-
const incoming = Array.from(fileList);
|
|
150
|
-
const accepted = incoming.filter(matchesAccept);
|
|
151
|
-
if (incoming.length && accepted.length === 0) {
|
|
152
|
-
onError?.({
|
|
153
|
-
code: "accept",
|
|
154
|
-
message: "No files match the accepted types."
|
|
155
|
-
});
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const sized = accepted.filter((file) => !maxFileSize || file.size <= maxFileSize);
|
|
159
|
-
if (accepted.length && sized.length === 0) {
|
|
160
|
-
onError?.({
|
|
161
|
-
code: "max_file_size",
|
|
162
|
-
message: "All files exceed the maximum size."
|
|
163
|
-
});
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
const capacity = typeof maxFiles === "number" ? Math.max(0, maxFiles - filesRef.current.length) : void 0;
|
|
167
|
-
const capped = typeof capacity === "number" ? sized.slice(0, capacity) : sized;
|
|
168
|
-
if (typeof capacity === "number" && sized.length > capacity) onError?.({
|
|
169
|
-
code: "max_files",
|
|
170
|
-
message: "Too many files. Some were not added."
|
|
171
|
-
});
|
|
172
|
-
if (!capped.length) return;
|
|
173
|
-
if (controller) controller.attachments.add(capped);
|
|
174
|
-
else addLocalFiles(capped);
|
|
175
|
-
}, [
|
|
176
|
-
addLocalFiles,
|
|
177
|
-
controller,
|
|
178
|
-
matchesAccept,
|
|
179
|
-
maxFileSize,
|
|
180
|
-
maxFiles,
|
|
181
|
-
onError
|
|
182
|
-
]);
|
|
183
|
-
const addDroppedFiles = React.useEffectEvent(add);
|
|
184
|
-
const remove = React.useCallback((attachmentId) => {
|
|
185
|
-
if (controller) {
|
|
186
|
-
controller.attachments.remove(attachmentId);
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
removeLocalFile(attachmentId);
|
|
190
|
-
}, [controller, removeLocalFile]);
|
|
191
|
-
const clearAttachments = React.useCallback(() => {
|
|
192
|
-
if (controller) {
|
|
193
|
-
controller.attachments.clear();
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
clearLocalFiles();
|
|
197
|
-
}, [clearLocalFiles, controller]);
|
|
198
|
-
const openFileDialog = React.useCallback(() => inputRef.current?.click(), []);
|
|
199
|
-
React.useEffect(() => {
|
|
200
|
-
if (!controller) return;
|
|
201
|
-
controller.__registerFileInput(inputRef, openFileDialog);
|
|
202
|
-
}, [controller, openFileDialog]);
|
|
203
|
-
React.useEffect(() => {
|
|
204
|
-
if (syncHiddenInput && inputRef.current && files.length === 0) inputRef.current.value = "";
|
|
205
|
-
}, [files.length, syncHiddenInput]);
|
|
209
|
+
const addDroppedFiles = React.useEffectEvent(controller.attachments.add);
|
|
206
210
|
React.useEffect(() => {
|
|
207
211
|
const target = globalDrop ? document : formRef.current;
|
|
208
212
|
if (!target) return;
|
|
@@ -222,69 +226,16 @@ function PromptInput({ className, accept, multiple, globalDrop, syncHiddenInput,
|
|
|
222
226
|
target.removeEventListener("drop", onDrop);
|
|
223
227
|
};
|
|
224
228
|
}, [globalDrop]);
|
|
225
|
-
const
|
|
226
|
-
add,
|
|
227
|
-
clear: clearAttachments,
|
|
228
|
-
fileInputRef: inputRef,
|
|
229
|
-
files,
|
|
230
|
-
openFileDialog,
|
|
231
|
-
remove
|
|
232
|
-
}), [
|
|
233
|
-
add,
|
|
234
|
-
clearAttachments,
|
|
235
|
-
files,
|
|
236
|
-
openFileDialog,
|
|
237
|
-
remove
|
|
238
|
-
]);
|
|
239
|
-
const handleSubmit = React.useCallback(async (event) => {
|
|
229
|
+
const handleSubmit = React.useCallback((event) => {
|
|
240
230
|
event.preventDefault();
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}, event);
|
|
250
|
-
if (!controller && field instanceof HTMLTextAreaElement) {
|
|
251
|
-
field.value = "";
|
|
252
|
-
field.dispatchEvent(new Event("input", { bubbles: true }));
|
|
253
|
-
} else if (!controller && field?.isContentEditable) {
|
|
254
|
-
field.replaceChildren();
|
|
255
|
-
field.dispatchEvent(new Event("input", { bubbles: true }));
|
|
256
|
-
}
|
|
257
|
-
controller?.textInput.clear();
|
|
258
|
-
clearAttachments();
|
|
259
|
-
await submission;
|
|
260
|
-
} catch {}
|
|
261
|
-
}, [
|
|
262
|
-
clearAttachments,
|
|
263
|
-
controller,
|
|
264
|
-
files,
|
|
265
|
-
onSubmit
|
|
266
|
-
]);
|
|
267
|
-
return /* @__PURE__ */ jsxs(LocalAttachmentsContext.Provider, {
|
|
268
|
-
value: attachmentsCtx,
|
|
269
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
270
|
-
ref: inputRef,
|
|
271
|
-
accept,
|
|
272
|
-
"aria-label": "Upload files",
|
|
273
|
-
className: "prompt-input__file-input",
|
|
274
|
-
multiple,
|
|
275
|
-
onChange: (event) => {
|
|
276
|
-
if (event.currentTarget.files?.length) add(event.currentTarget.files);
|
|
277
|
-
event.currentTarget.value = "";
|
|
278
|
-
},
|
|
279
|
-
tabIndex: -1,
|
|
280
|
-
type: "file"
|
|
281
|
-
}), /* @__PURE__ */ jsx("form", {
|
|
282
|
-
ref: formRef,
|
|
283
|
-
className: cx("prompt-input", className),
|
|
284
|
-
onSubmit: handleSubmit,
|
|
285
|
-
...props,
|
|
286
|
-
children
|
|
287
|
-
})]
|
|
231
|
+
return submitDraft(onSubmit, event);
|
|
232
|
+
}, [submitDraft, onSubmit]);
|
|
233
|
+
return /* @__PURE__ */ jsx("form", {
|
|
234
|
+
ref: mergeRefs(formRef, ref),
|
|
235
|
+
className: cx("prompt-input", className),
|
|
236
|
+
onSubmit: handleSubmit,
|
|
237
|
+
...props,
|
|
238
|
+
children
|
|
288
239
|
});
|
|
289
240
|
}
|
|
290
241
|
function PromptInputHeader({ className, children, ref, ...props }) {
|
|
@@ -368,6 +319,14 @@ function PromptInputFooter({ className, children, ref, ...props }) {
|
|
|
368
319
|
children
|
|
369
320
|
});
|
|
370
321
|
}
|
|
322
|
+
/** Trailing composer controls; expands for dictation without displacing the input. */
|
|
323
|
+
function PromptInputFooterEnd({ className, ref, ...props }) {
|
|
324
|
+
return /* @__PURE__ */ jsx("div", {
|
|
325
|
+
ref,
|
|
326
|
+
className: cx("prompt-input__footer-end", className),
|
|
327
|
+
...props
|
|
328
|
+
});
|
|
329
|
+
}
|
|
371
330
|
/** Supporting controls or queued work tucked behind a PromptInput edge. */
|
|
372
331
|
function PromptInputTray({ side, className, ref, ...props }) {
|
|
373
332
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -389,7 +348,7 @@ function PromptInputTools({ className, children, ref, ...props }) {
|
|
|
389
348
|
const MIN_TEXTAREA_HEIGHT_PX = 24;
|
|
390
349
|
const MAX_TEXTAREA_HEIGHT_PX = 240;
|
|
391
350
|
function PromptInputTextarea({ className, placeholder = "How can I help?", rows = 1, minHeight = MIN_TEXTAREA_HEIGHT_PX, maxHeight = MAX_TEXTAREA_HEIGHT_PX, onChange, onCompositionEnd, onCompositionStart, onKeyDown, onInput, onPaste, ref, ...props }) {
|
|
392
|
-
const controller =
|
|
351
|
+
const controller = usePromptInputController();
|
|
393
352
|
const attachments = usePromptInputAttachments();
|
|
394
353
|
const innerRef = React.useRef(null);
|
|
395
354
|
const isComposingRef = React.useRef(false);
|
|
@@ -404,19 +363,7 @@ function PromptInputTextarea({ className, placeholder = "How can I help?", rows
|
|
|
404
363
|
}, [maxHeight, minHeight]);
|
|
405
364
|
React.useLayoutEffect(() => {
|
|
406
365
|
resize();
|
|
407
|
-
}, [
|
|
408
|
-
resize,
|
|
409
|
-
props.value,
|
|
410
|
-
props.defaultValue,
|
|
411
|
-
controller?.textInput.value
|
|
412
|
-
]);
|
|
413
|
-
const controlledProps = controller ? {
|
|
414
|
-
value: controller.textInput.value,
|
|
415
|
-
onChange: (event) => {
|
|
416
|
-
controller.textInput.setInput(event.currentTarget.value);
|
|
417
|
-
onChange?.(event);
|
|
418
|
-
}
|
|
419
|
-
} : { onChange };
|
|
366
|
+
}, [resize, controller.textInput.value]);
|
|
420
367
|
return /* @__PURE__ */ jsx("textarea", {
|
|
421
368
|
ref: innerRef,
|
|
422
369
|
"data-prompt-input-textarea": "true",
|
|
@@ -453,11 +400,7 @@ function PromptInputTextarea({ className, placeholder = "How can I help?", rows
|
|
|
453
400
|
onPaste: (event) => {
|
|
454
401
|
onPaste?.(event);
|
|
455
402
|
if (event.defaultPrevented) return;
|
|
456
|
-
|
|
457
|
-
if (files.length) {
|
|
458
|
-
event.preventDefault();
|
|
459
|
-
attachments.add(files);
|
|
460
|
-
}
|
|
403
|
+
if (event.clipboardData.files.length) attachments.add(event.clipboardData.files);
|
|
461
404
|
},
|
|
462
405
|
style: {
|
|
463
406
|
minHeight,
|
|
@@ -465,7 +408,11 @@ function PromptInputTextarea({ className, placeholder = "How can I help?", rows
|
|
|
465
408
|
...props.style
|
|
466
409
|
},
|
|
467
410
|
...props,
|
|
468
|
-
|
|
411
|
+
value: controller.textInput.value,
|
|
412
|
+
onChange: (event) => {
|
|
413
|
+
controller.textInput.setInput(event.currentTarget.value);
|
|
414
|
+
onChange?.(event);
|
|
415
|
+
}
|
|
469
416
|
});
|
|
470
417
|
}
|
|
471
418
|
function PromptInputButton({ className, tooltip, variant = "ghost", color = "neutral", size, iconOnly, children, "aria-label": ariaLabel, ref, ...props }) {
|
|
@@ -507,7 +454,7 @@ function PromptInputButton({ className, tooltip, variant = "ghost", color = "neu
|
|
|
507
454
|
*/
|
|
508
455
|
const DICTATION_METER_GAIN = 12;
|
|
509
456
|
function PromptInputDictation({ voice, beforeStart, className, disabled, ref, ...props }) {
|
|
510
|
-
const controller =
|
|
457
|
+
const controller = usePromptInputController();
|
|
511
458
|
const attachments = usePromptInputAttachments();
|
|
512
459
|
const buttonRef = React.useRef(null);
|
|
513
460
|
const committedTranscriptRef = React.useRef("");
|
|
@@ -527,16 +474,7 @@ function PromptInputDictation({ voice, beforeStart, className, disabled, ref, ..
|
|
|
527
474
|
const addition = transcript.startsWith(previous) ? transcript.slice(previous.length).trim() : transcript.trim();
|
|
528
475
|
committedTranscriptRef.current = transcript;
|
|
529
476
|
if (!addition) return;
|
|
530
|
-
|
|
531
|
-
controller.textInput.setInput(appendDictationTranscript(controller.textInput.value, addition));
|
|
532
|
-
voice.clear();
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
const field = buttonRef.current?.form?.querySelector("[data-prompt-input-textarea=\"true\"]");
|
|
536
|
-
if (!field) return;
|
|
537
|
-
if (field instanceof HTMLTextAreaElement) Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value")?.set?.call(field, appendDictationTranscript(field.value, addition));
|
|
538
|
-
else if (field.isContentEditable) writeComposerDom(field, appendDictationTranscript(readComposerDom(field), addition));
|
|
539
|
-
field.dispatchEvent(new Event("input", { bubbles: true }));
|
|
477
|
+
controller.textInput.setInput(appendDictationTranscript(controller.textInput.value, addition));
|
|
540
478
|
voice.clear();
|
|
541
479
|
}, [
|
|
542
480
|
controller,
|
|
@@ -701,7 +639,7 @@ function PromptInputRecordingWaveform({ active, level }) {
|
|
|
701
639
|
const barCount = Math.max(1, Math.floor(rect.width / step));
|
|
702
640
|
if (active && time - lastUpdate >= 50) {
|
|
703
641
|
smoothedLevel += (levelRef.current - smoothedLevel) * .45;
|
|
704
|
-
historyRef.current.push(
|
|
642
|
+
historyRef.current.push(clamp(smoothedLevel, .08, 1));
|
|
705
643
|
if (historyRef.current.length > barCount) historyRef.current.shift();
|
|
706
644
|
lastUpdate = time;
|
|
707
645
|
}
|
|
@@ -746,6 +684,7 @@ function PromptInputActionMenuTrigger({ className, children, ...props }) {
|
|
|
746
684
|
unstyled: true,
|
|
747
685
|
render: /* @__PURE__ */ jsx(PromptInputButton, {
|
|
748
686
|
className: cx("prompt-input__action-menu-trigger", className),
|
|
687
|
+
"aria-label": children == null ? "Add context" : void 0,
|
|
749
688
|
...props,
|
|
750
689
|
children: children ?? /* @__PURE__ */ jsx(PlusIcon, {})
|
|
751
690
|
})
|
|
@@ -820,7 +759,7 @@ const PERMISSION_MODES = [{
|
|
|
820
759
|
/**
|
|
821
760
|
* Footer control for choosing how approval requests are handled — ask each
|
|
822
761
|
* time, or bypass. Purely a picker: the auto-approve behavior lives with
|
|
823
|
-
*
|
|
762
|
+
* the application that owns the approvals. Shared chat parts never grant bypass.
|
|
824
763
|
*/
|
|
825
764
|
function PromptInputPermissionSelector({ value, onValueChange, question = "How should agent actions be approved?" }) {
|
|
826
765
|
const selected = PERMISSION_MODES.find((mode) => mode.value === value) ?? PERMISSION_MODES[0];
|
|
@@ -1021,10 +960,12 @@ function composerLinksToReferences(text) {
|
|
|
1021
960
|
}));
|
|
1022
961
|
}
|
|
1023
962
|
/**
|
|
1024
|
-
*
|
|
963
|
+
* Shared-draft composer field with slash-command and mention discovery.
|
|
1025
964
|
* Selection inserts a special href into the draft — not a chip button.
|
|
1026
965
|
*/
|
|
1027
|
-
function PromptInputCommandComposer({ commands, mentionCommands,
|
|
966
|
+
function PromptInputCommandComposer({ commands, mentionCommands, onCommandSelect, emptyMessage = "No commands found.", mentionEmptyMessage = "No MCP servers found.", onKeyDown, ref, placeholder, disabled, className, minHeight, maxHeight, "aria-label": ariaLabel }) {
|
|
967
|
+
const { attachments, textInput } = usePromptInputController();
|
|
968
|
+
const { value, setInput: onValueChange } = textInput;
|
|
1028
969
|
const inputRef = React.useRef(null);
|
|
1029
970
|
const highlightedCommandRef = React.useRef(void 0);
|
|
1030
971
|
const [dismissedValue, setDismissedValue] = React.useState(null);
|
|
@@ -1090,6 +1031,9 @@ function PromptInputCommandComposer({ commands, mentionCommands, value, onValueC
|
|
|
1090
1031
|
event.preventDefault();
|
|
1091
1032
|
selectCommand(command);
|
|
1092
1033
|
},
|
|
1034
|
+
onPaste: (event) => {
|
|
1035
|
+
if (event.clipboardData.files.length) attachments.add(event.clipboardData.files);
|
|
1036
|
+
},
|
|
1093
1037
|
placeholder,
|
|
1094
1038
|
disabled,
|
|
1095
1039
|
className,
|
|
@@ -1309,4 +1253,4 @@ function createId() {
|
|
|
1309
1253
|
return globalThis.crypto?.randomUUID?.() ?? `prompt-input-${Date.now()}-${Math.random()}`;
|
|
1310
1254
|
}
|
|
1311
1255
|
//#endregion
|
|
1312
|
-
export { PromptInput, PromptInputActionAddAttachments, PromptInputActionAddScreenshot, PromptInputActionMenu, PromptInputActionMenuContent, PromptInputActionMenuItem, PromptInputActionMenuTrigger, PromptInputAttachment, PromptInputAttachments, PromptInputBody, PromptInputButton, PromptInputCommandComposer, PromptInputContextSelector, PromptInputDictation, PromptInputFooter, PromptInputHeader, PromptInputHoverCard, PromptInputHoverCardContent, PromptInputHoverCardTrigger, PromptInputPermissionSelector, PromptInputProvider, PromptInputSubmit, PromptInputTab, PromptInputTabBody, PromptInputTabItem, PromptInputTabLabel, PromptInputTabsList, PromptInputTextarea, PromptInputTools, PromptInputTray, composerLinksToReferences, usePromptInputAttachments, usePromptInputController
|
|
1256
|
+
export { PromptInput, PromptInputActionAddAttachments, PromptInputActionAddScreenshot, PromptInputActionMenu, PromptInputActionMenuContent, PromptInputActionMenuItem, PromptInputActionMenuTrigger, PromptInputAttachment, PromptInputAttachments, PromptInputBody, PromptInputButton, PromptInputCommandComposer, PromptInputContextSelector, PromptInputDictation, PromptInputFooter, PromptInputFooterEnd, PromptInputHeader, PromptInputHoverCard, PromptInputHoverCardContent, PromptInputHoverCardTrigger, PromptInputPermissionSelector, PromptInputProvider, PromptInputSubmit, PromptInputTab, PromptInputTabBody, PromptInputTabItem, PromptInputTabLabel, PromptInputTabsList, PromptInputTextarea, PromptInputTools, PromptInputTray, composerLinksToReferences, usePromptInputAttachments, usePromptInputController };
|
|
@@ -113,6 +113,22 @@ function placeCaretAtEnd(element) {
|
|
|
113
113
|
selection.removeAllRanges();
|
|
114
114
|
selection.addRange(range);
|
|
115
115
|
}
|
|
116
|
+
function insertPlainText(element, text) {
|
|
117
|
+
const selection = window.getSelection();
|
|
118
|
+
const range = selection?.rangeCount ? selection.getRangeAt(0) : void 0;
|
|
119
|
+
if (!selection || !range || !element.contains(range.commonAncestorContainer)) {
|
|
120
|
+
element.append(document.createTextNode(text));
|
|
121
|
+
placeCaretAtEnd(element);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
range.deleteContents();
|
|
125
|
+
const node = document.createTextNode(text);
|
|
126
|
+
range.insertNode(node);
|
|
127
|
+
range.setStartAfter(node);
|
|
128
|
+
range.collapse(true);
|
|
129
|
+
selection.removeAllRanges();
|
|
130
|
+
selection.addRange(range);
|
|
131
|
+
}
|
|
116
132
|
function PromptInputComposerEditor({ className, placeholder = "How can I help?", minHeight = MIN_COMPOSER_HEIGHT_PX, maxHeight = MAX_COMPOSER_HEIGHT_PX, draft, onDraftChange, onKeyDown, onPaste, disabled, ref, ...props }) {
|
|
117
133
|
const innerRef = React.useRef(null);
|
|
118
134
|
const lastWritten = React.useRef(null);
|
|
@@ -148,6 +164,14 @@ function PromptInputComposerEditor({ className, placeholder = "How can I help?",
|
|
|
148
164
|
if (document.activeElement === el) placeCaretAtEnd(el);
|
|
149
165
|
resize();
|
|
150
166
|
}, [resize, draft]);
|
|
167
|
+
const syncDraft = () => {
|
|
168
|
+
const el = innerRef.current;
|
|
169
|
+
if (!el) return;
|
|
170
|
+
const next = readComposerDom(el);
|
|
171
|
+
lastWritten.current = next;
|
|
172
|
+
onDraftChange(next);
|
|
173
|
+
resize();
|
|
174
|
+
};
|
|
151
175
|
return /* @__PURE__ */ jsx("div", {
|
|
152
176
|
...props,
|
|
153
177
|
ref: mergeRefs(innerRef, ref),
|
|
@@ -175,14 +199,7 @@ function PromptInputComposerEditor({ className, placeholder = "How can I help?",
|
|
|
175
199
|
isComposingRef.current = false;
|
|
176
200
|
props.onCompositionEnd?.(event);
|
|
177
201
|
},
|
|
178
|
-
onInput:
|
|
179
|
-
const el = innerRef.current;
|
|
180
|
-
if (!el) return;
|
|
181
|
-
const next = readComposerDom(el);
|
|
182
|
-
lastWritten.current = next;
|
|
183
|
-
onDraftChange(next);
|
|
184
|
-
resize();
|
|
185
|
-
},
|
|
202
|
+
onInput: syncDraft,
|
|
186
203
|
onKeyDown: (event) => {
|
|
187
204
|
onKeyDown?.(event);
|
|
188
205
|
if (event.defaultPrevented) return;
|
|
@@ -191,7 +208,13 @@ function PromptInputComposerEditor({ className, placeholder = "How can I help?",
|
|
|
191
208
|
event.currentTarget.closest("form")?.requestSubmit();
|
|
192
209
|
}
|
|
193
210
|
},
|
|
194
|
-
onPaste
|
|
211
|
+
onPaste: (event) => {
|
|
212
|
+
onPaste?.(event);
|
|
213
|
+
if (event.defaultPrevented) return;
|
|
214
|
+
event.preventDefault();
|
|
215
|
+
insertPlainText(event.currentTarget, event.clipboardData.getData("text/plain"));
|
|
216
|
+
syncDraft();
|
|
217
|
+
}
|
|
195
218
|
});
|
|
196
219
|
}
|
|
197
220
|
//#endregion
|