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