@cleanweb/react 1.0.10 → 1.0.11

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.
@@ -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 StateInitFunction = (props?: object) => object;
16
- type TInitialState<StateParamType> = StateParamType extends StateInitFunction ? ReturnType<StateParamType> : StateParamType;
17
- type StateInitParameters<StateInitializer> = StateInitializer extends StateInitFunction ? Parameters<StateInitializer> : [];
18
- type UseCleanState = <StateInitializer extends StateInitFunction | object>(_initialState: StateInitializer, ...props: StateInitParameters<StateInitializer>) => TCleanState<TInitialState<StateInitializer>>;
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,
@@ -92,9 +92,12 @@ var CleanStateBase = /** @class */ (function () {
92
92
  }());
93
93
  ;
94
94
  var CleanState = CleanStateBase;
95
- var useCleanState = function (_initialState, props) {
96
- if (props === void 0) { props = {}; }
97
- var initialState = typeof _initialState === 'function' ? (0, react_1.useMemo)(function () { return _initialState(props); }, []) : _initialState;
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;
@@ -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[]) => any;
42
+ declare type FunctionType = (...args: any) => any;
43
43
 
44
44
 
45
45
  declare interface Window {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleanweb/react",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "A suite of helpers for writing cleaner React function components.",
5
5
  "engines": {
6
6
  "node": ">=18"