gm-datagrid 0.1.31 → 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.
@@ -0,0 +1,6 @@
1
+ import { Row } from '../types';
2
+ import { GetRowIdFn } from './resolveGridRowId';
3
+ /**
4
+ * Maps Wasm page rows back to the original source rows so UI never sees getter-mutated fields.
5
+ */
6
+ export declare function reconcilePageRows(sourceRows: Row[], engineRows: Row[], getRowId?: GetRowIdFn): Row[];
@@ -0,0 +1,4 @@
1
+ import { Row } from '../types';
2
+ export type GetRowIdFn = (row: Row) => string;
3
+ /** Default row key for reconcile / selection (override with `getRowId` prop). */
4
+ export declare function defaultGetRowId(row: Row): string;
@@ -0,0 +1,9 @@
1
+ import { ColumnDef, Row } from '../types';
2
+ /**
3
+ * Convert a single cell value to a type the Rust CellValue enum can accept.
4
+ */
5
+ export declare function toCellValue(v: unknown): string | number | boolean | null;
6
+ /**
7
+ * Build engine rows: apply column valueGetters on a copy; never mutate input rows.
8
+ */
9
+ export declare function sanitizeRowsForEngine(rows: Row[], columns: ColumnDef[]): Record<string, string | number | boolean | null>[];
@@ -1,34 +1,20 @@
1
1
  import { ColumnDef, FilterGroup, GroupHeader, Row, SortKey } from '../types';
2
+ import { GetRowIdFn } from './resolveGridRowId';
2
3
  interface UseEngineSyncProps {
3
4
  engine: any;
4
5
  ready: boolean;
5
6
  rows: Row[];
6
7
  columns: ColumnDef[];
8
+ getRowId?: GetRowIdFn;
7
9
  onSynced: (totalCount: number, subtotals: Record<string, number>) => void;
8
10
  page: number;
9
11
  pageSize: number;
10
12
  onPageData: (rows: Row[]) => void;
11
- /** Applied atomically right after load_data — avoids calling engine methods before data is loaded. */
12
13
  sortStack?: SortKey[];
13
14
  filterGroup?: FilterGroup | null;
14
15
  quickFilterText?: string;
15
- /** When set, calls engine.set_group_by() and fires onGroups with the resulting headers. */
16
16
  groupBy?: string | null;
17
17
  onGroups?: (groups: GroupHeader[]) => void;
18
18
  }
19
- /**
20
- * Syncs React state → Wasm engine (push) and pulls page data + subtotals back.
21
- *
22
- * IMPORTANT: push and pull are intentionally in ONE effect, not two.
23
- * wasm-bindgen wraps GridEngine methods with a runtime borrow-check on `&mut self`.
24
- * Two separate effects that both call engine methods can fire in the same
25
- * synchronous React flush — the second effect starts before wasm-bindgen has
26
- * released the `&mut` borrow from the first, triggering:
27
- * "recursive use of an object detected which would lead to unsafe aliasing in rust"
28
- *
29
- * Keeping everything in a single effect guarantees all engine calls are sequential
30
- * within one borrow, and the pull (get_page / get_subtotals) always sees the
31
- * data that was just loaded.
32
- */
33
- export declare function useEngineSync({ engine, ready, rows, columns, onSynced, page, pageSize, onPageData, sortStack, filterGroup, quickFilterText, groupBy, onGroups, }: UseEngineSyncProps): void;
19
+ export declare function useEngineSync({ engine, ready, rows, columns, getRowId, onSynced, page, pageSize, onPageData, sortStack, filterGroup, quickFilterText, groupBy, onGroups, }: UseEngineSyncProps): void;
34
20
  export {};