@memori.ai/memori-react 7.1.3 → 7.3.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 +29 -0
- package/README.md +2 -0
- package/dist/components/Chat/Chat.d.ts +2 -0
- package/dist/components/Chat/Chat.js +3 -3
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.css +15 -10
- package/dist/components/ChatBubble/ChatBubble.d.ts +2 -0
- package/dist/components/ChatBubble/ChatBubble.js +23 -8
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.d.ts +3 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +76 -42
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/icons/Code.d.ts +5 -0
- package/dist/components/icons/Code.js +6 -0
- package/dist/components/icons/Code.js.map +1 -0
- package/dist/components/icons/Copy.js +1 -1
- package/dist/components/icons/Copy.js.map +1 -1
- package/dist/helpers/translations.js +5 -1
- package/dist/helpers/translations.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/locales/en.json +1 -0
- package/dist/locales/it.json +1 -0
- package/esm/components/Chat/Chat.d.ts +2 -0
- package/esm/components/Chat/Chat.js +3 -3
- package/esm/components/Chat/Chat.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.css +15 -10
- package/esm/components/ChatBubble/ChatBubble.d.ts +2 -0
- package/esm/components/ChatBubble/ChatBubble.js +23 -8
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.d.ts +3 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +76 -42
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/icons/Code.d.ts +5 -0
- package/esm/components/icons/Code.js +4 -0
- package/esm/components/icons/Code.js.map +1 -0
- package/esm/components/icons/Copy.js +2 -2
- package/esm/components/icons/Copy.js.map +1 -1
- package/esm/helpers/translations.js +5 -1
- package/esm/helpers/translations.js.map +1 -1
- package/esm/index.d.ts +2 -0
- package/esm/index.js +4 -2
- package/esm/index.js.map +1 -1
- package/esm/locales/en.json +1 -0
- package/esm/locales/it.json +1 -0
- package/package.json +2 -2
- package/src/components/Chat/Chat.tsx +6 -0
- package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +1672 -44
- package/src/components/ChatBubble/ChatBubble.css +15 -10
- package/src/components/ChatBubble/ChatBubble.stories.tsx +25 -0
- package/src/components/ChatBubble/ChatBubble.test.tsx +35 -0
- package/src/components/ChatBubble/ChatBubble.tsx +66 -4
- package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +896 -11
- package/src/components/MediaWidget/__snapshots__/MediaItemWidget.test.tsx.snap +30 -4
- package/src/components/MemoriWidget/MemoriWidget.tsx +86 -49
- package/src/components/Snippet/__snapshots__/Snippet.test.tsx.snap +120 -16
- package/src/components/icons/Code.tsx +24 -0
- package/src/components/icons/Copy.tsx +8 -2
- package/src/helpers/translations.ts +10 -2
- package/src/index.stories.tsx +3 -17
- package/src/index.tsx +8 -0
- package/src/locales/en.json +1 -0
- package/src/locales/it.json +1 -0
|
@@ -121,13 +121,26 @@ exports[`renders MediaItemWidget unchanged with css snippet to show 1`] = `
|
|
|
121
121
|
>
|
|
122
122
|
<svg
|
|
123
123
|
aria-hidden="true"
|
|
124
|
+
fill="none"
|
|
124
125
|
focusable="false"
|
|
125
126
|
role="img"
|
|
126
|
-
|
|
127
|
+
stroke="currentColor"
|
|
128
|
+
stroke-linecap="round"
|
|
129
|
+
stroke-linejoin="round"
|
|
130
|
+
stroke-width="1.5"
|
|
131
|
+
viewBox="0 0 24 24"
|
|
127
132
|
xmlns="http://www.w3.org/2000/svg"
|
|
128
133
|
>
|
|
134
|
+
<rect
|
|
135
|
+
height="14"
|
|
136
|
+
rx="2"
|
|
137
|
+
ry="2"
|
|
138
|
+
width="14"
|
|
139
|
+
x="8"
|
|
140
|
+
y="8"
|
|
141
|
+
/>
|
|
129
142
|
<path
|
|
130
|
-
d="
|
|
143
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
131
144
|
/>
|
|
132
145
|
</svg>
|
|
133
146
|
</span>
|
|
@@ -359,13 +372,26 @@ exports[`renders MediaItemWidget unchanged with js snippet to show 1`] = `
|
|
|
359
372
|
>
|
|
360
373
|
<svg
|
|
361
374
|
aria-hidden="true"
|
|
375
|
+
fill="none"
|
|
362
376
|
focusable="false"
|
|
363
377
|
role="img"
|
|
364
|
-
|
|
378
|
+
stroke="currentColor"
|
|
379
|
+
stroke-linecap="round"
|
|
380
|
+
stroke-linejoin="round"
|
|
381
|
+
stroke-width="1.5"
|
|
382
|
+
viewBox="0 0 24 24"
|
|
365
383
|
xmlns="http://www.w3.org/2000/svg"
|
|
366
384
|
>
|
|
385
|
+
<rect
|
|
386
|
+
height="14"
|
|
387
|
+
rx="2"
|
|
388
|
+
ry="2"
|
|
389
|
+
width="14"
|
|
390
|
+
x="8"
|
|
391
|
+
y="8"
|
|
392
|
+
/>
|
|
367
393
|
<path
|
|
368
|
-
d="
|
|
394
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
369
395
|
/>
|
|
370
396
|
</svg>
|
|
371
397
|
</span>
|
|
@@ -337,6 +337,8 @@ export interface Props {
|
|
|
337
337
|
layout?: 'DEFAULT' | 'FULLPAGE' | 'TOTEM' | 'CHAT' | 'WEBSITE_ASSISTANT';
|
|
338
338
|
customLayout?: React.FC<LayoutProps>;
|
|
339
339
|
showShare?: boolean;
|
|
340
|
+
showCopyButton?: boolean;
|
|
341
|
+
showTranslationOriginal?: boolean;
|
|
340
342
|
showInstruct?: boolean;
|
|
341
343
|
showInputs?: boolean;
|
|
342
344
|
showDates?: boolean;
|
|
@@ -388,6 +390,8 @@ const MemoriWidget = ({
|
|
|
388
390
|
showShare,
|
|
389
391
|
preview = false,
|
|
390
392
|
embed = false,
|
|
393
|
+
showCopyButton = true,
|
|
394
|
+
showTranslationOriginal = false,
|
|
391
395
|
showInputs = true,
|
|
392
396
|
showDates = false,
|
|
393
397
|
showContextPerLine = false,
|
|
@@ -666,6 +670,7 @@ const MemoriWidget = ({
|
|
|
666
670
|
|
|
667
671
|
try {
|
|
668
672
|
if (
|
|
673
|
+
!hidden &&
|
|
669
674
|
translate &&
|
|
670
675
|
!instruct &&
|
|
671
676
|
isMultilanguageEnabled &&
|
|
@@ -771,8 +776,9 @@ const MemoriWidget = ({
|
|
|
771
776
|
isMultilanguageEnabled
|
|
772
777
|
) {
|
|
773
778
|
translateDialogState(currentState, userLang, msg).then(ts => {
|
|
774
|
-
|
|
775
|
-
|
|
779
|
+
let text = ts.translatedEmission || ts.emission;
|
|
780
|
+
if (text) {
|
|
781
|
+
speak(text);
|
|
776
782
|
}
|
|
777
783
|
});
|
|
778
784
|
} else {
|
|
@@ -879,45 +885,66 @@ const MemoriWidget = ({
|
|
|
879
885
|
};
|
|
880
886
|
}
|
|
881
887
|
} else {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
888
|
+
try {
|
|
889
|
+
const t = await getTranslation(emission, userLang, language, baseUrl);
|
|
890
|
+
if (state.hints && state.hints.length > 0) {
|
|
891
|
+
const translatedHints = await Promise.all(
|
|
892
|
+
(state.hints ?? []).map(async hint => {
|
|
893
|
+
const tHint = await getTranslation(
|
|
894
|
+
hint,
|
|
895
|
+
userLang,
|
|
896
|
+
language,
|
|
897
|
+
baseUrl
|
|
898
|
+
);
|
|
899
|
+
return {
|
|
900
|
+
text: tHint?.text ?? hint,
|
|
901
|
+
originalText: hint,
|
|
902
|
+
} as TranslatedHint;
|
|
903
|
+
})
|
|
904
|
+
);
|
|
905
|
+
translatedState = {
|
|
906
|
+
...state,
|
|
907
|
+
emission: t.text,
|
|
908
|
+
translatedHints,
|
|
909
|
+
};
|
|
910
|
+
} else {
|
|
911
|
+
translatedState = {
|
|
912
|
+
...state,
|
|
913
|
+
emission: emission,
|
|
914
|
+
translatedEmission: t.text,
|
|
915
|
+
hints:
|
|
916
|
+
state.hints ??
|
|
917
|
+
(state.state === 'G1' ? currentDialogState?.hints : []),
|
|
918
|
+
};
|
|
919
|
+
}
|
|
912
920
|
|
|
913
|
-
|
|
921
|
+
if (t.text.length > 0)
|
|
922
|
+
translatedMsg = {
|
|
923
|
+
text: emission,
|
|
924
|
+
translatedText: t.text,
|
|
925
|
+
emitter: state.emitter,
|
|
926
|
+
media: state.media,
|
|
927
|
+
fromUser: false,
|
|
928
|
+
questionAnswered: msg,
|
|
929
|
+
generatedByAI: !!state.completion,
|
|
930
|
+
contextVars: state.contextVars,
|
|
931
|
+
date: state.currentDate,
|
|
932
|
+
placeName: state.currentPlaceName,
|
|
933
|
+
placeLatitude: state.currentLatitude,
|
|
934
|
+
placeLongitude: state.currentLongitude,
|
|
935
|
+
placeUncertaintyKm: state.currentUncertaintyKm,
|
|
936
|
+
tag: state.currentTag,
|
|
937
|
+
memoryTags: state.memoryTags,
|
|
938
|
+
};
|
|
939
|
+
} catch (error) {
|
|
940
|
+
console.error(error);
|
|
941
|
+
translatedState = { ...state, emission };
|
|
914
942
|
translatedMsg = {
|
|
915
|
-
text:
|
|
943
|
+
text: emission,
|
|
916
944
|
emitter: state.emitter,
|
|
917
945
|
media: state.media,
|
|
918
946
|
fromUser: false,
|
|
919
947
|
questionAnswered: msg,
|
|
920
|
-
generatedByAI: !!state.completion,
|
|
921
948
|
contextVars: state.contextVars,
|
|
922
949
|
date: state.currentDate,
|
|
923
950
|
placeName: state.currentPlaceName,
|
|
@@ -927,6 +954,7 @@ const MemoriWidget = ({
|
|
|
927
954
|
tag: state.currentTag,
|
|
928
955
|
memoryTags: state.memoryTags,
|
|
929
956
|
};
|
|
957
|
+
}
|
|
930
958
|
}
|
|
931
959
|
|
|
932
960
|
setCurrentDialogState(translatedState);
|
|
@@ -1451,8 +1479,9 @@ const MemoriWidget = ({
|
|
|
1451
1479
|
{ ...currentState, emission: emission },
|
|
1452
1480
|
userLang
|
|
1453
1481
|
).then(ts => {
|
|
1454
|
-
|
|
1455
|
-
|
|
1482
|
+
let text = ts.translatedEmission || ts.emission;
|
|
1483
|
+
if (text) {
|
|
1484
|
+
speak(text);
|
|
1456
1485
|
}
|
|
1457
1486
|
});
|
|
1458
1487
|
} else if (emission && emission.length > 0) {
|
|
@@ -2587,8 +2616,9 @@ const MemoriWidget = ({
|
|
|
2587
2616
|
|
|
2588
2617
|
translateDialogState(session.dialogState, userLang)
|
|
2589
2618
|
.then(ts => {
|
|
2590
|
-
|
|
2591
|
-
|
|
2619
|
+
let text = ts.translatedEmission || ts.emission;
|
|
2620
|
+
if (text) {
|
|
2621
|
+
speak(text);
|
|
2592
2622
|
}
|
|
2593
2623
|
})
|
|
2594
2624
|
.finally(() => {
|
|
@@ -2644,8 +2674,9 @@ const MemoriWidget = ({
|
|
|
2644
2674
|
if (session && session.resultCode === 0) {
|
|
2645
2675
|
translateDialogState(session.currentState, userLang)
|
|
2646
2676
|
.then(ts => {
|
|
2647
|
-
|
|
2648
|
-
|
|
2677
|
+
let text = ts.translatedEmission || ts.emission;
|
|
2678
|
+
if (text) {
|
|
2679
|
+
speak(text);
|
|
2649
2680
|
}
|
|
2650
2681
|
})
|
|
2651
2682
|
.finally(() => {
|
|
@@ -2697,8 +2728,9 @@ const MemoriWidget = ({
|
|
|
2697
2728
|
if (session && session.resultCode === 0) {
|
|
2698
2729
|
translateDialogState(session.currentState, userLang)
|
|
2699
2730
|
.then(ts => {
|
|
2700
|
-
|
|
2701
|
-
|
|
2731
|
+
let text = ts.translatedEmission || ts.emission;
|
|
2732
|
+
if (text) {
|
|
2733
|
+
speak(text);
|
|
2702
2734
|
}
|
|
2703
2735
|
})
|
|
2704
2736
|
.finally(() => {
|
|
@@ -2750,8 +2782,9 @@ const MemoriWidget = ({
|
|
|
2750
2782
|
if (session && session.resultCode === 0) {
|
|
2751
2783
|
translateDialogState(session.currentState, userLang)
|
|
2752
2784
|
.then(ts => {
|
|
2753
|
-
|
|
2754
|
-
|
|
2785
|
+
let text = ts.translatedEmission || ts.emission;
|
|
2786
|
+
if (text) {
|
|
2787
|
+
speak(text);
|
|
2755
2788
|
}
|
|
2756
2789
|
})
|
|
2757
2790
|
.finally(() => {
|
|
@@ -2786,8 +2819,9 @@ const MemoriWidget = ({
|
|
|
2786
2819
|
// no need to change tag
|
|
2787
2820
|
translateDialogState(currentState, userLang)
|
|
2788
2821
|
.then(ts => {
|
|
2789
|
-
|
|
2790
|
-
|
|
2822
|
+
let text = ts.translatedEmission || ts.emission;
|
|
2823
|
+
if (text) {
|
|
2824
|
+
speak(text);
|
|
2791
2825
|
}
|
|
2792
2826
|
})
|
|
2793
2827
|
.finally(() => {
|
|
@@ -2806,8 +2840,9 @@ const MemoriWidget = ({
|
|
|
2806
2840
|
// everything is fine, just translate dialog state and activate chat
|
|
2807
2841
|
translateDialogState(dialogState!, userLang)
|
|
2808
2842
|
.then(ts => {
|
|
2809
|
-
|
|
2810
|
-
|
|
2843
|
+
let text = ts.translatedEmission || ts.emission;
|
|
2844
|
+
if (text) {
|
|
2845
|
+
speak(text);
|
|
2811
2846
|
}
|
|
2812
2847
|
})
|
|
2813
2848
|
.finally(() => {
|
|
@@ -3036,6 +3071,8 @@ const MemoriWidget = ({
|
|
|
3036
3071
|
showContextPerLine,
|
|
3037
3072
|
showAIicon,
|
|
3038
3073
|
showWhyThisAnswer,
|
|
3074
|
+
showCopyButton,
|
|
3075
|
+
showTranslationOriginal,
|
|
3039
3076
|
client,
|
|
3040
3077
|
selectReceiverTag,
|
|
3041
3078
|
preview,
|
|
@@ -101,13 +101,26 @@ exports[`renders SnippetUpload with css code 1`] = `
|
|
|
101
101
|
>
|
|
102
102
|
<svg
|
|
103
103
|
aria-hidden="true"
|
|
104
|
+
fill="none"
|
|
104
105
|
focusable="false"
|
|
105
106
|
role="img"
|
|
106
|
-
|
|
107
|
+
stroke="currentColor"
|
|
108
|
+
stroke-linecap="round"
|
|
109
|
+
stroke-linejoin="round"
|
|
110
|
+
stroke-width="1.5"
|
|
111
|
+
viewBox="0 0 24 24"
|
|
107
112
|
xmlns="http://www.w3.org/2000/svg"
|
|
108
113
|
>
|
|
114
|
+
<rect
|
|
115
|
+
height="14"
|
|
116
|
+
rx="2"
|
|
117
|
+
ry="2"
|
|
118
|
+
width="14"
|
|
119
|
+
x="8"
|
|
120
|
+
y="8"
|
|
121
|
+
/>
|
|
109
122
|
<path
|
|
110
|
-
d="
|
|
123
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
111
124
|
/>
|
|
112
125
|
</svg>
|
|
113
126
|
</span>
|
|
@@ -197,13 +210,26 @@ exports[`renders SnippetUpload with html code 1`] = `
|
|
|
197
210
|
>
|
|
198
211
|
<svg
|
|
199
212
|
aria-hidden="true"
|
|
213
|
+
fill="none"
|
|
200
214
|
focusable="false"
|
|
201
215
|
role="img"
|
|
202
|
-
|
|
216
|
+
stroke="currentColor"
|
|
217
|
+
stroke-linecap="round"
|
|
218
|
+
stroke-linejoin="round"
|
|
219
|
+
stroke-width="1.5"
|
|
220
|
+
viewBox="0 0 24 24"
|
|
203
221
|
xmlns="http://www.w3.org/2000/svg"
|
|
204
222
|
>
|
|
223
|
+
<rect
|
|
224
|
+
height="14"
|
|
225
|
+
rx="2"
|
|
226
|
+
ry="2"
|
|
227
|
+
width="14"
|
|
228
|
+
x="8"
|
|
229
|
+
y="8"
|
|
230
|
+
/>
|
|
205
231
|
<path
|
|
206
|
-
d="
|
|
232
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
207
233
|
/>
|
|
208
234
|
</svg>
|
|
209
235
|
</span>
|
|
@@ -257,13 +283,26 @@ exports[`renders SnippetUpload with js code 1`] = `
|
|
|
257
283
|
>
|
|
258
284
|
<svg
|
|
259
285
|
aria-hidden="true"
|
|
286
|
+
fill="none"
|
|
260
287
|
focusable="false"
|
|
261
288
|
role="img"
|
|
262
|
-
|
|
289
|
+
stroke="currentColor"
|
|
290
|
+
stroke-linecap="round"
|
|
291
|
+
stroke-linejoin="round"
|
|
292
|
+
stroke-width="1.5"
|
|
293
|
+
viewBox="0 0 24 24"
|
|
263
294
|
xmlns="http://www.w3.org/2000/svg"
|
|
264
295
|
>
|
|
296
|
+
<rect
|
|
297
|
+
height="14"
|
|
298
|
+
rx="2"
|
|
299
|
+
ry="2"
|
|
300
|
+
width="14"
|
|
301
|
+
x="8"
|
|
302
|
+
y="8"
|
|
303
|
+
/>
|
|
265
304
|
<path
|
|
266
|
-
d="
|
|
305
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
267
306
|
/>
|
|
268
307
|
</svg>
|
|
269
308
|
</span>
|
|
@@ -425,13 +464,26 @@ exports[`renders SnippetUpload with js code without line numbers 1`] = `
|
|
|
425
464
|
>
|
|
426
465
|
<svg
|
|
427
466
|
aria-hidden="true"
|
|
467
|
+
fill="none"
|
|
428
468
|
focusable="false"
|
|
429
469
|
role="img"
|
|
430
|
-
|
|
470
|
+
stroke="currentColor"
|
|
471
|
+
stroke-linecap="round"
|
|
472
|
+
stroke-linejoin="round"
|
|
473
|
+
stroke-width="1.5"
|
|
474
|
+
viewBox="0 0 24 24"
|
|
431
475
|
xmlns="http://www.w3.org/2000/svg"
|
|
432
476
|
>
|
|
477
|
+
<rect
|
|
478
|
+
height="14"
|
|
479
|
+
rx="2"
|
|
480
|
+
ry="2"
|
|
481
|
+
width="14"
|
|
482
|
+
x="8"
|
|
483
|
+
y="8"
|
|
484
|
+
/>
|
|
433
485
|
<path
|
|
434
|
-
d="
|
|
486
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
435
487
|
/>
|
|
436
488
|
</svg>
|
|
437
489
|
</span>
|
|
@@ -763,13 +815,26 @@ exports[`renders SnippetUpload with preview mode (clamping) 1`] = `
|
|
|
763
815
|
>
|
|
764
816
|
<svg
|
|
765
817
|
aria-hidden="true"
|
|
818
|
+
fill="none"
|
|
766
819
|
focusable="false"
|
|
767
820
|
role="img"
|
|
768
|
-
|
|
821
|
+
stroke="currentColor"
|
|
822
|
+
stroke-linecap="round"
|
|
823
|
+
stroke-linejoin="round"
|
|
824
|
+
stroke-width="1.5"
|
|
825
|
+
viewBox="0 0 24 24"
|
|
769
826
|
xmlns="http://www.w3.org/2000/svg"
|
|
770
827
|
>
|
|
828
|
+
<rect
|
|
829
|
+
height="14"
|
|
830
|
+
rx="2"
|
|
831
|
+
ry="2"
|
|
832
|
+
width="14"
|
|
833
|
+
x="8"
|
|
834
|
+
y="8"
|
|
835
|
+
/>
|
|
771
836
|
<path
|
|
772
|
-
d="
|
|
837
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
773
838
|
/>
|
|
774
839
|
</svg>
|
|
775
840
|
</span>
|
|
@@ -2812,13 +2877,26 @@ exports[`renders SnippetUpload with react/tsx code 1`] = `
|
|
|
2812
2877
|
>
|
|
2813
2878
|
<svg
|
|
2814
2879
|
aria-hidden="true"
|
|
2880
|
+
fill="none"
|
|
2815
2881
|
focusable="false"
|
|
2816
2882
|
role="img"
|
|
2817
|
-
|
|
2883
|
+
stroke="currentColor"
|
|
2884
|
+
stroke-linecap="round"
|
|
2885
|
+
stroke-linejoin="round"
|
|
2886
|
+
stroke-width="1.5"
|
|
2887
|
+
viewBox="0 0 24 24"
|
|
2818
2888
|
xmlns="http://www.w3.org/2000/svg"
|
|
2819
2889
|
>
|
|
2890
|
+
<rect
|
|
2891
|
+
height="14"
|
|
2892
|
+
rx="2"
|
|
2893
|
+
ry="2"
|
|
2894
|
+
width="14"
|
|
2895
|
+
x="8"
|
|
2896
|
+
y="8"
|
|
2897
|
+
/>
|
|
2820
2898
|
<path
|
|
2821
|
-
d="
|
|
2899
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
2822
2900
|
/>
|
|
2823
2901
|
</svg>
|
|
2824
2902
|
</span>
|
|
@@ -2870,13 +2948,26 @@ exports[`renders SnippetUpload with text 1`] = `
|
|
|
2870
2948
|
>
|
|
2871
2949
|
<svg
|
|
2872
2950
|
aria-hidden="true"
|
|
2951
|
+
fill="none"
|
|
2873
2952
|
focusable="false"
|
|
2874
2953
|
role="img"
|
|
2875
|
-
|
|
2954
|
+
stroke="currentColor"
|
|
2955
|
+
stroke-linecap="round"
|
|
2956
|
+
stroke-linejoin="round"
|
|
2957
|
+
stroke-width="1.5"
|
|
2958
|
+
viewBox="0 0 24 24"
|
|
2876
2959
|
xmlns="http://www.w3.org/2000/svg"
|
|
2877
2960
|
>
|
|
2961
|
+
<rect
|
|
2962
|
+
height="14"
|
|
2963
|
+
rx="2"
|
|
2964
|
+
ry="2"
|
|
2965
|
+
width="14"
|
|
2966
|
+
x="8"
|
|
2967
|
+
y="8"
|
|
2968
|
+
/>
|
|
2878
2969
|
<path
|
|
2879
|
-
d="
|
|
2970
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
2880
2971
|
/>
|
|
2881
2972
|
</svg>
|
|
2882
2973
|
</span>
|
|
@@ -2928,13 +3019,26 @@ exports[`renders SnippetUpload with text as fallback 1`] = `
|
|
|
2928
3019
|
>
|
|
2929
3020
|
<svg
|
|
2930
3021
|
aria-hidden="true"
|
|
3022
|
+
fill="none"
|
|
2931
3023
|
focusable="false"
|
|
2932
3024
|
role="img"
|
|
2933
|
-
|
|
3025
|
+
stroke="currentColor"
|
|
3026
|
+
stroke-linecap="round"
|
|
3027
|
+
stroke-linejoin="round"
|
|
3028
|
+
stroke-width="1.5"
|
|
3029
|
+
viewBox="0 0 24 24"
|
|
2934
3030
|
xmlns="http://www.w3.org/2000/svg"
|
|
2935
3031
|
>
|
|
3032
|
+
<rect
|
|
3033
|
+
height="14"
|
|
3034
|
+
rx="2"
|
|
3035
|
+
ry="2"
|
|
3036
|
+
width="14"
|
|
3037
|
+
x="8"
|
|
3038
|
+
y="8"
|
|
3039
|
+
/>
|
|
2936
3040
|
<path
|
|
2937
|
-
d="
|
|
3041
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
2938
3042
|
/>
|
|
2939
3043
|
</svg>
|
|
2940
3044
|
</span>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const Code = ({ className, title }: { className?: string; title?: string }) => (
|
|
4
|
+
<svg
|
|
5
|
+
{...(!title ? { 'aria-hidden': 'true' } : {})}
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="none"
|
|
9
|
+
stroke="currentColor"
|
|
10
|
+
stroke-width="1.5"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
13
|
+
focusable="false"
|
|
14
|
+
role="img"
|
|
15
|
+
className={className}
|
|
16
|
+
aria-label={title}
|
|
17
|
+
>
|
|
18
|
+
<path d="M10 9.5 8 12l2 2.5" />
|
|
19
|
+
<path d="m14 9.5 2 2.5-2 2.5" />
|
|
20
|
+
<rect width="18" height="18" x="3" y="3" rx="2" />
|
|
21
|
+
</svg>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export default Code;
|
|
@@ -4,13 +4,19 @@ const Copy = ({ className, title }: { className?: string; title?: string }) => (
|
|
|
4
4
|
<svg
|
|
5
5
|
{...(!title ? { 'aria-hidden': 'true' } : {})}
|
|
6
6
|
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
-
viewBox="0 0
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="none"
|
|
9
|
+
stroke="currentColor"
|
|
10
|
+
stroke-width="1.5"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
8
13
|
focusable="false"
|
|
9
14
|
role="img"
|
|
10
15
|
className={className}
|
|
11
16
|
aria-label={title}
|
|
12
17
|
>
|
|
13
|
-
<
|
|
18
|
+
<rect width="14" height="14" x="8" y="8" rx="2" ry="2" />
|
|
19
|
+
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />
|
|
14
20
|
</svg>
|
|
15
21
|
);
|
|
16
22
|
|
|
@@ -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
|
-
`${
|
|
27
|
-
|
|
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
|
}`,
|
package/src/index.stories.tsx
CHANGED
|
@@ -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,
|