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/dist/index.d.ts CHANGED
@@ -2,9 +2,10 @@ export { GMDatagrid } from './GMDatagrid';
2
2
  export { GMGridContainer } from './GMGridContainer';
3
3
  export type { GMGridContainerRef } from './GMGridContainer';
4
4
  export { useGMGrid } from './context/GridContext';
5
- export type { GMDatagridProps, GMDatagridRef, ColumnDef, Row, CellRange, CellCoord, FilterGroup, FilterCondition, SortKey, ApiContext, DensityMode, MuiChipColor, StatusMapEntry, CellRenderParams, CellEditParams, GridBulkActionProps, GridCreatorSlotProps, GridSynchronizerSlotProps, GridToolbarSlots, GridToolbarSlotProps, StatusSwitchConfig, StatusSwitchUpdateArgs, } from './types';
5
+ export type { GMDatagridProps, GMDatagridRef, ColumnDef, Row, CellRange, CellCoord, FilterGroup, FilterCondition, SortKey, SourceApiResult, GMDatagridFetchParams, GridProcessingMode, ApiContext, DensityMode, MuiChipColor, StatusMapEntry, CellRenderParams, CellEditParams, GridBulkActionProps, GridBulkMenuItemProps, GridBulkMenuActionDef, GridBulkActionsMenuSlotProps, GridCreatorSlotProps, GridSynchronizerSlotProps, GridToolbarSlots, GridToolbarSlotProps, StatusSwitchConfig, StatusSwitchUpdateArgs, } from './types';
6
6
  export { ColumnDataTypesEnum } from './types';
7
7
  export { default as RecordStatusSwitchCell } from './cells/RecordStatusSwitchCell';
8
8
  export { resolveColumnStatusSwitchConfig } from './cells/resolveColumnStatusSwitch';
9
9
  export { default as GridBulkActionsHost } from './toolbar/GridBulkActionsHost';
10
+ export { default as GridBulkActionsMenu } from './toolbar/GridBulkActionsMenu';
10
11
  export type { ExportFormat } from './types';
