ag-grid-url-sync 0.5.1 → 0.5.2
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 +244 -26
- package/dist/core/ag-grid-url-sync.d.ts +6 -0
- package/dist/core/ag-grid-url-sync.js.map +1 -1
- package/dist/core/codecs.d.ts +28 -0
- package/dist/core/codecs.js +39 -0
- package/dist/core/codecs.js.map +1 -0
- package/dist/core/data-issue-codes.d.ts +3 -0
- package/dist/core/data-issue-codes.js +10 -0
- package/dist/core/data-issue-codes.js.map +1 -0
- package/dist/core/grid-integration.d.ts +11 -1
- package/dist/core/grid-integration.js +20 -11
- package/dist/core/grid-integration.js.map +1 -1
- package/dist/core/grid-url-sync.d.ts +62 -0
- package/dist/core/grid-url-sync.js +738 -0
- package/dist/core/grid-url-sync.js.map +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/issues.d.ts +2 -2
- package/dist/core/issues.js +2 -9
- package/dist/core/issues.js.map +1 -1
- package/dist/core/own-write.d.ts +138 -0
- package/dist/core/own-write.js +133 -0
- package/dist/core/own-write.js.map +1 -0
- package/dist/core/types.d.ts +151 -4
- package/dist/core/types.js +4 -0
- package/dist/core/types.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/sync-holder.d.ts +22 -0
- package/dist/react/sync-holder.js +68 -0
- package/dist/react/sync-holder.js.map +1 -0
- package/dist/react/sync-options.d.ts +17 -0
- package/dist/react/sync-options.js +22 -0
- package/dist/react/sync-options.js.map +1 -0
- package/dist/react/types.d.ts +71 -3
- package/dist/react/use-ag-grid-url-sync.d.ts +3 -0
- package/dist/react/use-ag-grid-url-sync.js +310 -526
- package/dist/react/use-ag-grid-url-sync.js.map +1 -1
- package/dist/react/use-grid-url-sync.d.ts +14 -0
- package/dist/react/use-grid-url-sync.js +206 -0
- package/dist/react/use-grid-url-sync.js.map +1 -0
- package/package.json +16 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAGzE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAE1E,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAEtD,cAAc,iBAAiB,CAAA;AAG/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGlD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAGxE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAGvE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAS7E,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,iCAAiC,CAAA;AAExC,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EACjB,MAAM,iCAAiC,CAAA"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
export { useGridUrlSync } from './use-grid-url-sync.js';
|
|
1
2
|
export { useAGGridUrlSync } from './use-ag-grid-url-sync.js';
|
|
2
|
-
export type { UseAGGridUrlSyncOptions, UseAGGridUrlSyncReturn } from './types.js';
|
|
3
|
+
export type { UseGridUrlSyncOptions, UseGridUrlSyncResult, UseAGGridUrlSyncOptions, UseAGGridUrlSyncReturn } from './types.js';
|
|
3
4
|
export type { GridView } from '../core/view-storage.js';
|
|
4
|
-
export type { FilterState, ColumnFilter, FilterOperation, AGGridUrlSyncConfig, GridApi } from '../core/types.js';
|
|
5
|
+
export type { FilterState, ColumnFilter, FilterOperation, AGGridUrlSyncConfig, GridApi, HistoryMode } from '../core/types.js';
|
package/dist/react/index.js
CHANGED
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAGvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { GridUrlSync, GridUrlSyncSnapshot, URLSyncError } from '../core/types.js';
|
|
2
|
+
import type { GridView } from '../core/view-storage.js';
|
|
3
|
+
export interface SyncHolder {
|
|
4
|
+
/** Puts a sync in the holder (or none). Does not destroy the old one. */
|
|
5
|
+
set(sync: GridUrlSync | null): void;
|
|
6
|
+
/** The current sync, or null */
|
|
7
|
+
get(): GridUrlSync | null;
|
|
8
|
+
/**
|
|
9
|
+
* The stored views to show while there is no sync (#223). The listeners
|
|
10
|
+
* hear of it only when no sync is in the holder and the views changed.
|
|
11
|
+
*/
|
|
12
|
+
setIdleViews(views: readonly GridView[]): void;
|
|
13
|
+
/**
|
|
14
|
+
* The apply issues of an earlier sync on the same grid. The snapshot of
|
|
15
|
+
* the current sync shows them before its own issues.
|
|
16
|
+
*/
|
|
17
|
+
setCarriedIssues(issues: readonly URLSyncError[]): void;
|
|
18
|
+
subscribe(listener: () => void): () => void;
|
|
19
|
+
/** The current sync's snapshot, or the idle snapshot */
|
|
20
|
+
getSnapshot(): GridUrlSyncSnapshot;
|
|
21
|
+
}
|
|
22
|
+
export declare function createSyncHolder(): SyncHolder;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { IDLE_SNAPSHOT } from '../core/grid-url-sync.js';
|
|
2
|
+
function sameViews(a, b) {
|
|
3
|
+
return a.length === b.length && JSON.stringify(a) === JSON.stringify(b);
|
|
4
|
+
}
|
|
5
|
+
export function createSyncHolder() {
|
|
6
|
+
const listeners = new Set();
|
|
7
|
+
let current = null;
|
|
8
|
+
let stopForwarding = null;
|
|
9
|
+
let idle = IDLE_SNAPSHOT;
|
|
10
|
+
let carried = [];
|
|
11
|
+
let merged = null;
|
|
12
|
+
const withCarried = (from) => {
|
|
13
|
+
if (merged?.from === from && merged.carried === carried) {
|
|
14
|
+
return merged.snapshot;
|
|
15
|
+
}
|
|
16
|
+
const issues = merged?.from.issues === from.issues && merged.carried === carried
|
|
17
|
+
? merged.snapshot.issues
|
|
18
|
+
: Object.freeze([...carried, ...from.issues]);
|
|
19
|
+
merged = { from, carried, snapshot: Object.freeze({ ...from, issues }) };
|
|
20
|
+
return merged.snapshot;
|
|
21
|
+
};
|
|
22
|
+
const notify = () => {
|
|
23
|
+
for (const listener of Array.from(listeners))
|
|
24
|
+
listener();
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
set(sync) {
|
|
28
|
+
if (sync === current)
|
|
29
|
+
return;
|
|
30
|
+
stopForwarding?.();
|
|
31
|
+
stopForwarding = null;
|
|
32
|
+
current = sync;
|
|
33
|
+
if (sync)
|
|
34
|
+
stopForwarding = sync.subscribe(notify);
|
|
35
|
+
notify();
|
|
36
|
+
},
|
|
37
|
+
get: () => current,
|
|
38
|
+
setIdleViews(views) {
|
|
39
|
+
if (sameViews(idle.views, views))
|
|
40
|
+
return;
|
|
41
|
+
idle = views.length
|
|
42
|
+
? Object.freeze({ ...IDLE_SNAPSHOT, views: Object.freeze([...views]) })
|
|
43
|
+
: IDLE_SNAPSHOT;
|
|
44
|
+
if (!current)
|
|
45
|
+
notify();
|
|
46
|
+
},
|
|
47
|
+
setCarriedIssues(issues) {
|
|
48
|
+
if (issues === carried)
|
|
49
|
+
return;
|
|
50
|
+
carried = issues;
|
|
51
|
+
if (current)
|
|
52
|
+
notify();
|
|
53
|
+
},
|
|
54
|
+
subscribe(listener) {
|
|
55
|
+
listeners.add(listener);
|
|
56
|
+
return () => {
|
|
57
|
+
listeners.delete(listener);
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
getSnapshot() {
|
|
61
|
+
if (!current)
|
|
62
|
+
return idle;
|
|
63
|
+
const snapshot = current.getSnapshot();
|
|
64
|
+
return carried.length ? withCarried(snapshot) : snapshot;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=sync-holder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-holder.js","sourceRoot":"","sources":["../../src/react/sync-holder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAqCxD,SAAS,SAAS,CAAC,CAAsB,EAAE,CAAsB;IAC/D,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;AACzE,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;IACvC,IAAI,OAAO,GAAuB,IAAI,CAAA;IACtC,IAAI,cAAc,GAAwB,IAAI,CAAA;IAC9C,IAAI,IAAI,GAAwB,aAAa,CAAA;IAC7C,IAAI,OAAO,GAA4B,EAAE,CAAA;IAGzC,IAAI,MAAM,GAIC,IAAI,CAAA;IAGf,MAAM,WAAW,GAAG,CAAC,IAAyB,EAAuB,EAAE;QACrE,IAAI,MAAM,EAAE,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;YACxD,OAAO,MAAM,CAAC,QAAQ,CAAA;QACxB,CAAC;QAGD,MAAM,MAAM,GACV,MAAM,EAAE,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO;YAC/D,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM;YACxB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;QAEjD,MAAM,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAA;QAExE,OAAO,MAAM,CAAC,QAAQ,CAAA;IACxB,CAAC,CAAA;IAED,MAAM,MAAM,GAAG,GAAS,EAAE;QACxB,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;YAAE,QAAQ,EAAE,CAAA;IAC1D,CAAC,CAAA;IAED,OAAO;QACL,GAAG,CAAC,IAAI;YACN,IAAI,IAAI,KAAK,OAAO;gBAAE,OAAM;YAE5B,cAAc,EAAE,EAAE,CAAA;YAClB,cAAc,GAAG,IAAI,CAAA;YACrB,OAAO,GAAG,IAAI,CAAA;YAEd,IAAI,IAAI;gBAAE,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;YAEjD,MAAM,EAAE,CAAA;QACV,CAAC;QACD,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO;QAClB,YAAY,CAAC,KAAK;YAChB,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC;gBAAE,OAAM;YAExC,IAAI,GAAG,KAAK,CAAC,MAAM;gBACjB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;gBACvE,CAAC,CAAC,aAAa,CAAA;YAEjB,IAAI,CAAC,OAAO;gBAAE,MAAM,EAAE,CAAA;QACxB,CAAC;QACD,gBAAgB,CAAC,MAAM;YACrB,IAAI,MAAM,KAAK,OAAO;gBAAE,OAAM;YAE9B,OAAO,GAAG,MAAM,CAAA;YAEhB,IAAI,OAAO;gBAAE,MAAM,EAAE,CAAA;QACvB,CAAC;QACD,SAAS,CAAC,QAAQ;YAChB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAEvB,OAAO,GAAG,EAAE;gBACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAC5B,CAAC,CAAA;QACH,CAAC;QACD,WAAW;YACT,IAAI,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAA;YAEzB,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAA;YAEtC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;QAC1D,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GridApi } from 'ag-grid-community';
|
|
2
|
+
import type { AGGridUrlSyncConfig, GridUrlSyncOptions, HistoryMode, IssueEvent } from '../core/types.js';
|
|
3
|
+
import type { ViewStore } from '../core/view-storage.js';
|
|
4
|
+
/** The address-bar options of the hook's sync (#270) */
|
|
5
|
+
export interface AddressBarOptions {
|
|
6
|
+
history: HistoryMode;
|
|
7
|
+
popstate: boolean | undefined;
|
|
8
|
+
}
|
|
9
|
+
/** The default: the sync never writes history and never follows popstate */
|
|
10
|
+
export declare const NO_ADDRESS_BAR: AddressBarOptions;
|
|
11
|
+
/**
|
|
12
|
+
* The createGridUrlSync options for the hook. The hook's sync never throws.
|
|
13
|
+
* It writes history and follows popstate only with the hook's options
|
|
14
|
+
* (#270). It applies the URL on create only when the hook asks for it
|
|
15
|
+
* (auto-apply with saved views, #223).
|
|
16
|
+
*/
|
|
17
|
+
export declare function gridUrlSyncOptions(api: GridApi, options: AGGridUrlSyncConfig, onIssue: (event: IssueEvent) => void, views?: ViewStore, applyUrlOnCreate?: boolean, addressBar?: AddressBarOptions): GridUrlSyncOptions;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { codecFromOptions } from '../core/codecs.js';
|
|
2
|
+
import { resolveOptions } from '../core/options.js';
|
|
3
|
+
export const NO_ADDRESS_BAR = {
|
|
4
|
+
history: 'none',
|
|
5
|
+
popstate: false
|
|
6
|
+
};
|
|
7
|
+
export function gridUrlSyncOptions(api, options, onIssue, views, applyUrlOnCreate = false, addressBar = NO_ADDRESS_BAR) {
|
|
8
|
+
const resolved = resolveOptions(options);
|
|
9
|
+
const codec = codecFromOptions(resolved);
|
|
10
|
+
return {
|
|
11
|
+
api,
|
|
12
|
+
codec,
|
|
13
|
+
maxValueLength: resolved.maxValueLength,
|
|
14
|
+
history: addressBar.history,
|
|
15
|
+
popstate: addressBar.popstate,
|
|
16
|
+
applyUrlOnCreate,
|
|
17
|
+
throwOnError: false,
|
|
18
|
+
onIssue,
|
|
19
|
+
views
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=sync-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-options.js","sourceRoot":"","sources":["../../src/react/sync-options.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAYnD,MAAM,CAAC,MAAM,cAAc,GAAsB;IAC/C,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,KAAK;CAChB,CAAA;AAQD,MAAM,UAAU,kBAAkB,CAChC,GAAY,EACZ,OAA4B,EAC5B,OAAoC,EACpC,KAAiB,EACjB,gBAAgB,GAAG,KAAK,EACxB,UAAU,GAAsB,cAAc;IAE9C,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;IAIxC,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IAExC,OAAO;QACL,GAAG;QACH,KAAK;QACL,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,gBAAgB;QAChB,YAAY,EAAE,KAAK;QACnB,OAAO;QACP,KAAK;KACN,CAAA;AACH,CAAC"}
|
package/dist/react/types.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GridApi } from 'ag-grid-community';
|
|
2
|
+
import type { AGGridUrlSyncConfig, ApplyResult, FilterState, GridUrlSyncOptions, GridUrlSyncSnapshot, HistoryMode, SerializationFormat, SerializationMode, URLSyncError } from '../core/types.js';
|
|
2
3
|
import type { GridView } from '../core/view-storage.js';
|
|
3
4
|
/**
|
|
4
5
|
* Configuration options for the React hook
|
|
6
|
+
*
|
|
7
|
+
* @deprecated Use `useGridUrlSync` and its types. Removed in 0.6.0.
|
|
5
8
|
*/
|
|
6
9
|
export interface UseAGGridUrlSyncOptions extends AGGridUrlSyncConfig {
|
|
7
10
|
/**
|
|
@@ -40,6 +43,24 @@ export interface UseAGGridUrlSyncOptions extends AGGridUrlSyncConfig {
|
|
|
40
43
|
* Default: true
|
|
41
44
|
*/
|
|
42
45
|
enabledWhenReady?: boolean | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* How a filter change goes to the address bar, as in `createGridUrlSync`
|
|
48
|
+
* (#270). A user edit, a view load, `applyFilters` and `clearFilters`
|
|
49
|
+
* write the URL. A URL apply (auto-apply, `applyUrlFilters`, the back
|
|
50
|
+
* button) writes nothing, because the URL holds those filters already.
|
|
51
|
+
* `'replace'` and `'push'` use `window.history`. A function gets the URL,
|
|
52
|
+
* for a router: a new function on a later render is used, and makes no
|
|
53
|
+
* new sync.
|
|
54
|
+
*
|
|
55
|
+
* Default: 'none'
|
|
56
|
+
*/
|
|
57
|
+
history?: HistoryMode | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Apply the URL when the browser's back or forward button changes it.
|
|
60
|
+
*
|
|
61
|
+
* Default: true when `history` is `'push'`, else false
|
|
62
|
+
*/
|
|
63
|
+
popstate?: boolean | undefined;
|
|
43
64
|
/**
|
|
44
65
|
* Optional handler for operation failures: an operation called before the
|
|
45
66
|
* grid is ready (`NOT_READY`), a grid API error (`GRID_ERROR`), a saved view
|
|
@@ -54,6 +75,8 @@ export interface UseAGGridUrlSyncOptions extends AGGridUrlSyncConfig {
|
|
|
54
75
|
}
|
|
55
76
|
/**
|
|
56
77
|
* Return type for the useAGGridUrlSync hook
|
|
78
|
+
*
|
|
79
|
+
* @deprecated Use `useGridUrlSync` and its types. Removed in 0.6.0.
|
|
57
80
|
*/
|
|
58
81
|
export interface UseAGGridUrlSyncReturn {
|
|
59
82
|
/**
|
|
@@ -124,8 +147,13 @@ export interface UseAGGridUrlSyncReturn {
|
|
|
124
147
|
*/
|
|
125
148
|
getFiltersAsFormat: (format: SerializationFormat) => string;
|
|
126
149
|
/**
|
|
127
|
-
*
|
|
128
|
-
|
|
150
|
+
* The serialization mode of the URL: `'individual'` or `'grouped'`
|
|
151
|
+
*/
|
|
152
|
+
getSerializationMode: () => SerializationMode;
|
|
153
|
+
/**
|
|
154
|
+
* The serialization mode of the URL. The name is wrong: it returns the
|
|
155
|
+
* mode, not the format.
|
|
156
|
+
* @deprecated Use `getSerializationMode`. Removed in 0.6.0.
|
|
129
157
|
*/
|
|
130
158
|
getCurrentFormat: () => SerializationMode;
|
|
131
159
|
/**
|
|
@@ -199,3 +227,43 @@ export interface UseAGGridUrlSyncReturn {
|
|
|
199
227
|
*/
|
|
200
228
|
deleteView: (id: string) => void;
|
|
201
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* The options of `useGridUrlSync`: the options of `createGridUrlSync`, with
|
|
232
|
+
* the grid's `api` that can be null while the grid starts, and the React
|
|
233
|
+
* options. An option can change after mount.
|
|
234
|
+
*/
|
|
235
|
+
export interface UseGridUrlSyncOptions extends Omit<GridUrlSyncOptions, 'api' | 'views'> {
|
|
236
|
+
/** The AG Grid API, or null while the grid starts */
|
|
237
|
+
api: GridApi | null | undefined;
|
|
238
|
+
/**
|
|
239
|
+
* Enables saved views, kept in localStorage under this key. Two grids on
|
|
240
|
+
* the same origin need two keys. With no key, `views` is empty and the
|
|
241
|
+
* view methods do nothing.
|
|
242
|
+
*/
|
|
243
|
+
storageKey?: string | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* With `false`, the hook makes no sync: the state is idle, and a method
|
|
246
|
+
* reports `NOT_READY`. `views` still shows what is in storage.
|
|
247
|
+
* @default true
|
|
248
|
+
*/
|
|
249
|
+
enabled?: boolean | undefined;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* The result of `useGridUrlSync`: the sync's snapshot and its methods. The
|
|
253
|
+
* object stays the same until a snapshot value changes, and the methods
|
|
254
|
+
* never change.
|
|
255
|
+
*/
|
|
256
|
+
export interface UseGridUrlSyncResult extends GridUrlSyncSnapshot {
|
|
257
|
+
/** Applies the filters of a URL (default: the address bar) to the grid */
|
|
258
|
+
applyUrl: (url?: string) => ApplyResult;
|
|
259
|
+
/** Applies filters to the grid, as the app's own write */
|
|
260
|
+
applyFilters: (filters: FilterState) => ApplyResult;
|
|
261
|
+
/** The URL with the grid's filters (default base: the address bar) */
|
|
262
|
+
getUrl: (baseUrl?: string) => string;
|
|
263
|
+
/** Saves the grid's filters as a view, and makes it active */
|
|
264
|
+
saveView: (name: string) => GridView | null;
|
|
265
|
+
/** Loads a saved view. `null` clears the filters. */
|
|
266
|
+
loadView: (id: string | null) => void;
|
|
267
|
+
/** Deletes a saved view */
|
|
268
|
+
deleteView: (id: string) => void;
|
|
269
|
+
}
|
|
@@ -3,6 +3,9 @@ import type { UseAGGridUrlSyncOptions, UseAGGridUrlSyncReturn } from './types.js
|
|
|
3
3
|
/**
|
|
4
4
|
* React hook for AG Grid URL synchronization
|
|
5
5
|
*
|
|
6
|
+
* @deprecated Use `useGridUrlSync({ api, ...options })` (#271). This hook
|
|
7
|
+
* will be removed in 0.6.0.
|
|
8
|
+
*
|
|
6
9
|
* @param gridApi - AG Grid API instance (can be null during initialization)
|
|
7
10
|
* @param options - Configuration options for the hook
|
|
8
11
|
* @returns Hook API for URL synchronization
|