@memori.ai/memori-react 7.11.3 → 7.12.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.
Files changed (156) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +2 -1
  3. package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js +52 -75
  4. package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js.map +1 -1
  5. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/AnimationController.js +2 -2
  6. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/AnimationController.js.map +1 -1
  7. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.d.ts +1 -1
  8. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +8 -2
  9. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
  10. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/types.d.ts +1 -0
  11. package/dist/components/Avatar/AvatarView/AvatarComponent/components/MorphTargetController.js +6 -3
  12. package/dist/components/Avatar/AvatarView/AvatarComponent/components/MorphTargetController.js.map +1 -1
  13. package/dist/components/Avatar/AvatarView/AvatarComponent/components/PositionController.js +1 -1
  14. package/dist/components/Avatar/AvatarView/AvatarComponent/components/PositionController.js.map +1 -1
  15. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controls.d.ts +1 -1
  16. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controls.js +1 -1
  17. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controls.js.map +1 -1
  18. package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js +1 -1
  19. package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js.map +1 -1
  20. package/dist/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +74 -0
  21. package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js +101 -0
  22. package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -0
  23. package/dist/components/Chat/Chat.d.ts +10 -1
  24. package/dist/components/Chat/Chat.js +2 -10
  25. package/dist/components/Chat/Chat.js.map +1 -1
  26. package/dist/components/ChatBubble/ChatBubble.css +4 -0
  27. package/dist/components/ChatBubble/ChatBubble.js +14 -4
  28. package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
  29. package/dist/components/ChatInputs/ChatInputs.d.ts +11 -2
  30. package/dist/components/ChatInputs/ChatInputs.js +44 -6
  31. package/dist/components/ChatInputs/ChatInputs.js.map +1 -1
  32. package/dist/components/CompletionProviderStatus/CompletionProviderStatus.css +8 -0
  33. package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js +75 -51
  34. package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
  35. package/dist/components/ExpertsDrawer/ExpertsDrawer.js +1 -1
  36. package/dist/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
  37. package/dist/components/FilePreview/FilePreview.css +155 -0
  38. package/dist/components/FilePreview/FilePreview.d.ts +12 -0
  39. package/dist/components/FilePreview/FilePreview.js +21 -0
  40. package/dist/components/FilePreview/FilePreview.js.map +1 -0
  41. package/dist/components/MemoriWidget/MemoriWidget.d.ts +3 -1
  42. package/dist/components/MemoriWidget/MemoriWidget.js +26 -11
  43. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  44. package/dist/components/UploadButton/UploadButton.css +38 -0
  45. package/dist/components/UploadButton/UploadButton.d.ts +8 -0
  46. package/dist/components/UploadButton/UploadButton.js +79 -0
  47. package/dist/components/UploadButton/UploadButton.js.map +1 -0
  48. package/dist/components/icons/Preview.d.ts +5 -0
  49. package/dist/components/icons/Preview.js +6 -0
  50. package/dist/components/icons/Preview.js.map +1 -0
  51. package/dist/components/icons/Upload.d.ts +5 -0
  52. package/dist/components/icons/Upload.js +6 -0
  53. package/dist/components/icons/Upload.js.map +1 -0
  54. package/dist/index.d.ts +1 -0
  55. package/dist/index.js +3 -2
  56. package/dist/index.js.map +1 -1
  57. package/dist/styles.css +2 -0
  58. package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js +52 -75
  59. package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js.map +1 -1
  60. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/AnimationController.js +2 -2
  61. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/AnimationController.js.map +1 -1
  62. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.d.ts +1 -1
  63. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +8 -2
  64. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
  65. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/types.d.ts +1 -0
  66. package/esm/components/Avatar/AvatarView/AvatarComponent/components/MorphTargetController.js +6 -3
  67. package/esm/components/Avatar/AvatarView/AvatarComponent/components/MorphTargetController.js.map +1 -1
  68. package/esm/components/Avatar/AvatarView/AvatarComponent/components/PositionController.js +1 -1
  69. package/esm/components/Avatar/AvatarView/AvatarComponent/components/PositionController.js.map +1 -1
  70. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controls.d.ts +1 -1
  71. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controls.js +1 -1
  72. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controls.js.map +1 -1
  73. package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js +1 -1
  74. package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js.map +1 -1
  75. package/esm/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +74 -0
  76. package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js +98 -0
  77. package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -0
  78. package/esm/components/Chat/Chat.d.ts +10 -1
  79. package/esm/components/Chat/Chat.js +2 -10
  80. package/esm/components/Chat/Chat.js.map +1 -1
  81. package/esm/components/ChatBubble/ChatBubble.css +4 -0
  82. package/esm/components/ChatBubble/ChatBubble.js +14 -4
  83. package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
  84. package/esm/components/ChatInputs/ChatInputs.d.ts +11 -2
  85. package/esm/components/ChatInputs/ChatInputs.js +45 -7
  86. package/esm/components/ChatInputs/ChatInputs.js.map +1 -1
  87. package/esm/components/CompletionProviderStatus/CompletionProviderStatus.css +8 -0
  88. package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js +76 -52
  89. package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
  90. package/esm/components/ExpertsDrawer/ExpertsDrawer.js +1 -1
  91. package/esm/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
  92. package/esm/components/FilePreview/FilePreview.css +155 -0
  93. package/esm/components/FilePreview/FilePreview.d.ts +12 -0
  94. package/esm/components/FilePreview/FilePreview.js +18 -0
  95. package/esm/components/FilePreview/FilePreview.js.map +1 -0
  96. package/esm/components/MemoriWidget/MemoriWidget.d.ts +3 -1
  97. package/esm/components/MemoriWidget/MemoriWidget.js +26 -11
  98. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  99. package/esm/components/UploadButton/UploadButton.css +38 -0
  100. package/esm/components/UploadButton/UploadButton.d.ts +8 -0
  101. package/esm/components/UploadButton/UploadButton.js +76 -0
  102. package/esm/components/UploadButton/UploadButton.js.map +1 -0
  103. package/esm/components/icons/Preview.d.ts +5 -0
  104. package/esm/components/icons/Preview.js +4 -0
  105. package/esm/components/icons/Preview.js.map +1 -0
  106. package/esm/components/icons/Upload.d.ts +5 -0
  107. package/esm/components/icons/Upload.js +4 -0
  108. package/esm/components/icons/Upload.js.map +1 -0
  109. package/esm/index.d.ts +1 -0
  110. package/esm/index.js +3 -2
  111. package/esm/index.js.map +1 -1
  112. package/esm/styles.css +2 -0
  113. package/package.json +2 -1
  114. package/src/components/Avatar/AvatarView/AvatarComponent/avatarComponent.tsx +120 -153
  115. package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/AnimationController.ts +3 -6
  116. package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.tsx +11 -1
  117. package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/types.ts +1 -0
  118. package/src/components/Avatar/AvatarView/AvatarComponent/components/MorphTargetController.ts +33 -10
  119. package/src/components/Avatar/AvatarView/AvatarComponent/components/PositionController.ts +1 -1
  120. package/src/components/Avatar/AvatarView/AvatarComponent/components/controls.tsx +2 -2
  121. package/src/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.tsx +1 -1
  122. package/src/components/Avatar/AvatarView/AvatarComponent/constants.ts +127 -0
  123. package/src/components/Chat/Chat.tsx +16 -10
  124. package/src/components/ChatBubble/ChatBubble.css +4 -0
  125. package/src/components/ChatBubble/ChatBubble.stories.tsx +12 -0
  126. package/src/components/ChatBubble/ChatBubble.tsx +23 -2
  127. package/src/components/ChatInputs/ChatInputs.stories.tsx +5 -0
  128. package/src/components/ChatInputs/ChatInputs.test.tsx +6 -6
  129. package/src/components/ChatInputs/ChatInputs.tsx +91 -23
  130. package/src/components/CompletionProviderStatus/CompletionProviderStatus.css +8 -0
  131. package/src/components/CompletionProviderStatus/CompletionProviderStatus.stories.tsx +1 -1
  132. package/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx +95 -66
  133. package/src/components/ExpertsDrawer/ExpertsDrawer.tsx +3 -1
  134. package/src/components/FilePreview/FilePreview.css +155 -0
  135. package/src/components/FilePreview/FilePreview.stories.tsx +66 -0
  136. package/src/components/FilePreview/FilePreview.test.tsx +26 -0
  137. package/src/components/FilePreview/FilePreview.tsx +85 -0
  138. package/src/components/FilePreview/__snapshots__/FilePreview.test.tsx.snap +149 -0
  139. package/src/components/MemoriWidget/MemoriWidget.tsx +68 -3
  140. package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +240 -0
  141. package/src/components/UploadButton/UploadButton.css +38 -0
  142. package/src/components/UploadButton/UploadButton.stories.tsx +62 -0
  143. package/src/components/UploadButton/UploadButton.test.tsx +11 -0
  144. package/src/components/UploadButton/UploadButton.tsx +126 -0
  145. package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +31 -0
  146. package/src/components/icons/Preview.tsx +23 -0
  147. package/src/components/icons/Upload.tsx +23 -0
  148. package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +24 -0
  149. package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +24 -0
  150. package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +24 -0
  151. package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +24 -0
  152. package/src/components/layouts/layouts.stories.tsx +30 -46
  153. package/src/index.stories.tsx +68 -2
  154. package/src/index.tsx +4 -0
  155. package/src/styles.css +2 -0
  156. package/src/components/Avatar/AvatarView/AvatarComponent/components/constants.ts +0 -29
