@memori.ai/memori-react 7.2.0 → 7.3.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 (49) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +1 -0
  3. package/dist/components/Chat/Chat.d.ts +1 -0
  4. package/dist/components/Chat/Chat.js +2 -2
  5. package/dist/components/Chat/Chat.js.map +1 -1
  6. package/dist/components/ChatBubble/ChatBubble.d.ts +1 -0
  7. package/dist/components/ChatBubble/ChatBubble.js +12 -7
  8. package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
  9. package/dist/components/MemoriWidget/MemoriWidget.d.ts +2 -1
  10. package/dist/components/MemoriWidget/MemoriWidget.js +77 -45
  11. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  12. package/dist/components/StartPanel/StartPanel.d.ts +1 -0
  13. package/dist/components/StartPanel/StartPanel.js +2 -2
  14. package/dist/components/StartPanel/StartPanel.js.map +1 -1
  15. package/dist/helpers/translations.js +5 -1
  16. package/dist/helpers/translations.js.map +1 -1
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.js +3 -2
  19. package/dist/index.js.map +1 -1
  20. package/esm/components/Chat/Chat.d.ts +1 -0
  21. package/esm/components/Chat/Chat.js +2 -2
  22. package/esm/components/Chat/Chat.js.map +1 -1
  23. package/esm/components/ChatBubble/ChatBubble.d.ts +1 -0
  24. package/esm/components/ChatBubble/ChatBubble.js +12 -7
  25. package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
  26. package/esm/components/MemoriWidget/MemoriWidget.d.ts +2 -1
  27. package/esm/components/MemoriWidget/MemoriWidget.js +77 -45
  28. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  29. package/esm/components/StartPanel/StartPanel.d.ts +1 -0
  30. package/esm/components/StartPanel/StartPanel.js +2 -2
  31. package/esm/components/StartPanel/StartPanel.js.map +1 -1
  32. package/esm/helpers/translations.js +5 -1
  33. package/esm/helpers/translations.js.map +1 -1
  34. package/esm/index.d.ts +1 -0
  35. package/esm/index.js +3 -2
  36. package/esm/index.js.map +1 -1
  37. package/package.json +2 -2
  38. package/src/components/Chat/Chat.tsx +3 -0
  39. package/src/components/ChatBubble/ChatBubble.stories.tsx +14 -0
  40. package/src/components/ChatBubble/ChatBubble.test.tsx +19 -0
  41. package/src/components/ChatBubble/ChatBubble.tsx +31 -7
  42. package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +132 -0
  43. package/src/components/MemoriWidget/MemoriWidget.tsx +86 -53
  44. package/src/components/StartPanel/StartPanel.test.tsx +20 -0
  45. package/src/components/StartPanel/StartPanel.tsx +3 -2
  46. package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +101 -0
  47. package/src/helpers/translations.ts +10 -2
  48. package/src/index.stories.tsx +3 -17
  49. package/src/index.tsx +4 -0
@@ -1170,6 +1170,107 @@ exports[`renders StartPanel with gamification level unchanged 1`] = `
1170
1170
  `;
1171
1171
 
