state-in-url 2.2.2 → 2.2.3
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/encodeState/encodeState.d.ts +2 -2
- package/dist/encoder/encoder.d.ts +3 -3
- package/dist/next/useUrlState/useUrlState.d.ts +2 -2
- package/dist/useSharedState/useSharedState.d.ts +1 -1
- package/dist/useUrlEncode/useUrlEncode.d.ts +3 -3
- package/dist/useUrlStateBase/useUrlStateBase.d.ts +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ import { type JSONCompatible, type UnknownObj } from '../utils';
|
|
|
12
12
|
* encodeState({ name: 'test' }, form, 'someExistingParam=123');
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* *
|
|
15
|
+
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url/tree/main/packages/urlstate/encodeState#encodestate}
|
|
16
16
|
*/
|
|
17
17
|
export declare function encodeState<T extends JSONCompatible>(state: T, defaults?: T, paramsToKeep?: string | URLSearchParams): string;
|
|
18
18
|
/**
|
|
@@ -27,6 +27,6 @@ export declare function encodeState<T extends JSONCompatible>(state: T, defaults
|
|
|
27
27
|
* decodeState('key=value&name=Alex', form);
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
|
-
* *
|
|
30
|
+
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url/tree/main/packages/urlstate/encodeState#decodestate}
|
|
31
31
|
*/
|
|
32
32
|
export declare function decodeState<T extends JSONCompatible>(uriString: string | URLSearchParams, defaults?: T): undefined extends T ? UnknownObj : T;
|
|
@@ -5,7 +5,7 @@ import { type JSONCompatible } from '../utils';
|
|
|
5
5
|
* @param {unknown} payload any value to serialize
|
|
6
6
|
* @returns {string} URLSearchParams compatible value string
|
|
7
7
|
*
|
|
8
|
-
* *
|
|
8
|
+
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url/tree/main/packages/urlstate/encoder#encode}
|
|
9
9
|
*/
|
|
10
10
|
export declare function encode(payload: unknown): string;
|
|
11
11
|
export declare const replacer: (_key: string, value: unknown) => unknown;
|
|
@@ -17,7 +17,7 @@ export type Primitive = Exclude<ReturnType<typeof decodePrimitive>, typeof error
|
|
|
17
17
|
* @param {any} fallback optional fallback value
|
|
18
18
|
* @returns {unknown} decoded object
|
|
19
19
|
*
|
|
20
|
-
* *
|
|
20
|
+
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url/tree/main/packages/urlstate/encoder#decode}
|
|
21
21
|
*/
|
|
22
22
|
export declare function decode<T>(payload: string, fallback?: T): JSONCompatible | Primitive;
|
|
23
23
|
export declare const decodePrimitive: (str: string) => string | number | boolean | Date | typeof errorSym | null | undefined;
|
|
@@ -30,6 +30,6 @@ export declare const reviver: (_key: string, value: unknown) => unknown;
|
|
|
30
30
|
* @param {T} [fallbackValue] - The fallback value to use if parsing fails.
|
|
31
31
|
* @return {T | Primitive | undefined} - The parsed object or a primitive value, or undefined if parsing fails.
|
|
32
32
|
*
|
|
33
|
-
* *
|
|
33
|
+
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url}
|
|
34
34
|
*/
|
|
35
35
|
export declare function parseJSON<T extends JSONCompatible>(jsonString: string, fallbackValue?: T): T | Primitive | undefined;
|
|
@@ -21,7 +21,7 @@ import { type DeepReadonly, type JSONCompatible } from '../../utils';
|
|
|
21
21
|
* updateUrl(curr => ({ ...curr, name: 'test' }), { replace: true, scroll: true });
|
|
22
22
|
* ```
|
|
23
23
|
*
|
|
24
|
-
* *
|
|
24
|
+
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url/tree/main/packages/urlstate/next/useUrlState#api}
|
|
25
25
|
*/
|
|
26
26
|
export declare function useUrlState<T extends JSONCompatible>(defaultState: T, searchParams?: object): {
|
|
27
27
|
state: DeepReadonly<T>;
|
|
@@ -49,7 +49,7 @@ export declare function useUrlState<T extends JSONCompatible>(defaultState: T, s
|
|
|
49
49
|
* updateUrl(curr => ({ ...curr, name: 'test' }), { replace: true, scroll: true });
|
|
50
50
|
* ```
|
|
51
51
|
*
|
|
52
|
-
* *
|
|
52
|
+
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url/tree/main/packages/urlstate/next/useUrlState#api}
|
|
53
53
|
*/
|
|
54
54
|
export declare function useUrlState<T extends JSONCompatible>({ defaultState, searchParams, }: {
|
|
55
55
|
defaultState: T;
|
|
@@ -15,7 +15,7 @@ import { type DeepReadonly, type JSONCompatible } from '../utils';
|
|
|
15
15
|
* // OR
|
|
16
16
|
* setState(curr => ({ ...curr, name: 'test' }))
|
|
17
17
|
* ```
|
|
18
|
-
* *
|
|
18
|
+
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url/tree/main/packages/urlstate/useSharedState}
|
|
19
19
|
*/
|
|
20
20
|
export declare function useSharedState<T extends JSONCompatible>(defaultState: T, _getInitial?: () => T): {
|
|
21
21
|
state: T;
|
|
@@ -17,7 +17,7 @@ import { type JSONCompatible } from '../utils';
|
|
|
17
17
|
* parse('name=Tom');
|
|
18
18
|
* ```
|
|
19
19
|
*
|
|
20
|
-
* *
|
|
20
|
+
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url/tree/main/packages/urlstate/useUrlEncode#api}
|
|
21
21
|
*/
|
|
22
22
|
export declare function useUrlEncode<T extends JSONCompatible>(stateShape: T): {
|
|
23
23
|
/**
|
|
@@ -28,7 +28,7 @@ const state = parse('name=◖Tom');
|
|
|
28
28
|
console.log(state); // Output: { name: 'Tom' }
|
|
29
29
|
* ```
|
|
30
30
|
*
|
|
31
|
-
* *
|
|
31
|
+
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url/tree/main/packages/urlstate/useUrlEncode#parse}
|
|
32
32
|
*/
|
|
33
33
|
parse: (strOrSearchParams: string | URLSearchParams) => T;
|
|
34
34
|
/**
|
|
@@ -39,7 +39,7 @@ const queryString = stringify({ name: 'John' }, 'someExistingParamToKeep=123');
|
|
|
39
39
|
console.log(queryString); // Output: name=◖John&someExistingParamToKeep=123
|
|
40
40
|
* ```
|
|
41
41
|
*
|
|
42
|
-
* *
|
|
42
|
+
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url/tree/main/packages/urlstate/useUrlEncode#stringify}
|
|
43
43
|
*/
|
|
44
44
|
stringify: (state: typeof stateShape, paramsToKeep?: string | URLSearchParams) => string;
|
|
45
45
|
};
|
|
@@ -13,7 +13,7 @@ import { type DeepReadonly, type JSONCompatible } from '../utils';
|
|
|
13
13
|
* const { state, updateState, updateUrl } = useUrlStateBase(form, router, sp);
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
|
-
* *
|
|
16
|
+
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url/tree/integrations/packages/urlstate/useUrlStateBase#api}
|
|
17
17
|
*/
|
|
18
18
|
export declare function useUrlStateBase<T extends JSONCompatible>(defaultState: T, router: Router, searchParams?: object): {
|
|
19
19
|
updateState: (value: Partial<T> | Partial<DeepReadonly<T>> | ((currState: T) => T)) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "state-in-url",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "Library to store state in browser URL, includes hook for NextJS, hook for pure React, and low level helpers.",
|
|
5
5
|
"homepage": "https://github.com/asmyshlyaev177/state-in-url#readme",
|
|
6
6
|
"keywords": [
|