@@ -79,6 +79,30 @@ exports[`renders StartPanel for board of experts unchanged 1`] = `
79
79
  >
80
80
  write_and_speak.tryMeButton
81
81
  </button>
82
+ <div
83
+ class="memori--completion-provider-status--loading"
84
+ >
85
+ <div
86
+ class="memori-spin memori-spin--spinning"
87
+ >
88
+ <div
89
+ class="memori-spin--spinner"
90
+ >
91
+ <svg
92
+ aria-hidden="true"
93
+ class="memori-loading-icon"
94
+ focusable="false"
95
+ role="img"
96
+ viewBox="0 0 1024 1024"
97
+ xmlns="http://www.w3.org/2000/svg"
98
+ >
99
+ <path
100
+ d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
101
+ />
102
+ </svg>
103
+ </div>
104
+ </div>
105
+ </div>
82
106
  <p
83
107
  class="memori--start-description"
84
108
  >
@@ -180,6 +204,30 @@ exports[`renders StartPanel on instruct unchanged 1`] = `
180
204
  >
181
205
  write_and_speak.instructButton
182
206
  </button>
207
+ <div
208
+ class="memori--completion-provider-status--loading"
209
+ >
210
+ <div
211
+ class="memori-spin memori-spin--spinning"
212
+ >
213
+ <div
214
+ class="memori-spin--spinner"
215
+ >
216
+ <svg
217
+ aria-hidden="true"
218
+ class="memori-loading-icon"
219
+ focusable="false"
220
+ role="img"
221
+ viewBox="0 0 1024 1024"
222
+ xmlns="http://www.w3.org/2000/svg"
223
+ >
224
+ <path
225
+ d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
226
+ />
227
+ </svg>
228
+ </div>
229
+ </div>
230
+ </div>
183
231
  <p
