@memori.ai/memori-react 7.11.3 → 7.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +2 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js +52 -75
- package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/AnimationController.js +2 -2
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/AnimationController.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.d.ts +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +8 -2
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/types.d.ts +1 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/MorphTargetController.js +6 -3
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/MorphTargetController.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/PositionController.js +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/PositionController.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controls.d.ts +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controls.js +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controls.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +74 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js +101 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -0
- package/dist/components/Chat/Chat.d.ts +10 -1
- package/dist/components/Chat/Chat.js +2 -10
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.css +4 -0
- package/dist/components/ChatBubble/ChatBubble.js +14 -4
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/ChatInputs/ChatInputs.d.ts +11 -2
- package/dist/components/ChatInputs/ChatInputs.js +44 -6
- package/dist/components/ChatInputs/ChatInputs.js.map +1 -1
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.css +8 -0
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js +75 -51
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
- package/dist/components/ExpertsDrawer/ExpertsDrawer.js +1 -1
- package/dist/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
- package/dist/components/FilePreview/FilePreview.css +155 -0
- package/dist/components/FilePreview/FilePreview.d.ts +12 -0
- package/dist/components/FilePreview/FilePreview.js +21 -0
- package/dist/components/FilePreview/FilePreview.js.map +1 -0
- package/dist/components/MemoriWidget/MemoriWidget.d.ts +3 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +26 -11
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/UploadButton/UploadButton.css +38 -0
- package/dist/components/UploadButton/UploadButton.d.ts +8 -0
- package/dist/components/UploadButton/UploadButton.js +79 -0
- package/dist/components/UploadButton/UploadButton.js.map +1 -0
- package/dist/components/icons/Preview.d.ts +5 -0
- package/dist/components/icons/Preview.js +6 -0
- package/dist/components/icons/Preview.js.map +1 -0
- package/dist/components/icons/Upload.d.ts +5 -0
- package/dist/components/icons/Upload.js +6 -0
- package/dist/components/icons/Upload.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js +52 -75
- package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/AnimationController.js +2 -2
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/AnimationController.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.d.ts +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +8 -2
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/types.d.ts +1 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/MorphTargetController.js +6 -3
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/MorphTargetController.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/PositionController.js +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/PositionController.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controls.d.ts +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controls.js +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controls.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +74 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js +98 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -0
- package/esm/components/Chat/Chat.d.ts +10 -1
- package/esm/components/Chat/Chat.js +2 -10
- package/esm/components/Chat/Chat.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.css +4 -0
- package/esm/components/ChatBubble/ChatBubble.js +14 -4
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/ChatInputs/ChatInputs.d.ts +11 -2
- package/esm/components/ChatInputs/ChatInputs.js +45 -7
- package/esm/components/ChatInputs/ChatInputs.js.map +1 -1
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.css +8 -0
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js +76 -52
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
- package/esm/components/ExpertsDrawer/ExpertsDrawer.js +1 -1
- package/esm/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
- package/esm/components/FilePreview/FilePreview.css +155 -0
- package/esm/components/FilePreview/FilePreview.d.ts +12 -0
- package/esm/components/FilePreview/FilePreview.js +18 -0
- package/esm/components/FilePreview/FilePreview.js.map +1 -0
- package/esm/components/MemoriWidget/MemoriWidget.d.ts +3 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +26 -11
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/UploadButton/UploadButton.css +38 -0
- package/esm/components/UploadButton/UploadButton.d.ts +8 -0
- package/esm/components/UploadButton/UploadButton.js +76 -0
- package/esm/components/UploadButton/UploadButton.js.map +1 -0
- package/esm/components/icons/Preview.d.ts +5 -0
- package/esm/components/icons/Preview.js +4 -0
- package/esm/components/icons/Preview.js.map +1 -0
- package/esm/components/icons/Upload.d.ts +5 -0
- package/esm/components/icons/Upload.js +4 -0
- package/esm/components/icons/Upload.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +3 -2
- package/esm/index.js.map +1 -1
- package/esm/styles.css +2 -0
- package/package.json +2 -1
- package/src/components/Avatar/AvatarView/AvatarComponent/avatarComponent.tsx +120 -153
- package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/AnimationController.ts +3 -6
- package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.tsx +11 -1
- package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/types.ts +1 -0
- package/src/components/Avatar/AvatarView/AvatarComponent/components/MorphTargetController.ts +33 -10
- package/src/components/Avatar/AvatarView/AvatarComponent/components/PositionController.ts +1 -1
- package/src/components/Avatar/AvatarView/AvatarComponent/components/controls.tsx +2 -2
- package/src/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.tsx +1 -1
- package/src/components/Avatar/AvatarView/AvatarComponent/constants.ts +127 -0
- package/src/components/Chat/Chat.tsx +16 -10
- package/src/components/ChatBubble/ChatBubble.css +4 -0
- package/src/components/ChatBubble/ChatBubble.stories.tsx +12 -0
- package/src/components/ChatBubble/ChatBubble.tsx +23 -2
- package/src/components/ChatInputs/ChatInputs.stories.tsx +5 -0
- package/src/components/ChatInputs/ChatInputs.test.tsx +6 -6
- package/src/components/ChatInputs/ChatInputs.tsx +91 -23
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.css +8 -0
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.stories.tsx +1 -1
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx +95 -66
- package/src/components/ExpertsDrawer/ExpertsDrawer.tsx +3 -1
- package/src/components/FilePreview/FilePreview.css +155 -0
- package/src/components/FilePreview/FilePreview.stories.tsx +66 -0
- package/src/components/FilePreview/FilePreview.test.tsx +26 -0
- package/src/components/FilePreview/FilePreview.tsx +85 -0
- package/src/components/FilePreview/__snapshots__/FilePreview.test.tsx.snap +149 -0
- package/src/components/MemoriWidget/MemoriWidget.tsx +68 -3
- package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +240 -0
- package/src/components/UploadButton/UploadButton.css +38 -0
- package/src/components/UploadButton/UploadButton.stories.tsx +62 -0
- package/src/components/UploadButton/UploadButton.test.tsx +11 -0
- package/src/components/UploadButton/UploadButton.tsx +126 -0
- package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +31 -0
- package/src/components/icons/Preview.tsx +23 -0
- package/src/components/icons/Upload.tsx +23 -0
- package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +24 -0
- package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +24 -0
- package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +24 -0
- package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +24 -0
- package/src/components/layouts/layouts.stories.tsx +30 -46
- package/src/index.stories.tsx +68 -2
- package/src/index.tsx +4 -0
- package/src/styles.css +2 -0
- package/src/components/Avatar/AvatarView/AvatarComponent/components/constants.ts +0 -29
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PreviewIcon from '../icons/Preview';
|
|
3
|
+
import CloseIcon from '../icons/Close';
|
|
4
|
+
import Button from '../ui/Button';
|
|
5
|
+
import Modal from '../ui/Modal';
|
|
6
|
+
|
|
7
|
+
type FilePreviewProps = {
|
|
8
|
+
previewFiles: { name: string; id: string; content: string }[];
|
|
9
|
+
removeFile: (id: string) => void;
|
|
10
|
+
allowRemove?: boolean;
|
|
11
|
+
isMessagePreview?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const FilePreview = ({
|
|
15
|
+
previewFiles,
|
|
16
|
+
removeFile,
|
|
17
|
+
allowRemove = true,
|
|
18
|
+
isMessagePreview = false,
|
|
19
|
+
}: FilePreviewProps) => {
|
|
20
|
+
const [selectedFile, setSelectedFile] = useState<{
|
|
21
|
+
name: string;
|
|
22
|
+
content: string;
|
|
23
|
+
} | null>(null);
|
|
24
|
+
const [hoveredId, setHoveredId] = useState<string | null>(null);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
{previewFiles.length > 0 && (
|
|
29
|
+
<div
|
|
30
|
+
className={`memori--preview-container ${
|
|
31
|
+
isMessagePreview
|
|
32
|
+
? 'memori--message-preview'
|
|
33
|
+
: 'memori--absolute-preview'
|
|
34
|
+
}`}
|
|
35
|
+
>
|
|
36
|
+
<div className="memori--preview-list">
|
|
37
|
+
{previewFiles.map(file => (
|
|
38
|
+
<div
|
|
39
|
+
key={file.id}
|
|
40
|
+
className="memori--preview-item"
|
|
41
|
+
onMouseEnter={() => setHoveredId(file.id)}
|
|
42
|
+
onMouseLeave={() => setHoveredId(null)}
|
|
43
|
+
onClick={() => setSelectedFile(file)}
|
|
44
|
+
>
|
|
45
|
+
<PreviewIcon className="memori--preview-icon" />
|
|
46
|
+
<span className="memori--preview-filename">{file.name}</span>
|
|
47
|
+
|
|
48
|
+
{allowRemove && (
|
|
49
|
+
<Button
|
|
50
|
+
shape="rounded"
|
|
51
|
+
icon={<CloseIcon />}
|
|
52
|
+
danger
|
|
53
|
+
className={`memori--remove-button ${
|
|
54
|
+
hoveredId === file.id ? 'visible' : ''
|
|
55
|
+
}`}
|
|
56
|
+
onClick={e => {
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
removeFile(file.id);
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
)}
|
|
62
|
+
</div>
|
|
63
|
+
))}
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
|
|
68
|
+
<Modal
|
|
69
|
+
width="80%"
|
|
70
|
+
widthMd="80%"
|
|
71
|
+
open={!!selectedFile}
|
|
72
|
+
className="memori--modal-preview-file"
|
|
73
|
+
onClose={() => setSelectedFile(null)}
|
|
74
|
+
closable
|
|
75
|
+
title={selectedFile?.name}
|
|
76
|
+
>
|
|
77
|
+
<div className="memori--preview-content" style={{ whiteSpace: 'pre-wrap', maxHeight: '70vh', overflowY: 'auto' }}>
|
|
78
|
+
{selectedFile?.content}
|
|
79
|
+
</div>
|
|
80
|
+
</Modal>
|
|
81
|
+
</>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default FilePreview;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`renders FilePreview unchanged 1`] = `<div />`;
|
|
4
|
+
|
|
5
|
+
exports[`renders FilePreview with one file 1`] = `
|
|
6
|
+
<div>
|
|
7
|
+
<div
|
|
8
|
+
class="memori--preview-container memori--absolute-preview"
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
class="memori--preview-list"
|
|
12
|
+
>
|
|
13
|
+
<div
|
|
14
|
+
class="memori--preview-item"
|
|
15
|
+
>
|
|
16
|
+
<svg
|
|
17
|
+
aria-hidden="true"
|
|
18
|
+
class="memori--preview-icon"
|
|
19
|
+
focusable="false"
|
|
20
|
+
role="img"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
23
|
+
>
|
|
24
|
+
<path
|
|
25
|
+
d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"
|
|
26
|
+
/>
|
|
27
|
+
</svg>
|
|
28
|
+
<span
|
|
29
|
+
class="memori--preview-filename"
|
|
30
|
+
>
|
|
31
|
+
test.pdf
|
|
32
|
+
</span>
|
|
33
|
+
<button
|
|
34
|
+
class="memori-button memori-button--rounded memori-button--padded memori-button--icon-only memori-button--danger memori--remove-button "
|
|
35
|
+
>
|
|
36
|
+
<span
|
|
37
|
+
class="memori-button--icon"
|
|
38
|
+
>
|
|
39
|
+
<svg
|
|
40
|
+
aria-hidden="true"
|
|
41
|
+
focusable="false"
|
|
42
|
+
role="img"
|
|
43
|
+
viewBox="0 0 1024 1024"
|
|
44
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
45
|
+
>
|
|
46
|
+
<path
|
|
47
|
+
d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"
|
|
48
|
+
/>
|
|
49
|
+
</svg>
|
|
50
|
+
</span>
|
|
51
|
+
</button>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
exports[`renders FilePreview with two files 1`] = `
|
|
59
|
+
<div>
|
|
60
|
+
<div
|
|
61
|
+
class="memori--preview-container memori--absolute-preview"
|
|
62
|
+
>
|
|
63
|
+
<div
|
|
64
|
+
class="memori--preview-list"
|
|
65
|
+
>
|
|
66
|
+
<div
|
|
67
|
+
class="memori--preview-item"
|
|
68
|
+
>
|
|
69
|
+
<svg
|
|
70
|
+
aria-hidden="true"
|
|
71
|
+
class="memori--preview-icon"
|
|
72
|
+
focusable="false"
|
|
73
|
+
role="img"
|
|
74
|
+
viewBox="0 0 24 24"
|
|
75
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
76
|
+
>
|
|
77
|
+
<path
|
|
78
|
+
d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"
|
|
79
|
+
/>
|
|
80
|
+
</svg>
|
|
81
|
+
<span
|
|
82
|
+
class="memori--preview-filename"
|
|
83
|
+
>
|
|
84
|
+
test.pdf
|
|
85
|
+
</span>
|
|
86
|
+
<button
|
|
87
|
+
class="memori-button memori-button--rounded memori-button--padded memori-button--icon-only memori-button--danger memori--remove-button "
|
|
88
|
+
>
|
|
89
|
+
<span
|
|
90
|
+
class="memori-button--icon"
|
|
91
|
+
>
|
|
92
|
+
<svg
|
|
93
|
+
aria-hidden="true"
|
|
94
|
+
focusable="false"
|
|
95
|
+
role="img"
|
|
96
|
+
viewBox="0 0 1024 1024"
|
|
97
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
98
|
+
>
|
|
99
|
+
<path
|
|
100
|
+
d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"
|
|
101
|
+
/>
|
|
102
|
+
</svg>
|
|
103
|
+
</span>
|
|
104
|
+
</button>
|
|
105
|
+
</div>
|
|
106
|
+
<div
|
|
107
|
+
class="memori--preview-item"
|
|
108
|
+
>
|
|
109
|
+
<svg
|
|
110
|
+
aria-hidden="true"
|
|
111
|
+
class="memori--preview-icon"
|
|
112
|
+
focusable="false"
|
|
113
|
+
role="img"
|
|
114
|
+
viewBox="0 0 24 24"
|
|
115
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
116
|
+
>
|
|
117
|
+
<path
|
|
118
|
+
d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"
|
|
119
|
+
/>
|
|
120
|
+
</svg>
|
|
121
|
+
<span
|
|
122
|
+
class="memori--preview-filename"
|
|
123
|
+
>
|
|
124
|
+
test.pdf
|
|
125
|
+
</span>
|
|
126
|
+
<button
|
|
127
|
+
class="memori-button memori-button--rounded memori-button--padded memori-button--icon-only memori-button--danger memori--remove-button "
|
|
128
|
+
>
|
|
129
|
+
<span
|
|
130
|
+
class="memori-button--icon"
|
|
131
|
+
>
|
|
132
|
+
<svg
|
|
133
|
+
aria-hidden="true"
|
|
134
|
+
focusable="false"
|
|
135
|
+
role="img"
|
|
136
|
+
viewBox="0 0 1024 1024"
|
|
137
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
138
|
+
>
|
|
139
|
+
<path
|
|
140
|
+
d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"
|
|
141
|
+
/>
|
|
142
|
+
</svg>
|
|
143
|
+
</span>
|
|
144
|
+
</button>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
`;
|
|
@@ -123,6 +123,15 @@ type MemoriTextEnteredEvent = CustomEvent<{
|
|
|
123
123
|
hasBatchQueued?: boolean;
|
|
124
124
|
}>;
|
|
125
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Dispatches a MemoriTextEntered event to simulate a user typing a message
|
|
128
|
+
* @param message The text message to send
|
|
129
|
+
* @param waitForPrevious Whether to wait for previous message to finish before sending (default true)
|
|
130
|
+
* @param hidden Whether to hide the message from chat history (default false)
|
|
131
|
+
* @param typingText Optional custom typing indicator text
|
|
132
|
+
* @param useLoaderTextAsMsg Whether to use the loader text as the message (default false)
|
|
133
|
+
* @param hasBatchQueued Whether there are more messages queued to be sent (default false)
|
|
134
|
+
*/
|
|
126
135
|
const typeMessage = (
|
|
127
136
|
message: string,
|
|
128
137
|
waitForPrevious = true,
|
|
@@ -143,17 +152,24 @@ const typeMessage = (
|
|
|
143
152
|
});
|
|
144
153
|
document.dispatchEvent(e);
|
|
145
154
|
|
|
155
|
+
// Special handling for Safari on iOS devices
|
|
146
156
|
const isSafariIOS =
|
|
147
157
|
window.navigator.userAgent.includes('Safari') &&
|
|
148
158
|
!window.navigator.userAgent.includes('Chrome') &&
|
|
149
159
|
/iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
150
160
|
|
|
151
161
|
if (isSafariIOS) {
|
|
162
|
+
// Dispatch end speak event after short delay for iOS Safari
|
|
152
163
|
setTimeout(() => {
|
|
153
164
|
document.dispatchEvent(new CustomEvent('MemoriEndSpeak'));
|
|
154
165
|
}, 300);
|
|
155
166
|
}
|
|
156
167
|
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Helper function to send a hidden message
|
|
171
|
+
* Wraps typeMessage with hidden=true and passes through other params
|
|
172
|
+
*/
|
|
157
173
|
const typeMessageHidden = (
|
|
158
174
|
message: string,
|
|
159
175
|
waitForPrevious = true,
|
|
@@ -334,6 +350,7 @@ export interface LayoutProps {
|
|
|
334
350
|
sessionId?: string;
|
|
335
351
|
hasUserActivatedSpeak?: boolean;
|
|
336
352
|
showInstruct?: boolean;
|
|
353
|
+
showUpload?: boolean;
|
|
337
354
|
loading?: boolean;
|
|
338
355
|
}
|
|
339
356
|
|
|
@@ -367,6 +384,7 @@ export interface Props {
|
|
|
367
384
|
showOnlyLastMessages?: boolean;
|
|
368
385
|
showTypingText?: boolean;
|
|
369
386
|
showLogin?: boolean;
|
|
387
|
+
showUpload?: boolean;
|
|
370
388
|
preview?: boolean;
|
|
371
389
|
embed?: boolean;
|
|
372
390
|
height?: number | string;
|
|
@@ -421,6 +439,7 @@ const MemoriWidget = ({
|
|
|
421
439
|
showTypingText = false,
|
|
422
440
|
showClear = false,
|
|
423
441
|
showLogin = false,
|
|
442
|
+
showUpload = false,
|
|
424
443
|
showOnlyLastMessages,
|
|
425
444
|
height = '100vh',
|
|
426
445
|
secret,
|
|
@@ -718,6 +737,18 @@ const MemoriWidget = ({
|
|
|
718
737
|
},
|
|
719
738
|
]);
|
|
720
739
|
};
|
|
740
|
+
/**
|
|
741
|
+
* Sends a message to the Memori and handles the response
|
|
742
|
+
* @param text The text message to send
|
|
743
|
+
* @param media Optional media attachments
|
|
744
|
+
* @param newSessionId Optional new session ID to use
|
|
745
|
+
* @param translate Whether to translate the message before sending (default true)
|
|
746
|
+
* @param translatedText Optional pre-translated text
|
|
747
|
+
* @param hidden Whether to hide the message from chat history (default false)
|
|
748
|
+
* @param typingText Optional custom typing indicator text
|
|
749
|
+
* @param useLoaderTextAsMsg Whether to use the loader text as the message (default false)
|
|
750
|
+
* @param hasBatchQueued Whether there are more messages queued to be sent (default false)
|
|
751
|
+
*/
|
|
721
752
|
const sendMessage = async (
|
|
722
753
|
text: string,
|
|
723
754
|
media?: Medium[],
|
|
@@ -729,12 +760,14 @@ const MemoriWidget = ({
|
|
|
729
760
|
useLoaderTextAsMsg = false,
|
|
730
761
|
hasBatchQueued = false
|
|
731
762
|
) => {
|
|
763
|
+
// Get the session ID from params or global state
|
|
732
764
|
const sessionID =
|
|
733
765
|
newSessionId ||
|
|
734
766
|
sessionId ||
|
|
735
767
|
(window.getMemoriState() as MemoriSession)?.sessionID;
|
|
736
768
|
if (!sessionID || !text?.length) return;
|
|
737
769
|
|
|
770
|
+
// Add user message to chat history if not hidden
|
|
738
771
|
if (!hidden)
|
|
739
772
|
pushMessage({
|
|
740
773
|
text: text,
|
|
@@ -746,6 +779,7 @@ const MemoriWidget = ({
|
|
|
746
779
|
: !!newSessionId,
|
|
747
780
|
});
|
|
748
781
|
|
|
782
|
+
// Show typing indicator
|
|
749
783
|
setMemoriTyping(true);
|
|
750
784
|
setTypingText(typingText);
|
|
751
785
|
|
|
@@ -753,6 +787,7 @@ const MemoriWidget = ({
|
|
|
753
787
|
let gotError = false;
|
|
754
788
|
|
|
755
789
|
try {
|
|
790
|
+
// Translate message if needed
|
|
756
791
|
if (
|
|
757
792
|
!hidden &&
|
|
758
793
|
translate &&
|
|
@@ -769,6 +804,10 @@ const MemoriWidget = ({
|
|
|
769
804
|
msg = translation.text;
|
|
770
805
|
}
|
|
771
806
|
|
|
807
|
+
if (media?.length && media[0]?.properties?.isAttachedFile) {
|
|
808
|
+
msg = msg + ' ' + media[0].content;
|
|
809
|
+
}
|
|
810
|
+
|
|
772
811
|
const { currentState, ...response } = await postTextEnteredEvent({
|
|
773
812
|
sessionId: sessionID,
|
|
774
813
|
text: msg,
|
|
@@ -778,6 +817,7 @@ const MemoriWidget = ({
|
|
|
778
817
|
useLoaderTextAsMsg && typingText
|
|
779
818
|
? typingText
|
|
780
819
|
: currentState.emission ?? currentDialogState?.emission;
|
|
820
|
+
|
|
781
821
|
if (currentState.state === 'X4' && memori.giverTag) {
|
|
782
822
|
const { currentState, ...resp } = await postTagChangedEvent(
|
|
783
823
|
sessionID,
|
|
@@ -892,10 +932,10 @@ const MemoriWidget = ({
|
|
|
892
932
|
}
|
|
893
933
|
}
|
|
894
934
|
} else if (response.resultCode === 404) {
|
|
935
|
+
// Handle expired session
|
|
895
936
|
// remove last sent message, will set it as initial
|
|
896
937
|
setHistory(h => [...h.slice(0, h.length - 1)]);
|
|
897
938
|
|
|
898
|
-
// post session timeout -> Z0/A0 -> restart session and re-send msg
|
|
899
939
|
reopenSession(
|
|
900
940
|
false,
|
|
901
941
|
memoriPwd || memori.secretToken,
|
|
@@ -2515,6 +2555,8 @@ const MemoriWidget = ({
|
|
|
2515
2555
|
? true
|
|
2516
2556
|
: integrationConfig?.showAIicon;
|
|
2517
2557
|
|
|
2558
|
+
const enableUpload = showUpload ?? integrationConfig?.showUpload ?? false;
|
|
2559
|
+
|
|
2518
2560
|
const showWhyThisAnswer =
|
|
2519
2561
|
integrationConfig?.showWhyThisAnswer === undefined
|
|
2520
2562
|
? true
|
|
@@ -3297,6 +3339,7 @@ const MemoriWidget = ({
|
|
|
3297
3339
|
showDates,
|
|
3298
3340
|
showContextPerLine,
|
|
3299
3341
|
showAIicon,
|
|
3342
|
+
showUpload: enableUpload,
|
|
3300
3343
|
showWhyThisAnswer,
|
|
3301
3344
|
showCopyButton,
|
|
3302
3345
|
showTranslationOriginal,
|
|
@@ -3313,10 +3356,32 @@ const MemoriWidget = ({
|
|
|
3313
3356
|
showMicrophone: !!AZURE_COGNITIVE_SERVICES_TTS_KEY,
|
|
3314
3357
|
userMessage,
|
|
3315
3358
|
onChangeUserMessage,
|
|
3316
|
-
sendMessage: (
|
|
3359
|
+
sendMessage: (
|
|
3360
|
+
msg: string,
|
|
3361
|
+
media?: {
|
|
3362
|
+
mediumID: string;
|
|
3363
|
+
mimeType: string;
|
|
3364
|
+
content: string;
|
|
3365
|
+
title?: string;
|
|
3366
|
+
properties?: { [key: string]: any };
|
|
3367
|
+
}
|
|
3368
|
+
) => {
|
|
3317
3369
|
stopAudio();
|
|
3318
3370
|
stopListening();
|
|
3319
|
-
sendMessage(
|
|
3371
|
+
sendMessage(
|
|
3372
|
+
msg,
|
|
3373
|
+
media
|
|
3374
|
+
? [
|
|
3375
|
+
{
|
|
3376
|
+
mediumID: media.mediumID,
|
|
3377
|
+
mimeType: media.mimeType,
|
|
3378
|
+
content: media.content,
|
|
3379
|
+
title: media.title,
|
|
3380
|
+
properties: media.properties,
|
|
3381
|
+
},
|
|
3382
|
+
]
|
|
3383
|
+
: undefined
|
|
3384
|
+
);
|
|
3320
3385
|
setUserMessage('');
|
|
3321
3386
|
resetTranscript();
|
|
3322
3387
|
},
|