gm-datagrid 0.1.3 → 0.1.5
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/context/GridContext.d.ts +7 -1
- package/dist/engine/useEngineSync.d.ts +14 -8
- package/dist/gm-datagrid.js +1932 -1622
- package/dist/gm-datagrid.umd.cjs +9 -9
- package/dist/toolbar/GridToolbar.d.ts +11 -0
- package/dist/types/index.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { Row } from '../types';
|
|
2
|
+
import { GroupHeader, Row } from '../types';
|
|
3
3
|
import { DataSetState } from '../dataset/useGMDataSet';
|
|
4
4
|
interface GridContextValue extends DataSetState {
|
|
5
5
|
pageRows: Row[];
|
|
@@ -12,6 +12,12 @@ interface GridContextValue extends DataSetState {
|
|
|
12
12
|
engineReady: boolean;
|
|
13
13
|
engineError: Error | null;
|
|
14
14
|
retryEngine: () => void;
|
|
15
|
+
groupBy: string | null;
|
|
16
|
+
setGroupBy: (field: string | null) => void;
|
|
17
|
+
groups: GroupHeader[];
|
|
18
|
+
expandedGroups: Set<string>;
|
|
19
|
+
groupRows: Record<string, Row[]>;
|
|
20
|
+
toggleGroup: (key: string) => void;
|
|
15
21
|
}
|
|
16
22
|
interface GridProviderProps {
|
|
17
23
|
dataset: DataSetState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnDef, FilterGroup, Row, SortKey } from '../types';
|
|
1
|
+
import { ColumnDef, FilterGroup, GroupHeader, Row, SortKey } from '../types';
|
|
2
2
|
interface UseEngineSyncProps {
|
|
3
3
|
engine: any;
|
|
4
4
|
ready: boolean;
|
|
@@ -12,17 +12,23 @@ interface UseEngineSyncProps {
|
|
|
12
12
|
sortStack?: SortKey[];
|
|
13
13
|
filterGroup?: FilterGroup | null;
|
|
14
14
|
quickFilterText?: string;
|
|
15
|
+
/** When set, calls engine.set_group_by() and fires onGroups with the resulting headers. */
|
|
16
|
+
groupBy?: string | null;
|
|
17
|
+
onGroups?: (groups: GroupHeader[]) => void;
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
20
|
* Syncs React state → Wasm engine (push) and pulls page data + subtotals back.
|
|
18
21
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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"
|
|
23
28
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
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.
|
|
26
32
|
*/
|
|
27
|
-
export declare function useEngineSync({ engine, ready, rows, columns, onSynced, page, pageSize, onPageData, sortStack, filterGroup, quickFilterText, }: UseEngineSyncProps): void;
|
|
33
|
+
export declare function useEngineSync({ engine, ready, rows, columns, onSynced, page, pageSize, onPageData, sortStack, filterGroup, quickFilterText, groupBy, onGroups, }: UseEngineSyncProps): void;
|
|
28
34
|
export {};
|