mapa-library-ui 2.13.2 → 2.14.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/docs/GUIDE_V5_COMPONENTS.md +76 -0
- package/docs/TABLE_EXPORT.md +55 -2
- package/fesm2022/mapa-library-ui-src-lib-components-capability.mjs +67 -0
- package/fesm2022/mapa-library-ui-src-lib-components-capability.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-chart.mjs +67 -0
- package/fesm2022/mapa-library-ui-src-lib-components-chart.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-datepicker.mjs +67 -1
- package/fesm2022/mapa-library-ui-src-lib-components-datepicker.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-dropdown-tree.mjs +67 -0
- package/fesm2022/mapa-library-ui-src-lib-components-dropdown-tree.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-dropdown.mjs +67 -0
- package/fesm2022/mapa-library-ui-src-lib-components-dropdown.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-filters.mjs +67 -0
- package/fesm2022/mapa-library-ui-src-lib-components-filters.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-form.mjs +67 -1
- package/fesm2022/mapa-library-ui-src-lib-components-form.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-group-report.mjs +67 -1
- package/fesm2022/mapa-library-ui-src-lib-components-group-report.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-input.mjs +67 -0
- package/fesm2022/mapa-library-ui-src-lib-components-input.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-scale-parameterization.mjs +67 -0
- package/fesm2022/mapa-library-ui-src-lib-components-scale-parameterization.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-scale.mjs +67 -0
- package/fesm2022/mapa-library-ui-src-lib-components-scale.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-table.mjs +67 -1
- package/fesm2022/mapa-library-ui-src-lib-components-table.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-textarea.mjs +67 -0
- package/fesm2022/mapa-library-ui-src-lib-components-textarea.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-warning.mjs +67 -0
- package/fesm2022/mapa-library-ui-src-lib-components-warning.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-core-excel-export.mjs +73 -41
- package/fesm2022/mapa-library-ui-src-lib-core-excel-export.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-core-export.mjs +92 -26
- package/fesm2022/mapa-library-ui-src-lib-core-export.mjs.map +1 -1
- package/fesm2022/mapa-library-ui.mjs +956 -4
- package/fesm2022/mapa-library-ui.mjs.map +1 -1
- package/index.d.ts +842 -475
- package/mapa-library-ui-2.14.0.tgz +0 -0
- package/package.json +38 -2
- package/src/lib/components/capability/index.d.ts +61 -8
- package/src/lib/components/filters/index.d.ts +61 -8
- package/src/lib/components/scale/index.d.ts +61 -8
- package/src/lib/components/scale-parameterization/index.d.ts +61 -8
- package/src/lib/components/table/index.d.ts +59 -6
- package/src/lib/components/warning/index.d.ts +59 -6
- package/src/lib/core/excel-export/index.d.ts +23 -2
- package/src/lib/core/export/index.d.ts +166 -0
- package/worker/excel-export.runtime.d.ts +2 -2
- package/worker/excel-export.runtime.js +17 -17
- package/worker/excel-export.worker.js +19 -19
- package/mapa-library-ui-2.13.2.tgz +0 -0
|
@@ -8,6 +8,18 @@ class ExcelExportCancelledError extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
function formatExportText(template, values) {
|
|
12
|
+
return template.replace(/\{(\w+)\}/g, (placeholder, key) => values[key] === undefined ? placeholder : String(values[key]));
|
|
13
|
+
}
|
|
14
|
+
/** Stable codes survive worker transport; default messages preserve the low-level API. */
|
|
15
|
+
class ExcelExportError extends Error {
|
|
16
|
+
constructor(exportCode, message) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.exportCode = exportCode;
|
|
19
|
+
this.name = 'ExcelExportError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
11
23
|
/** Excel format codes; values must already be typed numbers, strings or dates. */
|
|
12
24
|
const EXCEL_FORMATS = {
|
|
13
25
|
text: '@',
|
|
@@ -21,7 +33,7 @@ const EXCEL_FORMATS = {
|
|
|
21
33
|
};
|
|
22
34
|
function fraction(decimals) {
|
|
23
35
|
if (!Number.isInteger(decimals) || decimals < 0 || decimals > 15)
|
|
24
|
-
throw new
|
|
36
|
+
throw new ExcelExportError('errorDecimals', 'Informe de 0 a 15 casas decimais.');
|
|
25
37
|
return decimals ? `.${'0'.repeat(decimals)}` : '';
|
|
26
38
|
}
|
|
27
39
|
function excelNumberFormat(decimals = 2, useGrouping = true) {
|
|
@@ -169,6 +181,10 @@ function hexArgb(color) {
|
|
|
169
181
|
/** Finalize a branded table after widths and data have been assigned. */
|
|
170
182
|
function finishMapaExcelTable(sheet, request) {
|
|
171
183
|
const columns = request.columns;
|
|
184
|
+
const locale = request.localization?.locale ?? 'pt-BR';
|
|
185
|
+
const recordLabel = request.rows.length === 1
|
|
186
|
+
? (request.localization?.record ?? 'registro')
|
|
187
|
+
: (request.localization?.records ?? 'registros');
|
|
172
188
|
const count = Math.max(2, columns.length);
|
|
173
189
|
const end = request.rows.length + 9;
|
|
174
190
|
const range = (index) => `${sheet.getColumn(index + 1).letter}10:${sheet.getColumn(index + 1).letter}${Math.max(10, end)}`;
|
|
@@ -179,10 +195,10 @@ function finishMapaExcelTable(sheet, request) {
|
|
|
179
195
|
};
|
|
180
196
|
sheet.pageSetup.printTitlesRow = '9:9';
|
|
181
197
|
const summaryFormula = [
|
|
182
|
-
request.rows.length ? `ROWS(A10:A${end})
|
|
198
|
+
`${request.rows.length ? `ROWS(A10:A${end})` : '0'}&${quote(` ${recordLabel}`)}`,
|
|
183
199
|
];
|
|
184
200
|
const summaryResult = [
|
|
185
|
-
`${request.rows.length.toLocaleString(
|
|
201
|
+
`${request.rows.length.toLocaleString(locale)} ${recordLabel}`,
|
|
186
202
|
];
|
|
187
203
|
for (const indicator of (request.indicators ?? []).slice(0, 2)) {
|
|
188
204
|
const index = columns.findIndex((column) => column.key === indicator.key);
|
|
@@ -201,7 +217,7 @@ function finishMapaExcelTable(sheet, request) {
|
|
|
201
217
|
// Sign criteria cover financial additions and usage without evaluating arbitrary expressions.
|
|
202
218
|
const sign = String(indicator.criteria);
|
|
203
219
|
if (!['>0', '<0'].includes(sign))
|
|
204
|
-
throw new
|
|
220
|
+
throw new ExcelExportError('errorCriteria', 'Critério de soma inválido. Use >0 ou <0.');
|
|
205
221
|
formula = `SUMIF(${range(index)},${quote(sign)})`;
|
|
206
222
|
result = data.reduce((sum, value) => sum +
|
|
207
223
|
(typeof value === 'number' &&
|
|
@@ -220,7 +236,7 @@ function finishMapaExcelTable(sheet, request) {
|
|
|
220
236
|
}
|
|
221
237
|
const format = indicator.numFmt ?? '#,##0';
|
|
222
238
|
const digits = format.match(/\.(0+)/)?.[1].length ?? 0;
|
|
223
|
-
const formatted = new Intl.NumberFormat(
|
|
239
|
+
const formatted = new Intl.NumberFormat(locale, {
|
|
224
240
|
minimumFractionDigits: digits,
|
|
225
241
|
maximumFractionDigits: digits,
|
|
226
242
|
...(format.includes('R$')
|
|
@@ -253,7 +269,7 @@ function finishMapaExcelTable(sheet, request) {
|
|
|
253
269
|
};
|
|
254
270
|
if (request.context) {
|
|
255
271
|
const context = request.context;
|
|
256
|
-
const date = context.generatedAt.toLocaleString(
|
|
272
|
+
const date = context.generatedAt.toLocaleString(locale);
|
|
257
273
|
for (const row of [6, 7]) {
|
|
258
274
|
sheet.mergeCells(row, 1, row, count);
|
|
259
275
|
sheet.getRow(row).height = 24;
|
|
@@ -276,10 +292,18 @@ function finishMapaExcelTable(sheet, request) {
|
|
|
276
292
|
};
|
|
277
293
|
}
|
|
278
294
|
}
|
|
279
|
-
sheet.getCell(6, 1).value =
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
295
|
+
sheet.getCell(6, 1).value = formatExportText(request.localization?.sheetContext ??
|
|
296
|
+
'{module} · {company} · Exportado em {date} por {user}', {
|
|
297
|
+
module: context.module,
|
|
298
|
+
company: context.company,
|
|
299
|
+
user: context.user,
|
|
300
|
+
date,
|
|
301
|
+
});
|
|
302
|
+
sheet.getCell(7, 1).value = formatExportText(request.localization?.sheetFilters ?? 'Filtros aplicados: {filters}', {
|
|
303
|
+
filters: context.filters.length
|
|
304
|
+
? context.filters.join(' · ')
|
|
305
|
+
: (request.localization?.sheetNoFilters ?? 'nenhum'),
|
|
306
|
+
});
|
|
283
307
|
sheet.getRow(8).height = 6;
|
|
284
308
|
}
|
|
285
309
|
columns.forEach((column, index) => {
|
|
@@ -326,7 +350,8 @@ function finishMapaExcelTable(sheet, request) {
|
|
|
326
350
|
const row = sheet.getRow(end + 1);
|
|
327
351
|
const labelIndex = columns.findIndex((column) => !column.total);
|
|
328
352
|
if (labelIndex >= 0)
|
|
329
|
-
row.getCell(labelIndex + 1).value =
|
|
353
|
+
row.getCell(labelIndex + 1).value =
|
|
354
|
+
request.localization?.sheetTotal ?? 'TOTAL';
|
|
330
355
|
columns.forEach((column, index) => {
|
|
331
356
|
const cell = row.getCell(index + 1);
|
|
332
357
|
if (column.total)
|
|
@@ -351,7 +376,8 @@ function finishMapaExcelTable(sheet, request) {
|
|
|
351
376
|
sheet.mergeCells(footerRow, 1, footerRow, count);
|
|
352
377
|
const footer = sheet.getCell(footerRow, 1);
|
|
353
378
|
footer.value =
|
|
354
|
-
|
|
379
|
+
request.localization?.sheetFooter ??
|
|
380
|
+
'Documento gerado automaticamente pela plataforma Mapa HDS. Os dados respeitam as permissões de quem exportou.';
|
|
355
381
|
footer.font = {
|
|
356
382
|
name: 'Arial',
|
|
357
383
|
size: 8,
|
|
@@ -367,7 +393,7 @@ function finishMapaExcelTable(sheet, request) {
|
|
|
367
393
|
function argb(color) {
|
|
368
394
|
const match = /^#([\da-f]{3}|[\da-f]{6})$/i.exec(color.trim());
|
|
369
395
|
if (!match)
|
|
370
|
-
throw new
|
|
396
|
+
throw new ExcelExportError('errorColor', 'Cor de exportação inválida. Use HEX #RGB ou #RRGGBB.');
|
|
371
397
|
return `FF${(match[1].length === 3 ? [...match[1]].map((c) => c + c).join('') : match[1]).toUpperCase()}`;
|
|
372
398
|
}
|
|
373
399
|
function validateExcelCellStyle(style) {
|
|
@@ -397,7 +423,7 @@ function validateExcelCellStyle(style) {
|
|
|
397
423
|
(alignment?.vertical !== undefined &&
|
|
398
424
|
!['top', 'middle', 'bottom', 'distributed', 'justify'].includes(alignment.vertical));
|
|
399
425
|
if (invalid)
|
|
400
|
-
throw new
|
|
426
|
+
throw new ExcelExportError('errorStyle', 'Estilo de exportação inválido. Confira fonte e alinhamento.');
|
|
401
427
|
for (const color of [font?.color, style.backgroundColor])
|
|
402
428
|
if (color !== undefined)
|
|
403
429
|
argb(color);
|
|
@@ -417,7 +443,7 @@ function validateExcelCellStyle(style) {
|
|
|
417
443
|
'mediumDashDotDot',
|
|
418
444
|
'slantDashDot',
|
|
419
445
|
].includes(line.style))
|
|
420
|
-
throw new
|
|
446
|
+
throw new ExcelExportError('errorBorder', 'Borda de exportação inválida.');
|
|
421
447
|
if (line.color !== undefined)
|
|
422
448
|
argb(line.color);
|
|
423
449
|
}
|
|
@@ -466,13 +492,13 @@ function validateExcelAutoWidth(options) {
|
|
|
466
492
|
options.padding > 255)) ||
|
|
467
493
|
(options.mode !== undefined &&
|
|
468
494
|
!['header', 'content', 'both'].includes(options.mode)))
|
|
469
|
-
throw new
|
|
495
|
+
throw new ExcelExportError('errorAutoWidth', 'Configuração de largura automática inválida.');
|
|
470
496
|
}
|
|
471
497
|
|
|
472
498
|
function resolveWorkbookConstructor(module) {
|
|
473
499
|
const constructor = module.default?.Workbook ?? module.Workbook;
|
|
474
500
|
if (typeof constructor !== 'function')
|
|
475
|
-
throw new
|
|
501
|
+
throw new ExcelExportError('errorEngine', 'Não foi possível carregar a biblioteca de exportação Excel.');
|
|
476
502
|
return constructor;
|
|
477
503
|
}
|
|
478
504
|
async function createExcelWorkbook() {
|
|
@@ -492,7 +518,7 @@ function cellValue(value) {
|
|
|
492
518
|
return null;
|
|
493
519
|
if (value instanceof Date) {
|
|
494
520
|
if (!Number.isFinite(value.getTime()))
|
|
495
|
-
throw new
|
|
521
|
+
throw new ExcelExportError('errorDate', 'Data inválida na exportação.');
|
|
496
522
|
return value;
|
|
497
523
|
}
|
|
498
524
|
if (typeof value === 'number')
|
|
@@ -501,9 +527,9 @@ function cellValue(value) {
|
|
|
501
527
|
return { formula: value.formula, result: cellValue(value.result) };
|
|
502
528
|
}
|
|
503
529
|
if (typeof value === 'string' && value.length > 32767)
|
|
504
|
-
throw new
|
|
530
|
+
throw new ExcelExportError('errorCellLength', 'Uma célula excede o limite de 32.767 caracteres do Excel.');
|
|
505
531
|
if (!['string', 'number', 'boolean'].includes(typeof value))
|
|
506
|
-
throw new
|
|
532
|
+
throw new ExcelExportError('errorCellValue', 'Valor de célula inválido. Use um extrator de coluna para formatá-lo.');
|
|
507
533
|
return value;
|
|
508
534
|
}
|
|
509
535
|
/** Adds a table to an existing workbook; no domain or HTTP dependencies. */
|
|
@@ -511,33 +537,33 @@ async function addExcelTable(book, request, options = {}) {
|
|
|
511
537
|
const isCancelled = options.isCancelled ?? (() => false);
|
|
512
538
|
checkCancelled(isCancelled);
|
|
513
539
|
if (!request.columns.length)
|
|
514
|
-
throw new
|
|
540
|
+
throw new ExcelExportError('errorColumns', 'Informe pelo menos uma coluna.');
|
|
515
541
|
if (request.columns.length > 16384)
|
|
516
|
-
throw new
|
|
542
|
+
throw new ExcelExportError('errorColumnLimit', 'Quantidade de colunas excede o limite do Excel.');
|
|
517
543
|
const branded = request.mode !== 'plain';
|
|
518
544
|
if ((request.metadata?.length ?? 0) > 3)
|
|
519
|
-
throw new
|
|
545
|
+
throw new ExcelExportError('errorMetadata', 'Informe no máximo três linhas de metadados.');
|
|
520
546
|
const headerRow = branded ? 9 : 1;
|
|
521
547
|
validateExcelCellStyle(request.style);
|
|
522
548
|
validateExcelCellStyle(request.headerStyle);
|
|
523
549
|
for (const height of [request.rowHeight, request.headerHeight]) {
|
|
524
550
|
if (height !== undefined &&
|
|
525
551
|
(!Number.isFinite(height) || height <= 0 || height > 409))
|
|
526
|
-
throw new
|
|
552
|
+
throw new ExcelExportError('errorHeight', 'Altura de linha inválida. Use até 409 pontos.');
|
|
527
553
|
}
|
|
528
554
|
if (request.rows.length + headerRow > 1048576)
|
|
529
|
-
throw new
|
|
555
|
+
throw new ExcelExportError('errorRowLimit', 'Quantidade de linhas excede o limite do Excel.');
|
|
530
556
|
request.columns.forEach((column) => {
|
|
531
557
|
validateExcelAutoWidth({ ...request.autoWidth, ...column.autoWidth });
|
|
532
558
|
validateExcelCellStyle(column.style);
|
|
533
559
|
validateExcelCellStyle(column.headerStyle);
|
|
534
560
|
if (!column.value && !column.key)
|
|
535
|
-
throw new
|
|
561
|
+
throw new ExcelExportError('errorColumnKey', 'A coluna deve ter uma chave ou um extrator.');
|
|
536
562
|
if (column.width !== undefined &&
|
|
537
563
|
(!Number.isFinite(column.width) ||
|
|
538
564
|
column.width <= 0 ||
|
|
539
565
|
column.width > 255))
|
|
540
|
-
throw new
|
|
566
|
+
throw new ExcelExportError('errorWidth', 'Largura de coluna inválida.');
|
|
541
567
|
});
|
|
542
568
|
const sheet = book.addWorksheet(request.sheetName, branded
|
|
543
569
|
? {
|
|
@@ -669,7 +695,7 @@ async function addExcelTable(book, request, options = {}) {
|
|
|
669
695
|
async function buildExcelWorkbook(request, isCancelled = () => false, onProgress) {
|
|
670
696
|
checkCancelled(isCancelled);
|
|
671
697
|
if (!request.sheets.length)
|
|
672
|
-
throw new
|
|
698
|
+
throw new ExcelExportError('errorSheets', 'Informe pelo menos uma aba.');
|
|
673
699
|
const book = await createExcelWorkbook();
|
|
674
700
|
checkCancelled(isCancelled);
|
|
675
701
|
book.creator = request.creator ?? 'Mapa HDS';
|
|
@@ -683,6 +709,7 @@ async function buildExcelWorkbook(request, isCancelled = () => false, onProgress
|
|
|
683
709
|
for (const [index, sheet] of request.sheets.entries()) {
|
|
684
710
|
await addExcelTable(book, {
|
|
685
711
|
...sheet,
|
|
712
|
+
localization: sheet.localization ?? request.localization,
|
|
686
713
|
sheetName: names[index],
|
|
687
714
|
title: sheet.title ?? sheet.sheetName,
|
|
688
715
|
}, { logoId, isCancelled, onProgress: (progress) => onProgress?.({ ...progress, completed: completed + (progress.completed ?? 0), total }) });
|
|
@@ -708,7 +735,7 @@ const EXPORT_FILE_ROW_LIMIT = 100_000;
|
|
|
708
735
|
/** Encode browser-local calendar fields for timezone-free Excel and CSV cells. */
|
|
709
736
|
function toExportDate(value) {
|
|
710
737
|
if (!Number.isFinite(value.getTime()))
|
|
711
|
-
throw new
|
|
738
|
+
throw new ExcelExportError('errorDate', 'Data inválida na exportação.');
|
|
712
739
|
return new Date(value.getTime() - value.getTimezoneOffset() * 60_000);
|
|
713
740
|
}
|
|
714
741
|
const exportSlug = (value) => value
|
|
@@ -724,7 +751,7 @@ function exportFileBase(listing, company, date) {
|
|
|
724
751
|
/** Greedy packing preserves dataset order and counts records across all sheets. */
|
|
725
752
|
function splitExportSheets(sheets, limit = EXPORT_FILE_ROW_LIMIT) {
|
|
726
753
|
if (!Number.isInteger(limit) || limit < 1)
|
|
727
|
-
throw new
|
|
754
|
+
throw new ExcelExportError('errorRowCount', 'Limite de registros inválido.');
|
|
728
755
|
const parts = [[]];
|
|
729
756
|
let used = 0;
|
|
730
757
|
for (const sheet of sheets) {
|
|
@@ -754,13 +781,13 @@ function encodeExportCsv(sheet, onProgress) {
|
|
|
754
781
|
? input.result
|
|
755
782
|
: input;
|
|
756
783
|
if (value instanceof Date && !Number.isFinite(value.getTime()))
|
|
757
|
-
throw new
|
|
784
|
+
throw new ExcelExportError('errorDate', 'Data inválida na exportação.');
|
|
758
785
|
if (typeof value === 'number' && !Number.isFinite(value))
|
|
759
786
|
return '';
|
|
760
787
|
const text = value == null
|
|
761
788
|
? ''
|
|
762
789
|
: value instanceof Date
|
|
763
|
-
? value.toLocaleString('pt-BR', { timeZone: 'UTC' })
|
|
790
|
+
? value.toLocaleString(sheet.localization?.locale ?? 'pt-BR', { timeZone: 'UTC' })
|
|
764
791
|
: String(value);
|
|
765
792
|
// Quoting alone does not stop spreadsheet apps interpreting user text as a formula.
|
|
766
793
|
const literal = typeof value === 'string' && /^[=+\-@\t\r]/.test(text)
|
|
@@ -799,12 +826,12 @@ async function collectExportPages(options) {
|
|
|
799
826
|
(expected !== undefined && expected !== page.totalCount) ||
|
|
800
827
|
(page.pageIndex !== undefined && page.pageIndex !== pageIndex) ||
|
|
801
828
|
(pageIndex > 1 && page.pageSize !== pageSize))
|
|
802
|
-
throw new
|
|
829
|
+
throw new ExcelExportError('errorDataChanged', 'Os dados mudaram durante a exportação. Atualize a listagem e tente novamente.');
|
|
803
830
|
expected = page.totalCount;
|
|
804
831
|
for (const row of page.data) {
|
|
805
832
|
const key = options.key(row);
|
|
806
833
|
if (!key || keys.has(key))
|
|
807
|
-
throw new
|
|
834
|
+
throw new ExcelExportError('errorDuplicate', 'Registros duplicados ou sem identificação na exportação.');
|
|
808
835
|
keys.add(key);
|
|
809
836
|
result.push(row);
|
|
810
837
|
}
|
|
@@ -816,7 +843,7 @@ async function collectExportPages(options) {
|
|
|
816
843
|
!Number.isInteger(page.pageSize) ||
|
|
817
844
|
page.pageSize < 1 ||
|
|
818
845
|
page.data.length !== page.pageSize)
|
|
819
|
-
throw new
|
|
846
|
+
throw new ExcelExportError('errorIncomplete', 'A API retornou uma exportação incompleta.');
|
|
820
847
|
pageSize = page.pageSize;
|
|
821
848
|
pageIndex++;
|
|
822
849
|
}
|
|
@@ -863,7 +890,10 @@ class MapaExcelExportService {
|
|
|
863
890
|
async generateCsv(request, options) {
|
|
864
891
|
if (options.workerFactory)
|
|
865
892
|
return this.serializeInWorker(request, options.workerFactory, options.isCancelled ?? (() => false), options.onProgress, 'csv');
|
|
866
|
-
return encodeExportCsv(
|
|
893
|
+
return encodeExportCsv({
|
|
894
|
+
...request.sheets[0],
|
|
895
|
+
localization: request.sheets[0].localization ?? request.localization,
|
|
896
|
+
});
|
|
867
897
|
}
|
|
868
898
|
async save(book, fileName, isCancelled = () => false) {
|
|
869
899
|
if (isCancelled())
|
|
@@ -909,14 +939,16 @@ class MapaExcelExportService {
|
|
|
909
939
|
return;
|
|
910
940
|
}
|
|
911
941
|
if ('error' in data)
|
|
912
|
-
finish(
|
|
942
|
+
finish(data.exportCode
|
|
943
|
+
? new ExcelExportError(data.exportCode, data.error)
|
|
944
|
+
: new Error(data.error));
|
|
913
945
|
else if (data.buffer instanceof ArrayBuffer)
|
|
914
946
|
finish(undefined, data.buffer);
|
|
915
947
|
else
|
|
916
|
-
finish(new
|
|
948
|
+
finish(new ExcelExportError('errorWorkerResponse', 'Resposta inválida do worker de exportação.'));
|
|
917
949
|
};
|
|
918
|
-
worker.onerror = (event) => finish(new
|
|
919
|
-
worker.onmessageerror = () => finish(new
|
|
950
|
+
worker.onerror = (event) => finish(new ExcelExportError('errorWorkerFailure', event.message || 'Falha no worker de exportação.'));
|
|
951
|
+
worker.onmessageerror = () => finish(new ExcelExportError('errorWorkerReceive', 'Não foi possível receber o arquivo exportado.'));
|
|
920
952
|
try {
|
|
921
953
|
worker.postMessage({ request, format });
|
|
922
954
|
}
|
|
@@ -981,5 +1013,5 @@ function getExcelWorkerConstructor() {
|
|
|
981
1013
|
* Generated bundle index. Do not edit.
|
|
982
1014
|
*/
|
|
983
1015
|
|
|
984
|
-
export { EXCEL_FORMATS, ExcelExportCancelledError, MAPA_EXCEL_COLORS, MAPA_EXCEL_STATUS_COLORS, MapaExcelExportService, addExcelTable, addMapaExcelLogo, applyMapaExcelBanner, buildExcelWorkbook, createExcelWorkbook, excelCurrencyFormat, excelFileName, excelFileNameWithDate, excelNumberFormat, excelPercentFormat, excelSheetName, fillExcelCell, fitExcelSheetTitle, getExcelWorkerConstructor, resolveWorkbookConstructor, serializeExcelRequest, serializeExcelWorkbook, styleMapaExcelHeaderCell, uniqueExcelSheetNames };
|
|
1016
|
+
export { EXCEL_FORMATS, ExcelExportCancelledError, ExcelExportError, MAPA_EXCEL_COLORS, MAPA_EXCEL_STATUS_COLORS, MapaExcelExportService, addExcelTable, addMapaExcelLogo, applyMapaExcelBanner, buildExcelWorkbook, createExcelWorkbook, excelCurrencyFormat, excelFileName, excelFileNameWithDate, excelNumberFormat, excelPercentFormat, excelSheetName, fillExcelCell, fitExcelSheetTitle, formatExportText, getExcelWorkerConstructor, resolveWorkbookConstructor, serializeExcelRequest, serializeExcelWorkbook, styleMapaExcelHeaderCell, uniqueExcelSheetNames };
|
|
985
1017
|
//# sourceMappingURL=mapa-library-ui-src-lib-core-excel-export.mjs.map
|