@memori.ai/memori-react 8.12.0 → 8.13.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.
Files changed (135) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/components/Chat/Chat.css +37 -3
  3. package/dist/components/Chat/Chat.js +60 -22
  4. package/dist/components/Chat/Chat.js.map +1 -1
  5. package/dist/components/ChatBubble/ChatBubble.css +9 -5
  6. package/dist/components/ChatBubble/ChatBubble.js +54 -11
  7. package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
  8. package/dist/components/ChatInputs/ChatInputs.css +293 -17
  9. package/dist/components/ChatInputs/ChatInputs.js +41 -25
  10. package/dist/components/ChatInputs/ChatInputs.js.map +1 -1
  11. package/dist/components/ChatTextArea/ChatTextArea.css +75 -31
  12. package/dist/components/ChatTextArea/ChatTextArea.js +47 -18
  13. package/dist/components/ChatTextArea/ChatTextArea.js.map +1 -1
  14. package/dist/components/FilePreview/FilePreview.css +225 -146
  15. package/dist/components/FilePreview/FilePreview.d.ts +1 -2
  16. package/dist/components/FilePreview/FilePreview.js +20 -6
  17. package/dist/components/FilePreview/FilePreview.js.map +1 -1
  18. package/dist/components/Header/Header.css +2 -2
  19. package/dist/components/MediaWidget/MediaItemWidget.js +2 -1
  20. package/dist/components/MediaWidget/MediaItemWidget.js.map +1 -1
  21. package/dist/components/MediaWidget/MediaWidget.css +0 -4
  22. package/dist/components/MemoriWidget/MemoriWidget.css +11 -2
  23. package/dist/components/MemoriWidget/MemoriWidget.js +41 -5
  24. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  25. package/dist/components/MicrophoneButton/MicrophoneButton.css +2 -2
  26. package/dist/components/StartPanel/StartPanel.css +8 -0
  27. package/dist/components/UploadButton/UploadButton.css +20 -17
  28. package/dist/components/UploadButton/UploadButton.js +218 -89
  29. package/dist/components/UploadButton/UploadButton.js.map +1 -1
  30. package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js +14 -4
  31. package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
  32. package/dist/components/UploadButton/UploadImages/UploadImages.js +143 -16
  33. package/dist/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
  34. package/dist/components/layouts/chat.css +1 -1
  35. package/dist/helpers/constants.d.ts +1 -0
  36. package/dist/helpers/constants.js +2 -1
  37. package/dist/helpers/constants.js.map +1 -1
  38. package/dist/helpers/imageCompression.d.ts +7 -0
  39. package/dist/helpers/imageCompression.js +123 -0
  40. package/dist/helpers/imageCompression.js.map +1 -0
  41. package/dist/locales/de.json +7 -4
  42. package/dist/locales/en.json +8 -5
  43. package/dist/locales/es.json +7 -4
  44. package/dist/locales/fr.json +7 -4
  45. package/dist/locales/it.json +8 -5
  46. package/dist/styles.css +1 -2
  47. package/esm/components/Chat/Chat.css +37 -3
  48. package/esm/components/Chat/Chat.js +60 -22
  49. package/esm/components/Chat/Chat.js.map +1 -1
  50. package/esm/components/ChatBubble/ChatBubble.css +9 -5
  51. package/esm/components/ChatBubble/ChatBubble.js +54 -11
  52. package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
  53. package/esm/components/ChatInputs/ChatInputs.css +293 -17
  54. package/esm/components/ChatInputs/ChatInputs.js +42 -26
  55. package/esm/components/ChatInputs/ChatInputs.js.map +1 -1
  56. package/esm/components/ChatTextArea/ChatTextArea.css +75 -31
  57. package/esm/components/ChatTextArea/ChatTextArea.js +49 -20
  58. package/esm/components/ChatTextArea/ChatTextArea.js.map +1 -1
  59. package/esm/components/FilePreview/FilePreview.css +225 -146
  60. package/esm/components/FilePreview/FilePreview.d.ts +1 -2
  61. package/esm/components/FilePreview/FilePreview.js +21 -7
  62. package/esm/components/FilePreview/FilePreview.js.map +1 -1
  63. package/esm/components/Header/Header.css +2 -2
  64. package/esm/components/MediaWidget/MediaItemWidget.js +2 -1
  65. package/esm/components/MediaWidget/MediaItemWidget.js.map +1 -1
  66. package/esm/components/MediaWidget/MediaWidget.css +0 -4
  67. package/esm/components/MemoriWidget/MemoriWidget.css +11 -2
  68. package/esm/components/MemoriWidget/MemoriWidget.js +41 -5
  69. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  70. package/esm/components/MicrophoneButton/MicrophoneButton.css +2 -2
  71. package/esm/components/StartPanel/StartPanel.css +8 -0
  72. package/esm/components/UploadButton/UploadButton.css +20 -17
  73. package/esm/components/UploadButton/UploadButton.js +219 -90
  74. package/esm/components/UploadButton/UploadButton.js.map +1 -1
  75. package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js +14 -4
  76. package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
  77. package/esm/components/UploadButton/UploadImages/UploadImages.js +143 -16
  78. package/esm/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
  79. package/esm/components/layouts/chat.css +1 -1
  80. package/esm/helpers/constants.d.ts +1 -0
  81. package/esm/helpers/constants.js +1 -0
  82. package/esm/helpers/constants.js.map +1 -1
  83. package/esm/helpers/imageCompression.d.ts +7 -0
  84. package/esm/helpers/imageCompression.js +119 -0
  85. package/esm/helpers/imageCompression.js.map +1 -0
  86. package/esm/locales/de.json +7 -4
  87. package/esm/locales/en.json +8 -5
  88. package/esm/locales/es.json +7 -4
  89. package/esm/locales/fr.json +7 -4
  90. package/esm/locales/it.json +8 -5
  91. package/esm/styles.css +1 -2
  92. package/package.json +1 -1
  93. package/src/components/Chat/Chat.css +37 -3
  94. package/src/components/Chat/Chat.tsx +89 -21
  95. package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +672 -732
  96. package/src/components/ChatBubble/ChatBubble.css +9 -5
  97. package/src/components/ChatBubble/ChatBubble.tsx +111 -20
  98. package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +4 -4
  99. package/src/components/ChatInputs/ChatInputs.css +293 -17
  100. package/src/components/ChatInputs/ChatInputs.tsx +144 -87
  101. package/src/components/ChatInputs/__snapshots__/ChatInputs.test.tsx.snap +430 -424
  102. package/src/components/ChatTextArea/ChatTextArea.css +75 -31
  103. package/src/components/ChatTextArea/ChatTextArea.test.tsx +1 -16
  104. package/src/components/ChatTextArea/ChatTextArea.tsx +51 -22
  105. package/src/components/ChatTextArea/__snapshots__/ChatTextArea.test.tsx.snap +9 -72
  106. package/src/components/FilePreview/FilePreview.css +225 -146
  107. package/src/components/FilePreview/FilePreview.tsx +49 -36
  108. package/src/components/FilePreview/__snapshots__/FilePreview.test.tsx.snap +2 -2
  109. package/src/components/Header/Header.css +2 -2
  110. package/src/components/MediaWidget/MediaItemWidget.tsx +2 -1
  111. package/src/components/MediaWidget/MediaWidget.css +0 -4
  112. package/src/components/MemoriWidget/MemoriWidget.css +11 -2
  113. package/src/components/MemoriWidget/MemoriWidget.tsx +61 -12
  114. package/src/components/MicrophoneButton/MicrophoneButton.css +2 -2
  115. package/src/components/StartPanel/StartPanel.css +8 -0
  116. package/src/components/UploadButton/UploadButton.css +20 -17
  117. package/src/components/UploadButton/UploadButton.stories.tsx +247 -35
  118. package/src/components/UploadButton/UploadButton.tsx +280 -175
  119. package/src/components/UploadButton/UploadDocuments/UploadDocuments.tsx +19 -4
  120. package/src/components/UploadButton/UploadImages/UploadImages.tsx +195 -35
  121. package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +10 -1
  122. package/src/components/layouts/chat.css +1 -1
  123. package/src/helpers/constants.ts +1 -1
  124. package/src/helpers/imageCompression.ts +230 -0
  125. package/src/locales/de.json +7 -4
  126. package/src/locales/en.json +8 -5
  127. package/src/locales/es.json +7 -4
  128. package/src/locales/fr.json +7 -4
  129. package/src/locales/it.json +8 -5
  130. package/src/styles.css +1 -2
  131. package/src/components/UploadMenu/UploadMenu.css +0 -47
  132. package/src/components/UploadMenu/UploadMenu.stories.tsx +0 -66
  133. package/src/components/UploadMenu/UploadMenu.test.tsx +0 -34
  134. package/src/components/UploadMenu/UploadMenu.tsx +0 -68
  135. package/src/components/UploadMenu/__snapshots__/UploadMenu.test.tsx.snap +0 -137
