intelica-library-ui 0.1.194 → 0.1.196

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.
@@ -49,6 +49,7 @@ import * as XLSX from 'xlsx';
49
49
  import { Workbook } from 'exceljs';
50
50
  import { saveAs } from 'file-saver';
51
51
  import JSEncrypt from 'jsencrypt';
52
+ import pako from 'pako';
52
53
  import Aura from '@primeng/themes/aura';
53
54
  import { definePreset } from '@primeng/themes';
54
55
 
@@ -6436,7 +6437,9 @@ class HtmlToExcelService {
6436
6437
  return;
6437
6438
  Table.innerHTML = "";
6438
6439
  Table.innerHTML += html;
6439
- const ws = XLSX.utils.table_to_sheet(Table, { raw: false });
6440
+ const ws = XLSX.utils.table_to_sheet(Table, {
6441
+ raw: false,
6442
+ });
6440
6443
  const wb = XLSX.utils.book_new();
6441
6444
  XLSX.utils.book_append_sheet(wb, ws, tabname);
6442
6445
  XLSX.writeFile(wb, filename + "." + extension);
@@ -6447,23 +6450,48 @@ class HtmlToExcelService {
6447
6450
  horizontal: "center",
6448
6451
  wrapText: true,
6449
6452
  };
6450
- async ExportToExcel(excelName, reportTitle, filterTitle, rowsSerializate, columns, filters, subtitles = [], showTotalRow = false, headerGroups = [], childKey) {
6453
+ async ExportToExcel(excelNameOrOptions, reportTitle, filterTitle, rowsSerializate, columns, filters, subtitles = [], showTotalRow = false, headerGroups = [], childKey, SheetName = "") {
6454
+ let options;
6455
+ if (typeof excelNameOrOptions === "string") {
6456
+ options = {
6457
+ excelName: excelNameOrOptions,
6458
+ reportTitle: reportTitle,
6459
+ filterTitle: filterTitle,
6460
+ rowsSerializate: rowsSerializate,
6461
+ columns: columns,
6462
+ filters: filters,
6463
+ subtitles,
6464
+ showTotalRow,
6465
+ headerGroups,
6466
+ childKey,
6467
+ SheetName,
6468
+ };
6469
+ }
6470
+ else {
6471
+ options = {
6472
+ subtitles: [],
6473
+ showTotalRow: false,
6474
+ headerGroups: [],
6475
+ SheetName: "",
6476
+ ...excelNameOrOptions,
6477
+ };
6478
+ }
6451
6479
  const workbook = new Workbook();
6452
- const worksheet = workbook.addWorksheet(reportTitle);
6480
+ const worksheet = workbook.addWorksheet(options.SheetName || options.reportTitle);
6453
6481
  worksheet.views = [{ showGridLines: false }];
6454
6482
  const imageId = workbook.addImage({
6455
6483
  base64: this.Logo,
6456
6484
  extension: "png",
6457
6485
  });
6458
- this.SetReportPage(rowsSerializate, worksheet, columns, imageId, subtitles, showTotalRow, headerGroups, childKey);
6459
- this.SetTitle(worksheet, reportTitle);
6460
- if (filters.length > 0) {
6461
- const worksheetFilter = workbook.addWorksheet(filterTitle);
6486
+ this.SetReportPage(options.rowsSerializate, worksheet, options.columns, imageId, options.subtitles, options.showTotalRow, options.headerGroups, options.childKey);
6487
+ this.SetTitle(worksheet, options.reportTitle);
6488
+ if (options.filters.length > 0) {
6489
+ const worksheetFilter = workbook.addWorksheet(options.filterTitle);
6462
6490
  worksheetFilter.views = [{ showGridLines: false }];
6463
- this.SetFilterPage(filterTitle, worksheetFilter, filters);
6491
+ this.SetFilterPage(options.filterTitle, worksheetFilter, options.filters);
6464
6492
  }
6465
6493
  const buffer = await workbook.xlsx.writeBuffer();
6466
- saveAs(new Blob([buffer]), excelName);
6494
+ saveAs(new Blob([buffer]), options.excelName);
6467
6495
  }
6468
6496
  SetTitle(worksheet, reportTitle) {
6469
6497
  worksheet.mergeCells("D1:I5");
@@ -6558,12 +6586,17 @@ class HtmlToExcelService {
6558
6586
  else
6559
6587
  startRow += 1;
6560
6588
  if (showTotalRow) {
6561
- const sums = columns.map(col => {
6589
+ const sums = columns.map((col) => {
6562
6590
  if (col.columnName === "")
6563
6591
  return "Total";
6564
6592
  if (!col.totalRowValue)
6565
6593
  return null;
6566
- return col.totalRowValue ? { formula: `"${col.totalRowValue}"`, result: col.totalRowValue } : null;
6594
+ return col.totalRowValue
6595
+ ? {
6596
+ formula: `"${col.totalRowValue}"`,
6597
+ result: col.totalRowValue,
6598
+ }
6599
+ : null;
6567
6600
  });
6568
6601
  const insertedRow = worksheet.insertRow(startRow, sums);
6569
6602
  insertedRow.eachCell((cell, colNumber) => {
@@ -6578,7 +6611,9 @@ class HtmlToExcelService {
6578
6611
  vertical: "middle",
6579
6612
  horizontal: column?.alignHorizontal ?? "left",
6580
6613
  };
6581
- cell.border = { bottom: { style: "thin", color: { argb: "FF7F00" } } };
6614
+ cell.border = {
6615
+ bottom: { style: "thin", color: { argb: "FF7F00" } },
6616
+ };
6582
6617
  if (typeof cell.value === "number") {
6583
6618
  cell.numFmt = "0.00";
6584
6619
  }
@@ -6596,18 +6631,20 @@ class HtmlToExcelService {
6596
6631
  vertical: "middle",
6597
6632
  horizontal: col.alignHorizontal ?? "left",
6598
6633
  };
6599
- cell.border = { bottom: { style: "thin", color: { argb: "FF7F00" } } };
6634
+ cell.border = {
6635
+ bottom: { style: "thin", color: { argb: "FF7F00" } },
6636
+ };
6600
6637
  });
6601
6638
  startRow++;
6602
6639
  }
6603
6640
  //Inserción de filas
6604
6641
  const numberColIdx = (() => {
6605
- const byEmpty = columns.findIndex(c => (c.columnName ?? "").trim() === "");
6642
+ const byEmpty = columns.findIndex((c) => (c.columnName ?? "").trim() === "");
6606
6643
  if (byEmpty !== -1)
6607
6644
  return byEmpty;
6608
6645
  const isNumDisplay = (s) => (s ?? "").trim().toLowerCase().replace("º", "°") === "n°";
6609
- const byDisplay = columns.findIndex(c => isNumDisplay(c.displayColumnName));
6610
- const byColumnName = columns.findIndex(c => isNumDisplay(c.columnName));
6646
+ const byDisplay = columns.findIndex((c) => isNumDisplay(c.displayColumnName));
6647
+ const byColumnName = columns.findIndex((c) => isNumDisplay(c.columnName));
6611
6648
  const i = byDisplay !== -1 ? byDisplay : byColumnName;
6612
6649
  return i; // -1 si no hay numeración
6613
6650
  })(); // Detecta la columna de numeración ("", "N°" o "Nº") si existe
@@ -6618,7 +6655,7 @@ class HtmlToExcelService {
6618
6655
  indentColIdx = numberColIdx + 1;
6619
6656
  }
6620
6657
  else {
6621
- const nameIdx = columns.findIndex(c => (c.columnName ?? "").trim().toLowerCase() === "name" ||
6658
+ const nameIdx = columns.findIndex((c) => (c.columnName ?? "").trim().toLowerCase() === "name" ||
6622
6659
  (c.displayColumnName ?? "").trim().toLowerCase().includes("name"));
6623
6660
  if (nameIdx !== -1)
6624
6661
  indentColIdx = nameIdx;
@@ -6627,7 +6664,7 @@ class HtmlToExcelService {
6627
6664
  const rowValues = [];
6628
6665
  for (let colIndex = 0; colIndex < columns.length; colIndex++) {
6629
6666
  if (hasNumbering && colIndex === numberColIdx) {
6630
- rowValues.push(isHierarchical ? rows[rowIndex].__hier : (rowIndex + 1));
6667
+ rowValues.push(isHierarchical ? rows[rowIndex].__hier : rowIndex + 1);
6631
6668
  }
6632
6669
  else {
6633
6670
  rowValues.push(rows[rowIndex][columns[colIndex].columnName] ?? "");
@@ -6648,7 +6685,9 @@ class HtmlToExcelService {
6648
6685
  };
6649
6686
  });
6650
6687
  // Indentación: si hay jerarquía y hay columna definida para indentar
6651
- if (isHierarchical && indentColIdx !== null && indentColIdx < columns.length) {
6688
+ if (isHierarchical &&
6689
+ indentColIdx !== null &&
6690
+ indentColIdx < columns.length) {
6652
6691
  const indentCell = insertedRow.getCell(indentColIdx + 1); // 1-based
6653
6692
  indentCell.alignment = {
6654
6693
  ...(indentCell.alignment ?? {}),
@@ -6657,7 +6696,7 @@ class HtmlToExcelService {
6657
6696
  }
6658
6697
  }
6659
6698
  //Formato nombre de columnas
6660
- columnsCell.forEach(cellRef => {
6699
+ columnsCell.forEach((cellRef) => {
6661
6700
  const cell = worksheet.getCell(cellRef);
6662
6701
  cell.fill = {
6663
6702
  type: "pattern",
@@ -6678,7 +6717,7 @@ class HtmlToExcelService {
6678
6717
  if (rowIndex < firstDataRow)
6679
6718
  return;
6680
6719
  const isEven = (rowIndex - firstDataRow) % 2 === 0;
6681
- row.eachCell(cell => {
6720
+ row.eachCell((cell) => {
6682
6721
  if (!isEven) {
6683
6722
  cell.fill = {
6684
6723
  type: "pattern",
@@ -6731,12 +6770,12 @@ class HtmlToExcelService {
6731
6770
  let widtFilter = 30;
6732
6771
  worksheetFilter.addRow([filterTitle]);
6733
6772
  worksheetFilter.mergeCells(["A1", "B2"]);
6734
- worksheetFilter.columns.forEach(column => {
6773
+ worksheetFilter.columns.forEach((column) => {
6735
6774
  column.width = widtFilter;
6736
6775
  column.alignment = this.ColumnAligment;
6737
6776
  widtFilter *= 3;
6738
6777
  });
6739
- ["A1", "B1"].map(key => {
6778
+ ["A1", "B1"].map((key) => {
6740
6779
  worksheetFilter.getCell(key).fill = {
6741
6780
  type: "pattern",
6742
6781
  pattern: "solid",
@@ -6753,7 +6792,7 @@ class HtmlToExcelService {
6753
6792
  filters.forEach((element, index) => {
6754
6793
  let row = worksheetFilter.addRow([element.key, element.value]);
6755
6794
  let color = index % 2 === 1 ? "D9D9D9" : "FFFFFF";
6756
- row.eachCell(cell => {
6795
+ row.eachCell((cell) => {
6757
6796
  cell.fill = {
6758
6797
  type: "pattern",
6759
6798
  pattern: "solid",
@@ -6775,7 +6814,10 @@ class HtmlToExcelService {
6775
6814
  return;
6776
6815
  if (columns[index] == undefined)
6777
6816
  return;
6778
- let columnWidth = columns[index].width ?? Math.max(...column.values.map(v => (v ? v.toString().length : 0)).filter(v => typeof v === "number"), columns[index].displayColumnName.length) * 1.4;
6817
+ let columnWidth = columns[index].width ??
6818
+ Math.max(...column.values
6819
+ .map((v) => (v ? v.toString().length : 0))
6820
+ .filter((v) => typeof v === "number"), columns[index].displayColumnName.length) * 1.4;
6779
6821
  column.width = Math.min(Math.max(columnWidth, 5), 100);
6780
6822
  });
6781
6823
  worksheet.eachRow((row, rowIndex) => {
@@ -6784,7 +6826,9 @@ class HtmlToExcelService {
6784
6826
  let maxLines = 1;
6785
6827
  row.eachCell((cell, colNumber) => {
6786
6828
  if (cell.value) {
6787
- let text = typeof cell.value === "object" ? cell.text : cell.value.toString();
6829
+ let text = typeof cell.value === "object"
6830
+ ? cell.text
6831
+ : cell.value.toString();
6788
6832
  let columnWidth = worksheet.getColumn(colNumber).width ?? 10;
6789
6833
  let charsPerLine = columnWidth * 1.2;
6790
6834
  let estimatedLines = Math.ceil(text.length / charsPerLine);
@@ -6794,12 +6838,14 @@ class HtmlToExcelService {
6794
6838
  row.height = Math.min(Math.max(15 * maxLines, 15), 30);
6795
6839
  });
6796
6840
  }
6797
- async ExportToExcelRawData({ excelName, reportTitle, filterTitle, rowsSerializate, columns, filters, orderColumn = false }) {
6841
+ async ExportToExcelRawData({ excelName, reportTitle, filterTitle, rowsSerializate, columns, filters, orderColumn = false, }) {
6798
6842
  const workbook = new Workbook();
6799
6843
  const worksheet = workbook.addWorksheet(reportTitle);
6800
6844
  const rows = JSON.parse(rowsSerializate);
6801
6845
  worksheet.views = [{ showGridLines: false }];
6802
- const allColumns = orderColumn ? [{ displayColumnName: "N°" }, ...columns] : columns;
6846
+ const allColumns = orderColumn
6847
+ ? [{ displayColumnName: "N°" }, ...columns]
6848
+ : columns;
6803
6849
  allColumns.forEach((col, index) => {
6804
6850
  const columnLetter = this.GetExcelColumnLetter(index);
6805
6851
  const headerCell = worksheet.getCell(`${columnLetter}1`);
@@ -6807,14 +6853,14 @@ class HtmlToExcelService {
6807
6853
  headerCell.alignment = { horizontal: "center", vertical: "middle" };
6808
6854
  headerCell.font = { name: "Arial", bold: true, size: 10 };
6809
6855
  });
6810
- const maxLengths = allColumns.map(col => col.displayColumnName.length);
6856
+ const maxLengths = allColumns.map((col) => col.displayColumnName.length);
6811
6857
  rows.forEach((rowData, rowIndex) => {
6812
6858
  const rowValues = allColumns.map((col, colIndex) => {
6813
6859
  if (orderColumn && colIndex === 0) {
6814
- return (rowIndex + 1);
6860
+ return rowIndex + 1;
6815
6861
  }
6816
6862
  const originalColIndex = orderColumn ? colIndex - 1 : colIndex;
6817
- return rowData[columns[originalColIndex].columnName]?.toString() || "";
6863
+ return (rowData[columns[originalColIndex].columnName]?.toString() || "");
6818
6864
  });
6819
6865
  rowValues.forEach((value, i) => {
6820
6866
  const length = value.length;
@@ -6837,9 +6883,11 @@ class HtmlToExcelService {
6837
6883
  }
6838
6884
  async ExportToCSVRaw(excelName, rowsSerializate) {
6839
6885
  const rows = JSON.parse(rowsSerializate);
6840
- const csvLines = rows.map(r => r.linea);
6886
+ const csvLines = rows.map((r) => r.linea);
6841
6887
  const csvContent = csvLines.join("\n");
6842
- const blob = new Blob(["\uFEFF" + csvContent], { type: "text/csv;charset=utf-8;" });
6888
+ const blob = new Blob(["\uFEFF" + csvContent], {
6889
+ type: "text/csv;charset=utf-8;",
6890
+ });
6843
6891
  saveAs(blob, excelName.endsWith(".csv") ? excelName : `${excelName}.csv`);
6844
6892
  }
6845
6893
  GetExcelColumnLetter(columnNumber) {
@@ -6870,7 +6918,7 @@ class HtmlToExcelService {
6870
6918
  ...copy,
6871
6919
  __hier: seq.join("."), // "1" | "1.1" | "2.2.1" ...
6872
6920
  __level: seq.length - 1, // 0 = raíz, 1 = hijo, 2 = nieto...
6873
- __hasChildren: hasChildren // para formateo en negrita
6921
+ __hasChildren: hasChildren, // para formateo en negrita
6874
6922
  });
6875
6923
  if (hasChildren) {
6876
6924
  flat.push(...this.FlattenRowsForHierarchy(item[childKey], childKey, seq));
@@ -6879,7 +6927,7 @@ class HtmlToExcelService {
6879
6927
  return flat;
6880
6928
  }
6881
6929
  DetectsHierarchy(rows, childKey = "details") {
6882
- return rows?.some(r => Array.isArray(r?.[childKey]) && r[childKey].length > 0) ?? false;
6930
+ return (rows?.some((r) => Array.isArray(r?.[childKey]) && r[childKey].length > 0) ?? false);
6883
6931
  }
6884
6932
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: HtmlToExcelService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6885
6933
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: HtmlToExcelService, providedIn: "root" });
@@ -7488,6 +7536,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
7488
7536
  args: [{ providedIn: "root" }]
7489
7537
  }] });
7490
7538
 
7539
+ class CompressService {
7540
+ Zip(data) {
7541
+ let dataZip = pako.gzip(data);
7542
+ const base64 = btoa(String.fromCharCode(...dataZip));
7543
+ const encode = encodeURIComponent(base64);
7544
+ return encode;
7545
+ }
7546
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: CompressService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
7547
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: CompressService, providedIn: "root" });
7548
+ }
7549
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: CompressService, decorators: [{
7550
+ type: Injectable,
7551
+ args: [{ providedIn: "root" }]
7552
+ }] });
7553
+
7491
7554
  /**
7492
7555
  * Función de comparación genérica para ordenar objetos por un campo específico.
7493
7556
  *
@@ -9874,5 +9937,5 @@ const IntelicaTheme = definePreset(Aura, {
9874
9937
  * Generated bundle index. Do not edit.
9875
9938
  */
9876
9939
 
9877
- export { ActionDirective, ActionsMenuComponent, ButtonSplitComponent, CheckboxFilterDirective, Color, ColumnComponent, ColumnGroupComponent, CompareByField, ConfigService, CookieAttributesGeneral, DataDirective, DateFilterDirective, DateModeOptions, DynamicInputValidation, EchartComponent, EchartService, ElementService, EmailInputValidation, ErrorInterceptor, FeatureFlagService, FilterChipsComponent, FiltersComponent, FormatAmountPipe, GetCookieAttributes, GlobalFeatureFlagService, GlobalTermService, HtmlToExcelService, InitializeConfigService, InputValidation, IntelicaCellCheckboxDirective, IntelicaTheme, ItemSplitDirective, LanguageService, MatrixColumnComponent, MatrixColumnGroupComponent, MatrixTableComponent, ModalDialogComponent, MultiSelectComponent, OrderConstants, PaginatorComponent, Patterns, PopoverComponent, ProfileService, RecordPerPageComponent, RefreshTokenInterceptor, RouteGuard, RowResumenComponent, RowResumenTreeComponent, SearchComponent, SelectDetailFilterDirective, SelectFilterDirective, SharedService, SkeletonChartComponent, SkeletonComponent, SkeletonService, SkeletonTableComponent, SortingComponent, SpinnerComponent, SpinnerService, SweetAlertService, TableComponent, TableFetchComponent, TableSortOrder, TemplateDirective, TemplateMenuComponent, TermGuard, TermPipe, TermService, TextAreaFilterDirective, TextFilterDirective, TextRangeFilterDirective, TitlesComponent, TreeColumnComponent, TreeColumnGroupComponent, TreeTableComponent, TruncatePipe, decryptData, encryptData, getColor };
9940
+ export { ActionDirective, ActionsMenuComponent, ButtonSplitComponent, CheckboxFilterDirective, Color, ColumnComponent, ColumnGroupComponent, CompareByField, CompressService, ConfigService, CookieAttributesGeneral, DataDirective, DateFilterDirective, DateModeOptions, DynamicInputValidation, EchartComponent, EchartService, ElementService, EmailInputValidation, ErrorInterceptor, FeatureFlagService, FilterChipsComponent, FiltersComponent, FormatAmountPipe, GetCookieAttributes, GlobalFeatureFlagService, GlobalTermService, HtmlToExcelService, InitializeConfigService, InputValidation, IntelicaCellCheckboxDirective, IntelicaTheme, ItemSplitDirective, LanguageService, MatrixColumnComponent, MatrixColumnGroupComponent, MatrixTableComponent, ModalDialogComponent, MultiSelectComponent, OrderConstants, PaginatorComponent, Patterns, PopoverComponent, ProfileService, RecordPerPageComponent, RefreshTokenInterceptor, RouteGuard, RowResumenComponent, RowResumenTreeComponent, SearchComponent, SelectDetailFilterDirective, SelectFilterDirective, SharedService, SkeletonChartComponent, SkeletonComponent, SkeletonService, SkeletonTableComponent, SortingComponent, SpinnerComponent, SpinnerService, SweetAlertService, TableComponent, TableFetchComponent, TableSortOrder, TemplateDirective, TemplateMenuComponent, TermGuard, TermPipe, TermService, TextAreaFilterDirective, TextFilterDirective, TextRangeFilterDirective, TitlesComponent, TreeColumnComponent, TreeColumnGroupComponent, TreeTableComponent, TruncatePipe, decryptData, encryptData, getColor };
9878
9941
  //# sourceMappingURL=intelica-library-ui.mjs.map