184
232
  class="memori--start-description"
185
233
  >
@@ -281,6 +329,30 @@ exports[`renders StartPanel unchanged 1`] = `
281
329
  >
282
330
  write_and_speak.tryMeButton
283
331
  </button>
332
+ <div
333
+ class="memori--completion-provider-status--loading"
334
+ >
335
+ <div
336
+ class="memori-spin memori-spin--spinning"
337
+ >
338
+ <div
339
+ class="memori-spin--spinner"
340
+ >
341
+ <svg
342
+ aria-hidden="true"
343
+ class="memori-loading-icon"
344
+ focusable="false"
345
+ role="img"
346
+ viewBox="0 0 1024 1024"
347
+ xmlns="http://www.w3.org/2000/svg"
348
+ >
349
+ <path
350
+ d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
351
+ />
352
+ </svg>
353
+ </div>
354
+ </div>
355
+ </div>
284
356
  <p
285
357
  class="memori--start-description"
286
358
  >
@@ -521,6 +593,30 @@ exports[`renders StartPanel with completions enabled unchanged 1`] = `
521
593
  >
522
594
  write_and_speak.tryMeButton
523
595
  </button>
596
+ <div
597
+ class="memori--completion-provider-status--loading"
598
+ >
599
+ <div
600
+ class="memori-spin memori-spin--spinning"
601
+ >
602
+ <div
603
+ class="memori-spin--spinner"
604
+ >
605
+ <svg
606
+ aria-hidden="true"
607
+ class="memori-loading-icon"
608
+ focusable="false"
609
+ role="img"
610
+ viewBox="0 0 1024 1024"
611
+ xmlns="http://www.w3.org/2000/svg"
612
+ >
613
+ <path
614
+ d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
615
+ />
616
+ </svg>
617
+ </div>
618
+ </div>
619
+ </div>
524
620
  <p
