@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,174 @@
|
|
|
1
|
+
# InputComponent (AIAgent)
|
|
2
|
+
|
|
3
|
+
A full **message input** component for the AI inbox: textarea, file attachments, plan/build mode toggles, optional template pill, project settings modal, and send/mic button. It composes `InputToolBar` from `@admin-layout/tailwind-ui` and wires model config, templates, and overrides.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Message input**: Controlled textarea with placeholder, paste handling, and Enter-to-send.
|
|
8
|
+
- **Attachments**: Add/remove files; image previews; configurable max files per message.
|
|
9
|
+
- **Plan / Build mode**: Left toolbar toggles (plan = chat, build = template mode). Mode is synced with `modelConfig.mode` via `onModelConfigChange`.
|
|
10
|
+
- **Template pill**: In build mode, optional “+ Template” pill opens a template selection modal. Visibility is controlled by `leftItemsOverrides.template.enabled` (default: hidden unless `enabled: true`).
|
|
11
|
+
- **Project settings**: Optional gear button opens the same project settings modal (Configuration, Other Settings, Secret). Enabled via `rightItemsOverrides.projectSettings.enabled === true`.
|
|
12
|
+
- **Toolbar customization**: Use `leftItemsOverrides` / `rightItemsOverrides` for per-item overrides, or `inputToolBarProps` for full overrides (left/right items, classNames, callbacks, modals).
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
The component lives in `@messenger-box/tailwind-ui-inbox`:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { InputComponent } from '@messenger-box/tailwind-ui-inbox';
|
|
20
|
+
// Types
|
|
21
|
+
import type {
|
|
22
|
+
MessageInputProps,
|
|
23
|
+
LeftItemsOverrides,
|
|
24
|
+
RightItemsOverrides,
|
|
25
|
+
InputToolBarPropsOverrides,
|
|
26
|
+
LeftToolbarItemId,
|
|
27
|
+
RightToolbarItemId,
|
|
28
|
+
} from '@messenger-box/tailwind-ui-inbox';
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Props (`MessageInputProps`)
|
|
32
|
+
|
|
33
|
+
| Prop | Type | Description |
|
|
34
|
+
| ------------------------- | --------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
35
|
+
| `handleSend` | `(message: string, files: File[]) => Promise<void>` | Called on submit with message text and attached files. |
|
|
36
|
+
| `placeholder` | `string` | Placeholder for the textarea. |
|
|
37
|
+
| `modelConfig` | `ModelConfig` | Current model config (provider, model, apiKey, template, mode, etc.). From `usePersistentModelConfig()`. |
|
|
38
|
+
| `onModelConfigChange` | `(config: ModelConfig) => void` | Called when mode or config changes (e.g. plan/build switch, settings modal). |
|
|
39
|
+
| `textareaClassName` | `string` | Optional class for the textarea. |
|
|
40
|
+
| `textareaStyles` | `React.CSSProperties` | Optional inline styles for the textarea. |
|
|
41
|
+
| `toolBarParentClassName` | `string` | Optional class for the wrapper around the toolbar. |
|
|
42
|
+
| `inputToolBarParentClass` | `string` | Optional class merged onto the InputToolBar container. |
|
|
43
|
+
| `isShowMeta` | `boolean` | Passed to the project settings modal (e.g. show extra metadata). |
|
|
44
|
+
| `showModeSelector` | `boolean` | Whether the plan/build left toggles are relevant (no direct visual change; can be used by parent). |
|
|
45
|
+
| `showStopButton` | `boolean` | When true, mic/send button can show Stop and call `onStop`. |
|
|
46
|
+
| `onStop` | `() => void` | Called when user clicks Stop (e.g. stop AI generation). |
|
|
47
|
+
| `templates` | `TemplateConfig[]` | List of templates for the template modal (build mode). |
|
|
48
|
+
| `selectedTemplate` | `TemplateConfig \| null` | Currently selected template. |
|
|
49
|
+
| `suggestedTemplate` | `TemplateConfig \| null` | Optional suggested template in the modal. |
|
|
50
|
+
| `onSelectTemplate` | `(template: TemplateConfig \| null) => void` | Called when user selects or clears a template. |
|
|
51
|
+
| `leftItemsOverrides` | `LeftItemsOverrides` | Per-item overrides for left toolbar (search, zap, lightbulb, template). |
|
|
52
|
+
| `rightItemsOverrides` | `RightItemsOverrides` | Per-item overrides for right toolbar (projectSettings, tag, chip, camera, image, attach, mic). |
|
|
53
|
+
| `inputToolBarProps` | `InputToolBarPropsOverrides` | Full overrides for InputToolBar (className, classNames, leftItems, rightItems, callbacks, modals, etc.). |
|
|
54
|
+
|
|
55
|
+
## Left / right item overrides
|
|
56
|
+
|
|
57
|
+
Use these to show/hide or customize toolbar items **without** replacing the whole list.
|
|
58
|
+
|
|
59
|
+
### Left item ids (`LeftToolbarItemId`)
|
|
60
|
+
|
|
61
|
+
`'search' | 'zap' | 'lightbulb' | 'template'`
|
|
62
|
+
|
|
63
|
+
- **search** – Plan mode (chat).
|
|
64
|
+
- **zap** – Disabled by default.
|
|
65
|
+
- **lightbulb** – Build mode (templates).
|
|
66
|
+
- **template** – When `enabled: true`, the template pill is shown in build mode; when `enabled: false` or omitted, the pill is hidden.
|
|
67
|
+
|
|
68
|
+
### Right item ids (`RightToolbarItemId`)
|
|
69
|
+
|
|
70
|
+
`'projectSettings' | 'tag' | 'chip' | 'camera' | 'image' | 'attach' | 'mic'`
|
|
71
|
+
|
|
72
|
+
- **projectSettings** – Gear icon. Shown only when `rightItemsOverrides.projectSettings.enabled === true`. Opens the project settings modal.
|
|
73
|
+
- **tag**, **chip**, **camera**, **image** – Disabled by default; enable or override as needed.
|
|
74
|
+
- **attach** – Wired to a hidden file input; override `onClick` if you need custom behavior.
|
|
75
|
+
- **mic** – Replaced by the combined mic/send button when the component provides `micSendButton`.
|
|
76
|
+
|
|
77
|
+
### Override shape
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
// Left: e.g. hide template pill, or enable and keep default behavior
|
|
81
|
+
leftItemsOverrides={{ template: { enabled: false } }}
|
|
82
|
+
leftItemsOverrides={{ template: { enabled: true } }}
|
|
83
|
+
|
|
84
|
+
// Right: enable project settings button
|
|
85
|
+
rightItemsOverrides={{ projectSettings: { enabled: true } }}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Each item can receive `enabled`, `label`, `active`, `onClick`, `icon`, `customButton` (see `LeftItemOverride` / `RightItemOverride` in the source).
|
|
89
|
+
|
|
90
|
+
## InputToolBar overrides (`inputToolBarProps`)
|
|
91
|
+
|
|
92
|
+
When you need to **replace** or fully control toolbar content or behavior, pass `inputToolBarProps`. Any prop you set overrides the component’s internal value for that prop.
|
|
93
|
+
|
|
94
|
+
### Type
|
|
95
|
+
|
|
96
|
+
`InputToolBarPropsOverrides` = `Partial<Omit<InputToolBarProps, 'inputConfig' | 'children'>> & { templateModalClassName?: string }`
|
|
97
|
+
|
|
98
|
+
So you can pass any InputToolBar prop except `inputConfig` and `children`, plus:
|
|
99
|
+
|
|
100
|
+
- **templateModalClassName** – Class for the template modal content box (e.g. `max-w-xl`). Used when the component builds the default template modal.
|
|
101
|
+
|
|
102
|
+
### Overridable props (summary)
|
|
103
|
+
|
|
104
|
+
| Category | Props |
|
|
105
|
+
| -------------------- | --------------------------------------------------------------------------------------- |
|
|
106
|
+
| **Styling** | `className`, `classNames`, `templateModalClassName` |
|
|
107
|
+
| **Content** | `topContent`, `leftItems`, `rightItems`, `leftCustomRender`, `rightCustomRender` |
|
|
108
|
+
| **Template** | `templateButton`, `templateModalConfig`, `templateModalRender` |
|
|
109
|
+
| **Project settings** | `projectSettingsModalOpen`, `onProjectSettingsModalClose`, `projectSettingsModalRender` |
|
|
110
|
+
| **Actions** | `micSendButton`, `onContainerClick` |
|
|
111
|
+
|
|
112
|
+
### Example: standardize from the loader
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
// e.g. in TestInboxWithAiLoader or InboxWithAiLoader
|
|
116
|
+
<InboxWithAiLoader
|
|
117
|
+
inputToolBarProps={{
|
|
118
|
+
templateModalClassName: 'max-w-xl',
|
|
119
|
+
classNames: {
|
|
120
|
+
container: 'rounded-[24px]',
|
|
121
|
+
},
|
|
122
|
+
}}
|
|
123
|
+
leftItemsOverrides={{ template: { enabled: false } }}
|
|
124
|
+
rightItemsOverrides={{ projectSettings: { enabled: true } }}
|
|
125
|
+
/>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Example: custom left/right items and callback
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
<InputComponent
|
|
132
|
+
handleSend={handleSend}
|
|
133
|
+
modelConfig={modelConfig}
|
|
134
|
+
onModelConfigChange={updateModelConfig}
|
|
135
|
+
inputToolBarProps={{
|
|
136
|
+
leftItems: myCustomLeftItems,
|
|
137
|
+
rightItems: myCustomRightItems,
|
|
138
|
+
onContainerClick: (e) => {
|
|
139
|
+
myFocusLogic();
|
|
140
|
+
textareaRef.current?.focus();
|
|
141
|
+
},
|
|
142
|
+
}}
|
|
143
|
+
/>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Internal behavior (no override)
|
|
147
|
+
|
|
148
|
+
- **inputConfig** and **children** are never overridable; the component always owns the textarea and optional attachment preview as `topContent`.
|
|
149
|
+
- **Default left items**: Plan (search) and Build (lightbulb) toggles, with zap disabled. Merged with `leftItemsOverrides` and passed to `getDefaultLeftItems`.
|
|
150
|
+
- **Default right items**: Attach wired to file input; projectSettings only if `rightItemsOverrides.projectSettings.enabled === true`. Merged with `rightItemsOverrides` and passed to `getDefaultRightItems`.
|
|
151
|
+
- **Template pill**: Rendered only in build mode and when `leftItemsOverrides.template.enabled === true`.
|
|
152
|
+
- **Project settings modal**: Uses `ProjectSettingsModal` from `ModelConfigPanel`; open state is internal, unless overridden via `inputToolBarProps.projectSettingsModalOpen` / `onProjectSettingsModalClose` / `projectSettingsModalRender`.
|
|
153
|
+
|
|
154
|
+
## Exported types
|
|
155
|
+
|
|
156
|
+
From `@messenger-box/tailwind-ui-inbox`:
|
|
157
|
+
|
|
158
|
+
- `MessageInputProps` – Props for `InputComponent`.
|
|
159
|
+
- `LeftItemOverride`, `RightItemOverride` – Per-item override shape.
|
|
160
|
+
- `LeftToolbarItemId`, `RightToolbarItemId` – Item id unions.
|
|
161
|
+
- `LeftItemsOverrides`, `RightItemsOverrides` – Maps of overrides by id.
|
|
162
|
+
- `InputToolBarPropsOverrides` – Full InputToolBar overrides (excluding `inputConfig` and `children`).
|
|
163
|
+
|
|
164
|
+
## Dependencies
|
|
165
|
+
|
|
166
|
+
- **@admin-layout/tailwind-ui**: `InputToolBar`, `getDefaultLeftItems`, `getDefaultRightItems`, and `InputToolBarProps`.
|
|
167
|
+
- **usePersistentModelConfig**: Not used inside InputComponent; parent passes `modelConfig` and `onModelConfigChange`.
|
|
168
|
+
- **ProjectSettingsModal**: From `../ModelConfigPanel`; used when project settings is enabled.
|
|
169
|
+
|
|
170
|
+
## See also
|
|
171
|
+
|
|
172
|
+
- **InputToolBar** in `@admin-layout/tailwind-ui`: that package’s InputToolBar README documents toolbar props (`leftItems`, `rightItems`, `classNames`, `templateModalConfig`, etc.).
|
|
173
|
+
- **usePersistentModelConfig**: shared model config state; parent typically passes `modelConfig` and `updateModelConfig` into this component.
|
|
174
|
+
- **InboxWithAiLoader**, **TestInboxWithAiLoader**: examples of passing `inputToolBarProps`, `leftItemsOverrides`, and `rightItemsOverrides` from the route/loader level.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AIAgent } from './AIAgent';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { format } from 'date-fns';
|
|
3
|
+
import { BsFlag } from '@react-icons/all-files/bs/BsFlag.js';
|
|
4
|
+
import { FilesList } from '../inbox';
|
|
5
|
+
|
|
6
|
+
export const CommonMessage = ({ message, index, onOpen, currentUser }) => {
|
|
7
|
+
return (
|
|
8
|
+
<div className="w-full flex justify-start mb-7" key={`msgList_${index}`}>
|
|
9
|
+
<div className="flex flex-grow">
|
|
10
|
+
<img
|
|
11
|
+
className="w-8 h-8 bg-gray-500 rounded-full mr-4 cursor-pointer"
|
|
12
|
+
src={message?.imageUrl || ''}
|
|
13
|
+
alt="User avatar"
|
|
14
|
+
onClick={onOpen}
|
|
15
|
+
/>
|
|
16
|
+
<div className="flex-grow">
|
|
17
|
+
<div className="flex flex-grow mt-1">
|
|
18
|
+
<span className="text-sm text-gray-600 font-bold">
|
|
19
|
+
{message?.author?.familyName && message?.author?.givenName
|
|
20
|
+
? message?.author?.givenName + ' ' + message?.author?.familyName
|
|
21
|
+
: message?.author?.username}
|
|
22
|
+
</span>
|
|
23
|
+
<span className="text-sm text-gray-500 ml-2">
|
|
24
|
+
{format(new Date(message?.createdAt), 'MMM dd, yyyy hh:mm aaa')}
|
|
25
|
+
</span>
|
|
26
|
+
</div>
|
|
27
|
+
<div>
|
|
28
|
+
<p className="text-sm mt-1 mb-1 whitespace-pre-line">{message?.message}</p>
|
|
29
|
+
{message.files?.totalCount ? <FilesList uploaded files={message.files?.data} /> : null}
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
{currentUser?.id !== message?.author?.id && (
|
|
34
|
+
<div className="ml-2">
|
|
35
|
+
<BsFlag className="text-gray-600 w-6 h-6" />
|
|
36
|
+
</div>
|
|
37
|
+
)}
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { useMessagesQuery, OnChatMessageAddedDocument as CHAT_MESSAGE_ADDED } from 'common/graphql';
|
|
2
|
+
import { format, isToday, isYesterday } from 'date-fns';
|
|
3
|
+
import React, { useMemo, useEffect, useState, useCallback } from 'react';
|
|
4
|
+
import { SubscriptionHandler } from './SubscriptionHandler';
|
|
5
|
+
|
|
6
|
+
const createdAtText = (value) => {
|
|
7
|
+
if (!value) return '';
|
|
8
|
+
let date = new Date(value);
|
|
9
|
+
if (isToday(date)) return 'Today';
|
|
10
|
+
if (isYesterday(date)) return 'Yesterday';
|
|
11
|
+
return format(new Date(value), 'MMM dd, yyyy');
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Custom Skeleton component for loading state
|
|
15
|
+
const Skeleton = ({ className = '' }) => {
|
|
16
|
+
return (
|
|
17
|
+
<div className={`animate-pulse bg-gray-300 dark:bg-gray-600 rounded ${className}`}>
|
|
18
|
+
<div className="h-4 bg-gray-300 dark:bg-gray-600 rounded w-3/4 mb-2"></div>
|
|
19
|
+
<div className="h-4 bg-gray-300 dark:bg-gray-600 rounded w-1/2"></div>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
interface ConversationItemProps {
|
|
25
|
+
showBorder: boolean;
|
|
26
|
+
currentUser: any;
|
|
27
|
+
filter: string;
|
|
28
|
+
channel: any;
|
|
29
|
+
handleSelectChannel: (channelId: string) => void;
|
|
30
|
+
users: any[];
|
|
31
|
+
selectedChannelId: string;
|
|
32
|
+
messagesQuery: any;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const ConversationItem = React.memo(
|
|
36
|
+
({
|
|
37
|
+
showBorder,
|
|
38
|
+
currentUser,
|
|
39
|
+
filter,
|
|
40
|
+
channel,
|
|
41
|
+
handleSelectChannel,
|
|
42
|
+
users,
|
|
43
|
+
selectedChannelId,
|
|
44
|
+
messagesQuery: messagesQueryProp,
|
|
45
|
+
}: ConversationItemProps) => {
|
|
46
|
+
// const {
|
|
47
|
+
// data: messagesQuery,
|
|
48
|
+
// loading: messageLoading,
|
|
49
|
+
// } = useMessagesQuery({
|
|
50
|
+
// variables: {
|
|
51
|
+
// channelId: channel.id?.toString(),
|
|
52
|
+
// limit: 1,
|
|
53
|
+
// },
|
|
54
|
+
// fetchPolicy: 'cache-and-network',
|
|
55
|
+
// });
|
|
56
|
+
const [messages, setMessages] = useState([]);
|
|
57
|
+
const {
|
|
58
|
+
data: messagesQuery,
|
|
59
|
+
loading: messageLoading,
|
|
60
|
+
refetch: refetchMessages,
|
|
61
|
+
subscribeToMore,
|
|
62
|
+
} = useMessagesQuery({
|
|
63
|
+
variables: {
|
|
64
|
+
channelId: channel?.id?.toString(),
|
|
65
|
+
parentId: null,
|
|
66
|
+
limit: 10,
|
|
67
|
+
// sort: {
|
|
68
|
+
// key: 'updatedAt',
|
|
69
|
+
// value: SortEnum.Desc,
|
|
70
|
+
// },
|
|
71
|
+
},
|
|
72
|
+
fetchPolicy: 'cache-and-network',
|
|
73
|
+
refetchWritePolicy: 'merge',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// const {
|
|
77
|
+
// data: newMessage,
|
|
78
|
+
// loading: newMsgLoading,
|
|
79
|
+
// error: newMsgError,
|
|
80
|
+
// }: any = useOnChatMessageAddedSubscription({
|
|
81
|
+
// variables: {
|
|
82
|
+
// channelId: channel?.id?.toString(),
|
|
83
|
+
// },
|
|
84
|
+
// });
|
|
85
|
+
|
|
86
|
+
React.useEffect(() => {
|
|
87
|
+
if (channel?.id) {
|
|
88
|
+
refetchMessages({
|
|
89
|
+
channelId: channel?.id?.toString(),
|
|
90
|
+
parentId: null,
|
|
91
|
+
limit: 10,
|
|
92
|
+
// sort: {
|
|
93
|
+
// key: 'updatedAt',
|
|
94
|
+
// value: SortEnum.Desc,
|
|
95
|
+
// },
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}, [channel?.id, refetchMessages]);
|
|
99
|
+
|
|
100
|
+
React.useEffect(() => {
|
|
101
|
+
if (messagesQuery?.messages?.data?.length) {
|
|
102
|
+
setMessages(messagesQuery.messages.data);
|
|
103
|
+
}
|
|
104
|
+
}, [messagesQuery?.messages?.data]);
|
|
105
|
+
|
|
106
|
+
const chatUser = useMemo(
|
|
107
|
+
() =>
|
|
108
|
+
users?.find(({ id }) => {
|
|
109
|
+
const isNotCurrentUser = id !== currentUser?.id;
|
|
110
|
+
if (isNotCurrentUser) {
|
|
111
|
+
return channel?.members?.find(({ user }) => user.id === id);
|
|
112
|
+
}
|
|
113
|
+
if (channel?.members?.length === 1 && channel?.members?.[0]?.user?.id === currentUser?.id) {
|
|
114
|
+
return currentUser;
|
|
115
|
+
}
|
|
116
|
+
return isNotCurrentUser;
|
|
117
|
+
}),
|
|
118
|
+
[users, currentUser, channel],
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// Last Message
|
|
122
|
+
// const lastMessage = useMemo(() => {
|
|
123
|
+
// if (!messagesQuery?.messages?.data?.length) {
|
|
124
|
+
// return null;
|
|
125
|
+
// }
|
|
126
|
+
// const { data } = messagesQuery.messages;
|
|
127
|
+
// return data[data.length - 1];
|
|
128
|
+
// }, [messagesQuery]);
|
|
129
|
+
const lastMessage = useMemo(() => {
|
|
130
|
+
if (!messages?.length) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const data = messages;
|
|
134
|
+
const filteredData: any = data?.filter((p: any) => p?.message !== '');
|
|
135
|
+
|
|
136
|
+
//return filteredData[0];
|
|
137
|
+
let filteredLastMessage =
|
|
138
|
+
filteredData && filteredData?.length
|
|
139
|
+
? filteredData?.reduce((a, b) => {
|
|
140
|
+
return new Date(a?.updatedAt) > new Date(b?.updatedAt) ? a : b;
|
|
141
|
+
}, []) ?? null
|
|
142
|
+
: null;
|
|
143
|
+
return filteredLastMessage;
|
|
144
|
+
// //return data[data.length - 1];
|
|
145
|
+
}, [messages]);
|
|
146
|
+
|
|
147
|
+
const channelType = useMemo(() => {
|
|
148
|
+
return channel?.type;
|
|
149
|
+
}, [channel]);
|
|
150
|
+
|
|
151
|
+
if (
|
|
152
|
+
filter &&
|
|
153
|
+
!chatUser?.username?.toLowerCase().includes(filter.toLowerCase()) &&
|
|
154
|
+
!lastMessage?.message?.toLowerCase().includes(filter.toLowerCase())
|
|
155
|
+
) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<div
|
|
161
|
+
key={`conv_channel_${channel.id}`}
|
|
162
|
+
className={`cursor-pointer flex items-center p-3 border-b ${
|
|
163
|
+
showBorder ? 'border-gray-300' : 'border-transparent'
|
|
164
|
+
} ${
|
|
165
|
+
channel.id == selectedChannelId
|
|
166
|
+
? 'bg-gray-300 dark:bg-gray-500'
|
|
167
|
+
: 'hover:bg-gray-50 dark:hover:bg-gray-700'
|
|
168
|
+
}`}
|
|
169
|
+
onClick={() => channel.id !== selectedChannelId && handleSelectChannel(channel.id)}
|
|
170
|
+
>
|
|
171
|
+
<img
|
|
172
|
+
className="w-10 h-10 rounded-full bg-gray-400 object-cover flex-shrink-0"
|
|
173
|
+
src={chatUser?.picture || '/default-avatar.svg'}
|
|
174
|
+
alt={chatUser?.givenName || 'User avatar'}
|
|
175
|
+
onError={(e) => {
|
|
176
|
+
// Prevent infinite loop by checking if we're already showing the fallback
|
|
177
|
+
if (e.currentTarget.src.includes('default-avatar.svg')) {
|
|
178
|
+
// If SVG also fails, use a data URL fallback
|
|
179
|
+
e.currentTarget.src =
|
|
180
|
+
'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSIyMCIgY3k9IjIwIiByPSIyMCIgZmlsbD0iI0U1RTdFQiIvPgogIDxjaXJjbGUgY3g9IjIwIiBjeT0iMTYiIHI9IjYiIGZpbGw9IiM5Q0EzQUYiLz4KICA8cGF0aCBkPSJNOCAzMmMwLTYuNjI3IDUuMzczLTEyIDEyLTEyczEyIDUuMzczIDEyIDEyIiBmaWxsPSIjOUNBM0FGIi8+Cjwvc3ZnPgo=';
|
|
181
|
+
} else {
|
|
182
|
+
e.currentTarget.src = '/default-avatar.svg';
|
|
183
|
+
}
|
|
184
|
+
}}
|
|
185
|
+
/>
|
|
186
|
+
<div className="ml-2 flex-grow min-w-10 max-w-96">
|
|
187
|
+
{messageLoading && <Skeleton className="w-full h-16" />}
|
|
188
|
+
{!messageLoading && (
|
|
189
|
+
<>
|
|
190
|
+
<LastMessageComponent
|
|
191
|
+
lastMessage={lastMessage}
|
|
192
|
+
channelType={channelType}
|
|
193
|
+
chatUser={chatUser}
|
|
194
|
+
/>
|
|
195
|
+
<SubscriptionHandler
|
|
196
|
+
subscribeToMore={subscribeToMore}
|
|
197
|
+
document={CHAT_MESSAGE_ADDED}
|
|
198
|
+
variables={{ channelId: channel?.id?.toString() }}
|
|
199
|
+
enabled={!!channel?.id && !!subscribeToMore}
|
|
200
|
+
updateQuery={(prev, { subscriptionData }: any) => {
|
|
201
|
+
if (!subscriptionData.data) return prev;
|
|
202
|
+
const newMessage: any = subscriptionData?.data?.chatMessageAdded;
|
|
203
|
+
console.log('ConversationItem: New message received via subscription:', newMessage);
|
|
204
|
+
const previousData = prev?.messages?.data
|
|
205
|
+
? [...prev.messages.data, newMessage]
|
|
206
|
+
: [];
|
|
207
|
+
const totalMsgCount = prev?.messages?.totalCount + 1;
|
|
208
|
+
const merged = {
|
|
209
|
+
...prev,
|
|
210
|
+
messages: {
|
|
211
|
+
...prev?.messages,
|
|
212
|
+
data: previousData,
|
|
213
|
+
totalCount: totalMsgCount,
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
return merged;
|
|
217
|
+
}}
|
|
218
|
+
onError={(error) => {
|
|
219
|
+
console.error('ConversationItem: Subscription error:', error);
|
|
220
|
+
}}
|
|
221
|
+
/>
|
|
222
|
+
</>
|
|
223
|
+
)}
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
);
|
|
227
|
+
},
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
interface LastMessageComponentProps {
|
|
231
|
+
lastMessage: any;
|
|
232
|
+
channelType: string;
|
|
233
|
+
chatUser: any;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const LastMessageComponent = React.memo(({ lastMessage, channelType, chatUser }: LastMessageComponentProps) => {
|
|
237
|
+
return (
|
|
238
|
+
<div className="flex flex-col w-full">
|
|
239
|
+
<div className="w-full flex justify-between items-center">
|
|
240
|
+
<span className="text-xs text-green-500 truncate">{channelType}</span>
|
|
241
|
+
<span className="text-xs text-gray-500">
|
|
242
|
+
{lastMessage ? createdAtText(lastMessage?.createdAt) : ''}
|
|
243
|
+
</span>
|
|
244
|
+
</div>
|
|
245
|
+
<p className="text-sm text-gray-600 dark:text-gray-300 font-bold mt-1">
|
|
246
|
+
{chatUser?.givenName + ' ' + chatUser?.familyName}
|
|
247
|
+
</p>
|
|
248
|
+
<p className="text-sm text-gray-600 dark:text-gray-400 truncate w-4/5 mt-1 line-clamp-1">
|
|
249
|
+
{lastMessage?.message && lastMessage.message.length > 30
|
|
250
|
+
? lastMessage.message.slice(0, 30) + '…'
|
|
251
|
+
: lastMessage?.message}
|
|
252
|
+
</p>
|
|
253
|
+
</div>
|
|
254
|
+
);
|
|
255
|
+
});
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { config } from '../../config';
|
|
4
|
+
import { FilesList } from '../inbox';
|
|
5
|
+
import { ModelToolbar } from '../ModelConfigPanel';
|
|
6
|
+
import { ModelConfig } from '../../hooks/usePersistentModelConfig';
|
|
7
|
+
|
|
8
|
+
type MessageInputProps = {
|
|
9
|
+
channelId?: string;
|
|
10
|
+
handleSend?: (message: string, files: File[]) => Promise<void>;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
modelConfig?: ModelConfig;
|
|
13
|
+
onModelConfigChange?: (config: ModelConfig) => void;
|
|
14
|
+
textareaClassName?: string;
|
|
15
|
+
textareaStyles?: React.CSSProperties;
|
|
16
|
+
toolBarParentClassName?: string;
|
|
17
|
+
showModelToolbarProjectSettings?: boolean;
|
|
18
|
+
isShowMeta?: boolean;
|
|
19
|
+
showModeSelector?: boolean;
|
|
20
|
+
showStopButton?: boolean;
|
|
21
|
+
onStop?: () => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const InputComponent = ({
|
|
25
|
+
handleSend: handleSendProp,
|
|
26
|
+
placeholder,
|
|
27
|
+
modelConfig,
|
|
28
|
+
onModelConfigChange,
|
|
29
|
+
textareaClassName,
|
|
30
|
+
toolBarParentClassName,
|
|
31
|
+
textareaStyles,
|
|
32
|
+
showModelToolbarProjectSettings = false,
|
|
33
|
+
isShowMeta = false,
|
|
34
|
+
showModeSelector = false,
|
|
35
|
+
showStopButton = false,
|
|
36
|
+
onStop,
|
|
37
|
+
}: MessageInputProps) => {
|
|
38
|
+
const [message, setMessage] = useState('');
|
|
39
|
+
const [sending, setSending] = useState(false);
|
|
40
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
41
|
+
const [showToast, setShowToast] = useState(false);
|
|
42
|
+
const [toastMessage, setToastMessage] = useState('');
|
|
43
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
44
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
45
|
+
const { t } = useTranslation('translations');
|
|
46
|
+
|
|
47
|
+
// Auto-focus the textarea when component mounts
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (textareaRef.current) {
|
|
50
|
+
textareaRef.current.focus();
|
|
51
|
+
}
|
|
52
|
+
}, []);
|
|
53
|
+
|
|
54
|
+
// Ensure default template is set to 'vite-react' if missing
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (modelConfig && !modelConfig.template && onModelConfigChange) {
|
|
57
|
+
onModelConfigChange({ ...modelConfig, template: 'vite-react' as any });
|
|
58
|
+
}
|
|
59
|
+
}, [modelConfig, onModelConfigChange]);
|
|
60
|
+
|
|
61
|
+
// no dropdowns managed here; toolbar handles its own
|
|
62
|
+
|
|
63
|
+
const showToastMessage = useCallback((message: string) => {
|
|
64
|
+
setToastMessage(message);
|
|
65
|
+
setShowToast(true);
|
|
66
|
+
setTimeout(() => setShowToast(false), 3000);
|
|
67
|
+
}, []);
|
|
68
|
+
|
|
69
|
+
const handleSend = useCallback(() => {
|
|
70
|
+
if (!message.trim() && files.length === 0) return;
|
|
71
|
+
|
|
72
|
+
setSending(true);
|
|
73
|
+
handleSendProp(message, files)
|
|
74
|
+
.then(() => {
|
|
75
|
+
setMessage('');
|
|
76
|
+
setFiles([]);
|
|
77
|
+
// Auto-focus the textarea after sending a message
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
if (textareaRef.current) {
|
|
80
|
+
textareaRef.current.focus();
|
|
81
|
+
}
|
|
82
|
+
}, 100);
|
|
83
|
+
})
|
|
84
|
+
.finally(() => setSending(false));
|
|
85
|
+
}, [files, handleSendProp, message]);
|
|
86
|
+
|
|
87
|
+
const handleKeyDown = useCallback(
|
|
88
|
+
(e) => {
|
|
89
|
+
const keyCode = e.which || e.keyCode;
|
|
90
|
+
if (keyCode == 13 && !e.shiftKey) {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
handleSend();
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
[handleSend],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const inputHeight = useMemo(() => {
|
|
99
|
+
const lines = message.split('\n').length;
|
|
100
|
+
return Math.max(120, Math.min(200, 120 + (lines - 1) * 20));
|
|
101
|
+
}, [message]);
|
|
102
|
+
|
|
103
|
+
const onUploadImageChange = useCallback(
|
|
104
|
+
({ target }) => {
|
|
105
|
+
let fileList = [];
|
|
106
|
+
let index = 0;
|
|
107
|
+
if (files.length + target.files.length > config.FILES_PER_MESSAGE) {
|
|
108
|
+
showToastMessage(
|
|
109
|
+
t('tailwind_ui_inbox.you_can_not_upload_more_than_files', {
|
|
110
|
+
files_per_message: config.FILES_PER_MESSAGE,
|
|
111
|
+
}),
|
|
112
|
+
);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
while (target.files[index]) {
|
|
116
|
+
fileList.push(target.files[index]);
|
|
117
|
+
index += 1;
|
|
118
|
+
}
|
|
119
|
+
setFiles((oldFiles) => [...oldFiles, ...fileList]);
|
|
120
|
+
},
|
|
121
|
+
[setFiles, files, showToastMessage, t],
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const canSend = message.trim() || files.length > 0;
|
|
125
|
+
const hasContent = message.trim().length > 0;
|
|
126
|
+
|
|
127
|
+
// toolbar now owns model/template selections
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
// <div className="bg-gray-50 border-t border-gray-200">
|
|
131
|
+
<div className="bg-white ">
|
|
132
|
+
{/* Toast notification */}
|
|
133
|
+
{showToast && (
|
|
134
|
+
<div className="fixed top-4 right-4 z-50 bg-orange-50 border border-orange-200 text-orange-800 px-4 py-3 rounded-lg shadow-lg animate-bounce">
|
|
135
|
+
<div className="flex items-center">
|
|
136
|
+
<svg className="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
|
|
137
|
+
<path
|
|
138
|
+
fillRule="evenodd"
|
|
139
|
+
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"
|
|
140
|
+
clipRule="evenodd"
|
|
141
|
+
/>
|
|
142
|
+
</svg>
|
|
143
|
+
{toastMessage}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
)}
|
|
147
|
+
|
|
148
|
+
{/* Files list */}
|
|
149
|
+
{files?.length > 0 && !sending && (
|
|
150
|
+
<div className="px-4 py-3 border-b border-gray-200">
|
|
151
|
+
<FilesList files={files} />
|
|
152
|
+
</div>
|
|
153
|
+
)}
|
|
154
|
+
|
|
155
|
+
{/* Input container with textarea first, toolbar at bottom */}
|
|
156
|
+
<div className="px-4 py-3">
|
|
157
|
+
{/* Input field */}
|
|
158
|
+
<div className="relative mb-3">
|
|
159
|
+
<textarea
|
|
160
|
+
ref={textareaRef}
|
|
161
|
+
className={`w-full text-base bg-white border border-gray-300 rounded-2xl pl-4 pr-4 py-3 resize-none focus:border-gray-300 focus:outline-none placeholder-gray-500 transition-all duration-200 ${
|
|
162
|
+
isFocused ? 'border-gray-400 ring-2 ring-gray-300 focus:ring-gray-300' : 'border-gray-300'
|
|
163
|
+
} ${textareaClassName}`}
|
|
164
|
+
style={{
|
|
165
|
+
height: `${inputHeight}px`,
|
|
166
|
+
minHeight: '120px',
|
|
167
|
+
maxHeight: '200px',
|
|
168
|
+
...textareaStyles,
|
|
169
|
+
}}
|
|
170
|
+
placeholder={placeholder || 'Message'}
|
|
171
|
+
value={sending ? '' : message}
|
|
172
|
+
onKeyDown={handleKeyDown}
|
|
173
|
+
onChange={(e) => setMessage(e.target.value)}
|
|
174
|
+
onFocus={() => setIsFocused(true)}
|
|
175
|
+
onBlur={() => setIsFocused(false)}
|
|
176
|
+
disabled={sending}
|
|
177
|
+
rows={1}
|
|
178
|
+
/>
|
|
179
|
+
</div>
|
|
180
|
+
<div className={`${toolBarParentClassName}`}>
|
|
181
|
+
<ModelToolbar
|
|
182
|
+
modelConfig={modelConfig}
|
|
183
|
+
onModelConfigChange={onModelConfigChange}
|
|
184
|
+
sending={sending}
|
|
185
|
+
canSend={!!canSend}
|
|
186
|
+
onSend={handleSend}
|
|
187
|
+
onUploadImageChange={onUploadImageChange}
|
|
188
|
+
showProjectSettings={showModelToolbarProjectSettings}
|
|
189
|
+
isShowMeta={isShowMeta}
|
|
190
|
+
showModeSelector={showModeSelector}
|
|
191
|
+
showStopButton={showStopButton}
|
|
192
|
+
onStop={onStop}
|
|
193
|
+
/>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
);
|
|
198
|
+
};
|