@@ -0,0 +1,12 @@
1
+ /** MUI DataGrid-compatible client | server processing mode. */
2
+ export type GridProcessingMode = 'client' | 'server';
3
+ export declare const DEFAULT_GRID_PROCESSING_MODE: GridProcessingMode;
4
+ export declare function isServerPagination(mode?: GridProcessingMode): boolean;
5
+ export declare function isServerSorting(mode?: GridProcessingMode): boolean;
6
+ export declare function isServerFiltering(mode?: GridProcessingMode): boolean;
7
+ /** True when any dimension uses server-side processing (triggers query-driven fetch). */
8
+ export declare function usesServerDrivenFetch(flags: {
9
+ paginationMode?: GridProcessingMode;
10
+ sortingMode?: GridProcessingMode;
11
+ filterMode?: GridProcessingMode;
12
+ }): boolean;
@@ -0,0 +1,14 @@
1
+ import { GridBulkActionProps, GridBulkMenuActionDef } from '../types';
2
+ export interface GridBulkActionsMenuProps extends GridBulkActionProps {
3
+ label?: string;
4
+ actions?: GridBulkMenuActionDef[];
5
+ showWhenEmpty?: boolean;
6
+ maxSelection?: number;
7
+ clearSelectionOnSuccess?: boolean;
8
+ /** Compact button for floating selection bar */
9
+ size?: 'small' | 'medium';
10
+ }
11
+ /**
12
+ * Toolbar bulk slot: scrollable menu of actions; each entry may use `component` for custom UI.
13
+ */
14
+ export default function GridBulkActionsMenu({ label, actions, selectedRows, selectedCount, showWhenEmpty, maxSelection, clearSelectionOnSuccess, disabled, size, onRefresh, clearSelection, onAfterSave, }: GridBulkActionsMenuProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,9 @@
1
+ import { GridBulkActionProps, GridBulkMenuActionDef } from '../types';
2
+ interface GridBulkMenuItemHostProps {
3
+ action: GridBulkMenuActionDef;
4
+ ctx: GridBulkActionProps;
5
+ closeMenu: () => void;
6
+ clearSelectionOnSuccess?: boolean;
7
+ }
8
+ export default function GridBulkMenuItemHost({ action, ctx, closeMenu, clearSelectionOnSuccess, }: GridBulkMenuItemHostProps): import("react/jsx-runtime").JSX.Element | null;
9
+ export {};
@@ -108,6 +108,34 @@ export interface GridBulkActionProps {
108
108
  onAfterSave?: () => void;
109
109
  [key: string]: unknown;
110
110
  }
111
+ /** Injected into each bulk menu option sub-component */
112
+ export interface GridBulkMenuItemProps extends GridBulkActionProps {
113
+ actionId: string;
114
+ closeMenu: () => void;
115
+ }
116
+ export interface GridBulkMenuActionDef {
117
+ id: string;
118
+ label: string;
119
+ icon?: React.ReactNode;
120
+ hidden?: (ctx: GridBulkActionProps) => boolean;
121
+ disabled?: boolean | ((ctx: GridBulkActionProps) => boolean);
122
+ dividerBefore?: boolean;
123
+ /** Group label rendered as ListSubheader when it changes between items */
124
+ group?: string;
125
+ confirmMessage?: string | ((ctx: GridBulkActionProps) => string);
126
+ onAction?: (ctx: GridBulkActionProps) => void | Promise<void>;
127
+ /** Dedicated sub-component per menu option (dialogs, wizards, nested UI) */
128
+ component?: React.ComponentType<GridBulkMenuItemProps>;
129
+ }
130
+ export interface GridBulkActionsMenuSlotProps extends Record<string, unknown> {
131
+ showWhenEmpty?: boolean;
132
+ /** Menu title on toolbar button */
133
+ label?: string;
134
+ actions?: GridBulkMenuActionDef[];
135
+ maxSelection?: number;
136
+ clearSelectionOnSuccess?: boolean;
137
+ showInFloatingBar?: boolean;
138
+ }
111
139
  export interface GridCreatorSlotProps {
112
140
  onRefresh: () => void;
113
141
  [key: string]: unknown;
@@ -124,9 +152,7 @@ export interface GridToolbarSlots {
124
152
  actions?: React.ComponentType<Record<string, unknown>>;
125
153
  }
126
154
  export interface GridToolbarSlotProps {
127
- bulkAction?: Record<string, unknown> & {
128
- showWhenEmpty?: boolean;
129
- };
155
+ bulkAction?: GridBulkActionsMenuSlotProps;
130
156
  creator?: Record<string, unknown>;
131
157
  synchronizer?: Record<string, unknown> & {
132
158
  handler?: () => void | Promise<void>;
@@ -290,14 +316,30 @@ export interface AggregationCalculatedParams {
290
316
  /** Current rows used in the calculation. */
291
317
  rows: Row[];
292
318
  }
319
+ export type GridProcessingMode = 'client' | 'server';
320
+ /** Return type for `sourceApi` — `total` supplies server `rowCount` when paginationMode is server. */
321
+ export interface SourceApiResult {
322
+ success: boolean;
323
+ data: Row[];
324
+ /** Total rows matching the current server query (not just the current page). */
325
+ total?: number;
326
+ }
327
+ /**
328
+ * Query payload merged into every `sourceApi` call when server modes are enabled.
329
+ * Extra keys from `apiParameters` are included via index signature.
330
+ */
331
+ export type GMDatagridFetchParams = {
332
+ page?: number;
333
+ pageSize?: number;
334
+ sortStack?: SortKey[];
335
+ filterGroup?: FilterGroup | null;
336
+ search?: string;
337
+ } & Record<string, unknown>;
293
338
  export interface GMDatagridProps {
294
339
  title: string;
295
340
  columns: ColumnDef[];
296
- /** Async data fetcher. Must return `{ success: boolean; data: Row[] }`. */
297
- sourceApi?: (params: Record<string, unknown>) => Promise<{
298
- success: boolean;
299
- data: Row[];
300
- }>;
341
+ /** Async data fetcher. Returns rows for the current query; optional `total` for server pagination. */
342
+ sourceApi?: (params: Record<string, unknown>) => Promise<SourceApiResult>;
301
343
  /** Initial params merged with apiContext on every sourceApi call. */
302
344
  apiParameters?: Record<string, unknown>;
303
345
  /** Provide static rows — skips sourceApi entirely. */
@@ -372,6 +414,11 @@ export interface GMDatagridProps {
372
414
  floatingSelectionBar?: boolean;
373
415
  /** Fired whenever the selection changes. Receives the full array of selected rows. */
374
416
  onRowSelectionChange?: (rows: Row[]) => void;
417
+ /**
418
+ * Stable row id for selection, engine reconcile, and pagination.
419
+ * @default (row) => String(row.id ?? row.uuid ?? '')
420
+ */
421
+ getRowId?: (row: Row) => string;
375
422
  /**
376
423
  * Controls the active page and page size.
377
424
  * Equivalent to MUI DataGrid v9 `paginationModel`.
@@ -409,7 +456,25 @@ export interface GMDatagridProps {
409
456
  * Equivalent to MUI DataGrid v9 `paginationMode`.
410
457
  * @default "client"
411
458
  */
412
- paginationMode?: 'client' | 'server';
459
+ paginationMode?: GridProcessingMode;
460
+ /**
461
+ * `"client"` — Wasm sorts loaded rows (default).
462
+ * `"server"` — `sortStack` is sent to `sourceApi`; sort changes trigger refetch.
463
+ * Equivalent to MUI DataGrid `sortingMode`.
464
+ * @default "client"
465
+ */
466
+ sortingMode?: GridProcessingMode;
467
+ /**
468
+ * `"client"` — Wasm + match-sorter filter loaded rows (default).
469
+ * `"server"` — `filterGroup` and toolbar `search` are sent to `sourceApi`.
470
+ * Equivalent to MUI DataGrid `filterMode`.
471
+ * @default "client"
472
+ */
473
+ filterMode?: GridProcessingMode;
474
+ /**
475
+ * Fired when `sourceApi` returns `total` (controlled `rowCount` pattern, MUI-compatible).
476
+ */
477
+ onRowCountChange?: (rowCount: number) => void;
413
478
  /**
414
479
  * UI label locale for built-in strings (filter operators, tooltips, placeholders).
415
480
  * @default 'es'
@@ -0,0 +1,52 @@
1
+ # Publishing `gm-datagrid` to npm
2
+
3
+ ## Pre-flight (from repo root, Docker)
4
+
5
+ ```bash
6
+ cd /path/to/gm-datagrid
7
+ docker compose up -d
8
+ make publish-check
9
+ ```
10
+
11
+ `publish-check` runs: release Wasm build → `pnpm build` → copy root `CHANGELOG.md` → `pnpm test` → `npm pack --dry-run`.
12
+
13
+ ## Registry status
14
+
15
+ - Package: `gm-datagrid` (public)
16
+ - Version to publish: see `react-wrapper/package.json` (currently **0.1.34**)
17
+ - Latest on npm before this release was **0.1.33**
18
+
19
+ ## Publish (requires npm login + 2FA OTP)
20
+
21
+ From **inside** `rust-dev` (recommended — same env as CI):
22
+
23
+ ```bash
24
+ docker compose exec rust-dev bash
25
+ cd /workspace/react-wrapper
26
+ npm whoami # must succeed
27
+ npm publish --access public
28
+ ```
29
+
30
+ If `prepublishOnly` (`pnpm build`) fails in your shell, publish with dist already built:
31
+
32
+ ```bash
33
+ npm publish --access public --ignore-scripts
34
+ ```
35
+
36
+ With **2FA**, pass OTP on the same command:
37
+
38
+ ```bash
39
+ npm publish --access public --otp=XXXXXX
40
+ ```
41
+
42
+ ## After publish
43
+
44
+ 1. goal-front: `pnpm add gm-datagrid@0.1.34` (or match published version)
45
+ 2. Smoke: server pagination flags (`paginationMode` / `sortingMode` / `filterMode`), bulk menu slot, `valueGetter` + `getRowId`
46
+ 3. Tag git (optional): `git tag gm-datagrid-v0.1.34`
47
+
48
+ ## Tarball contents
49
+
50
+ Published files: `dist/`, `README.md`, `LICENSE`, `CHANGELOG.md`, `docs/` (see `package.json` `files`).
51
+
52
+ `npm pack --dry-run` must list `GridBulkActionsMenu`, engine wasm bundles, and `docs/TOOLBAR_SLOTS.md`.
@@ -2,7 +2,7 @@
2
2
 
3
3
  `GMDatagrid` / `GMGridContainer` accept legacy-compatible `slot` and `slotProps`. The package does **not** implement dialogs, permissions, or app-specific APIs — only injects grid context into your components.
4
4
 
5
- ## Bulk actions
5
+ ## Bulk actions (single host component)
6
6
 
7
7
  ```tsx
8
8
  import { GMDatagrid, type GridBulkActionProps } from 'gm-datagrid';
@@ -10,7 +10,7 @@ import { GMDatagrid, type GridBulkActionProps } from 'gm-datagrid';
10
10
  function BulkMenu({ selectedRows, selectedCount, onRefresh, clearSelection }: GridBulkActionProps) {
11
11
  if (selectedCount === 0) return null;
12
12
  return (
13
- <button type="button" onClick={() => { /* open drawer */ onRefresh(); }}>
13
+ <button type="button" onClick={() => { onRefresh(); }}>
14
14
  Bulk ({selectedCount})
15
15
  </button>
16
16
  );
@@ -25,6 +25,61 @@ function BulkMenu({ selectedRows, selectedCount, onRefresh, clearSelection }: Gr
25
25
  />
26
26
  ```
27
27
 
28
+ ## Bulk actions menu (many options + sub-components)
29
+
30
+ Use **`GridBulkActionsMenu`** when you need a scrollable menu with many mass actions. Each action may define a **`component`** sub-component (dialogs, wizards) or a simple **`onAction`** with optional **`confirmMessage`**.
31
+
32
+ ```tsx
33
+ import {
34
+ GMDatagrid,
35
+ GridBulkActionsMenu,
36
+ type GridBulkMenuActionDef,
37
+ type GridBulkMenuItemProps,
38
+ } from 'gm-datagrid';
39
+
40
+ function ReprocessItem({ selectedRows, selectedCount, closeMenu, onRefresh }: GridBulkMenuItemProps) {
41
+ return (
42
+ <MenuItem
43
+ onClick={() => {
44
+ void doWork(selectedRows).then(() => onRefresh());
45
+ closeMenu();
46
+ }}
47
+ >
48
+ Reprocesar ({selectedCount})
49
+ </MenuItem>
50
+ );
51
+ }
52
+
53
+ const actions: GridBulkMenuActionDef[] = [
54
+ { id: 'reprocess', label: 'Reprocesar', component: ReprocessItem },
55
+ {
56
+ id: 'export',
57
+ label: 'Exportar selección',
58
+ group: 'Datos',
59
+ confirmMessage: (ctx) => `¿Exportar ${ctx.selectedCount} filas?`,
60
+ onAction: async ({ selectedRows, onRefresh }) => {
61
+ await exportRows(selectedRows);
62
+ onRefresh();
63
+ },
64
+ },
65
+ ];
66
+
67
+ <GMDatagrid
68
+ slot={{ bulkAction: GridBulkActionsMenu }}
69
+ slotProps={{
70
+ bulkAction: {
71
+ label: 'Acciones masivas',
72
+ actions,
73
+ clearSelectionOnSuccess: true,
74
+ showInFloatingBar: true,
75
+ maxSelection: 500,
76
+ },
77
+ }}
78
+ />
79
+ ```
80
+
81
+ `selectedRows` comes from `getSelectedRows()` (full dataset, **raw API rows** after 0.1.33 reconcile). Use `getRowId` for uuid-keyed lists.
82
+
28
83
  `autoCheckboxSelection` defaults to `true`: when `slot.bulkAction` is set, row checkboxes are enabled automatically.
29
84
 
30
85
  ## Creator
@@ -65,4 +120,4 @@ function CreateControl({ onRefresh, title }: { onRefresh: () => void; title?: st
65
120
 
66
121
  Bulk components can use `useGMGrid()` inside the grid tree:
67
122
 
68
- - `getSelectedRows()`, `selectedCount`, `handleRefresh`, `clearSelection`, `data`, `getRows()`
123
+ - `getSelectedRows()`, `selectedCount`, `handleRefresh`, `clearSelection`, `data`, `getRows()`, `getRowId(row)`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-datagrid",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "Enterprise Excel-like data grid with Rust/Wasm engine, featuring inline-aligned group subtotals and automatic group aggregate preloading",
5
5
  "keywords": [
6
6
  "datagrid",