525
621
  class="memori--start-description"
526
622
  >
@@ -622,6 +718,30 @@ exports[`renders StartPanel with deep thought but unlogged unchanged 1`] = `
622
718
  >
623
719
  write_and_speak.tryMeButton
624
720
  </button>
721
+ <div
722
+ class="memori--completion-provider-status--loading"
723
+ >
724
+ <div
725
+ class="memori-spin memori-spin--spinning"
726
+ >
727
+ <div
728
+ class="memori-spin--spinner"
729
+ >
730
+ <svg
731
+ aria-hidden="true"
732
+ class="memori-loading-icon"
733
+ focusable="false"
734
+ role="img"
735
+ viewBox="0 0 1024 1024"
736
+ xmlns="http://www.w3.org/2000/svg"
737
+ >
738
+ <path
739
+ d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
740
+ />
741
+ </svg>
742
+ </div>
743
+ </div>
744
+ </div>
625
745
  <p
626
746
  class="memori--start-description"
627
747
  >
@@ -792,6 +912,30 @@ exports[`renders StartPanel with deep thought enabled but without permission fla
792
912
  >
793
913
  write_and_speak.tryMeButton
794
914
  </button>
915
+ <div
916
+ class="memori--completion-provider-status--loading"
917
+ >
918
+ <div
919
+ class="memori-spin memori-spin--spinning"
920
+ >
921
+ <div
922
+ class="memori-spin--spinner"
923
+ >
924
+ <svg
925
+ aria-hidden="true"
926
+ class="memori-loading-icon"
927
+ focusable="false"
928
+ role="img"
929
+ viewBox="0 0 1024 1024"
930
+ xmlns="http://www.w3.org/2000/svg"
931
+ >
932
+ <path
933
+ d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
934
+ />
935
+ </svg>
936
+ </div>
937
+ </div>
938
+ </div>
795
939
  <p
796
940
  class="memori--start-description"
797
941
  >
