@hairy/react-lib 1.7.1 → 1.7.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +9 -6
  2. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -151,20 +151,23 @@ declare function defineAsyncStorePlain<T extends FunctionReturningPromise>(fn: T
151
151
  readonly error: Error | undefined;
152
152
  }, T, (value: ReturnType<T> extends Promise<infer U_1> ? U_1 : undefined) => void];
153
153
 
154
- interface StoreDefine<S extends object, A extends Actions<S> = Record<string, any>> {
154
+ interface StoreDefine<S extends object, A extends Actions<S>> {
155
155
  state: (() => S) | S;
156
156
  actions?: A;
157
157
  }
158
158
  interface StoreOptions {
159
159
  persistant?: string;
160
160
  }
161
- type Actions<S> = Record<string, (this: S) => void>;
162
- type Store<S, A> = A & {
161
+ type Actions<S> = Record<string, (this: S, ...args: any) => any>;
162
+ type ActionsOmitThisParameter<A extends Actions<any>> = {
163
+ [K in keyof A]: (...args: Parameters<A[K]>) => ReturnType<A[K]>;
164
+ };
165
+ type Store<S, A extends Actions<S>> = {
163
166
  $subscribe: (listener: (state: S) => void) => () => void;
164
167
  $patch: (patch: Partial<S> | ((state: S) => void)) => void;
165
168
  $state: S;
166
- $actions: A;
167
- };
169
+ $actions: ActionsOmitThisParameter<A>;
170
+ } & ActionsOmitThisParameter<A>;
168
171
  declare function defineStore<S extends object, A extends Actions<S>>(store: StoreDefine<S, A>, options?: StoreOptions): Store<S, A>;
169
172
 
170
173
  interface PersistantOptions {
@@ -192,4 +195,4 @@ declare namespace cls {
192
195
  var append: (value: any, newClass: any) => any;
193
196
  }
194
197
 
195
- export { type Actions, type Argument, type ArgumentArray, type AsyncStoreOptions, type AsyncStorePlainOptions, Case, type CaseProps, Default, Else, type EventBusListener, type FetchRequestInterceptCallback, type FetchResponseInterceptCallback, If, type IfProps, type InjectComponent, Injector, type InjectorProps, type Mapping, type PersistantOptions, type PropWithHtmlProps, type ReadonlyArgumentArray, type StateFromFunctionReturningPromise, type Store, type StoreDefine, type StoreOptions, Switch, type SwitchProps, Then, Trans, type TransProps, Unless, type UnlessProps, type UseAsyncStateOptions, type Value, type WatchCallback, type WatchOptions, cls, defineAsyncStore, defineAsyncStorePlain, defineStore, proxyWithPersistant, useAsyncCallback, useAsyncState, useDebounce, useEventBus, useFetchRequestIntercept, useFetchResponseIntercept, useMounted, useStore, useWatch, useWhenever };
198
+ export { type Actions, type ActionsOmitThisParameter, type Argument, type ArgumentArray, type AsyncStoreOptions, type AsyncStorePlainOptions, Case, type CaseProps, Default, Else, type EventBusListener, type FetchRequestInterceptCallback, type FetchResponseInterceptCallback, If, type IfProps, type InjectComponent, Injector, type InjectorProps, type Mapping, type PersistantOptions, type PropWithHtmlProps, type ReadonlyArgumentArray, type StateFromFunctionReturningPromise, type Store, type StoreDefine, type StoreOptions, Switch, type SwitchProps, Then, Trans, type TransProps, Unless, type UnlessProps, type UseAsyncStateOptions, type Value, type WatchCallback, type WatchOptions, cls, defineAsyncStore, defineAsyncStorePlain, defineStore, proxyWithPersistant, useAsyncCallback, useAsyncState, useDebounce, useEventBus, useFetchRequestIntercept, useFetchResponseIntercept, useMounted, useStore, useWatch, useWhenever };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hairy/react-lib",
3
3
  "type": "module",
4
- "version": "1.7.1",
4
+ "version": "1.7.3",
5
5
  "description": "Library for react",
6
6
  "author": "Hairyf <wwu710632@gmail.com>",
7
7
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  "react-dom": "^18.2.0",
39
39
  "react-i18next": "^14.1.2",
40
40
  "react-use": "^17.6.0",
41
- "@hairy/utils": "1.7.1"
41
+ "@hairy/utils": "1.7.3"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsup",