@messenger-box/tailwind-ui-inbox 10.0.3-alpha.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/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/jest.config.js +9 -0
- package/lib/cdm-locales/en/translations.json +31 -0
- package/lib/cdm-locales/es/translations.json +31 -0
- package/lib/components/AIAgent/AIAgent.d.ts +32 -0
- package/lib/components/AIAgent/AIAgent.d.ts.map +1 -0
- package/lib/components/AIAgent/AIAgent.js +1135 -0
- package/lib/components/AIAgent/AIAgent.js.map +1 -0
- package/lib/components/AIAgent/InputComponent.d.ts +84 -0
- package/lib/components/AIAgent/InputComponent.d.ts.map +1 -0
- package/lib/components/AIAgent/InputComponent.js +417 -0
- package/lib/components/AIAgent/InputComponent.js.map +1 -0
- package/lib/components/AIAgent/index.d.ts +2 -0
- package/lib/components/AIAgent/index.d.ts.map +1 -0
- package/lib/components/InboxMessage/CommonMessage.d.ts +8 -0
- package/lib/components/InboxMessage/CommonMessage.d.ts.map +1 -0
- package/lib/components/InboxMessage/CommonMessage.js +35 -0
- package/lib/components/InboxMessage/CommonMessage.js.map +1 -0
- package/lib/components/InboxMessage/ConversationItem.d.ts +14 -0
- package/lib/components/InboxMessage/ConversationItem.d.ts.map +1 -0
- package/lib/components/InboxMessage/ConversationItem.js +200 -0
- package/lib/components/InboxMessage/ConversationItem.js.map +1 -0
- package/lib/components/InboxMessage/InputComponent.d.ts +20 -0
- package/lib/components/InboxMessage/InputComponent.d.ts.map +1 -0
- package/lib/components/InboxMessage/InputComponent.js +148 -0
- package/lib/components/InboxMessage/InputComponent.js.map +1 -0
- package/lib/components/InboxMessage/LeftSidebar.d.ts +20 -0
- package/lib/components/InboxMessage/LeftSidebar.d.ts.map +1 -0
- package/lib/components/InboxMessage/LeftSidebar.js +102 -0
- package/lib/components/InboxMessage/LeftSidebar.js.map +1 -0
- package/lib/components/InboxMessage/MessageInput.d.ts +9 -0
- package/lib/components/InboxMessage/MessageInput.d.ts.map +1 -0
- package/lib/components/InboxMessage/MessageInput.js +154 -0
- package/lib/components/InboxMessage/MessageInput.js.map +1 -0
- package/lib/components/InboxMessage/MessageInputComponent.d.ts +9 -0
- package/lib/components/InboxMessage/MessageInputComponent.d.ts.map +1 -0
- package/lib/components/InboxMessage/Messages.d.ts +17 -0
- package/lib/components/InboxMessage/Messages.d.ts.map +1 -0
- package/lib/components/InboxMessage/Messages.js +99 -0
- package/lib/components/InboxMessage/Messages.js.map +1 -0
- package/lib/components/InboxMessage/MessagesBuilderUi.d.ts +17 -0
- package/lib/components/InboxMessage/MessagesBuilderUi.d.ts.map +1 -0
- package/lib/components/InboxMessage/Popover.d.ts +3 -0
- package/lib/components/InboxMessage/Popover.d.ts.map +1 -0
- package/lib/components/InboxMessage/Popover.js +31 -0
- package/lib/components/InboxMessage/Popover.js.map +1 -0
- package/lib/components/InboxMessage/RightSidebar.d.ts +9 -0
- package/lib/components/InboxMessage/RightSidebar.d.ts.map +1 -0
- package/lib/components/InboxMessage/RightSidebar.js +9 -0
- package/lib/components/InboxMessage/RightSidebar.js.map +1 -0
- package/lib/components/InboxMessage/RightSidebarAi.d.ts +37 -0
- package/lib/components/InboxMessage/RightSidebarAi.d.ts.map +1 -0
- package/lib/components/InboxMessage/RightSidebarAi.js +9 -0
- package/lib/components/InboxMessage/RightSidebarAi.js.map +1 -0
- package/lib/components/InboxMessage/ServiceConversationItem.d.ts +12 -0
- package/lib/components/InboxMessage/ServiceConversationItem.d.ts.map +1 -0
- package/lib/components/InboxMessage/ServiceConversationItem.js +185 -0
- package/lib/components/InboxMessage/ServiceConversationItem.js.map +1 -0
- package/lib/components/InboxMessage/ServiceInboxItem.d.ts +12 -0
- package/lib/components/InboxMessage/ServiceInboxItem.d.ts.map +1 -0
- package/lib/components/InboxMessage/ServiceInboxItem.js +182 -0
- package/lib/components/InboxMessage/ServiceInboxItem.js.map +1 -0
- package/lib/components/InboxMessage/StreamingMessageBubble.d.ts +18 -0
- package/lib/components/InboxMessage/StreamingMessageBubble.d.ts.map +1 -0
- package/lib/components/InboxMessage/SubscriptionHandler.d.ts +19 -0
- package/lib/components/InboxMessage/SubscriptionHandler.d.ts.map +1 -0
- package/lib/components/InboxMessage/SubscriptionHandler.js +41 -0
- package/lib/components/InboxMessage/SubscriptionHandler.js.map +1 -0
- package/lib/components/InboxMessage/TypingIndicator.d.ts +11 -0
- package/lib/components/InboxMessage/TypingIndicator.d.ts.map +1 -0
- package/lib/components/InboxMessage/UploadImageButton.d.ts +7 -0
- package/lib/components/InboxMessage/UploadImageButton.d.ts.map +1 -0
- package/lib/components/InboxMessage/UploadImageButton.js +30 -0
- package/lib/components/InboxMessage/UploadImageButton.js.map +1 -0
- package/lib/components/InboxMessage/UserModalContent.d.ts +3 -0
- package/lib/components/InboxMessage/UserModalContent.d.ts.map +1 -0
- package/lib/components/InboxMessage/UserModalContent.js +60 -0
- package/lib/components/InboxMessage/UserModalContent.js.map +1 -0
- package/lib/components/InboxMessage/index.d.ts +19 -0
- package/lib/components/InboxMessage/index.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.d.ts +11 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.js +44 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts +10 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js +194 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/MessageCard.d.ts +8 -0
- package/lib/components/InboxMessage/message-widgets/MessageCard.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.d.ts +12 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.js +37 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts +42 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js +1339 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.d.ts +8 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.js +14 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/PropertyMessageWidget.d.ts +9 -0
- package/lib/components/InboxMessage/message-widgets/PropertyMessageWidget.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.d.ts +14 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.js +333 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/index.d.ts +4 -0
- package/lib/components/InboxMessage/message-widgets/index.d.ts.map +1 -0
- package/lib/components/ModelConfigPanel.d.ts +74 -0
- package/lib/components/ModelConfigPanel.d.ts.map +1 -0
- package/lib/components/ModelConfigPanel.js +1152 -0
- package/lib/components/ModelConfigPanel.js.map +1 -0
- package/lib/components/filler-components/RightSiderBar.d.ts +3 -0
- package/lib/components/filler-components/RightSiderBar.d.ts.map +1 -0
- package/lib/components/filler-components/RightSiderBar.js +532 -0
- package/lib/components/filler-components/RightSiderBar.js.map +1 -0
- package/lib/components/inbox/FilesList.d.ts +20 -0
- package/lib/components/inbox/FilesList.d.ts.map +1 -0
- package/lib/components/inbox/FilesList.js +68 -0
- package/lib/components/inbox/FilesList.js.map +1 -0
- package/lib/components/inbox/MessageItem.d.ts +17 -0
- package/lib/components/inbox/MessageItem.d.ts.map +1 -0
- package/lib/components/inbox/MessageItem.js +50 -0
- package/lib/components/inbox/MessageItem.js.map +1 -0
- package/lib/components/inbox/ThreadItem.d.ts +11 -0
- package/lib/components/inbox/ThreadItem.d.ts.map +1 -0
- package/lib/components/inbox/ThreadItem.js +147 -0
- package/lib/components/inbox/ThreadItem.js.map +1 -0
- package/lib/components/inbox/index.d.ts +4 -0
- package/lib/components/inbox/index.d.ts.map +1 -0
- package/lib/components/index.d.ts +10 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/live-code-editor/hybrid-live-editor.d.ts +20 -0
- package/lib/components/live-code-editor/hybrid-live-editor.d.ts.map +1 -0
- package/lib/components/live-code-editor/index.d.ts +4 -0
- package/lib/components/live-code-editor/index.d.ts.map +1 -0
- package/lib/components/live-code-editor/live-code-editor.d.ts +14 -0
- package/lib/components/live-code-editor/live-code-editor.d.ts.map +1 -0
- package/lib/components/messages-container-ui/MessagesContainerUI.d.ts +81 -0
- package/lib/components/messages-container-ui/MessagesContainerUI.d.ts.map +1 -0
- package/lib/components/messages-container-ui/MessagesContainerUI.js +77 -0
- package/lib/components/messages-container-ui/MessagesContainerUI.js.map +1 -0
- package/lib/components/messages-container-ui/PlanModeView.d.ts +82 -0
- package/lib/components/messages-container-ui/PlanModeView.d.ts.map +1 -0
- package/lib/components/messages-container-ui/PlanModeView.js +267 -0
- package/lib/components/messages-container-ui/PlanModeView.js.map +1 -0
- package/lib/components/messages-container-ui/index.d.ts +6 -0
- package/lib/components/messages-container-ui/index.d.ts.map +1 -0
- package/lib/components/messages-container-ui/types.d.ts +38 -0
- package/lib/components/messages-container-ui/types.d.ts.map +1 -0
- package/lib/components/slot-fill/chat-message-filler.d.ts +4 -0
- package/lib/components/slot-fill/chat-message-filler.d.ts.map +1 -0
- package/lib/components/slot-fill/chat-message-filler.js +5 -0
- package/lib/components/slot-fill/chat-message-filler.js.map +1 -0
- package/lib/components/slot-fill/chat-message-slot.d.ts +11 -0
- package/lib/components/slot-fill/chat-message-slot.d.ts.map +1 -0
- package/lib/components/slot-fill/chat-message-slot.js +6 -0
- package/lib/components/slot-fill/chat-message-slot.js.map +1 -0
- package/lib/components/slot-fill/index.d.ts +4 -0
- package/lib/components/slot-fill/index.d.ts.map +1 -0
- package/lib/components/slot-fill/right-sidebar-filler.d.ts +4 -0
- package/lib/components/slot-fill/right-sidebar-filler.d.ts.map +1 -0
- package/lib/components/slot-fill/right-sidebar-filler.js +13 -0
- package/lib/components/slot-fill/right-sidebar-filler.js.map +1 -0
- package/lib/components/ui/button.d.ts +9 -0
- package/lib/components/ui/button.d.ts.map +1 -0
- package/lib/compute.d.ts +8 -0
- package/lib/compute.d.ts.map +1 -0
- package/lib/compute.js +264 -0
- package/lib/compute.js.map +1 -0
- package/lib/config/env-config.d.ts +20 -0
- package/lib/config/env-config.d.ts.map +1 -0
- package/lib/config/env-config.js +55 -0
- package/lib/config/env-config.js.map +1 -0
- package/lib/config/index.d.ts +2 -0
- package/lib/config/index.d.ts.map +1 -0
- package/lib/constants/breakpoints.d.ts +8 -0
- package/lib/constants/breakpoints.d.ts.map +1 -0
- package/lib/constants/index.d.ts +3 -0
- package/lib/constants/index.d.ts.map +1 -0
- package/lib/container/AiInbox.d.ts +15 -0
- package/lib/container/AiInbox.d.ts.map +1 -0
- package/lib/container/AiInboxWithLoader.d.ts +36 -0
- package/lib/container/AiInboxWithLoader.d.ts.map +1 -0
- package/lib/container/AiLandingInput.d.ts +27 -0
- package/lib/container/AiLandingInput.d.ts.map +1 -0
- package/lib/container/AiLandingInput.js +149 -0
- package/lib/container/AiLandingInput.js.map +1 -0
- package/lib/container/Inbox.d.ts +15 -0
- package/lib/container/Inbox.d.ts.map +1 -0
- package/lib/container/Inbox.js +964 -0
- package/lib/container/Inbox.js.map +1 -0
- package/lib/container/InboxAiMessagesLoader.d.ts +45 -0
- package/lib/container/InboxAiMessagesLoader.d.ts.map +1 -0
- package/lib/container/InboxAiMessagesLoader.js +80 -0
- package/lib/container/InboxAiMessagesLoader.js.map +1 -0
- package/lib/container/InboxContainer.d.ts +41 -0
- package/lib/container/InboxContainer.d.ts.map +1 -0
- package/lib/container/InboxContainer.js +27 -0
- package/lib/container/InboxContainer.js.map +1 -0
- package/lib/container/InboxTemplate1.d.ts +15 -0
- package/lib/container/InboxTemplate1.d.ts.map +1 -0
- package/lib/container/InboxTemplate1WithLoader.d.ts +36 -0
- package/lib/container/InboxTemplate1WithLoader.d.ts.map +1 -0
- package/lib/container/InboxTemplate2.d.ts +15 -0
- package/lib/container/InboxTemplate2.d.ts.map +1 -0
- package/lib/container/InboxWithAiLoader.d.ts +47 -0
- package/lib/container/InboxWithAiLoader.d.ts.map +1 -0
- package/lib/container/InboxWithAiLoader.js +118 -0
- package/lib/container/InboxWithAiLoader.js.map +1 -0
- package/lib/container/InboxWithLoader.d.ts +36 -0
- package/lib/container/InboxWithLoader.d.ts.map +1 -0
- package/lib/container/InboxWithLoader.js +277 -0
- package/lib/container/InboxWithLoader.js.map +1 -0
- package/lib/container/ServiceInbox.d.ts +9 -0
- package/lib/container/ServiceInbox.d.ts.map +1 -0
- package/lib/container/ServiceInbox.js +141 -0
- package/lib/container/ServiceInbox.js.map +1 -0
- package/lib/container/TestInboxWithAiLoader.d.ts +7 -0
- package/lib/container/TestInboxWithAiLoader.d.ts.map +1 -0
- package/lib/container/TestInboxWithAiLoader.js +135 -0
- package/lib/container/TestInboxWithAiLoader.js.map +1 -0
- package/lib/container/ThreadMessages.d.ts +13 -0
- package/lib/container/ThreadMessages.d.ts.map +1 -0
- package/lib/container/ThreadMessages.js +320 -0
- package/lib/container/ThreadMessages.js.map +1 -0
- package/lib/container/ThreadMessagesInbox.d.ts +14 -0
- package/lib/container/ThreadMessagesInbox.d.ts.map +1 -0
- package/lib/container/ThreadMessagesInbox.js +347 -0
- package/lib/container/ThreadMessagesInbox.js.map +1 -0
- package/lib/container/Threads.d.ts +8 -0
- package/lib/container/Threads.d.ts.map +1 -0
- package/lib/container/Threads.js +231 -0
- package/lib/container/Threads.js.map +1 -0
- package/lib/container/ThreadsInbox.d.ts +21 -0
- package/lib/container/ThreadsInbox.d.ts.map +1 -0
- package/lib/container/ThreadsInbox.js +243 -0
- package/lib/container/ThreadsInbox.js.map +1 -0
- package/lib/container/apply-footer-styles.d.ts +2 -0
- package/lib/container/apply-footer-styles.d.ts.map +1 -0
- package/lib/container/apply-footer-styles.js +16 -0
- package/lib/container/apply-footer-styles.js.map +1 -0
- package/lib/container/index.d.ts +13 -0
- package/lib/container/index.d.ts.map +1 -0
- package/lib/enums/index.d.ts +2 -0
- package/lib/enums/index.d.ts.map +1 -0
- package/lib/enums/messenger-slot-fill-name-enum.d.ts +11 -0
- package/lib/enums/messenger-slot-fill-name-enum.d.ts.map +1 -0
- package/lib/enums/messenger-slot-fill-name-enum.js +11 -0
- package/lib/enums/messenger-slot-fill-name-enum.js.map +1 -0
- package/lib/hooks/index.d.ts +4 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/usePersistentModelConfig.d.ts +33 -0
- package/lib/hooks/usePersistentModelConfig.d.ts.map +1 -0
- package/lib/hooks/usePersistentModelConfig.js +123 -0
- package/lib/hooks/usePersistentModelConfig.js.map +1 -0
- package/lib/hooks/useStreamAssembler.d.ts +8 -0
- package/lib/hooks/useStreamAssembler.d.ts.map +1 -0
- package/lib/hooks/useTemplates.d.ts +14 -0
- package/lib/hooks/useTemplates.d.ts.map +1 -0
- package/lib/hooks/useTemplates.js +59 -0
- package/lib/hooks/useTemplates.js.map +1 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces/index.d.ts +2 -0
- package/lib/interfaces/index.d.ts.map +1 -0
- package/lib/interfaces/message-widgets.interface.d.ts +21 -0
- package/lib/interfaces/message-widgets.interface.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.d.ts +3 -0
- package/lib/machines/aiAgentMachine.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.js +1083 -0
- package/lib/machines/aiAgentMachine.js.map +1 -0
- package/lib/machines/aiAgentMachine.simple.d.ts +3 -0
- package/lib/machines/aiAgentMachine.simple.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.simple.js +108 -0
- package/lib/machines/aiAgentMachine.simple.js.map +1 -0
- package/lib/machines/index.d.ts +3 -0
- package/lib/machines/index.d.ts.map +1 -0
- package/lib/machines/types.d.ts +77 -0
- package/lib/machines/types.d.ts.map +1 -0
- package/lib/module.d.ts +7 -0
- package/lib/module.d.ts.map +1 -0
- package/lib/module.js +26 -0
- package/lib/module.js.map +1 -0
- package/lib/routes.json +251 -0
- package/lib/styles/responsive.css +76 -0
- package/lib/templates/InboxWithAi.d.ts +44 -0
- package/lib/templates/InboxWithAi.d.ts.map +1 -0
- package/lib/templates/InboxWithAi.js +651 -0
- package/lib/templates/InboxWithAi.js.map +1 -0
- package/lib/templates/InboxWithAi.tsx +844 -0
- package/lib/templates/index.d.ts +2 -0
- package/lib/templates/index.d.ts.map +1 -0
- package/lib/templates/index.ts +1 -0
- package/lib/types/templates.d.ts +35 -0
- package/lib/types/templates.d.ts.map +1 -0
- package/lib/utils/utils.d.ts +2 -0
- package/lib/utils/utils.d.ts.map +1 -0
- package/lib/xstate/index.d.ts +3 -0
- package/lib/xstate/index.d.ts.map +1 -0
- package/lib/xstate/rightSidebar.machine.d.ts +4 -0
- package/lib/xstate/rightSidebar.machine.d.ts.map +1 -0
- package/lib/xstate/rightSidebar.types.d.ts +57 -0
- package/lib/xstate/rightSidebar.types.d.ts.map +1 -0
- package/package.json +69 -0
- package/rollup.config.mjs +47 -0
- package/src/cdm-locales/en/translations.json +31 -0
- package/src/cdm-locales/es/translations.json +31 -0
- package/src/components/AIAgent/AIAgent.tsx +1468 -0
- package/src/components/AIAgent/AIAgent.tsx.bk +1365 -0
- package/src/components/AIAgent/InputComponent.tsx +608 -0
- package/src/components/AIAgent/README.md +174 -0
- package/src/components/AIAgent/index.ts +1 -0
- package/src/components/InboxMessage/CommonMessage.tsx +40 -0
- package/src/components/InboxMessage/ConversationItem.tsx +255 -0
- package/src/components/InboxMessage/InputComponent.tsx +198 -0
- package/src/components/InboxMessage/LeftSidebar.tsx +140 -0
- package/src/components/InboxMessage/MessageInput.tsx +209 -0
- package/src/components/InboxMessage/MessageInputComponent.tsx +245 -0
- package/src/components/InboxMessage/Messages.tsx +137 -0
- package/src/components/InboxMessage/MessagesBuilderUi.tsx +205 -0
- package/src/components/InboxMessage/Popover.tsx +42 -0
- package/src/components/InboxMessage/RightSidebar.tsx +22 -0
- package/src/components/InboxMessage/RightSidebarAi.tsx +47 -0
- package/src/components/InboxMessage/ServiceConversationItem.tsx +234 -0
- package/src/components/InboxMessage/ServiceInboxItem.tsx +223 -0
- package/src/components/InboxMessage/StreamingMessageBubble.tsx +270 -0
- package/src/components/InboxMessage/SubscriptionHandler.tsx +55 -0
- package/src/components/InboxMessage/TypingIndicator.tsx +38 -0
- package/src/components/InboxMessage/UploadImageButton.tsx +46 -0
- package/src/components/InboxMessage/UserModalContent.tsx +60 -0
- package/src/components/InboxMessage/index.ts +18 -0
- package/src/components/InboxMessage/message-widgets/CommonMessage.tsx +69 -0
- package/src/components/InboxMessage/message-widgets/ErrorFixCard.tsx +239 -0
- package/src/components/InboxMessage/message-widgets/MessageCard.tsx +127 -0
- package/src/components/InboxMessage/message-widgets/MessageSliceRenderer.tsx +40 -0
- package/src/components/InboxMessage/message-widgets/ModernMessageGroup.tsx +1733 -0
- package/src/components/InboxMessage/message-widgets/PlainMessage.tsx +18 -0
- package/src/components/InboxMessage/message-widgets/PropertyMessageWidget.tsx +29 -0
- package/src/components/InboxMessage/message-widgets/SlackLikeMessageGroup.tsx +492 -0
- package/src/components/InboxMessage/message-widgets/index.ts +8 -0
- package/src/components/ModelConfigPanel.tsx +1357 -0
- package/src/components/filler-components/RightSiderBar.tsx +572 -0
- package/src/components/inbox/FilesList.tsx +89 -0
- package/src/components/inbox/MessageItem.tsx +50 -0
- package/src/components/inbox/ThreadItem.tsx +295 -0
- package/src/components/inbox/index.ts +3 -0
- package/src/components/index.ts +29 -0
- package/src/components/live-code-editor/hybrid-live-editor.tsx +105 -0
- package/src/components/live-code-editor/index.ts +3 -0
- package/src/components/live-code-editor/live-code-editor.tsx +257 -0
- package/src/components/messages-container-ui/MessagesContainerUI.tsx +151 -0
- package/src/components/messages-container-ui/PlanModeView.tsx +426 -0
- package/src/components/messages-container-ui/README.md +91 -0
- package/src/components/messages-container-ui/index.ts +5 -0
- package/src/components/messages-container-ui/types.ts +40 -0
- package/src/components/slot-fill/chat-message-filler.tsx +18 -0
- package/src/components/slot-fill/chat-message-slot.tsx +18 -0
- package/src/components/slot-fill/index.ts +3 -0
- package/src/components/slot-fill/right-sidebar-filler.tsx +48 -0
- package/src/components/ui/button.tsx +32 -0
- package/src/compute.ts +271 -0
- package/src/config/env-config.ts +24 -0
- package/src/config/index.ts +1 -0
- package/src/constants/breakpoints.ts +7 -0
- package/src/constants/index.ts +5 -0
- package/src/container/AiInbox.tsx +1879 -0
- package/src/container/AiInboxWithLoader.tsx +356 -0
- package/src/container/AiLandingInput.tsx +200 -0
- package/src/container/Inbox.tsx +1095 -0
- package/src/container/InboxAiMessagesLoader.tsx +129 -0
- package/src/container/InboxContainer.tsx +61 -0
- package/src/container/InboxTemplate1.tsx +1553 -0
- package/src/container/InboxTemplate1WithLoader.tsx +338 -0
- package/src/container/InboxTemplate2.tsx +1617 -0
- package/src/container/InboxWithAiLoader.tsx +177 -0
- package/src/container/InboxWithLoader.tsx +341 -0
- package/src/container/ServiceInbox.tsx +188 -0
- package/src/container/TestInboxWithAiLoader.tsx +147 -0
- package/src/container/ThreadMessages.tsx +378 -0
- package/src/container/ThreadMessagesInbox.tsx +457 -0
- package/src/container/Threads.tsx +270 -0
- package/src/container/ThreadsInbox.tsx +351 -0
- package/src/container/apply-footer-styles.ts +17 -0
- package/src/container/index.ts +31 -0
- package/src/enums/index.ts +1 -0
- package/src/enums/messenger-slot-fill-name-enum.ts +10 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/usePersistentModelConfig.ts +166 -0
- package/src/hooks/useStreamAssembler.ts +7 -0
- package/src/hooks/useTemplates.ts +75 -0
- package/src/index.ts +49 -0
- package/src/interfaces/index.ts +1 -0
- package/src/interfaces/message-widgets.interface.ts +21 -0
- package/src/machines/aiAgentMachine.simple.ts +89 -0
- package/src/machines/aiAgentMachine.ts +1296 -0
- package/src/machines/aiAgentMachine.ts.bk +1296 -0
- package/src/machines/index.ts +2 -0
- package/src/machines/types.ts +59 -0
- package/src/module.tsx +32 -0
- package/src/styles/responsive.css +76 -0
- package/src/templates/InboxWithAi.tsx +844 -0
- package/src/templates/index.ts +1 -0
- package/src/types/templates.ts +35 -0
- package/src/utils/utils.ts +3 -0
- package/src/xstate/index.ts +2 -0
- package/src/xstate/rightSidebar.machine.ts +304 -0
- package/src/xstate/rightSidebar.types.ts +58 -0
- package/tsconfig.json +14 -0
- package/webpack.config.js +92 -0
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { InputToolBar, getDefaultLeftItems, getDefaultRightItems } from '@admin-layout/tailwind-ui';
|
|
4
|
+
import type { InputToolBarProps } from '@admin-layout/tailwind-ui';
|
|
5
|
+
import { config } from '../../config';
|
|
6
|
+
import { ProjectSettingsModal } from '../ModelConfigPanel';
|
|
7
|
+
import type { ModelConfig } from '../../hooks/usePersistentModelConfig';
|
|
8
|
+
import type { TemplateConfig, TemplateModalItem } from '../../types/templates';
|
|
9
|
+
|
|
10
|
+
type AttachedFile = {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
size?: number;
|
|
14
|
+
file: File;
|
|
15
|
+
dataUrl?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function AttachmentPreview({ attachment, onRemove }: { attachment: AttachedFile; onRemove: (id: string) => void }) {
|
|
19
|
+
const isImage = !!attachment.dataUrl && attachment.dataUrl.startsWith('data:image/');
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div className="relative group inline-flex items-center gap-2 rounded-xl border border-border/50 bg-secondary/60 px-3 py-2 text-sm">
|
|
23
|
+
{isImage && attachment.dataUrl ? (
|
|
24
|
+
<div className="h-8 w-8 flex-shrink-0 overflow-hidden rounded-lg bg-muted">
|
|
25
|
+
<img src={attachment.dataUrl} alt={attachment.name} className="h-full w-full object-cover" />
|
|
26
|
+
</div>
|
|
27
|
+
) : (
|
|
28
|
+
<div className="flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-muted">
|
|
29
|
+
<svg
|
|
30
|
+
className="h-3.5 w-3.5 text-muted-foreground"
|
|
31
|
+
fill="none"
|
|
32
|
+
stroke="currentColor"
|
|
33
|
+
viewBox="0 0 24 24"
|
|
34
|
+
>
|
|
35
|
+
<path
|
|
36
|
+
strokeLinecap="round"
|
|
37
|
+
strokeLinejoin="round"
|
|
38
|
+
strokeWidth={2}
|
|
39
|
+
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
|
40
|
+
/>
|
|
41
|
+
</svg>
|
|
42
|
+
</div>
|
|
43
|
+
)}
|
|
44
|
+
<div className="flex min-w-0 max-w-[140px] flex-col">
|
|
45
|
+
<span className="truncate text-xs font-medium text-foreground">{attachment.name}</span>
|
|
46
|
+
{attachment.size != null && (
|
|
47
|
+
<span className="text-[10px] text-muted-foreground">
|
|
48
|
+
{attachment.size < 1024 * 1024
|
|
49
|
+
? `${(attachment.size / 1024).toFixed(1)} KB`
|
|
50
|
+
: `${(attachment.size / (1024 * 1024)).toFixed(1)} MB`}
|
|
51
|
+
</span>
|
|
52
|
+
)}
|
|
53
|
+
</div>
|
|
54
|
+
<button
|
|
55
|
+
type="button"
|
|
56
|
+
onClick={(e) => {
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
onRemove(attachment.id);
|
|
59
|
+
}}
|
|
60
|
+
className="absolute -right-2 -top-2 flex h-4 w-4 items-center justify-center rounded-full bg-destructive text-destructive-foreground shadow-md opacity-0 transition-opacity hover:bg-destructive/90 group-hover:opacity-100"
|
|
61
|
+
aria-label={`Remove ${attachment.name}`}
|
|
62
|
+
>
|
|
63
|
+
<svg className="h-2.5 w-2.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
64
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
|
65
|
+
</svg>
|
|
66
|
+
</button>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Override config for a single left toolbar item (enabled, label, active, onClick, etc.) */
|
|
72
|
+
export type LeftItemOverride = {
|
|
73
|
+
enabled?: boolean;
|
|
74
|
+
label?: string;
|
|
75
|
+
active?: boolean;
|
|
76
|
+
onClick?: () => void;
|
|
77
|
+
icon?: React.ReactNode;
|
|
78
|
+
customButton?: React.ReactNode;
|
|
79
|
+
};
|
|
80
|
+
/** Override config for a single right toolbar item */
|
|
81
|
+
export type RightItemOverride = {
|
|
82
|
+
enabled?: boolean;
|
|
83
|
+
label?: string;
|
|
84
|
+
onClick?: () => void;
|
|
85
|
+
icon?: React.ReactNode;
|
|
86
|
+
customButton?: React.ReactNode;
|
|
87
|
+
};
|
|
88
|
+
/** Left item ids: search, zap, lightbulb, template */
|
|
89
|
+
export type LeftToolbarItemId = 'search' | 'zap' | 'lightbulb' | 'template';
|
|
90
|
+
/** Right item ids: projectSettings, tag, chip, camera, image, attach, mic */
|
|
91
|
+
export type RightToolbarItemId = 'projectSettings' | 'tag' | 'chip' | 'camera' | 'image' | 'attach' | 'mic';
|
|
92
|
+
/** Per-item overrides for left toolbar. Pass { search: { enabled: false } } to hide search. */
|
|
93
|
+
export type LeftItemsOverrides = Partial<Record<LeftToolbarItemId, LeftItemOverride>>;
|
|
94
|
+
/** Per-item overrides for right toolbar. Pass { camera: { enabled: false } } to hide camera. */
|
|
95
|
+
export type RightItemsOverrides = Partial<Record<RightToolbarItemId, RightItemOverride>>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Props that can be passed from outside to customize InputToolBar.
|
|
99
|
+
* Excludes inputConfig and children (controlled by InputComponent).
|
|
100
|
+
* When a prop is set, it overrides the internal value (e.g. leftItems, rightItems, callbacks).
|
|
101
|
+
*/
|
|
102
|
+
export type InputToolBarPropsOverrides = Partial<Omit<InputToolBarProps, 'inputConfig' | 'children'>> & {
|
|
103
|
+
/** Optional class for the template selection modal content box (e.g. max-w-md, max-w-xl). Merged into templateModalConfig when not passing full templateModalConfig. */
|
|
104
|
+
templateModalClassName?: string;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type MessageInputProps = {
|
|
108
|
+
channelId?: string;
|
|
109
|
+
handleSend?: (message: string, files: File[]) => Promise<void>;
|
|
110
|
+
placeholder?: string;
|
|
111
|
+
modelConfig?: ModelConfig;
|
|
112
|
+
onModelConfigChange?: (config: ModelConfig) => void;
|
|
113
|
+
textareaClassName?: string;
|
|
114
|
+
textareaStyles?: React.CSSProperties;
|
|
115
|
+
toolBarParentClassName?: string;
|
|
116
|
+
isShowMeta?: boolean;
|
|
117
|
+
showModeSelector?: boolean;
|
|
118
|
+
showStopButton?: boolean;
|
|
119
|
+
onStop?: () => void;
|
|
120
|
+
inputToolBarParentClass?: string;
|
|
121
|
+
/** Templates for build mode (from extension/marketplace query). Shown when lightbulb/build is active. */
|
|
122
|
+
templates?: TemplateConfig[];
|
|
123
|
+
selectedTemplate?: TemplateConfig | null;
|
|
124
|
+
suggestedTemplate?: TemplateConfig | null;
|
|
125
|
+
onSelectTemplate?: (template: TemplateConfig | null) => void;
|
|
126
|
+
/** Optional override for displayed template label (when parent controls it, e.g. AIPage). */
|
|
127
|
+
templateSelectedLabel?: string | null;
|
|
128
|
+
/** Optional override for template modal items (when parent provides them). */
|
|
129
|
+
templateModalItems?: TemplateModalItem[];
|
|
130
|
+
/** Controlled template modal: when set with onOpen/onClose, parent controls open state. */
|
|
131
|
+
showTemplateModal?: boolean;
|
|
132
|
+
onOpenTemplateModal?: () => void;
|
|
133
|
+
onCloseTemplateModal?: () => void;
|
|
134
|
+
/** When provided, used instead of internal handler for selecting template by id. */
|
|
135
|
+
onSelectTemplateById?: (id: string) => void;
|
|
136
|
+
/** When provided, used for clearing template (else onSelectTemplate?.(null)). */
|
|
137
|
+
onClearTemplate?: () => void;
|
|
138
|
+
/** When provided, called when user accepts suggested template. */
|
|
139
|
+
onAcceptSuggestedTemplate?: () => void;
|
|
140
|
+
/** When true, show analyzing state (e.g. for query-based template suggestion). */
|
|
141
|
+
isAnalyzingQuery?: boolean;
|
|
142
|
+
/** When provided, called when message/query text changes (for template suggestion matching). */
|
|
143
|
+
onQueryChange?: (query: string) => void;
|
|
144
|
+
/** Overrides for left toolbar items (search, zap, lightbulb). e.g. { zap: { enabled: false } } */
|
|
145
|
+
leftItemsOverrides?: LeftItemsOverrides;
|
|
146
|
+
/** Overrides for right toolbar items (tag, chip, camera, image, attach, mic). e.g. { camera: { enabled: false } } */
|
|
147
|
+
rightItemsOverrides?: RightItemsOverrides;
|
|
148
|
+
/** Customize InputToolBar from outside: className, classNames, leftItems, rightItems, templateButton, callbacks (onContainerClick, etc.), modals, topContent, templateModalClassName. When set, overrides the internal value for that prop. */
|
|
149
|
+
inputToolBarProps?: InputToolBarPropsOverrides;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const InputComponent = ({
|
|
153
|
+
handleSend: handleSendProp,
|
|
154
|
+
placeholder,
|
|
155
|
+
modelConfig,
|
|
156
|
+
onModelConfigChange,
|
|
157
|
+
textareaClassName,
|
|
158
|
+
toolBarParentClassName,
|
|
159
|
+
textareaStyles,
|
|
160
|
+
isShowMeta = false,
|
|
161
|
+
showModeSelector = false,
|
|
162
|
+
showStopButton = false,
|
|
163
|
+
onStop,
|
|
164
|
+
inputToolBarParentClass,
|
|
165
|
+
templates = [],
|
|
166
|
+
leftItemsOverrides,
|
|
167
|
+
rightItemsOverrides,
|
|
168
|
+
inputToolBarProps,
|
|
169
|
+
selectedTemplate = null,
|
|
170
|
+
suggestedTemplate = null,
|
|
171
|
+
onSelectTemplate,
|
|
172
|
+
templateSelectedLabel: templateSelectedLabelProp,
|
|
173
|
+
templateModalItems: templateModalItemsProp,
|
|
174
|
+
showTemplateModal: showTemplateModalProp,
|
|
175
|
+
onOpenTemplateModal,
|
|
176
|
+
onCloseTemplateModal,
|
|
177
|
+
onSelectTemplateById: onSelectTemplateByIdProp,
|
|
178
|
+
onClearTemplate,
|
|
179
|
+
onAcceptSuggestedTemplate,
|
|
180
|
+
isAnalyzingQuery,
|
|
181
|
+
onQueryChange,
|
|
182
|
+
}: MessageInputProps) => {
|
|
183
|
+
const [message, setMessage] = useState('');
|
|
184
|
+
const [sending, setSending] = useState(false);
|
|
185
|
+
const [attachments, setAttachments] = useState<AttachedFile[]>([]);
|
|
186
|
+
const [showToast, setShowToast] = useState(false);
|
|
187
|
+
const [toastMessage, setToastMessage] = useState('');
|
|
188
|
+
const [showTemplateModal, setShowTemplateModal] = useState(false);
|
|
189
|
+
const [showProjectSettingsModal, setShowProjectSettingsModal] = useState(false);
|
|
190
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
191
|
+
const formRef = useRef<HTMLFormElement>(null);
|
|
192
|
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
193
|
+
const { t } = useTranslation('translations');
|
|
194
|
+
|
|
195
|
+
const isControlledTemplateModal =
|
|
196
|
+
showTemplateModalProp !== undefined && onOpenTemplateModal != null && onCloseTemplateModal != null;
|
|
197
|
+
const setShowTemplateModalEffective = useCallback(
|
|
198
|
+
(open: boolean) => {
|
|
199
|
+
if (isControlledTemplateModal) {
|
|
200
|
+
if (open) onOpenTemplateModal?.();
|
|
201
|
+
else onCloseTemplateModal?.();
|
|
202
|
+
} else {
|
|
203
|
+
setShowTemplateModal(open);
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
[isControlledTemplateModal, onOpenTemplateModal, onCloseTemplateModal],
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
// Auto-focus the textarea when component mounts
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
if (textareaRef.current) {
|
|
212
|
+
textareaRef.current.focus();
|
|
213
|
+
}
|
|
214
|
+
}, []);
|
|
215
|
+
|
|
216
|
+
// Ensure default template is set to 'vite-react' if missing
|
|
217
|
+
useEffect(() => {
|
|
218
|
+
if (modelConfig && !modelConfig.template && onModelConfigChange) {
|
|
219
|
+
onModelConfigChange({ ...modelConfig, template: 'vite-react' as ModelConfig['template'] });
|
|
220
|
+
}
|
|
221
|
+
}, [modelConfig, onModelConfigChange]);
|
|
222
|
+
|
|
223
|
+
// Clear template selection when switching away from build mode
|
|
224
|
+
const currentModeForEffect = modelConfig?.mode ?? 'plan';
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
if (currentModeForEffect !== 'build') {
|
|
227
|
+
onSelectTemplate?.(null);
|
|
228
|
+
setShowTemplateModalEffective(false);
|
|
229
|
+
}
|
|
230
|
+
}, [currentModeForEffect, onSelectTemplate, setShowTemplateModalEffective]);
|
|
231
|
+
|
|
232
|
+
const showToastMessage = useCallback((msg: string) => {
|
|
233
|
+
setToastMessage(msg);
|
|
234
|
+
setShowToast(true);
|
|
235
|
+
setTimeout(() => setShowToast(false), 3000);
|
|
236
|
+
}, []);
|
|
237
|
+
|
|
238
|
+
const handleSend = useCallback(() => {
|
|
239
|
+
if (!message.trim() && attachments.length === 0) return;
|
|
240
|
+
if (!handleSendProp) return;
|
|
241
|
+
|
|
242
|
+
setSending(true);
|
|
243
|
+
handleSendProp(
|
|
244
|
+
message,
|
|
245
|
+
attachments.map((a) => a.file),
|
|
246
|
+
)
|
|
247
|
+
.then(() => {
|
|
248
|
+
setMessage('');
|
|
249
|
+
setAttachments([]);
|
|
250
|
+
setTimeout(() => {
|
|
251
|
+
textareaRef.current?.focus();
|
|
252
|
+
}, 100);
|
|
253
|
+
})
|
|
254
|
+
.finally(() => setSending(false));
|
|
255
|
+
}, [attachments, handleSendProp, message]);
|
|
256
|
+
|
|
257
|
+
const handleSubmit = useCallback(
|
|
258
|
+
(e: React.FormEvent) => {
|
|
259
|
+
e.preventDefault();
|
|
260
|
+
handleSend();
|
|
261
|
+
},
|
|
262
|
+
[handleSend],
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
const handleKeyDown = useCallback(
|
|
266
|
+
(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
267
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
268
|
+
e.preventDefault();
|
|
269
|
+
handleSend();
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
[handleSend],
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
const handleChange = useCallback(
|
|
276
|
+
(e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
277
|
+
const value = e.target.value;
|
|
278
|
+
setMessage(value);
|
|
279
|
+
onQueryChange?.(value);
|
|
280
|
+
},
|
|
281
|
+
[onQueryChange],
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
const fileToAttached = useCallback(async (file: File): Promise<AttachedFile> => {
|
|
285
|
+
const id = `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
286
|
+
let dataUrl: string | undefined;
|
|
287
|
+
if (file.type.startsWith('image/')) {
|
|
288
|
+
dataUrl = await new Promise<string>((resolve, reject) => {
|
|
289
|
+
const reader = new FileReader();
|
|
290
|
+
reader.onload = () => resolve(reader.result as string);
|
|
291
|
+
reader.onerror = () => reject(new Error(`Failed to read file: ${file.name}`));
|
|
292
|
+
reader.readAsDataURL(file);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
id,
|
|
297
|
+
name: file.name,
|
|
298
|
+
size: file.size,
|
|
299
|
+
file,
|
|
300
|
+
dataUrl,
|
|
301
|
+
};
|
|
302
|
+
}, []);
|
|
303
|
+
|
|
304
|
+
const handleFilesSelected = useCallback(
|
|
305
|
+
async (newFiles: File[]) => {
|
|
306
|
+
if (attachments.length + newFiles.length > config.FILES_PER_MESSAGE) {
|
|
307
|
+
showToastMessage(
|
|
308
|
+
t('tailwind_ui_inbox.you_can_not_upload_more_than_files', {
|
|
309
|
+
files_per_message: config.FILES_PER_MESSAGE,
|
|
310
|
+
}),
|
|
311
|
+
);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const newAttachments = await Promise.all(newFiles.map(fileToAttached));
|
|
315
|
+
setAttachments((prev) => [...prev, ...newAttachments]);
|
|
316
|
+
},
|
|
317
|
+
[attachments.length, fileToAttached, showToastMessage, t],
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
const handleRemoveAttachment = useCallback((id: string) => {
|
|
321
|
+
setAttachments((prev) => prev.filter((a) => a.id !== id));
|
|
322
|
+
}, []);
|
|
323
|
+
|
|
324
|
+
const handleClearAttachments = useCallback(() => {
|
|
325
|
+
setAttachments([]);
|
|
326
|
+
}, []);
|
|
327
|
+
|
|
328
|
+
const handlePaste = useCallback(
|
|
329
|
+
(e: React.ClipboardEvent<HTMLTextAreaElement>) => {
|
|
330
|
+
const items = e.clipboardData?.items;
|
|
331
|
+
if (!items) return;
|
|
332
|
+
const pastedFiles: File[] = [];
|
|
333
|
+
for (let i = 0; i < items.length; i++) {
|
|
334
|
+
if (items[i].kind === 'file') {
|
|
335
|
+
const file = items[i].getAsFile();
|
|
336
|
+
if (file) pastedFiles.push(file);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (pastedFiles.length > 0) {
|
|
340
|
+
e.preventDefault();
|
|
341
|
+
handleFilesSelected(pastedFiles);
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
[handleFilesSelected],
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
const canSend = Boolean(message.trim() || attachments.length > 0);
|
|
348
|
+
|
|
349
|
+
const currentMode = modelConfig?.mode ?? 'plan';
|
|
350
|
+
|
|
351
|
+
const handleModeSwitch = useCallback(
|
|
352
|
+
(mode: 'plan' | 'build') => {
|
|
353
|
+
if (modelConfig && onModelConfigChange) {
|
|
354
|
+
onModelConfigChange({ ...modelConfig, mode });
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
[modelConfig, onModelConfigChange],
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
const leftItems = useMemo(() => {
|
|
361
|
+
const base: Record<string, Record<string, unknown>> = {
|
|
362
|
+
search: {
|
|
363
|
+
active: currentMode === 'plan',
|
|
364
|
+
onClick: () => handleModeSwitch('plan'),
|
|
365
|
+
},
|
|
366
|
+
zap: { enabled: false },
|
|
367
|
+
lightbulb: {
|
|
368
|
+
active: currentMode === 'build',
|
|
369
|
+
onClick: () => handleModeSwitch('build'),
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
if (leftItemsOverrides) {
|
|
373
|
+
for (const [k, v] of Object.entries(leftItemsOverrides)) {
|
|
374
|
+
if (v) base[k] = { ...base[k], ...v };
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return getDefaultLeftItems(base as LeftItemsOverrides);
|
|
378
|
+
}, [currentMode, handleModeSwitch, leftItemsOverrides]);
|
|
379
|
+
|
|
380
|
+
const rightItems = useMemo(() => {
|
|
381
|
+
const base: Record<string, Record<string, unknown>> = {
|
|
382
|
+
tag: { enabled: false },
|
|
383
|
+
chip: { enabled: false },
|
|
384
|
+
camera: { enabled: false },
|
|
385
|
+
image: { enabled: false },
|
|
386
|
+
attach: { onClick: () => fileInputRef.current?.click() },
|
|
387
|
+
};
|
|
388
|
+
if (rightItemsOverrides) {
|
|
389
|
+
for (const [k, v] of Object.entries(rightItemsOverrides)) {
|
|
390
|
+
if (v) base[k] = { ...base[k], ...v };
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
const projectSettingsOverride = base.projectSettings as { enabled?: boolean } | undefined;
|
|
394
|
+
const projectSettingsEnabled = projectSettingsOverride?.enabled === true;
|
|
395
|
+
if (projectSettingsEnabled && projectSettingsOverride) {
|
|
396
|
+
base.projectSettings = {
|
|
397
|
+
...projectSettingsOverride,
|
|
398
|
+
enabled: true,
|
|
399
|
+
onClick: () => setShowProjectSettingsModal(true),
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
return getDefaultRightItems(base as RightItemsOverrides);
|
|
403
|
+
}, [rightItemsOverrides]);
|
|
404
|
+
|
|
405
|
+
const templateModalItemsDerived = useMemo(
|
|
406
|
+
(): TemplateModalItem[] =>
|
|
407
|
+
templates.map((t) => ({
|
|
408
|
+
id: t.formExtensionId ?? t.formId,
|
|
409
|
+
label: t.displayName ?? t.templateName ?? '',
|
|
410
|
+
description: t.description,
|
|
411
|
+
category: t.category,
|
|
412
|
+
})),
|
|
413
|
+
[templates],
|
|
414
|
+
);
|
|
415
|
+
const templateModalItems = templateModalItemsProp ?? templateModalItemsDerived;
|
|
416
|
+
|
|
417
|
+
const handleSelectTemplateByIdInternal = useCallback(
|
|
418
|
+
(id: string) => {
|
|
419
|
+
const t = templates.find((x) => (x.formExtensionId ?? x.formId) === id);
|
|
420
|
+
if (t) onSelectTemplate?.(t);
|
|
421
|
+
},
|
|
422
|
+
[templates, onSelectTemplate],
|
|
423
|
+
);
|
|
424
|
+
const handleSelectTemplateById = onSelectTemplateByIdProp ?? handleSelectTemplateByIdInternal;
|
|
425
|
+
|
|
426
|
+
const displayTemplate = selectedTemplate ?? suggestedTemplate;
|
|
427
|
+
const templateSelectedLabelDerived = displayTemplate?.displayName ?? displayTemplate?.templateName ?? null;
|
|
428
|
+
const templateSelectedLabel = templateSelectedLabelProp ?? templateSelectedLabelDerived;
|
|
429
|
+
|
|
430
|
+
const showTemplateModalEffective = isControlledTemplateModal ? showTemplateModalProp : showTemplateModal;
|
|
431
|
+
const handleClearTemplate = useCallback(() => {
|
|
432
|
+
if (onClearTemplate) onClearTemplate();
|
|
433
|
+
else onSelectTemplate?.(null);
|
|
434
|
+
}, [onClearTemplate, onSelectTemplate]);
|
|
435
|
+
const isBuildMode = currentMode === 'build';
|
|
436
|
+
|
|
437
|
+
const handleContainerClick = useCallback((e: React.MouseEvent) => {
|
|
438
|
+
if (!(e.target as HTMLElement).closest('button')) {
|
|
439
|
+
textareaRef.current?.focus();
|
|
440
|
+
}
|
|
441
|
+
}, []);
|
|
442
|
+
|
|
443
|
+
// const templateButtonHidden = (leftItemsOverrides?.template as { enabled?: boolean })?.enabled === false;
|
|
444
|
+
const templateButtonEnabled = (leftItemsOverrides?.template as { enabled?: boolean })?.enabled || false;
|
|
445
|
+
const projectSettingsModalRender = useCallback(
|
|
446
|
+
(props: { onClose: () => void }) => {
|
|
447
|
+
if (!modelConfig || !onModelConfigChange) return null;
|
|
448
|
+
return (
|
|
449
|
+
<ProjectSettingsModal
|
|
450
|
+
modelConfig={modelConfig}
|
|
451
|
+
onModelConfigChange={onModelConfigChange}
|
|
452
|
+
onClose={props.onClose}
|
|
453
|
+
isShowMeta={isShowMeta}
|
|
454
|
+
/>
|
|
455
|
+
);
|
|
456
|
+
},
|
|
457
|
+
[modelConfig, onModelConfigChange, isShowMeta],
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
const showProjectSettingsModalContent =
|
|
461
|
+
(rightItemsOverrides?.projectSettings as { enabled?: boolean })?.enabled === true;
|
|
462
|
+
|
|
463
|
+
return (
|
|
464
|
+
<div className={`bg-white ${toolBarParentClassName ?? ''}`}>
|
|
465
|
+
{showToast && (
|
|
466
|
+
<div className="fixed top-4 right-4 z-50 rounded-lg border border-orange-200 bg-orange-50 px-4 py-3 text-orange-800 shadow-lg animate-bounce">
|
|
467
|
+
<div className="flex items-center">
|
|
468
|
+
<svg className="mr-2 h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
|
|
469
|
+
<path
|
|
470
|
+
fillRule="evenodd"
|
|
471
|
+
d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z"
|
|
472
|
+
clipRule="evenodd"
|
|
473
|
+
/>
|
|
474
|
+
</svg>
|
|
475
|
+
{toastMessage}
|
|
476
|
+
</div>
|
|
477
|
+
</div>
|
|
478
|
+
)}
|
|
479
|
+
|
|
480
|
+
<form ref={formRef} onSubmit={handleSubmit} aria-label="Message input form">
|
|
481
|
+
<InputToolBar
|
|
482
|
+
className={`w-full cursor-text overflow-visible rounded-[24px] border border-border/70 bg-card shadow-md ${
|
|
483
|
+
inputToolBarParentClass ?? ''
|
|
484
|
+
} ${inputToolBarProps?.className ?? ''}`.trim()}
|
|
485
|
+
inputConfig={{
|
|
486
|
+
value: sending ? '' : message,
|
|
487
|
+
onChange: handleChange,
|
|
488
|
+
onKeyDown: handleKeyDown,
|
|
489
|
+
onPaste: handlePaste,
|
|
490
|
+
placeholder: placeholder || 'Message',
|
|
491
|
+
disabled: sending,
|
|
492
|
+
id: 'message-input',
|
|
493
|
+
name: 'message',
|
|
494
|
+
inputRef: textareaRef,
|
|
495
|
+
}}
|
|
496
|
+
topContent={
|
|
497
|
+
inputToolBarProps?.topContent !== undefined ? (
|
|
498
|
+
inputToolBarProps.topContent
|
|
499
|
+
) : attachments.length > 0 && !sending ? (
|
|
500
|
+
<div className="flex flex-col gap-2 px-4 py-3">
|
|
501
|
+
{attachments.length > 1 && (
|
|
502
|
+
<div className="flex items-center justify-between">
|
|
503
|
+
<button
|
|
504
|
+
type="button"
|
|
505
|
+
onClick={handleClearAttachments}
|
|
506
|
+
className="px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-destructive"
|
|
507
|
+
>
|
|
508
|
+
Clear all
|
|
509
|
+
</button>
|
|
510
|
+
</div>
|
|
511
|
+
)}
|
|
512
|
+
<div className="flex flex-wrap gap-2">
|
|
513
|
+
{attachments.map((attachment) => (
|
|
514
|
+
<AttachmentPreview
|
|
515
|
+
key={attachment.id}
|
|
516
|
+
attachment={attachment}
|
|
517
|
+
onRemove={handleRemoveAttachment}
|
|
518
|
+
/>
|
|
519
|
+
))}
|
|
520
|
+
</div>
|
|
521
|
+
</div>
|
|
522
|
+
) : undefined
|
|
523
|
+
}
|
|
524
|
+
leftItems={inputToolBarProps?.leftItems ?? leftItems}
|
|
525
|
+
leftCustomRender={inputToolBarProps?.leftCustomRender}
|
|
526
|
+
templateButton={
|
|
527
|
+
inputToolBarProps?.templateButton !== undefined
|
|
528
|
+
? inputToolBarProps.templateButton
|
|
529
|
+
: isBuildMode && templateButtonEnabled === true
|
|
530
|
+
? {
|
|
531
|
+
label: '+ Template',
|
|
532
|
+
count: templates.length > 0 ? templates.length : undefined,
|
|
533
|
+
selectedLabel: templateSelectedLabel ?? undefined,
|
|
534
|
+
onClick: () => setShowTemplateModalEffective(true),
|
|
535
|
+
onClearTemplate: handleClearTemplate,
|
|
536
|
+
disabled: sending,
|
|
537
|
+
}
|
|
538
|
+
: null
|
|
539
|
+
}
|
|
540
|
+
classNames={
|
|
541
|
+
isBuildMode
|
|
542
|
+
? {
|
|
543
|
+
templatePill:
|
|
544
|
+
'rounded-full px-2 py-1 text-xs font-medium border border-border bg-muted/50 text-foreground hover:border-primary hover:bg-primary/5 transition-colors',
|
|
545
|
+
templatePillSelected:
|
|
546
|
+
'rounded-full px-2 py-1 text-xs font-medium border border-primary/20 bg-primary/10 text-primary',
|
|
547
|
+
...inputToolBarProps?.classNames,
|
|
548
|
+
}
|
|
549
|
+
: inputToolBarProps?.classNames
|
|
550
|
+
}
|
|
551
|
+
templateModalConfig={
|
|
552
|
+
inputToolBarProps?.templateModalConfig !== undefined
|
|
553
|
+
? inputToolBarProps.templateModalConfig
|
|
554
|
+
: isBuildMode && templateButtonEnabled === true
|
|
555
|
+
? {
|
|
556
|
+
isOpen: showTemplateModalEffective,
|
|
557
|
+
onClose: () => setShowTemplateModalEffective(false),
|
|
558
|
+
templates: templateModalItems,
|
|
559
|
+
selectedId: selectedTemplate?.formExtensionId ?? selectedTemplate?.formId ?? null,
|
|
560
|
+
onSelect: handleSelectTemplateById,
|
|
561
|
+
suggestedId:
|
|
562
|
+
suggestedTemplate?.formExtensionId ?? suggestedTemplate?.formId ?? undefined,
|
|
563
|
+
title: 'Choose Template',
|
|
564
|
+
modalClassName: inputToolBarProps?.templateModalClassName,
|
|
565
|
+
}
|
|
566
|
+
: undefined
|
|
567
|
+
}
|
|
568
|
+
templateModalRender={inputToolBarProps?.templateModalRender}
|
|
569
|
+
rightItems={inputToolBarProps?.rightItems ?? rightItems}
|
|
570
|
+
rightCustomRender={inputToolBarProps?.rightCustomRender}
|
|
571
|
+
projectSettingsModalOpen={inputToolBarProps?.projectSettingsModalOpen ?? showProjectSettingsModal}
|
|
572
|
+
onProjectSettingsModalClose={
|
|
573
|
+
inputToolBarProps?.onProjectSettingsModalClose ?? (() => setShowProjectSettingsModal(false))
|
|
574
|
+
}
|
|
575
|
+
projectSettingsModalRender={
|
|
576
|
+
inputToolBarProps?.projectSettingsModalRender ??
|
|
577
|
+
(showProjectSettingsModalContent ? projectSettingsModalRender : undefined)
|
|
578
|
+
}
|
|
579
|
+
micSendButton={
|
|
580
|
+
inputToolBarProps?.micSendButton ?? {
|
|
581
|
+
hasContent: canSend,
|
|
582
|
+
onSend: () => formRef.current?.requestSubmit(),
|
|
583
|
+
onMic: () => {
|
|
584
|
+
/* Voice input - placeholder */
|
|
585
|
+
},
|
|
586
|
+
disabled: sending,
|
|
587
|
+
isLoading: showStopButton,
|
|
588
|
+
onStop: showStopButton ? onStop : undefined,
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
onContainerClick={inputToolBarProps?.onContainerClick ?? handleContainerClick}
|
|
592
|
+
/>
|
|
593
|
+
<input
|
|
594
|
+
ref={fileInputRef}
|
|
595
|
+
type="file"
|
|
596
|
+
multiple
|
|
597
|
+
className="hidden"
|
|
598
|
+
aria-hidden
|
|
599
|
+
onChange={(e) => {
|
|
600
|
+
const selectedFiles = Array.from(e.target.files ?? []);
|
|
601
|
+
if (selectedFiles.length > 0) handleFilesSelected(selectedFiles);
|
|
602
|
+
e.target.value = '';
|
|
603
|
+
}}
|
|
604
|
+
/>
|
|
605
|
+
</form>
|
|
606
|
+
</div>
|
|
607
|
+
);
|
|
608
|
+
};
|