@vueuse/shared 6.7.6 → 6.9.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/index.cjs +196 -150
- package/index.d.ts +62 -35
- package/index.iife.js +196 -150
- package/index.iife.min.js +1 -1
- package/index.mjs +194 -151
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -31,10 +31,14 @@ declare type MaybeRef<T> = T | Ref<T>;
|
|
|
31
31
|
/**
|
|
32
32
|
* A ref that allow to set null or undefined
|
|
33
33
|
*/
|
|
34
|
-
declare type
|
|
34
|
+
declare type RemovableRef<T> = Omit<Ref<T>, 'value'> & {
|
|
35
35
|
get value(): T;
|
|
36
36
|
set value(value: T | null | undefined);
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated Use `RemovableRef`
|
|
40
|
+
*/
|
|
41
|
+
declare type RemoveableRef<T> = RemovableRef<T>;
|
|
38
42
|
/**
|
|
39
43
|
* Make all the nested attributes of an object or array to MaybeRef<T>
|
|
40
44
|
*
|
|
@@ -66,9 +70,9 @@ interface Pausable {
|
|
|
66
70
|
*/
|
|
67
71
|
resume: Fn;
|
|
68
72
|
}
|
|
69
|
-
interface
|
|
73
|
+
interface Stoppable {
|
|
70
74
|
/**
|
|
71
|
-
* A ref indicate whether a
|
|
75
|
+
* A ref indicate whether a stoppable instance is executing
|
|
72
76
|
*/
|
|
73
77
|
isPending: Ref<boolean>;
|
|
74
78
|
/**
|
|
@@ -80,6 +84,10 @@ interface Stopable {
|
|
|
80
84
|
*/
|
|
81
85
|
start: Fn;
|
|
82
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Use `Stoppable`
|
|
89
|
+
*/
|
|
90
|
+
declare type Stopable = Stoppable;
|
|
83
91
|
interface ConfigurableFlush {
|
|
84
92
|
/**
|
|
85
93
|
* Timing for monitoring changes, refer to WatchOptions for more details
|
|
@@ -119,6 +127,13 @@ interface ConfigurableEventFilter {
|
|
|
119
127
|
*/
|
|
120
128
|
eventFilter?: EventFilter;
|
|
121
129
|
}
|
|
130
|
+
interface DebounceFilterOptions {
|
|
131
|
+
/**
|
|
132
|
+
* The maximum time allowed to be delayed before it's invoked.
|
|
133
|
+
* In milliseconds.
|
|
134
|
+
*/
|
|
135
|
+
maxWait?: number;
|
|
136
|
+
}
|
|
122
137
|
/**
|
|
123
138
|
* @internal
|
|
124
139
|
*/
|
|
@@ -128,8 +143,9 @@ declare const bypassFilter: EventFilter;
|
|
|
128
143
|
* Create an EventFilter that debounce the events
|
|
129
144
|
*
|
|
130
145
|
* @param ms
|
|
146
|
+
* @param [maxWait=null]
|
|
131
147
|
*/
|
|
132
|
-
declare function debounceFilter(ms: MaybeRef<number
|
|
148
|
+
declare function debounceFilter(ms: MaybeRef<number>, options?: DebounceFilterOptions): EventFilter<any[], any>;
|
|
133
149
|
/**
|
|
134
150
|
* Create an EventFilter that throttle the events
|
|
135
151
|
*
|
|
@@ -271,6 +287,18 @@ declare type CreateGlobalStateReturn<T> = () => T;
|
|
|
271
287
|
*/
|
|
272
288
|
declare function createGlobalState<T>(stateFactory: () => T): CreateGlobalStateReturn<T>;
|
|
273
289
|
|
|
290
|
+
declare type Reactify<T> = T extends (...args: infer A) => infer R ? (...args: {
|
|
291
|
+
[K in keyof A]: MaybeRef<A[K]>;
|
|
292
|
+
}) => ComputedRef<R> : never;
|
|
293
|
+
/**
|
|
294
|
+
* Converts plain function into a reactive function.
|
|
295
|
+
* The converted function accepts refs as it's arguments
|
|
296
|
+
* and returns a ComputedRef, with proper typing.
|
|
297
|
+
*
|
|
298
|
+
* @param fn - Source function
|
|
299
|
+
*/
|
|
300
|
+
declare function reactify<T extends Function>(fn: T): Reactify<T>;
|
|
301
|
+
|
|
274
302
|
/**
|
|
275
303
|
* Make a composable function usable with multiple Vue instances.
|
|
276
304
|
*
|
|
@@ -278,6 +306,13 @@ declare function createGlobalState<T>(stateFactory: () => T): CreateGlobalStateR
|
|
|
278
306
|
*/
|
|
279
307
|
declare function createSharedComposable<Fn extends ((...args: any[]) => any)>(composable: Fn): Fn;
|
|
280
308
|
|
|
309
|
+
/**
|
|
310
|
+
* Debounce updates of a ref.
|
|
311
|
+
*
|
|
312
|
+
* @return A new debounced ref.
|
|
313
|
+
*/
|
|
314
|
+
declare function useDebounce<T>(value: Ref<T>, ms?: number, options?: DebounceFilterOptions): Readonly<Ref<T>>;
|
|
315
|
+
|
|
281
316
|
interface DebouncedWatchOptions<Immediate> extends WatchOptions<Immediate> {
|
|
282
317
|
debounce?: MaybeRef<number>;
|
|
283
318
|
}
|
|
@@ -359,18 +394,6 @@ declare function pausableWatch<T extends Readonly<WatchSource<unknown>[]>, Immed
|
|
|
359
394
|
declare function pausableWatch<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): PausableWatchReturn;
|
|
360
395
|
declare function pausableWatch<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): PausableWatchReturn;
|
|
361
396
|
|
|
362
|
-
declare type Reactify<T> = T extends (...args: infer A) => infer R ? (...args: {
|
|
363
|
-
[K in keyof A]: MaybeRef<A[K]>;
|
|
364
|
-
}) => ComputedRef<R> : never;
|
|
365
|
-
/**
|
|
366
|
-
* Converts plain function into a reactive function.
|
|
367
|
-
* The converted function accepts refs as it's arguments
|
|
368
|
-
* and returns a ComputedRef, with proper typing.
|
|
369
|
-
*
|
|
370
|
-
* @param fn - Source function
|
|
371
|
-
*/
|
|
372
|
-
declare function reactify<T extends Function>(fn: T): Reactify<T>;
|
|
373
|
-
|
|
374
397
|
declare type ReactifyNested<T, Keys extends keyof T = keyof T> = {
|
|
375
398
|
[K in Keys]: T[K] extends (...args: any[]) => any ? Reactify<T[K]> : T[K];
|
|
376
399
|
};
|
|
@@ -428,7 +451,18 @@ interface SyncRefOptions extends ConfigurableFlushSync {
|
|
|
428
451
|
* @param source source ref
|
|
429
452
|
* @param targets
|
|
430
453
|
*/
|
|
431
|
-
declare function syncRef<
|
|
454
|
+
declare function syncRef<T>(source: WatchSource<T>, targets: Ref<T> | Ref<T>[], { flush, deep, immediate, }?: SyncRefOptions): vue_demi.WatchStopHandle;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Throttle execution of a function. Especially useful for rate limiting
|
|
458
|
+
* execution of handlers on events like resize and scroll.
|
|
459
|
+
*
|
|
460
|
+
* @param value Ref value to be watched with throttle effect
|
|
461
|
+
* @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
462
|
+
* @param [trailing=true] if true, update the value again after the delay time is up
|
|
463
|
+
* @param [leading=true] if true, update the value on the leading edge of the ms timeout
|
|
464
|
+
*/
|
|
465
|
+
declare function useThrottle<T>(value: Ref<T>, delay?: number, trailing?: boolean, leading?: boolean): Ref<T>;
|
|
432
466
|
|
|
433
467
|
interface ThrottledWatchOptions<Immediate> extends WatchOptions<Immediate> {
|
|
434
468
|
throttle?: MaybeRef<number>;
|
|
@@ -544,13 +578,18 @@ interface UntilArrayInstance<T> extends UntilBaseInstance<T> {
|
|
|
544
578
|
declare function until<T extends unknown[]>(r: WatchSource<T> | MaybeRef<T>): UntilArrayInstance<T>;
|
|
545
579
|
declare function until<T>(r: WatchSource<T> | MaybeRef<T>): UntilValueInstance<T>;
|
|
546
580
|
|
|
581
|
+
interface UseCounterOptions {
|
|
582
|
+
min?: number;
|
|
583
|
+
max?: number;
|
|
584
|
+
}
|
|
547
585
|
/**
|
|
548
586
|
* Basic counter with utility functions.
|
|
549
587
|
*
|
|
550
588
|
* @see https://vueuse.org/useCounter
|
|
551
589
|
* @param [initialValue=0]
|
|
590
|
+
* @param {Object} options
|
|
552
591
|
*/
|
|
553
|
-
declare function useCounter(initialValue?: number): {
|
|
592
|
+
declare function useCounter(initialValue?: number, options?: UseCounterOptions): {
|
|
554
593
|
count: vue_demi.Ref<number>;
|
|
555
594
|
inc: (delta?: number) => number;
|
|
556
595
|
dec: (delta?: number) => number;
|
|
@@ -559,17 +598,16 @@ declare function useCounter(initialValue?: number): {
|
|
|
559
598
|
reset: (val?: number) => number;
|
|
560
599
|
};
|
|
561
600
|
|
|
562
|
-
declare function useDebounce<T>(value: Ref<T>, ms?: number): Readonly<Ref<T>>;
|
|
563
|
-
|
|
564
601
|
/**
|
|
565
602
|
* Debounce execution of a function.
|
|
566
603
|
*
|
|
567
604
|
* @param fn A function to be executed after delay milliseconds debounced.
|
|
568
605
|
* @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
606
|
+
* @param opts options
|
|
569
607
|
*
|
|
570
608
|
* @return A new, debounce, function.
|
|
571
609
|
*/
|
|
572
|
-
declare function useDebounceFn<T extends FunctionArgs>(fn: T, ms?: MaybeRef<number
|
|
610
|
+
declare function useDebounceFn<T extends FunctionArgs>(fn: T, ms?: MaybeRef<number>, options?: DebounceFilterOptions): T;
|
|
573
611
|
|
|
574
612
|
interface IntervalOptions<Controls extends boolean> {
|
|
575
613
|
/**
|
|
@@ -625,17 +663,6 @@ declare function useLastChanged(source: WatchSource, options?: UseLastChangedOpt
|
|
|
625
663
|
declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<true>): Ref<number>;
|
|
626
664
|
declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<boolean, number>): Ref<number>;
|
|
627
665
|
|
|
628
|
-
/**
|
|
629
|
-
* Throttle execution of a function. Especially useful for rate limiting
|
|
630
|
-
* execution of handlers on events like resize and scroll.
|
|
631
|
-
*
|
|
632
|
-
* @param value Ref value to be watched with throttle effect
|
|
633
|
-
* @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
634
|
-
* @param [trailing=true] if true, update the value again after the delay time is up
|
|
635
|
-
* @param [leading=true] if true, update the value on the leading edge of the ms timeout
|
|
636
|
-
*/
|
|
637
|
-
declare function useThrottle<T>(value: Ref<T>, delay?: number, trailing?: boolean, leading?: boolean): Ref<T>;
|
|
638
|
-
|
|
639
666
|
/**
|
|
640
667
|
* Throttle execution of a function. Especially useful for rate limiting
|
|
641
668
|
* execution of handlers on events like resize and scroll.
|
|
@@ -667,7 +694,7 @@ interface TimeoutFnOptions {
|
|
|
667
694
|
* @param interval
|
|
668
695
|
* @param immediate
|
|
669
696
|
*/
|
|
670
|
-
declare function useTimeoutFn(cb: (...args: unknown[]) => any, interval: MaybeRef<number>, options?: TimeoutFnOptions):
|
|
697
|
+
declare function useTimeoutFn(cb: (...args: unknown[]) => any, interval: MaybeRef<number>, options?: TimeoutFnOptions): Stoppable;
|
|
671
698
|
|
|
672
699
|
interface TimeoutOptions<Controls extends boolean> extends TimeoutFnOptions {
|
|
673
700
|
/**
|
|
@@ -687,7 +714,7 @@ interface TimeoutOptions<Controls extends boolean> extends TimeoutFnOptions {
|
|
|
687
714
|
declare function useTimeout(interval?: number, options?: TimeoutOptions<false>): ComputedRef<boolean>;
|
|
688
715
|
declare function useTimeout(interval: number, options: TimeoutOptions<true>): {
|
|
689
716
|
ready: ComputedRef<boolean>;
|
|
690
|
-
} &
|
|
717
|
+
} & Stoppable;
|
|
691
718
|
|
|
692
719
|
/**
|
|
693
720
|
* A boolean ref with a toggler
|
|
@@ -720,4 +747,4 @@ declare function watchOnce<T, Immediate extends Readonly<boolean> = false>(sourc
|
|
|
720
747
|
*/
|
|
721
748
|
declare function whenever<T>(source: WatchSource<T>, cb: WatchCallback, options?: WatchOptions): vue_demi.WatchStopHandle;
|
|
722
749
|
|
|
723
|
-
export { ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, CreateGlobalStateReturn, DebouncedWatchOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookTrigger, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnorableWatchReturn, IgnoredUpdater, IntervalFnOptions, IntervalOptions, MapOldSources, MapSources, MaybeRef, Pausable, PausableWatchReturn, Reactify, ReactifyNested, ReactifyObjectOptions, RemoveableRef, ShallowUnwrapRef, SingletonPromiseReturn, Stopable, SyncRefOptions, ThrottledWatchOptions, TimeoutFnOptions, TimeoutOptions, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, UseLastChangedOptions, WatchAtMostOptions, WatchAtMostReturn, WatchWithFilterOptions, and, assert, biSyncRef, bypassFilter, clamp, containsProp, controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createSharedComposable, createSingletonPromise, debounceFilter, debouncedWatch, eagerComputed, extendRef, get, identity, ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isNumber, isObject, isString, isWindow, makeDestructurable, noop, not, now, objectPick, or, pausableFilter, pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactivePick, refDefault, set, syncRef, throttleFilter, throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useCounter, useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchAtMost, watchOnce, watchWithFilter, whenever };
|
|
750
|
+
export { ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, CreateGlobalStateReturn, DebounceFilterOptions, DebouncedWatchOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookTrigger, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnorableWatchReturn, IgnoredUpdater, IntervalFnOptions, IntervalOptions, MapOldSources, MapSources, MaybeRef, Pausable, PausableWatchReturn, Reactify, ReactifyNested, ReactifyObjectOptions, RemovableRef, RemoveableRef, ShallowUnwrapRef, SingletonPromiseReturn, Stopable, Stoppable, SyncRefOptions, ThrottledWatchOptions, TimeoutFnOptions, TimeoutOptions, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, UseCounterOptions, UseLastChangedOptions, WatchAtMostOptions, WatchAtMostReturn, WatchWithFilterOptions, and, assert, biSyncRef, bypassFilter, clamp, containsProp, controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, useDebounce as debouncedRef, debouncedWatch, eagerComputed, extendRef, get, identity, ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isNumber, isObject, isString, isWindow, makeDestructurable, noop, not, now, objectPick, or, pausableFilter, pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactivePick, refDefault, set, syncRef, throttleFilter, useThrottle as throttledRef, throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useCounter, useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchAtMost, watchOnce, watchWithFilter, whenever };
|