gm-datagrid 0.1.13 โ†’ 0.1.14

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
@@ -9,6 +9,7 @@ Enterprise-grade, Excel-like data grid for React โ€” powered by a **Rust/WebAsse
9
9
  - ๐Ÿ“Š Column subtotals updated live as filters change
10
10
  - ๐Ÿ“… Date filter operators โ€” is / is not / is after / is before / is empty / is not empty
11
11
  - ๐Ÿ“ฅ One-click `.xlsx` export (generated in Wasm, no server round-trip)
12
+ - ๐Ÿ“ค **Multi-format export** โ€” toolbar picker for `xlsx`, `csv`, `txt`, `json`
12
13
  - ๐ŸŒ Built-in **i18n** โ€” `locale="es"` / `locale="en"` with full label overrides
13
14
  - ๐Ÿ”’ **Feature flags** โ€” selectively disable export, filters, sort, or grouping per instance
14
15
  - ๐Ÿงน **Clear all filters** button in toolbar (desktop + mobile)
@@ -105,6 +106,7 @@ Control which toolbar actions and column interactions are available without touc
105
106
  | Prop | Type | Default | Description |
106
107
  |---|---|---|---|
107
108
  | `exportable` | `boolean` | `true` | Show / hide the **Export** button in the toolbar |
109
+ | `exportFormats` | `ExportFormat[]` | `['xlsx', 'csv']` | Which formats appear in the export menu. A single format skips the menu and downloads directly |
108
110
  | `exportableColumns` | `string[]` | โ€” | Whitelist of `field` values included in the `.xlsx` export. Omit to export all visible columns |
109
111
  | `filterable` | `boolean` | `true` | Show / hide the filter panel toggle button and the per-column filter row |
110
112
  | `filterableColumns` | `string[]` | โ€” | Only these fields render a filter input in the filter panel |
@@ -478,7 +480,39 @@ function App() {
478
480
 
479
481
  The toolbar includes an **Export** button that generates a `.xlsx` file entirely inside the Wasm engine โ€” no server call required. The exported file reflects the current sort and filter state.
480
482
 
481
- Column formatting is preserved in the export:
483
+ ---
484
+
485
+ ## Multi-format export
486
+
487
+ By default the toolbar shows an export button that downloads both `.xlsx` and `.csv`. When more than one format is enabled a **format picker menu** opens on click:
488
+
489
+ ```tsx
490
+ <GMDatagrid
491
+ title="Products"
492
+ columns={columns}
493
+ sourceApi={fetchProducts}
494
+ exportFormats={['xlsx', 'csv', 'txt', 'json']} // all four formats
495
+ />
496
+
497
+ // xlsx only โ€” no menu, direct download
498
+ <GMDatagrid exportFormats={['xlsx']} ... />
499
+
500
+ // Disable export entirely
501
+ <GMDatagrid exportable={false} ... />
502
+ ```
503
+
504
+ ### Supported formats
505
+
506
+ | Format | Extension | Notes |
507
+ |---|---|---|
508
+ | `xlsx` | `.xlsx` | Generated by Rust/Wasm; preserves number & date formats, column widths |
509
+ | `csv` | `.csv` | RFC 4180, UTF-8 BOM โ€” opens correctly in Excel |
510
+ | `txt` | `.txt` | Tab-separated values โ€” paste directly into Excel |
511
+ | `json` | `.json` | Array of objects keyed by column `field` |
512
+
513
+ `ACTION`, `MENU_ACTION`, and `IMAGE` columns are automatically excluded from CSV/TXT/JSON exports.
514
+
515
+ Column formatting is preserved in the xlsx export:
482
516
 
483
517
  - `PRICE` / `TOTAL` columns use Excel number formats
484
518
  - `DATE` / `DATE_TIME` columns use Excel date formats
@@ -509,6 +543,7 @@ import type {
509
543
  Row,
510
544
  CellRenderParams,
511
545
  CellEditParams,
546
+ ExportFormat,
512
547
  FilterGroup,
513
548
  FilterCellValue,
514
549
  DateFilterValue,
@@ -601,7 +636,7 @@ interface CellEditParams {
601
636
 
602
637
  All four levels must pass for a cell to be editable:
603
638
 
604
- 1. `editable` prop โ€” global feature flag (`true` by default)
639
+ 1. `editable` prop โ€” global feature flag (`false` by default)
605
640
  2. `editableColumns` whitelist โ€” if set, field must be in the list
606
641
  3. `col.editable` โ€” per-column flag in `ColumnDef`
607
642
  4. `isCellEditable(params)` callback โ€” per-row guard
@@ -1,16 +1,18 @@
1
+ import { default as React } from 'react';
1
2
  import { GridEngine } from '../wasm/core_engine';
3
+ import { ColumnDef, ExportFormat } from '../types';
2
4
  interface UseExportProps {
3
5
  engineRef: React.RefObject<GridEngine | null>;
4
6
  title: string;
5
7
  /** When provided, only columns whose field is in this set are included in the export. */
6
8
  exportableFields?: Set<string>;
9
+ /** All visible columns โ€” used to build CSV/TXT/JSON exports. */
10
+ columns: ColumnDef[];
11
+ /** Formats enabled for this grid instance (default: ['xlsx', 'csv']). */
12
+ exportFormats?: ExportFormat[];
7
13
  }
8
- /**
9
- * Triggers a Wasm-side Excel export and downloads the result as a .xlsx file.
10
- * If `exportableFields` is provided the Wasm engine is asked to restrict the
11
- * export to those columns only; otherwise all columns are exported.
12
- */
13
- export declare function useExport({ engineRef, title, exportableFields }: UseExportProps): {
14
- handleExport: () => void;
14
+ export declare function useExport({ engineRef, title, exportableFields, columns, exportFormats, }: UseExportProps): {
15
+ handleExport: (format: ExportFormat) => void;
16
+ exportFormats: ExportFormat[];
15
17
  };
16
18
  export {};