gm-datagrid 0.1.32 → 0.1.34

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 CHANGED
@@ -4,6 +4,113 @@ All notable changes to `gm-datagrid` are documented here.
4
4
 
5
5
  ---
6
6
 
7
+ ## [0.1.34] — 2026-11-21
8
+
9
+ ### Added
10
+
11
+ - **Server-side data (MUI DataGrid parity)** — opt-in via `paginationMode`, `sortingMode`, and `filterMode` (`'client' | 'server'`, default `'client'`).
12
+ - **`sourceApi`** may return `{ success, data, total? }`; `onRowCountChange` for controlled `rowCount`.
13
+ - Query params sent to `sourceApi` when server modes are on: `page`, `pageSize`, `sortStack`, `filterGroup`, `search` (merged with `apiParameters` + `apiContext`).
14
+ - Automatic refetch on page/sort/filter changes; page resets to `0` on sort/filter/api param changes (MUI behavior).
15
+
16
+ ### Fixed
17
+
18
+ - **Server pagination** — Wasm engine no longer double-slices rows (`get_page(0, n)` when `paginationMode="server"`).
19
+ - **Server filter** — toolbar search skips client `match-sorter` when `filterMode="server"`.
20
+
21
+ ---
22
+
23
+ ## [0.1.33] — 2026-11-15
24
+
25
+ ### Fixed
26
+
27
+ - **`valueGetter`**: engine rows are reconciled back to source rows after `get_page` / `get_group_page`; getters run once on raw rows in the UI (`getRowId` prop, default `id` / `uuid`).
28
+ - **Export**: no second `valueGetter` pass on engine-stored cell values.
29
+
30
+ ### Added
31
+
32
+ - **`GridBulkActionsMenu`** — scrollable bulk menu with `actions[]`, per-option `component` sub-components, optional `group`, confirm + `onAction`.
33
+ - Slot props: `maxSelection`, `clearSelectionOnSuccess`, `showInFloatingBar`.
34
+
35
+ ---
36
+
37
+ ## [0.1.32] — 2026-11-13
38
+
39
+ ### Fixed
40
+
41
+ - **Wasm engine:** `ColumnType::Boolean` — `set_columns` accepts `type: "boolean"` (fixes engine sync with `ColumnDataTypesEnum.BOOLEAN`).
42
+
43
+ ---
44
+
45
+ ## [0.1.31] — 2026-11-13
46
+
47
+ ### Added
48
+
49
+ - `ColumnDataTypesEnum.BOOLEAN` with `BooleanCell` (Sí / No chips).
50
+ - Runtime alias `ColumnDataTypesEnum.DATETIME` → `DATE_TIME` for goal-front `grid-definitions` parity.
51
+
52
+ ### Changed
53
+
54
+ - `CODE` columns render monospace text; empty values show `—`.
55
+ - `DATE_TIME` / `BOOLEAN` values format correctly in default cells (no raw ISO / `true` strings).
56
+
57
+ ---
58
+
59
+ ## [0.1.30] — 2026-11-12
60
+
61
+ ### Added
62
+
63
+ - **`fillAvailableWidth`** (default `true`): grows columns to use the full grid viewport when the column sum is narrower.
64
+ - **Double-click column resize** to auto-fit width (`disableColumnAutoFit`, `autoFitMaxWidth`).
65
+ - **Sticky header + filter row** inside a single scrollport; viewport-anchored header separator line on horizontal scroll.
66
+ - **`stickyHeader`** (default `true`).
67
+
68
+ ### Changed
69
+
70
+ - Column layout uses `resolveColumnWidths` with `ColumnDef.flex` when distributing extra space.
71
+ - Aggregation footer keeps horizontal scroll in sync with the body scrollport only.
72
+
73
+ ---
74
+
75
+ ## [0.1.29] — 2026-03-27
76
+
77
+ ### Added
78
+
79
+ - `floatingSelectionBar` prop (default `true`). Set `false` on grids inside drawers/dialogs to avoid a fixed bar over the main page.
80
+
81
+ ---
82
+
83
+ ## [0.1.28] — 2026-03-27
84
+
85
+ ### Fixed
86
+
87
+ - **Selection floating bar**: uses theme `background.paper`, `divider`, and `shadows[8]` instead of hard-coded light colors (readable in dark mode).
88
+
89
+ ---
90
+
91
+ ## [0.1.27] — 2026-03-11
92
+
93
+ ### Added
94
+
95
+ - Horizontal scroll: `contentMinWidth` from column sums; virtualized rows use `minWidth` instead of `right: 0`.
96
+ - `minHeight` (default `360`), `bodyMinHeight`, loading skeleton, `showRowNumber` (default `true`), `rowNumberPosition`, `confirmPrompt` / `GridConfirmDialog`.
97
+
98
+ ### Changed
99
+
100
+ - Status switch uses async in-grid confirm dialog (no `window.confirm`).
101
+
102
+ ---
103
+
104
+ ## [0.1.26] — 2026-03-11
105
+
106
+ ### Fixed
107
+
108
+ - **`useVirtualization`**: removed perpetual `requestAnimationFrame` → `setState` loop (caused runaway re-renders / “Maximum update depth exceeded”).
109
+ - **`useEngineSync`**: stop calling `onGroups([])` on every sync when not grouped.
110
+ - **`handleGroups`**: skip state updates when group headers are unchanged.
111
+
112
+ ---
113
+
7
114
  ## [0.1.25] — 2026-03-11