@@ -37,6 +37,7 @@
37
37
  "last_7_days": "Ultimi 7 giorni",
38
38
  "last_30_days": "Ultimi 30 giorni",
39
39
  "previous": "Precedente",
40
+ "placeholder": "Fai una domanda",
40
41
  "copy": "Copia",
41
42
  "copyRawCode": "Copia codice sorgente",
42
43
  "copyToClipboard": "Copia negli appunti",
@@ -273,10 +274,11 @@
273
274
  "upload": {
274
275
  "loginRequired": "Login richiesto",
275
276
  "loginRequiredDescription": "Per caricare immagini, devi prima accedere",
276
- "uploadFiles": "Carica file",
277
- "uploadImage": "Carica immagine",
277
+ "uploadFiles": "Carica file ({{shortcut}}+O per aprire il selettore file)",
278
+ "uploadFilesWithShortcut": "{{shortcut}}+O per aprire il selettore file",
279
+ "uploadImages": "Carica immagini",
278
280
  "lastDocumentSlot": "Carica ultimo documento",
279
- "uploadDocument": "Carica documento",
281
+ "uploadDocuments": "Carica documenti",
280
282
  "maxDocumentsReached": "Puoi caricare fino a {{max}} documenti",
281
283
  "replace": "Sostituisci documento",
282
284
  "maxImagesReached": "Puoi caricare fino a {{max}} immagini",
@@ -286,13 +288,14 @@
286
288
  "uploadSuccess": "Caricamento riuscito",
287
289
  "remaining": "rimanenti",
288
290
  "maxReached": "Limite raggiunto",
289
- "titleImage": "Immagine: {{title}}",
291
+ "titleImage": "Titolo immagine: {{title}}",
290
292
  "titleImageUpload": "Carica immagini",
291
293
  "titleHelp": "Aggiungi un titolo descrittivo per aiutare l'AI a fornire risposte più appropriate.",
292
294
  "titlePlaceholder": "Inserisci il titolo dell'immagine",
293
295
  "uploadSuccessDescription": "Il file è stato caricato con successo",
294
296
  "partialUpload": "Solo {{uploaded}} immagini su {{total}} immagini saranno caricate. Massimo {{max}} immagini consentite.",
295
- "cancel": "Annulla"
297
+ "cancel": "Annulla",
298
+ "dragAndDropFiles": "Trascina qui i file per aggiungerli alla chat"
296
299
  },
