@messenger-box/tailwind-ui-inbox 10.0.3-alpha.100
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 +104 -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 +21 -0
- package/lib/components/AIAgent/AIAgent.d.ts.map +1 -0
- package/lib/components/AIAgent/AIAgent.js +904 -0
- package/lib/components/AIAgent/AIAgent.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 +12 -0
- package/lib/components/InboxMessage/InputComponent.d.ts.map +1 -0
- package/lib/components/InboxMessage/InputComponent.js +359 -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 +23 -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/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/UploadImageButton.d.ts +7 -0
- package/lib/components/InboxMessage/UploadImageButton.d.ts.map +1 -0
- package/lib/components/InboxMessage/UploadImageButton.js +34 -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 +17 -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 +11 -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 +18 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js +1082 -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 +37 -0
- package/lib/components/ModelConfigPanel.d.ts.map +1 -0
- package/lib/components/ModelConfigPanel.js +317 -0
- package/lib/components/ModelConfigPanel.js.map +1 -0
- package/lib/components/filler-components/RightSiderBar.d.ts +24 -0
- package/lib/components/filler-components/RightSiderBar.d.ts.map +1 -0
- package/lib/components/filler-components/RightSiderBar.js +335 -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 +7 -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/hybrid-live-editor.js +68 -0
- package/lib/components/live-code-editor/hybrid-live-editor.js.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/live-code-editor/live-code-editor.js +207 -0
- package/lib/components/live-code-editor/live-code-editor.js.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 +137 -0
- package/lib/compute.js.map +1 -0
- package/lib/config/env-config.d.ts +13 -0
- package/lib/config/env-config.d.ts.map +1 -0
- package/lib/config/env-config.js +34 -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 +4 -0
- package/lib/container/AiLandingInput.d.ts.map +1 -0
- package/lib/container/AiLandingInput.js +101 -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 +955 -0
- package/lib/container/Inbox.js.map +1 -0
- package/lib/container/InboxAiMessagesLoader.d.ts +15 -0
- package/lib/container/InboxAiMessagesLoader.d.ts.map +1 -0
- package/lib/container/InboxAiMessagesLoader.js +30 -0
- package/lib/container/InboxAiMessagesLoader.js.map +1 -0
- package/lib/container/InboxContainer.d.ts +12 -0
- package/lib/container/InboxContainer.d.ts.map +1 -0
- package/lib/container/InboxContainer.js +31 -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 +15 -0
- package/lib/container/InboxWithAiLoader.d.ts.map +1 -0
- package/lib/container/InboxWithAiLoader.js +56 -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 +144 -0
- package/lib/container/ServiceInbox.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 +314 -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 +341 -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 +244 -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 +5 -0
- package/lib/enums/messenger-slot-fill-name-enum.d.ts.map +1 -0
- package/lib/enums/messenger-slot-fill-name-enum.js +5 -0
- package/lib/enums/messenger-slot-fill-name-enum.js.map +1 -0
- package/lib/hooks/index.d.ts +3 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/use-file-sync.d.ts +16 -0
- package/lib/hooks/use-file-sync.d.ts.map +1 -0
- package/lib/hooks/use-file-sync.js +63 -0
- package/lib/hooks/use-file-sync.js.map +1 -0
- package/lib/hooks/usePersistentModelConfig.d.ts +15 -0
- package/lib/hooks/usePersistentModelConfig.d.ts.map +1 -0
- package/lib/hooks/usePersistentModelConfig.js +46 -0
- package/lib/hooks/usePersistentModelConfig.js.map +1 -0
- package/lib/index.d.ts +10 -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 +98 -0
- package/lib/styles/responsive.css +76 -0
- package/lib/templates/InboxWithAi.d.ts +15 -0
- package/lib/templates/InboxWithAi.d.ts.map +1 -0
- package/lib/templates/InboxWithAi.js +440 -0
- package/lib/templates/InboxWithAi.js.map +1 -0
- package/lib/templates/InboxWithAi.tsx +533 -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/utils/utils.d.ts +2 -0
- package/lib/utils/utils.d.ts.map +1 -0
- package/lib/utils/utils.js +3 -0
- package/lib/utils/utils.js.map +1 -0
- package/package.json +62 -0
- package/rollup.config.mjs +35 -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 +1103 -0
- package/src/components/AIAgent/AIAgent.tsx.bk +1365 -0
- package/src/components/AIAgent/README.md +82 -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 +462 -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 +37 -0
- package/src/components/InboxMessage/ServiceConversationItem.tsx +234 -0
- package/src/components/InboxMessage/ServiceInboxItem.tsx +223 -0
- package/src/components/InboxMessage/SubscriptionHandler.tsx +55 -0
- package/src/components/InboxMessage/UploadImageButton.tsx +46 -0
- package/src/components/InboxMessage/UserModalContent.tsx +60 -0
- package/src/components/InboxMessage/index.ts +16 -0
- package/src/components/InboxMessage/message-widgets/CommonMessage.tsx +69 -0
- package/src/components/InboxMessage/message-widgets/ErrorFixCard.tsx +240 -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 +1295 -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 +3 -0
- package/src/components/ModelConfigPanel.tsx +345 -0
- package/src/components/filler-components/RightSiderBar.tsx +408 -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 +22 -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/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 +39 -0
- package/src/components/ui/button.tsx +32 -0
- package/src/compute.ts +134 -0
- package/src/config/env-config.ts +17 -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 +1819 -0
- package/src/container/AiInboxWithLoader.tsx +356 -0
- package/src/container/AiLandingInput.tsx +221 -0
- package/src/container/Inbox.tsx +1092 -0
- package/src/container/InboxAiMessagesLoader.tsx +44 -0
- package/src/container/InboxContainer.tsx +35 -0
- package/src/container/InboxTemplate1.tsx +1542 -0
- package/src/container/InboxTemplate1WithLoader.tsx +338 -0
- package/src/container/InboxTemplate2.tsx +1606 -0
- package/src/container/InboxWithAiLoader.tsx +76 -0
- package/src/container/InboxWithLoader.tsx +341 -0
- package/src/container/ServiceInbox.tsx +190 -0
- package/src/container/ThreadMessages.tsx +371 -0
- package/src/container/ThreadMessagesInbox.tsx +450 -0
- package/src/container/Threads.tsx +270 -0
- package/src/container/ThreadsInbox.tsx +354 -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 +4 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-file-sync.ts +91 -0
- package/src/hooks/usePersistentModelConfig.ts +63 -0
- package/src/index.ts +37 -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 +533 -0
- package/src/templates/index.ts +1 -0
- package/src/utils/utils.ts +3 -0
- package/tsconfig.json +14 -0
- package/webpack.config.js +92 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { config } from '../../config';
|
|
4
|
+
import { UploadImageButton } from './UploadImageButton';
|
|
5
|
+
import { FilesList } from '../inbox';
|
|
6
|
+
import { ModelConfigPanel, modelOptions, templateOptions, getAllModels } from '../ModelConfigPanel';
|
|
7
|
+
import { ModelConfig } from '../../hooks/usePersistentModelConfig';
|
|
8
|
+
|
|
9
|
+
type MessageInputProps = {
|
|
10
|
+
channelId?: string;
|
|
11
|
+
handleSend?: (message: string, files: File[]) => Promise<void>;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
modelConfig?: ModelConfig;
|
|
14
|
+
onModelConfigChange?: (config: ModelConfig) => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const InputComponent = ({
|
|
18
|
+
handleSend: handleSendProp,
|
|
19
|
+
placeholder,
|
|
20
|
+
modelConfig,
|
|
21
|
+
onModelConfigChange,
|
|
22
|
+
}: MessageInputProps) => {
|
|
23
|
+
const [message, setMessage] = useState('');
|
|
24
|
+
const [sending, setSending] = useState(false);
|
|
25
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
26
|
+
const [showToast, setShowToast] = useState(false);
|
|
27
|
+
const [toastMessage, setToastMessage] = useState('');
|
|
28
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
29
|
+
const [showModelDropdown, setShowModelDropdown] = useState(false);
|
|
30
|
+
const [showTemplateDropdown, setShowTemplateDropdown] = useState(false);
|
|
31
|
+
const [showSettingsModal, setShowSettingsModal] = useState(false);
|
|
32
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
33
|
+
const modelDropdownRef = useRef<HTMLDivElement>(null);
|
|
34
|
+
const templateDropdownRef = useRef<HTMLDivElement>(null);
|
|
35
|
+
const { t } = useTranslation('translations');
|
|
36
|
+
|
|
37
|
+
// Auto-focus the textarea when component mounts
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (textareaRef.current) {
|
|
40
|
+
textareaRef.current.focus();
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
// Handle click outside for dropdowns
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
47
|
+
if (modelDropdownRef.current && !modelDropdownRef.current.contains(event.target as Node)) {
|
|
48
|
+
setShowModelDropdown(false);
|
|
49
|
+
}
|
|
50
|
+
if (templateDropdownRef.current && !templateDropdownRef.current.contains(event.target as Node)) {
|
|
51
|
+
setShowTemplateDropdown(false);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
55
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
const showToastMessage = useCallback((message: string) => {
|
|
59
|
+
setToastMessage(message);
|
|
60
|
+
setShowToast(true);
|
|
61
|
+
setTimeout(() => setShowToast(false), 3000);
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
const handleSend = useCallback(() => {
|
|
65
|
+
if (!message.trim() && files.length === 0) return;
|
|
66
|
+
|
|
67
|
+
setSending(true);
|
|
68
|
+
handleSendProp(message, files)
|
|
69
|
+
.then(() => {
|
|
70
|
+
setMessage('');
|
|
71
|
+
setFiles([]);
|
|
72
|
+
// Auto-focus the textarea after sending a message
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
if (textareaRef.current) {
|
|
75
|
+
textareaRef.current.focus();
|
|
76
|
+
}
|
|
77
|
+
}, 100);
|
|
78
|
+
})
|
|
79
|
+
.finally(() => setSending(false));
|
|
80
|
+
}, [files, handleSendProp, message]);
|
|
81
|
+
|
|
82
|
+
const handleKeyDown = useCallback(
|
|
83
|
+
(e) => {
|
|
84
|
+
const keyCode = e.which || e.keyCode;
|
|
85
|
+
if (keyCode == 13 && !e.shiftKey) {
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
handleSend();
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
[handleSend],
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const inputHeight = useMemo(() => {
|
|
94
|
+
const lines = message.split('\n').length;
|
|
95
|
+
return Math.max(120, Math.min(200, 120 + (lines - 1) * 20));
|
|
96
|
+
}, [message]);
|
|
97
|
+
|
|
98
|
+
const onUploadImageChange = useCallback(
|
|
99
|
+
({ target }) => {
|
|
100
|
+
let fileList = [];
|
|
101
|
+
let index = 0;
|
|
102
|
+
if (files.length + target.files.length > config.FILES_PER_MESSAGE) {
|
|
103
|
+
showToastMessage(
|
|
104
|
+
t('tailwind_ui_inbox.you_can_not_upload_more_than_files', {
|
|
105
|
+
files_per_message: config.FILES_PER_MESSAGE,
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
while (target.files[index]) {
|
|
111
|
+
fileList.push(target.files[index]);
|
|
112
|
+
index += 1;
|
|
113
|
+
}
|
|
114
|
+
setFiles((oldFiles) => [...oldFiles, ...fileList]);
|
|
115
|
+
},
|
|
116
|
+
[setFiles, files, showToastMessage, t],
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const canSend = message.trim() || files.length > 0;
|
|
120
|
+
const hasContent = message.trim().length > 0;
|
|
121
|
+
|
|
122
|
+
// Get models and templates from ModelConfigPanel
|
|
123
|
+
const allModelOptions = useMemo(() => {
|
|
124
|
+
return getAllModels();
|
|
125
|
+
}, []);
|
|
126
|
+
|
|
127
|
+
const templateOptionsList = useMemo(() => {
|
|
128
|
+
return templateOptions.map((t) => ({ value: t.value, label: t.label, icon: t.icon }));
|
|
129
|
+
}, []);
|
|
130
|
+
|
|
131
|
+
const handleModelSelect = useCallback(
|
|
132
|
+
(modelValue: string) => {
|
|
133
|
+
if (onModelConfigChange && modelConfig) {
|
|
134
|
+
onModelConfigChange({ ...modelConfig, model: modelValue });
|
|
135
|
+
}
|
|
136
|
+
setShowModelDropdown(false);
|
|
137
|
+
},
|
|
138
|
+
[modelConfig, onModelConfigChange],
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const handleTemplateSelect = useCallback(
|
|
142
|
+
(templateValue: string) => {
|
|
143
|
+
if (onModelConfigChange && modelConfig) {
|
|
144
|
+
onModelConfigChange({ ...modelConfig, template: templateValue as any });
|
|
145
|
+
}
|
|
146
|
+
setShowTemplateDropdown(false);
|
|
147
|
+
},
|
|
148
|
+
[modelConfig, onModelConfigChange],
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
// <div className="bg-gray-50 border-t border-gray-200">
|
|
153
|
+
<div className="bg-gray-50 border border-gray-200">
|
|
154
|
+
{/* Toast notification */}
|
|
155
|
+
{showToast && (
|
|
156
|
+
<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">
|
|
157
|
+
<div className="flex items-center">
|
|
158
|
+
<svg className="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
|
|
159
|
+
<path
|
|
160
|
+
fillRule="evenodd"
|
|
161
|
+
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"
|
|
162
|
+
clipRule="evenodd"
|
|
163
|
+
/>
|
|
164
|
+
</svg>
|
|
165
|
+
{toastMessage}
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
)}
|
|
169
|
+
|
|
170
|
+
{/* Files list */}
|
|
171
|
+
{files?.length > 0 && !sending && (
|
|
172
|
+
<div className="px-4 py-3 border-b border-gray-200">
|
|
173
|
+
<FilesList files={files} />
|
|
174
|
+
</div>
|
|
175
|
+
)}
|
|
176
|
+
|
|
177
|
+
{/* Input container with textarea first, toolbar at bottom */}
|
|
178
|
+
<div className="px-4 py-3">
|
|
179
|
+
{/* Input field */}
|
|
180
|
+
<div className="relative mb-3">
|
|
181
|
+
<textarea
|
|
182
|
+
ref={textareaRef}
|
|
183
|
+
className={`w-full text-base bg-white border-2 rounded-2xl pl-4 pr-4 py-3 resize-none focus:outline-none placeholder-gray-500 transition-all duration-200 ${
|
|
184
|
+
isFocused ? 'border-blue-500 ring-2 ring-blue-200' : 'border-gray-300'
|
|
185
|
+
}`}
|
|
186
|
+
style={{
|
|
187
|
+
height: `${inputHeight}px`,
|
|
188
|
+
minHeight: '120px',
|
|
189
|
+
maxHeight: '200px',
|
|
190
|
+
}}
|
|
191
|
+
placeholder={placeholder || 'Message'}
|
|
192
|
+
value={sending ? '' : message}
|
|
193
|
+
onKeyDown={handleKeyDown}
|
|
194
|
+
onChange={(e) => setMessage(e.target.value)}
|
|
195
|
+
onFocus={() => setIsFocused(true)}
|
|
196
|
+
onBlur={() => setIsFocused(false)}
|
|
197
|
+
disabled={sending}
|
|
198
|
+
rows={1}
|
|
199
|
+
/>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
{/* Simplified Toolbar - Only Template, Model, Upload, Send, and Settings */}
|
|
203
|
+
<div className="flex items-center gap-2">
|
|
204
|
+
<UploadImageButton onChange={onUploadImageChange}>
|
|
205
|
+
<div className="flex items-center justify-center w-8 h-8 rounded-lg border border-gray-300 bg-white hover:bg-gray-50 transition-colors">
|
|
206
|
+
<svg
|
|
207
|
+
className="w-4 h-4 text-gray-600"
|
|
208
|
+
fill="none"
|
|
209
|
+
stroke="currentColor"
|
|
210
|
+
viewBox="0 0 24 24"
|
|
211
|
+
>
|
|
212
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" />
|
|
213
|
+
</svg>
|
|
214
|
+
</div>
|
|
215
|
+
</UploadImageButton>
|
|
216
|
+
{/* 1. Template Selection Dropdown */}
|
|
217
|
+
<div className="relative" ref={templateDropdownRef}>
|
|
218
|
+
<button
|
|
219
|
+
onClick={() => setShowTemplateDropdown(!showTemplateDropdown)}
|
|
220
|
+
className="flex items-center gap-2 px-3 py-1.5 text-sm rounded-lg border border-gray-300 bg-white hover:bg-gray-50 transition-colors min-w-[120px]"
|
|
221
|
+
>
|
|
222
|
+
{(() => {
|
|
223
|
+
if (modelConfig && modelConfig.template) {
|
|
224
|
+
const currentTemplate = templateOptionsList.find(
|
|
225
|
+
(option) => option.value === modelConfig.template,
|
|
226
|
+
);
|
|
227
|
+
return currentTemplate ? (
|
|
228
|
+
<>
|
|
229
|
+
<span className="text-lg">{currentTemplate.icon}</span>
|
|
230
|
+
<span className="text-gray-700">{currentTemplate.label}</span>
|
|
231
|
+
</>
|
|
232
|
+
) : (
|
|
233
|
+
<>
|
|
234
|
+
<span className="text-lg">📝</span>
|
|
235
|
+
<span className="text-gray-500">Template</span>
|
|
236
|
+
</>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
return (
|
|
240
|
+
<>
|
|
241
|
+
<span className="text-lg">📝</span>
|
|
242
|
+
<span className="text-gray-500">Template</span>
|
|
243
|
+
</>
|
|
244
|
+
);
|
|
245
|
+
})()}
|
|
246
|
+
<svg
|
|
247
|
+
className="w-4 h-4 text-gray-500 ml-auto"
|
|
248
|
+
fill="none"
|
|
249
|
+
stroke="currentColor"
|
|
250
|
+
viewBox="0 0 24 24"
|
|
251
|
+
>
|
|
252
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 9l-7 7-7-7" />
|
|
253
|
+
</svg>
|
|
254
|
+
</button>
|
|
255
|
+
|
|
256
|
+
{showTemplateDropdown && (
|
|
257
|
+
<div className="absolute bottom-full left-0 mb-2 w-48 bg-white border border-gray-200 rounded-lg shadow-lg z-50">
|
|
258
|
+
<div className="py-1">
|
|
259
|
+
{templateOptionsList.map((option) => (
|
|
260
|
+
<button
|
|
261
|
+
key={option.value}
|
|
262
|
+
onClick={() => handleTemplateSelect(option.value)}
|
|
263
|
+
className={`w-full px-3 py-2 text-left hover:bg-gray-50 transition-colors flex items-center gap-2 ${
|
|
264
|
+
modelConfig?.template === option.value ? 'bg-blue-50' : ''
|
|
265
|
+
}`}
|
|
266
|
+
>
|
|
267
|
+
<span className="text-lg">{option.icon}</span>
|
|
268
|
+
<span className="font-medium text-gray-900">{option.label}</span>
|
|
269
|
+
</button>
|
|
270
|
+
))}
|
|
271
|
+
</div>
|
|
272
|
+
</div>
|
|
273
|
+
)}
|
|
274
|
+
</div>
|
|
275
|
+
|
|
276
|
+
{/* 2. Model Selection Dropdown */}
|
|
277
|
+
<div className="relative" ref={modelDropdownRef}>
|
|
278
|
+
<button
|
|
279
|
+
onClick={() => setShowModelDropdown(!showModelDropdown)}
|
|
280
|
+
className="flex items-center gap-2 px-3 py-1.5 text-sm rounded-lg border border-gray-300 bg-white hover:bg-gray-50 transition-colors min-w-[140px]"
|
|
281
|
+
>
|
|
282
|
+
{(() => {
|
|
283
|
+
if (modelConfig && modelConfig.model) {
|
|
284
|
+
const currentModel = allModelOptions.find(
|
|
285
|
+
(option) => option.value === modelConfig.model,
|
|
286
|
+
);
|
|
287
|
+
return currentModel ? (
|
|
288
|
+
<span className="text-gray-700">{currentModel.label}</span>
|
|
289
|
+
) : (
|
|
290
|
+
<span className="text-gray-500">Model</span>
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
return <span className="text-gray-500">Model</span>;
|
|
294
|
+
})()}
|
|
295
|
+
<svg
|
|
296
|
+
className="w-4 h-4 text-gray-500 ml-auto"
|
|
297
|
+
fill="none"
|
|
298
|
+
stroke="currentColor"
|
|
299
|
+
viewBox="0 0 24 24"
|
|
300
|
+
>
|
|
301
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 9l-7 7-7-7" />
|
|
302
|
+
</svg>
|
|
303
|
+
</button>
|
|
304
|
+
|
|
305
|
+
{showModelDropdown && (
|
|
306
|
+
<div className="absolute bottom-full left-0 mb-2 w-64 bg-white border border-gray-200 rounded-lg shadow-lg z-50 max-h-60 overflow-y-auto">
|
|
307
|
+
<div className="py-1">
|
|
308
|
+
{allModelOptions.map((option) => (
|
|
309
|
+
<button
|
|
310
|
+
key={option.value}
|
|
311
|
+
onClick={() => handleModelSelect(option.value)}
|
|
312
|
+
className={`w-full px-3 py-2 text-left hover:bg-gray-50 transition-colors ${
|
|
313
|
+
modelConfig?.model === option.value ? 'bg-blue-50' : ''
|
|
314
|
+
}`}
|
|
315
|
+
>
|
|
316
|
+
<div className="font-medium text-gray-900">{option.label}</div>
|
|
317
|
+
</button>
|
|
318
|
+
))}
|
|
319
|
+
</div>
|
|
320
|
+
</div>
|
|
321
|
+
)}
|
|
322
|
+
</div>
|
|
323
|
+
|
|
324
|
+
<div className="flex-1"></div>
|
|
325
|
+
|
|
326
|
+
{/* 3. Upload Button */}
|
|
327
|
+
|
|
328
|
+
{/* 4. Project Settings Button */}
|
|
329
|
+
<button
|
|
330
|
+
onClick={() => setShowSettingsModal(true)}
|
|
331
|
+
className="flex items-center justify-center w-8 h-8 rounded-lg border border-gray-300 bg-white hover:bg-gray-50 transition-colors"
|
|
332
|
+
>
|
|
333
|
+
<svg className="w-4 h-4 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
334
|
+
<path
|
|
335
|
+
strokeLinecap="round"
|
|
336
|
+
strokeLinejoin="round"
|
|
337
|
+
strokeWidth={2}
|
|
338
|
+
d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
|
|
339
|
+
/>
|
|
340
|
+
<path
|
|
341
|
+
strokeLinecap="round"
|
|
342
|
+
strokeLinejoin="round"
|
|
343
|
+
strokeWidth={2}
|
|
344
|
+
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
|
345
|
+
/>
|
|
346
|
+
</svg>
|
|
347
|
+
</button>
|
|
348
|
+
|
|
349
|
+
{/* 5. Send Button */}
|
|
350
|
+
<button
|
|
351
|
+
className={`flex items-center justify-center w-8 h-8 rounded-lg border transition-colors ${
|
|
352
|
+
canSend && !sending
|
|
353
|
+
? 'border-blue-500 bg-blue-500 hover:bg-blue-600 text-white'
|
|
354
|
+
: 'border-gray-300 bg-gray-100 text-gray-400 cursor-not-allowed'
|
|
355
|
+
}`}
|
|
356
|
+
onClick={handleSend}
|
|
357
|
+
disabled={!canSend || sending}
|
|
358
|
+
type="button"
|
|
359
|
+
>
|
|
360
|
+
{sending ? (
|
|
361
|
+
<svg className="w-4 h-4 animate-spin" fill="none" viewBox="0 0 24 24">
|
|
362
|
+
<circle
|
|
363
|
+
className="opacity-25"
|
|
364
|
+
cx="12"
|
|
365
|
+
cy="12"
|
|
366
|
+
r="10"
|
|
367
|
+
stroke="currentColor"
|
|
368
|
+
strokeWidth="4"
|
|
369
|
+
></circle>
|
|
370
|
+
<path
|
|
371
|
+
className="opacity-75"
|
|
372
|
+
fill="currentColor"
|
|
373
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
374
|
+
></path>
|
|
375
|
+
</svg>
|
|
376
|
+
) : (
|
|
377
|
+
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
378
|
+
<path
|
|
379
|
+
strokeLinecap="round"
|
|
380
|
+
strokeLinejoin="round"
|
|
381
|
+
strokeWidth={2}
|
|
382
|
+
d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"
|
|
383
|
+
/>
|
|
384
|
+
</svg>
|
|
385
|
+
)}
|
|
386
|
+
</button>
|
|
387
|
+
</div>
|
|
388
|
+
</div>
|
|
389
|
+
|
|
390
|
+
{/* Simplified Settings Modal - Only API Key and Model */}
|
|
391
|
+
{showSettingsModal && (
|
|
392
|
+
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
|
|
393
|
+
<div className="bg-white rounded-lg shadow-xl max-w-md w-full mx-4">
|
|
394
|
+
<div className="p-6 mb-4">
|
|
395
|
+
<div className="flex items-center justify-between mb-4">
|
|
396
|
+
<h3 className="text-lg font-semibold text-gray-900">Project Settings</h3>
|
|
397
|
+
<button
|
|
398
|
+
onClick={() => setShowSettingsModal(false)}
|
|
399
|
+
className="text-gray-400 hover:text-gray-600 transition-colors"
|
|
400
|
+
>
|
|
401
|
+
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
402
|
+
<path
|
|
403
|
+
strokeLinecap="round"
|
|
404
|
+
strokeLinejoin="round"
|
|
405
|
+
strokeWidth={2}
|
|
406
|
+
d="M6 18L18 6M6 6l12 12"
|
|
407
|
+
/>
|
|
408
|
+
</svg>
|
|
409
|
+
</button>
|
|
410
|
+
</div>
|
|
411
|
+
|
|
412
|
+
{modelConfig && onModelConfigChange && (
|
|
413
|
+
<div className="space-y-4">
|
|
414
|
+
{/* API Key Input */}
|
|
415
|
+
<div>
|
|
416
|
+
<label className="block text-sm font-medium text-gray-700 mb-2">API Key</label>
|
|
417
|
+
<input
|
|
418
|
+
type="password"
|
|
419
|
+
value={modelConfig.apiKey}
|
|
420
|
+
onChange={(e) =>
|
|
421
|
+
onModelConfigChange({ ...modelConfig, apiKey: e.target.value })
|
|
422
|
+
}
|
|
423
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
|
424
|
+
placeholder="Enter your API key"
|
|
425
|
+
/>
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
{/* Model Selection */}
|
|
429
|
+
<div>
|
|
430
|
+
<label className="block text-sm font-medium text-gray-700 mb-2">Model</label>
|
|
431
|
+
<select
|
|
432
|
+
value={modelConfig.model}
|
|
433
|
+
onChange={(e) =>
|
|
434
|
+
onModelConfigChange({ ...modelConfig, model: e.target.value })
|
|
435
|
+
}
|
|
436
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
|
437
|
+
>
|
|
438
|
+
{allModelOptions.map((option) => (
|
|
439
|
+
<option key={option.value} value={option.value}>
|
|
440
|
+
{option.label}
|
|
441
|
+
</option>
|
|
442
|
+
))}
|
|
443
|
+
</select>
|
|
444
|
+
</div>
|
|
445
|
+
</div>
|
|
446
|
+
)}
|
|
447
|
+
|
|
448
|
+
{/* <div className="mt-6 flex justify-end">
|
|
449
|
+
<button
|
|
450
|
+
onClick={() => setShowSettingsModal(false)}
|
|
451
|
+
className="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors"
|
|
452
|
+
>
|
|
453
|
+
Save Settings
|
|
454
|
+
</button>
|
|
455
|
+
</div> */}
|
|
456
|
+
</div>
|
|
457
|
+
</div>
|
|
458
|
+
</div>
|
|
459
|
+
)}
|
|
460
|
+
</div>
|
|
461
|
+
);
|
|
462
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { GoSettings } from '@react-icons/all-files/go/GoSettings.js';
|
|
2
|
+
import { GoSearch } from '@react-icons/all-files/go/GoSearch.js';
|
|
3
|
+
import React, { useState, useEffect, useMemo } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { orderBy, uniqBy } from 'lodash-es';
|
|
6
|
+
import { ConversationItem } from './ConversationItem';
|
|
7
|
+
import { ServiceConversationItem } from './ServiceConversationItem';
|
|
8
|
+
import { RoomType } from 'common';
|
|
9
|
+
|
|
10
|
+
type LeftSidebarProps = {
|
|
11
|
+
userChannels: any;
|
|
12
|
+
userChannelsLoading: boolean;
|
|
13
|
+
currentUser: any;
|
|
14
|
+
users?: any[];
|
|
15
|
+
handleSelectChannel: (channel: any, postId?: any) => void;
|
|
16
|
+
clearMessages?: () => void;
|
|
17
|
+
selectedChannelId?: any;
|
|
18
|
+
channelToTop: number;
|
|
19
|
+
getChannelsRefetch: any;
|
|
20
|
+
supportServices?: any;
|
|
21
|
+
role?: any;
|
|
22
|
+
messagesQuery?: any;
|
|
23
|
+
windowHeight?: number;
|
|
24
|
+
windowWidth?: number;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const LeftSidebar = React.memo((props: LeftSidebarProps) => {
|
|
28
|
+
const {
|
|
29
|
+
currentUser,
|
|
30
|
+
handleSelectChannel,
|
|
31
|
+
users,
|
|
32
|
+
userChannels,
|
|
33
|
+
userChannelsLoading,
|
|
34
|
+
selectedChannelId,
|
|
35
|
+
supportServices,
|
|
36
|
+
role,
|
|
37
|
+
messagesQuery,
|
|
38
|
+
windowHeight = 768,
|
|
39
|
+
windowWidth = 1024,
|
|
40
|
+
} = props;
|
|
41
|
+
const [keyword, setKeyword] = useState('');
|
|
42
|
+
const { t } = useTranslation('translations');
|
|
43
|
+
|
|
44
|
+
// Memoize the sorted channels to prevent unnecessary re-renders
|
|
45
|
+
const sortedChannels = useMemo(() => {
|
|
46
|
+
if (!userChannels?.length) return [];
|
|
47
|
+
return orderBy(
|
|
48
|
+
uniqBy([...userChannels], ({ id }) => id),
|
|
49
|
+
['updatedAt'],
|
|
50
|
+
['desc'],
|
|
51
|
+
);
|
|
52
|
+
}, [userChannels]);
|
|
53
|
+
|
|
54
|
+
if (userChannelsLoading) {
|
|
55
|
+
return (
|
|
56
|
+
<div className="space-y-4">
|
|
57
|
+
{Array(10)
|
|
58
|
+
.fill(1)
|
|
59
|
+
.map((x, y) => (
|
|
60
|
+
<div key={y} className="h-10 bg-gray-200 rounded animate-pulse" />
|
|
61
|
+
))}
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return (
|
|
66
|
+
<div className="w-full flex flex-col bg-white" style={{ height: `${windowHeight}px`, maxHeight: '100vh' }}>
|
|
67
|
+
<div className="flex-shrink-0 p-3 sm:p-4 border-b border-gray-200">
|
|
68
|
+
<SearchInput keyword={keyword} setKeyword={setKeyword} />
|
|
69
|
+
</div>
|
|
70
|
+
<div className="flex-1 min-h-0 overflow-hidden">
|
|
71
|
+
<div
|
|
72
|
+
className="overflow-y-auto p-2 sm:p-4 space-y-1"
|
|
73
|
+
style={{
|
|
74
|
+
height: `${windowHeight - 80}px`, // Subtract header height
|
|
75
|
+
minHeight: 0,
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<>
|
|
79
|
+
{supportServices ? supportServices : <></>}
|
|
80
|
+
|
|
81
|
+
{sortedChannels.length > 0 ? (
|
|
82
|
+
sortedChannels.map((channel, index) =>
|
|
83
|
+
channel?.type === RoomType.Service ? (
|
|
84
|
+
<ServiceConversationItem
|
|
85
|
+
key={`service_channel_${channel.id}`}
|
|
86
|
+
filter={keyword}
|
|
87
|
+
channel={channel}
|
|
88
|
+
currentUser={currentUser}
|
|
89
|
+
handleSelectChannel={handleSelectChannel}
|
|
90
|
+
users={users}
|
|
91
|
+
selectedChannelId={selectedChannelId}
|
|
92
|
+
showBorder={index != sortedChannels.length - 1}
|
|
93
|
+
role={role || null}
|
|
94
|
+
/>
|
|
95
|
+
) : (
|
|
96
|
+
<ConversationItem
|
|
97
|
+
key={`conv_channel_${channel.id}`}
|
|
98
|
+
filter={keyword}
|
|
99
|
+
channel={channel}
|
|
100
|
+
currentUser={currentUser}
|
|
101
|
+
handleSelectChannel={handleSelectChannel}
|
|
102
|
+
users={users}
|
|
103
|
+
selectedChannelId={selectedChannelId}
|
|
104
|
+
showBorder={index != sortedChannels.length - 1}
|
|
105
|
+
messagesQuery={messagesQuery}
|
|
106
|
+
/>
|
|
107
|
+
),
|
|
108
|
+
)
|
|
109
|
+
) : (
|
|
110
|
+
<div className="text-center py-8 text-gray-500">
|
|
111
|
+
<div className="text-3xl mb-2">💬</div>
|
|
112
|
+
<p>No conversations yet</p>
|
|
113
|
+
</div>
|
|
114
|
+
)}
|
|
115
|
+
</>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const SearchInput = ({ keyword, setKeyword }: any) => {
|
|
123
|
+
const { t } = useTranslation('translations');
|
|
124
|
+
return (
|
|
125
|
+
<div className="w-full">
|
|
126
|
+
<div className="relative">
|
|
127
|
+
<input
|
|
128
|
+
type="text"
|
|
129
|
+
placeholder={t('tailwind_ui_inbox.search_inbox') || 'Search Inbox'}
|
|
130
|
+
className="w-full pl-10 sm:pl-12 pr-4 py-2 sm:py-2.5 bg-gray-50 border border-gray-200 rounded-lg text-gray-900 placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-blue-400 focus:border-blue-400 focus:bg-white transition-all duration-200 text-sm"
|
|
131
|
+
value={keyword}
|
|
132
|
+
onChange={(e) => setKeyword(e.target.value)}
|
|
133
|
+
/>
|
|
134
|
+
<div className="absolute left-3 sm:left-4 top-1/2 transform -translate-y-1/2">
|
|
135
|
+
<GoSearch className="w-4 h-4 text-gray-400" />
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
};
|