@memori.ai/memori-react 7.26.1 → 7.27.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 (76) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/components/ChatBubble/ChatBubble.css +34 -1
  3. package/dist/components/ChatBubble/ChatBubble.js +7 -6
  4. package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
  5. package/dist/components/Header/Header.d.ts +1 -0
  6. package/dist/components/Header/Header.js +23 -22
  7. package/dist/components/Header/Header.js.map +1 -1
  8. package/dist/components/ShareButton/ShareButton.css +6 -0
  9. package/dist/components/ShareButton/ShareButton.d.ts +3 -1
  10. package/dist/components/ShareButton/ShareButton.js +3 -3
  11. package/dist/components/ShareButton/ShareButton.js.map +1 -1
  12. package/dist/components/UploadButton/UploadButton.js.map +1 -1
  13. package/dist/components/layouts/HiddenChat.js +6 -25
  14. package/dist/components/layouts/HiddenChat.js.map +1 -1
  15. package/dist/helpers/message.d.ts +1 -1
  16. package/dist/helpers/message.js +2 -1
  17. package/dist/helpers/message.js.map +1 -1
  18. package/dist/helpers/utils.js +3 -0
  19. package/dist/helpers/utils.js.map +1 -1
  20. package/dist/locales/de.json +2 -0
  21. package/dist/locales/en.json +2 -0
  22. package/dist/locales/es.json +2 -0
  23. package/dist/locales/fr.json +2 -0
  24. package/dist/locales/it.json +2 -0
  25. package/esm/components/ChatBubble/ChatBubble.css +34 -1
  26. package/esm/components/ChatBubble/ChatBubble.js +7 -6
  27. package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
  28. package/esm/components/Header/Header.d.ts +1 -0
  29. package/esm/components/Header/Header.js +23 -22
  30. package/esm/components/Header/Header.js.map +1 -1
  31. package/esm/components/ShareButton/ShareButton.css +6 -0
  32. package/esm/components/ShareButton/ShareButton.d.ts +3 -1
  33. package/esm/components/ShareButton/ShareButton.js +3 -3
  34. package/esm/components/ShareButton/ShareButton.js.map +1 -1
  35. package/esm/components/UploadButton/UploadButton.js.map +1 -1
  36. package/esm/components/layouts/HiddenChat.js +6 -25
  37. package/esm/components/layouts/HiddenChat.js.map +1 -1
  38. package/esm/helpers/message.d.ts +1 -1
  39. package/esm/helpers/message.js +2 -1
  40. package/esm/helpers/message.js.map +1 -1
  41. package/esm/helpers/utils.js +3 -0
  42. package/esm/helpers/utils.js.map +1 -1
  43. package/esm/locales/de.json +2 -0
  44. package/esm/locales/en.json +2 -0
  45. package/esm/locales/es.json +2 -0
  46. package/esm/locales/fr.json +2 -0
  47. package/esm/locales/it.json +2 -0
  48. package/package.json +1 -1
  49. package/src/components/ChatBubble/ChatBubble.css +34 -1
  50. package/src/components/ChatBubble/ChatBubble.stories.tsx +13 -0
  51. package/src/components/ChatBubble/ChatBubble.test.tsx +32 -0
  52. package/src/components/ChatBubble/ChatBubble.tsx +24 -16
  53. package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +232 -0
  54. package/src/components/Header/Header.stories.tsx +7 -1
  55. package/src/components/Header/Header.tsx +27 -22
  56. package/src/components/ShareButton/ShareButton.css +6 -0
  57. package/src/components/ShareButton/ShareButton.stories.tsx +18 -1
  58. package/src/components/ShareButton/ShareButton.test.tsx +8 -1
  59. package/src/components/ShareButton/ShareButton.tsx +33 -2
  60. package/src/components/ShareButton/__snapshots__/ShareButton.test.tsx.snap +35 -0
  61. package/src/components/UploadButton/UploadButton.tsx +1 -0
  62. package/src/components/layouts/HiddenChat.tsx +2 -33
  63. package/src/components/layouts/layouts.stories.tsx +1 -0
  64. package/src/helpers/message.ts +6 -1
  65. package/src/helpers/utils.ts +5 -0
  66. package/src/locales/de.json +2 -0
  67. package/src/locales/en.json +2 -0
  68. package/src/locales/es.json +2 -0
  69. package/src/locales/fr.json +2 -0
  70. package/src/locales/it.json +2 -0
  71. package/dist/components/ChatBubble/VirtualizedContent/VirtualizedContent.d.ts +0 -7
  72. package/dist/components/ChatBubble/VirtualizedContent/VirtualizedContent.js +0 -69
  73. package/dist/components/ChatBubble/VirtualizedContent/VirtualizedContent.js.map +0 -1
  74. package/esm/components/ChatBubble/VirtualizedContent/VirtualizedContent.d.ts +0 -7
  75. package/esm/components/ChatBubble/VirtualizedContent/VirtualizedContent.js +0 -67
  76. package/esm/components/ChatBubble/VirtualizedContent/VirtualizedContent.js.map +0 -1
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Meta, Story } from '@storybook/react';
3
3
  import I18nWrapper from '../../I18nWrapper';