297
300
  "gamification": {
298
301
  "level": "Livello",
package/esm/styles.css CHANGED
@@ -43,7 +43,6 @@
43
43
  @import url('./components/ShareButton/ShareButton.css');
44
44
  @import url('./components/Snippet/Snippet.css');
45
45
  @import url('./components/StartPanel/StartPanel.css');
46
- @import url('./components/UploadMenu/UploadMenu.css');
47
46
  @import url('./components/DateSelector/DateSelector.css');
48
47
  @import url('./components/AgeVerificationModal/AgeVerificationModal.css');
49
48
  @import url('./components/KnownFacts/KnownFacts.css');
@@ -97,7 +96,7 @@ body.sb-show-main #root,
97
96
  --memori-chat-bubble-bg: #fff;
98
97
  --memori-chat-user-bubble-bg: var(--memori-primary);
99
98
  --memori-text-color: #000;
100
- --memori-border-radius: 5px;
99
+ --memori-border-radius: 8px;
101
100
  --memori-box-shadow: 0 2px 0 rgba(0, 0, 0, 0.02);
102
101
  --memori-button-bg: #fff;
103
102
  --memori-button-text: #000;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "8.12.0",
2
+ "version": "8.13.0",
3
3
  "name": "@memori.ai/memori-react",
4
4
  "author": "Memori Srl",
5
5
  "main": "dist/index.js",
@@ -52,7 +52,7 @@
52
52
  flex: 1;
53
53
  flex-direction: column;
54
54
  padding: 2rem 10px;
55
- mask-image: linear-gradient(transparent, black 5%, black 95%, transparent 100%);
55
+ /* mask-image: linear-gradient(transparent, black 5%, black 95%, transparent 100%); */
56
56
  overflow-y: auto;
57
57
  scroll-behavior: smooth;
58
58
  }
@@ -76,8 +76,8 @@
76
76
  margin-bottom: 10px;
77
77
  background-position: center;
78
78
  background-size: cover;
