gm-datagrid 0.1.33 → 0.1.35
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 +24 -0
- package/README.md +19 -9
- package/dist/context/GridContext.d.ts +5 -1
- package/dist/dataset/buildServerFetchParams.d.ts +18 -0
- package/dist/dataset/useGMDataSet.d.ts +16 -6
- package/dist/engine/useEngineSync.d.ts +5 -1
- package/dist/gm-datagrid.js +14126 -15453
- package/dist/gm-datagrid.umd.cjs +47 -68
- package/dist/index.d.ts +1 -1
- package/dist/lib/serverModes.d.ts +12 -0
- package/dist/types/index.d.ts +40 -6
- package/docs/PUBLISH.md +5 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,30 @@ All notable changes to `gm-datagrid` are documented here.
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## [0.1.35] — 2026-11-22
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Production bundle** — library build no longer inlines `react/jsx-dev-runtime` (fixes `jsxDEV is not a function` when the host app runs a production Vite build). JSX is emitted against external `react/jsx-runtime`.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## [0.1.34] — 2026-11-21
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **Server-side data (MUI DataGrid parity)** — opt-in via `paginationMode`, `sortingMode`, and `filterMode` (`'client' | 'server'`, default `'client'`).
|
|
20
|
+
- **`sourceApi`** may return `{ success, data, total? }`; `onRowCountChange` for controlled `rowCount`.
|
|
21
|
+
- Query params sent to `sourceApi` when server modes are on: `page`, `pageSize`, `sortStack`, `filterGroup`, `search` (merged with `apiParameters` + `apiContext`).
|
|
22
|
+
- Automatic refetch on page/sort/filter changes; page resets to `0` on sort/filter/api param changes (MUI behavior).
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- **Server pagination** — Wasm engine no longer double-slices rows (`get_page(0, n)` when `paginationMode="server"`).
|
|
27
|
+
- **Server filter** — toolbar search skips client `match-sorter` when `filterMode="server"`.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
7
31
|
## [0.1.33] — 2026-11-15
|
|
8
32
|
|
|
9
33
|
### 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
|
|
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'` |
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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={
|
|
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
|
|
@@ -42,7 +42,11 @@ interface GridProviderProps {
|
|
|
42
42
|
defaultPageSize?: number;
|
|
43
43
|
onRowSelectionChange?: (rows: Row[]) => void;
|
|
44
44
|
getRowId?: GetRowIdFn;
|
|
45
|
+
onPaginationModelChange?: (model: {
|
|
46
|
+
page: number;
|
|
47
|
+
pageSize: number;
|
|
48
|
+
}) => void;
|
|
45
49
|
}
|
|
46
|
-
export declare function GridProvider({ dataset, children, defaultPageSize, onRowSelectionChange, getRowId: getRowIdProp, }: 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;
|
|
47
51
|
export declare function useGMGrid(): GridContextValue;
|
|
48
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
|
-
|
|
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;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ColumnDef, FilterGroup, GroupHeader, Row, SortKey } from '../types';
|
|
2
|
+
import { GridProcessingMode } from '../lib/serverModes';
|
|
2
3
|
import { GetRowIdFn } from './resolveGridRowId';
|
|
3
4
|
interface UseEngineSyncProps {
|
|
4
5
|
engine: any;
|
|
@@ -15,6 +16,9 @@ interface UseEngineSyncProps {
|
|
|
15
16
|
quickFilterText?: string;
|
|
16
17
|
groupBy?: string | null;
|
|
17
18
|
onGroups?: (groups: GroupHeader[]) => void;
|
|
19
|
+
paginationMode?: GridProcessingMode;
|
|
20
|
+
sortingMode?: GridProcessingMode;
|
|
21
|
+
filterMode?: GridProcessingMode;
|
|
18
22
|
}
|
|
19
|
-
export declare function useEngineSync({ engine, ready, rows, columns, getRowId, 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;
|
|
20
24
|
export {};
|