8
115
 
9
116
  ### Fixed
package/README.md CHANGED
@@ -106,15 +106,20 @@ export default function ProductsPage() {
106
106
 
107
107
  **Column types (built-in cells):** `BOOLEAN` → Sí/No chips; `DATE_TIME` or `DATETIME` alias → `DD/MM/YYYY HH:mm:ss`; `CODE` → monospace with `—` when empty.
108
108
 
109
- ### Pagination props
109
+ ### Pagination & server modes (MUI DataGrid-compatible)
110
+
111
+ Server behavior is **opt-in per dimension**. Defaults keep the Wasm client path unchanged.
110
112
 
111
113
  | Prop | Type | Default | Description |
112
114
  |---|---|---|---|
113
- | `paginationMode` | `'client' \| 'server'` | `'client'` | Client-side (engine) or server-side pagination |
115
+ | `paginationMode` | `'client' \| 'server'` | `'client'` | `'server'` → `page` / `pageSize` sent to `sourceApi`; footer uses `rowCount` |
116
+ | `sortingMode` | `'client' \| 'server'` | `'client'` | `'server'` → `sortStack` sent to `sourceApi` |
117
+ | `filterMode` | `'client' \| 'server'` | `'client'` | `'server'` → `filterGroup` + toolbar `search` sent to `sourceApi` |
114
118
  | `paginationModel` | `{ page: number; pageSize: number }` | `{ page: 0, pageSize: 25 }` | Controlled pagination state |
115
- | `onPaginationModelChange` | `(model) => void` | — | Called when the user changes page or page size |
119
+ | `onPaginationModelChange` | `(model) => void` | — | Called when page or page size changes (required for controlled server pagination) |
120
+ | `onRowCountChange` | `(count: number) => void` | — | Fired when `sourceApi` returns `total` |
116
121
  | `pageSizeOptions` | `number[]` | `[25, 50, 100]` | Rows-per-page options shown in the footer selector |
117
- | `rowCount` | `number` | — | Total row count for server-side pagination |
122
+ | `rowCount` | `number` | — | Total row count when `paginationMode="server"` |
118
123
 
119
124
  ### Feature flags
120
125
 
@@ -306,16 +311,16 @@ The Wasm engine slices rows in memory — no extra API calls on page change:
306
311
  />
307
312
  ```
308
313
 
309
- ### Server-side
314
+ ### Server-side (MUI parity)
310
315
 
311
- Control pagination yourself and pass the total row count:
316
+ Enable the flags you need, control `paginationModel` / `rowCount`, and return `total` from `sourceApi` (or use `onRowCountChange`):
312
317
 
313
318
  ```tsx
314
319
  const [paginationModel, setPaginationModel] = useState({ page: 0, pageSize: 25 })
320
+ const [rowCount, setRowCount] = useState(0)
315
321
 
316
322
  async function fetchPage(params) {
317
- const { page, pageSize } = params
318
- const res = await api.get('/products', { page, pageSize })
323
+ const res = await api.get('/products', params)
319
324
  return { success: true, data: res.rows, total: res.total }
320
325
  }
321
326
 
@@ -324,13 +329,18 @@ async function fetchPage(params) {
324
329
  columns={columns}
325
330
  sourceApi={fetchPage}
326
331
  paginationMode="server"
332
+ sortingMode="server"
333
+ filterMode="server"
327
334
  paginationModel={paginationModel}
328
335
  onPaginationModelChange={setPaginationModel}
329
- rowCount={totalFromServer}
336
+ rowCount={rowCount}
337
+ onRowCountChange={setRowCount}
330
338
  pageSizeOptions={[25, 50, 100]}
331
339
  />
332
340
  ```
333
341
 
342
+ The grid refetches when page, sort, or filters change. Sort/filter changes reset the page to `0` (same as MUI Data Grid). Do not combine `groupable` with `paginationMode="server"`.
343
+
334
344
  ---
335
345
 
336
346
  ## Row selection
@@ -1,5 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { GroupHeader, Row } from '../types';
3
+ import { GetRowIdFn } from '../engine/resolveGridRowId';
3
4
  import { DataSetState } from '../dataset/useGMDataSet';
4
5
  interface GridContextValue extends DataSetState {
5
6
  pageRows: Row[];
@@ -33,13 +34,19 @@ interface GridContextValue extends DataSetState {
33
34
  getRows: () => Row[];
34
35
  getSelectedRows: () => Row[];
35
36
  selectedCount: number;
37
+ getRowId: (row: Row) => string;
36
38
  }
37
39
  interface GridProviderProps {
38
40
  dataset: DataSetState;
39
41
  children: React.ReactNode;
40
42
  defaultPageSize?: number;
41
43
  onRowSelectionChange?: (rows: Row[]) => void;
44
+ getRowId?: GetRowIdFn;
45
+ onPaginationModelChange?: (model: {
46
+ page: number;
47
+ pageSize: number;
48
+ }) => void;
42
49
  }
43
- export declare function GridProvider({ dataset, children, defaultPageSize, onRowSelectionChange }: GridProviderProps): import("react/jsx-runtime").JSX.Element;
50
+ export declare function GridProvider({ dataset, children, defaultPageSize, onRowSelectionChange, getRowId: getRowIdProp, onPaginationModelChange, }: GridProviderProps): import("react/jsx-runtime").JSX.Element;
44
51
  export declare function useGMGrid(): GridContextValue;
45
52
  export {};
@@ -0,0 +1,18 @@
1
+ import { FilterGroup, SortKey } from '../types';
2
+ import { GridProcessingMode } from '../lib/serverModes';
3
+ export interface BuildServerFetchParamsInput {
4
+ paginationMode?: GridProcessingMode;
5
+ sortingMode?: GridProcessingMode;
6
+ filterMode?: GridProcessingMode;
7
+ page: number;
8
+ pageSize: number;
9
+ sortStack: SortKey[];
10
+ filterGroup: FilterGroup | null;
11
+ search: string;
12
+ apiParameters: Record<string, unknown>;
13
+ }
14
+ /**
15
+ * Builds the query payload merged into sourceApi calls when server modes are active.
16
+ * Only includes dimensions whose mode is `'server'` (MUI DataGrid parity).
17
+ */
18
+ export declare function buildServerFetchParams(input: BuildServerFetchParamsInput): Record<string, unknown>;
@@ -1,13 +1,15 @@
1
- import { ApiContext, ColumnDef, FilterGroup, Row, SortKey } from '../types';
1
+ import { ApiContext, ColumnDef, FilterGroup, Row, SortKey, SourceApiResult } from '../types';
2
+ import { GridProcessingMode } from '../lib/serverModes';
2
3
  interface UseGMDataSetProps {
3
4
  columns: ColumnDef[];
4
- sourceApi?: (params: Record<string, unknown>) => Promise<{
5
- success: boolean;
6
- data: Row[];
7
- }>;
5
+ sourceApi?: (params: Record<string, unknown>) => Promise<SourceApiResult>;
8
6
  apiParameters?: Record<string, unknown>;
9
7
  localData?: Row[];
10
8
  apiContext?: ApiContext;
9
+ paginationMode?: GridProcessingMode;
10
+ sortingMode?: GridProcessingMode;
11
+ filterMode?: GridProcessingMode;
12
+ onRowCountChange?: (rowCount: number) => void;
11
13
  }
12
14
  export interface DataSetState {
13
15
  rows: Row[];
@@ -19,7 +21,15 @@ export interface DataSetState {
19
21
  dataVersion: number;
20
22
  handleRefresh: () => void;
21
23
  setApiParameters: (params: Record<string, unknown>) => void;
22
- /** Push a new sort stack to the Wasm engine ref held by GridContext. */
24
+ apiParameters: Record<string, unknown>;
25
+ /** Total from last sourceApi `total` when paginationMode is server. */
26
+ serverRowCount: number | null;
27
+ /** Fetch with merged apiParameters + overrides + apiContext. */
28
+ loadData: (overrides?: Record<string, unknown>) => Promise<void>;
29
+ usesServerDrivenFetch: boolean;
30
+ paginationMode: GridProcessingMode;
31
+ sortingMode: GridProcessingMode;
32
+ filterMode: GridProcessingMode;
23
33
  sortStack: SortKey[];
24
34
  setSortStack: (stack: SortKey[]) => void;
25
35
  filterGroup: FilterGroup | null;
@@ -0,0 +1,6 @@
1
+ import { Row } from '../types';
2
+ import { GetRowIdFn } from './resolveGridRowId';
3
+ /**
4
+ * Maps Wasm page rows back to the original source rows so UI never sees getter-mutated fields.
5
+ */
6
+ export declare function reconcilePageRows(sourceRows: Row[], engineRows: Row[], getRowId?: GetRowIdFn): Row[];
@@ -0,0 +1,4 @@
1
+ import { Row } from '../types';
2
+ export type GetRowIdFn = (row: Row) => string;
3
+ /** Default row key for reconcile / selection (override with `getRowId` prop). */
4
+ export declare function defaultGetRowId(row: Row): string;
@@ -0,0 +1,9 @@
1
+ import { ColumnDef, Row } from '../types';
2
+ /**
3
+ * Convert a single cell value to a type the Rust CellValue enum can accept.
4
+ */
5
+ export declare function toCellValue(v: unknown): string | number | boolean | null;
6
+ /**
7
+ * Build engine rows: apply column valueGetters on a copy; never mutate input rows.
8
+ */
9
+ export declare function sanitizeRowsForEngine(rows: Row[], columns: ColumnDef[]): Record<string, string | number | boolean | null>[];
@@ -1,34 +1,24 @@
1
1
  import { ColumnDef, FilterGroup, GroupHeader, Row, SortKey } from '../types';
2
+ import { GridProcessingMode } from '../lib/serverModes';
3
+ import { GetRowIdFn } from './resolveGridRowId';
2
4
  interface UseEngineSyncProps {
3
5
  engine: any;
4
6
  ready: boolean;
5
7
  rows: Row[];
6
8
  columns: ColumnDef[];
9
+ getRowId?: GetRowIdFn;
7
10
  onSynced: (totalCount: number, subtotals: Record<string, number>) => void;
8
11
  page: number;
9
12
  pageSize: number;
10
13
  onPageData: (rows: Row[]) => void;
11
- /** Applied atomically right after load_data — avoids calling engine methods before data is loaded. */
12
14
  sortStack?: SortKey[];
13
15
  filterGroup?: FilterGroup | null;
14
16
  quickFilterText?: string;
15
- /** When set, calls engine.set_group_by() and fires onGroups with the resulting headers. */
16
17
  groupBy?: string | null;
17
18
  onGroups?: (groups: GroupHeader[]) => void;
19
+ paginationMode?: GridProcessingMode;
20
+ sortingMode?: GridProcessingMode;
21
+ filterMode?: GridProcessingMode;
18
22
  }
19
- /**
20
- * Syncs React state → Wasm engine (push) and pulls page data + subtotals back.
21
- *
22
- * IMPORTANT: push and pull are intentionally in ONE effect, not two.
23
- * wasm-bindgen wraps GridEngine methods with a runtime borrow-check on `&mut self`.
24
- * Two separate effects that both call engine methods can fire in the same
25
- * synchronous React flush — the second effect starts before wasm-bindgen has
26
- * released the `&mut` borrow from the first, triggering:
27
- * "recursive use of an object detected which would lead to unsafe aliasing in rust"
28
- *
29
- * Keeping everything in a single effect guarantees all engine calls are sequential
30
- * within one borrow, and the pull (get_page / get_subtotals) always sees the
31
- * data that was just loaded.
32
- */
33
- export declare function useEngineSync({ engine, ready, rows, columns, onSynced, page, pageSize, onPageData, sortStack, filterGroup, quickFilterText, groupBy, onGroups, }: UseEngineSyncProps): void;
23
+ export declare function useEngineSync({ engine, ready, rows, columns, getRowId, onSynced, page, pageSize, onPageData, sortStack, filterGroup, quickFilterText, groupBy, onGroups, paginationMode, sortingMode, filterMode, }: UseEngineSyncProps): void;
34
24
  export {};