@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.
Files changed (182) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/components/Avatar/Avatar.css +0 -1
  3. package/dist/components/Blob/Blob.css +6 -1
  4. package/dist/components/ChangeMode/ChangeMode.css +1 -1
  5. package/dist/components/Chat/Chat.css +3 -2
  6. package/dist/components/Chat/Chat.d.ts +1 -0
  7. package/dist/components/Chat/Chat.js +2 -2
  8. package/dist/components/Chat/Chat.js.map +1 -1
  9. package/dist/components/ChatBubble/ChatBubble.css +1 -1
  10. package/dist/components/ChatBubble/ChatBubble.js +1 -1
  11. package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
  12. package/dist/components/ChatInputs/ChatInputs.css +1 -41
  13. package/dist/components/ChatInputs/ChatInputs.d.ts +1 -0
  14. package/dist/components/ChatInputs/ChatInputs.js +9 -3
  15. package/dist/components/ChatInputs/ChatInputs.js.map +1 -1
  16. package/dist/components/ChatTextArea/ChatTextArea.css +7 -3
  17. package/dist/components/DateSelector/DateSelector.css +17 -15
  18. package/dist/components/ExportHistoryButton/ExportHistoryButton.css +1 -1
  19. package/dist/components/FeedbackButtons/FeedbackButtons.css +4 -4
  20. package/dist/components/FeedbackButtons/FeedbackButtons.js +1 -1
  21. package/dist/components/FeedbackButtons/FeedbackButtons.js.map +1 -1
  22. package/dist/components/Header/Header.css +2 -1
  23. package/dist/components/Header/Header.js +1 -1
  24. package/dist/components/Header/Header.js.map +1 -1
  25. package/dist/components/ImageUpload/ImageUpload.css +2 -3
  26. package/dist/components/MediaWidget/MediaItemWidget.css +2 -0
  27. package/dist/components/MediaWidget/MediaWidget.css +1 -1
  28. package/dist/components/MemoriWidget/MemoriWidget.css +1 -2
  29. package/dist/components/MemoriWidget/MemoriWidget.js +23 -13
  30. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  31. package/dist/components/MicrophoneButton/MicrophoneButton.css +107 -0
  32. package/dist/components/MicrophoneButton/MicrophoneButton.d.ts +9 -0
  33. package/dist/components/MicrophoneButton/MicrophoneButton.js +46 -0
  34. package/dist/components/MicrophoneButton/MicrophoneButton.js.map +1 -0
  35. package/dist/components/SettingsDrawer/SettingsDrawer.d.ts +3 -3
  36. package/dist/components/SettingsDrawer/SettingsDrawer.js +8 -6
  37. package/dist/components/SettingsDrawer/SettingsDrawer.js.map +1 -1
  38. package/dist/components/SettingsDrawer/SettingsDrawer.test.js +7 -7
  39. package/dist/components/SettingsDrawer/SettingsDrawer.test.js.map +1 -1
  40. package/dist/components/StartPanel/StartPanel.css +1 -1
  41. package/dist/components/StartPanel/StartPanel.js +1 -1
  42. package/dist/components/StartPanel/StartPanel.js.map +1 -1
  43. package/dist/components/layouts/totem.css +49 -8
  44. package/dist/components/ui/Button.css +1 -1
  45. package/dist/components/ui/Button.d.ts +5 -1
  46. package/dist/components/ui/Button.js +1 -1
  47. package/dist/components/ui/Button.js.map +1 -1
  48. package/dist/components/ui/Checkbox.css +0 -2
  49. package/dist/components/ui/Drawer.css +1 -1
  50. package/dist/components/ui/Modal.css +1 -1
  51. package/dist/components/ui/Select.css +17 -16
  52. package/dist/components/ui/Tooltip.css +38 -3
  53. package/dist/components/ui/Tooltip.d.ts +2 -1
  54. package/dist/components/ui/Tooltip.js +1 -2
  55. package/dist/components/ui/Tooltip.js.map +1 -1
  56. package/dist/components/ui/Tooltip.test.js +16 -0
  57. package/dist/components/ui/Tooltip.test.js.map +1 -1
  58. package/dist/helpers/configuration.js +1 -1
  59. package/dist/helpers/configuration.js.map +1 -1
  60. package/dist/helpers/translations.js +1 -2
  61. package/dist/helpers/translations.js.map +1 -1
  62. package/dist/locales/en.json +4 -0
  63. package/dist/locales/it.json +4 -0
  64. package/dist/styles.css +2 -1
  65. package/esm/components/Avatar/Avatar.css +0 -1
  66. package/esm/components/Blob/Blob.css +6 -1
  67. package/esm/components/ChangeMode/ChangeMode.css +1 -1
  68. package/esm/components/Chat/Chat.css +3 -2
  69. package/esm/components/Chat/Chat.d.ts +1 -0
  70. package/esm/components/Chat/Chat.js +2 -2
  71. package/esm/components/Chat/Chat.js.map +1 -1
  72. package/esm/components/ChatBubble/ChatBubble.css +1 -1
  73. package/esm/components/ChatBubble/ChatBubble.js +1 -1
  74. package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
  75. package/esm/components/ChatInputs/ChatInputs.css +1 -41
  76. package/esm/components/ChatInputs/ChatInputs.d.ts +1 -0
  77. package/esm/components/ChatInputs/ChatInputs.js +9 -3
  78. package/esm/components/ChatInputs/ChatInputs.js.map +1 -1
  79. package/esm/components/ChatTextArea/ChatTextArea.css +7 -3
  80. package/esm/components/DateSelector/DateSelector.css +17 -15
  81. package/esm/components/ExportHistoryButton/ExportHistoryButton.css +1 -1
  82. package/esm/components/FeedbackButtons/FeedbackButtons.css +4 -4
  83. package/esm/components/FeedbackButtons/FeedbackButtons.js +1 -1
  84. package/esm/components/FeedbackButtons/FeedbackButtons.js.map +1 -1
  85. package/esm/components/Header/Header.css +2 -1
  86. package/esm/components/Header/Header.js +1 -1
  87. package/esm/components/Header/Header.js.map +1 -1
  88. package/esm/components/ImageUpload/ImageUpload.css +2 -3
  89. package/esm/components/MediaWidget/MediaItemWidget.css +2 -0
  90. package/esm/components/MediaWidget/MediaWidget.css +1 -1
  91. package/esm/components/MemoriWidget/MemoriWidget.css +1 -2
  92. package/esm/components/MemoriWidget/MemoriWidget.js +23 -13
  93. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  94. package/esm/components/MicrophoneButton/MicrophoneButton.css +107 -0
  95. package/esm/components/MicrophoneButton/MicrophoneButton.d.ts +9 -0
  96. package/esm/components/MicrophoneButton/MicrophoneButton.js +43 -0
  97. package/esm/components/MicrophoneButton/MicrophoneButton.js.map +1 -0
  98. package/esm/components/SettingsDrawer/SettingsDrawer.d.ts +3 -3
  99. package/esm/components/SettingsDrawer/SettingsDrawer.js +9 -7
  100. package/esm/components/SettingsDrawer/SettingsDrawer.js.map +1 -1
  101. package/esm/components/SettingsDrawer/SettingsDrawer.test.js +7 -7
  102. package/esm/components/SettingsDrawer/SettingsDrawer.test.js.map +1 -1
  103. package/esm/components/StartPanel/StartPanel.css +1 -1
  104. package/esm/components/StartPanel/StartPanel.js +1 -1
  105. package/esm/components/StartPanel/StartPanel.js.map +1 -1
  106. package/esm/components/layouts/totem.css +49 -8
  107. package/esm/components/ui/Button.css +1 -1
  108. package/esm/components/ui/Button.d.ts +5 -1
  109. package/esm/components/ui/Button.js +1 -1
  110. package/esm/components/ui/Button.js.map +1 -1
  111. package/esm/components/ui/Checkbox.css +0 -2
  112. package/esm/components/ui/Drawer.css +1 -1
  113. package/esm/components/ui/Modal.css +1 -1
  114. package/esm/components/ui/Select.css +17 -16
  115. package/esm/components/ui/Tooltip.css +38 -3
  116. package/esm/components/ui/Tooltip.d.ts +2 -1
  117. package/esm/components/ui/Tooltip.js +1 -2
  118. package/esm/components/ui/Tooltip.js.map +1 -1
  119. package/esm/components/ui/Tooltip.test.js +16 -0
  120. package/esm/components/ui/Tooltip.test.js.map +1 -1
  121. package/esm/helpers/configuration.js +1 -1
  122. package/esm/helpers/configuration.js.map +1 -1
  123. package/esm/helpers/translations.js +1 -2
  124. package/esm/helpers/translations.js.map +1 -1
  125. package/esm/locales/en.json +4 -0
  126. package/esm/locales/it.json +4 -0
  127. package/esm/styles.css +2 -1
  128. package/package.json +1 -1
  129. package/src/components/Avatar/Avatar.css +0 -1
  130. package/src/components/Blob/Blob.css +6 -1
  131. package/src/components/BlockedMemoriBadge/__snapshots__/BlockedMemoriBadge.test.tsx.snap +4 -4
  132. package/src/components/ChangeMode/ChangeMode.css +1 -1
  133. package/src/components/Chat/Chat.css +3 -2
  134. package/src/components/Chat/Chat.tsx +3 -0
  135. package/src/components/ChatBubble/ChatBubble.css +1 -1
  136. package/src/components/ChatBubble/ChatBubble.tsx +1 -1
  137. package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +1 -1
  138. package/src/components/ChatInputs/ChatInputs.css +1 -41
  139. package/src/components/ChatInputs/ChatInputs.stories.tsx +50 -3
  140. package/src/components/ChatInputs/ChatInputs.tsx +20 -3
  141. package/src/components/ChatInputs/__snapshots__/ChatInputs.test.tsx.snap +160 -85
  142. package/src/components/ChatTextArea/ChatTextArea.css +7 -3
  143. package/src/components/DateSelector/DateSelector.css +17 -15
  144. package/src/components/ExportHistoryButton/ExportHistoryButton.css +1 -1
  145. package/src/components/FeedbackButtons/FeedbackButtons.css +4 -4
  146. package/src/components/FeedbackButtons/FeedbackButtons.tsx +1 -1
  147. package/src/components/Header/Header.css +2 -1
  148. package/src/components/Header/Header.stories.tsx +3 -0
  149. package/src/components/Header/Header.tsx +1 -1
  150. package/src/components/Header/__snapshots__/Header.test.tsx.snap +1 -1
  151. package/src/components/ImageUpload/ImageUpload.css +2 -3
  152. package/src/components/MediaWidget/MediaItemWidget.css +2 -0
  153. package/src/components/MediaWidget/MediaWidget.css +1 -1
  154. package/src/components/MemoriWidget/MemoriWidget.css +1 -2
  155. package/src/components/MemoriWidget/MemoriWidget.tsx +29 -12
  156. package/src/components/MicrophoneButton/MicrophoneButton.css +107 -0
  157. package/src/components/MicrophoneButton/MicrophoneButton.stories.tsx +49 -0
  158. package/src/components/MicrophoneButton/MicrophoneButton.tsx +95 -0
  159. package/src/components/SettingsDrawer/SettingsDrawer.stories.tsx +6 -4
  160. package/src/components/SettingsDrawer/SettingsDrawer.test.tsx +14 -14
  161. package/src/components/SettingsDrawer/SettingsDrawer.tsx +57 -25
  162. package/src/components/StartPanel/StartPanel.css +1 -1
  163. package/src/components/StartPanel/StartPanel.tsx +3 -3
  164. package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +1 -1
  165. package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +1 -1
  166. package/src/components/layouts/totem.css +49 -8
  167. package/src/components/ui/Button.css +1 -1
  168. package/src/components/ui/Button.tsx +21 -1
  169. package/src/components/ui/Checkbox.css +0 -2
  170. package/src/components/ui/Drawer.css +1 -1
  171. package/src/components/ui/Modal.css +1 -1
  172. package/src/components/ui/Select.css +17 -16
  173. package/src/components/ui/Tooltip.css +38 -3
  174. package/src/components/ui/Tooltip.stories.tsx +40 -3
  175. package/src/components/ui/Tooltip.test.tsx +52 -0
  176. package/src/components/ui/Tooltip.tsx +12 -7
  177. package/src/components/ui/__snapshots__/Tooltip.test.tsx.snap +80 -4
  178. package/src/helpers/configuration.ts +1 -1
  179. package/src/helpers/translations.ts +3 -2
  180. package/src/locales/en.json +4 -0
  181. package/src/locales/it.json +4 -0
  182. package/src/styles.css +2 -1
