define-zustand 3.1.1 → 3.2.0
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/types.d.ts +7 -4
- package/dist/utils.d.ts +6 -7
- package/package.json +4 -4
package/dist/types.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { StoreApi as ZStoreApi } from 'zustand';
|
|
1
|
+
import { StoreApi as ZStoreApi, ExtractState as ZExtractState } from 'zustand';
|
|
2
2
|
export type defGetterStateType<S> = Record<string, (state: S) => any>;
|
|
3
3
|
export type ExtraGetterState<S, G extends defGetterStateType<S>> = {
|
|
4
4
|
[key in keyof G]: ReturnType<G[key]>;
|
|
5
5
|
};
|
|
6
|
+
export type stateType<S, G extends defGetterStateType<S>> = S & ExtraGetterState<S, G>;
|
|
6
7
|
export type StoreApi<S> = Omit<ZStoreApi<S>, 'setState'> & {
|
|
7
8
|
setState: (updater: ((state: S) => void) | Partial<S>, replace?: boolean) => void;
|
|
8
9
|
};
|
|
10
|
+
export type ExtractState<S> = ZExtractState<S>;
|
|
9
11
|
export interface insideActionsType<S> {
|
|
10
12
|
reset: () => void;
|
|
11
13
|
setState: StoreApi<S>['setState'];
|
|
12
14
|
subscribe: StoreApi<S>['subscribe'];
|
|
13
15
|
}
|
|
14
|
-
export type actionsType<S, G extends defGetterStateType<S>, OptionAction
|
|
15
|
-
export interface optionsType<S, G extends defGetterStateType<S>,
|
|
16
|
+
export type actionsType<S, G extends defGetterStateType<S>, OptionAction> = (getState: () => stateType<S, G>, actions: Omit<insideActionsType<S>, 'subscribe'>, store: StoreApi<S>) => OptionAction;
|
|
17
|
+
export interface optionsType<S, G extends defGetterStateType<S>, Actions> {
|
|
16
18
|
state: () => S;
|
|
17
19
|
getter: G;
|
|
18
|
-
actions: actionsType<S, G,
|
|
20
|
+
actions: actionsType<S, G, Actions>;
|
|
19
21
|
}
|
|
22
|
+
export type modelStateType<S, G extends defGetterStateType<S>, Actions> = stateType<S, G> & Actions & insideActionsType<S>;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function defineContext<S extends Record<string, any>, G extends defGetterStateType<S>, OptionActions extends Record<string, any>>(options: optionsType<S, G, OptionActions>): {
|
|
2
|
+
import { defGetterStateType, optionsType, modelStateType } from './types';
|
|
3
|
+
export declare function defineStateFactory<S extends Record<string, any>, G extends defGetterStateType<S>, OptionActions extends Record<string, any>>(options: optionsType<S, G, OptionActions>): () => optionsType<S, G, OptionActions>;
|
|
4
|
+
export declare function creator<S extends Record<string, any>, G extends defGetterStateType<S>, Actions extends Record<string, any>>(options: optionsType<S, G, Actions>): (set: any, get: any, store: any) => modelStateType<S, G, Actions>;
|
|
5
|
+
export declare function defineStore<S extends Record<string, any>, G extends defGetterStateType<S>, Actions extends Record<string, any>>(options: optionsType<S, G, Actions>): import("zustand").UseBoundStore<import("zustand").StoreApi<modelStateType<S, G, Actions>>>;
|
|
6
|
+
export declare function defineContext<S extends Record<string, any>, G extends defGetterStateType<S>, Actions extends Record<string, any>>(options: optionsType<S, G, Actions>): {
|
|
8
7
|
Provider: FunctionComponent<{
|
|
9
8
|
children?: ReactNode;
|
|
10
9
|
}>;
|
|
11
|
-
useContext: <T>(selector: (state:
|
|
10
|
+
useContext: <T>(selector: (state: modelStateType<S, G, Actions>) => T) => T;
|
|
12
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "define-zustand",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"stylelint": "15.9.0",
|
|
24
24
|
"stylelint-config-standard": "33.0.0",
|
|
25
25
|
"ts-jest": "29.0.5",
|
|
26
|
-
"typescript": "5.
|
|
27
|
-
"zustand": "
|
|
26
|
+
"typescript": "5.7.3",
|
|
27
|
+
"zustand": "5.0.3"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@types/react": "18.3.3",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "~18.3.1",
|
|
36
|
-
"zustand": "~
|
|
36
|
+
"zustand": "~5.0.3"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "node scripts/build.js",
|