zustand-querystring 0.6.2 → 0.6.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/index.d.mts CHANGED
@@ -3,10 +3,6 @@ import { StoreMutatorIdentifier, StateCreator } from 'zustand/vanilla';
3
3
  type DeepSelect<T> = T extends object ? {
4
4
  [P in keyof T]?: DeepSelect<T[P]> | boolean;
5
5
  } : boolean;
6
- /** Maps T to only the fields marked as selected in S. `false` excludes, everything else includes. */
7
- type ApplySelect<T, S> = [S] extends [false] ? never : S extends object ? T extends object ? {
8
- [P in keyof S & keyof T as [ApplySelect<T[P], S[P]>] extends [never] ? never : P]: ApplySelect<T[P], S[P]>;
9
- } : never : T;
10
6
  interface QueryStringParam {
11
7
  key: string;
12
8
  value: string | string[];
@@ -46,18 +42,18 @@ interface QueryStringMap<S, U extends object = Record<string, unknown>> {
46
42
  to: (state: S, pathname: string) => U;
47
43
  from: (urlState: U, pathname: string) => Partial<S>;
48
44
  }
49
- interface QueryStringOptions<T, K extends string | false = string | false, S extends DeepSelect<T> = DeepSelect<T>, U extends object = Record<string, unknown>> {
45
+ interface QueryStringOptions<T, K extends string | false = string | false> {
50
46
  url?: string;
51
- select?: (pathname: string) => S;
47
+ select?: (pathname: string) => DeepSelect<T>;
52
48
  key?: K;
53
49
  prefix?: string;
54
50
  format?: QueryStringFormatFor<K>;
55
51
  syncNull?: boolean;
56
52
  syncUndefined?: boolean;
57
53
  /** Bidirectional mapping between store state shape and URL state shape. */
58
- map?: QueryStringMap<ApplySelect<T, S>, U>;
54
+ map?: QueryStringMap<T>;
59
55
  }
60
- type QueryString = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = [], const S extends DeepSelect<T> = DeepSelect<T>, U extends object = Record<string, unknown>>(initializer: StateCreator<T, Mps, Mcs>, options?: QueryStringOptions<T, string | false, S, U>) => StateCreator<T, Mps, Mcs>;
56
+ type QueryString = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, Mps, Mcs>, options?: QueryStringOptions<T>) => StateCreator<T, Mps, Mcs>;
61
57
  declare const querystring: QueryString;
62
58
 
63
59
  export { type ParseContext, type QueryStringFormat, type QueryStringFormatFor, type QueryStringFormatNamespaced, type QueryStringFormatStandalone, type QueryStringMap, type QueryStringOptions, type QueryStringParam, type QueryStringParams, querystring };
package/dist/index.d.ts CHANGED
@@ -3,10 +3,6 @@ import { StoreMutatorIdentifier, StateCreator } from 'zustand/vanilla';
3
3
  type DeepSelect<T> = T extends object ? {
4
4
  [P in keyof T]?: DeepSelect<T[P]> | boolean;
5
5
  } : boolean;
6
- /** Maps T to only the fields marked as selected in S. `false` excludes, everything else includes. */
7
- type ApplySelect<T, S> = [S] extends [false] ? never : S extends object ? T extends object ? {
8
- [P in keyof S & keyof T as [ApplySelect<T[P], S[P]>] extends [never] ? never : P]: ApplySelect<T[P], S[P]>;
9
- } : never : T;
10
6
  interface QueryStringParam {
11
7
  key: string;
12
8
  value: string | string[];
@@ -46,18 +42,18 @@ interface QueryStringMap<S, U extends object = Record<string, unknown>> {
46
42
  to: (state: S, pathname: string) => U;
47
43
  from: (urlState: U, pathname: string) => Partial<S>;
48
44
  }
49
- interface QueryStringOptions<T, K extends string | false = string | false, S extends DeepSelect<T> = DeepSelect<T>, U extends object = Record<string, unknown>> {
45
+ interface QueryStringOptions<T, K extends string | false = string | false> {
50
46
  url?: string;
51
- select?: (pathname: string) => S;
47
+ select?: (pathname: string) => DeepSelect<T>;
52
48
  key?: K;
53
49
  prefix?: string;
54
50
  format?: QueryStringFormatFor<K>;
55
51
  syncNull?: boolean;
56
52
  syncUndefined?: boolean;
57
53
  /** Bidirectional mapping between store state shape and URL state shape. */
58
- map?: QueryStringMap<ApplySelect<T, S>, U>;
54
+ map?: QueryStringMap<T>;
59
55
  }
60
- type QueryString = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = [], const S extends DeepSelect<T> = DeepSelect<T>, U extends object = Record<string, unknown>>(initializer: StateCreator<T, Mps, Mcs>, options?: QueryStringOptions<T, string | false, S, U>) => StateCreator<T, Mps, Mcs>;
56
+ type QueryString = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, Mps, Mcs>, options?: QueryStringOptions<T>) => StateCreator<T, Mps, Mcs>;
61
57
  declare const querystring: QueryString;
62
58
 
63
59
  export { type ParseContext, type QueryStringFormat, type QueryStringFormatFor, type QueryStringFormatNamespaced, type QueryStringFormatStandalone, type QueryStringMap, type QueryStringOptions, type QueryStringParam, type QueryStringParams, querystring };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zustand-querystring",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",