@@ -955,6 +1099,30 @@ exports[`renders StartPanel with deep thought enabled unchanged 1`] = `
955
1099
  >
956
1100
  write_and_speak.tryMeButton
957
1101
  </button>
1102
+ <div
1103
+ class="memori--completion-provider-status--loading"
1104
+ >
1105
+ <div
1106
+ class="memori-spin memori-spin--spinning"
1107
+ >
1108
+ <div
1109
+ class="memori-spin--spinner"
1110
+ >
1111
+ <svg
1112
+ aria-hidden="true"
1113
+ class="memori-loading-icon"
1114
+ focusable="false"
1115
+ role="img"
1116
+ viewBox="0 0 1024 1024"
1117
+ xmlns="http://www.w3.org/2000/svg"
1118
+ >
1119
+ <path
1120
+ d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
1121
+ />
1122
+ </svg>
1123
+ </div>
1124
+ </div>
1125
+ </div>
958
1126
  <p
959
1127
  class="memori--start-description"
960
1128
  >
@@ -1115,6 +1283,30 @@ exports[`renders StartPanel with existing sessionunchanged 1`] = `
1115
1283
  >
1116
1284
  write_and_speak.resumeButton
1117
1285
  </button>
1286
+ <div
1287
+ class="memori--completion-provider-status--loading"
1288
+ >
1289
+ <div
1290
+ class="memori-spin memori-spin--spinning"
1291
+ >
1292
+ <div
1293
+ class="memori-spin--spinner"
1294
+ >
1295
+ <svg
1296
+ aria-hidden="true"
1297
+ class="memori-loading-icon"
1298
+ focusable="false"
1299
+ role="img"
1300
+ viewBox="0 0 1024 1024"
1301
+ xmlns="http://www.w3.org/2000/svg"
1302
+ >
1303
+ <path
1304
+ d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
1305
+ />
1306
+ </svg>
1307
+ </div>
1308
+ </div>
1309
+ </div>
1118
1310
  <p
1119
1311
  class="memori--start-description"
1120
1312
  >
@@ -1216,6 +1408,30 @@ exports[`renders StartPanel with integrationConfig unchanged 1`] = `
1216
1408
  >
1217
1409
  write_and_speak.tryMeButton
1218
1410
  </button>
1411
+ <div
1412
+ class="memori--completion-provider-status--loading"
1413
+ >
1414
+ <div
1415
+ class="memori-spin memori-spin--spinning"
1416
+ >
1417
+ <div
1418
+ class="memori-spin--spinner"
1419
+ >
1420
+ <svg
1421
+ aria-hidden="true"
1422
+ class="memori-loading-icon"
1423
+ focusable="false"
1424
+ role="img"
1425
+ viewBox="0 0 1024 1024"
1426
+ xmlns="http://www.w3.org/2000/svg"
1427
+ >
1428
+ <path
1429
+ d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
1430
+ />
1431
+ </svg>
1432
+ </div>
1433
+ </div>
1434
+ </div>
1219
1435
  <p
1220
1436
  class="memori--start-description"
1221
1437
  >
@@ -1417,6 +1633,30 @@ exports[`renders StartPanel with multilangual unchanged 1`] = `
1417
1633
  >
1418
1634
  write_and_speak.tryMeButton
1419
1635
  </button>
1636
+ <div
1637
+ class="memori--completion-provider-status--loading"
1638
+ >
1639
+ <div
1640
+ class="memori-spin memori-spin--spinning"
1641
+ >
1642
+ <div
1643
+ class="memori-spin--spinner"
1644
+ >
1645
+ <svg
1646
+ aria-hidden="true"
1647
+ class="memori-loading-icon"
1648
+ focusable="false"
1649
+ role="img"
1650
+ viewBox="0 0 1024 1024"
1651
+ xmlns="http://www.w3.org/2000/svg"
1652
+ >
1653
+ <path
1654
+ d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
1655
+ />
1656
+ </svg>
1657
+ </div>
1658
+ </div>
1659
+ </div>
1420
1660
  <p
1421
1661
  class="memori--start-description"
1422
1662
  >
