ivue 1.1.1 → 1.1.2
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/src/ivue.d.ts +4 -8
- package/docs/package.json +1 -1
- package/package.json +1 -1
- package/src/ivue.ts +7 -7
package/dist/src/ivue.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComputedRef, ExtractPropTypes,
|
|
1
|
+
import type { ComputedRef, ExtractPropTypes, Ref, ToRef } from 'vue';
|
|
2
2
|
import { UnwrapRef } from 'vue';
|
|
3
3
|
/** Types */
|
|
4
4
|
/**
|
|
@@ -25,12 +25,8 @@ export declare type IVueRefs<T = any> = {
|
|
|
25
25
|
/**
|
|
26
26
|
* Unwraps the returned Refs of composable method T to a reactive type definition.
|
|
27
27
|
*/
|
|
28
|
-
export declare type UseComposableReturn<T extends
|
|
29
|
-
[K in keyof T]: T[K] extends
|
|
30
|
-
value: any;
|
|
31
|
-
} ? T[K]['value'] extends {
|
|
32
|
-
value: any;
|
|
33
|
-
} ? T[K]['value']['value'] : T[K]['value'] : T[K];
|
|
28
|
+
export declare type UseComposableReturn<T extends Record<string, Ref | any>> = T extends Ref ? T : {
|
|
29
|
+
[K in keyof T]: T[K] extends Ref ? T[K]['value'] extends Ref ? T[K]['value']['value'] : T[K]['value'] : T[K];
|
|
34
30
|
};
|
|
35
31
|
export declare type UseComposable<T extends (...args: any[]) => any> = UseComposableReturn<ReturnType<T>>;
|
|
36
32
|
/**
|
|
@@ -154,7 +150,7 @@ export declare function iref<T>(val?: T): UnwrapRef<T>;
|
|
|
154
150
|
* `iuse` stands for composable.
|
|
155
151
|
* Returns unwrapped composable type definition without the Refs.
|
|
156
152
|
*/
|
|
157
|
-
export declare function iuse<T extends Object>(val?: T): UseComposableReturn<
|
|
153
|
+
export declare function iuse<T extends Object>(val?: T): UseComposableReturn<T>;
|
|
158
154
|
/**
|
|
159
155
|
* Convert reactive ivue class to Vue 3 refs.
|
|
160
156
|
*
|
package/docs/package.json
CHANGED
package/package.json
CHANGED
package/src/ivue.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import type {
|
|
4
4
|
ComputedRef,
|
|
5
5
|
ExtractPropTypes,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
Ref,
|
|
7
|
+
ToRef
|
|
8
8
|
} from 'vue';
|
|
9
9
|
import { UnwrapRef, computed, reactive, ref, toRef } from 'vue';
|
|
10
10
|
|
|
@@ -39,9 +39,9 @@ export type IVueRefs<T = any> = {
|
|
|
39
39
|
/**
|
|
40
40
|
* Unwraps the returned Refs of composable method T to a reactive type definition.
|
|
41
41
|
*/
|
|
42
|
-
export type UseComposableReturn<T extends
|
|
43
|
-
[K in keyof T]: T[K] extends
|
|
44
|
-
? T[K]['value'] extends
|
|
42
|
+
export type UseComposableReturn<T extends Record<string, Ref | any>> = T extends Ref ? T : {
|
|
43
|
+
[K in keyof T]: T[K] extends Ref // Handle Ref
|
|
44
|
+
? T[K]['value'] extends Ref // Handle Double Wrapped Ref: Most often a Ref that is inside a Computed Ref
|
|
45
45
|
? T[K]['value']['value'] // Return doubly wrapped internal value
|
|
46
46
|
: T[K]['value'] // Handle Standard Ref or Computed Ref
|
|
47
47
|
: T[K]; // Handle non Ref property or method
|
|
@@ -318,8 +318,8 @@ export function iref<T>(val?: T): UnwrapRef<T> {
|
|
|
318
318
|
*/
|
|
319
319
|
export function iuse<T extends Object>(
|
|
320
320
|
val?: T
|
|
321
|
-
): UseComposableReturn<
|
|
322
|
-
return val as unknown as UseComposableReturn<
|
|
321
|
+
): UseComposableReturn<T> {
|
|
322
|
+
return val as unknown as UseComposableReturn<T>;
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
/**
|