@aiszlab/relax 1.2.69 → 1.2.70
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.
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { type Dispatch, type SetStateAction } from "react";
|
|
2
|
-
import type { State } from "../types";
|
|
3
|
-
|
|
2
|
+
import type { State, RequiredTo } from "../types";
|
|
3
|
+
type UseControlledStateBy<T> = {
|
|
4
4
|
/**
|
|
5
5
|
* @description
|
|
6
6
|
* default value
|
|
7
7
|
*/
|
|
8
8
|
defaultState?: State<T>;
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
|
+
type UsedControlledState<T, R> = R extends undefined ? [T, Dispatch<SetStateAction<T>>] : [RequiredTo<T>, Dispatch<SetStateAction<RequiredTo<T>>>];
|
|
10
11
|
/**
|
|
11
12
|
* @author murukal
|
|
12
13
|
*
|
|
13
14
|
* @description
|
|
14
15
|
* controlled state
|
|
15
16
|
*/
|
|
16
|
-
export declare const useControlledState: <T>(controlledState: T, { defaultState }?:
|
|
17
|
+
export declare const useControlledState: <T, R extends T>(controlledState: T, { defaultState }?: UseControlledStateBy<R>) => UsedControlledState<T, R>;
|
|
17
18
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type RequiredTo<T> = Exclude<T, undefined>;
|