@universe-platform/ui 0.1.0-beta.14 → 0.1.0-beta.15
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/dist/index.js +20 -5
- package/dist/index.mjs +20 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5472,14 +5472,29 @@ function TableBlockClient({
|
|
|
5472
5472
|
}
|
|
5473
5473
|
const result = (res == null ? void 0 : res.data) || res;
|
|
5474
5474
|
if ((result == null ? void 0 : result.success) === false) {
|
|
5475
|
-
throw new Error(result.error || "
|
|
5475
|
+
throw new Error(result.error || "Failed to export data");
|
|
5476
5476
|
}
|
|
5477
|
+
const base64Data = result == null ? void 0 : result.base64Data;
|
|
5477
5478
|
const csvString = (result == null ? void 0 : result.csvString) || (result == null ? void 0 : result.csv);
|
|
5478
|
-
if (!csvString) {
|
|
5479
|
-
throw new Error("
|
|
5479
|
+
if (!base64Data && !csvString) {
|
|
5480
|
+
throw new Error("No export data received from server");
|
|
5481
|
+
}
|
|
5482
|
+
let blob;
|
|
5483
|
+
const defaultFileName = `${((schema == null ? void 0 : schema.title) || (schema == null ? void 0 : schema.name) || "table").trim()}_export.xlsx`;
|
|
5484
|
+
let fileName = (result == null ? void 0 : result.fileName) || defaultFileName;
|
|
5485
|
+
if (base64Data) {
|
|
5486
|
+
const byteCharacters = atob(base64Data);
|
|
5487
|
+
const byteNumbers = new Uint8Array(byteCharacters.length);
|
|
5488
|
+
for (let i = 0; i < byteCharacters.length; i++) {
|
|
5489
|
+
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
5490
|
+
}
|
|
5491
|
+
blob = new Blob([byteNumbers], {
|
|
5492
|
+
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
5493
|
+
});
|
|
5494
|
+
} else {
|
|
5495
|
+
fileName = fileName.replace(/\.xlsx$/i, ".csv");
|
|
5496
|
+
blob = new Blob([csvString], { type: "text/csv;charset=utf-8;" });
|
|
5480
5497
|
}
|
|
5481
|
-
const fileName = (result == null ? void 0 : result.fileName) || `${((schema == null ? void 0 : schema.title) || (schema == null ? void 0 : schema.name) || "table").trim()}_export.csv`;
|
|
5482
|
-
const blob = new Blob([csvString], { type: "text/csv;charset=utf-8;" });
|
|
5483
5498
|
const url = URL.createObjectURL(blob);
|
|
5484
5499
|
const link = document.createElement("a");
|
|
5485
5500
|
link.href = url;
|
package/dist/index.mjs
CHANGED
|
@@ -5405,14 +5405,29 @@ function TableBlockClient({
|
|
|
5405
5405
|
}
|
|
5406
5406
|
const result = (res == null ? void 0 : res.data) || res;
|
|
5407
5407
|
if ((result == null ? void 0 : result.success) === false) {
|
|
5408
|
-
throw new Error(result.error || "
|
|
5408
|
+
throw new Error(result.error || "Failed to export data");
|
|
5409
5409
|
}
|
|
5410
|
+
const base64Data = result == null ? void 0 : result.base64Data;
|
|
5410
5411
|
const csvString = (result == null ? void 0 : result.csvString) || (result == null ? void 0 : result.csv);
|
|
5411
|
-
if (!csvString) {
|
|
5412
|
-
throw new Error("
|
|
5412
|
+
if (!base64Data && !csvString) {
|
|
5413
|
+
throw new Error("No export data received from server");
|
|
5414
|
+
}
|
|
5415
|
+
let blob;
|
|
5416
|
+
const defaultFileName = `${((schema == null ? void 0 : schema.title) || (schema == null ? void 0 : schema.name) || "table").trim()}_export.xlsx`;
|
|
5417
|
+
let fileName = (result == null ? void 0 : result.fileName) || defaultFileName;
|
|
5418
|
+
if (base64Data) {
|
|
5419
|
+
const byteCharacters = atob(base64Data);
|
|
5420
|
+
const byteNumbers = new Uint8Array(byteCharacters.length);
|
|
5421
|
+
for (let i = 0; i < byteCharacters.length; i++) {
|
|
5422
|
+
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
5423
|
+
}
|
|
5424
|
+
blob = new Blob([byteNumbers], {
|
|
5425
|
+
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
5426
|
+
});
|
|
5427
|
+
} else {
|
|
5428
|
+
fileName = fileName.replace(/\.xlsx$/i, ".csv");
|
|
5429
|
+
blob = new Blob([csvString], { type: "text/csv;charset=utf-8;" });
|
|
5413
5430
|
}
|
|
5414
|
-
const fileName = (result == null ? void 0 : result.fileName) || `${((schema == null ? void 0 : schema.title) || (schema == null ? void 0 : schema.name) || "table").trim()}_export.csv`;
|
|
5415
|
-
const blob = new Blob([csvString], { type: "text/csv;charset=utf-8;" });
|
|
5416
5431
|
const url = URL.createObjectURL(blob);
|
|
5417
5432
|
const link = document.createElement("a");
|
|
5418
5433
|
link.href = url;
|