gm-datagrid 0.1.23 → 0.1.25

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.
@@ -11,10 +11,12 @@ interface UseGMDataSetProps {
11
11
  }
12
12
  export interface DataSetState {
13
13
  rows: Row[];
14
+ originalRows: Row[];
14
15
  loading: boolean;
15
16
  error: string | null;
16
17
  ready: boolean;
17
18
  columns: ColumnDef[];
19
+ dataVersion: number;
18
20
  handleRefresh: () => void;
19
21
  setApiParameters: (params: Record<string, unknown>) => void;
20
22
  /** Push a new sort stack to the Wasm engine ref held by GridContext. */
@@ -24,6 +26,10 @@ export interface DataSetState {
24
26
  setFilterGroup: (group: FilterGroup | null) => void;
25
27
  quickFilterText: string;
26
28
  setQuickFilterText: (text: string) => void;
29
+ updateRow: (updatedRow: Row) => void;
30
+ updateRows: (updatedRows: Row[]) => void;
31
+ revertRow: (id: string | number) => void;
32
+ revertAll: () => void;
27
33
  }
28
34
  /**
29
35
  * Mirrors the legacy `useGMDataSet` hook API.
@@ -5,6 +5,8 @@ interface UseAggregationProps {
5
5
  columns: ColumnDef[];
6
6
  aggregationModel: AggregationModel;
7
7
  enabled: boolean;
8
+ rows?: Row[];
9
+ dataVersion?: number;
8
10
  }
9
11
  /**
10
12
  * Returns the aggregation functions available for a column based on its type.
@@ -28,7 +30,7 @@ export declare function aggFnLabel(fn: AggregationFunction): string;
28
30
  * Computes aggregated footer values from the full filtered+sorted dataset.
29
31
  * Only processes columns present in `aggregationModel`.
30
32
  */
31
- export declare function useAggregation({ engineRef, columns, aggregationModel, enabled, }: UseAggregationProps): AggregationResults;
33
+ export declare function useAggregation({ engineRef, columns, aggregationModel, enabled, rows: passedRows, dataVersion, }: UseAggregationProps): AggregationResults;
32
34
  /**
33
35
  * Computes per-group aggregated values.
34
36
  * Uses the pre-fetched `groupRows` map.
@@ -1,45 +1,67 @@
1
- import { CellCoord, CellEditParams, ColumnDef, Row } from '../types';
1
+ import { AfterCellEditParams, CellCoord, CellEditParams, ColumnDef, EditMode, Row, RowEditParams } from '../types';
2
2
  interface UseInlineEditProps {
3
3
  visibleRows: Row[];
4
+ allRows?: Row[];
4
5
  columns: ColumnDef[];
5
- engine: any;
6
+ engine?: any;
6
7
  engineReady: boolean;
8
+ updateRow?: (row: Row) => void;
7
9
  processRowUpdate?: (newRow: Row, oldRow: Row) => Row | Promise<Row>;
8
10
  onCellError: (rowId: string, message: string) => void;
9
11
  /** Fired when a cell enters edit mode (MUI DataGrid compatible). */
10
12
  onCellEditStart?: (params: CellEditParams) => void;
11
13
  /** Fired when a cell exits edit mode (MUI DataGrid compatible). */
12
14
  onCellEditStop?: (params: CellEditParams) => void;
15
+ /** Fired when a row enters edit mode (`editMode="row"`). */
16
+ onRowEditStart?: (params: RowEditParams) => void;
17
+ /** Fired when a row exits edit mode (`editMode="row"`). */
18
+ onRowEditStop?: (params: RowEditParams) => void;
19
+ /**
20
+ * Fired after a cell is edited/changed.
21
+ * Can return a partial row or call `params.updateRowValues` to update other columns in the same row.
22
+ */
23
+ onAfterCellEdit?: (params: AfterCellEditParams) => Partial<Row> | Row | void | Promise<Partial<Row> | Row | void>;
13
24
  /** Per-cell editability guard — return false to block editing. */
14
25
  isCellEditable?: (params: CellEditParams) => boolean;
15
26
  /** Global editable flag — when false, no cell can be edited. */
16
27
  editableFlag?: boolean;
17
28
  /** Whitelist of editable fields — overrides per-column editable flag when set. */
18
29
  editableSet?: Set<string> | null;
30
+ /** Edit mode: 'cell' | 'row' | 'complete'. Default: 'cell'. */
31
+ editMode?: EditMode;
32
+ /** Original baseline rows before any modifications. */
33
+ originalRows?: Row[];
34
+ /** When true, track old values for badge display. */
35
+ displayOldEditedValues?: boolean;
19
36
  }