@@ -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 + #headlessui-portal-root,
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
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.1.0",
2
+ "version": "2.2.1",
3
3
  "name": "@memori.ai/memori-react",
4
4
  "author": "Memori Srl",
5
5
  "main": "dist/index.js",
@@ -61,7 +61,6 @@
61
61
  }
62
62
 
63
63
  @media (max-width: 870px) {
64
-
65
64
  .memori--avatar-wrapper div,
66
65
  .memori--avatar-wrapper canvas,
67
66
  .memori--avatar-wrapper model-viewer {
@@ -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~.mainDiv {
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"
@@ -17,6 +17,6 @@
17
17
  border-top-left-radius: 0;
18
18
  }
19
19
 
20
- .memori--changeMode-instruct-radio-button[data-headlessui-state="checked"] button {
20
+ .memori--changeMode-instruct-radio-button[data-headlessui-state='checked'] button {
21
21
  font-weight: 600;
22
22
  }
@@ -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+.memori-chat--bubble-initial {
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+.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}
@@ -64,7 +64,7 @@
64
64
  margin-bottom: 0;
65
65
  }
66
66
 
67
- .memori-chat--bubble p+p {
67
+ .memori-chat--bubble p + p {
68
68
  margin-top: 0.5em;
69
69
  }
70
70
 
@@ -138,7 +138,7 @@ const ChatBubble: React.FC<Props> = ({
138
138
 
139
139
  {message.generatedByAI && showAIicon && (
140
140
  <Tooltip
141
- alignLeft
141
+ align="left"
142
142
  content={t('generatedByAI')}
143
143
  className="memori-chat--bubble-ai-icon"
144
144
  >
@@ -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 memori-tooltip--align-left"
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+.memori-send-on-enter-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 Listening = Template.bind({});
163
- Listening.args = {
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', {