4
4
  import ShareButton, { Props } from './ShareButton';
5
- import { tenant } from '../../mocks/data';
5
+ import { tenant, memori, sessionID } from '../../mocks/data';
6
6
 
7
7
  import './ShareButton.css';
8
8
 
@@ -79,3 +79,20 @@ WithQrCodeAndOtherTenant.args = {
79
79
  theme: 'tailoor',
80
80
  },
81
81
  };
82
+
83
+ export const WithMemoriAndSessionID = Template.bind({});
84
+ WithMemoriAndSessionID.args = {
85
+ url: 'https://memori.ai',
86
+ memori,
87
+ sessionID,
88
+ showQrCode: false,
89
+ };
90
+
91
+ export const WithMemoriAndSessionIDAndQrCode = Template.bind({});
92
+ WithMemoriAndSessionIDAndQrCode.args = {
93
+ url: 'https://memori.ai',
94
+ memori,
95
+ sessionID,
96
+ showQrCode: true,
97
+ align: 'right',
98
+ };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { render } from '@testing-library/react';
3
3
  import ShareButton from './ShareButton';
4
- import { tenant } from '../../mocks/data';
4
+ import { tenant, memori, sessionID } from '../../mocks/data';
5
5
 
6
6
  it('renders ShareButton unchanged', () => {
7
7
  const { container } = render(<ShareButton />);
@@ -44,3 +44,10 @@ it('renders ShareButton with other tenant img set unchanged', () => {
44
44
  );
45
45
  expect(container).toMatchSnapshot();
46
46
  });
47
+
48
+ it('renders ShareButton with share chat unchanged', () => {
49
+ const { container } = render(
50
+ <ShareButton memori={memori} sessionID={sessionID} />
51
+ );
52
+ expect(container).toMatchSnapshot();
53
+ });
@@ -13,10 +13,12 @@ import { QRCodeCanvas } from 'qrcode.react';
13
13
  import { Menu } from '@headlessui/react';
14
14
  import Button from '../ui/Button';
15
15
  import cx from 'classnames';
16
- import { Tenant } from '@memori.ai/memori-api-client/dist/types';
16
+ import { Tenant, Memori } from '@memori.ai/memori-api-client/dist/types';
17
17
 
18
18
  export interface Props {
19
19
  tenant?: Tenant;
20
+ memori?: Memori;
21
+ sessionID?: string;
20
22
  url?: string;
21
23
  title?: string;
22
24
  className?: string;
@@ -28,6 +30,8 @@ export interface Props {
28
30
 
29
31
  const ShareButton: React.FC<Props> = ({
30
32
  tenant,
33
+ memori,
34
+ sessionID,
31
35
  url,
32
36
  title = '',
33
37
  className,
@@ -36,7 +40,7 @@ const ShareButton: React.FC<Props> = ({
36
40
  showQrCode = true,
37
41
  align = 'right',
38
42
  }: Props) => {
39
- const { t } = useTranslation();
43
+ const { t, i18n } = useTranslation();
40
44
  const [targetUrl, setTargetUrl] = useState(url);
41
45
 
42
46
  const qrImageURL = useMemo(
@@ -132,6 +136,33 @@ const ShareButton: React.FC<Props> = ({
132
136
  </div>
133
137
  </Menu.Button>
134
138
  <Menu.Items className="memori-share-button--overlay" as="ul">
139
+ {memori && sessionID && (
140
+ <Menu.Item
141
+ key="shared"
142
+ as="li"
143
+ className="memori-share-button--li memori-share-button--li-shared"
144
+ >
145
+ <a
146
+ className={cx(
147
+ 'memori-button',
148
+ 'memori-button--with-icon',
149
+ 'memori-button--ghost',
150
+ 'memori-button--padded',
151
+ 'memori-share-button--link'
152
+ )}
153
+ href={`${baseUrl ?? 'https://www.aisuru.com'}/${
154
+ i18n.language === 'it' ? 'it' : 'en'
155
+ }/shared/${memori.ownerUserID}/${memori.memoriID}/${sessionID}`}
156
+ target="_blank"
157
+ rel="noopener noreferrer"
158
+ >
159
+ <div className="memori-button--icon">
160
+ <Share />
161
+ </div>
162
+ {t('widget.shareChat') || 'Share chat'}
163
+ </a>
164
+ </Menu.Item>
165
+ )}
135
166
  <Menu.Item key="copy" as="li" className="memori-share-button--li">
136
167
  <Button
137
168
  className="memori-share-button--link"
@@ -140,6 +140,41 @@ exports[`renders ShareButton with other tenant img set unchanged 1`] = `
140
140
  </div>
141
141
  `;
142
142
 
143
+ exports[`renders ShareButton with share chat unchanged 1`] = `
144
+ <div>
145
+ <div
146
+ class="memori-share-button"
147
+ data-headlessui-state=""
148
+ >
149
+ <button
150
+ aria-expanded="false"
151
+ aria-haspopup="true"
152
+ class="memori-button memori-button--circle memori-button--icon-only memori-share-button--button memori-button--primary"
153
+ data-headlessui-state=""
154
+ id="headlessui-menu-button-:rg:"
155
+ title="widget.share"
156
+ type="button"
157
+ >
158
+ <div
159
+ class="memori-button--icon"
160
+ >
161
+ <svg
162
+ aria-hidden="true"
163
+ focusable="false"
164
+ role="img"
165
+ viewBox="0 0 1024 1024"
166
+ xmlns="http://www.w3.org/2000/svg"
167
+ >
168
+ <path
169
+ d="M752 664c-28.5 0-54.8 10-75.4 26.7L469.4 540.8a160.68 160.68 0 0 0 0-57.6l207.2-149.9C697.2 350 723.5 360 752 360c66.2 0 120-53.8 120-120s-53.8-120-120-120-120 53.8-120 120c0 11.6 1.6 22.7 4.7 33.3L439.9 415.8C410.7 377.1 364.3 352 312 352c-88.4 0-160 71.6-160 160s71.6 160 160 160c52.3 0 98.7-25.1 127.9-63.8l196.8 142.5c-3.1 10.6-4.7 21.8-4.7 33.3 0 66.2 53.8 120 120 120s120-53.8 120-120-53.8-120-120-120zm0-476c28.7 0 52 23.3 52 52s-23.3 52-52 52-52-23.3-52-52 23.3-52 52-52zM312 600c-48.5 0-88-39.5-88-88s39.5-88 88-88 88 39.5 88 88-39.5 88-88 88zm440 236c-28.7 0-52-23.3-52-52s23.3-52 52-52 52 23.3 52 52-23.3 52-52 52z"
170
+ />
171
+ </svg>
172
+ </div>
173
+ </button>
174
+ </div>
175
+ </div>
176
+ `;
177
+
143
178
  exports[`renders ShareButton with tenant img set unchanged 1`] = `
144
179
  <div>
145
180
  <div
@@ -125,6 +125,7 @@ const UploadButton: React.FC<UploadManagerProps> = ({
125
125
  .replace(/>/g, '&gt;');
126
126
  };
127
127
 
128
+ // ✅ MIGLIORE SOLUZIONE: Tag XML valido con attributi chiari
128
129
  const escapedFileName = escapeAttributeValue(file.name);
129
130
  const formattedContent = `<document_attachment filename="${escapedFileName}" type="${file.mimeType}">
130
131
  ${file.content}
@@ -12,7 +12,7 @@ const HiddenChatLayout: React.FC<LayoutProps> = ({
12
12
  headerProps,
13
13
  Chat,
14
14
  chatProps,
15
- startPanelProps,
15
+ // startPanelProps,
16
16
  sessionId,
17
17
  hasUserActivatedSpeak,
18
18
  }) => {
@@ -28,18 +28,6 @@ const HiddenChatLayout: React.FC<LayoutProps> = ({
28
28
  backgroundColor: '',
29
29
  });
30
30
 
31
- const initChat = () => {
32
- try {
33
- window.speechSynthesis.speak(new SpeechSynthesisUtterance(''));
34
- } catch (e) {
35
- console.error(e);
36
- }
37
- if (startPanelProps && startPanelProps?.initializeTTS)
38
- startPanelProps?.initializeTTS();
39
- if (startPanelProps && startPanelProps?.onClickStart)
40
- startPanelProps?.onClickStart();
41
- };
42
-
43
31
  useEffect(() => {
44
32
  // Check if fullscreen is available
45
33
  if (document.fullscreenEnabled) {
@@ -93,9 +81,6 @@ const HiddenChatLayout: React.FC<LayoutProps> = ({
93
81
  }
94
82
 
95
83
  setIsOpen(prev => {
96
- if (!prev) {
97
- initChat();
98
- }
99
84
  return !prev;
100
85
  });
101
86
  };
@@ -203,25 +188,9 @@ const HiddenChatLayout: React.FC<LayoutProps> = ({
203
188
  }}
204
189
  {...headerProps}
205
190
  className="memori-hidden-chat-layout-header--layout"
191
+ fullScreenHandler={handleFullscreenToggle}
206
192
  />
207
193
  )}
208
- {fullScreenAvailable && (
209
- <button
210
- className="memori-fullscreen-button memori-button--primary memori-button--icon"
211
- onClick={handleFullscreenToggle}
212
- title={
213
- fullScreen
214
- ? t('fullscreenExit') || 'Exit fullscreen'
215
- : t('fullscreenEnter') || 'Enter fullscreen'
216
- }
217
- >
218
- {fullScreen ? (
219
- <FullscreenExit className="memori-icon" />
220
- ) : (
221
- <Fullscreen className="memori-icon" />
222
- )}
223
- </button>
224
- )}
225
194
  </div>
226
195
  </div>
227
196
  <div id="extension" />
@@ -417,6 +417,7 @@ HiddenChat.args = {
417
417
  uiLang: 'it',
418
418
  showShare: true,
419
419
  showSettings: true,
420
+ autoStart: true,
420
421
  // memori,
421
422
  // tenant,
422
423
  memori: {
@@ -62,7 +62,8 @@ export const truncateMessage = (message: string) => {
62
62
 
63
63
  export const renderMsg = (
64
64
  text: string,
65
- useMathFormatting = false
65
+ useMathFormatting = false,
66
+ reasoningText = 'Reasoning...'
66
67
  ): {
67
68
  text: string;
68
69
  } => {
@@ -74,6 +75,10 @@ export const renderMsg = (
74
75
  /\[([^\]]+)\]\(([^\)]+)\)/g,
75
76
  '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'
76
77
  )
78
+ .replaceAll(
79
+ /<think>(.*?)<\/think>/g,
80
+ `<details class="memori-think"><summary>${reasoningText}</summary>$1</details>`
81
+ )
77
82
  .replaceAll(/```markdown([^```]+)```/g, '$1')
78
83
  .replaceAll('($', '( $')
79
84
  .replaceAll(':$', ': $')
@@ -4,6 +4,11 @@ import * as THREE from 'three';
4
4
 
5
5
  export const hasTouchscreen = (): boolean => {
6
6
  let hasTouchScreen = false;
7
+
8
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
9
+ return hasTouchScreen;
10
+ }
11
+
7
12
  if ('maxTouchPoints' in navigator) {
8
13
  hasTouchScreen = navigator.maxTouchPoints > 0;
9
14
  } else if ('msMaxTouchPoints' in navigator) {
@@ -45,6 +45,7 @@
45
45
  "memoriBlockedReasonExceedChats": "weil der monatliche Schwellenwert für erlaubte Chats überschritten wurde.",
46
46
  "memoriBlockedGiverHelper": "Sie können es weiterhin als Administrator verwalten, andere Benutzer können jedoch nicht damit interagieren.",
47
47
  "generatedByAI": "Von KI generierte Antworten können gelegentlich falsche Informationen generieren",
48
+ "reasoning": "Überlegung...",
48
49
  "whyThisAnswer": "Warum diese Antwort?",
49
50
  "whyThisAnswerHelper": "Diese Antwort wurde automatisch von einer künstlichen Intelligenz auf Basis dieser verifizierten Inhalte generiert.",
50
51
  "receiverLabel": "Zugewiesen an",
@@ -106,6 +107,7 @@
106
107
  "position": "Positionspräferenzen",
107
108
  "settings": "Einstellungen",
108
109
  "share": "Aktie",
110
+ "shareChat": "Chat teilen",
109
111
  "sendOnKeypress": "Drücken Sie zum Senden die Eingabetaste",
110
112
  "sendOnClick": "Klicken Sie auf Senden",
111
113
  "boardOfExperts": "Expertengremium",
@@ -45,6 +45,7 @@
45
45
  "memoriBlockedReasonExceedChats": "because it has exceeded the monthly threshold of allowed chats.",
46
46
  "memoriBlockedGiverHelper": "You can still manage it as administrator, but other users will not be able to interact with it.",
47
47
  "generatedByAI": "Answer generated by AI, may occasionally generate incorrect informations",
48
+ "reasoning": "Reasoning...",
48
49
  "whyThisAnswer": "Why this answer?",
49
50
  "whyThisAnswerHelper": "This answer was generated automatically by an artificial intelligence based on these verified contents.",
50
51
  "receiverLabel": "Assigned to",
@@ -106,6 +107,7 @@
106
107
  "position": "Position preferences",
107
108
  "settings": "Settings",
108
109
  "share": "Share",
110
+ "shareChat": "Share chat",
109
111
  "sendOnKeypress": "Hit Enter to send",
110
112
  "sendOnClick": "Click on Submit",
111
113
  "boardOfExperts": "Board of experts",
@@ -45,6 +45,7 @@
45
45
  "memoriBlockedReasonExceedChats": "porque ha superado el umbral mensual de chats permitidos.",
46
46
  "memoriBlockedGiverHelper": "Aún podrás administrarlo como administrador, pero otros usuarios no podrán interactuar con él.",
47
47
  "generatedByAI": "La respuesta generada por IA, ocasionalmente puede generar información incorrecta",
48
+ "reasoning": "Pensamiento...",
48
49
  "whyThisAnswer": "¿Por qué esta respuesta?",
49
50
  "whyThisAnswerHelper": "Esta respuesta fue generada automáticamente por una inteligencia artificial basada en estos contenidos verificados.",
50
51
  "receiverLabel": "Asignado a",
@@ -106,6 +107,7 @@
106
107
  "position": "Preferencias de posición",
107
108
  "settings": "Ajustes",
108
109
  "share": "Compartir",
110
+ "shareChat": "Compartir chat",
109
111
  "sendOnKeypress": "Presiona Enter para enviar",
110
112
  "sendOnClick": "Haga clic en Enviar",
111
113
  "boardOfExperts": "junta de expertos",
@@ -44,6 +44,7 @@
44
44
  "memoriBlockedReasonExceedChats": "car il a dépassé le seuil mensuel de chats autorisés.",
45
45
  "memoriBlockedGiverHelper": "Vous pouvez toujours le gérer en tant qu'administrateur, mais les autres utilisateurs ne pourront pas interagir avec lui.",
46
46
  "generatedByAI": "Réponse générée par l'IA, peut occasionnellement générer des informations incorrectes",
47
+ "reasoning": "Réflexion...",
47
48
  "whyThisAnswer": "Pourquoi cette réponse ?",
48
49
  "whyThisAnswerHelper": "Cette réponse a été générée automatiquement par une intelligence artificielle basée sur ces contenus vérifiés.",
49
50
  "receiverLabel": "Assigné à",
@@ -105,6 +106,7 @@
105
106
  "position": "Préférences de position",
106
107
  "settings": "Paramètres",
107
108
  "share": "Partager",
109
+ "shareChat": "Partager le chat",
108
110
  "sendOnKeypress": "Appuyez sur Entrée pour envoyer",
109
111
  "sendOnClick": "Cliquez sur Soumettre",
110
112
  "boardOfExperts": "Conseil d'experts",
@@ -45,6 +45,7 @@
45
45
  "memoriBlockedReasonExceedChats": "perchè ha superato la soglia mensile di chat ammesse.",
46
46
  "memoriBlockedGiverHelper": "Puoi sempre gestirlo in qualità di amministratore, ma altri utenti non potranno interrogarlo.",
47
47
  "generatedByAI": "Risposta generata da IA, può talvolta generare informazioni non corrette",
48
+ "reasoning": "Ragionamento...",
48
49
  "whyThisAnswer": "Perché questa risposta?",
49
50
  "whyThisAnswerHelper": "Questa risposta è stata generata automaticamente da un'intelligenza artificiale sulla base di questi contenuti verificati.",
50
51
  "receiverLabel": "Assegnato a",
@@ -106,6 +107,7 @@
106
107
  "position": "Preferenze posizione",
107
108
  "settings": "Impostazioni",
108
109
  "share": "Condividi",
110
+ "shareChat": "Condividi chat",
109
111
  "sendOnKeypress": "Premi Invio per inviare",
110
112
  "sendOnClick": "Clicca sul bottone di invio",
111
113
  "boardOfExperts": "Gruppo di esperti",
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface Props {
3
- content: string;
4
- className?: string;
5
- }
6
- declare const VirtualizedContent: React.FC<Props>;
7
- export default VirtualizedContent;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
- const react_1 = require("react");
5
- const VirtualizedContent = ({ content, className = '' }) => {
6
- const [processedContent, setProcessedContent] = (0, react_1.useState)('');
7
- const containerRef = (0, react_1.useRef)(null);
8
- const [height, setHeight] = (0, react_1.useState)(500);
9
- const [loading, setLoading] = (0, react_1.useState)(true);
10
- const [mounted, setMounted] = (0, react_1.useState)(false);
11
- (0, react_1.useEffect)(() => {
12
- setMounted(true);
13
- return () => setMounted(false);
14
- }, []);
15
- (0, react_1.useEffect)(() => {
16
- if (!content) {
17
- setProcessedContent('');
18
- setLoading(false);
19
- return;
20
- }
21
- setLoading(true);
22
- const processContent = () => {
23
- try {
24
- if (content.includes('<')) {
25
- return `<div class="html-content">${content}</div>`;
26
- }
27
- return content
28
- .split(/\n{2,}/)
29
- .filter(para => para.trim().length > 0)
30
- .map(para => `<p>${para.trim()}</p>`)
31
- .join('');
32
- }
33
- catch (error) {
34
- console.error('Error processing content:', error);
35
- return `<p>${content}</p>`;
36
- }
37
- };
38
- setTimeout(() => {
39
- if (mounted) {
40
- const processed = processContent();
41
- setProcessedContent(processed);
42
- setLoading(false);
43
- }
44
- }, 0);
45
- }, [content, mounted]);
46
- (0, react_1.useEffect)(() => {
47
- setHeight(Math.min(500, window.innerHeight * 0.6));
48
- if (containerRef.current) {
49
- const resizeObserver = new ResizeObserver(() => {
50
- setHeight(Math.min(500, window.innerHeight * 0.6));
51
- });
52
- resizeObserver.observe(containerRef.current);
53
- return () => {
54
- if (containerRef.current) {
55
- resizeObserver.unobserve(containerRef.current);
56
- }
57
- };
58
- }
59
- }, []);
60
- if (loading) {
61
- return (0, jsx_runtime_1.jsx)("div", { className: "virtualized-content-loading", children: "Processing content..." });
62
- }
63
- if (!processedContent) {
64
- return (0, jsx_runtime_1.jsx)("div", { className: "virtualized-content-empty", children: "No content to display" });
65
- }
66
- return ((0, jsx_runtime_1.jsx)("div", { ref: containerRef, className: `virtualized-content-container ${className}`, style: { height: height + 'px', width: '100%', position: 'relative' }, children: (0, jsx_runtime_1.jsx)("div", { className: "virtualized-content", style: { height: height, width: '100%', overflow: 'auto' }, dangerouslySetInnerHTML: { __html: processedContent } }) }));
67
- };
68
- exports.default = VirtualizedContent;
69
- //# sourceMappingURL=VirtualizedContent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VirtualizedContent.js","sourceRoot":"","sources":["../../../../src/components/ChatBubble/VirtualizedContent/VirtualizedContent.tsx"],"names":[],"mappings":";;;AAAA,iCAA2D;AAY3D,MAAM,kBAAkB,GAAoB,CAAC,EAAE,OAAO,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE,EAAE;IAC1E,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAS,EAAE,CAAC,CAAC;IACrE,MAAM,YAAY,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAG9C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,EAAE,EAA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E;YACxB,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,GAAG,EAAE;gBAE7C,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,GAAG,CAAC,CAAC,CAAC;YACrD,CAAC,CAAC,CAAC;YAEH,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC7C,OAAO,GAAG,EAAE;gBACV,IAAI,YAAY,CAAC,OAAO,EAAE;oBACxB,cAAc,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;iBAChD;YACH,CAAC,CAAC;SACH;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAGP,IAAI,OAAO,EAAE;QACX,OAAO,gCAAK,SAAS,EAAC,6BAA6B,sCAA4B,CAAC;KACjF;IAGD,IAAI,CAAC,gBAAgB,EAAE;QACrB,OAAO,gCAAK,SAAS,EAAC,2BAA2B,sCAA4B,CAAC;KAC/E;IAED,OAAO,CACL,gCACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,iCAAiC,SAAS,EAAE,EACvD,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,YAErE,gCACE,SAAS,EAAC,qBAAqB,EAC/B,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAC1D,uBAAuB,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,GACrD,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface Props {
3
- content: string;
4
- className?: string;
5
- }
6
- declare const VirtualizedContent: React.FC<Props>;
7
- export default VirtualizedContent;
@@ -1,67 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useState, useRef } from 'react';
3
- const VirtualizedContent = ({ content, className = '' }) => {
4
- const [processedContent, setProcessedContent] = useState('');
5
- const containerRef = useRef(null);
6
- const [height, setHeight] = useState(500);
7
- const [loading, setLoading] = useState(true);
8
- const [mounted, setMounted] = useState(false);
9
- useEffect(() => {
10
- setMounted(true);
11
- return () => setMounted(false);
12
- }, []);
13
- useEffect(() => {
14
- if (!content) {
15
- setProcessedContent('');
16
- setLoading(false);
17
- return;
18
- }
19
- setLoading(true);
20
- const processContent = () => {
21
- try {
22
- if (content.includes('<')) {
23
- return `<div class="html-content">${content}</div>`;
24
- }
25
- return content
26
- .split(/\n{2,}/)
27
- .filter(para => para.trim().length > 0)
28
- .map(para => `<p>${para.trim()}</p>`)
29
- .join('');
30
- }
31
- catch (error) {
32
- console.error('Error processing content:', error);
33
- return `<p>${content}</p>`;
34
- }
35
- };
36
- setTimeout(() => {
37
- if (mounted) {
38
- const processed = processContent();
39
- setProcessedContent(processed);
40
- setLoading(false);
41
- }
42
- }, 0);
43
- }, [content, mounted]);
44
- useEffect(() => {
45
- setHeight(Math.min(500, window.innerHeight * 0.6));
46
- if (containerRef.current) {
47
- const resizeObserver = new ResizeObserver(() => {
48
- setHeight(Math.min(500, window.innerHeight * 0.6));
49
- });
50
- resizeObserver.observe(containerRef.current);
51
- return () => {
52
- if (containerRef.current) {
53
- resizeObserver.unobserve(containerRef.current);
54
- }
55
- };
56
- }
57
- }, []);
58
- if (loading) {
59
- return _jsx("div", { className: "virtualized-content-loading", children: "Processing content..." });
60
- }
61
- if (!processedContent) {
62
- return _jsx("div", { className: "virtualized-content-empty", children: "No content to display" });
63
- }
64
- return (_jsx("div", { ref: containerRef, className: `virtualized-content-container ${className}`, style: { height: height + 'px', width: '100%', position: 'relative' }, children: _jsx("div", { className: "virtualized-content", style: { height: height, width: '100%', overflow: 'auto' }, dangerouslySetInnerHTML: { __html: processedContent } }) }));
65
- };
66
- export default VirtualizedContent;
67
- //# sourceMappingURL=VirtualizedContent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VirtualizedContent.js","sourceRoot":"","sources":["../../../../src/components/ChatBubble/VirtualizedContent/VirtualizedContent.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAY3D,MAAM,kBAAkB,GAAoB,CAAC,EAAE,OAAO,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE,EAAE;IAC1E,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;IACrE,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAG9C,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,EAAE,EAAE,CAAC,CAAC;IAGP,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,EAAE;YACZ,mBAAmB,CAAC,EAAE,CAAC,CAAC;YACxB,UAAU,CAAC,KAAK,CAAC,CAAC;YAClB,OAAO;SACR;QAED,UAAU,CAAC,IAAI,CAAC,CAAC;QAGjB,MAAM,cAAc,GAAG,GAAG,EAAE;YAC1B,IAAI;gBAEF,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;oBACzB,OAAO,6BAA6B,OAAO,QAAQ,CAAC;iBACrD;gBAED,OAAO,OAAO;qBACX,KAAK,CAAC,QAAQ,CAAC;qBACf,MAAM,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