gm-datagrid 0.1.32 → 0.1.33
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 +91 -0
- package/dist/context/GridContext.d.ts +4 -1
- package/dist/engine/reconcilePageRows.d.ts +6 -0
- package/dist/engine/resolveGridRowId.d.ts +4 -0
- package/dist/engine/sanitizeRowsForEngine.d.ts +9 -0
- package/dist/engine/useEngineSync.d.ts +3 -17
- package/dist/gm-datagrid.js +6492 -6242
- package/dist/gm-datagrid.umd.cjs +36 -36
- package/dist/index.d.ts +2 -1
- package/dist/toolbar/GridBulkActionsMenu.d.ts +14 -0
- package/dist/toolbar/GridBulkMenuItemHost.d.ts +9 -0
- package/dist/types/index.d.ts +34 -3
- package/docs/PUBLISH.md +52 -0
- package/docs/TOOLBAR_SLOTS.md +58 -3
- package/package.json +1 -1
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, 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,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 {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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?:
|
|
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>;
|
|
@@ -372,6 +398,11 @@ export interface GMDatagridProps {
|
|
|
372
398
|
floatingSelectionBar?: boolean;
|
|
373
399
|
/** Fired whenever the selection changes. Receives the full array of selected rows. */
|
|
374
400
|
onRowSelectionChange?: (rows: Row[]) => void;
|
|
401
|
+
/**
|
|
402
|
+
* Stable row id for selection, engine reconcile, and pagination.
|
|
403
|
+
* @default (row) => String(row.id ?? row.uuid ?? '')
|
|
404
|
+
*/
|
|
405
|
+
getRowId?: (row: Row) => string;
|
|
375
406
|
/**
|
|
376
407
|
* Controls the active page and page size.
|
|
377
408
|
* Equivalent to MUI DataGrid v9 `paginationModel`.
|
package/docs/PUBLISH.md
ADDED
|
@@ -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.33**)
|
|
17
|
+
- Latest on npm before this release was **0.1.32**
|
|
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.33` (or match published version)
|
|
45
|
+
2. Smoke: import templates grid, bulk menu slot, list with `valueGetter` + `getRowId`
|
|
46
|
+
3. Tag git (optional): `git tag gm-datagrid-v0.1.33`
|
|
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`.
|
package/docs/TOOLBAR_SLOTS.md
CHANGED
|
@@ -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={() => {
|
|
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