@@ -0,0 +1,38 @@
1
+ .file-upload-wrapper {
2
+ margin-right: 0.5rem;
3
+ }
4
+
5
+ .memori--upload-file-input {
6
+ display: none;
7
+ }
8
+
9
+ .memori--upload-button {
10
+ /* position: absolute; */
11
+ right: 160px;
12
+ bottom: 8px;
13
+ padding: 8px;
14
+ border: none;
15
+ background: transparent;
16
+ cursor: pointer;
17
+ transition: background-color 0.2s ease;
18
+ }
19
+
20
+ .memori--upload-button:disabled {
21
+ cursor: not-allowed;
22
+ opacity: 0.6;
23
+ }
24
+
25
+ .memori--upload-button:hover:not(:disabled) {
26
+ background-color: rgba(128, 128, 128, 0.1);
27
+ }
28
+
29
+ .memori--upload-icon {
30
+ width: 20px;
31
+ height: 20px;
32
+ }
33
+
34
+ .memori--conversation-button:hover .memori--upload-icon {
35
+ fill: var(--memori-primary);
36
+ transition: fill 0.2s ease;
37
+ }
38
+
@@ -0,0 +1,62 @@
1
+ import React, { useState } from 'react';
2
+ import { Meta, Story } from '@storybook/react';
3
+ import I18nWrapper from '../../I18nWrapper';
4
+ import UploadButton from './UploadButton';
5
+
6
+ import './UploadButton.css';
7
+
8
+ const meta: Meta = {
9
+ title: 'Widget/Upload Button',
10
+ component: UploadButton,
11
+ argTypes: {
12
+ disabled: {
13
+ control: {
14
+ type: 'boolean',
15
+ },
16
+ },
17
+ },
18
+ parameters: {
19
+ controls: { expanded: true },
20
+ },
21
+ };
22
+
23
+
24
+ type Props = {
25
+ onUpload: (text: string) => void;
26
+ convertapiToken: string;
27
+ };
28
+
29
+ export default meta;
30
+
31
+ const Template: Story<Props> = args => {
32
+ const [previewFiles, setPreviewFiles] = useState<{ name: string; id: string; content: string; }[]>([]);
33
+
34
+ return (
35
+ <I18nWrapper>
36
+ <div
37
+ style={{
38
+ minHeight: '200px',
39
+ display: 'flex',
40
+ alignItems: 'flex-end',
41
+ }}
42
+ >
43
+ <UploadButton {...args} setPreviewFiles={setPreviewFiles} />
44
+ </div>
45
+ </I18nWrapper>
46
+ );
47
+ };
48
+
49
+ // By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
50
+ // https://storybook.js.org/docs/react/workflows/unit-testing
51
+ export const Default = Template.bind({});
52
+ Default.args = {
53
+ onUpload: () => {},
54
+ convertapiToken: 'c3lITDU8Pvr1ovTz',
55
+ };
56
+
57
+ export const Disabled = Template.bind({});
58
+ Disabled.args = {
59
+ onUpload: () => {},
60
+ convertapiToken: 'c3lITDU8Pvr1ovTz',
61
+ disabled: true,
62
+ };
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import UploadButton from './UploadButton';
4
+
5
+ it('renders UploadButton unchanged', () => {
6
+ const { container } = render(
7
+ <UploadButton setPreviewFiles={jest.fn()} />
8
+ );
9
+ expect(container).toMatchSnapshot();
10
+ });
11
+
@@ -0,0 +1,126 @@
1
+ import React, { useState, useRef, useEffect } from 'react';
2
+ import cx from 'classnames';
3
+ import ConvertApi from 'convertapi-js';
4
+ import UploadIcon from '../icons/Upload';
5
+ import Spin from '../ui/Spin';
6
+
7
+ /**
8
+ * UploadButton component
9
+ * @param {Function} setPreviewFiles - Callback function to handle the uploaded text
10
+ * @returns {JSX.Element}
11
+ */
12
+ const FileUploadButton = ({
13
+ setPreviewFiles,
14
+ }: {
15
+ setPreviewFiles: (
16
+ previewFiles: { name: string; id: string; content: string }[]
17
+ ) => void;
18
+ }) => {
19
+ const [isLoading, setIsLoading] = useState(false);
20
+ const [error, setError] = useState<string | null>(null);
21
+ const fileInputRef = useRef<HTMLInputElement>(null);
22
+ const [convertapiToken, setConvertapiToken] = useState<string>();
23
+
24
+ const fetchConvertapiToken = async () => {
25
+ try {
26
+ const result = await fetch('https://www.aisuru.com/api/convertapi-token');
27
+ const response = await result.json();
28
+ setConvertapiToken(response.Tokens?.[0]?.Id);
29
+ } catch (error) {
30
+ console.error('Error fetching ConvertAPI token:', error);
31
+ }
32
+ };
33
+ useEffect(() => {
34
+ fetchConvertapiToken();
35
+ // eslint-disable-next-line react-hooks/exhaustive-deps
36
+ }, []);
37
+
38
+ const convertToTxt = async (file: File) => {
39
+ if (!convertapiToken || !file) {
40
+ console.error('Missing ConvertAPI token or file');
41
+ setError('Missing ConvertAPI token or file');
42
+ return;
43
+ }
44
+
45
+ setIsLoading(true);
46
+ const fileExt =
47
+ file.name.split('.').pop() || file.type.split('/').pop() || 'pdf';
48
+
49
+ try {
50
+ const convertApi = ConvertApi.auth(convertapiToken);
51
+ const params = convertApi.createParams();
52
+ params.add('File', file);
53
+ params.add('TextEncoding', 'UTF-8');
54
+ params.add('PageRange', '1-2000');
55
+
56
+ const result = await convertApi.convert(fileExt, 'txt', params);
57
+ const fileUrl = result.files[0].Url;
58
+
59
+ const response = await fetch(fileUrl);
60
+ const text = await response.text();
61
+
62
+ return text;
63
+ } catch (error) {
64
+ console.error('Conversion error:', error);
65
+ setError('Conversion error');
66
+ } finally {
67
+ setIsLoading(false);
68
+ }
69
+ };
70
+
71
+ const handleFileSelect = async (e: React.ChangeEvent<HTMLInputElement>) => {
72
+ const files = Array.from(e.target.files || []);
73
+ const newPreviewFiles: { name: string; id: string; content: string }[] = [];
74
+
75
+ for (const file of files) {
76
+ const fileId = Math.random().toString(36).substr(2, 9);
77
+
78
+ const text = await convertToTxt(file);
79
+
80
+ if (text) {
81
+ newPreviewFiles.push({
82
+ name: file.name,
83
+ id: fileId,
84
+ content: text || '',
85
+ });
86
+ } else {
87
+ setError('Failed to convert file to text');
88
+ }
89
+ }
90
+
91
+ setPreviewFiles(newPreviewFiles);
92
+ };
93
+
94
+ return (
95
+ <div className="file-upload-wrapper">
96
+ <input
97
+ ref={fileInputRef}
98
+ type="file"
99
+ accept=".pdf,.doc,.docx,.txt"
100
+ className="memori--upload-file-input"
101
+ onChange={handleFileSelect}
102
+ />
103
+
104
+ <button
105
+ className={cx(
106
+ 'memori-button',
107
+ 'memori-button--circle',
108
+ 'memori-button--icon-only',
109
+ 'memori-share-button--button',
110
+ 'memori--conversation-button',
111
+ { 'memori--error': error }
112
+ )}
113
+ onClick={() => fileInputRef.current?.click()}
114
+ disabled={isLoading}
115
+ >
116
+ {isLoading ? (
117
+ <Spin spinning className="memori--upload-icon" />
118
+ ) : (
119
+ <UploadIcon className="memori--upload-icon" />
120
+ )}
121
+ </button>
122
+ </div>
123
+ );
124
+ };
125
+
126
+ export default FileUploadButton;
@@ -0,0 +1,31 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders UploadButton unchanged 1`] = `
4
+ <div>
5
+ <div
6
+ class="file-upload-wrapper"
7
+ >
8
+ <input
9
+ accept=".pdf,.doc,.docx,.txt"
10
+ class="memori--upload-file-input"
11
+ type="file"
12
+ />
13
+ <button
14
+ class="memori-button memori-button--circle memori-button--icon-only memori-share-button--button memori--conversation-button"
15
+ >
16
+ <svg
17
+ aria-hidden="true"
18
+ class="memori--upload-icon"
19
+ focusable="false"
20
+ role="img"
21
+ viewBox="0 0 24 24"
22
+ xmlns="http://www.w3.org/2000/svg"
23
+ >
24
+ <path
25
+ d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"
26
+ />
27
+ </svg>
28
+ </button>
29
+ </div>
30
+ </div>
31
+ `;
@@ -0,0 +1,23 @@
1
+ const PreviewIcon = ({
2
+ className,
3
+ title,
4
+ }: {
5
+ className?: string;
6
+ title?: string;
7
+ }) => (
8
+ <svg
9
+ {...(!title ? { 'aria-hidden': 'true' } : {})}
10
+ focusable="false"
11
+ role="img"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ viewBox="0 0 24 24"
14
+ className={className}
15
+ aria-label={title}
16
+ >
17
+ <path
18
+ d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"
19
+ />
20
+ </svg>
21
+ );
22
+
23
+ export default PreviewIcon;
@@ -0,0 +1,23 @@
1
+ const UploadIcon = ({
2
+ className,
3
+ title,
4
+ }: {
5
+ className?: string;
6
+ title?: string;
7
+ }) => (
8
+ <svg
9
+ {...(!title ? { 'aria-hidden': 'true' } : {})}
10
+ focusable="false"
11
+ role="img"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ viewBox="0 0 24 24"
14
+ className={className}
15
+ aria-label={title}
16
+ >
17
+ <path
18
+ d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"
19
+ />
20
+ </svg>
21
+ );
22
+
23
+ export default UploadIcon;
@@ -342,6 +342,30 @@ exports[`renders Chat layout unchanged 1`] = `
342
342
  >
