@memori.ai/memori-react 8.41.2 → 8.41.3
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 +14 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +8 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +2 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js +14 -5
- package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.js +16 -11
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js +79 -52
- package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +9 -2
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js +2 -2
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +2 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js +13 -4
- package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.js +16 -11
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js +79 -52
- package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/package.json +1 -1
- package/src/components/Avatar/Avatar.test.tsx +27 -0
- package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.tsx +12 -5
- package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.ts +2 -1
- package/src/components/Avatar/AvatarView/AvatarComponent/constants.ts +16 -4
- package/src/components/Avatar/__snapshots__/Avatar.test.tsx.snap +63 -0
- package/src/components/ChatBubble/ChatBubble.tsx +28 -3
- package/src/components/UploadButton/UploadDocuments/UploadDocuments.tsx +103 -55
- package/src/components/layouts/layouts.stories.tsx +6 -13
- package/src/version.ts +1 -1
|
@@ -167,64 +167,101 @@ const UploadDocuments: React.FC<UploadDocumentsProps> = ({
|
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
169
|
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
170
|
+
const loadXLSXLibrary = async (): Promise<void> => {
|
|
171
|
+
if (window.XLSX) return;
|
|
172
|
+
|
|
173
|
+
await new Promise((resolve, reject) => {
|
|
174
|
+
const script = document.createElement('script');
|
|
175
|
+
script.src = XLSX_URL;
|
|
176
|
+
script.onload = resolve;
|
|
177
|
+
script.onerror = reject;
|
|
178
|
+
document.head.appendChild(script);
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
182
|
+
const readXLSXWorkbook = async (file: File) => {
|
|
183
|
+
await loadXLSXLibrary();
|
|
184
|
+
|
|
185
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
186
|
+
return window.XLSX.read(arrayBuffer, {
|
|
187
|
+
type: 'array',
|
|
188
|
+
cellFormula: true,
|
|
189
|
+
cellNF: true,
|
|
190
|
+
cellText: true,
|
|
191
|
+
cellDates: true,
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const formatXLSXWorkbookForDisplay = (workbook: {
|
|
196
|
+
SheetNames: string[];
|
|
197
|
+
Sheets: Record<string, unknown>;
|
|
198
|
+
}): string => {
|
|
199
|
+
let text = '';
|
|
200
|
+
|
|
201
|
+
for (const sheetName of workbook.SheetNames) {
|
|
202
|
+
const worksheet = workbook.Sheets[sheetName];
|
|
203
|
+
const data = window.XLSX.utils.sheet_to_json(worksheet, {
|
|
204
|
+
header: 1,
|
|
205
|
+
raw: false,
|
|
189
206
|
});
|
|
190
207
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
header: 1,
|
|
196
|
-
raw: false,
|
|
208
|
+
const colWidths = data.reduce((widths: number[], row: any[]) => {
|
|
209
|
+
row.forEach((cell, i) => {
|
|
210
|
+
const cellWidth = (cell || '').toString().length;
|
|
211
|
+
widths[i] = Math.max(widths[i] || 0, cellWidth);
|
|
197
212
|
});
|
|
213
|
+
return widths;
|
|
214
|
+
}, []);
|
|
215
|
+
|
|
216
|
+
const formattedText = data.map((row: any[]) => {
|
|
217
|
+
return row
|
|
218
|
+
.map((cell, i) => {
|
|
219
|
+
const cellStr = (cell || '').toString();
|
|
220
|
+
return cellStr.padEnd(colWidths[i] + 2);
|
|
221
|
+
})
|
|
222
|
+
.join('|')
|
|
223
|
+
.trim();
|
|
224
|
+
});
|
|
198
225
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}, []);
|
|
206
|
-
|
|
207
|
-
const formattedText = data.map((row: any[]) => {
|
|
208
|
-
return row
|
|
209
|
-
.map((cell, i) => {
|
|
210
|
-
const cellStr = (cell || '').toString();
|
|
211
|
-
return cellStr.padEnd(colWidths[i] + 2);
|
|
212
|
-
})
|
|
213
|
-
.join('|')
|
|
214
|
-
.trim();
|
|
215
|
-
});
|
|
226
|
+
if (formattedText.length > 0) {
|
|
227
|
+
const separator = colWidths
|
|
228
|
+
.map((w: number) => '-'.repeat(w + 2))
|
|
229
|
+
.join('+');
|
|
230
|
+
formattedText.splice(1, 0, separator);
|
|
231
|
+
}
|
|
216
232
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
233
|
+
text += `Sheet: ${sheetName}\n${formattedText.join('\n')}\n\n`;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return text;
|
|
237
|
+
};
|
|
223
238
|
|
|
224
|
-
|
|
239
|
+
const formatXLSXWorkbookAsCsv = (workbook: {
|
|
240
|
+
SheetNames: string[];
|
|
241
|
+
Sheets: Record<string, unknown>;
|
|
242
|
+
}): string => {
|
|
243
|
+
let text = '';
|
|
244
|
+
|
|
245
|
+
for (const sheetName of workbook.SheetNames) {
|
|
246
|
+
const worksheet = workbook.Sheets[sheetName];
|
|
247
|
+
const csv = window.XLSX.utils.sheet_to_csv(worksheet, { raw: false });
|
|
248
|
+
if (csv.trim()) {
|
|
249
|
+
text += `Sheet: ${sheetName}\n${csv}\n\n`;
|
|
225
250
|
}
|
|
251
|
+
}
|
|
226
252
|
|
|
227
|
-
|
|
253
|
+
return text;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const extractTextFromXLSX = async (
|
|
257
|
+
file: File
|
|
258
|
+
): Promise<{ display: string; asset: string }> => {
|
|
259
|
+
try {
|
|
260
|
+
const workbook = await readXLSXWorkbook(file);
|
|
261
|
+
return {
|
|
262
|
+
display: formatXLSXWorkbookForDisplay(workbook),
|
|
263
|
+
asset: formatXLSXWorkbookAsCsv(workbook),
|
|
264
|
+
};
|
|
228
265
|
} catch (error) {
|
|
229
266
|
console.error('XLSX extraction failed:', error);
|
|
230
267
|
throw new Error(
|
|
@@ -237,7 +274,11 @@ const UploadDocuments: React.FC<UploadDocumentsProps> = ({
|
|
|
237
274
|
|
|
238
275
|
const processDocumentFile = async (
|
|
239
276
|
file: File
|
|
240
|
-
): Promise<{
|
|
277
|
+
): Promise<{
|
|
278
|
+
text: string | null;
|
|
279
|
+
textForAsset?: string;
|
|
280
|
+
uploadAsOriginal?: boolean;
|
|
281
|
+
}> => {
|
|
241
282
|
if (isOfficeNativeFilename(file.name)) {
|
|
242
283
|
return { text: null, uploadAsOriginal: true };
|
|
243
284
|
}
|
|
@@ -245,16 +286,19 @@ const UploadDocuments: React.FC<UploadDocumentsProps> = ({
|
|
|
245
286
|
const ext = file.name.split('.').pop()?.toLowerCase() || '';
|
|
246
287
|
try {
|
|
247
288
|
let text: string | null = null;
|
|
289
|
+
let textForAsset: string | undefined;
|
|
248
290
|
|
|
249
291
|
if (ext === 'pdf') {
|
|
250
292
|
text = await extractTextFromPDF(file);
|
|
251
293
|
} else if (['txt', 'md', 'json', 'csv', 'html'].includes(ext)) {
|
|
252
294
|
text = await file.text();
|
|
253
295
|
} else if (ext === 'xlsx') {
|
|
254
|
-
|
|
296
|
+
const extracted = await extractTextFromXLSX(file);
|
|
297
|
+
text = extracted.display;
|
|
298
|
+
textForAsset = extracted.asset;
|
|
255
299
|
}
|
|
256
300
|
|
|
257
|
-
return { text };
|
|
301
|
+
return { text, textForAsset };
|
|
258
302
|
} catch (error) {
|
|
259
303
|
console.error('Document processing failed:', error);
|
|
260
304
|
throw new Error(
|
|
@@ -370,7 +414,8 @@ const UploadDocuments: React.FC<UploadDocumentsProps> = ({
|
|
|
370
414
|
const fileId = Math.random().toString(36).substr(2, 9);
|
|
371
415
|
|
|
372
416
|
try {
|
|
373
|
-
const { text, uploadAsOriginal } =
|
|
417
|
+
const { text, textForAsset, uploadAsOriginal } =
|
|
418
|
+
await processDocumentFile(file);
|
|
374
419
|
|
|
375
420
|
if (uploadAsOriginal) {
|
|
376
421
|
// Office native format: upload the original file as asset, no text extraction
|
|
@@ -403,7 +448,8 @@ const UploadDocuments: React.FC<UploadDocumentsProps> = ({
|
|
|
403
448
|
});
|
|
404
449
|
} else if (text) {
|
|
405
450
|
const baseName = file.name.replace(/\.[^/.]+$/, '') || file.name;
|
|
406
|
-
const
|
|
451
|
+
const assetText = textForAsset ?? text;
|
|
452
|
+
const textFile = new File([assetText], `${baseName}.txt`, {
|
|
407
453
|
type: 'text/plain',
|
|
408
454
|
});
|
|
409
455
|
|
|
@@ -468,7 +514,9 @@ const UploadDocuments: React.FC<UploadDocumentsProps> = ({
|
|
|
468
514
|
<input
|
|
469
515
|
ref={documentInputRef}
|
|
470
516
|
type="file"
|
|
471
|
-
accept={`.pdf,.txt,.md,.json,.xlsx,.csv,.html,${officeNativeExtensions.join(
|
|
517
|
+
accept={`.pdf,.txt,.md,.json,.xlsx,.csv,.html,${officeNativeExtensions.join(
|
|
518
|
+
','
|
|
519
|
+
)}`}
|
|
472
520
|
multiple
|
|
473
521
|
className="memori--upload-file-input"
|
|
474
522
|
onChange={handleDocumentUpload}
|
|
@@ -32,25 +32,18 @@ const Template: Story<Props> = args => (
|
|
|
32
32
|
|
|
33
33
|
const DefaultLayout = Template.bind({});
|
|
34
34
|
DefaultLayout.args = {
|
|
35
|
-
memoriName: '
|
|
36
|
-
ownerUserName: '
|
|
37
|
-
memoriID: '
|
|
35
|
+
memoriName: 'prova-sharepoint',
|
|
36
|
+
ownerUserName: 'Andrea-Patini',
|
|
37
|
+
memoriID: '019f129c-a5a3-74d3-b0c8-b7794437bb23',
|
|
38
38
|
ownerUserID: '91dbc9ba-b684-4fbe-9828-b5980af6cda9',
|
|
39
39
|
tenantID: 'aisuru-staging.aclambda.online',
|
|
40
40
|
engineURL: 'https://engine-staging.memori.ai/memori/v2',
|
|
41
41
|
apiURL: 'https://backend-staging.memori.ai/api/v2',
|
|
42
|
-
|
|
42
|
+
baseURL: 'https://aisuru-staging.aclambda.online',
|
|
43
|
+
layout: 'TOTEM',
|
|
43
44
|
uiLang: 'IT',
|
|
44
45
|
spokenLang: 'IT',
|
|
45
|
-
integrationID: '
|
|
46
|
-
autoStart: true,
|
|
47
|
-
sessionID: '' as string | undefined,
|
|
48
|
-
showUpload: true,
|
|
49
|
-
showReasoning: false,
|
|
50
|
-
showLogin: true,
|
|
51
|
-
multilingual: true,
|
|
52
|
-
avatar3dHidden: true,
|
|
53
|
-
showMessageConsumption: true,
|
|
46
|
+
integrationID: '019f1896-730d-7e19-9a88-6413f485247b',
|
|
54
47
|
};
|
|
55
48
|
|
|
56
49
|
export const Default = Template.bind({});
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is auto-generated. Do not edit manually.
|
|
2
|
-
export const version = '8.41.
|
|
2
|
+
export const version = '8.41.3';
|