gm-datagrid 0.1.22 → 0.1.24
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/README.md +35 -9
- package/dist/cells/EditCell.d.ts +5 -3
- package/dist/cells/RecordStatusSwitchCell.d.ts +14 -0
- package/dist/cells/resolveColumnStatusSwitch.d.ts +5 -0
- package/dist/columns/useResolvedColumns.d.ts +5 -0
- package/dist/context/GridContext.d.ts +5 -0
- package/dist/core_engine-CUZl08WL.js +431 -0
- package/dist/dataset/useGMDataSet.d.ts +6 -0
- package/dist/features/useAggregation.d.ts +23 -13
- package/dist/features/useInlineEdit.d.ts +39 -17
- package/dist/gm-datagrid.js +8341 -7250
- package/dist/gm-datagrid.umd.cjs +53 -50
- package/dist/index.d.ts +4 -1
- package/dist/toolbar/GridBulkActionsHost.d.ts +12 -0
- package/dist/toolbar/GridToolbar.d.ts +5 -1
- package/dist/toolbar/GridToolbarCreator.d.ts +11 -0
- package/dist/toolbar/GridToolbarSynchronizer.d.ts +10 -0
- package/dist/toolbar/MobileToolbar.d.ts +5 -1
- package/dist/types/index.d.ts +168 -7
- package/docs/MIGRATION_LEGACY_GMGRID.md +20 -0
- package/docs/STATUS_SWITCH.md +37 -0
- package/docs/TOOLBAR_SLOTS.md +68 -0
- package/package.json +73 -71
- package/dist/core_engine-21HtFNxu.js +0 -360
|
@@ -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.
|
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { AggregationFunction, AggregationModel, AggregationResults, ColumnDef, Row } from '../types';
|
|
3
3
|
interface UseAggregationProps {
|
|
4
|
-
/** Grid root engine ref (same one used by useExport). */
|
|
5
4
|
engineRef: React.RefObject<unknown>;
|
|
6
5
|
columns: ColumnDef[];
|
|
7
|
-
/** { field: 'sum' | 'avg' | ... } — only entries here produce footer cells. */
|
|
8
6
|
aggregationModel: AggregationModel;
|
|
9
|
-
/** When false the hook is a no-op. */
|
|
10
7
|
enabled: boolean;
|
|
8
|
+
rows?: Row[];
|
|
9
|
+
dataVersion?: number;
|
|
11
10
|
}
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Returns the aggregation functions available for a column based on its type.
|
|
13
|
+
* Used to populate the picker and to auto-derive the initial aggregation model
|
|
14
|
+
* for columns with `calculateSubTotal: true`.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* | Column type | Available functions |
|
|
17
|
+
* |--------------------------|--------------------------------------------|
|
|
18
|
+
* | numeric | sum, avg, min, max, count |
|
|
19
|
+
* | date / dateTime | min, max, count-distinct, count |
|
|
20
|
+
* | boolean / active | count-true, count-false, count |
|
|
21
|
+
* | status / labels | count-distinct, count |
|
|
22
|
+
* | string (default) | min, max, count-distinct, count |
|
|
19
23
|
*/
|
|
20
|
-
export declare function
|
|
21
|
-
/**
|
|
24
|
+
export declare function getDefaultAvailableFns(col: ColumnDef): AggregationFunction[];
|
|
25
|
+
/** Returns the best default aggregation function for a column (first of its type defaults). */
|
|
26
|
+
export declare function getDefaultAggFn(col: ColumnDef): AggregationFunction;
|
|
27
|
+
/** Short symbol shown inside the aggregation pill in the column header. */
|
|
22
28
|
export declare function aggFnLabel(fn: AggregationFunction): string;
|
|
23
29
|
/**
|
|
24
|
-
* Computes aggregated values
|
|
25
|
-
*
|
|
26
|
-
|
|
30
|
+
* Computes aggregated footer values from the full filtered+sorted dataset.
|
|
31
|
+
* Only processes columns present in `aggregationModel`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useAggregation({ engineRef, columns, aggregationModel, enabled, rows: passedRows, dataVersion, }: UseAggregationProps): AggregationResults;
|
|
34
|
+
/**
|
|
35
|
+
* Computes per-group aggregated values.
|
|
36
|
+
* Uses the pre-fetched `groupRows` map.
|
|
27
37
|
*/
|
|
28
38
|
export declare function useGroupAggregations({ groupRows, columns, aggregationModel, enabled, }: {
|
|
29
39
|
groupRows: Record<string, Row[]>;
|
|
@@ -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
|
|
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
|
|
57
|
+
* Manages cell, row, and complete inline editing.
|
|
30
58
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
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 {};
|