@memori.ai/memori-react 2.1.0 → 2.2.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 +17 -0
- package/dist/components/Chat/Chat.d.ts +1 -0
- package/dist/components/Chat/Chat.js +2 -2
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.js +1 -1
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/ChatInputs/ChatInputs.css +1 -41
- package/dist/components/ChatInputs/ChatInputs.d.ts +1 -0
- package/dist/components/ChatInputs/ChatInputs.js +9 -3
- package/dist/components/ChatInputs/ChatInputs.js.map +1 -1
- package/dist/components/FeedbackButtons/FeedbackButtons.js +1 -1
- package/dist/components/FeedbackButtons/FeedbackButtons.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +23 -13
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/MicrophoneButton/MicrophoneButton.css +101 -0
- package/dist/components/MicrophoneButton/MicrophoneButton.d.ts +9 -0
- package/dist/components/MicrophoneButton/MicrophoneButton.js +46 -0
- package/dist/components/MicrophoneButton/MicrophoneButton.js.map +1 -0
- package/dist/components/SettingsDrawer/SettingsDrawer.d.ts +3 -3
- package/dist/components/SettingsDrawer/SettingsDrawer.js +8 -6
- package/dist/components/SettingsDrawer/SettingsDrawer.js.map +1 -1
- package/dist/components/SettingsDrawer/SettingsDrawer.test.js +7 -7
- package/dist/components/SettingsDrawer/SettingsDrawer.test.js.map +1 -1
- package/dist/components/StartPanel/StartPanel.js +1 -1
- package/dist/components/StartPanel/StartPanel.js.map +1 -1
- package/dist/components/ui/Button.d.ts +5 -1
- package/dist/components/ui/Button.js +1 -1
- package/dist/components/ui/Button.js.map +1 -1
- package/dist/components/ui/Tooltip.css +33 -2
- package/dist/components/ui/Tooltip.d.ts +2 -1
- package/dist/components/ui/Tooltip.js +1 -2
- package/dist/components/ui/Tooltip.js.map +1 -1
- package/dist/components/ui/Tooltip.test.js +16 -0
- package/dist/components/ui/Tooltip.test.js.map +1 -1
- package/dist/helpers/configuration.js +1 -1
- package/dist/helpers/configuration.js.map +1 -1
- package/dist/locales/en.json +4 -0
- package/dist/locales/it.json +4 -0
- package/dist/styles.css +3 -2
- package/esm/components/Chat/Chat.d.ts +1 -0
- package/esm/components/Chat/Chat.js +2 -2
- package/esm/components/Chat/Chat.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.js +1 -1
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/ChatInputs/ChatInputs.css +1 -41
- package/esm/components/ChatInputs/ChatInputs.d.ts +1 -0
- package/esm/components/ChatInputs/ChatInputs.js +9 -3
- package/esm/components/ChatInputs/ChatInputs.js.map +1 -1
- package/esm/components/FeedbackButtons/FeedbackButtons.js +1 -1
- package/esm/components/FeedbackButtons/FeedbackButtons.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +23 -13
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/MicrophoneButton/MicrophoneButton.css +101 -0
- package/esm/components/MicrophoneButton/MicrophoneButton.d.ts +9 -0
- package/esm/components/MicrophoneButton/MicrophoneButton.js +43 -0
- package/esm/components/MicrophoneButton/MicrophoneButton.js.map +1 -0
- package/esm/components/SettingsDrawer/SettingsDrawer.d.ts +3 -3
- package/esm/components/SettingsDrawer/SettingsDrawer.js +9 -7
- package/esm/components/SettingsDrawer/SettingsDrawer.js.map +1 -1
- package/esm/components/SettingsDrawer/SettingsDrawer.test.js +7 -7
- package/esm/components/SettingsDrawer/SettingsDrawer.test.js.map +1 -1
- package/esm/components/StartPanel/StartPanel.js +1 -1
- package/esm/components/StartPanel/StartPanel.js.map +1 -1
- package/esm/components/ui/Button.d.ts +5 -1
- package/esm/components/ui/Button.js +1 -1
- package/esm/components/ui/Button.js.map +1 -1
- package/esm/components/ui/Tooltip.css +33 -2
- package/esm/components/ui/Tooltip.d.ts +2 -1
- package/esm/components/ui/Tooltip.js +1 -2
- package/esm/components/ui/Tooltip.js.map +1 -1
- package/esm/components/ui/Tooltip.test.js +16 -0
- package/esm/components/ui/Tooltip.test.js.map +1 -1
- package/esm/helpers/configuration.js +1 -1
- package/esm/helpers/configuration.js.map +1 -1
- package/esm/locales/en.json +4 -0
- package/esm/locales/it.json +4 -0
- package/esm/styles.css +3 -2
- package/package.json +1 -1
- package/src/components/BlockedMemoriBadge/__snapshots__/BlockedMemoriBadge.test.tsx.snap +4 -4
- package/src/components/Chat/Chat.tsx +3 -0
- package/src/components/ChatBubble/ChatBubble.tsx +1 -1
- package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +1 -1
- package/src/components/ChatInputs/ChatInputs.css +1 -41
- package/src/components/ChatInputs/ChatInputs.stories.tsx +50 -3
- package/src/components/ChatInputs/ChatInputs.tsx +20 -3
- package/src/components/ChatInputs/__snapshots__/ChatInputs.test.tsx.snap +160 -85
- package/src/components/FeedbackButtons/FeedbackButtons.tsx +1 -1
- package/src/components/Header/Header.stories.tsx +3 -0
- package/src/components/MemoriWidget/MemoriWidget.tsx +29 -12
- package/src/components/MicrophoneButton/MicrophoneButton.css +101 -0
- package/src/components/MicrophoneButton/MicrophoneButton.stories.tsx +49 -0
- package/src/components/MicrophoneButton/MicrophoneButton.tsx +95 -0
- package/src/components/SettingsDrawer/SettingsDrawer.stories.tsx +6 -4
- package/src/components/SettingsDrawer/SettingsDrawer.test.tsx +14 -14
- package/src/components/SettingsDrawer/SettingsDrawer.tsx +57 -25
- package/src/components/StartPanel/StartPanel.tsx +3 -3
- package/src/components/ui/Button.tsx +21 -1
- package/src/components/ui/Tooltip.css +33 -2
- package/src/components/ui/Tooltip.stories.tsx +40 -3
- package/src/components/ui/Tooltip.test.tsx +52 -0
- package/src/components/ui/Tooltip.tsx +12 -7
- package/src/components/ui/__snapshots__/Tooltip.test.tsx.snap +80 -4
- package/src/helpers/configuration.ts +1 -1
- package/src/locales/en.json +4 -0
- package/src/locales/it.json +4 -0
- package/src/styles.css +3 -2
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
2
|
import { DialogState } from '@memori.ai/memori-api-client/dist/types';
|
|
3
3
|
import UploadMenu from '../UploadMenu/UploadMenu';
|
|
4
4
|
import SendOnEnterMenu from '../SendOnEnterMenu/SendOnEnterMenu';
|
|
5
5
|
import ChatTextArea from '../ChatTextArea/ChatTextArea';
|
|
6
6
|
import Button from '../ui/Button';
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
|
-
import cx from 'classnames';
|
|
9
8
|
import Send from '../icons/Send';
|
|
9
|
+
import MicrophoneButton from '../MicrophoneButton/MicrophoneButton';
|
|
10
|
+
import cx from 'classnames';
|
|
10
11
|
import Microphone from '../icons/Microphone';
|
|
11
12
|
|
|
12
13
|
export interface Props {
|
|
@@ -28,6 +29,7 @@ export interface Props {
|
|
|
28
29
|
startListening: () => void;
|
|
29
30
|
stopListening: () => void;
|
|
30
31
|
showMicrophone?: boolean;
|
|
32
|
+
microphoneMode?: 'CONTINUOUS' | 'HOLD_TO_TALK';
|
|
31
33
|
authToken?: string;
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -45,6 +47,7 @@ const ChatInputs: React.FC<Props> = ({
|
|
|
45
47
|
onTextareaBlur,
|
|
46
48
|
onTextareaPressEnter,
|
|
47
49
|
showMicrophone = false,
|
|
50
|
+
microphoneMode = 'HOLD_TO_TALK',
|
|
48
51
|
listening = false,
|
|
49
52
|
stopAudio,
|
|
50
53
|
startListening,
|
|
@@ -94,7 +97,21 @@ const ChatInputs: React.FC<Props> = ({
|
|
|
94
97
|
title={t('send') || 'Send'}
|
|
95
98
|
icon={<Send />}
|
|
96
99
|
/>
|
|
97
|
-
{showMicrophone && (
|
|
100
|
+
{showMicrophone && microphoneMode === 'HOLD_TO_TALK' && (
|
|
101
|
+
<MicrophoneButton
|
|
102
|
+
listening={listening}
|
|
103
|
+
startListening={startListening}
|
|
104
|
+
stopListening={() => {
|
|
105
|
+
stopListening();
|
|
106
|
+
|
|
107
|
+
if (!!userMessage?.length) {
|
|
108
|
+
sendMessage(userMessage);
|
|
109
|
+
}
|
|
110
|
+
}}
|
|
111
|
+
stopAudio={stopAudio}
|
|
112
|
+
/>
|
|
113
|
+
)}
|
|
114
|
+
{showMicrophone && microphoneMode === 'CONTINUOUS' && (
|
|
98
115
|
<Button
|
|
99
116
|
primary
|
|
100
117
|
className={cx('memori-chat-inputs--mic', {
|
|
@@ -88,26 +88,41 @@ exports[`renders ChatInputs disabled unchanged 1`] = `
|
|
|
88
88
|
</svg>
|
|
89
89
|
</span>
|
|
90
90
|
</button>
|
|
91
|
-
<
|
|
92
|
-
class="memori-
|
|
93
|
-
title="write_and_speak.micButtonPopover"
|
|
91
|
+
<div
|
|
92
|
+
class="memori-tooltip memori-tooltip--align-topLeft memori-mic-btn-tooltip"
|
|
94
93
|
>
|
|
95
|
-
<
|
|
96
|
-
class="memori-
|
|
94
|
+
<div
|
|
95
|
+
class="memori-tooltip--content"
|
|
97
96
|
>
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
<span>
|
|
98
|
+
write_and_speak.pressAndHoldToSpeak
|
|
99
|
+
</span>
|
|
100
|
+
</div>
|
|
101
|
+
<div
|
|
102
|
+
class="memori-tooltip--trigger"
|
|
103
|
+
>
|
|
104
|
+
<button
|
|
105
|
+
class="memori-button memori-button--primary memori-button--circle memori-button--padded memori-button--icon-only memori-chat-inputs--mic"
|
|
106
|
+
title="write_and_speak.micButtonPopover"
|
|
104
107
|
>
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
<span
|
|
109
|
+
class="memori-button--icon"
|
|
110
|
+
>
|
|
111
|
+
<svg
|
|
112
|
+
aria-hidden="true"
|
|
113
|
+
focusable="false"
|
|
114
|
+
role="img"
|
|
115
|
+
viewBox="0 0 1024 1024"
|
|
116
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
117
|
+
>
|
|
118
|
+
<path
|
|
119
|
+
d="M842 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 140.3-113.7 254-254 254S258 594.3 258 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 168.7 126.6 307.9 290 327.6V884H326.7c-13.7 0-24.7 14.3-24.7 32v36c0 4.4 2.8 8 6.2 8h407.6c3.4 0 6.2-3.6 6.2-8v-36c0-17.7-11-32-24.7-32H548V782.1c165.3-18 294-158 294-328.1zM512 624c93.9 0 170-75.2 170-168V232c0-92.8-76.1-168-170-168s-170 75.2-170 168v224c0 92.8 76.1 168 170 168zm-94-392c0-50.6 41.9-92 94-92s94 41.4 94 92v224c0 50.6-41.9 92-94 92s-94-41.4-94-92V232z"
|
|
120
|
+
/>
|
|
121
|
+
</svg>
|
|
122
|
+
</span>
|
|
123
|
+
</button>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
111
126
|
</fieldset>
|
|
112
127
|
</div>
|
|
113
128
|
`;
|
|
@@ -198,26 +213,41 @@ exports[`renders ChatInputs listening unchanged 1`] = `
|
|
|
198
213
|
</svg>
|
|
199
214
|
</span>
|
|
200
215
|
</button>
|
|
201
|
-
<
|
|
202
|
-
class="memori-
|
|
203
|
-
title="write_and_speak.micButtonPopoverListening"
|
|
216
|
+
<div
|
|
217
|
+
class="memori-tooltip memori-tooltip--align-topLeft memori-mic-btn-tooltip"
|
|
204
218
|
>
|
|
205
|
-
<
|
|
206
|
-
class="memori-
|
|
219
|
+
<div
|
|
220
|
+
class="memori-tooltip--content"
|
|
207
221
|
>
|
|
208
|
-
<
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
222
|
+
<span>
|
|
223
|
+
write_and_speak.pressAndHoldToSpeak
|
|
224
|
+
</span>
|
|
225
|
+
</div>
|
|
226
|
+
<div
|
|
227
|
+
class="memori-tooltip--trigger"
|
|
228
|
+
>
|
|
229
|
+
<button
|
|
230
|
+
class="memori-button memori-button--primary memori-button--circle memori-button--padded memori-button--icon-only memori-chat-inputs--mic memori-chat-inputs--mic--listening"
|
|
231
|
+
title="write_and_speak.micButtonPopoverListening"
|
|
214
232
|
>
|
|
215
|
-
<
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
233
|
+
<span
|
|
234
|
+
class="memori-button--icon"
|
|
235
|
+
>
|
|
236
|
+
<svg
|
|
237
|
+
aria-hidden="true"
|
|
238
|
+
focusable="false"
|
|
239
|
+
role="img"
|
|
240
|
+
viewBox="0 0 1024 1024"
|
|
241
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
242
|
+
>
|
|
243
|
+
<path
|
|
244
|
+
d="M842 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 140.3-113.7 254-254 254S258 594.3 258 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 168.7 126.6 307.9 290 327.6V884H326.7c-13.7 0-24.7 14.3-24.7 32v36c0 4.4 2.8 8 6.2 8h407.6c3.4 0 6.2-3.6 6.2-8v-36c0-17.7-11-32-24.7-32H548V782.1c165.3-18 294-158 294-328.1zM512 624c93.9 0 170-75.2 170-168V232c0-92.8-76.1-168-170-168s-170 75.2-170 168v224c0 92.8 76.1 168 170 168zm-94-392c0-50.6 41.9-92 94-92s94 41.4 94 92v224c0 50.6-41.9 92-94 92s-94-41.4-94-92V232z"
|
|
245
|
+
/>
|
|
246
|
+
</svg>
|
|
247
|
+
</span>
|
|
248
|
+
</button>
|
|
249
|
+
</div>
|
|
250
|
+
</div>
|
|
221
251
|
</fieldset>
|
|
222
252
|
</div>
|
|
223
253
|
`;
|
|
@@ -337,26 +367,41 @@ exports[`renders ChatInputs on instruct unchanged 1`] = `
|
|
|
337
367
|
</svg>
|
|
338
368
|
</span>
|
|
339
369
|
</button>
|
|
340
|
-
<
|
|
341
|
-
class="memori-
|
|
342
|
-
title="write_and_speak.micButtonPopover"
|
|
370
|
+
<div
|
|
371
|
+
class="memori-tooltip memori-tooltip--align-topLeft memori-mic-btn-tooltip"
|
|
343
372
|
>
|
|
344
|
-
<
|
|
345
|
-
class="memori-
|
|
373
|
+
<div
|
|
374
|
+
class="memori-tooltip--content"
|
|
346
375
|
>
|
|
347
|
-
<
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
376
|
+
<span>
|
|
377
|
+
write_and_speak.pressAndHoldToSpeak
|
|
378
|
+
</span>
|
|
379
|
+
</div>
|
|
380
|
+
<div
|
|
381
|
+
class="memori-tooltip--trigger"
|
|
382
|
+
>
|
|
383
|
+
<button
|
|
384
|
+
class="memori-button memori-button--primary memori-button--circle memori-button--padded memori-button--icon-only memori-chat-inputs--mic"
|
|
385
|
+
title="write_and_speak.micButtonPopover"
|
|
353
386
|
>
|
|
354
|
-
<
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
387
|
+
<span
|
|
388
|
+
class="memori-button--icon"
|
|
389
|
+
>
|
|
390
|
+
<svg
|
|
391
|
+
aria-hidden="true"
|
|
392
|
+
focusable="false"
|
|
393
|
+
role="img"
|
|
394
|
+
viewBox="0 0 1024 1024"
|
|
395
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
396
|
+
>
|
|
397
|
+
<path
|
|
398
|
+
d="M842 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 140.3-113.7 254-254 254S258 594.3 258 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 168.7 126.6 307.9 290 327.6V884H326.7c-13.7 0-24.7 14.3-24.7 32v36c0 4.4 2.8 8 6.2 8h407.6c3.4 0 6.2-3.6 6.2-8v-36c0-17.7-11-32-24.7-32H548V782.1c165.3-18 294-158 294-328.1zM512 624c93.9 0 170-75.2 170-168V232c0-92.8-76.1-168-170-168s-170 75.2-170 168v224c0 92.8 76.1 168 170 168zm-94-392c0-50.6 41.9-92 94-92s94 41.4 94 92v224c0 50.6-41.9 92-94 92s-94-41.4-94-92V232z"
|
|
399
|
+
/>
|
|
400
|
+
</svg>
|
|
401
|
+
</span>
|
|
402
|
+
</button>
|
|
403
|
+
</div>
|
|
404
|
+
</div>
|
|
360
405
|
</fieldset>
|
|
361
406
|
</div>
|
|
362
407
|
`;
|
|
@@ -446,26 +491,41 @@ exports[`renders ChatInputs unchanged 1`] = `
|
|
|
446
491
|
</svg>
|
|
447
492
|
</span>
|
|
448
493
|
</button>
|
|
449
|
-
<
|
|
450
|
-
class="memori-
|
|
451
|
-
title="write_and_speak.micButtonPopover"
|
|
494
|
+
<div
|
|
495
|
+
class="memori-tooltip memori-tooltip--align-topLeft memori-mic-btn-tooltip"
|
|
452
496
|
>
|
|
453
|
-
<
|
|
454
|
-
class="memori-
|
|
497
|
+
<div
|
|
498
|
+
class="memori-tooltip--content"
|
|
455
499
|
>
|
|
456
|
-
<
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
500
|
+
<span>
|
|
501
|
+
write_and_speak.pressAndHoldToSpeak
|
|
502
|
+
</span>
|
|
503
|
+
</div>
|
|
504
|
+
<div
|
|
505
|
+
class="memori-tooltip--trigger"
|
|
506
|
+
>
|
|
507
|
+
<button
|
|
508
|
+
class="memori-button memori-button--primary memori-button--circle memori-button--padded memori-button--icon-only memori-chat-inputs--mic"
|
|
509
|
+
title="write_and_speak.micButtonPopover"
|
|
462
510
|
>
|
|
463
|
-
<
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
511
|
+
<span
|
|
512
|
+
class="memori-button--icon"
|
|
513
|
+
>
|
|
514
|
+
<svg
|
|
515
|
+
aria-hidden="true"
|
|
516
|
+
focusable="false"
|
|
517
|
+
role="img"
|
|
518
|
+
viewBox="0 0 1024 1024"
|
|
519
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
520
|
+
>
|
|
521
|
+
<path
|
|
522
|
+
d="M842 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 140.3-113.7 254-254 254S258 594.3 258 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 168.7 126.6 307.9 290 327.6V884H326.7c-13.7 0-24.7 14.3-24.7 32v36c0 4.4 2.8 8 6.2 8h407.6c3.4 0 6.2-3.6 6.2-8v-36c0-17.7-11-32-24.7-32H548V782.1c165.3-18 294-158 294-328.1zM512 624c93.9 0 170-75.2 170-168V232c0-92.8-76.1-168-170-168s-170 75.2-170 168v224c0 92.8 76.1 168 170 168zm-94-392c0-50.6 41.9-92 94-92s94 41.4 94 92v224c0 50.6-41.9 92-94 92s-94-41.4-94-92V232z"
|
|
523
|
+
/>
|
|
524
|
+
</svg>
|
|
525
|
+
</span>
|
|
526
|
+
</button>
|
|
527
|
+
</div>
|
|
528
|
+
</div>
|
|
469
529
|
</fieldset>
|
|
470
530
|
</div>
|
|
471
531
|
`;
|
|
@@ -556,26 +616,41 @@ exports[`renders ChatInputs with user message unchanged 1`] = `
|
|
|
556
616
|
</svg>
|
|
557
617
|
</span>
|
|
558
618
|
</button>
|
|
559
|
-
<
|
|
560
|
-
class="memori-
|
|
561
|
-
title="write_and_speak.micButtonPopover"
|
|
619
|
+
<div
|
|
620
|
+
class="memori-tooltip memori-tooltip--align-topLeft memori-mic-btn-tooltip"
|
|
562
621
|
>
|
|
563
|
-
<
|
|
564
|
-
class="memori-
|
|
622
|
+
<div
|
|
623
|
+
class="memori-tooltip--content"
|
|
565
624
|
>
|
|
566
|
-
<
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
625
|
+
<span>
|
|
626
|
+
write_and_speak.pressAndHoldToSpeak
|
|
627
|
+
</span>
|
|
628
|
+
</div>
|
|
629
|
+
<div
|
|
630
|
+
class="memori-tooltip--trigger"
|
|
631
|
+
>
|
|
632
|
+
<button
|
|
633
|
+
class="memori-button memori-button--primary memori-button--circle memori-button--padded memori-button--icon-only memori-chat-inputs--mic"
|
|
634
|
+
title="write_and_speak.micButtonPopover"
|
|
572
635
|
>
|
|
573
|
-
<
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
636
|
+
<span
|
|
637
|
+
class="memori-button--icon"
|
|
638
|
+
>
|
|
639
|
+
<svg
|
|
640
|
+
aria-hidden="true"
|
|
641
|
+
focusable="false"
|
|
642
|
+
role="img"
|
|
643
|
+
viewBox="0 0 1024 1024"
|
|
644
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
645
|
+
>
|
|
646
|
+
<path
|
|
647
|
+
d="M842 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 140.3-113.7 254-254 254S258 594.3 258 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 168.7 126.6 307.9 290 327.6V884H326.7c-13.7 0-24.7 14.3-24.7 32v36c0 4.4 2.8 8 6.2 8h407.6c3.4 0 6.2-3.6 6.2-8v-36c0-17.7-11-32-24.7-32H548V782.1c165.3-18 294-158 294-328.1zM512 624c93.9 0 170-75.2 170-168V232c0-92.8-76.1-168-170-168s-170 75.2-170 168v224c0 92.8 76.1 168 170 168zm-94-392c0-50.6 41.9-92 94-92s94 41.4 94 92v224c0 50.6-41.9 92-94 92s-94-41.4-94-92V232z"
|
|
648
|
+
/>
|
|
649
|
+
</svg>
|
|
650
|
+
</span>
|
|
651
|
+
</button>
|
|
652
|
+
</div>
|
|
653
|
+
</div>
|
|
579
654
|
</fieldset>
|
|
580
655
|
</div>
|
|
581
656
|
`;
|
|
@@ -46,6 +46,9 @@ const Template: Story<Props> = args => {
|
|
|
46
46
|
continuousSpeechTimeout={continuousSpeechTimeout}
|
|
47
47
|
setContinuousSpeech={setContinuousSpeech}
|
|
48
48
|
setContinuousSpeechTimeout={setContinuousSpeechTimeout}
|
|
49
|
+
setControlsPosition={() => {}}
|
|
50
|
+
controlsPosition="bottom"
|
|
51
|
+
setHideEmissions={() => {}}
|
|
49
52
|
/>
|
|
50
53
|
</>
|
|
51
54
|
);
|
|
@@ -251,18 +251,19 @@ const MemoriWidget = ({
|
|
|
251
251
|
?.find(c => c.memoriConfigID === memori.memoriConfigurationID)
|
|
252
252
|
?.culture?.split('-')?.[0]
|
|
253
253
|
?.toUpperCase();
|
|
254
|
-
|
|
254
|
+
const integrationConfig = integration?.customData
|
|
255
|
+
? JSON.parse(integration.customData)
|
|
256
|
+
: null;
|
|
257
|
+
const isMultilanguageEnabled = !!integrationConfig?.multilanguage;
|
|
255
258
|
const [userLang, setUserLang] = useState(
|
|
256
|
-
|
|
259
|
+
integrationConfig?.lang ??
|
|
260
|
+
memoriLang ??
|
|
257
261
|
memori?.culture?.split('-')?.[0] ??
|
|
258
262
|
language ??
|
|
263
|
+
integrationConfig?.uiLang ??
|
|
259
264
|
i18n.language ??
|
|
260
265
|
'IT'
|
|
261
266
|
);
|
|
262
|
-
const integrationConfig = integration?.customData
|
|
263
|
-
? JSON.parse(integration.customData)
|
|
264
|
-
: null;
|
|
265
|
-
const isMultilanguageEnabled = !!integrationConfig?.multilanguage;
|
|
266
267
|
|
|
267
268
|
const [loading, setLoading] = useState(false);
|
|
268
269
|
const [memoriTyping, setMemoriTyping] = useState(false);
|
|
@@ -275,7 +276,7 @@ const MemoriWidget = ({
|
|
|
275
276
|
const [showPositionDrawer, setShowPositionDrawer] = useState(false);
|
|
276
277
|
const [showSettingsDrawer, setShowSettingsDrawer] = useState(false);
|
|
277
278
|
const [muteSpeaker, setMuteSpeaker] = useState(false);
|
|
278
|
-
const [continuousSpeech, setContinuousSpeech] = useState(
|
|
279
|
+
const [continuousSpeech, setContinuousSpeech] = useState(false);
|
|
279
280
|
const [continuousSpeechTimeout, setContinuousSpeechTimeout] = useState(2);
|
|
280
281
|
const [isPlayingAudio, setIsPlayingAudio] = useState(false);
|
|
281
282
|
const [controlsPosition, setControlsPosition] = useState<'center' | 'bottom'>(
|
|
@@ -289,9 +290,16 @@ const MemoriWidget = ({
|
|
|
289
290
|
|
|
290
291
|
useEffect(() => {
|
|
291
292
|
let defaultControlsPosition: 'center' | 'bottom' = 'bottom';
|
|
292
|
-
|
|
293
|
+
let microphoneMode = getLocalConfig<string>(
|
|
294
|
+
'microphoneMode',
|
|
295
|
+
'HOLD_TO_TALK'
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
if (window.innerWidth <= 768) {
|
|
293
299
|
// on mobile, default position is bottom
|
|
294
300
|
defaultControlsPosition = 'bottom';
|
|
301
|
+
// on mobile, keep only HOLD_TO_TALK mode
|
|
302
|
+
microphoneMode = 'HOLD_TO_TALK';
|
|
295
303
|
} else if (
|
|
296
304
|
window.matchMedia('(orientation: portrait)').matches ||
|
|
297
305
|
window.innerHeight > window.innerWidth
|
|
@@ -304,7 +312,7 @@ const MemoriWidget = ({
|
|
|
304
312
|
}
|
|
305
313
|
|
|
306
314
|
setMuteSpeaker(getLocalConfig('muteSpeaker', false));
|
|
307
|
-
setContinuousSpeech(
|
|
315
|
+
setContinuousSpeech(microphoneMode === 'CONTINUOUS');
|
|
308
316
|
setContinuousSpeechTimeout(getLocalConfig('continuousSpeechTimeout', 2));
|
|
309
317
|
setControlsPosition(
|
|
310
318
|
getLocalConfig('controlsPosition', defaultControlsPosition)
|
|
@@ -944,6 +952,10 @@ const MemoriWidget = ({
|
|
|
944
952
|
}
|
|
945
953
|
}
|
|
946
954
|
|
|
955
|
+
if (memori.enableCompletions) {
|
|
956
|
+
timeout = timeout + 60;
|
|
957
|
+
}
|
|
958
|
+
|
|
947
959
|
let uiTimeout = setTimeout(handleTimeout, timeout * 1000);
|
|
948
960
|
setUserInteractionTimeout(uiTimeout);
|
|
949
961
|
timeoutRef.current = uiTimeout;
|
|
@@ -1442,6 +1454,7 @@ const MemoriWidget = ({
|
|
|
1442
1454
|
|
|
1443
1455
|
clearListening();
|
|
1444
1456
|
setTranscript('');
|
|
1457
|
+
resetTranscript();
|
|
1445
1458
|
|
|
1446
1459
|
try {
|
|
1447
1460
|
navigator.mediaDevices
|
|
@@ -1498,6 +1511,8 @@ const MemoriWidget = ({
|
|
|
1498
1511
|
recognizer.sessionStopped = (_s, _e) => {
|
|
1499
1512
|
stopListening();
|
|
1500
1513
|
};
|
|
1514
|
+
|
|
1515
|
+
resetTranscript();
|
|
1501
1516
|
recognizer.startContinuousRecognitionAsync();
|
|
1502
1517
|
})
|
|
1503
1518
|
.catch(console.error);
|
|
@@ -1595,7 +1610,8 @@ const MemoriWidget = ({
|
|
|
1595
1610
|
'sendOnEnter',
|
|
1596
1611
|
'keypress'
|
|
1597
1612
|
);
|
|
1598
|
-
setSendOnEnter(
|
|
1613
|
+
if (window.innerWidth <= 768) setSendOnEnter('click');
|
|
1614
|
+
else setSendOnEnter(stored);
|
|
1599
1615
|
}, []);
|
|
1600
1616
|
useEffect(() => {
|
|
1601
1617
|
setLocalConfig('sendOnEnter', sendOnEnter);
|
|
@@ -2217,6 +2233,7 @@ const MemoriWidget = ({
|
|
|
2217
2233
|
selectReceiverTag={selectReceiverTag}
|
|
2218
2234
|
preview={preview}
|
|
2219
2235
|
sendOnEnter={sendOnEnter}
|
|
2236
|
+
microphoneMode={continuousSpeech ? 'CONTINUOUS' : 'HOLD_TO_TALK'}
|
|
2220
2237
|
setSendOnEnter={setSendOnEnter}
|
|
2221
2238
|
attachmentsMenuOpen={attachmentsMenuOpen}
|
|
2222
2239
|
setAttachmentsMenuOpen={setAttachmentsMenuOpen}
|
|
@@ -2405,9 +2422,9 @@ const MemoriWidget = ({
|
|
|
2405
2422
|
layout={selectedLayout}
|
|
2406
2423
|
open={!!showSettingsDrawer}
|
|
2407
2424
|
onClose={() => setShowSettingsDrawer(false)}
|
|
2408
|
-
|
|
2425
|
+
microphoneMode={continuousSpeech ? 'CONTINUOUS' : 'HOLD_TO_TALK'}
|
|
2409
2426
|
continuousSpeechTimeout={continuousSpeechTimeout}
|
|
2410
|
-
|
|
2427
|
+
setMicrophoneMode={mode => setContinuousSpeech(mode === 'CONTINUOUS')}
|
|
2411
2428
|
setContinuousSpeechTimeout={setContinuousSpeechTimeout}
|
|
2412
2429
|
controlsPosition={controlsPosition}
|
|
2413
2430
|
setControlsPosition={setControlsPosition}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
.memori-mic-btn-tooltip.memori-tooltip.memori-tooltip--align-topLeft:not(.memori-tooltip--disabled).memori-tooltip--visible .memori-tooltip--content,
|
|
2
|
+
.memori-mic-btn-tooltip.memori-tooltip.memori-tooltip--align-topLeft:not(.memori-tooltip--disabled):not(.memori-tooltip--visible):hover .memori-tooltip--content {
|
|
3
|
+
touch-action: none;
|
|
4
|
+
transform: translateY(-180%) translateX(27%);
|
|
5
|
+
-webkit-user-select: none;
|
|
6
|
+
user-select: none;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.memori-chat-inputs--mic {
|
|
10
|
+
z-index: 1;
|
|
11
|
+
margin-left: 0.33rem;
|
|
12
|
+
touch-action: none;
|
|
13
|
+
-webkit-user-select: none;
|
|
14
|
+
user-select: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.memori-chat-inputs--mic svg {
|
|
18
|
+
color: var(--memori-primary-text, #fff);
|
|
19
|
+
font-size: 1em;
|
|
20
|
+
touch-action: none;
|
|
21
|
+
-webkit-user-select: none;
|
|
22
|
+
user-select: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.memori-chat-inputs--mic:hover,
|
|
26
|
+
.memori-chat-inputs--mic:active,
|
|
27
|
+
.memori-chat-inputs--mic:focus {
|
|
28
|
+
border-color: var(--memori-primary) !important;
|
|
29
|
+
color: var(--memori-primary-text, #fff);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.memori-chat-inputs--mic:active,
|
|
33
|
+
.memori-chat-inputs--mic:focus {
|
|
34
|
+
box-shadow: 0 0.2rem 0.33rem var(--memori-primary) !important;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.memori-chat-inputs--mic:not(.memori-chat-inputs--mic--listening):active,
|
|
38
|
+
.memori-chat-inputs--mic:not(.memori-chat-inputs--mic--listening):focus {
|
|
39
|
+
color: var(--memori-primary) !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@keyframes micBtnActivePulse {
|
|
43
|
+
0% {
|
|
44
|
+
transform: scale(1.25);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
25% {
|
|
48
|
+
transform: scale(1.4);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
50% {
|
|
52
|
+
transform: scale(1.3);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
75% {
|
|
56
|
+
transform: scale(1.4);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
100% {
|
|
60
|
+
transform: scale(1.2);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.memori-chat-inputs--mic.memori-chat-inputs--mic--listening {
|
|
65
|
+
position: relative;
|
|
66
|
+
color: red !important;
|
|
67
|
+
transform: scale(1.5);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.memori-chat-inputs--mic.memori-chat-inputs--mic--listening::before,
|
|
71
|
+
.memori-chat-inputs--mic.memori-chat-inputs--mic--listening::after {
|
|
72
|
+
position: absolute;
|
|
73
|
+
z-index: -1;
|
|
74
|
+
top: 0;
|
|
75
|
+
left: 0;
|
|
76
|
+
width: 100%;
|
|
77
|
+
height: 100%;
|
|
78
|
+
border-radius: 50%;
|
|
79
|
+
animation: micBtnActivePulse 2s infinite;
|
|
80
|
+
background: var(--memori-primary);
|
|
81
|
+
content: "";
|
|
82
|
+
opacity: 0.2;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.memori-chat-inputs--mic.memori-chat-inputs--mic--listening::after {
|
|
86
|
+
top: 5%;
|
|
87
|
+
left: 5%;
|
|
88
|
+
width: 90%;
|
|
89
|
+
height: 90%;
|
|
90
|
+
animation-delay: 0.3s;
|
|
91
|
+
opacity: 0.3;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.memori-chat-inputs--mic.memori-chat-inputs--mic--listening:active,
|
|
95
|
+
.memori-chat-inputs--mic.memori-chat-inputs--mic--listening:focus {
|
|
96
|
+
border-color: red !important;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.memori-chat-inputs--mic.memori-chat-inputs--mic--listening svg {
|
|
100
|
+
color: red !important;
|
|
101
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, Story } from '@storybook/react';
|
|
3
|
+
import MicrophoneButton, { Props } from './MicrophoneButton';
|
|
4
|
+
|
|
5
|
+
import './MicrophoneButton.css';
|
|
6
|
+
|
|
7
|
+
const meta: Meta = {
|
|
8
|
+
title: 'Widget/Microphone Button',
|
|
9
|
+
component: MicrophoneButton,
|
|
10
|
+
argTypes: {
|
|
11
|
+
disabled: {
|
|
12
|
+
control: {
|
|
13
|
+
type: 'boolean',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
parameters: {
|
|
18
|
+
controls: { expanded: true },
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
|
|
24
|
+
const Template: Story<Props> = args => {
|
|
25
|
+
const [listening, setListening] = React.useState(args.listening);
|
|
26
|
+
const startListening = () => setListening(true);
|
|
27
|
+
const stopListening = () => setListening(false);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div style={{ paddingTop: '10rem', textAlign: 'right' }}>
|
|
31
|
+
<MicrophoneButton
|
|
32
|
+
{...args}
|
|
33
|
+
listening={listening}
|
|
34
|
+
startListening={startListening}
|
|
35
|
+
stopListening={stopListening}
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
|
|
42
|
+
// https://storybook.js.org/docs/react/workflows/unit-testing
|
|
43
|
+
export const Default = Template.bind({});
|
|
44
|
+
Default.args = {
|
|
45
|
+
listening: false,
|
|
46
|
+
stopAudio: () => {},
|
|
47
|
+
startListening: () => {},
|
|
48
|
+
stopListening: () => {},
|
|
49
|
+
};
|