@memori.ai/memori-react 2.1.0 → 2.2.1
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 +37 -0
- package/dist/components/Avatar/Avatar.css +0 -1
- package/dist/components/Blob/Blob.css +6 -1
- package/dist/components/ChangeMode/ChangeMode.css +1 -1
- package/dist/components/Chat/Chat.css +3 -2
- 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.css +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/ChatTextArea/ChatTextArea.css +7 -3
- package/dist/components/DateSelector/DateSelector.css +17 -15
- package/dist/components/ExportHistoryButton/ExportHistoryButton.css +1 -1
- package/dist/components/FeedbackButtons/FeedbackButtons.css +4 -4
- package/dist/components/FeedbackButtons/FeedbackButtons.js +1 -1
- package/dist/components/FeedbackButtons/FeedbackButtons.js.map +1 -1
- package/dist/components/Header/Header.css +2 -1
- package/dist/components/Header/Header.js +1 -1
- package/dist/components/Header/Header.js.map +1 -1
- package/dist/components/ImageUpload/ImageUpload.css +2 -3
- package/dist/components/MediaWidget/MediaItemWidget.css +2 -0
- package/dist/components/MediaWidget/MediaWidget.css +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.css +1 -2
- package/dist/components/MemoriWidget/MemoriWidget.js +23 -13
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/MicrophoneButton/MicrophoneButton.css +107 -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.css +1 -1
- package/dist/components/StartPanel/StartPanel.js +1 -1
- package/dist/components/StartPanel/StartPanel.js.map +1 -1
- package/dist/components/layouts/totem.css +49 -8
- package/dist/components/ui/Button.css +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/Checkbox.css +0 -2
- package/dist/components/ui/Drawer.css +1 -1
- package/dist/components/ui/Modal.css +1 -1
- package/dist/components/ui/Select.css +17 -16
- package/dist/components/ui/Tooltip.css +38 -3
- 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/helpers/translations.js +1 -2
- package/dist/helpers/translations.js.map +1 -1
- package/dist/locales/en.json +4 -0
- package/dist/locales/it.json +4 -0
- package/dist/styles.css +2 -1
- package/esm/components/Avatar/Avatar.css +0 -1
- package/esm/components/Blob/Blob.css +6 -1
- package/esm/components/ChangeMode/ChangeMode.css +1 -1
- package/esm/components/Chat/Chat.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.css +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/ChatTextArea/ChatTextArea.css +7 -3
- package/esm/components/DateSelector/DateSelector.css +17 -15
- package/esm/components/ExportHistoryButton/ExportHistoryButton.css +1 -1
- package/esm/components/FeedbackButtons/FeedbackButtons.css +4 -4
- package/esm/components/FeedbackButtons/FeedbackButtons.js +1 -1
- package/esm/components/FeedbackButtons/FeedbackButtons.js.map +1 -1
- package/esm/components/Header/Header.css +2 -1
- package/esm/components/Header/Header.js +1 -1
- package/esm/components/Header/Header.js.map +1 -1
- package/esm/components/ImageUpload/ImageUpload.css +2 -3
- package/esm/components/MediaWidget/MediaItemWidget.css +2 -0
- package/esm/components/MediaWidget/MediaWidget.css +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.css +1 -2
- package/esm/components/MemoriWidget/MemoriWidget.js +23 -13
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/MicrophoneButton/MicrophoneButton.css +107 -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.css +1 -1
- package/esm/components/StartPanel/StartPanel.js +1 -1
- package/esm/components/StartPanel/StartPanel.js.map +1 -1
- package/esm/components/layouts/totem.css +49 -8
- package/esm/components/ui/Button.css +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/Checkbox.css +0 -2
- package/esm/components/ui/Drawer.css +1 -1
- package/esm/components/ui/Modal.css +1 -1
- package/esm/components/ui/Select.css +17 -16
- package/esm/components/ui/Tooltip.css +38 -3
- 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/helpers/translations.js +1 -2
- package/esm/helpers/translations.js.map +1 -1
- package/esm/locales/en.json +4 -0
- package/esm/locales/it.json +4 -0
- package/esm/styles.css +2 -1
- package/package.json +1 -1
- package/src/components/Avatar/Avatar.css +0 -1
- package/src/components/Blob/Blob.css +6 -1
- package/src/components/BlockedMemoriBadge/__snapshots__/BlockedMemoriBadge.test.tsx.snap +4 -4
- package/src/components/ChangeMode/ChangeMode.css +1 -1
- package/src/components/Chat/Chat.css +3 -2
- package/src/components/Chat/Chat.tsx +3 -0
- package/src/components/ChatBubble/ChatBubble.css +1 -1
- 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/ChatTextArea/ChatTextArea.css +7 -3
- package/src/components/DateSelector/DateSelector.css +17 -15
- package/src/components/ExportHistoryButton/ExportHistoryButton.css +1 -1
- package/src/components/FeedbackButtons/FeedbackButtons.css +4 -4
- package/src/components/FeedbackButtons/FeedbackButtons.tsx +1 -1
- package/src/components/Header/Header.css +2 -1
- package/src/components/Header/Header.stories.tsx +3 -0
- package/src/components/Header/Header.tsx +1 -1
- package/src/components/Header/__snapshots__/Header.test.tsx.snap +1 -1
- package/src/components/ImageUpload/ImageUpload.css +2 -3
- package/src/components/MediaWidget/MediaItemWidget.css +2 -0
- package/src/components/MediaWidget/MediaWidget.css +1 -1
- package/src/components/MemoriWidget/MemoriWidget.css +1 -2
- package/src/components/MemoriWidget/MemoriWidget.tsx +29 -12
- package/src/components/MicrophoneButton/MicrophoneButton.css +107 -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.css +1 -1
- package/src/components/StartPanel/StartPanel.tsx +3 -3
- package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +1 -1
- package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +1 -1
- package/src/components/layouts/totem.css +49 -8
- package/src/components/ui/Button.css +1 -1
- package/src/components/ui/Button.tsx +21 -1
- package/src/components/ui/Checkbox.css +0 -2
- package/src/components/ui/Drawer.css +1 -1
- package/src/components/ui/Modal.css +1 -1
- package/src/components/ui/Select.css +17 -16
- package/src/components/ui/Tooltip.css +38 -3
- 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/helpers/translations.ts +3 -2
- package/src/locales/en.json +4 -0
- package/src/locales/it.json +4 -0
- package/src/styles.css +2 -1
package/esm/locales/it.json
CHANGED
|
@@ -70,6 +70,10 @@
|
|
|
70
70
|
"conversationStartedLabel": "Conversazione avvenuta il",
|
|
71
71
|
"settingsHeaderLabel": "Configura qui il memori se vuoi impostare una conversazione continua. Setta i secondi di silenzio prima dell'invio.",
|
|
72
72
|
"continuousSpeechLabel": "Conversazione continua",
|
|
73
|
+
"holdToSpeak": "Tieni premuto per parlare",
|
|
74
|
+
"releaseToEndListening": "Rilascia per smettere di parlare",
|
|
75
|
+
"pressAndHoldToSpeak": "Premi e tieni premuto per parlare",
|
|
76
|
+
"microphoneMode": "Modalità microfono",
|
|
73
77
|
"hideEmissionsLabel": "Nascondi testo emesso dal Twin",
|
|
74
78
|
"secondsLabel": "Secondi",
|
|
75
79
|
"controlsPosition": "Posizione dei controlli",
|
package/esm/styles.css
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
@import url('./components/Chat/Chat.css');
|
|
18
18
|
@import url('./components/ChatBubble/ChatBubble.css');
|
|
19
19
|
@import url('./components/ChatInputs/ChatInputs.css');
|
|
20
|
+
@import url('./components/MicrophoneButton/MicrophoneButton.css');
|
|
20
21
|
@import url('./components/ChatTextArea/ChatTextArea.css');
|
|
21
22
|
@import url('./components/CustomGLBModelViewer/ModelViewer.css');
|
|
22
23
|
@import url('./components/SettingsDrawer/SettingsDrawer.css');
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
|
|
56
57
|
memori-client,
|
|
57
58
|
memori-client #root,
|
|
58
|
-
memori-client
|
|
59
|
+
memori-client ~ #headlessui-portal-root,
|
|
59
60
|
body.sb-show-main #root,
|
|
60
61
|
body.sb-show-main #headlessui-portal-root,
|
|
61
62
|
#storybook-root,
|
package/package.json
CHANGED
|
@@ -93,20 +93,25 @@
|
|
|
93
93
|
filter: brightness(1);
|
|
94
94
|
transform: scale(1);
|
|
95
95
|
}
|
|
96
|
+
|
|
96
97
|
15% {
|
|
97
98
|
filter: brightness(1.1);
|
|
98
99
|
}
|
|
100
|
+
|
|
99
101
|
30% {
|
|
100
102
|
filter: brightness(1);
|
|
101
103
|
transform: scale(0.99);
|
|
102
104
|
}
|
|
105
|
+
|
|
103
106
|
50% {
|
|
104
107
|
filter: brightness(1.05);
|
|
105
108
|
transform: scale(1.01);
|
|
106
109
|
}
|
|
110
|
+
|
|
107
111
|
75% {
|
|
108
112
|
filter: brightness(1.15);
|
|
109
113
|
}
|
|
114
|
+
|
|
110
115
|
100% {
|
|
111
116
|
filter: brightness(1.1);
|
|
112
117
|
transform: scale(0.99);
|
|
@@ -140,7 +145,7 @@
|
|
|
140
145
|
object-fit: contain;
|
|
141
146
|
}
|
|
142
147
|
|
|
143
|
-
.memori-blob figure
|
|
148
|
+
.memori-blob figure ~ .mainDiv {
|
|
144
149
|
opacity: 0.2;
|
|
145
150
|
}
|
|
146
151
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`renders BlockedMemoriBadge unchanged 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<div
|
|
6
|
-
class="memori-tooltip blocked-memori-badge--tooltip"
|
|
6
|
+
class="memori-tooltip memori-tooltip--align-right blocked-memori-badge--tooltip"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
9
9
|
class="memori-tooltip--content"
|
|
@@ -41,7 +41,7 @@ exports[`renders BlockedMemoriBadge unchanged 1`] = `
|
|
|
41
41
|
exports[`renders BlockedMemoriBadge with giver info unchanged 1`] = `
|
|
42
42
|
<div>
|
|
43
43
|
<div
|
|
44
|
-
class="memori-tooltip blocked-memori-badge--tooltip"
|
|
44
|
+
class="memori-tooltip memori-tooltip--align-right blocked-memori-badge--tooltip"
|
|
45
45
|
>
|
|
46
46
|
<div
|
|
47
47
|
class="memori-tooltip--content"
|
|
@@ -83,7 +83,7 @@ memoriBlockedGiverHelper
|
|
|
83
83
|
exports[`renders BlockedMemoriBadge with margin left unchanged 1`] = `
|
|
84
84
|
<div>
|
|
85
85
|
<div
|
|
86
|
-
class="memori-tooltip blocked-memori-badge--tooltip"
|
|
86
|
+
class="memori-tooltip memori-tooltip--align-right blocked-memori-badge--tooltip"
|
|
87
87
|
>
|
|
88
88
|
<div
|
|
89
89
|
class="memori-tooltip--content"
|
|
@@ -121,7 +121,7 @@ exports[`renders BlockedMemoriBadge with margin left unchanged 1`] = `
|
|
|
121
121
|
exports[`renders BlockedMemoriBadge with title unchanged 1`] = `
|
|
122
122
|
<div>
|
|
123
123
|
<div
|
|
124
|
-
class="memori-tooltip blocked-memori-badge--tooltip"
|
|
124
|
+
class="memori-tooltip memori-tooltip--align-right blocked-memori-badge--tooltip"
|
|
125
125
|
>
|
|
126
126
|
<div
|
|
127
127
|
class="memori-tooltip--content"
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
padding: calc(var(--memori-inner-content-pad) / 4) calc(var(--memori-inner-content-pad) / 2);
|
|
13
13
|
border-radius: 10px;
|
|
14
14
|
margin: 1rem 0;
|
|
15
|
+
-webkit-backdrop-filter: blur(10px);
|
|
15
16
|
backdrop-filter: blur(10px);
|
|
16
17
|
background-color: var(--memori-inner-bg);
|
|
17
18
|
}
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
border-top-right-radius: 3px;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
.memori-chat--cover
|
|
52
|
+
.memori-chat--cover + .memori-chat--bubble-initial {
|
|
52
53
|
display: none;
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -102,7 +103,7 @@
|
|
|
102
103
|
white-space: nowrap;
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
.memori-chat--context-tag
|
|
106
|
+
.memori-chat--context-tag + .memori-chat--context-tag {
|
|
106
107
|
margin-top: 0.5rem;
|
|
107
108
|
}
|
|
108
109
|
|
|
@@ -34,6 +34,7 @@ export interface Props {
|
|
|
34
34
|
client: ReturnType<typeof memoriApiClient>;
|
|
35
35
|
selectReceiverTag: (tag: string) => Promise<void>;
|
|
36
36
|
preview?: boolean;
|
|
37
|
+
microphoneMode?: 'CONTINUOUS' | 'HOLD_TO_TALK';
|
|
37
38
|
sendOnEnter?: 'keypress' | 'click';
|
|
38
39
|
setSendOnEnter: (sendOnEnter: 'keypress' | 'click') => void;
|
|
39
40
|
attachmentsMenuOpen?: 'link' | 'media';
|
|
@@ -72,6 +73,7 @@ const Chat: React.FC<Props> = ({
|
|
|
72
73
|
instruct = false,
|
|
73
74
|
showInputs = true,
|
|
74
75
|
showMicrophone = false,
|
|
76
|
+
microphoneMode = 'HOLD_TO_TALK',
|
|
75
77
|
sendOnEnter,
|
|
76
78
|
setSendOnEnter,
|
|
77
79
|
attachmentsMenuOpen,
|
|
@@ -309,6 +311,7 @@ const Chat: React.FC<Props> = ({
|
|
|
309
311
|
instruct={instruct}
|
|
310
312
|
authToken={authToken}
|
|
311
313
|
sendMessage={sendMessage}
|
|
314
|
+
microphoneMode={microphoneMode}
|
|
312
315
|
sendOnEnter={sendOnEnter}
|
|
313
316
|
setSendOnEnter={setSendOnEnter}
|
|
314
317
|
attachmentsMenuOpen={attachmentsMenuOpen}
|
|
@@ -74,7 +74,7 @@ exports[`renders ChatBubble with msg generated by AI unchanged 1`] = `
|
|
|
74
74
|
class="memori-chat--bubble-addon"
|
|
75
75
|
>
|
|
76
76
|
<div
|
|
77
|
-
class="memori-tooltip memori-chat--bubble-ai-icon
|
|
77
|
+
class="memori-tooltip memori-tooltip--align-left memori-chat--bubble-ai-icon"
|
|
78
78
|
>
|
|
79
79
|
<div
|
|
80
80
|
class="memori-tooltip--content"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
margin: 0;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.memori-chat-inputs .memori-upload-menu
|
|
14
|
+
.memori-chat-inputs .memori-upload-menu + .memori-send-on-enter-menu {
|
|
15
15
|
margin-left: 0.33rem;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -19,43 +19,3 @@
|
|
|
19
19
|
background: #fff;
|
|
20
20
|
color: #000;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
.memori-chat-inputs--mic {
|
|
24
|
-
z-index: 1;
|
|
25
|
-
margin-left: 0.33rem;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.memori-chat-inputs--mic svg {
|
|
29
|
-
color: var(--memori-primary-text, #fff);
|
|
30
|
-
font-size: 1em;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.memori-chat-inputs--mic:hover,
|
|
34
|
-
.memori-chat-inputs--mic:active,
|
|
35
|
-
.memori-chat-inputs--mic:focus {
|
|
36
|
-
border-color: var(--memori-primary) !important;
|
|
37
|
-
color: var(--memori-primary-text, #fff);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.memori-chat-inputs--mic:active,
|
|
41
|
-
.memori-chat-inputs--mic:focus {
|
|
42
|
-
box-shadow: 0 0.2rem 0.33rem var(--memori-primary) !important;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.memori-chat-inputs--mic:not(.memori-chat-inputs--mic--listening):active,
|
|
46
|
-
.memori-chat-inputs--mic:not(.memori-chat-inputs--mic--listening):focus {
|
|
47
|
-
color: var(--memori-primary) !important;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.memori-chat-inputs--mic.memori-chat-inputs--mic--listening {
|
|
51
|
-
color: red !important;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.memori-chat-inputs--mic.memori-chat-inputs--mic--listening:active,
|
|
55
|
-
.memori-chat-inputs--mic.memori-chat-inputs--mic--listening:focus {
|
|
56
|
-
border-color: red !important;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.memori-chat-inputs--mic.memori-chat-inputs--mic--listening svg {
|
|
60
|
-
color: red !important;
|
|
61
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import { Meta, Story } from '@storybook/react';
|
|
3
3
|
import ChatInputs, { Props } from './ChatInputs';
|
|
4
4
|
import { dialogState } from '../../mocks/data';
|
|
@@ -22,13 +22,40 @@ const meta: Meta = {
|
|
|
22
22
|
|
|
23
23
|
export default meta;
|
|
24
24
|
|
|
25
|
+
const text =
|
|
26
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
|
|
27
|
+
.split(' ')
|
|
28
|
+
.reverse();
|
|
29
|
+
|
|
25
30
|
const Template: Story<Props> = args => {
|
|
26
31
|
const [userMessage, setUserMessage] = React.useState(args.userMessage);
|
|
32
|
+
const [listening, setListening] = React.useState(args.listening);
|
|
33
|
+
const startListening = () => setListening(true);
|
|
34
|
+
const stopListening = () => setListening(false);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (listening) {
|
|
38
|
+
const interval = setInterval(() => {
|
|
39
|
+
let nextWord = text.pop();
|
|
40
|
+
|
|
41
|
+
if (!nextWord) {
|
|
42
|
+
clearInterval(interval);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
setUserMessage(prev => `${prev || ''}${prev ? ' ' : ''}${nextWord}`);
|
|
47
|
+
}, Math.random() * 500 + 100);
|
|
48
|
+
return () => clearInterval(interval);
|
|
49
|
+
}
|
|
50
|
+
}, [listening]);
|
|
27
51
|
|
|
28
52
|
return (
|
|
29
53
|
<div style={{ paddingTop: '10rem' }}>
|
|
30
54
|
<ChatInputs
|
|
31
55
|
{...args}
|
|
56
|
+
listening={listening}
|
|
57
|
+
startListening={startListening}
|
|
58
|
+
stopListening={stopListening}
|
|
32
59
|
userMessage={userMessage}
|
|
33
60
|
onChangeUserMessage={setUserMessage}
|
|
34
61
|
/>
|
|
@@ -159,8 +186,27 @@ Disabled.args = {
|
|
|
159
186
|
showMicrophone: true,
|
|
160
187
|
};
|
|
161
188
|
|
|
162
|
-
export const
|
|
163
|
-
|
|
189
|
+
export const ContinuousSpeech = Template.bind({});
|
|
190
|
+
ContinuousSpeech.args = {
|
|
191
|
+
dialogState,
|
|
192
|
+
userMessage: 'Suspendisse sit amet volutpat velit.',
|
|
193
|
+
sendMessage: (msg: string) => console.log(msg),
|
|
194
|
+
onTextareaBlur: () => {},
|
|
195
|
+
onTextareaFocus: () => {},
|
|
196
|
+
onTextareaPressEnter: () => {},
|
|
197
|
+
setAttachmentsMenuOpen: () => {},
|
|
198
|
+
setSendOnEnter: () => {},
|
|
199
|
+
listening: false,
|
|
200
|
+
isPlayingAudio: false,
|
|
201
|
+
stopAudio: () => {},
|
|
202
|
+
startListening: () => {},
|
|
203
|
+
stopListening: () => {},
|
|
204
|
+
showMicrophone: true,
|
|
205
|
+
microphoneMode: 'CONTINUOUS',
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export const ContinuousSpeechListening = Template.bind({});
|
|
209
|
+
ContinuousSpeechListening.args = {
|
|
164
210
|
dialogState,
|
|
165
211
|
userMessage: 'Suspendisse sit amet volutpat velit.',
|
|
166
212
|
sendMessage: (msg: string) => console.log(msg),
|
|
@@ -175,6 +221,7 @@ Listening.args = {
|
|
|
175
221
|
startListening: () => {},
|
|
176
222
|
stopListening: () => {},
|
|
177
223
|
showMicrophone: true,
|
|
224
|
+
microphoneMode: 'CONTINUOUS',
|
|
178
225
|
};
|
|
179
226
|
|
|
180
227
|
export const WithoutMicrophone = Template.bind({});
|
|
@@ -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', {
|