@colijnit/corecomponents_v12 261.20.7 → 261.20.8

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.
@@ -11642,6 +11642,7 @@ class BaseSimpleGridComponent {
11642
11642
  showEdit = false;
11643
11643
  showToolbar = false;
11644
11644
  autoAddRow = false;
11645
+ useCustomExcelExport = false;
11645
11646
  /**
11646
11647
  * Should component emit drag and drop actions instead of handle
11647
11648
  * (update collection) by itself
@@ -11659,6 +11660,7 @@ class BaseSimpleGridComponent {
11659
11660
  addRow = new EventEmitter();
11660
11661
  rowVisible = new EventEmitter();
11661
11662
  paginationPageChange = new EventEmitter();
11663
+ customExcelExport = new EventEmitter();
11662
11664
  handleMouseMove(event) {
11663
11665
  if (this.resizable && event.buttons === 1 && this._columnForResize) {
11664
11666
  // this._columnForResize.width = this._columnForResize.originalWidth - (this._startMousePositionX - event.clientX);
@@ -11772,7 +11774,7 @@ class BaseSimpleGridComponent {
11772
11774
  });
11773
11775
  }
11774
11776
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: BaseSimpleGridComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
11775
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.16", type: BaseSimpleGridComponent, isStandalone: true, inputs: { data: "data", exportData: "exportData", dragDropEnabled: "dragDropEnabled", resizable: "resizable", inlineEdit: "inlineEdit", showEdit: "showEdit", showToolbar: "showToolbar", autoAddRow: "autoAddRow", emitDragDrop: "emitDragDrop", extraColumns: "extraColumns" }, outputs: { onDrop: "onDrop", selectRow: "selectRow", deselectRow: "deselectRow", dblClickRow: "dblClickRow", saveRow: "saveRow", deleteRow: "deleteRow", addRow: "addRow", rowVisible: "rowVisible", paginationPageChange: "paginationPageChange" }, host: { listeners: { "document:mousemove": "handleMouseMove($event)", "document:mouseup": "handleMouseUp($event)" } }, queries: [{ propertyName: "content", predicate: SimpleGridColumnDirective }], ngImport: i0 });
11777
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.16", type: BaseSimpleGridComponent, isStandalone: true, inputs: { data: "data", exportData: "exportData", dragDropEnabled: "dragDropEnabled", resizable: "resizable", inlineEdit: "inlineEdit", showEdit: "showEdit", showToolbar: "showToolbar", autoAddRow: "autoAddRow", useCustomExcelExport: "useCustomExcelExport", emitDragDrop: "emitDragDrop", extraColumns: "extraColumns" }, outputs: { onDrop: "onDrop", selectRow: "selectRow", deselectRow: "deselectRow", dblClickRow: "dblClickRow", saveRow: "saveRow", deleteRow: "deleteRow", addRow: "addRow", rowVisible: "rowVisible", paginationPageChange: "paginationPageChange", customExcelExport: "customExcelExport" }, host: { listeners: { "document:mousemove": "handleMouseMove($event)", "document:mouseup": "handleMouseUp($event)" } }, queries: [{ propertyName: "content", predicate: SimpleGridColumnDirective }], ngImport: i0 });
11776
11778
  }
11777
11779
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: BaseSimpleGridComponent, decorators: [{
11778
11780
  type: Directive
@@ -11795,6 +11797,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
11795
11797
  type: Input
11796
11798
  }], autoAddRow: [{
11797
11799
  type: Input
11800
+ }], useCustomExcelExport: [{
11801
+ type: Input
11798
11802
  }], emitDragDrop: [{
11799
11803
  type: Input
11800
11804
  }], extraColumns: [{
@@ -11817,6 +11821,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
11817
11821
  type: Output
11818
11822
  }], paginationPageChange: [{
11819
11823
  type: Output
11824
+ }], customExcelExport: [{
11825
+ type: Output
11820
11826
  }], handleMouseMove: [{
11821
11827
  type: HostListener,
11822
11828
  args: ['document:mousemove', ['$event']]
@@ -12738,55 +12744,61 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
12738
12744
  header: column.headerText
12739
12745
  });
12740
12746
  });
12741
- const headers = columns.map(col => col.header);
12742
- const rows = exportData.map(row => columns.map(col => {
12743
- const value = row[col.key];
12744
- if (value instanceof Date) {
12745
- const formattedDate = value.toISOString().split('T')[0];
12746
- const [year, month, day] = formattedDate.split('-');
12747
- return `${day}-${month}-${year}`;
12748
- }
12749
- else if (typeof value === 'number') {
12750
- const hasDecimal = (num) => !Number.isInteger(num);
12751
- return hasDecimal(value) ? value.toFixed(2) : value.toFixed(0);
12752
- }
12753
- else if (Array.isArray(value)) {
12754
- return value.join(', ');
12755
- }
12756
- else if (typeof value === 'object' && value !== null) {
12757
- return JSON.stringify(value);
12758
- }
12759
- else if (typeof value === 'boolean') {
12760
- return String(value);
12761
- }
12762
- else {
12763
- if (!value)
12764
- return '';
12765
- if (typeof value === 'string' && value.includes('T00:00:00')) {
12766
- const [year, month, day] = value.replace('T00:00:00', '').split('-');
12747
+ if (this.useCustomExcelExport) {
12748
+ this.customExcelExport.emit({ exportData: exportData, columns: columns });
12749
+ return;
12750
+ }
12751
+ else {
12752
+ const headers = columns.map(col => col.header);
12753
+ const rows = exportData.map(row => columns.map(col => {
12754
+ const value = row[col.key];
12755
+ if (value instanceof Date) {
12756
+ const formattedDate = value.toISOString().split('T')[0];
12757
+ const [year, month, day] = formattedDate.split('-');
12767
12758
  return `${day}-${month}-${year}`;
12768
12759
  }
12769
- return String(value);
12770
- }
12771
- }));
12772
- // const csvContent = [headers, ...rows].map(row =>
12773
- // row.map(cell => `"${cell.replace(/"/g, '""')}"`).join(',')
12774
- // ).join('\r\n');
12775
- const csvContent = [headers, ...rows].map(row => row.map((cell) => `"${String(cell).replace(/"/g, '""')}"`).join(',')).join('\r\n');
12776
- const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
12777
- const link = document.createElement('a');
12778
- const url = URL.createObjectURL(blob);
12779
- link.href = url;
12780
- link.setAttribute('download', 'ExcelSheet');
12781
- document.body.appendChild(link);
12782
- link.click();
12783
- document.body.removeChild(link);
12784
- // this.excelExportService.exportToExcel(
12785
- // this.data,
12786
- // columns,
12787
- // 'ExcelSheet',
12788
- // 'Sheet1'
12789
- // );
12760
+ else if (typeof value === 'number') {
12761
+ const hasDecimal = (num) => !Number.isInteger(num);
12762
+ return hasDecimal(value) ? value.toFixed(2) : value.toFixed(0);
12763
+ }
12764
+ else if (Array.isArray(value)) {
12765
+ return value.join(', ');
12766
+ }
12767
+ else if (typeof value === 'object' && value !== null) {
12768
+ return JSON.stringify(value);
12769
+ }
12770
+ else if (typeof value === 'boolean') {
12771
+ return String(value);
12772
+ }
12773
+ else {
12774
+ if (!value)
12775
+ return '';
12776
+ if (typeof value === 'string' && value.includes('T00:00:00')) {
12777
+ const [year, month, day] = value.replace('T00:00:00', '').split('-');
12778
+ return `${day}-${month}-${year}`;
12779
+ }
12780
+ return String(value);
12781
+ }
12782
+ }));
12783
+ // const csvContent = [headers, ...rows].map(row =>
12784
+ // row.map(cell => `"${cell.replace(/"/g, '""')}"`).join(',')
12785
+ // ).join('\r\n');
12786
+ const csvContent = [headers, ...rows].map(row => row.map((cell) => `"${String(cell).replace(/"/g, '""')}"`).join(',')).join('\r\n');
12787
+ const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
12788
+ const link = document.createElement('a');
12789
+ const url = URL.createObjectURL(blob);
12790
+ link.href = url;
12791
+ link.setAttribute('download', 'ExcelSheet');
12792
+ document.body.appendChild(link);
12793
+ link.click();
12794
+ document.body.removeChild(link);
12795
+ // this.excelExportService.exportToExcel(
12796
+ // this.data,
12797
+ // columns,
12798
+ // 'ExcelSheet',
12799
+ // 'Sheet1'
12800
+ // );
12801
+ }
12790
12802
  }
12791
12803
  goToPreviousPage() {
12792
12804
  this.currentPage -= 1;