@devjuliovilla/jv-ui 1.11.1 → 1.11.2

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/README.md CHANGED
@@ -147,9 +147,10 @@ import { JvGridComponent } from '@devjuliovilla/jv-ui';
147
147
  | `pageSizeOptions` | `number[]` | `[10, 20, 50, 100]` | Page size selector options |
148
148
  | `density` | `'compact' \| 'normal' \| 'comfortable'` | `'normal'` | Row density |
149
149
  | `loading` | `boolean` | `false` | Show loading spinner |
150
- | `emptyMessage` | `string` | — | Empty state message |
151
- | `exportable` | `boolean` | `false` | Show CSV/Excel export buttons |
152
- | `serverSide` | `boolean` | `false` | Disable client-side processing |
150
+ | `emptyMessage` | `string` | — | Empty state message |
151
+ | `exportable` | `boolean` | `false` | Show CSV/Excel export buttons |
152
+ | `exportFileName` | `string` | `''` | Base filename used for CSV/Excel exports; the component applies the correct extension |
153
+ | `serverSide` | `boolean` | `false` | Disable client-side processing |
153
154
  | `totalItems` | `number` | `0` | Total items for server-side mode |
154
155
  | `stickyColumns` | `boolean` | `false` | Enable sticky column support |
155
156
  | `resizableColumns` | `boolean` | `false` | Enable column resizing |
@@ -182,7 +183,7 @@ interface Product {
182
183
  <jv-grid
183
184
  [data]="products"
184
185
  [columns]="columns"
185
- [options]="{ selectable: true, exportable: true, pageSize: 10 }"
186
+ [options]="{ selectable: true, exportable: true, exportFileName: 'products', pageSize: 10 }"
186
187
  [trackBy]="'id'"
187
188
  [selectedIds]="selectedIds"
188
189
  (selectionChange)="selectedIds = $event"
@@ -23212,6 +23212,7 @@ const JV_GRID_DEFAULT_OPTIONS = {
23212
23212
  virtualScroll: false,
23213
23213
  virtualScrollRowHeight: 48,
23214
23214
  exportable: false,
23215
+ exportFileName: '',
23215
23216
  columnFilters: false,
23216
23217
  rowDoubleClick: false,
23217
23218
  };
@@ -23219,6 +23220,7 @@ const JV_GRID_DEFAULT_OPTIONS = {
23219
23220
  const MAIN_NS = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main';
23220
23221
  const REL_NS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';
23221
23222
  const PKG_REL_NS = 'http://schemas.openxmlformats.org/package/2006/relationships';
23223
+ const CONTENT_TYPES_NS = 'http://schemas.openxmlformats.org/package/2006/content-types';
23222
23224
  const XML_DECL = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
23223
23225
  /**
23224
23226
  * Builds a real Office Open XML (.xlsx) spreadsheet as a Blob.
@@ -23254,7 +23256,7 @@ function buildXlsxBuffer(sheets) {
23254
23256
  }
23255
23257
  function buildContentTypes(sheetCount) {
23256
23258
  let xml = XML_DECL;
23257
- xml += `<Types xmlns="${PKG_REL_NS}">`;
23259
+ xml += `<Types xmlns="${CONTENT_TYPES_NS}">`;
23258
23260
  xml += `<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>`;
23259
23261
  xml += `<Default Extension="xml" ContentType="application/xml"/>`;
23260
23262
  xml += `<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>`;
@@ -24002,11 +24004,22 @@ class JvGridComponent {
24002
24004
  // Export
24003
24005
  exportCsv() {
24004
24006
  const { header, rows } = this.buildExportMatrix();
24005
- exportGridToCsv(header, rows, 'grid-export.csv');
24007
+ exportGridToCsv(header, rows, this.resolveExportFileName('csv'));
24006
24008
  }
24007
24009
  exportExcel() {
24008
24010
  const { header, rows } = this.buildExportMatrix();
24009
- exportGridToExcel(header, rows, 'grid-export.xlsx');
24011
+ exportGridToExcel(header, rows, this.resolveExportFileName('xlsx'));
24012
+ }
24013
+ resolveExportFileName(extension) {
24014
+ const configuredName = this.effectiveOptions().exportFileName?.trim();
24015
+ const fallbackName = `grid-export.${extension}`;
24016
+ if (!configuredName) {
24017
+ return fallbackName;
24018
+ }
24019
+ if (configuredName.toLowerCase().endsWith(`.${extension}`)) {
24020
+ return configuredName;
24021
+ }
24022
+ return configuredName.replace(/\.(csv|xlsx)$/i, '') + `.${extension}`;
24010
24023
  }
24011
24024
  buildExportMatrix() {
24012
24025
  const cols = this.visibleColumns().map(c => ({ key: this.colKey(c), header: c.header, column: c }));