@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.
- package/CHANGELOG.md +24 -0
- package/dist/components/Chat/Chat.css +37 -3
- package/dist/components/Chat/Chat.js +60 -22
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.css +9 -5
- package/dist/components/ChatBubble/ChatBubble.js +54 -11
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/ChatInputs/ChatInputs.css +293 -17
- package/dist/components/ChatInputs/ChatInputs.js +41 -25
- package/dist/components/ChatInputs/ChatInputs.js.map +1 -1
- package/dist/components/ChatTextArea/ChatTextArea.css +75 -31
- package/dist/components/ChatTextArea/ChatTextArea.js +47 -18
- package/dist/components/ChatTextArea/ChatTextArea.js.map +1 -1
- package/dist/components/FilePreview/FilePreview.css +225 -146
- package/dist/components/FilePreview/FilePreview.d.ts +1 -2
- package/dist/components/FilePreview/FilePreview.js +20 -6
- package/dist/components/FilePreview/FilePreview.js.map +1 -1
- package/dist/components/Header/Header.css +2 -2
- package/dist/components/MediaWidget/MediaItemWidget.js +2 -1
- package/dist/components/MediaWidget/MediaItemWidget.js.map +1 -1
- package/dist/components/MediaWidget/MediaWidget.css +0 -4
- package/dist/components/MemoriWidget/MemoriWidget.css +11 -2
- package/dist/components/MemoriWidget/MemoriWidget.js +41 -5
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/MicrophoneButton/MicrophoneButton.css +2 -2
- package/dist/components/StartPanel/StartPanel.css +8 -0
- package/dist/components/UploadButton/UploadButton.css +20 -17
- package/dist/components/UploadButton/UploadButton.js +218 -89
- package/dist/components/UploadButton/UploadButton.js.map +1 -1
- package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js +14 -4
- package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
- package/dist/components/UploadButton/UploadImages/UploadImages.js +143 -16
- package/dist/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
- package/dist/components/layouts/chat.css +1 -1
- package/dist/helpers/constants.d.ts +1 -0
- package/dist/helpers/constants.js +2 -1
- package/dist/helpers/constants.js.map +1 -1
- package/dist/helpers/imageCompression.d.ts +7 -0
- package/dist/helpers/imageCompression.js +123 -0
- package/dist/helpers/imageCompression.js.map +1 -0
- package/dist/locales/de.json +7 -4
- package/dist/locales/en.json +8 -5
- package/dist/locales/es.json +7 -4
- package/dist/locales/fr.json +7 -4
- package/dist/locales/it.json +8 -5
- package/dist/styles.css +1 -2
- package/esm/components/Chat/Chat.css +37 -3
- package/esm/components/Chat/Chat.js +60 -22
- package/esm/components/Chat/Chat.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.css +9 -5
- package/esm/components/ChatBubble/ChatBubble.js +54 -11
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/ChatInputs/ChatInputs.css +293 -17
- package/esm/components/ChatInputs/ChatInputs.js +42 -26
- package/esm/components/ChatInputs/ChatInputs.js.map +1 -1
- package/esm/components/ChatTextArea/ChatTextArea.css +75 -31
- package/esm/components/ChatTextArea/ChatTextArea.js +49 -20
- package/esm/components/ChatTextArea/ChatTextArea.js.map +1 -1
- package/esm/components/FilePreview/FilePreview.css +225 -146
- package/esm/components/FilePreview/FilePreview.d.ts +1 -2
- package/esm/components/FilePreview/FilePreview.js +21 -7
- package/esm/components/FilePreview/FilePreview.js.map +1 -1
- package/esm/components/Header/Header.css +2 -2
- package/esm/components/MediaWidget/MediaItemWidget.js +2 -1
- package/esm/components/MediaWidget/MediaItemWidget.js.map +1 -1
- package/esm/components/MediaWidget/MediaWidget.css +0 -4
- package/esm/components/MemoriWidget/MemoriWidget.css +11 -2
- package/esm/components/MemoriWidget/MemoriWidget.js +41 -5
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/MicrophoneButton/MicrophoneButton.css +2 -2
- package/esm/components/StartPanel/StartPanel.css +8 -0
- package/esm/components/UploadButton/UploadButton.css +20 -17
- package/esm/components/UploadButton/UploadButton.js +219 -90
- package/esm/components/UploadButton/UploadButton.js.map +1 -1
- package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js +14 -4
- package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
- package/esm/components/UploadButton/UploadImages/UploadImages.js +143 -16
- package/esm/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
- package/esm/components/layouts/chat.css +1 -1
- package/esm/helpers/constants.d.ts +1 -0
- package/esm/helpers/constants.js +1 -0
- package/esm/helpers/constants.js.map +1 -1
- package/esm/helpers/imageCompression.d.ts +7 -0
- package/esm/helpers/imageCompression.js +119 -0
- package/esm/helpers/imageCompression.js.map +1 -0
- package/esm/locales/de.json +7 -4
- package/esm/locales/en.json +8 -5
- package/esm/locales/es.json +7 -4
- package/esm/locales/fr.json +7 -4
- package/esm/locales/it.json +8 -5
- package/esm/styles.css +1 -2
- package/package.json +1 -1
- package/src/components/Chat/Chat.css +37 -3
- package/src/components/Chat/Chat.tsx +89 -21
- package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +672 -732
- package/src/components/ChatBubble/ChatBubble.css +9 -5
- package/src/components/ChatBubble/ChatBubble.tsx +111 -20
- package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +4 -4
- package/src/components/ChatInputs/ChatInputs.css +293 -17
- package/src/components/ChatInputs/ChatInputs.tsx +144 -87
- package/src/components/ChatInputs/__snapshots__/ChatInputs.test.tsx.snap +430 -424
- package/src/components/ChatTextArea/ChatTextArea.css +75 -31
- package/src/components/ChatTextArea/ChatTextArea.test.tsx +1 -16
- package/src/components/ChatTextArea/ChatTextArea.tsx +51 -22
- package/src/components/ChatTextArea/__snapshots__/ChatTextArea.test.tsx.snap +9 -72
- package/src/components/FilePreview/FilePreview.css +225 -146
- package/src/components/FilePreview/FilePreview.tsx +49 -36
- package/src/components/FilePreview/__snapshots__/FilePreview.test.tsx.snap +2 -2
- package/src/components/Header/Header.css +2 -2
- package/src/components/MediaWidget/MediaItemWidget.tsx +2 -1
- package/src/components/MediaWidget/MediaWidget.css +0 -4
- package/src/components/MemoriWidget/MemoriWidget.css +11 -2
- package/src/components/MemoriWidget/MemoriWidget.tsx +61 -12
- package/src/components/MicrophoneButton/MicrophoneButton.css +2 -2
- package/src/components/StartPanel/StartPanel.css +8 -0
- package/src/components/UploadButton/UploadButton.css +20 -17
- package/src/components/UploadButton/UploadButton.stories.tsx +247 -35
- package/src/components/UploadButton/UploadButton.tsx +280 -175
- package/src/components/UploadButton/UploadDocuments/UploadDocuments.tsx +19 -4
- package/src/components/UploadButton/UploadImages/UploadImages.tsx +195 -35
- package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +10 -1
- package/src/components/layouts/chat.css +1 -1
- package/src/helpers/constants.ts +1 -1
- package/src/helpers/imageCompression.ts +230 -0
- package/src/locales/de.json +7 -4
- package/src/locales/en.json +8 -5
- package/src/locales/es.json +7 -4
- package/src/locales/fr.json +7 -4
- package/src/locales/it.json +8 -5
- package/src/styles.css +1 -2
- package/src/components/UploadMenu/UploadMenu.css +0 -47
- package/src/components/UploadMenu/UploadMenu.stories.tsx +0 -66
- package/src/components/UploadMenu/UploadMenu.test.tsx +0 -34
- package/src/components/UploadMenu/UploadMenu.tsx +0 -68
- package/src/components/UploadMenu/__snapshots__/UploadMenu.test.tsx.snap +0 -137
|
@@ -10,6 +10,7 @@ import Microphone from '../icons/Microphone';
|
|
|
10
10
|
import UploadButton from '../UploadButton/UploadButton';
|
|
11
11
|
import FilePreview from '../FilePreview/FilePreview';
|
|
12
12
|
import memoriApiClient from '@memori.ai/memori-api-client';
|
|
13
|
+
import Plus from '../icons/Plus';
|
|
13
14
|
export interface Props {
|
|
14
15
|
dialogState?: DialogState;
|
|
15
16
|
instruct?: boolean;
|
|
@@ -98,9 +99,13 @@ const ChatInputs: React.FC<Props> = ({
|
|
|
98
99
|
}[]
|
|
99
100
|
) => {
|
|
100
101
|
if (isTyping) return;
|
|
101
|
-
|
|
102
|
+
|
|
102
103
|
const mediaWithIds = files.map((file, index) => {
|
|
103
|
-
const generatedMediumID =
|
|
104
|
+
const generatedMediumID =
|
|
105
|
+
file.mediumID ||
|
|
106
|
+
`file_${Date.now()}_${index}_${Math.random()
|
|
107
|
+
.toString(36)
|
|
108
|
+
.substr(2, 9)}`;
|
|
104
109
|
return {
|
|
105
110
|
mediumID: generatedMediumID,
|
|
106
111
|
mimeType: file.mimeType,
|
|
@@ -111,7 +116,7 @@ const ChatInputs: React.FC<Props> = ({
|
|
|
111
116
|
url: file.url,
|
|
112
117
|
};
|
|
113
118
|
});
|
|
114
|
-
|
|
119
|
+
|
|
115
120
|
sendMessage(userMessage, mediaWithIds);
|
|
116
121
|
|
|
117
122
|
// Reset states after sending
|
|
@@ -135,7 +140,11 @@ const ChatInputs: React.FC<Props> = ({
|
|
|
135
140
|
if (sendOnEnter === 'keypress' && userMessage?.length > 0) {
|
|
136
141
|
stopListening();
|
|
137
142
|
const mediaWithIds = documentPreviewFiles.map((file, index) => {
|
|
138
|
-
const generatedMediumID =
|
|
143
|
+
const generatedMediumID =
|
|
144
|
+
file.mediumID ||
|
|
145
|
+
`file_${Date.now()}_${index}_${Math.random()
|
|
146
|
+
.toString(36)
|
|
147
|
+
.substr(2, 9)}`;
|
|
139
148
|
return {
|
|
140
149
|
mediumID: generatedMediumID,
|
|
141
150
|
mimeType: file.mimeType,
|
|
@@ -146,7 +155,7 @@ const ChatInputs: React.FC<Props> = ({
|
|
|
146
155
|
url: file.url,
|
|
147
156
|
};
|
|
148
157
|
});
|
|
149
|
-
|
|
158
|
+
|
|
150
159
|
sendMessage(userMessage, mediaWithIds);
|
|
151
160
|
|
|
152
161
|
setDocumentPreviewFiles([]);
|
|
@@ -187,94 +196,142 @@ const ChatInputs: React.FC<Props> = ({
|
|
|
187
196
|
}
|
|
188
197
|
};
|
|
189
198
|
|
|
199
|
+
const isDisabled =
|
|
200
|
+
dialogState?.state === 'X2a' || dialogState?.state === 'X3';
|
|
201
|
+
const textareaDisabled = ['R2', 'R3', 'R4', 'R5', 'G3', 'X3'].includes(
|
|
202
|
+
dialogState?.state || ''
|
|
203
|
+
);
|
|
204
|
+
|
|
190
205
|
return (
|
|
191
|
-
<
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
'memori-chat-inputs
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
onPressEnter={onTextareaPressEnter}
|
|
202
|
-
onFocus={onTextareaFocus}
|
|
203
|
-
onBlur={onTextareaBlur}
|
|
204
|
-
onExpandedChange={handleTextareaExpanded}
|
|
205
|
-
disabled={['R2', 'R3', 'R4', 'R5', 'G3', 'X3'].includes(
|
|
206
|
-
dialogState?.state || ''
|
|
207
|
-
)}
|
|
208
|
-
/>
|
|
209
|
-
{/* Preview for document files */}
|
|
210
|
-
{showUpload && (
|
|
211
|
-
<>
|
|
206
|
+
<div className="memori-chat-inputs-wrapper">
|
|
207
|
+
<fieldset
|
|
208
|
+
id="chat-fieldset"
|
|
209
|
+
className={cx('memori-chat-inputs', {
|
|
210
|
+
'memori-chat-inputs--expanded': isExpanded,
|
|
211
|
+
})}
|
|
212
|
+
disabled={isDisabled}
|
|
213
|
+
>
|
|
214
|
+
{/* Preview for document files */}
|
|
215
|
+
{showUpload && (
|
|
212
216
|
<FilePreview
|
|
213
217
|
previewFiles={documentPreviewFiles}
|
|
214
218
|
removeFile={removeFile}
|
|
215
219
|
/>
|
|
220
|
+
)}
|
|
221
|
+
<div className="memori-chat-inputs--container">
|
|
222
|
+
{/* Leading area - Plus button */}
|
|
223
|
+
<div className="memori-chat-inputs--leading">
|
|
224
|
+
{showUpload && (
|
|
225
|
+
<div className="memori-chat-inputs--upload-wrapper">
|
|
226
|
+
<UploadButton
|
|
227
|
+
authToken={authToken}
|
|
228
|
+
client={client}
|
|
229
|
+
sessionID={sessionID}
|
|
230
|
+
isMediaAccepted={dialogState?.acceptsMedia || false}
|
|
231
|
+
setDocumentPreviewFiles={setDocumentPreviewFiles}
|
|
232
|
+
documentPreviewFiles={documentPreviewFiles}
|
|
233
|
+
memoriID={memoriID}
|
|
234
|
+
/>
|
|
235
|
+
</div>
|
|
236
|
+
)}
|
|
237
|
+
</div>
|
|
216
238
|
|
|
217
|
-
{/*
|
|
218
|
-
<
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
239
|
+
{/* Primary area - Textarea */}
|
|
240
|
+
<div className="memori-chat-inputs--primary">
|
|
241
|
+
<ChatTextArea
|
|
242
|
+
value={userMessage}
|
|
243
|
+
onChange={onChangeUserMessage}
|
|
244
|
+
onPressEnter={onTextareaPressEnter}
|
|
245
|
+
onFocus={onTextareaFocus}
|
|
246
|
+
onBlur={onTextareaBlur}
|
|
247
|
+
onExpandedChange={handleTextareaExpanded}
|
|
248
|
+
disabled={textareaDisabled}
|
|
249
|
+
/>
|
|
250
|
+
</div>
|
|
251
|
+
|
|
252
|
+
{/* Trailing area - Microphone and Send button */}
|
|
253
|
+
<div className="memori-chat-inputs--trailing">
|
|
254
|
+
<div className="memori-chat-inputs--trailing-inner">
|
|
255
|
+
{showMicrophone && microphoneMode === 'CONTINUOUS' && (
|
|
256
|
+
<button
|
|
257
|
+
type="button"
|
|
258
|
+
className={cx('memori-chat-inputs--mic-btn', {
|
|
259
|
+
'memori-chat-inputs--mic-btn--listening': listening,
|
|
260
|
+
})}
|
|
261
|
+
title={
|
|
262
|
+
listening
|
|
263
|
+
? t('write_and_speak.micButtonPopoverListening') ||
|
|
264
|
+
'Listening'
|
|
265
|
+
: t('write_and_speak.micButtonPopover') ||
|
|
266
|
+
'Start listening'
|
|
267
|
+
}
|
|
268
|
+
onClick={() => {
|
|
269
|
+
if (listening) {
|
|
270
|
+
stopListening();
|
|
271
|
+
} else {
|
|
272
|
+
stopAudio();
|
|
273
|
+
startListening();
|
|
274
|
+
}
|
|
275
|
+
}}
|
|
276
|
+
disabled={isDisabled}
|
|
277
|
+
aria-label={
|
|
278
|
+
listening
|
|
279
|
+
? t('write_and_speak.micButtonPopoverListening') ||
|
|
280
|
+
'Listening'
|
|
281
|
+
: t('write_and_speak.micButtonPopover') ||
|
|
282
|
+
'Start listening'
|
|
283
|
+
}
|
|
284
|
+
>
|
|
285
|
+
<Microphone className="icon" />
|
|
286
|
+
</button>
|
|
287
|
+
)}
|
|
288
|
+
{showMicrophone && microphoneMode === 'HOLD_TO_TALK' && (
|
|
289
|
+
<MicrophoneButton
|
|
290
|
+
listening={listening}
|
|
291
|
+
startListening={startListening}
|
|
292
|
+
stopListening={() => {
|
|
293
|
+
stopListening();
|
|
294
|
+
if (listening && !!userMessage?.length) {
|
|
295
|
+
sendMessage(userMessage);
|
|
296
|
+
}
|
|
297
|
+
}}
|
|
298
|
+
stopAudio={stopAudio}
|
|
299
|
+
/>
|
|
300
|
+
)}
|
|
301
|
+
<button
|
|
302
|
+
type="button"
|
|
303
|
+
className={cx('memori-chat-inputs--send-btn', {
|
|
304
|
+
'memori-chat-inputs--send-btn--active': !!userMessage?.length,
|
|
305
|
+
'memori-chat-inputs--send-btn--disabled':
|
|
306
|
+
!userMessage || userMessage.length === 0,
|
|
307
|
+
})}
|
|
308
|
+
onClick={() => {
|
|
309
|
+
onSendMessage(documentPreviewFiles);
|
|
310
|
+
}}
|
|
311
|
+
disabled={!userMessage || userMessage.length === 0 || isTyping}
|
|
312
|
+
title={t('send') || 'Send'}
|
|
313
|
+
aria-label={t('send') || 'Send'}
|
|
314
|
+
>
|
|
315
|
+
{isTyping ? (
|
|
316
|
+
<div className="memori-chat-inputs--send-btn--loading" />
|
|
317
|
+
) : (
|
|
318
|
+
<Send className="icon" />
|
|
319
|
+
)}
|
|
320
|
+
</button>
|
|
321
|
+
</div>
|
|
322
|
+
</div>
|
|
323
|
+
</div>
|
|
324
|
+
</fieldset>
|
|
325
|
+
{/* Disclaimer */}
|
|
326
|
+
{/* <div className="memori-chat-inputs--disclaimer">
|
|
327
|
+
<div>
|
|
328
|
+
{t(
|
|
329
|
+
'chat.disclaimer',
|
|
330
|
+
'AIsuru può commettere errori. Assicurati di verificare le informazioni importanti.'
|
|
331
|
+
)}
|
|
332
|
+
</div>
|
|
333
|
+
</div> */}
|
|
334
|
+
</div>
|
|
278
335
|
);
|
|
279
336
|
};
|
|
280
337
|
|