@opencorestack/opengridx 1.2.3 → 1.3.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/CHANGELOG.md +16 -0
- package/dist/index.d.ts +41 -0
- package/dist/opengridx.es.js +3641 -3473
- package/dist/opengridx.es.js.map +1 -1
- package/dist/opengridx.umd.js +26 -29
- package/dist/opengridx.umd.js.map +1 -1
- package/lib/components/DataGrid/DataGrid.tsx +48 -2
- package/lib/hooks/core/useDataGrid.ts +1 -0
- package/lib/types/index.ts +34 -0
- package/lib/utils/export/exportToPdf.ts +67 -30
- package/lib/utils/export/groupedExport.test.ts +144 -0
- package/lib/utils/export/index.ts +400 -271
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [1.3.0] — 2026-09-08
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Grouped export** — all five export functions (`exportToCsv`, `exportToExcel`, `exportToJson`,
|
|
12
|
+
`printGrid`, `exportToPdf`) now accept an optional `groupedRows?: GridGroupedExportRow[]` option.
|
|
13
|
+
When provided, the export preserves the row-grouping structure: group-header rows, indented leaf
|
|
14
|
+
rows, per-group subtotals, and a grand total footer. Flat behavior is unchanged when the option
|
|
15
|
+
is absent, making this a fully backward-compatible addition.
|
|
16
|
+
- **`GridApi.getGroupedExportRows()`** — new method that returns a flat ordered list of
|
|
17
|
+
`GridGroupedExportRow` entries (types: `group-header | leaf | group-subtotal | grand-total`)
|
|
18
|
+
by traversing the active row-grouping tree. Returns `null` when row grouping is not active.
|
|
19
|
+
- **`GridGroupedExportRow` type** — new public interface describing each entry in the grouped
|
|
20
|
+
export list (`type`, `depth`, `groupField?`, `groupValue?`, `aggregatedValues?`, `row?`).
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
8
24
|
## [1.2.3] — 2026-09-08
|
|
9
25
|
|
|
10
26
|
### Fixed
|
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,8 @@ export declare interface CsvExportOptions {
|
|
|
78
78
|
selectedRows?: (string | number)[];
|
|
79
79
|
aggregationResult?: Record<string, unknown> | null;
|
|
80
80
|
aggregationModel?: GridAggregationModel | null;
|
|
81
|
+
/** When provided, emits group headers, leaf rows, subtotals, and a grand total instead of a flat row list. */
|
|
82
|
+
groupedRows?: GridGroupedExportRow[];
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
export declare const darkTheme: GridTheme;
|
|
@@ -330,6 +332,8 @@ export declare interface ExcelExportOptions {
|
|
|
330
332
|
selectedRows?: (string | number)[];
|
|
331
333
|
aggregationResult?: Record<string, unknown> | null;
|
|
332
334
|
aggregationModel?: GridAggregationModel | null;
|
|
335
|
+
/** When provided, emits group headers, leaf rows, subtotals, and a grand total instead of a flat row list. */
|
|
336
|
+
groupedRows?: GridGroupedExportRow[];
|
|
333
337
|
}
|
|
334
338
|
|
|
335
339
|
export declare interface ExcelSheetDefinition {
|
|
@@ -404,6 +408,13 @@ export declare interface GridApi {
|
|
|
404
408
|
getVisibleRows: () => GridRowModel[];
|
|
405
409
|
/** Returns all filtered and sorted rows, ignoring pagination. Use this for full-dataset exports. */
|
|
406
410
|
getAllFilteredRows: () => GridRowModel[];
|
|
411
|
+
/**
|
|
412
|
+
* Returns an ordered flat list of `GridGroupedExportRow` entries that mirrors the
|
|
413
|
+
* on-screen grouping tree: group-headers, leaf rows, per-group subtotals, and a
|
|
414
|
+
* grand-total entry at the end. Returns `null` when no `rowGroupingModel` is active.
|
|
415
|
+
* Pass the result to export functions that accept a `groupedRows` option.
|
|
416
|
+
*/
|
|
417
|
+
getGroupedExportRows: () => GridGroupedExportRow[] | null;
|
|
407
418
|
/** Returns the current aggregation results. */
|
|
408
419
|
getAggregationResult: () => Record<string, unknown> | null;
|
|
409
420
|
/** Returns the active aggregation configuration. */
|
|
@@ -697,6 +708,25 @@ export declare interface GridGetRowsResponse<R extends GridRowModel = GridRowMod
|
|
|
697
708
|
aggregationResults?: Record<string, unknown>;
|
|
698
709
|
}
|
|
699
710
|
|
|
711
|
+
/**
|
|
712
|
+
* A single entry in the ordered list returned by `GridApi.getGroupedExportRows()`.
|
|
713
|
+
* Traverse in array order to reproduce the on-screen grouping structure.
|
|
714
|
+
*/
|
|
715
|
+
declare interface GridGroupedExportRow {
|
|
716
|
+
/** Discriminator: the kind of row this entry represents. */
|
|
717
|
+
type: 'group-header' | 'leaf' | 'group-subtotal' | 'grand-total';
|
|
718
|
+
/** Nesting depth (0 = top-level group, 1 = nested group, etc.). */
|
|
719
|
+
depth: number;
|
|
720
|
+
/** The grouping field for this level (absent on 'leaf' and 'grand-total'). */
|
|
721
|
+
groupField?: string;
|
|
722
|
+
/** The raw grouping value for this level (absent on 'leaf' and 'grand-total'). */
|
|
723
|
+
groupValue?: unknown;
|
|
724
|
+
/** Per-group aggregation results (present on 'group-subtotal' and 'grand-total'). */
|
|
725
|
+
aggregatedValues?: Record<string, unknown>;
|
|
726
|
+
/** The original data row (only present when `type === 'leaf'`). */
|
|
727
|
+
row?: GridRowModel;
|
|
728
|
+
}
|
|
729
|
+
|
|
700
730
|
export declare type GridInitialState = GridState;
|
|
701
731
|
|
|
702
732
|
/** Column definition used exclusively in List View mode. */
|
|
@@ -1176,6 +1206,8 @@ export declare interface JsonExportOptions {
|
|
|
1176
1206
|
selectedRows?: (string | number)[];
|
|
1177
1207
|
aggregationResult?: Record<string, unknown> | null;
|
|
1178
1208
|
aggregationModel?: GridAggregationModel | null;
|
|
1209
|
+
/** When provided, emits a nested grouping tree instead of a flat array. */
|
|
1210
|
+
groupedRows?: GridGroupedExportRow[];
|
|
1179
1211
|
}
|
|
1180
1212
|
|
|
1181
1213
|
/**
|
|
@@ -1234,6 +1266,13 @@ export declare interface PdfExportOptions {
|
|
|
1234
1266
|
* Base font size in points for table body. Default: 9
|
|
1235
1267
|
*/
|
|
1236
1268
|
fontSize?: number;
|
|
1269
|
+
/**
|
|
1270
|
+
* Pre-built grouped export rows from `apiRef.current.getGroupedExportRows()`.
|
|
1271
|
+
* When provided, the PDF table reflects the grouping structure (group headers,
|
|
1272
|
+
* leaf rows, per-group subtotals, grand total) instead of a flat row list.
|
|
1273
|
+
* Has no effect when the grid has no active `rowGroupingModel`.
|
|
1274
|
+
*/
|
|
1275
|
+
groupedRows?: GridGroupedExportRow[];
|
|
1237
1276
|
}
|
|
1238
1277
|
|
|
1239
1278
|
/**
|
|
@@ -1246,6 +1285,8 @@ export declare interface PrintOptions {
|
|
|
1246
1285
|
selectedRows?: (string | number)[];
|
|
1247
1286
|
aggregationResult?: Record<string, unknown> | null;
|
|
1248
1287
|
aggregationModel?: GridAggregationModel | null;
|
|
1288
|
+
/** When provided, emits group headers, leaf rows, subtotals, and a grand total instead of a flat row list. */
|
|
1289
|
+
groupedRows?: GridGroupedExportRow[];
|
|
1249
1290
|
}
|
|
1250
1291
|
|
|
1251
1292
|
export declare const roseTheme: GridTheme;
|