79
- border-top-left-radius: 3px;
80
- border-top-right-radius: 3px;
79
+ border-top-left-radius: 12px;
80
+ border-top-right-radius: 12px;
81
81
  }
82
82
 
83
83
  .memori-chat--cover+.memori-chat--bubble-initial {
@@ -146,4 +146,38 @@
146
146
 
147
147
  .memori-chat--known-tag {
148
148
  margin-right: 0.5rem;
149
+ }
150
+
151
+ /* Drag and drop overlay */
152
+ .memori-chat--drag-overlay {
153
+ position: absolute;
154
+ z-index: 1000;
155
+ top: 0;
156
+ right: 0;
157
+ bottom: 0;
158
+ left: 0;
159
+ display: flex;
160
+ flex-direction: column;
161
+ align-items: center;
162
+ justify-content: center;
163
+ border-radius: 10px;
164
+ backdrop-filter: blur(4px);
165
+ background-color: rgba(0, 0, 0, 0.7);
166
+ pointer-events: none;
167
+ }
168
+
169
+ .memori-chat--drag-overlay-icon {
170
+ width: 64px;
171
+ height: 64px;
172
+ margin-bottom: 1rem;
173
+ color: #fff;
174
+ opacity: 0.9;
175
+ }
176
+
177
+ .memori-chat--drag-overlay-text {
178
+ padding: 0 2rem;
179
+ color: #ffffff;
180
+ font-size: 1.2rem;
181
+ font-weight: 500;
182
+ text-align: center;
149
183
  }
@@ -21,6 +21,8 @@ import ChatInputs from '../ChatInputs/ChatInputs';
21
21
  import Typing from '../Typing/Typing';
22
22
  import { boardOfExpertsLoadingSentences } from '../../helpers/constants';
23
23
  import ArtifactHandler from '../MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler';
24
+ import { DocumentIcon } from '../icons/Document';
25
+ import { useTranslation } from 'react-i18next';
24
26
  export interface Props {
25
27
  memori: Memori;
26
28
  tenant?: Tenant;
@@ -125,7 +127,8 @@ const Chat: React.FC<Props> = ({
125
127
  showFunctionCache = false,
126
128
  }) => {
127
129
  const [isTextareaExpanded, setIsTextareaExpanded] = useState(false);
128
-
130
+ const [isDragging, setIsDragging] = useState(false);
131
+ const { t } = useTranslation();
129
132
  const scrollToBottom = () => {
130
133
  if (isHistoryView) return;
131
134
  setTimeout(() => {
@@ -140,13 +143,13 @@ const Chat: React.FC<Props> = ({
140
143
  }, [history, preview, isHistoryView]);
141
144
 
142
145
  // Scroll to bottom when textarea is expanded
143
- useEffect(() => {
144
- if (isTextareaExpanded && !isHistoryView) {
145
- setTimeout(() => {
146
- scrollToBottom();
147
- }, 250);
148
- }
149
- }, [isTextareaExpanded, isHistoryView]);
146
+ // useEffect(() => {
147
+ // if (isTextareaExpanded && !isHistoryView) {
148
+ // setTimeout(() => {
149
+ // scrollToBottom();
150
+ // }, 250);
151
+ // }
152
+ // }, [isTextareaExpanded, isHistoryView]);
150
153
 
151
154
  const onTextareaFocus = () => {
152
155
  stopListening();
@@ -154,16 +157,16 @@ const Chat: React.FC<Props> = ({
154
157
 
155
158
  if (hasTouch) setEnableFocusChatInput(true);
156
159
  // if the user is on mobile and had not recorded audio, add the chat-focused class to the chat wrapper
157
- if (hasTouch && window.innerWidth <= 768) {
158
- document.getElementById('chat-wrapper')?.classList?.add('chat-focused');
159
- // add the chat-focused class to the memori widget
160
- document
161
- .querySelector('.memori.memori-widget')
162
- ?.classList?.add('chat-focused');
163
- setTimeout(() => {
164
- scrollToBottom();
165
- }, 300);
166
- }
160
+ // if (hasTouch && window.innerWidth <= 768) {
161
+ // document.getElementById('chat-wrapper')?.classList?.add('chat-focused');
162
+ // // add the chat-focused class to the memori widget
163
+ // document
164
+ // .querySelector('.memori.memori-widget')
165
+ // ?.classList?.add('chat-focused');
166
+ // setTimeout(() => {
167
+ // scrollToBottom();
168
+ // }, 300);
169
+ // }
167
170
  };
168
171
  const onTextareaBlur = () => {
169
172
  if (
@@ -183,16 +186,82 @@ const Chat: React.FC<Props> = ({
183
186
  setIsTextareaExpanded(expanded);
184
187
  };
185
188
 
189
+ // Drag and drop handlers for overlay
190
+ useEffect(() => {
191
+ let dragCounter = 0;
192
+ const chatWrapper = document.getElementById('chat-wrapper');
193
+
194
+ const handleDragEnter = (e: DragEvent) => {
195
+ // Only show overlay if dragging files (not text/links)
196
+ if (e.dataTransfer?.types.includes('Files')) {
197
+ dragCounter++;
198
+ if (dragCounter === 1) {
199
+ setIsDragging(true);
200
+ }
201
+ }
202
+ };
203
+
204
+ const handleDragLeave = (e: DragEvent) => {
205
+ if (e.dataTransfer?.types.includes('Files')) {
206
+ dragCounter--;
207
+ if (dragCounter === 0) {
208
+ setIsDragging(false);
209
+ }
210
+ }
211
+ };
212
+
213
+ const handleDragOver = (e: DragEvent) => {
214
+ // Prevent default to allow drop, but don't stop propagation
215
+ if (e.dataTransfer?.types.includes('Files')) {
216
+ e.preventDefault();
217
+ }
218
+ };
219
+
220
+ const handleDrop = (e: DragEvent) => {
221
+ // Reset dragging state, but let UploadButton handle the actual drop
222
+ if (e.dataTransfer?.types.includes('Files')) {
223
+ dragCounter = 0;
224
+ setIsDragging(false);
225
+ }
226
+ };
227
+
228
+ if (chatWrapper) {
229
+ chatWrapper.addEventListener('dragenter', handleDragEnter);
230
+ chatWrapper.addEventListener('dragleave', handleDragLeave);
231
+ chatWrapper.addEventListener('dragover', handleDragOver);
232
+ chatWrapper.addEventListener('drop', handleDrop);
233
+ }
234
+
235
+ return () => {
236
+ if (chatWrapper) {
237
+ chatWrapper.removeEventListener('dragenter', handleDragEnter);
238
+ chatWrapper.removeEventListener('dragleave', handleDragLeave);
239
+ chatWrapper.removeEventListener('dragover', handleDragOver);
240
+ chatWrapper.removeEventListener('drop', handleDrop);
241
+ }
242
+ };
243
+ }, []);
244
+
186
245
  return (
187
246
  <div
188
247
  className={cx('memori-chat--wrapper', {
189
248
  'memori-chat-wrapper--translate': translateTo,
190
249
  'memori-chat-wrapper--expanded': isTextareaExpanded,
250
+ 'memori-chat-wrapper--dragging': isDragging,
191
251
  })}
192
252
  id="chat-wrapper"
193
253
  lang={translateTo?.toUpperCase()}
194
254
  data-memori-lang={memori.culture?.split('-')?.[0]?.toUpperCase() ?? 'EN'}
195
255
  >
256
+ {/* Drag and drop overlay */}
257
+ {isDragging && (
258
+ <div className="memori-chat--drag-overlay">
259
+ <DocumentIcon className="memori-chat--drag-overlay-icon" />
260
+ <span className="memori-chat--drag-overlay-text">
261
+ {t('upload.dragAndDropFiles') ?? 'Drag and drop files here to add them to the chat'}
262
+ </span>
263
+ </div>
264
+ )}
196
265
  <div
197
266
  className={cx('memori-chat--history', {
198
267
  'memori-chat--history-touch': hasTouchscreen(),
@@ -316,8 +385,7 @@ const Chat: React.FC<Props> = ({
316
385
  media={[
317
386
  // Filter out HTML and plain text media items from the message
318
387
  ...(message?.media?.filter(
319
- m =>
320
- m.mimeType !== 'text/html' && !m.properties?.functionSignature
388
+ m => !m.properties?.functionSignature
321
389
  ) || []),
322
390
 
323
391
  // Extract document attachments that are embedded in the message text
@@ -364,7 +432,7 @@ const Chat: React.FC<Props> = ({
364
432
  return attachments;
365
433
  })(),
366
434
  ]}
367
- links={message?.media?.filter(m => m.mimeType === 'text/html')}
435
+ // links={message?.media?.filter(m => m.mimeType === 'text/html')}
368
436
  sessionID={sessionID}
369
437
  baseUrl={baseUrl}
370
438
  apiUrl={apiUrl}