@cleanweb/react 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- package/build/base/state.d.ts +4 -4
- package/build/base/state.js +6 -3
- package/build/globals.d.ts +1 -1
- package/package.json +1 -1
package/build/base/state.d.ts
CHANGED
@@ -12,10 +12,10 @@ declare class CleanStateBase<TState extends object> {
|
|
12
12
|
}
|
13
13
|
type TCleanStateInstance<TState extends object> = TState & CleanStateBase<TState>;
|
14
14
|
export type TCleanState<TState extends object> = TCleanStateInstance<TState>;
|
15
|
-
type
|
16
|
-
type TInitialState<StateParamType> = StateParamType extends
|
17
|
-
type StateInitParameters<StateInitializer> = StateInitializer extends
|
18
|
-
type UseCleanState = <StateInitializer extends
|
15
|
+
type TFunctionType = (...args: any) => object;
|
16
|
+
type TInitialState<StateParamType> = StateParamType extends TFunctionType ? ReturnType<StateParamType> : StateParamType;
|
17
|
+
type StateInitParameters<StateInitializer> = StateInitializer extends TFunctionType ? Parameters<StateInitializer> : [];
|
18
|
+
type UseCleanState = <StateInitializer extends TFunctionType | object>(_initialState: StateInitializer, ...props: StateInitParameters<StateInitializer>) => TCleanStateInstance<TInitialState<StateInitializer>>;
|
19
19
|
export declare const useCleanState: UseCleanState;
|
20
20
|
/**
|
21
21
|
* Returns a value that is false before the component has been mounted,
|
package/build/base/state.js
CHANGED
@@ -92,9 +92,12 @@ var CleanStateBase = /** @class */ (function () {
|
|
92
92
|
}());
|
93
93
|
;
|
94
94
|
var CleanState = CleanStateBase;
|
95
|
-
var useCleanState = function (_initialState
|
96
|
-
|
97
|
-
var
|
95
|
+
var useCleanState = function (_initialState) {
|
96
|
+
var props = [];
|
97
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
98
|
+
props[_i - 1] = arguments[_i];
|
99
|
+
}
|
100
|
+
var initialState = typeof _initialState === 'function' ? (0, react_1.useMemo)(function () { return _initialState.apply(void 0, props); }, []) : _initialState;
|
98
101
|
var cleanState = (0, react_1.useMemo)(function () { return new CleanState(initialState); }, []);
|
99
102
|
CleanState.update.call(cleanState);
|
100
103
|
return cleanState;
|
package/build/globals.d.ts
CHANGED
@@ -39,7 +39,7 @@ declare interface IVoidFunction<AsyncType extends 'async' | 'sync' | 'both' = 'b
|
|
39
39
|
: Promise<void> | void
|
40
40
|
}
|
41
41
|
|
42
|
-
declare type FunctionType = (...args: any
|
42
|
+
declare type FunctionType = (...args: any) => any;
|
43
43
|
|
44
44
|
|
45
45
|
declare interface Window {
|