@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,223 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { useLocation } from '@remix-run/react';
|
|
3
|
+
import {
|
|
4
|
+
useThreadMessagesQuery,
|
|
5
|
+
useOnThreadChatMessageAddedSubscription,
|
|
6
|
+
useOnThreadCreatedUpdatedSubscription,
|
|
7
|
+
OnThreadCreatedUpdatedDocument as THREAD_CHAT_ADDED,
|
|
8
|
+
OnThreadChatMessageAddedDocument as CHAT_MESSAGE_ADDED,
|
|
9
|
+
} from 'common/graphql';
|
|
10
|
+
import { format, isToday, isYesterday } from 'date-fns';
|
|
11
|
+
|
|
12
|
+
const createdAtText = (value) => {
|
|
13
|
+
if (!value) return '';
|
|
14
|
+
let date = new Date(value);
|
|
15
|
+
if (isToday(date)) return 'Today';
|
|
16
|
+
if (isYesterday(date)) return 'Yesterday';
|
|
17
|
+
return format(new Date(value), 'MMM dd, yyyy');
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const ServiceInboxItemComponent = ({
|
|
21
|
+
showBorder,
|
|
22
|
+
currentUser,
|
|
23
|
+
filter,
|
|
24
|
+
channel,
|
|
25
|
+
handleSelectChannel,
|
|
26
|
+
users,
|
|
27
|
+
selectedChannelId,
|
|
28
|
+
role,
|
|
29
|
+
}) => {
|
|
30
|
+
const [parentId, setParentId] = React.useState<any>(null);
|
|
31
|
+
const [messages, setMessages] = React.useState([]);
|
|
32
|
+
const [servicePostParentId, setServicePostParentId] = React.useState(null);
|
|
33
|
+
const { pathname } = useLocation();
|
|
34
|
+
const {
|
|
35
|
+
data: threadMessages,
|
|
36
|
+
loading: threadMessageLoading,
|
|
37
|
+
fetchMore: fetchMoreMessages,
|
|
38
|
+
refetch: refetchThreadMessages,
|
|
39
|
+
subscribeToMore,
|
|
40
|
+
} = useThreadMessagesQuery({
|
|
41
|
+
variables: {
|
|
42
|
+
channelId: channel?.id?.toString(),
|
|
43
|
+
role,
|
|
44
|
+
limit: 10,
|
|
45
|
+
},
|
|
46
|
+
fetchPolicy: 'cache-and-network',
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
if (channel) refetchThreadMessages({ channelId: channel?.id?.toString(), role, limit: 10 });
|
|
51
|
+
}, [channel, pathname]);
|
|
52
|
+
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
if (threadMessages?.threadMessages?.data?.length) {
|
|
55
|
+
const { data }: any = threadMessages.threadMessages;
|
|
56
|
+
const replies =
|
|
57
|
+
data
|
|
58
|
+
?.map((t: any) => t?.replies)
|
|
59
|
+
?.flat(1)
|
|
60
|
+
?.filter((p: any) => p?.message !== '') ?? [];
|
|
61
|
+
const post =
|
|
62
|
+
data?.find((t: any) => {
|
|
63
|
+
return t?.post?.message !== '';
|
|
64
|
+
}) ??
|
|
65
|
+
data?.find((t: any) => {
|
|
66
|
+
return t?.post;
|
|
67
|
+
}) ??
|
|
68
|
+
null;
|
|
69
|
+
|
|
70
|
+
if (replies?.length) {
|
|
71
|
+
setMessages((pre: any) => [...pre, ...replies]);
|
|
72
|
+
} else if (post) {
|
|
73
|
+
setMessages((pre: any) => [...pre, ...[post]]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}, [threadMessages]);
|
|
77
|
+
|
|
78
|
+
const lastMessage = useMemo(() => {
|
|
79
|
+
if (!messages?.length) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let filteredLastMessage =
|
|
84
|
+
messages && messages?.length
|
|
85
|
+
? messages?.reduce((a, b) => {
|
|
86
|
+
return new Date(a?.updatedAt) > new Date(b?.updatedAt) ? a : b;
|
|
87
|
+
}, []) ?? null
|
|
88
|
+
: null;
|
|
89
|
+
return filteredLastMessage;
|
|
90
|
+
}, [messages]);
|
|
91
|
+
|
|
92
|
+
React.useEffect(() => {
|
|
93
|
+
if (lastMessage) {
|
|
94
|
+
const sParentId = lastMessage?.parentId ? lastMessage?.parentId : lastMessage?.id;
|
|
95
|
+
setServicePostParentId(sParentId);
|
|
96
|
+
}
|
|
97
|
+
}, [lastMessage]);
|
|
98
|
+
|
|
99
|
+
const creatorAndMembersId = React.useMemo(() => {
|
|
100
|
+
if (!channel?.members) return null;
|
|
101
|
+
const membersIds: any =
|
|
102
|
+
channel?.members?.filter((m: any) => m?.user?.id !== currentUser?.id)?.map((mu: any) => mu?.user?.id) ?? [];
|
|
103
|
+
const creatorId: any = channel?.creator?.id;
|
|
104
|
+
const mergedIds: any = [].concat(membersIds, creatorId) ?? [];
|
|
105
|
+
return mergedIds?.filter((m: any, pos: any) => mergedIds?.indexOf(m) === pos) ?? [];
|
|
106
|
+
}, [channel]);
|
|
107
|
+
|
|
108
|
+
const postParentId = React.useMemo(() => {
|
|
109
|
+
if (!creatorAndMembersId?.length) return null;
|
|
110
|
+
|
|
111
|
+
return creatorAndMembersId?.length && creatorAndMembersId?.includes(currentUser?.id)
|
|
112
|
+
? 1
|
|
113
|
+
: lastMessage?.parentId
|
|
114
|
+
? lastMessage?.parentId
|
|
115
|
+
: lastMessage?.id ?? 0;
|
|
116
|
+
}, [creatorAndMembersId, lastMessage]);
|
|
117
|
+
|
|
118
|
+
React.useEffect(() => {
|
|
119
|
+
if (postParentId) {
|
|
120
|
+
setParentId(postParentId);
|
|
121
|
+
}
|
|
122
|
+
}, [postParentId]);
|
|
123
|
+
|
|
124
|
+
const channelType = useMemo(() => {
|
|
125
|
+
return channel?.type;
|
|
126
|
+
}, [channel]);
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<div
|
|
130
|
+
key={`services_channel_${channel.id}`}
|
|
131
|
+
className={`
|
|
132
|
+
cursor-pointer flex items-center p-3
|
|
133
|
+
border-b border-solid
|
|
134
|
+
${showBorder ? 'border-gray-300' : 'border-transparent'}
|
|
135
|
+
${channel.id == selectedChannelId ? 'bg-gray-300 dark:bg-gray-500' : ''}
|
|
136
|
+
hover:bg-gray-100 dark:hover:bg-gray-600 transition-colors
|
|
137
|
+
`}
|
|
138
|
+
onClick={() => handleSelectChannel(channel.id, postParentId)}
|
|
139
|
+
>
|
|
140
|
+
<img
|
|
141
|
+
className="w-10 h-10 rounded-full bg-gray-400"
|
|
142
|
+
src={channel?.creator?.picture || '/default-avatar.svg'}
|
|
143
|
+
alt="Avatar"
|
|
144
|
+
onError={(e) => {
|
|
145
|
+
if (e.currentTarget.src.includes('default-avatar.svg')) {
|
|
146
|
+
e.currentTarget.src =
|
|
147
|
+
'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSIyMCIgY3k9IjIwIiByPSIyMCIgZmlsbD0iI0U1RTdFQiIvPgogIDxjaXJjbGUgY3g9IjIwIiBjeT0iMTYiIHI9IjYiIGZpbGw9IiM5Q0EzQUYiLz4KICA8cGF0aCBkPSJNOCAzMmMwLTYuNjI3IDUuMzczLTEyIDEyLTEyczEyIDUuMzczIDEyIDEyIiBmaWxsPSIjOUNBM0FGIi8+Cjwvc3ZnPgo=';
|
|
148
|
+
} else {
|
|
149
|
+
e.currentTarget.src = '/default-avatar.svg';
|
|
150
|
+
}
|
|
151
|
+
}}
|
|
152
|
+
/>
|
|
153
|
+
|
|
154
|
+
<div className="ml-2 flex-grow min-w-10 max-w-96">
|
|
155
|
+
{threadMessageLoading && (
|
|
156
|
+
<div className="animate-pulse">
|
|
157
|
+
<div className="h-4 bg-gray-300 rounded mb-2"></div>
|
|
158
|
+
<div className="h-3 bg-gray-300 rounded w-3/4 mb-2"></div>
|
|
159
|
+
<div className="h-3 bg-gray-300 rounded w-1/2"></div>
|
|
160
|
+
</div>
|
|
161
|
+
)}
|
|
162
|
+
{!threadMessageLoading && (
|
|
163
|
+
<ServiceLastMessageComponent
|
|
164
|
+
channel={channel}
|
|
165
|
+
channelType={channelType}
|
|
166
|
+
lastMessage={lastMessage}
|
|
167
|
+
subscribeToNewMessages={() =>
|
|
168
|
+
subscribeToMore({
|
|
169
|
+
document: THREAD_CHAT_ADDED,
|
|
170
|
+
variables: {
|
|
171
|
+
channelId: channel?.id?.toString(),
|
|
172
|
+
postParentId: postParentId && postParentId == 1 ? null : servicePostParentId,
|
|
173
|
+
},
|
|
174
|
+
updateQuery: (prev, { subscriptionData }: any) => {
|
|
175
|
+
if (!subscriptionData.data) return prev;
|
|
176
|
+
|
|
177
|
+
const newPostThreadData: any = subscriptionData?.data?.threadCreatedUpdated?.data;
|
|
178
|
+
const newMessage: any = subscriptionData?.data?.threadCreatedUpdated?.lastMessage;
|
|
179
|
+
const data = prev?.threadMessages?.data?.map((t: any) =>
|
|
180
|
+
t.id === newPostThreadData?.id
|
|
181
|
+
? {
|
|
182
|
+
...t,
|
|
183
|
+
replies: [...t?.replies, newMessage],
|
|
184
|
+
replyCount: newPostThreadData?.replyCount,
|
|
185
|
+
lastReplyAt: newPostThreadData?.lastReplyAt,
|
|
186
|
+
updatedAt: newPostThreadData?.updatedAt,
|
|
187
|
+
}
|
|
188
|
+
: t,
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
return Object.assign({}, prev, {
|
|
192
|
+
threadMessages: {
|
|
193
|
+
...prev?.threadMessages,
|
|
194
|
+
data: data,
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
/>
|
|
201
|
+
)}
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export const ServiceInboxItem = React.memo(ServiceInboxItemComponent);
|
|
208
|
+
|
|
209
|
+
const ServiceLastMessageComponent = ({ subscribeToNewMessages, channel, channelType, lastMessage }) => {
|
|
210
|
+
React.useEffect(() => subscribeToNewMessages(), []);
|
|
211
|
+
return (
|
|
212
|
+
<div className="flex flex-col w-full">
|
|
213
|
+
<div className="w-full flex justify-between items-center">
|
|
214
|
+
<span className="text-xs text-green-500 truncate">{channelType}</span>
|
|
215
|
+
<span className="text-xs text-gray-500">
|
|
216
|
+
{lastMessage ? createdAtText(lastMessage?.createdAt) : ''}
|
|
217
|
+
</span>
|
|
218
|
+
</div>
|
|
219
|
+
<h3 className="text-sm text-gray-600 dark:text-gray-300 font-bold mt-1">{channel?.title}</h3>
|
|
220
|
+
<p className="text-sm text-gray-600 dark:text-gray-400 truncate w-4/5 mt-1">{lastMessage?.message}</p>
|
|
221
|
+
</div>
|
|
222
|
+
);
|
|
223
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared SubscriptionHandler for Apollo subscribeToMore
|
|
5
|
+
*
|
|
6
|
+
* @param subscribeToMore - Apollo subscribeToMore function
|
|
7
|
+
* @param document - GraphQL subscription document
|
|
8
|
+
* @param variables - Variables for the subscription
|
|
9
|
+
* @param updateQuery - Apollo updateQuery function
|
|
10
|
+
* @param onError - Optional error handler
|
|
11
|
+
* @param enabled - If false, disables the subscription
|
|
12
|
+
*/
|
|
13
|
+
export function SubscriptionHandler({
|
|
14
|
+
subscribeToMore,
|
|
15
|
+
document,
|
|
16
|
+
variables,
|
|
17
|
+
updateQuery,
|
|
18
|
+
onError,
|
|
19
|
+
enabled = true,
|
|
20
|
+
}: {
|
|
21
|
+
subscribeToMore: Function;
|
|
22
|
+
document: any;
|
|
23
|
+
variables: Record<string, any>;
|
|
24
|
+
updateQuery: (prev: any, { subscriptionData }: any) => any;
|
|
25
|
+
onError?: (error: any) => void;
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
}) {
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!enabled) return;
|
|
30
|
+
|
|
31
|
+
console.log('SubscriptionHandler: Setting up subscription with variables:', variables);
|
|
32
|
+
|
|
33
|
+
const unsubscribe = subscribeToMore({
|
|
34
|
+
document,
|
|
35
|
+
variables,
|
|
36
|
+
updateQuery,
|
|
37
|
+
onError,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
console.log('SubscriptionHandler: Subscription setup successful, unsubscribe function:', unsubscribe);
|
|
41
|
+
|
|
42
|
+
return () => {
|
|
43
|
+
console.log('SubscriptionHandler: Cleaning up subscription');
|
|
44
|
+
if (unsubscribe && typeof unsubscribe === 'function') {
|
|
45
|
+
try {
|
|
46
|
+
unsubscribe();
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error('Error unsubscribing:', error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}, [subscribeToMore, document, variables, updateQuery, onError, enabled]);
|
|
53
|
+
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { ChangeEventHandler, useCallback, useRef } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { BiImage } from '@react-icons/all-files/bi/BiImage.js';
|
|
4
|
+
|
|
5
|
+
export interface IUploadImageButtonProps {
|
|
6
|
+
onChange: ChangeEventHandler<HTMLInputElement>;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const UploadImageButton = (props: IUploadImageButtonProps) => {
|
|
11
|
+
const fileInput = useRef<HTMLInputElement>();
|
|
12
|
+
const { t } = useTranslation('translations');
|
|
13
|
+
|
|
14
|
+
const selectFile = useCallback(() => {
|
|
15
|
+
if (fileInput?.current) {
|
|
16
|
+
fileInput?.current?.click();
|
|
17
|
+
}
|
|
18
|
+
}, [fileInput]);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className="relative group">
|
|
22
|
+
<input
|
|
23
|
+
multiple={true}
|
|
24
|
+
accept="image/apng, image/avif, image/gif, image/jpeg, image/png, image/svg+xml, image/webp"
|
|
25
|
+
type="file"
|
|
26
|
+
style={{ display: 'none' }}
|
|
27
|
+
ref={fileInput}
|
|
28
|
+
onChange={props.onChange}
|
|
29
|
+
/>
|
|
30
|
+
{/* Tooltip */}
|
|
31
|
+
<div className="absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-900 text-white text-xs rounded-lg shadow-lg opacity-0 group-hover:opacity-100 transition-all duration-200 pointer-events-none whitespace-nowrap z-20">
|
|
32
|
+
{t('tailwind_ui_inbox.upload_image')}
|
|
33
|
+
{/* Tooltip arrow */}
|
|
34
|
+
<div className="absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-l-transparent border-r-transparent border-t-gray-900"></div>
|
|
35
|
+
</div>
|
|
36
|
+
<button
|
|
37
|
+
type="button"
|
|
38
|
+
className="flex items-center justify-center w-8 h-8 bg-transparent hover:bg-gray-100 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 transition-all duration-200 ease-in-out"
|
|
39
|
+
onClick={selectFile}
|
|
40
|
+
aria-label={t('tailwind_ui_inbox.upload_image')}
|
|
41
|
+
>
|
|
42
|
+
{props.children || <BiImage className="w-5 h-5 text-gray-500 hover:text-gray-700" />}
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { AiOutlineSecurityScan } from '@react-icons/all-files/ai/AiOutlineSecurityScan.js';
|
|
4
|
+
import { FiCheck } from '@react-icons/all-files/fi/FiCheck.js';
|
|
5
|
+
import { BsFillStarFill } from '@react-icons/all-files/bs/BsFillStarFill.js';
|
|
6
|
+
|
|
7
|
+
export const UserModalContent = ({ username, imageUrl }: any) => {
|
|
8
|
+
const { t } = useTranslation('translations');
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<div>
|
|
12
|
+
<div>
|
|
13
|
+
<img
|
|
14
|
+
src={imageUrl !== '' ? imageUrl : ''}
|
|
15
|
+
alt="User avatar"
|
|
16
|
+
className="w-50 h-50 rounded-full bg-gray-400 object-cover"
|
|
17
|
+
style={{ width: '200px', height: '200px' }}
|
|
18
|
+
/>
|
|
19
|
+
<a href="#" className="text-blue-600 hover:text-blue-800 underline">
|
|
20
|
+
{t('tailwind_ui_inbox.update_photo')}
|
|
21
|
+
</a>
|
|
22
|
+
<AiOutlineSecurityScan className="w-6 h-6 text-black" />
|
|
23
|
+
<div>
|
|
24
|
+
<span className="text-black font-medium">{t('tailwind_ui_inbox.identity_verification')}</span>
|
|
25
|
+
<p className="text-black">{t('tailwind_ui_inbox.show_others_you_are_really_you')}</p>
|
|
26
|
+
<button className="get-badge-btn text-black bg-transparent border border-gray-300 px-4 py-2 rounded hover:bg-gray-50 transition-colors">
|
|
27
|
+
{t('tailwind_ui_inbox.get_the_badge')}
|
|
28
|
+
</button>
|
|
29
|
+
</div>
|
|
30
|
+
<div>
|
|
31
|
+
<span className="text-black font-medium">
|
|
32
|
+
{t('tailwind_ui_inbox.username_confirmed', { username: username })}
|
|
33
|
+
</span>
|
|
34
|
+
<div className="flex items-center gap-2">
|
|
35
|
+
<FiCheck className="text-black" />
|
|
36
|
+
<p className="text-black">{t('tailwind_ui_inbox.email_address')}</p>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
<div>
|
|
41
|
+
<div className="flex flex-col gap-2">
|
|
42
|
+
<span className="text-black font-medium">
|
|
43
|
+
{t('tailwind_ui_inbox.hi_im_username', { username: username })}
|
|
44
|
+
</span>
|
|
45
|
+
<p className="text-gray-600">{t('tailwind_ui_inbox.joined_in_date', { date: '2021' })}</p>
|
|
46
|
+
<a href="#" className="text-blue-600 hover:text-blue-800 underline">
|
|
47
|
+
{t('tailwind_ui_inbox.edit_profile')}
|
|
48
|
+
</a>
|
|
49
|
+
<div className="flex items-center gap-1">
|
|
50
|
+
<BsFillStarFill className="text-black text-base" />
|
|
51
|
+
<span className="text-black">{t('tailwind_ui_inbox.reviews')}</span>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
<a href="" className="text-blue-600 hover:text-blue-800 underline">
|
|
55
|
+
{t('tailwind_ui_inbox.reviews_by_you')}
|
|
56
|
+
</a>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './CommonMessage';
|
|
2
|
+
export * from './ConversationItem';
|
|
3
|
+
export * from './ServiceConversationItem';
|
|
4
|
+
export * from './LeftSidebar';
|
|
5
|
+
export * from './MessageInput';
|
|
6
|
+
export * from './Messages';
|
|
7
|
+
export * from './Popover';
|
|
8
|
+
export * from './UploadImageButton';
|
|
9
|
+
export * from './UserModalContent';
|
|
10
|
+
export * from './message-widgets';
|
|
11
|
+
export * from './RightSidebar';
|
|
12
|
+
export * from './ServiceInboxItem';
|
|
13
|
+
export * from './MessageInputComponent';
|
|
14
|
+
export * from './InputComponent';
|
|
15
|
+
export * from './MessagesBuilderUi';
|
|
16
|
+
export * from './RightSidebarAi';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { formatDistance } from 'date-fns';
|
|
3
|
+
import { BsFlag } from '@react-icons/all-files/bs/BsFlag.js';
|
|
4
|
+
import { IPost, IAuthUser } from 'common';
|
|
5
|
+
// import { IAuthUser } from '@pubngo-stack/core';
|
|
6
|
+
import { FilesList } from '../../inbox';
|
|
7
|
+
|
|
8
|
+
interface ICommonMessageProps {
|
|
9
|
+
message: IPost;
|
|
10
|
+
index: number;
|
|
11
|
+
onOpen: () => void;
|
|
12
|
+
currentUser: IAuthUser;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const CommonMessage = (props: ICommonMessageProps) => {
|
|
16
|
+
const { message, index, onOpen, currentUser } = props;
|
|
17
|
+
|
|
18
|
+
// Determine if this is an AI/system message for special styling
|
|
19
|
+
const isSystemMessage =
|
|
20
|
+
message?.author?.username?.toLowerCase().includes('ai') ||
|
|
21
|
+
message?.author?.username?.toLowerCase().includes('assistant') ||
|
|
22
|
+
message?.author?.username?.toLowerCase().includes('system');
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="w-full flex justify-start mb-7" key={`msgList_${index}`}>
|
|
26
|
+
<div className="flex-grow flex">
|
|
27
|
+
{/* User avatar - Only show for non-system messages */}
|
|
28
|
+
{!isSystemMessage && (
|
|
29
|
+
<img
|
|
30
|
+
className="w-8 h-8 bg-gray-400 rounded-full mr-4 cursor-pointer"
|
|
31
|
+
src={message?.author?.picture}
|
|
32
|
+
alt={message?.author?.username || 'User avatar'}
|
|
33
|
+
onClick={onOpen}
|
|
34
|
+
/>
|
|
35
|
+
)}
|
|
36
|
+
<div className="flex-grow">
|
|
37
|
+
{/* Author header - Only show for non-system messages */}
|
|
38
|
+
{!isSystemMessage && (
|
|
39
|
+
<div className="flex flex-grow mt-1.5">
|
|
40
|
+
<p className="text-sm text-gray-600 font-bold">
|
|
41
|
+
{message?.author?.familyName && message?.author?.givenName
|
|
42
|
+
? message?.author?.givenName + ' ' + message?.author?.familyName
|
|
43
|
+
: message?.author?.username}
|
|
44
|
+
</p>
|
|
45
|
+
<p className="text-sm text-gray-500 ml-2.5">
|
|
46
|
+
{formatDistance(new Date(message?.createdAt), new Date(), {
|
|
47
|
+
includeSeconds: true,
|
|
48
|
+
addSuffix: true,
|
|
49
|
+
})}
|
|
50
|
+
</p>
|
|
51
|
+
</div>
|
|
52
|
+
)}
|
|
53
|
+
{/* <p className="text-sm mt-1.5 whitespace-pre-line">{message?.message}</p> */}
|
|
54
|
+
<div
|
|
55
|
+
className="text-sm mt-1.5 whitespace-pre-wrap prose prose-sm max-w-none"
|
|
56
|
+
dangerouslySetInnerHTML={{ __html: message?.message || '' }}
|
|
57
|
+
/>
|
|
58
|
+
{message.files?.totalCount ? <FilesList uploaded files={message.files?.data} /> : null}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
{/* Flag button - Only show for non-system messages */}
|
|
62
|
+
{!isSystemMessage && currentUser?.id !== message?.author?.id && (
|
|
63
|
+
<div className="ml-2">
|
|
64
|
+
<BsFlag className="text-gray-600 w-6 h-6" />
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
};
|