@memori.ai/memori-react 8.45.1 → 8.45.4
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 +27 -0
- package/dist/components/Chat/Chat.js +4 -1
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/ChatHistoryDrawer/ChatResumeDrawer.d.ts +4 -1
- package/dist/components/ChatHistoryDrawer/ChatResumeDrawer.js +7 -57
- package/dist/components/ChatHistoryDrawer/ChatResumeDrawer.js.map +1 -1
- package/dist/components/IconButton/IconButton.d.ts +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.d.ts +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +2 -1
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/PositionPopover/PositionPopover.js +38 -25
- package/dist/components/PositionPopover/PositionPopover.js.map +1 -1
- package/dist/components/UploadButton/UploadButton.js +3 -0
- package/dist/components/UploadButton/UploadButton.js.map +1 -1
- package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js +14 -2
- package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
- package/dist/components/layouts/chat.css +27 -4
- package/dist/context/widgetSurfaceContext.js +2 -2
- package/dist/context/widgetSurfaceContext.js.map +1 -1
- package/dist/helpers/constants.d.ts +3 -2
- package/dist/helpers/constants.js +19 -20
- package/dist/helpers/constants.js.map +1 -1
- package/dist/helpers/positionPopover.d.ts +2 -1
- package/dist/helpers/positionPopover.js +12 -3
- package/dist/helpers/positionPopover.js.map +1 -1
- package/dist/helpers/tts/muteSpeaker.js +4 -3
- package/dist/helpers/tts/muteSpeaker.js.map +1 -1
- package/dist/helpers/usePressTooltip.js +2 -1
- package/dist/helpers/usePressTooltip.js.map +1 -1
- package/dist/helpers/utils.d.ts +2 -1
- package/dist/helpers/utils.js +7 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/icons/MemoriIcon.js +1 -1
- package/dist/icons/MemoriIcon.js.map +1 -1
- package/dist/styles.css +1 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/esm/components/Chat/Chat.js +4 -1
- package/esm/components/Chat/Chat.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.d.ts +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +2 -1
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/UploadButton/UploadButton.js +4 -1
- package/esm/components/UploadButton/UploadButton.js.map +1 -1
- package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js +16 -4
- package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
- package/esm/components/layouts/chat.css +27 -4
- package/esm/helpers/constants.d.ts +3 -2
- package/esm/helpers/constants.js +18 -19
- package/esm/helpers/constants.js.map +1 -1
- package/esm/helpers/utils.d.ts +2 -1
- package/esm/helpers/utils.js +6 -1
- package/esm/helpers/utils.js.map +1 -1
- package/esm/styles.css +1 -2
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/package.json +6 -7
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.d.ts +0 -3
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.js +0 -64
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.js.map +0 -1
- package/dist/testUtils.d.ts +0 -5
- package/dist/testUtils.js +0 -18
- package/dist/testUtils.js.map +0 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.d.ts +0 -3
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.js +0 -62
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.js.map +0 -1
- package/src/I18nWrapper.tsx +0 -13
- package/src/__snapshots__/index.test.tsx.snap +0 -96
- package/src/components/AgeVerificationModal/AgeVerificationModal.css +0 -95
- package/src/components/AgeVerificationModal/AgeVerificationModal.stories.tsx +0 -46
- package/src/components/AgeVerificationModal/AgeVerificationModal.test.tsx +0 -33
- package/src/components/AgeVerificationModal/AgeVerificationModal.tsx +0 -99
- package/src/components/AgeVerificationModal/__snapshots__/AgeVerificationModal.test.tsx.snap +0 -19
- package/src/components/Auth/Auth.css +0 -57
- package/src/components/Auth/Auth.stories.tsx +0 -90
- package/src/components/Auth/Auth.test.tsx +0 -63
- package/src/components/Auth/Auth.tsx +0 -201
- package/src/components/Auth/__snapshots__/Auth.test.tsx.snap +0 -143
- package/src/components/Avatar/Avatar.css +0 -151
- package/src/components/Avatar/Avatar.stories.tsx +0 -160
- package/src/components/Avatar/Avatar.test.tsx +0 -158
- package/src/components/Avatar/Avatar.tsx +0 -245
- package/src/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.tsx +0 -103
- package/src/components/Avatar/AvatarView/AvatarComponent/avatarComponent.tsx +0 -105
- package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.tsx +0 -338
- package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/types.ts +0 -44
- package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.ts +0 -1091
- package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarPositionController.ts +0 -83
- package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.ts +0 -301
- package/src/components/Avatar/AvatarView/AvatarComponent/components/controls.tsx +0 -100
- package/src/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.tsx +0 -152
- package/src/components/Avatar/AvatarView/AvatarComponent/components/loader.tsx +0 -31
- package/src/components/Avatar/AvatarView/AvatarComponent/constants.ts +0 -141
- package/src/components/Avatar/AvatarView/AvatarComponent/lights/Lights.tsx +0 -145
- package/src/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.css +0 -111
- package/src/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.tsx +0 -201
- package/src/components/Avatar/AvatarView/AvatarView.stories.tsx +0 -254
- package/src/components/Avatar/AvatarView/index.tsx +0 -194
- package/src/components/Avatar/AvatarView/utils/hideHands.ts +0 -11
- package/src/components/Avatar/AvatarView/utils/useEyeBlink.ts +0 -100
- package/src/components/Avatar/AvatarView/utils/useHeadMovement.ts +0 -72
- package/src/components/Avatar/AvatarView/utils/useLoadingMorphAnim.ts +0 -38
- package/src/components/Avatar/AvatarView/utils/useMouthAnimation.ts +0 -93
- package/src/components/Avatar/AvatarView/utils/useSmile.ts +0 -39
- package/src/components/Avatar/AvatarView/utils/utils.ts +0 -55
- package/src/components/Avatar/__snapshots__/Avatar.test.tsx.snap +0 -246
- package/src/components/Blob/Blob.css +0 -286
- package/src/components/Blob/Blob.stories.tsx +0 -53
- package/src/components/Blob/Blob.test.tsx +0 -18
- package/src/components/Blob/Blob.tsx +0 -26
- package/src/components/Blob/__snapshots__/Blob.test.tsx.snap +0 -80
- package/src/components/BlockedMemoriBadge/BlockedMemoriBadge.css +0 -40
- package/src/components/BlockedMemoriBadge/BlockedMemoriBadge.stories.tsx +0 -58
- package/src/components/BlockedMemoriBadge/BlockedMemoriBadge.test.tsx +0 -53
- package/src/components/BlockedMemoriBadge/BlockedMemoriBadge.tsx +0 -74
- package/src/components/BlockedMemoriBadge/__snapshots__/BlockedMemoriBadge.test.tsx.snap +0 -181
- package/src/components/ChangeMode/ChangeMode.css +0 -22
- package/src/components/ChangeMode/ChangeMode.stories.tsx +0 -50
- package/src/components/ChangeMode/ChangeMode.test.tsx +0 -24
- package/src/components/ChangeMode/ChangeMode.tsx +0 -51
- package/src/components/ChangeMode/__snapshots__/ChangeMode.test.tsx.snap +0 -107
- package/src/components/Chat/Chat.css +0 -285
- package/src/components/Chat/Chat.stories.tsx +0 -1684
- package/src/components/Chat/Chat.test.tsx +0 -372
- package/src/components/Chat/Chat.tsx +0 -778
- package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +0 -6816
- package/src/components/ChatBubble/ChatBubble.css +0 -430
- package/src/components/ChatBubble/ChatBubble.stories.tsx +0 -1192
- package/src/components/ChatBubble/ChatBubble.test.tsx +0 -481
- package/src/components/ChatBubble/ChatBubble.tsx +0 -776
- package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +0 -8734
- package/src/components/ChatHistoryDrawer/ChatHistory.css +0 -587
- package/src/components/ChatHistoryDrawer/ChatHistory.stories.tsx +0 -410
- package/src/components/ChatHistoryDrawer/ChatHistory.test.tsx +0 -107
- package/src/components/ChatHistoryDrawer/ChatHistory.tsx +0 -1298
- package/src/components/ChatHistoryDrawer/__snapshots__/ChatHistory.test.tsx.snap +0 -27
- package/src/components/ChatInputs/ChatInputs.css +0 -340
- package/src/components/ChatInputs/ChatInputs.stories.tsx +0 -251
- package/src/components/ChatInputs/ChatInputs.tsx +0 -487
- package/src/components/ChatTextArea/ChatTextArea.css +0 -185
- package/src/components/ChatTextArea/ChatTextArea.stories.tsx +0 -55
- package/src/components/ChatTextArea/ChatTextArea.test.tsx +0 -28
- package/src/components/ChatTextArea/ChatTextArea.tsx +0 -171
- package/src/components/ChatTextArea/__snapshots__/ChatTextArea.test.tsx.snap +0 -68
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.css +0 -36
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.stories.tsx +0 -296
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.test.tsx +0 -31
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx +0 -232
- package/src/components/CompletionProviderStatus/__snapshots__/CompletionProviderStatus.test.tsx.snap +0 -96
- package/src/components/ContentPreviewModal/ContentPreviewModal.css +0 -128
- package/src/components/ContentPreviewModal/ContentPreviewModal.tsx +0 -67
- package/src/components/ContentPreviewModal/index.ts +0 -2
- package/src/components/CustomGLBModelViewer/ModelViewer.css +0 -11
- package/src/components/CustomGLBModelViewer/ModelViewer.stories.tsx +0 -58
- package/src/components/CustomGLBModelViewer/ModelViewer.test.tsx +0 -13
- package/src/components/CustomGLBModelViewer/ModelViewer.tsx +0 -37
- package/src/components/CustomGLBModelViewer/__snapshots__/ModelViewer.test.tsx.snap +0 -20
- package/src/components/DateSelector/DateSelector.css +0 -158
- package/src/components/DateSelector/DateSelector.stories.tsx +0 -47
- package/src/components/DateSelector/DateSelector.test.tsx +0 -149
- package/src/components/DateSelector/DateSelector.tsx +0 -251
- package/src/components/DateSelector/__snapshots__/DateSelector.test.tsx.snap +0 -1954
- package/src/components/ErrorBoundary/ErrorBoundary.tsx +0 -54
- package/src/components/ExpertsDrawer/ExpertsDrawer.css +0 -67
- package/src/components/ExpertsDrawer/ExpertsDrawer.stories.tsx +0 -54
- package/src/components/ExpertsDrawer/ExpertsDrawer.test.tsx +0 -53
- package/src/components/ExpertsDrawer/ExpertsDrawer.tsx +0 -69
- package/src/components/ExpertsDrawer/__snapshots__/ExpertsDrawer.test.tsx.snap +0 -11
- package/src/components/ExportHistoryButton/ExportHistoryButton.css +0 -22
- package/src/components/FeedbackButtons/FeedbackButtons.css +0 -107
- package/src/components/FeedbackButtons/FeedbackButtons.stories.tsx +0 -52
- package/src/components/FeedbackButtons/FeedbackButtons.test.tsx +0 -11
- package/src/components/FeedbackButtons/FeedbackButtons.tsx +0 -152
- package/src/components/FeedbackButtons/__snapshots__/FeedbackButtons.test.tsx.snap +0 -42
- package/src/components/FilePreview/FilePreview.css +0 -358
- package/src/components/FilePreview/FilePreview.stories.tsx +0 -63
- package/src/components/FilePreview/FilePreview.test.tsx +0 -26
- package/src/components/FilePreview/FilePreview.tsx +0 -277
- package/src/components/FilePreview/__snapshots__/FilePreview.test.tsx.snap +0 -185
- package/src/components/Header/ChatConsumptionDropdown.test.tsx +0 -117
- package/src/components/Header/ChatConsumptionDropdown.tsx +0 -275
- package/src/components/Header/Header.css +0 -282
- package/src/components/Header/Header.stories.tsx +0 -338
- package/src/components/Header/Header.test.tsx +0 -371
- package/src/components/Header/Header.tsx +0 -442
- package/src/components/Header/__snapshots__/Header.test.tsx.snap +0 -964
- package/src/components/KnownFacts/KnownFacts.css +0 -19
- package/src/components/KnownFacts/KnownFacts.stories.tsx +0 -80
- package/src/components/KnownFacts/KnownFacts.test.tsx +0 -57
- package/src/components/KnownFacts/KnownFacts.tsx +0 -376
- package/src/components/KnownFacts/__snapshots__/KnownFacts.test.tsx.snap +0 -19
- package/src/components/LoginDrawer/LoginDrawer.css +0 -1616
- package/src/components/LoginDrawer/LoginDrawer.stories.tsx +0 -102
- package/src/components/LoginDrawer/LoginDrawer.test.tsx +0 -199
- package/src/components/LoginDrawer/LoginDrawer.tsx +0 -600
- package/src/components/LoginDrawer/__snapshots__/LoginDrawer.test.tsx.snap +0 -91
- package/src/components/MediaWidget/DocumentCard.test.tsx +0 -45
- package/src/components/MediaWidget/DocumentCard.tsx +0 -19
- package/src/components/MediaWidget/MediaItemWidget.css +0 -1398
- package/src/components/MediaWidget/MediaItemWidget.stories.tsx +0 -423
- package/src/components/MediaWidget/MediaItemWidget.test.tsx +0 -248
- package/src/components/MediaWidget/MediaItemWidget.tsx +0 -997
- package/src/components/MediaWidget/MediaItemWidget.types.ts +0 -65
- package/src/components/MediaWidget/MediaItemWidget.utils.test.ts +0 -367
- package/src/components/MediaWidget/MediaItemWidget.utils.ts +0 -227
- package/src/components/MediaWidget/MediaPreviewModal.test.tsx +0 -271
- package/src/components/MediaWidget/MediaPreviewModal.tsx +0 -425
- package/src/components/MediaWidget/MediaWidget.css +0 -131
- package/src/components/MediaWidget/MediaWidget.stories.tsx +0 -319
- package/src/components/MediaWidget/MediaWidget.test.tsx +0 -41
- package/src/components/MediaWidget/MediaWidget.tsx +0 -107
- package/src/components/MediaWidget/__snapshots__/DocumentCard.test.tsx.snap +0 -24
- package/src/components/MediaWidget/__snapshots__/MediaItemWidget.test.tsx.snap +0 -791
- package/src/components/MediaWidget/__snapshots__/MediaWidget.test.tsx.snap +0 -154
- package/src/components/MemoriArtifactSystem/ArtifactDrawer.stories.tsx +0 -2299
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.css +0 -163
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.tsx +0 -250
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/CopyButton.stories.tsx +0 -30
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyButtonWithDropdown.tsx +0 -467
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyMenuItem.tsx +0 -89
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/hooks/useCopyArtifact.ts +0 -619
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/index.ts +0 -9
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/styles.css +0 -489
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.tsx +0 -90
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/types.ts +0 -73
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/utils/PDFExporter.ts +0 -454
- package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +0 -1059
- package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.tsx +0 -431
- package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.css +0 -150
- package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.tsx +0 -79
- package/src/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.css +0 -253
- package/src/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.tsx +0 -561
- package/src/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.css +0 -355
- package/src/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.tsx +0 -160
- package/src/components/MemoriArtifactSystem/context/ArtifactContext.tsx +0 -167
- package/src/components/MemoriArtifactSystem/types/artifact.types.ts +0 -35
- package/src/components/MemoriArtifactSystem/utils/ArtifactAPI.test.tsx +0 -308
- package/src/components/MemoriArtifactSystem/utils/ArtifactAPI.tsx +0 -379
- package/src/components/MemoriArtifactSystem/utils/applyEdits.test.ts +0 -85
- package/src/components/MemoriArtifactSystem/utils/applyEdits.ts +0 -173
- package/src/components/MemoriWidget/MemoriWidget.css +0 -220
- package/src/components/MemoriWidget/MemoriWidget.stories.tsx +0 -274
- package/src/components/MemoriWidget/MemoriWidget.tsx +0 -3930
- package/src/components/MicrophoneButton/MicrophoneButton.css +0 -142
- package/src/components/MicrophoneButton/MicrophoneButton.stories.tsx +0 -52
- package/src/components/MicrophoneButton/MicrophoneButton.tsx +0 -128
- package/src/components/PositionDrawer/PositionDrawer.stories.tsx +0 -51
- package/src/components/PositionDrawer/PositionDrawer.test.tsx +0 -39
- package/src/components/PositionDrawer/PositionDrawer.tsx +0 -50
- package/src/components/PositionDrawer/__snapshots__/PositionDrawer.test.tsx.snap +0 -17
- package/src/components/PoweredBy/PoweredBy.css +0 -47
- package/src/components/PoweredBy/PoweredBy.stories.tsx +0 -75
- package/src/components/PoweredBy/PoweredBy.test.tsx +0 -15
- package/src/components/PoweredBy/PoweredBy.tsx +0 -44
- package/src/components/PoweredBy/__snapshots__/PoweredBy.test.tsx.snap +0 -55
- package/src/components/SendOnEnterMenu/SendOnEnterMenu.css +0 -47
- package/src/components/SendOnEnterMenu/SendOnEnterMenu.stories.tsx +0 -58
- package/src/components/SendOnEnterMenu/SendOnEnterMenu.test.tsx +0 -17
- package/src/components/SendOnEnterMenu/SendOnEnterMenu.tsx +0 -82
- package/src/components/SendOnEnterMenu/__snapshots__/SendOnEnterMenu.test.tsx.snap +0 -57
- package/src/components/SettingsDrawer/SettingsDrawer.css +0 -24
- package/src/components/SettingsDrawer/SettingsDrawer.stories.tsx +0 -94
- package/src/components/SettingsDrawer/SettingsDrawer.test.tsx +0 -202
- package/src/components/SettingsDrawer/SettingsDrawer.tsx +0 -255
- package/src/components/SettingsDrawer/__snapshots__/SettingsDrawer.test.tsx.snap +0 -59
- package/src/components/ShareButton/ShareButton.css +0 -73
- package/src/components/ShareButton/ShareButton.stories.tsx +0 -98
- package/src/components/ShareButton/ShareButton.test.tsx +0 -53
- package/src/components/ShareButton/ShareButton.tsx +0 -395
- package/src/components/ShareButton/__snapshots__/ShareButton.test.tsx.snap +0 -316
- package/src/components/Snippet/Snippet.css +0 -142
- package/src/components/Snippet/Snippet.stories.tsx +0 -286
- package/src/components/Snippet/Snippet.test.tsx +0 -176
- package/src/components/Snippet/Snippet.tsx +0 -148
- package/src/components/Snippet/__snapshots__/Snippet.test.tsx.snap +0 -603
- package/src/components/StartPanel/StartPanel.css +0 -273
- package/src/components/StartPanel/StartPanel.stories.tsx +0 -404
- package/src/components/StartPanel/StartPanel.test.tsx +0 -360
- package/src/components/StartPanel/StartPanel.tsx +0 -426
- package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +0 -1986
- package/src/components/Typing/Typing.stories.tsx +0 -130
- package/src/components/Typing/Typing.test.tsx +0 -62
- package/src/components/Typing/Typing.tsx +0 -154
- package/src/components/Typing/__snapshots__/Typing.test.tsx.snap +0 -133
- package/src/components/UploadButton/UploadButton.css +0 -542
- package/src/components/UploadButton/UploadButton.stories.tsx +0 -376
- package/src/components/UploadButton/UploadButton.test.tsx +0 -11
- package/src/components/UploadButton/UploadButton.tsx +0 -684
- package/src/components/UploadButton/UploadDocuments/UploadDocuments.tsx +0 -405
- package/src/components/UploadButton/UploadImages/UploadImages.tsx +0 -538
- package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +0 -165
- package/src/components/VenueWidget/VenueWidget.css +0 -163
- package/src/components/VenueWidget/VenueWidget.stories.tsx +0 -66
- package/src/components/VenueWidget/VenueWidget.test.tsx +0 -49
- package/src/components/VenueWidget/VenueWidget.tsx +0 -458
- package/src/components/VenueWidget/__snapshots__/VenueWidget.test.tsx.snap +0 -370
- package/src/components/WhyThisAnswer/WhyThisAnswer.css +0 -171
- package/src/components/WhyThisAnswer/WhyThisAnswer.stories.tsx +0 -285
- package/src/components/WhyThisAnswer/WhyThisAnswer.test.tsx +0 -245
- package/src/components/WhyThisAnswer/WhyThisAnswer.tsx +0 -233
- package/src/components/WhyThisAnswer/__snapshots__/WhyThisAnswer.test.tsx.snap +0 -27
- package/src/components/icons/AI.tsx +0 -34
- package/src/components/icons/Alert.tsx +0 -31
- package/src/components/icons/ArrowUp.tsx +0 -28
- package/src/components/icons/Bug.tsx +0 -81
- package/src/components/icons/Chat.tsx +0 -30
- package/src/components/icons/ChevronDown.tsx +0 -26
- package/src/components/icons/ChevronLeft.tsx +0 -28
- package/src/components/icons/ChevronRight.tsx +0 -28
- package/src/components/icons/ChevronUp.tsx +0 -24
- package/src/components/icons/Clear.tsx +0 -23
- package/src/components/icons/Close.tsx +0 -30
- package/src/components/icons/Code.tsx +0 -24
- package/src/components/icons/Copy.tsx +0 -23
- package/src/components/icons/DeepThought.tsx +0 -38
- package/src/components/icons/Delete.tsx +0 -23
- package/src/components/icons/Document.tsx +0 -50
- package/src/components/icons/Download.tsx +0 -23
- package/src/components/icons/Edit.tsx +0 -17
- package/src/components/icons/Expand.tsx +0 -23
- package/src/components/icons/Eye.tsx +0 -17
- package/src/components/icons/EyeInvisible.tsx +0 -24
- package/src/components/icons/Facebook.tsx +0 -23
- package/src/components/icons/Feedback.tsx +0 -24
- package/src/components/icons/File.tsx +0 -17
- package/src/components/icons/FileExcel.tsx +0 -23
- package/src/components/icons/FilePdf.tsx +0 -23
- package/src/components/icons/FileWord.tsx +0 -23
- package/src/components/icons/Fullscreen.tsx +0 -23
- package/src/components/icons/FullscreenExit.tsx +0 -23
- package/src/components/icons/GasStation.tsx +0 -36
- package/src/components/icons/Group.tsx +0 -30
- package/src/components/icons/History.tsx +0 -33
- package/src/components/icons/Image.tsx +0 -37
- package/src/components/icons/Info.tsx +0 -31
- package/src/components/icons/Link.tsx +0 -17
- package/src/components/icons/Linkedin.tsx +0 -23
- package/src/components/icons/Loading.tsx +0 -28
- package/src/components/icons/Logout.tsx +0 -27
- package/src/components/icons/Mail.tsx +0 -17
- package/src/components/icons/MapMarker.tsx +0 -26
- package/src/components/icons/MenuHorizontal.tsx +0 -29
- package/src/components/icons/MenuVertical.tsx +0 -29
- package/src/components/icons/Message.tsx +0 -23
- package/src/components/icons/Microphone.tsx +0 -23
- package/src/components/icons/Minus.tsx +0 -23
- package/src/components/icons/MinusCircle.tsx +0 -24
- package/src/components/icons/PaperClip.tsx +0 -23
- package/src/components/icons/Picture.tsx +0 -23
- package/src/components/icons/Plus.tsx +0 -18
- package/src/components/icons/Preview.tsx +0 -29
- package/src/components/icons/Print.tsx +0 -38
- package/src/components/icons/QuestionHelp.tsx +0 -30
- package/src/components/icons/Refresh.tsx +0 -30
- package/src/components/icons/SelectIcon.tsx +0 -28
- package/src/components/icons/Send.tsx +0 -17
- package/src/components/icons/Setting.tsx +0 -23
- package/src/components/icons/Share.tsx +0 -23
- package/src/components/icons/Sound.tsx +0 -23
- package/src/components/icons/SoundDeactivated.tsx +0 -27
- package/src/components/icons/Telegram.tsx +0 -26
- package/src/components/icons/ThumbDown.tsx +0 -29
- package/src/components/icons/ThumbUp.tsx +0 -29
- package/src/components/icons/Translation.tsx +0 -24
- package/src/components/icons/Twitter.tsx +0 -23
- package/src/components/icons/Upload.tsx +0 -34
- package/src/components/icons/User.tsx +0 -17
- package/src/components/icons/Warning.tsx +0 -24
- package/src/components/icons/WhatsApp.tsx +0 -24
- package/src/components/icons/icons.stories.css +0 -5
- package/src/components/icons/icons.stories.tsx +0 -81
- package/src/components/icons/loading.css +0 -14
- package/src/components/layouts/Chat.test.tsx +0 -40
- package/src/components/layouts/Chat.tsx +0 -69
- package/src/components/layouts/FullBody/FullBody.stories.tsx +0 -110
- package/src/components/layouts/FullPage.test.tsx +0 -65
- package/src/components/layouts/FullPage.tsx +0 -80
- package/src/components/layouts/HiddenChat.test.tsx +0 -40
- package/src/components/layouts/HiddenChat.tsx +0 -233
- package/src/components/layouts/Totem/Totem.stories.tsx +0 -131
- package/src/components/layouts/Totem.test.tsx +0 -40
- package/src/components/layouts/Totem.tsx +0 -49
- package/src/components/layouts/WebsiteAssistant.test.tsx +0 -40
- package/src/components/layouts/WebsiteAssistant.tsx +0 -132
- package/src/components/layouts/ZoomedFullBody/ZoomedFullBody.stories.tsx +0 -131
- package/src/components/layouts/ZoomedFullBody.test.tsx +0 -40
- package/src/components/layouts/ZoomedFullBody.tsx +0 -81
- package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +0 -457
- package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +0 -1045
- package/src/components/layouts/__snapshots__/HiddenChat.test.tsx.snap +0 -460
- package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +0 -566
- package/src/components/layouts/__snapshots__/WebsiteAssistant.test.tsx.snap +0 -59
- package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +0 -523
- package/src/components/layouts/chat.css +0 -451
- package/src/components/layouts/hidden-chat.css +0 -276
- package/src/components/layouts/layouts.stories.tsx +0 -231
- package/src/components/layouts/totem.css +0 -221
- package/src/components/layouts/website-assistant.css +0 -677
- package/src/components/layouts/zoomed-full-body.css +0 -18
- package/src/components/ui/Alert.css +0 -93
- package/src/components/ui/Alert.stories.tsx +0 -137
- package/src/components/ui/Alert.test.tsx +0 -129
- package/src/components/ui/Alert.tsx +0 -123
- package/src/components/ui/Button.css +0 -167
- package/src/components/ui/Button.stories.tsx +0 -156
- package/src/components/ui/Button.test.tsx +0 -74
- package/src/components/ui/Button.tsx +0 -107
- package/src/components/ui/Card.css +0 -65
- package/src/components/ui/Card.stories.tsx +0 -95
- package/src/components/ui/Card.test.tsx +0 -47
- package/src/components/ui/Card.tsx +0 -48
- package/src/components/ui/Checkbox.css +0 -116
- package/src/components/ui/Checkbox.stories.tsx +0 -74
- package/src/components/ui/Checkbox.test.tsx +0 -28
- package/src/components/ui/Checkbox.tsx +0 -58
- package/src/components/ui/ConfirmDialog.css +0 -42
- package/src/components/ui/ConfirmDialog.stories.tsx +0 -216
- package/src/components/ui/ConfirmDialog.test.tsx +0 -124
- package/src/components/ui/ConfirmDialog.tsx +0 -58
- package/src/components/ui/Details.css +0 -66
- package/src/components/ui/Drawer.css +0 -270
- package/src/components/ui/Drawer.stories.tsx +0 -267
- package/src/components/ui/Drawer.test.tsx +0 -130
- package/src/components/ui/Drawer.tsx +0 -293
- package/src/components/ui/Dropdown.css +0 -173
- package/src/components/ui/Dropdown.tsx +0 -63
- package/src/components/ui/Expandable.css +0 -15
- package/src/components/ui/Expandable.stories.tsx +0 -180
- package/src/components/ui/Expandable.test.tsx +0 -107
- package/src/components/ui/Expandable.tsx +0 -121
- package/src/components/ui/Modal.css +0 -98
- package/src/components/ui/Modal.stories.tsx +0 -171
- package/src/components/ui/Modal.test.tsx +0 -111
- package/src/components/ui/Modal.tsx +0 -117
- package/src/components/ui/Select.css +0 -138
- package/src/components/ui/Select.stories.tsx +0 -79
- package/src/components/ui/Select.test.tsx +0 -84
- package/src/components/ui/Select.tsx +0 -79
- package/src/components/ui/Slider.css +0 -192
- package/src/components/ui/Slider.stories.tsx +0 -63
- package/src/components/ui/Slider.tsx +0 -142
- package/src/components/ui/Spin.css +0 -31
- package/src/components/ui/Spin.stories.tsx +0 -64
- package/src/components/ui/Spin.test.tsx +0 -41
- package/src/components/ui/Spin.tsx +0 -31
- package/src/components/ui/Table.css +0 -132
- package/src/components/ui/Tooltip.css +0 -171
- package/src/components/ui/Tooltip.stories.tsx +0 -109
- package/src/components/ui/Tooltip.test.tsx +0 -102
- package/src/components/ui/Tooltip.tsx +0 -163
- package/src/components/ui/__snapshots__/Alert.test.tsx.snap +0 -59
- package/src/components/ui/__snapshots__/Button.test.tsx.snap +0 -204
- package/src/components/ui/__snapshots__/Card.test.tsx.snap +0 -321
- package/src/components/ui/__snapshots__/Checkbox.test.tsx.snap +0 -131
- package/src/components/ui/__snapshots__/ConfirmDialog.test.tsx.snap +0 -35
- package/src/components/ui/__snapshots__/Drawer.test.tsx.snap +0 -67
- package/src/components/ui/__snapshots__/Expandable.test.tsx.snap +0 -159
- package/src/components/ui/__snapshots__/Modal.test.tsx.snap +0 -59
- package/src/components/ui/__snapshots__/Select.test.tsx.snap +0 -254
- package/src/components/ui/__snapshots__/Spin.test.tsx.snap +0 -193
- package/src/components/ui/__snapshots__/Tooltip.test.tsx.snap +0 -113
- package/src/components/ui/definitions.stories.tsx +0 -139
- package/src/context/visemeContext.tsx +0 -384
- package/src/helpers/chatPdfExport.ts +0 -544
- package/src/helpers/configuration.ts +0 -42
- package/src/helpers/constants.ts +0 -267
- package/src/helpers/convertDocument.test.ts +0 -67
- package/src/helpers/convertDocument.ts +0 -35
- package/src/helpers/credits.ts +0 -54
- package/src/helpers/error.test.ts +0 -29
- package/src/helpers/error.ts +0 -278
- package/src/helpers/imageCompression.ts +0 -230
- package/src/helpers/llmUsage.ts +0 -328
- package/src/helpers/markedExtendedTables.js +0 -217
- package/src/helpers/media.test.ts +0 -169
- package/src/helpers/media.ts +0 -81
- package/src/helpers/message.test.ts +0 -126
- package/src/helpers/message.ts +0 -219
- package/src/helpers/nats/getNatsConfig.ts +0 -148
- package/src/helpers/nats/isSessionExpiredError.test.ts +0 -38
- package/src/helpers/nats/isSessionExpiredError.ts +0 -51
- package/src/helpers/nats/useNats.test.tsx +0 -81
- package/src/helpers/nats/useNats.ts +0 -204
- package/src/helpers/nats/useNatsSession.test.ts +0 -16
- package/src/helpers/nats/useNatsSession.ts +0 -460
- package/src/helpers/piiDetection.test.ts +0 -186
- package/src/helpers/piiDetection.ts +0 -91
- package/src/helpers/sanitizer.ts +0 -17
- package/src/helpers/statistics.ts +0 -58
- package/src/helpers/stt/useSTT.ts +0 -515
- package/src/helpers/translations.ts +0 -39
- package/src/helpers/tts/ttsVoiceUtility.ts +0 -275
- package/src/helpers/tts/useTTS.ts +0 -621
- package/src/helpers/utils.test.ts +0 -321
- package/src/helpers/utils.ts +0 -586
- package/src/helpers/venue.ts +0 -36
- package/src/i18n.ts +0 -39
- package/src/index.stories.tsx +0 -220
- package/src/index.test.tsx +0 -156
- package/src/index.tsx +0 -592
- package/src/locales/de.json +0 -680
- package/src/locales/en.json +0 -754
- package/src/locales/es.json +0 -682
- package/src/locales/fr.json +0 -682
- package/src/locales/it.json +0 -750
- package/src/mocks/data.ts +0 -790
- package/src/styles.css +0 -126
- package/src/types/integration.test.ts +0 -32
- package/src/types/integration.ts +0 -31
- package/src/types/layout.ts +0 -50
- package/src/version.ts +0 -2
|
@@ -1,684 +0,0 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
2
|
-
import { DocumentIcon } from '../icons/Document';
|
|
3
|
-
import { ImageIcon } from '../icons/Image';
|
|
4
|
-
import { UploadIcon } from '../icons/Upload';
|
|
5
|
-
import Spin from '../ui/Spin';
|
|
6
|
-
import Alert from '../ui/Alert';
|
|
7
|
-
import cx from 'classnames';
|
|
8
|
-
import UploadDocuments from './UploadDocuments/UploadDocuments';
|
|
9
|
-
import UploadImages from './UploadImages/UploadImages';
|
|
10
|
-
import { useTranslation } from 'react-i18next';
|
|
11
|
-
import memoriApiClient from '@memori.ai/memori-api-client';
|
|
12
|
-
import {
|
|
13
|
-
documentConversionExtensions,
|
|
14
|
-
officeNativeExtensions,
|
|
15
|
-
} from '../../helpers/constants';
|
|
16
|
-
import Tooltip from '../ui/Tooltip';
|
|
17
|
-
// Props interface
|
|
18
|
-
interface UploadManagerProps {
|
|
19
|
-
authToken?: string;
|
|
20
|
-
client?: ReturnType<typeof memoriApiClient>;
|
|
21
|
-
sessionID?: string;
|
|
22
|
-
baseUrl?: string;
|
|
23
|
-
isMediaAccepted?: boolean;
|
|
24
|
-
setDocumentPreviewFiles: any;
|
|
25
|
-
documentPreviewFiles: {
|
|
26
|
-
name: string;
|
|
27
|
-
id: string;
|
|
28
|
-
content: string;
|
|
29
|
-
mediumID?: string;
|
|
30
|
-
type?: string;
|
|
31
|
-
}[];
|
|
32
|
-
memoriID?: string;
|
|
33
|
-
/** Override per-document content length limit (character count). */
|
|
34
|
-
maxTotalMessagePayload?: number;
|
|
35
|
-
/** Max attachments (docs + images) per message. */
|
|
36
|
-
maxDocumentsPerMessage?: number;
|
|
37
|
-
/** Per-document content character limit. */
|
|
38
|
-
maxDocumentContentLength?: number;
|
|
39
|
-
/** Called when the upload loading state changes. */
|
|
40
|
-
onUploadLoadingChange?: (loading: boolean, fileCount?: number) => void;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const UploadButton: React.FC<UploadManagerProps> = ({
|
|
44
|
-
authToken = '',
|
|
45
|
-
client,
|
|
46
|
-
sessionID = '',
|
|
47
|
-
baseUrl = '',
|
|
48
|
-
isMediaAccepted = false,
|
|
49
|
-
setDocumentPreviewFiles,
|
|
50
|
-
documentPreviewFiles,
|
|
51
|
-
memoriID = '',
|
|
52
|
-
maxTotalMessagePayload,
|
|
53
|
-
maxDocumentsPerMessage = 10,
|
|
54
|
-
maxDocumentContentLength = 300000,
|
|
55
|
-
onUploadLoadingChange,
|
|
56
|
-
}) => {
|
|
57
|
-
// Per-document character limit for the inlined `<document_attachment>`
|
|
58
|
-
// content. Does NOT affect the full text uploaded as an asset.
|
|
59
|
-
const effectivePerDocumentLimit =
|
|
60
|
-
maxTotalMessagePayload ?? maxDocumentContentLength ?? 300000;
|
|
61
|
-
// State
|
|
62
|
-
const [isDocumentLoading, setIsDocumentLoading] = useState(false);
|
|
63
|
-
const [isImageLoading, setIsImageLoading] = useState(false);
|
|
64
|
-
const isLoading = isDocumentLoading || isImageLoading;
|
|
65
|
-
const [docUploadingCount, setDocUploadingCount] = useState(0);
|
|
66
|
-
const [imgUploadingCount, setImgUploadingCount] = useState(0);
|
|
67
|
-
const uploadingFileCount = docUploadingCount + imgUploadingCount;
|
|
68
|
-
const [errors, setErrors] = useState<
|
|
69
|
-
{ message: string; severity: 'error' | 'warning' | 'info' }[]
|
|
70
|
-
>([]);
|
|
71
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
72
|
-
const { t, i18n } = useTranslation();
|
|
73
|
-
|
|
74
|
-
// Refs
|
|
75
|
-
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
76
|
-
const documentRef = useRef<HTMLDivElement>(null);
|
|
77
|
-
const imageRef = useRef<HTMLDivElement>(null);
|
|
78
|
-
const unifiedInputRef = useRef<HTMLInputElement>(null);
|
|
79
|
-
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
80
|
-
|
|
81
|
-
// Calculate total media count
|
|
82
|
-
const currentMediaCount = documentPreviewFiles.length;
|
|
83
|
-
const remainingSlots = maxDocumentsPerMessage - currentMediaCount;
|
|
84
|
-
const hasReachedMediaLimit = remainingSlots <= 0;
|
|
85
|
-
|
|
86
|
-
// Error handling
|
|
87
|
-
const removeError = (errorMessage: string) => {
|
|
88
|
-
setErrors(prev => prev.filter(e => e.message !== errorMessage));
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const addError = (error: {
|
|
92
|
-
message: string;
|
|
93
|
-
severity: 'error' | 'warning' | 'info';
|
|
94
|
-
}) => {
|
|
95
|
-
setErrors(prev => [...prev, error]);
|
|
96
|
-
setTimeout(() => removeError(error.message), 5000);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// Check if file is an image
|
|
100
|
-
const isImageFile = (file: File): boolean => {
|
|
101
|
-
const imageTypes = ['image/jpeg', 'image/jpg', 'image/png'];
|
|
102
|
-
const imageExtensions = ['.jpg', '.jpeg', '.png'];
|
|
103
|
-
const fileExt = `.${file.name.split('.').pop()?.toLowerCase()}`;
|
|
104
|
-
return imageTypes.includes(file.type) || imageExtensions.includes(fileExt);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
// Check if file is a document
|
|
108
|
-
const isDocumentFile = (file: File): boolean => {
|
|
109
|
-
const documentExtensions: readonly string[] = [
|
|
110
|
-
...documentConversionExtensions,
|
|
111
|
-
...officeNativeExtensions,
|
|
112
|
-
];
|
|
113
|
-
const fileExt = `.${file.name.split('.').pop()?.toLowerCase()}`;
|
|
114
|
-
return documentExtensions.includes(fileExt);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
// Use refs to access latest values in event handlers
|
|
118
|
-
const isMediaAcceptedRef = useRef(isMediaAccepted);
|
|
119
|
-
const currentMediaCountRef = useRef(currentMediaCount);
|
|
120
|
-
const addErrorRef = useRef(addError);
|
|
121
|
-
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
isMediaAcceptedRef.current = isMediaAccepted;
|
|
124
|
-
currentMediaCountRef.current = currentMediaCount;
|
|
125
|
-
addErrorRef.current = addError;
|
|
126
|
-
}, [isMediaAccepted, currentMediaCount, addError]);
|
|
127
|
-
|
|
128
|
-
// Handle unified file selection
|
|
129
|
-
const handleUnifiedFileSelection = useCallback(
|
|
130
|
-
(files: FileList | File[]) => {
|
|
131
|
-
const fileArray = Array.from(files);
|
|
132
|
-
if (fileArray.length === 0) return;
|
|
133
|
-
|
|
134
|
-
const supportedFiles: File[] = [];
|
|
135
|
-
fileArray.forEach(file => {
|
|
136
|
-
if (isImageFile(file)) {
|
|
137
|
-
supportedFiles.push(file);
|
|
138
|
-
} else if (isDocumentFile(file)) {
|
|
139
|
-
supportedFiles.push(file);
|
|
140
|
-
} else {
|
|
141
|
-
addErrorRef.current({
|
|
142
|
-
message: `File "${file.name}" is not a supported image or document type`,
|
|
143
|
-
severity: 'warning',
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
const totalSupported = supportedFiles.length;
|
|
149
|
-
if (totalSupported === 0) return;
|
|
150
|
-
|
|
151
|
-
const remainingSlots =
|
|
152
|
-
maxDocumentsPerMessage - currentMediaCountRef.current;
|
|
153
|
-
if (remainingSlots <= 0) {
|
|
154
|
-
addErrorRef.current({
|
|
155
|
-
message: `Maximum ${maxDocumentsPerMessage} media files allowed.`,
|
|
156
|
-
severity: 'warning',
|
|
157
|
-
});
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const toProcess = supportedFiles.slice(0, remainingSlots);
|
|
162
|
-
const imageFiles = toProcess.filter(f => isImageFile(f));
|
|
163
|
-
const documentFiles = toProcess.filter(f => isDocumentFile(f));
|
|
164
|
-
|
|
165
|
-
if (totalSupported > remainingSlots) {
|
|
166
|
-
const skipped = totalSupported - remainingSlots;
|
|
167
|
-
addErrorRef.current({
|
|
168
|
-
message:
|
|
169
|
-
t('upload.filesNotAddedMaxAllowed', {
|
|
170
|
-
count: skipped,
|
|
171
|
-
max: maxDocumentsPerMessage,
|
|
172
|
-
defaultValue: `${skipped} file(s) not added (maximum ${maxDocumentsPerMessage} files allowed).`,
|
|
173
|
-
}) ??
|
|
174
|
-
`${skipped} file(s) not added (maximum ${maxDocumentsPerMessage} files allowed).`,
|
|
175
|
-
severity: 'warning',
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Process images
|
|
180
|
-
if (imageFiles.length > 0) {
|
|
181
|
-
if (!isMediaAcceptedRef.current) {
|
|
182
|
-
addErrorRef.current({
|
|
183
|
-
message:
|
|
184
|
-
t('upload.mediaNotAccepted') ?? 'Media uploads are not accepted',
|
|
185
|
-
severity: 'warning',
|
|
186
|
-
});
|
|
187
|
-
} else {
|
|
188
|
-
// Trigger image upload by creating a synthetic event
|
|
189
|
-
const imageInput = imageRef.current?.querySelector(
|
|
190
|
-
'input[type="file"]'
|
|
191
|
-
) as HTMLInputElement;
|
|
192
|
-
if (imageInput) {
|
|
193
|
-
const dataTransfer = new DataTransfer();
|
|
194
|
-
imageFiles.forEach(file => {
|
|
195
|
-
try {
|
|
196
|
-
dataTransfer.items.add(file);
|
|
197
|
-
} catch (err) {
|
|
198
|
-
console.warn('Failed to add image file to DataTransfer:', err);
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
// Only proceed if we successfully added files
|
|
203
|
-
if (dataTransfer.files.length > 0) {
|
|
204
|
-
try {
|
|
205
|
-
imageInput.files = dataTransfer.files;
|
|
206
|
-
} catch {
|
|
207
|
-
// JSDOM and some environments do not allow assigning to input.files
|
|
208
|
-
}
|
|
209
|
-
const changeEvent = new Event('change', { bubbles: true });
|
|
210
|
-
imageInput.dispatchEvent(changeEvent);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Process documents – set loading early so skeleton shows for all entry points
|
|
217
|
-
if (documentFiles.length > 0) {
|
|
218
|
-
setIsDocumentLoading(true);
|
|
219
|
-
const documentInput = documentRef.current?.querySelector(
|
|
220
|
-
'input[type="file"]'
|
|
221
|
-
) as HTMLInputElement;
|
|
222
|
-
if (documentInput) {
|
|
223
|
-
const dataTransfer = new DataTransfer();
|
|
224
|
-
documentFiles.forEach(file => {
|
|
225
|
-
try {
|
|
226
|
-
dataTransfer.items.add(file);
|
|
227
|
-
} catch (err) {
|
|
228
|
-
console.warn('Failed to add document file to DataTransfer:', err);
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
// Only proceed if we successfully added files
|
|
233
|
-
if (dataTransfer.files.length > 0) {
|
|
234
|
-
try {
|
|
235
|
-
documentInput.files = dataTransfer.files;
|
|
236
|
-
} catch {
|
|
237
|
-
// JSDOM and some environments do not allow assigning to input.files
|
|
238
|
-
}
|
|
239
|
-
const changeEvent = new Event('change', { bubbles: true });
|
|
240
|
-
documentInput.dispatchEvent(changeEvent);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
[t]
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
// Handle button click - open file chooser directly
|
|
249
|
-
const handleButtonClick = () => {
|
|
250
|
-
if (unifiedInputRef.current) {
|
|
251
|
-
unifiedInputRef.current.click();
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// Handle file input change
|
|
256
|
-
const handleFileInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
257
|
-
const files = e.target.files;
|
|
258
|
-
if (files && files.length > 0) {
|
|
259
|
-
handleUnifiedFileSelection(files);
|
|
260
|
-
}
|
|
261
|
-
// Reset input value to allow selecting the same file again
|
|
262
|
-
if (unifiedInputRef.current) {
|
|
263
|
-
unifiedInputRef.current.value = '';
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
// Paste handler for files
|
|
268
|
-
useEffect(() => {
|
|
269
|
-
const handlePaste = (e: ClipboardEvent) => {
|
|
270
|
-
const clipboardData = e.clipboardData;
|
|
271
|
-
if (!clipboardData) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const files: File[] = [];
|
|
276
|
-
|
|
277
|
-
// Helper to check if a file is already in the array
|
|
278
|
-
const isDuplicate = (file: File) => {
|
|
279
|
-
return files.some(
|
|
280
|
-
f =>
|
|
281
|
-
f.name === file.name &&
|
|
282
|
-
f.size === file.size &&
|
|
283
|
-
f.lastModified === file.lastModified
|
|
284
|
-
);
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
// Prefer clipboardData.files if available (most reliable and prevents duplicates)
|
|
288
|
-
// Only fall back to items if files is empty (some browsers only populate items)
|
|
289
|
-
if (clipboardData.files && clipboardData.files.length > 0) {
|
|
290
|
-
const clipboardFiles = Array.from(clipboardData.files);
|
|
291
|
-
clipboardFiles.forEach(file => {
|
|
292
|
-
if (!isDuplicate(file)) {
|
|
293
|
-
files.push(file);
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
} else {
|
|
297
|
-
// Fall back to items array only if files is empty
|
|
298
|
-
// This prevents processing the same file twice when both are populated
|
|
299
|
-
const items = clipboardData.items;
|
|
300
|
-
if (items) {
|
|
301
|
-
for (let i = 0; i < items.length; i++) {
|
|
302
|
-
const item = items[i];
|
|
303
|
-
if (item.kind === 'file') {
|
|
304
|
-
const file = item.getAsFile();
|
|
305
|
-
if (file && !isDuplicate(file)) {
|
|
306
|
-
files.push(file);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (files.length > 0) {
|
|
314
|
-
e.preventDefault();
|
|
315
|
-
handleUnifiedFileSelection(files);
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
// Add paste listener to document
|
|
320
|
-
document.addEventListener('paste', handlePaste);
|
|
321
|
-
return () => {
|
|
322
|
-
document.removeEventListener('paste', handlePaste);
|
|
323
|
-
};
|
|
324
|
-
}, [handleUnifiedFileSelection]);
|
|
325
|
-
|
|
326
|
-
// Drag and drop handlers
|
|
327
|
-
useEffect(() => {
|
|
328
|
-
let dragCounter = 0;
|
|
329
|
-
|
|
330
|
-
const handleDragEnter = (e: DragEvent) => {
|
|
331
|
-
e.preventDefault();
|
|
332
|
-
e.stopPropagation();
|
|
333
|
-
dragCounter++;
|
|
334
|
-
if (dragCounter === 1) {
|
|
335
|
-
setIsDragging(true);
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
const handleDragLeave = (e: DragEvent) => {
|
|
340
|
-
e.preventDefault();
|
|
341
|
-
e.stopPropagation();
|
|
342
|
-
dragCounter--;
|
|
343
|
-
if (dragCounter === 0) {
|
|
344
|
-
setIsDragging(false);
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
const handleDragOver = (e: DragEvent) => {
|
|
349
|
-
e.preventDefault();
|
|
350
|
-
e.stopPropagation();
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
const handleDrop = (e: DragEvent) => {
|
|
354
|
-
e.preventDefault();
|
|
355
|
-
e.stopPropagation();
|
|
356
|
-
dragCounter = 0;
|
|
357
|
-
setIsDragging(false);
|
|
358
|
-
|
|
359
|
-
const files = e.dataTransfer?.files;
|
|
360
|
-
if (files && files.length > 0) {
|
|
361
|
-
handleUnifiedFileSelection(files);
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
// Add drag and drop listeners to document
|
|
366
|
-
document.addEventListener('dragenter', handleDragEnter);
|
|
367
|
-
document.addEventListener('dragleave', handleDragLeave);
|
|
368
|
-
document.addEventListener('dragover', handleDragOver);
|
|
369
|
-
document.addEventListener('drop', handleDrop);
|
|
370
|
-
|
|
371
|
-
return () => {
|
|
372
|
-
document.removeEventListener('dragenter', handleDragEnter);
|
|
373
|
-
document.removeEventListener('dragleave', handleDragLeave);
|
|
374
|
-
document.removeEventListener('dragover', handleDragOver);
|
|
375
|
-
document.removeEventListener('drop', handleDrop);
|
|
376
|
-
};
|
|
377
|
-
}, [handleUnifiedFileSelection]);
|
|
378
|
-
|
|
379
|
-
// Handler for document files - now supports multiple documents
|
|
380
|
-
const handleDocumentFiles = (
|
|
381
|
-
files: {
|
|
382
|
-
name: string;
|
|
383
|
-
id: string;
|
|
384
|
-
content: string;
|
|
385
|
-
mimeType: string;
|
|
386
|
-
textAssetUrl?: string;
|
|
387
|
-
}[]
|
|
388
|
-
) => {
|
|
389
|
-
if (files.length === 0) return;
|
|
390
|
-
|
|
391
|
-
// Funzione helper per fare escape dell'HTML nei valori degli attributi
|
|
392
|
-
const escapeAttributeValue = (text: string) => {
|
|
393
|
-
return text
|
|
394
|
-
.replace(/&/g, '&')
|
|
395
|
-
.replace(/"/g, '"')
|
|
396
|
-
.replace(/'/g, ''')
|
|
397
|
-
.replace(/</g, '<')
|
|
398
|
-
.replace(/>/g, '>');
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
// Process each document file
|
|
402
|
-
const processedDocuments = files.map(file => {
|
|
403
|
-
const escapedFileName = escapeAttributeValue(file.name);
|
|
404
|
-
|
|
405
|
-
let formattedContent: string;
|
|
406
|
-
|
|
407
|
-
if (!file.content) {
|
|
408
|
-
// Office native format: metadata-only attachment tag + asset link (no text body)
|
|
409
|
-
formattedContent = `<document_attachment filename="${escapedFileName}" type="${file.mimeType}">
|
|
410
|
-
</document_attachment>
|
|
411
|
-
|
|
412
|
-
<attachment_link>
|
|
413
|
-
${file.textAssetUrl || ''}
|
|
414
|
-
</attachment_link>`;
|
|
415
|
-
} else {
|
|
416
|
-
// Truncate only the content that gets inlined inside the message
|
|
417
|
-
// <document_attachment> tag. The full text is still available via
|
|
418
|
-
// textAssetUrl as an uploaded asset.
|
|
419
|
-
const inlinedContent =
|
|
420
|
-
file.content.length > effectivePerDocumentLimit
|
|
421
|
-
? file.content.substring(0, effectivePerDocumentLimit) +
|
|
422
|
-
'\n\n[Content truncated due to size limits]'
|
|
423
|
-
: file.content;
|
|
424
|
-
|
|
425
|
-
formattedContent = `<document_attachment filename="${escapedFileName}" type="${
|
|
426
|
-
file.mimeType
|
|
427
|
-
}">
|
|
428
|
-
|
|
429
|
-
${inlinedContent}
|
|
430
|
-
|
|
431
|
-
</document_attachment>
|
|
432
|
-
|
|
433
|
-
<attachment_link>
|
|
434
|
-
${file.textAssetUrl || ''}
|
|
435
|
-
</attachment_link>`;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
return {
|
|
439
|
-
name: file.name,
|
|
440
|
-
id: file.id,
|
|
441
|
-
content: formattedContent,
|
|
442
|
-
type: 'document',
|
|
443
|
-
mimeType: file.mimeType,
|
|
444
|
-
url: file.textAssetUrl,
|
|
445
|
-
};
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
// Append new documents to existing files (images + previous documents)
|
|
449
|
-
setDocumentPreviewFiles((prev: any[]) => [...prev, ...processedDocuments]);
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
// Document validation and error handling
|
|
453
|
-
const validateDocumentFile = (file: File): boolean => {
|
|
454
|
-
const fileExt = `.${file.name.split('.').pop()?.toLowerCase()}`;
|
|
455
|
-
const ALLOWED_FILE_TYPES: readonly string[] = [
|
|
456
|
-
...documentConversionExtensions,
|
|
457
|
-
...officeNativeExtensions,
|
|
458
|
-
];
|
|
459
|
-
const MAX_FILE_SIZE = 25 * 1024 * 1024;
|
|
460
|
-
|
|
461
|
-
if (!ALLOWED_FILE_TYPES.includes(fileExt)) {
|
|
462
|
-
addError({
|
|
463
|
-
message: `File type "${fileExt}" is not supported. Please use: ${ALLOWED_FILE_TYPES.join(
|
|
464
|
-
', '
|
|
465
|
-
)}`,
|
|
466
|
-
severity: 'warning',
|
|
467
|
-
});
|
|
468
|
-
return false;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
if (file.size > MAX_FILE_SIZE) {
|
|
472
|
-
addError({
|
|
473
|
-
message: `File "${file.name}" exceeds ${
|
|
474
|
-
MAX_FILE_SIZE / 1024 / 1024
|
|
475
|
-
}MB limit`,
|
|
476
|
-
severity: 'warning',
|
|
477
|
-
});
|
|
478
|
-
return false;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
return true;
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
// Validate total payload size. Returns result so caller can avoid showing this error when truncation was already shown.
|
|
485
|
-
const validatePayloadSize = (
|
|
486
|
-
_newDocuments: {
|
|
487
|
-
name: string;
|
|
488
|
-
id: string;
|
|
489
|
-
content: string;
|
|
490
|
-
mimeType: string;
|
|
491
|
-
}[]
|
|
492
|
-
): { valid: boolean; message?: string } => {
|
|
493
|
-
return { valid: true };
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
// Handle document upload errors
|
|
497
|
-
const handleDocumentError = (error: {
|
|
498
|
-
message: string;
|
|
499
|
-
severity: 'error' | 'warning' | 'info';
|
|
500
|
-
}) => {
|
|
501
|
-
addError(error);
|
|
502
|
-
};
|
|
503
|
-
|
|
504
|
-
// Image validation and error handling
|
|
505
|
-
const validateImageFile = (file: File): boolean => {
|
|
506
|
-
const fileExt = `.${file.name.split('.').pop()?.toLowerCase()}`;
|
|
507
|
-
const ALLOWED_FILE_TYPES = ['.jpg', '.jpeg', '.png'];
|
|
508
|
-
const MAX_FILE_SIZE = 15 * 1024 * 1024; // 15MB
|
|
509
|
-
|
|
510
|
-
if (
|
|
511
|
-
!ALLOWED_FILE_TYPES.includes(fileExt) &&
|
|
512
|
-
!file.type.startsWith('image/')
|
|
513
|
-
) {
|
|
514
|
-
addError({
|
|
515
|
-
message: `File type "${fileExt}" is not supported. Please use: ${ALLOWED_FILE_TYPES.join(
|
|
516
|
-
', '
|
|
517
|
-
)}`,
|
|
518
|
-
severity: 'warning',
|
|
519
|
-
});
|
|
520
|
-
return false;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
if (file.size > MAX_FILE_SIZE) {
|
|
524
|
-
addError({
|
|
525
|
-
message: `File "${file.name}" exceeds ${
|
|
526
|
-
MAX_FILE_SIZE / 1024 / 1024
|
|
527
|
-
}MB limit`,
|
|
528
|
-
severity: 'warning',
|
|
529
|
-
});
|
|
530
|
-
return false;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
return true;
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
// Handle image upload errors
|
|
537
|
-
const handleImageError = (error: {
|
|
538
|
-
message: string;
|
|
539
|
-
severity: 'error' | 'warning' | 'info';
|
|
540
|
-
}) => {
|
|
541
|
-
addError(error);
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
const handleDocumentLoadingChange = useCallback(
|
|
545
|
-
(loading: boolean, fileCount?: number) => {
|
|
546
|
-
setIsDocumentLoading(loading);
|
|
547
|
-
setDocUploadingCount(loading ? fileCount ?? 1 : 0);
|
|
548
|
-
},
|
|
549
|
-
[]
|
|
550
|
-
);
|
|
551
|
-
const handleImageLoadingChange = useCallback(
|
|
552
|
-
(loading: boolean, fileCount?: number) => {
|
|
553
|
-
setIsImageLoading(loading);
|
|
554
|
-
setImgUploadingCount(loading ? fileCount ?? 1 : 0);
|
|
555
|
-
},
|
|
556
|
-
[]
|
|
557
|
-
);
|
|
558
|
-
|
|
559
|
-
useEffect(() => {
|
|
560
|
-
onUploadLoadingChange?.(isLoading, isLoading ? uploadingFileCount : 0);
|
|
561
|
-
}, [isLoading, uploadingFileCount, onUploadLoadingChange]);
|
|
562
|
-
|
|
563
|
-
return (
|
|
564
|
-
<div
|
|
565
|
-
className={cx('memori--unified-upload-wrapper', {
|
|
566
|
-
'memori--dragging': isDragging,
|
|
567
|
-
})}
|
|
568
|
-
ref={wrapperRef}
|
|
569
|
-
>
|
|
570
|
-
{/* Unified file input - accepts both images and documents */}
|
|
571
|
-
<input
|
|
572
|
-
ref={unifiedInputRef}
|
|
573
|
-
type="file"
|
|
574
|
-
accept={[
|
|
575
|
-
'.jpg',
|
|
576
|
-
'.jpeg',
|
|
577
|
-
'.png',
|
|
578
|
-
...documentConversionExtensions,
|
|
579
|
-
...officeNativeExtensions,
|
|
580
|
-
].join(',')}
|
|
581
|
-
multiple
|
|
582
|
-
className="memori--upload-file-input"
|
|
583
|
-
onChange={handleFileInputChange}
|
|
584
|
-
style={{ display: 'none' }}
|
|
585
|
-
/>
|
|
586
|
-
|
|
587
|
-
{/* Main upload button */}
|
|
588
|
-
<button
|
|
589
|
-
ref={buttonRef}
|
|
590
|
-
className={cx(
|
|
591
|
-
'memori-button',
|
|
592
|
-
'memori-button--circle',
|
|
593
|
-
'memori-button--icon-only',
|
|
594
|
-
'memori-share-button--button',
|
|
595
|
-
'memori--conversation-button',
|
|
596
|
-
'memori--unified-upload-button',
|
|
597
|
-
{ 'memori--error': errors.length > 0 }
|
|
598
|
-
)}
|
|
599
|
-
onClick={handleButtonClick}
|
|
600
|
-
disabled={isLoading || hasReachedMediaLimit}
|
|
601
|
-
title={
|
|
602
|
-
t('upload.uploadFiles', {
|
|
603
|
-
shortcut:
|
|
604
|
-
/Mac|iPhone|iPod|iPad/i.test(navigator.platform) ||
|
|
605
|
-
navigator.userAgent.includes('Mac')
|
|
606
|
-
? 'Cmd'
|
|
607
|
-
: 'Ctrl',
|
|
608
|
-
}) ?? 'Upload files (drag & drop)'
|
|
609
|
-
}
|
|
610
|
-
>
|
|
611
|
-
{isLoading ? (
|
|
612
|
-
<Spin spinning className="memori--upload-icon" />
|
|
613
|
-
) : (
|
|
614
|
-
<UploadIcon className="memori--upload-icon" />
|
|
615
|
-
)}
|
|
616
|
-
</button>
|
|
617
|
-
|
|
618
|
-
{/* Media count indicator */}
|
|
619
|
-
{currentMediaCount > 0 && (
|
|
620
|
-
<div
|
|
621
|
-
className={cx('memori--document-count', {
|
|
622
|
-
'memori--document-count-full': hasReachedMediaLimit,
|
|
623
|
-
})}
|
|
624
|
-
>
|
|
625
|
-
{currentMediaCount}/{maxDocumentsPerMessage}
|
|
626
|
-
</div>
|
|
627
|
-
)}
|
|
628
|
-
|
|
629
|
-
{/* Hidden components */}
|
|
630
|
-
<div className="memori--hidden-uploader" ref={documentRef}>
|
|
631
|
-
<UploadDocuments
|
|
632
|
-
setDocumentPreviewFiles={handleDocumentFiles}
|
|
633
|
-
authToken={authToken}
|
|
634
|
-
client={client}
|
|
635
|
-
sessionID={sessionID}
|
|
636
|
-
baseUrl={baseUrl}
|
|
637
|
-
memoriID={memoriID}
|
|
638
|
-
maxDocuments={maxDocumentsPerMessage}
|
|
639
|
-
documentPreviewFiles={documentPreviewFiles}
|
|
640
|
-
onLoadingChange={handleDocumentLoadingChange}
|
|
641
|
-
onDocumentError={handleDocumentError}
|
|
642
|
-
onValidateFile={validateDocumentFile}
|
|
643
|
-
onValidatePayloadSize={validatePayloadSize}
|
|
644
|
-
/>
|
|
645
|
-
</div>
|
|
646
|
-
|
|
647
|
-
<div className="memori--hidden-uploader" ref={imageRef}>
|
|
648
|
-
<UploadImages
|
|
649
|
-
authToken={authToken}
|
|
650
|
-
client={client}
|
|
651
|
-
setDocumentPreviewFiles={setDocumentPreviewFiles}
|
|
652
|
-
sessionID={sessionID}
|
|
653
|
-
documentPreviewFiles={documentPreviewFiles}
|
|
654
|
-
isMediaAccepted={isMediaAccepted}
|
|
655
|
-
onLoadingChange={handleImageLoadingChange}
|
|
656
|
-
maxImages={maxDocumentsPerMessage}
|
|
657
|
-
memoriID={memoriID}
|
|
658
|
-
onImageError={handleImageError}
|
|
659
|
-
onValidateImageFile={validateImageFile}
|
|
660
|
-
/>
|
|
661
|
-
</div>
|
|
662
|
-
|
|
663
|
-
{/* Error messages container */}
|
|
664
|
-
<div className="memori--error-message-container">
|
|
665
|
-
{errors.map((error, index) => (
|
|
666
|
-
<Alert
|
|
667
|
-
className="memori--error-message-alert"
|
|
668
|
-
key={`${error.message}-${index}`}
|
|
669
|
-
open={true}
|
|
670
|
-
type={error.severity}
|
|
671
|
-
title={t('upload.uploadNotification', {
|
|
672
|
-
defaultValue: 'Upload notification',
|
|
673
|
-
})}
|
|
674
|
-
description={error.message}
|
|
675
|
-
onClose={() => removeError(error.message)}
|
|
676
|
-
width="350px"
|
|
677
|
-
/>
|
|
678
|
-
))}
|
|
679
|
-
</div>
|
|
680
|
-
</div>
|
|
681
|
-
);
|
|
682
|
-
};
|
|
683
|
-
|
|
684
|
-
export default UploadButton;
|