343
343
  INIZIAMO
344
344
  </button>
345
+ <div
346
+ class="memori--completion-provider-status--loading"
347
+ >
348
+ <div
349
+ class="memori-spin memori-spin--spinning"
350
+ >
351
+ <div
352
+ class="memori-spin--spinner"
353
+ >
354
+ <svg
355
+ aria-hidden="true"
356
+ class="memori-loading-icon"
357
+ focusable="false"
358
+ role="img"
359
+ viewBox="0 0 1024 1024"
360
+ xmlns="http://www.w3.org/2000/svg"
361
+ >
362
+ <path
363
+ d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
364
+ />
365
+ </svg>
366
+ </div>
367
+ </div>
368
+ </div>
345
369
  <p
346
370
  class="memori--start-description"
347
371
  >
@@ -381,6 +381,30 @@ exports[`renders FullPage layout unchanged 1`] = `
381
381
  >
382
382
  INIZIAMO
383
383
  </button>
384
+ <div
385
+ class="memori--completion-provider-status--loading"
386
+ >
387
+ <div
388
+ class="memori-spin memori-spin--spinning"
389
+ >
390
+ <div
391
+ class="memori-spin--spinner"
392
+ >
393
+ <svg
394
+ aria-hidden="true"
395
+ class="memori-loading-icon"
396
+ focusable="false"
397
+ role="img"
398
+ viewBox="0 0 1024 1024"
399
+ xmlns="http://www.w3.org/2000/svg"
400
+ >
401
+ <path
402
+ d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
403
+ />
404
+ </svg>
405
+ </div>
406
+ </div>
407
+ </div>
384
408
  <p
385
409
  class="memori--start-description"
386
410
  >