1172
1172
  exports[`renders StartPanel with integrationConfig unchanged 1`] = `
1173
+ <div>
1174
+ <div
1175
+ class="memori--start-panel"
1176
+ >
1177
+ <div
1178
+ class="memori--cover"
1179
+ >
1180
+ <div
1181
+ class="memori--completions-enabled"
1182
+ >
1183
+ <div
1184
+ class="memori-tooltip memori-tooltip--align-left"
1185
+ >
1186
+ <div
1187
+ class="memori-tooltip--content"
1188
+ >
1189
+ completionsEnabled
1190
+ </div>
1191
+ <div
1192
+ class="memori-tooltip--trigger"
1193
+ >
1194
+ <span
1195
+ aria-label="completionsEnabled"
1196
+ >
1197
+ <svg
1198
+ aria-hidden="true"
1199
+ fill="none"
1200
+ focusable="false"
1201
+ role="img"
1202
+ viewBox="0 0 24 24"
1203
+ xmlns="http://www.w3.org/2000/svg"
1204
+ >
1205
+ <g
1206
+ clip-rule="evenodd"
1207
+ fill="currentColor"
1208
+ fill-rule="evenodd"
1209
+ >
1210
+ <path
1211
+ clip-rule="evenodd"
1212
+ d="M0 4a4 4 0 014-4h16a4 4 0 014 4v16a4 4 0 01-4 4H4a4 4 0 01-4-4zm4-2.4A2.4 2.4 0 001.6 4v16A2.4 2.4 0 004 22.4h16a2.4 2.4 0 002.4-2.4V4A2.4 2.4 0 0020 1.6z"
1213
+ fill-rule="evenodd"
1214
+ />
1215
+ <path
1216
+ clip-rule="evenodd"
1217
+ d="M9.715 8.442a.798.798 0 00-1.43 0l-3.2 6.4a.799.799 0 101.431.716l.579-1.158h3.811l.578 1.158a.8.8 0 001.431-.716zm.391 4.358L9 10.589 7.894 12.8z"
1218
+ fill-rule="evenodd"
1219
+ />
1220
+ <path
1221
+ clip-rule="evenodd"
1222
+ d="M17 8c.552 0 1 .358 1 .8v6.4c0 .442-.448.8-1 .8s-1-.358-1-.8V8.8c0-.442.448-.8 1-.8z"
1223
+ fill-rule="evenodd"
1224
+ />
1225
+ </g>
1226
+ </svg>
1227
+ </span>
1228
+ </div>
1229
+ </div>
1230
+ </div>
1231
+ </div>
1232
+ <picture
1233
+ class="memori--avatar"
1234
+ >
1235
+ <source
1236
+ src="https://aisuru.com/images/aisuru/square_logo.png"
1237
+ />
1238
+ <img
1239
+ alt="Memori"
1240
+ src="https://aisuru.com/images/aisuru/square_logo.png"
1241
+ />
1242
+ </picture>
1243
+ <h2
1244
+ class="memori--title"
1245
+ >
1246
+ Memori
1247
+ </h2>
1248
+ <div
1249
+ class="memori--description"
1250
+ >
1251
+ <p>
1252
+ <span
1253
+ class="memori--description-text"
1254
+ >
1255
+ Lorem ipsum.
1256
+ </span>
1257
+ </p>
1258
+ <button
1259
+ class="memori-button memori-button--primary memori-button--rounded memori-button--padded memori--start-button"
1260
+ >
1261
+ write_and_speak.tryMeButton
1262
+ </button>
1263
+ <p
1264
+ class="memori--start-description"
1265
+ >
1266
+ write_and_speak.pageTryMeExplanation
1267
+ </p>
1268
+ </div>
1269
+ </div>
1270
+ </div>
1271
+ `;
1272
+
1273
+ exports[`renders StartPanel with multilangual unchanged 1`] = `
1173
1274
  <div>
1174
1275
  <div
1175
1276
  class="memori--start-panel"
@@ -14,17 +14,25 @@ export const dialogKeywords = [
14
14
  'non mi è piaciuto',
15
15
  ];
16
16
 
17
+ const stripOutputTags = (text: string) => {
18
+ return text.replaceAll(/<output.*?>(.*?)<\/output>/g, '');
19
+ };
20
+
17
21
  export const getTranslation = async (
18
22
  text: string,
19
23
  to: string,
20
24
  from?: string,
21
25
  baseUrl?: string
22
26
  ): Promise<DeeplTranslation> => {
27
+ let textToTranslate = stripOutputTags(text);
28
+
23
29
  const isReservedKeyword = dialogKeywords.indexOf(text.toLowerCase()) > -1;
24
30
  const fromLanguage = isReservedKeyword ? 'IT' : from?.toUpperCase();
25
31
  const deeplResult = await fetch(
26
- `${baseUrl || 'https://aisuru.com'}/api/translate?text=${encodeURIComponent(
27
- text
32
+ `${
33
+ baseUrl || 'https://www.aisuru.com'
34
+ }/api/translate?text=${encodeURIComponent(
35
+ textToTranslate
28
36
  )}&target_lang=${to.toUpperCase()}${
29
37
  fromLanguage ? `&source_lang=${fromLanguage}` : ''
30
38
  }`,
@@ -30,7 +30,7 @@ Anonymous.args = {
30
30
  memoriName: 'Nicola',
31
31
  tenantID: 'aisuru.com',
32
32
  apiURL: 'https://backend.memori.ai',
33
- baseURL: 'https://aisuru.com',
33
+ baseURL: 'https://www.aisuru.com',
34
34
  uiLang: 'it',
35
35
  showShare: true,
36
36
  showSettings: true,
@@ -82,20 +82,6 @@ Staging.args = {
82
82
  layout: 'FULLPAGE',
83
83
  };
84
84
 
85
- export const StagingTokenized = Template.bind({});
86
- StagingTokenized.args = {
87
- memoriName: 'Test',
88
- ownerUserName: 'nicola',
89
- memoriID: '36798f8a-7018-4cf7-9be4-e681949a46a3',
90
- ownerUserID: '585ec0ff-e805-495e-b8fc-5b0b8dd288ff',
91
- tenantID: 'aisuru-staging-tokenized.aclambda.online',
92
- apiURL: 'https://backend-staging.memori.ai',
93
- baseURL: 'https://aisuru-staging-tokenized.aclambda.online',
94
- uiLang: 'EN',
95
- lang: 'IT',
96
- layout: 'FULLPAGE',
97
- };
98
-
99
85
  const TemplateWithBatchButton: Story<Props> = args => (
100
86
  <div>
101
87
  <button
@@ -136,7 +122,7 @@ WithBatch.args = {
136
122
  memoriName: 'Nicola',
137
123
  tenantID: 'aisuru.com',
138
124
  apiURL: 'https://backend.memori.ai',
139
- baseURL: 'https://aisuru.com',
125
+ baseURL: 'https://www.aisuru.com',
140
126
  uiLang: 'it',
141
127
  showShare: true,
142
128
  showSettings: true,
@@ -148,7 +134,7 @@ WithCustomUserAvatar.args = {
148
134
  memoriName: 'Nicola',
149
135
  tenantID: 'aisuru.com',
150
136
  apiURL: 'https://backend.memori.ai',
151
- baseURL: 'https://aisuru.com',
137
+ baseURL: 'https://www.aisuru.com',
152
138
  uiLang: 'it',
153
139
  showShare: true,
154
140
  showSettings: true,
package/src/index.tsx CHANGED
@@ -29,6 +29,7 @@ export interface Props {
29
29
  customLayout?: WidgetProps['customLayout'];
30
30
  showShare?: boolean;
31
31
  showCopyButton?: boolean;
32
+ showTranslationOriginal?: boolean;
32
33
  showInstruct?: boolean;
33
34
  showInputs?: boolean;
34
35
  showDates?: boolean;
@@ -90,6 +91,7 @@ const Memori: React.FC<Props> = ({
90
91
  customLayout,
91
92
  showShare = true,
92
93
  showCopyButton = true,
94
+ showTranslationOriginal = false,
93
95
  showSettings = true,
94
96
  showInstruct = false,
95
97
  showTypingText = false,
@@ -242,6 +244,7 @@ const Memori: React.FC<Props> = ({
242
244
  sessionID={sessionID}
243
245
  showShare={showShare}
244
246
  showCopyButton={showCopyButton}
247
+ showTranslationOriginal={showTranslationOriginal}
245
248
  showSettings={showSettings}
246
249
  showInstruct={showInstruct}
247
250
  showTypingText={showTypingText}
@@ -318,6 +321,7 @@ Memori.propTypes = {
318
321
  customLayout: PropTypes.any,
319
322
  showShare: PropTypes.bool,
320
323
  showCopyButton: PropTypes.bool,
324
+ showTranslationOriginal: PropTypes.bool,
321
325
  showInstruct: PropTypes.bool,
322
326
  showInputs: PropTypes.bool,
323
327
  showDates: PropTypes.bool,