20
- interface InlineEditState {
37
+ export interface InlineEditState {
38
+ editMode: EditMode;
39
+ setEditMode: (mode: EditMode) => void;
21
40
  editingCell: CellCoord | null;
22
41
  editValue: string;
23
42
  startEditing: (cell: CellCoord, initialChar?: string) => void;
24
43
  stopEditing: (save: boolean) => Promise<void>;
25
44
  setEditValue: (v: string) => void;
45
+ editingRowId: string | null;
46
+ rowDraft: Row | null;
47
+ startRowEditing: (rowId: string | number) => void;
48
+ stopRowEditing: (rowId: string | number, save: boolean) => Promise<void>;
49
+ setRowDraftValue: (field: string, value: unknown) => Promise<void>;
50
+ completeDrafts: Record<string, Row>;
51
+ handleCellChange: (rowId: string | number, field: string, value: unknown) => Promise<void>;
52
+ isFieldModified: (rowId: string | number, field: string) => boolean;
53
+ getOldValue: (rowId: string | number, field: string) => unknown;
26
54
  cellErrors: Record<string, string>;
27
55
  }
28
56
  /**
29
- * Manages Excel-like inline cell editing.
57
+ * Manages cell, row, and complete inline editing.
30
58
  *
31
- * Fires MUI DataGrid-compatible events:
32
- * onCellEditStart({ id, field, value, row }) — when a cell enters edit mode
33
- * onCellEditStop({ id, field, value, row }) — when a cell exits edit mode
34
- *
35
- * Editability hierarchy (all must pass):
36
- * 1. editableFlag (global feature flag, default false)
37
- * 2. editableSet (column whitelist from editableColumns prop)
38
- * 3. col.editable (per-column ColumnDef flag)
39
- * 4. isCellEditable(params) (per-row/cell callback)
40
- *
41
- * On save: calls processRowUpdate (async), reverts on rejection.
42
- * On escape: discards changes.
59
+ * Supports:
60
+ * 1. Cell edit mode (`editMode="cell"`) — standard Excel-like single cell editing.
61
+ * 2. Row edit mode (`editMode="row"`) — entire row enters edit mode with multiple editable inputs.
62
+ * 3. Complete edit mode (`editMode="complete"`) — all rows and editable cells active simultaneously.
63
+ * 4. After-cell-edit event (`onAfterCellEdit`) — allows updating other columns in the row.
64
+ * 5. Tracking old values and displaying them via MUI Badge (`displayOldEditedValues`).
43
65
  */
44
- export declare function useInlineEdit({ visibleRows, columns, engine, engineReady, processRowUpdate, onCellError, onCellEditStart, onCellEditStop, isCellEditable, editableFlag, editableSet, }: UseInlineEditProps): InlineEditState;
66
+ export declare function useInlineEdit({ visibleRows, allRows, columns, engine, engineReady, updateRow, processRowUpdate, onCellError, onCellEditStart, onCellEditStop, onRowEditStart, onRowEditStop, onAfterCellEdit, isCellEditable, editableFlag, editableSet, editMode: initialEditMode, originalRows, displayOldEditedValues, }: UseInlineEditProps): InlineEditState;
45
67
  export {};