@vueuse/shared 10.4.1 → 10.6.0
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 +67 -35
- package/index.d.cts +136 -63
- package/index.d.mts +136 -63
- package/index.d.ts +136 -63
- package/index.iife.js +67 -35
- package/index.iife.min.js +1 -1
- package/index.mjs +66 -37
- package/package.json +2 -2
package/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue_demi from 'vue-demi';
|
|
2
|
-
import { WatchOptionsBase, Ref, ComputedRef, WritableComputedRef, WatchSource, ComputedGetter, WritableComputedOptions, WatchOptions, ShallowUnwrapRef as ShallowUnwrapRef$1, UnwrapNestedRefs, UnwrapRef, ToRef, ToRefs, MaybeRef as MaybeRef$1, WatchCallback, WatchStopHandle } from 'vue-demi';
|
|
2
|
+
import { WatchOptionsBase, Ref, ComputedRef, WritableComputedRef, WatchSource, ComputedGetter, WritableComputedOptions, WatchOptions, InjectionKey, ShallowUnwrapRef as ShallowUnwrapRef$1, inject, provide, UnwrapNestedRefs, UnwrapRef, ToRef, ToRefs, MaybeRef as MaybeRef$1, WatchCallback, WatchStopHandle } from 'vue-demi';
|
|
3
3
|
|
|
4
4
|
declare function computedEager<T>(fn: () => T, options?: WatchOptionsBase): Readonly<Ref<T>>;
|
|
5
5
|
|
|
@@ -16,11 +16,12 @@ interface WritableComputedRefWithControl<T> extends WritableComputedRef<T>, Comp
|
|
|
16
16
|
declare function computedWithControl<T, S>(source: WatchSource<S> | WatchSource<S>[], fn: ComputedGetter<T>): ComputedRefWithControl<T>;
|
|
17
17
|
declare function computedWithControl<T, S>(source: WatchSource<S> | WatchSource<S>[], fn: WritableComputedOptions<T>): WritableComputedRefWithControl<T>;
|
|
18
18
|
|
|
19
|
-
type
|
|
19
|
+
type Callback<T> = T extends void ? () => void : (param: T) => void;
|
|
20
|
+
type EventHookOn<T = any> = (fn: Callback<T>) => {
|
|
20
21
|
off: () => void;
|
|
21
22
|
};
|
|
22
|
-
type EventHookOff<T = any> = (fn:
|
|
23
|
-
type EventHookTrigger<T = any> = (param
|
|
23
|
+
type EventHookOff<T = any> = (fn: Callback<T>) => void;
|
|
24
|
+
type EventHookTrigger<T = any> = (param?: T) => Promise<unknown[]>;
|
|
24
25
|
interface EventHook<T = any> {
|
|
25
26
|
on: EventHookOn<T>;
|
|
26
27
|
off: EventHookOff<T>;
|
|
@@ -34,6 +35,7 @@ interface EventHook<T = any> {
|
|
|
34
35
|
declare function createEventHook<T = any>(): EventHook<T>;
|
|
35
36
|
|
|
36
37
|
declare const isClient: boolean;
|
|
38
|
+
declare const isWorker: boolean;
|
|
37
39
|
declare const isDef: <T = any>(val?: T | undefined) => val is T;
|
|
38
40
|
declare const notNullish: <T = any>(val?: T | null | undefined) => val is T;
|
|
39
41
|
declare const assert: (condition: boolean, ...infos: any[]) => void;
|
|
@@ -101,7 +103,14 @@ type ElementOf<T> = T extends (infer E)[] ? E : never;
|
|
|
101
103
|
type ShallowUnwrapRef<T> = T extends Ref<infer P> ? P : T;
|
|
102
104
|
type Awaitable<T> = Promise<T> | T;
|
|
103
105
|
type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
104
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Compatible with versions below TypeScript 4.5 Awaited
|
|
108
|
+
*/
|
|
109
|
+
type Awaited<T> = T extends null | undefined ? T : T extends object & {
|
|
110
|
+
then(onfulfilled: infer F, ...args: infer _): any;
|
|
111
|
+
} ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T;
|
|
112
|
+
type Promisify<T> = Promise<Awaited<T>>;
|
|
113
|
+
type PromisifyFn<T extends AnyFn> = (...args: ArgumentsType<T>) => Promisify<ReturnType<T>>;
|
|
105
114
|
interface Pausable {
|
|
106
115
|
/**
|
|
107
116
|
* A ref indicate whether a pausable instance is active
|
|
@@ -164,7 +173,7 @@ interface FunctionWrapperOptions<Args extends any[] = any[], This = any> {
|
|
|
164
173
|
args: Args;
|
|
165
174
|
thisArg: This;
|
|
166
175
|
}
|
|
167
|
-
type EventFilter<Args extends any[] = any[], This = any, Invoke extends AnyFn = AnyFn> = (invoke: Invoke, options: FunctionWrapperOptions<Args, This>) => ReturnType<Invoke> |
|
|
176
|
+
type EventFilter<Args extends any[] = any[], This = any, Invoke extends AnyFn = AnyFn> = (invoke: Invoke, options: FunctionWrapperOptions<Args, This>) => ReturnType<Invoke> | Promisify<ReturnType<Invoke>>;
|
|
168
177
|
interface ConfigurableEventFilter {
|
|
169
178
|
/**
|
|
170
179
|
* Filter for if events should to be received.
|
|
@@ -189,7 +198,7 @@ interface DebounceFilterOptions {
|
|
|
189
198
|
/**
|
|
190
199
|
* @internal
|
|
191
200
|
*/
|
|
192
|
-
declare function createFilterWrapper<T extends AnyFn>(filter: EventFilter, fn: T): (this: any, ...args: ArgumentsType<T>) => Promise<ReturnType<T
|
|
201
|
+
declare function createFilterWrapper<T extends AnyFn>(filter: EventFilter, fn: T): (this: any, ...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
|
|
193
202
|
declare const bypassFilter: EventFilter;
|
|
194
203
|
/**
|
|
195
204
|
* Create an EventFilter that debounce the events
|
|
@@ -199,9 +208,9 @@ declare function debounceFilter(ms: MaybeRefOrGetter<number>, options?: Debounce
|
|
|
199
208
|
* Create an EventFilter that throttle the events
|
|
200
209
|
*
|
|
201
210
|
* @param ms
|
|
202
|
-
* @param [trailing
|
|
203
|
-
* @param [leading
|
|
204
|
-
* @param [rejectOnCancel
|
|
211
|
+
* @param [trailing]
|
|
212
|
+
* @param [leading]
|
|
213
|
+
* @param [rejectOnCancel]
|
|
205
214
|
*/
|
|
206
215
|
declare function throttleFilter(ms: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter<any[], any, AnyFn>;
|
|
207
216
|
/**
|
|
@@ -275,13 +284,19 @@ declare function objectEntries<T extends object>(obj: T): [keyof T, T[keyof T]][
|
|
|
275
284
|
*/
|
|
276
285
|
declare function createGlobalState<Fn extends AnyFn>(stateFactory: Fn): Fn;
|
|
277
286
|
|
|
287
|
+
interface CreateInjectionStateOptions<Return> {
|
|
288
|
+
/**
|
|
289
|
+
* Custom injectionKey for InjectionState
|
|
290
|
+
*/
|
|
291
|
+
injectionKey?: string | InjectionKey<Return>;
|
|
292
|
+
}
|
|
278
293
|
/**
|
|
279
294
|
* Create global state that can be injected into components.
|
|
280
295
|
*
|
|
281
296
|
* @see https://vueuse.org/createInjectionState
|
|
282
297
|
*
|
|
283
298
|
*/
|
|
284
|
-
declare function createInjectionState<Arguments extends Array<any>, Return>(composable: (...args: Arguments) => Return): readonly [useProvidingState: (...args: Arguments) => Return, useInjectedState: () => Return | undefined];
|
|
299
|
+
declare function createInjectionState<Arguments extends Array<any>, Return>(composable: (...args: Arguments) => Return, options?: CreateInjectionStateOptions<Return>): readonly [useProvidingState: (...args: Arguments) => Return, useInjectedState: () => Return | undefined];
|
|
285
300
|
|
|
286
301
|
/**
|
|
287
302
|
* Make a composable function usable with multiple Vue instances.
|
|
@@ -319,12 +334,34 @@ declare function extendRef<R extends Ref<any>, Extend extends object, Options ex
|
|
|
319
334
|
declare function get<T>(ref: MaybeRef<T>): T;
|
|
320
335
|
declare function get<T, K extends keyof T>(ref: MaybeRef<T>, key: K): T[K];
|
|
321
336
|
|
|
337
|
+
/**
|
|
338
|
+
* On the basis of `inject`, it is allowed to directly call inject to obtain the value after call provide in the same component.
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* ```ts
|
|
342
|
+
* injectLocal('MyInjectionKey', 1)
|
|
343
|
+
* const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
declare const injectLocal: typeof inject;
|
|
347
|
+
|
|
322
348
|
declare function isDefined<T>(v: Ref<T>): v is Ref<Exclude<T, null | undefined>>;
|
|
323
349
|
declare function isDefined<T>(v: ComputedRef<T>): v is ComputedRef<Exclude<T, null | undefined>>;
|
|
324
350
|
declare function isDefined<T>(v: T): v is Exclude<T, null | undefined>;
|
|
325
351
|
|
|
326
352
|
declare function makeDestructurable<T extends Record<string, unknown>, A extends readonly any[]>(obj: T, arr: A): T & A;
|
|
327
353
|
|
|
354
|
+
/**
|
|
355
|
+
* On the basis of `provide`, it is allowed to directly call inject to obtain the value after call provide in the same component.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```ts
|
|
359
|
+
* provideLocal('MyInjectionKey', 1)
|
|
360
|
+
* const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
declare const provideLocal: typeof provide;
|
|
364
|
+
|
|
328
365
|
type Reactified<T, Computed extends boolean> = T extends (...args: infer A) => infer R ? (...args: {
|
|
329
366
|
[K in keyof A]: Computed extends true ? MaybeRefOrGetter<A[K]> : MaybeRef<A[K]>;
|
|
330
367
|
}) => ComputedRef<R> : never;
|
|
@@ -397,9 +434,6 @@ declare function refDebounced<T>(value: Ref<T>, ms?: MaybeRefOrGetter<number>, o
|
|
|
397
434
|
|
|
398
435
|
/**
|
|
399
436
|
* Apply default value to a ref.
|
|
400
|
-
*
|
|
401
|
-
* @param source source ref
|
|
402
|
-
* @param targets
|
|
403
437
|
*/
|
|
404
438
|
declare function refDefault<T>(source: Ref<T | undefined | null>, defaultValue: T): Ref<T>;
|
|
405
439
|
|
|
@@ -409,8 +443,8 @@ declare function refDefault<T>(source: Ref<T | undefined | null>, defaultValue:
|
|
|
409
443
|
*
|
|
410
444
|
* @param value Ref value to be watched with throttle effect
|
|
411
445
|
* @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
412
|
-
* @param [trailing
|
|
413
|
-
* @param [leading
|
|
446
|
+
* @param [trailing] if true, update the value again after the delay time is up
|
|
447
|
+
* @param [leading] if true, update the value on the leading edge of the ms timeout
|
|
414
448
|
*/
|
|
415
449
|
declare function refThrottled<T>(value: Ref<T>, delay?: number, trailing?: boolean, leading?: boolean): Ref<T>;
|
|
416
450
|
|
|
@@ -430,9 +464,6 @@ interface ControlledRefOptions<T> {
|
|
|
430
464
|
}
|
|
431
465
|
/**
|
|
432
466
|
* Explicitly define the deps of computed.
|
|
433
|
-
*
|
|
434
|
-
* @param source
|
|
435
|
-
* @param fn
|
|
436
467
|
*/
|
|
437
468
|
declare function refWithControl<T>(initial: T, options?: ControlledRefOptions<T>): vue_demi.ShallowUnwrapRef<{
|
|
438
469
|
get: (tracking?: boolean) => T;
|
|
@@ -450,7 +481,47 @@ declare const controlledRef: typeof refWithControl;
|
|
|
450
481
|
declare function set<T>(ref: Ref<T>, value: T): void;
|
|
451
482
|
declare function set<O extends object, K extends keyof O>(target: O, key: K, value: O[K]): void;
|
|
452
483
|
|
|
453
|
-
|
|
484
|
+
type Direction = 'ltr' | 'rtl' | 'both';
|
|
485
|
+
type SpecificFieldPartial<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
|
|
486
|
+
/**
|
|
487
|
+
* A = B
|
|
488
|
+
*/
|
|
489
|
+
type Equal<A, B> = A extends B ? (B extends A ? true : false) : false;
|
|
490
|
+
/**
|
|
491
|
+
* A ∩ B ≠ ∅
|
|
492
|
+
*/
|
|
493
|
+
type IntersectButNotEqual<A, B> = Equal<A, B> extends true ? false : A & B extends never ? false : true;
|
|
494
|
+
/**
|
|
495
|
+
* A ⊆ B
|
|
496
|
+
*/
|
|
497
|
+
type IncludeButNotEqual<A, B> = Equal<A, B> extends true ? false : A extends B ? true : false;
|
|
498
|
+
/**
|
|
499
|
+
* A ∩ B = ∅
|
|
500
|
+
*/
|
|
501
|
+
type NotIntersect<A, B> = Equal<A, B> extends true ? false : A & B extends never ? true : false;
|
|
502
|
+
interface EqualType<D extends Direction, L, R, O extends keyof Transform<L, R> = D extends 'both' ? 'ltr' | 'rtl' : D> {
|
|
503
|
+
transform?: SpecificFieldPartial<Pick<Transform<L, R>, O>, O>;
|
|
504
|
+
}
|
|
505
|
+
type StrictIncludeMap<IncludeType extends 'LR' | 'RL', D extends Exclude<Direction, 'both'>, L, R> = (Equal<[IncludeType, D], ['LR', 'ltr']> & Equal<[IncludeType, D], ['RL', 'rtl']>) extends true ? {
|
|
506
|
+
transform?: SpecificFieldPartial<Pick<Transform<L, R>, D>, D>;
|
|
507
|
+
} : {
|
|
508
|
+
transform: Pick<Transform<L, R>, D>;
|
|
509
|
+
};
|
|
510
|
+
type StrictIncludeType<IncludeType extends 'LR' | 'RL', D extends Direction, L, R> = D extends 'both' ? {
|
|
511
|
+
transform: SpecificFieldPartial<Transform<L, R>, IncludeType extends 'LR' ? 'ltr' : 'rtl'>;
|
|
512
|
+
} : D extends Exclude<Direction, 'both'> ? StrictIncludeMap<IncludeType, D, L, R> : never;
|
|
513
|
+
type IntersectButNotEqualType<D extends Direction, L, R> = D extends 'both' ? {
|
|
514
|
+
transform: Transform<L, R>;
|
|
515
|
+
} : D extends Exclude<Direction, 'both'> ? {
|
|
516
|
+
transform: Pick<Transform<L, R>, D>;
|
|
517
|
+
} : never;
|
|
518
|
+
type NotIntersectType<D extends Direction, L, R> = IntersectButNotEqualType<D, L, R>;
|
|
519
|
+
interface Transform<L, R> {
|
|
520
|
+
ltr: (left: L) => R;
|
|
521
|
+
rtl: (right: R) => L;
|
|
522
|
+
}
|
|
523
|
+
type TransformType<D extends Direction, L, R> = Equal<L, R> extends true ? EqualType<D, L, R> : IncludeButNotEqual<L, R> extends true ? StrictIncludeType<'LR', D, L, R> : IncludeButNotEqual<R, L> extends true ? StrictIncludeType<'RL', D, L, R> : IntersectButNotEqual<L, R> extends true ? IntersectButNotEqualType<D, L, R> : NotIntersect<L, R> extends true ? NotIntersectType<D, L, R> : never;
|
|
524
|
+
type SyncRefOptions<L, R, D extends Direction> = ConfigurableFlushSync & {
|
|
454
525
|
/**
|
|
455
526
|
* Watch deeply
|
|
456
527
|
*
|
|
@@ -468,22 +539,18 @@ interface SyncRefOptions<L, R = L> extends ConfigurableFlushSync {
|
|
|
468
539
|
*
|
|
469
540
|
* @default 'both'
|
|
470
541
|
*/
|
|
471
|
-
direction?:
|
|
472
|
-
|
|
473
|
-
* Custom transform function
|
|
474
|
-
*/
|
|
475
|
-
transform?: {
|
|
476
|
-
ltr?: (left: L) => R;
|
|
477
|
-
rtl?: (right: R) => L;
|
|
478
|
-
};
|
|
479
|
-
}
|
|
542
|
+
direction?: D;
|
|
543
|
+
} & TransformType<D, L, R>;
|
|
480
544
|
/**
|
|
481
545
|
* Two-way refs synchronization.
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
546
|
+
* From the set theory perspective to restrict the option's type
|
|
547
|
+
* Check in the following order:
|
|
548
|
+
* 1. L = R
|
|
549
|
+
* 2. L ∩ R ≠ ∅
|
|
550
|
+
* 3. L ⊆ R
|
|
551
|
+
* 4. L ∩ R = ∅
|
|
485
552
|
*/
|
|
486
|
-
declare function syncRef<L, R
|
|
553
|
+
declare function syncRef<L, R, D extends Direction>(left: Ref<L>, right: Ref<R>, ...[options]: Equal<L, R> extends true ? [options?: SyncRefOptions<L, R, D>] : [options: SyncRefOptions<L, R, D>]): () => void;
|
|
487
554
|
|
|
488
555
|
interface SyncRefsOptions extends ConfigurableFlushSync {
|
|
489
556
|
/**
|
|
@@ -660,10 +727,10 @@ declare function useArrayDifference<T>(list: MaybeRefOrGetter<T[]>, values: Mayb
|
|
|
660
727
|
* Reactive `Array.every`
|
|
661
728
|
*
|
|
662
729
|
* @see https://vueuse.org/useArrayEvery
|
|
663
|
-
* @param
|
|
730
|
+
* @param list - the array was called upon.
|
|
664
731
|
* @param fn - a function to test each element.
|
|
665
732
|
*
|
|
666
|
-
* @returns
|
|
733
|
+
* @returns **true** if the `fn` function returns a **truthy** value for every element from the array. Otherwise, **false**.
|
|
667
734
|
*/
|
|
668
735
|
declare function useArrayEvery<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): ComputedRef<boolean>;
|
|
669
736
|
|
|
@@ -671,10 +738,10 @@ declare function useArrayEvery<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>,
|
|
|
671
738
|
* Reactive `Array.filter`
|
|
672
739
|
*
|
|
673
740
|
* @see https://vueuse.org/useArrayFilter
|
|
674
|
-
* @param
|
|
741
|
+
* @param list - the array was called upon.
|
|
675
742
|
* @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array.
|
|
676
743
|
*
|
|
677
|
-
* @returns
|
|
744
|
+
* @returns a shallow copy of a portion of the given array, filtered down to just the elements from the given array that pass the test implemented by the provided function. If no elements pass the test, an empty array will be returned.
|
|
678
745
|
*/
|
|
679
746
|
declare function useArrayFilter<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => boolean): ComputedRef<T[]>;
|
|
680
747
|
|
|
@@ -682,7 +749,7 @@ declare function useArrayFilter<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>
|
|
|
682
749
|
* Reactive `Array.find`
|
|
683
750
|
*
|
|
684
751
|
* @see https://vueuse.org/useArrayFind
|
|
685
|
-
* @param
|
|
752
|
+
* @param list - the array was called upon.
|
|
686
753
|
* @param fn - a function to test each element.
|
|
687
754
|
*
|
|
688
755
|
* @returns the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
|
|
@@ -693,10 +760,10 @@ declare function useArrayFind<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>,
|
|
|
693
760
|
* Reactive `Array.findIndex`
|
|
694
761
|
*
|
|
695
762
|
* @see https://vueuse.org/useArrayFindIndex
|
|
696
|
-
* @param
|
|
763
|
+
* @param list - the array was called upon.
|
|
697
764
|
* @param fn - a function to test each element.
|
|
698
765
|
*
|
|
699
|
-
* @returns
|
|
766
|
+
* @returns the index of the first element in the array that passes the test. Otherwise, "-1".
|
|
700
767
|
*/
|
|
701
768
|
declare function useArrayFindIndex<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): ComputedRef<number>;
|
|
702
769
|
|
|
@@ -704,7 +771,7 @@ declare function useArrayFindIndex<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>
|
|
|
704
771
|
* Reactive `Array.findLast`
|
|
705
772
|
*
|
|
706
773
|
* @see https://vueuse.org/useArrayFindLast
|
|
707
|
-
* @param
|
|
774
|
+
* @param list - the array was called upon.
|
|
708
775
|
* @param fn - a function to test each element.
|
|
709
776
|
*
|
|
710
777
|
* @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
|
|
@@ -716,6 +783,13 @@ interface UseArrayIncludesOptions<T, V> {
|
|
|
716
783
|
fromIndex?: number;
|
|
717
784
|
comparator?: UseArrayIncludesComparatorFn<T, V> | keyof T;
|
|
718
785
|
}
|
|
786
|
+
/**
|
|
787
|
+
* Reactive `Array.includes`
|
|
788
|
+
*
|
|
789
|
+
* @see https://vueuse.org/useArrayIncludes
|
|
790
|
+
*
|
|
791
|
+
* @returns true if the `value` is found in the array. Otherwise, false.
|
|
792
|
+
*/
|
|
719
793
|
declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, comparator?: UseArrayIncludesComparatorFn<T, V>): ComputedRef<boolean>;
|
|
720
794
|
declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, comparator?: keyof T): ComputedRef<boolean>;
|
|
721
795
|
declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, options?: UseArrayIncludesOptions<T, V>): ComputedRef<boolean>;
|
|
@@ -724,10 +798,10 @@ declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrG
|
|
|
724
798
|
* Reactive `Array.join`
|
|
725
799
|
*
|
|
726
800
|
* @see https://vueuse.org/useArrayJoin
|
|
727
|
-
* @param
|
|
728
|
-
* @param
|
|
801
|
+
* @param list - the array was called upon.
|
|
802
|
+
* @param separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (",").
|
|
729
803
|
*
|
|
730
|
-
* @returns
|
|
804
|
+
* @returns a string with all array elements joined. If arr.length is 0, the empty string is returned.
|
|
731
805
|
*/
|
|
732
806
|
declare function useArrayJoin(list: MaybeRefOrGetter<MaybeRefOrGetter<any>[]>, separator?: MaybeRefOrGetter<string>): ComputedRef<string>;
|
|
733
807
|
|
|
@@ -735,10 +809,10 @@ declare function useArrayJoin(list: MaybeRefOrGetter<MaybeRefOrGetter<any>[]>, s
|
|
|
735
809
|
* Reactive `Array.map`
|
|
736
810
|
*
|
|
737
811
|
* @see https://vueuse.org/useArrayMap
|
|
738
|
-
* @param
|
|
812
|
+
* @param list - the array was called upon.
|
|
739
813
|
* @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array.
|
|
740
814
|
*
|
|
741
|
-
* @returns
|
|
815
|
+
* @returns a new array with each element being the result of the callback function.
|
|
742
816
|
*/
|
|
743
817
|
declare function useArrayMap<T, U = T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => U): ComputedRef<U[]>;
|
|
744
818
|
|
|
@@ -747,7 +821,7 @@ type UseArrayReducer<PV, CV, R> = (previousValue: PV, currentValue: CV, currentI
|
|
|
747
821
|
* Reactive `Array.reduce`
|
|
748
822
|
*
|
|
749
823
|
* @see https://vueuse.org/useArrayReduce
|
|
750
|
-
* @param
|
|
824
|
+
* @param list - the array was called upon.
|
|
751
825
|
* @param reducer - a "reducer" function.
|
|
752
826
|
*
|
|
753
827
|
* @returns the value that results from running the "reducer" callback function to completion over the entire array.
|
|
@@ -757,7 +831,7 @@ declare function useArrayReduce<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>
|
|
|
757
831
|
* Reactive `Array.reduce`
|
|
758
832
|
*
|
|
759
833
|
* @see https://vueuse.org/useArrayReduce
|
|
760
|
-
* @param
|
|
834
|
+
* @param list - the array was called upon.
|
|
761
835
|
* @param reducer - a "reducer" function.
|
|
762
836
|
* @param initialValue - a value to be initialized the first time when the callback is called.
|
|
763
837
|
*
|
|
@@ -769,19 +843,19 @@ declare function useArrayReduce<T, U>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>
|
|
|
769
843
|
* Reactive `Array.some`
|
|
770
844
|
*
|
|
771
845
|
* @see https://vueuse.org/useArraySome
|
|
772
|
-
* @param
|
|
846
|
+
* @param list - the array was called upon.
|
|
773
847
|
* @param fn - a function to test each element.
|
|
774
848
|
*
|
|
775
|
-
* @returns
|
|
849
|
+
* @returns **true** if the `fn` function returns a **truthy** value for any element from the array. Otherwise, **false**.
|
|
776
850
|
*/
|
|
777
851
|
declare function useArraySome<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): ComputedRef<boolean>;
|
|
778
852
|
|
|
779
853
|
/**
|
|
780
854
|
* reactive unique array
|
|
781
855
|
* @see https://vueuse.org/useArrayUnique
|
|
782
|
-
* @param
|
|
856
|
+
* @param list - the array was called upon.
|
|
783
857
|
* @param compareFn
|
|
784
|
-
* @returns
|
|
858
|
+
* @returns A computed ref that returns a unique array of items.
|
|
785
859
|
*/
|
|
786
860
|
declare function useArrayUnique<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, compareFn?: (a: T, b: T, array: T[]) => boolean): ComputedRef<T[]>;
|
|
787
861
|
|
|
@@ -793,8 +867,8 @@ interface UseCounterOptions {
|
|
|
793
867
|
* Basic counter with utility functions.
|
|
794
868
|
*
|
|
795
869
|
* @see https://vueuse.org/useCounter
|
|
796
|
-
* @param [initialValue
|
|
797
|
-
* @param
|
|
870
|
+
* @param [initialValue]
|
|
871
|
+
* @param options
|
|
798
872
|
*/
|
|
799
873
|
declare function useCounter(initialValue?: MaybeRef$1<number>, options?: UseCounterOptions): {
|
|
800
874
|
count: vue_demi.Ref<number>;
|
|
@@ -838,7 +912,7 @@ type UseDateFormatReturn = ReturnType<typeof useDateFormat>;
|
|
|
838
912
|
* @see https://vueuse.org/useDebounceFn
|
|
839
913
|
* @param fn A function to be executed after delay milliseconds debounced.
|
|
840
914
|
* @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
841
|
-
* @param
|
|
915
|
+
* @param options Options
|
|
842
916
|
*
|
|
843
917
|
* @return A new, debounce, function.
|
|
844
918
|
*/
|
|
@@ -908,8 +982,7 @@ interface UseLastChangedOptions<Immediate extends boolean, InitialValue extends
|
|
|
908
982
|
* @see https://vueuse.org/useLastChanged
|
|
909
983
|
*/
|
|
910
984
|
declare function useLastChanged(source: WatchSource, options?: UseLastChangedOptions<false>): Ref<number | null>;
|
|
911
|
-
declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<true>): Ref<number>;
|
|
912
|
-
declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<boolean, number>): Ref<number>;
|
|
985
|
+
declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<true> | UseLastChangedOptions<boolean, number>): Ref<number>;
|
|
913
986
|
|
|
914
987
|
/**
|
|
915
988
|
* Throttle execution of a function. Especially useful for rate limiting
|
|
@@ -919,11 +992,11 @@ declare function useLastChanged(source: WatchSource, options: UseLastChangedOpti
|
|
|
919
992
|
* to `callback` when the throttled-function is executed.
|
|
920
993
|
* @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
921
994
|
*
|
|
922
|
-
* @param [trailing
|
|
995
|
+
* @param [trailing] if true, call fn again after the time is up
|
|
923
996
|
*
|
|
924
|
-
* @param [leading
|
|
997
|
+
* @param [leading] if true, call fn on the leading edge of the ms timeout
|
|
925
998
|
*
|
|
926
|
-
* @param [rejectOnCancel
|
|
999
|
+
* @param [rejectOnCancel] if true, reject the last call if it's been cancel
|
|
927
1000
|
*
|
|
928
1001
|
* @return A new, throttled, function.
|
|
929
1002
|
*/
|
|
@@ -1057,8 +1130,8 @@ declare function watchImmediate<T extends Readonly<MultiWatchSources>>(source: T
|
|
|
1057
1130
|
declare function watchImmediate<T>(source: WatchSource<T>, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchStopHandle;
|
|
1058
1131
|
declare function watchImmediate<T extends object>(source: T, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchStopHandle;
|
|
1059
1132
|
|
|
1060
|
-
declare function watchOnce<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchOptions<Immediate>):
|
|
1061
|
-
declare function watchOnce<T, Immediate extends Readonly<boolean> = false>(sources: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchOptions<Immediate>):
|
|
1133
|
+
declare function watchOnce<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchOptions<Immediate>): WatchStopHandle;
|
|
1134
|
+
declare function watchOnce<T, Immediate extends Readonly<boolean> = false>(sources: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchOptions<Immediate>): WatchStopHandle;
|
|
1062
1135
|
|
|
1063
1136
|
interface WatchPausableReturn extends Pausable {
|
|
1064
1137
|
stop: WatchStopHandle;
|
|
@@ -1093,4 +1166,4 @@ declare function watchTriggerable<T extends object, FnReturnT>(source: T, cb: Wa
|
|
|
1093
1166
|
*/
|
|
1094
1167
|
declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WatchOptions): vue_demi.WatchStopHandle;
|
|
1095
1168
|
|
|
1096
|
-
export { type AnyFn, type ArgumentsType, type Arrayable, type Awaitable, type ComputedRefWithControl, type ComputedWithControlRefExtra, type ConfigurableEventFilter, type ConfigurableFlush, type ConfigurableFlushSync, type ControlledRefOptions, type DateLike, type DebounceFilterOptions, type DeepMaybeRef, type ElementOf, type EventFilter, type EventHook, type EventHookOff, type EventHookOn, type EventHookTrigger, type ExtendRefOptions, type Fn, type FunctionArgs, type FunctionWrapperOptions, type IgnoredUpdater, type MapOldSources, type MapSources, type MaybeRef, type MaybeRefOrGetter, type MultiWatchSources, type Mutable, type Pausable, type PromisifyFn, type Reactified, type ReactifyNested, type ReactifyObjectOptions, type ReactifyOptions, type ReactiveOmitPredicate, type ReactivePickPredicate, type ReadonlyRefOrGetter, type RemovableRef, type ShallowUnwrapRef, type SingletonPromiseReturn, type Stoppable, type SyncRefOptions, type SyncRefsOptions, type ToRefsOptions, type UntilArrayInstance, type UntilBaseInstance, type UntilToMatchOptions, type UntilValueInstance, type UseArrayIncludesComparatorFn, type UseArrayIncludesOptions, type UseArrayReducer, type UseCounterOptions, type UseDateFormatOptions, type UseDateFormatReturn, type UseIntervalControls, type UseIntervalFnOptions, type UseIntervalOptions, type UseLastChangedOptions, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseToNumberOptions, type UseToggleOptions, type WatchArrayCallback, type WatchAtMostOptions, type WatchAtMostReturn, type WatchDebouncedOptions, type WatchIgnorableReturn, type WatchPausableReturn, type WatchThrottledOptions, type WatchTriggerableCallback, type WatchTriggerableReturn, type WatchWithFilterOptions, type WritableComputedRefWithControl, assert, refAutoReset as autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isClient, isDef, isDefined, isIOS, isObject, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
|
|
1169
|
+
export { type AnyFn, type ArgumentsType, type Arrayable, type Awaitable, type Awaited, type ComputedRefWithControl, type ComputedWithControlRefExtra, type ConfigurableEventFilter, type ConfigurableFlush, type ConfigurableFlushSync, type ControlledRefOptions, type CreateInjectionStateOptions, type DateLike, type DebounceFilterOptions, type DeepMaybeRef, type ElementOf, type EventFilter, type EventHook, type EventHookOff, type EventHookOn, type EventHookTrigger, type ExtendRefOptions, type Fn, type FunctionArgs, type FunctionWrapperOptions, type IgnoredUpdater, type MapOldSources, type MapSources, type MaybeRef, type MaybeRefOrGetter, type MultiWatchSources, type Mutable, type Pausable, type Promisify, type PromisifyFn, type Reactified, type ReactifyNested, type ReactifyObjectOptions, type ReactifyOptions, type ReactiveOmitPredicate, type ReactivePickPredicate, type ReadonlyRefOrGetter, type RemovableRef, type ShallowUnwrapRef, type SingletonPromiseReturn, type Stoppable, type SyncRefOptions, type SyncRefsOptions, type ToRefsOptions, type UntilArrayInstance, type UntilBaseInstance, type UntilToMatchOptions, type UntilValueInstance, type UseArrayIncludesComparatorFn, type UseArrayIncludesOptions, type UseArrayReducer, type UseCounterOptions, type UseDateFormatOptions, type UseDateFormatReturn, type UseIntervalControls, type UseIntervalFnOptions, type UseIntervalOptions, type UseLastChangedOptions, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseToNumberOptions, type UseToggleOptions, type WatchArrayCallback, type WatchAtMostOptions, type WatchAtMostReturn, type WatchDebouncedOptions, type WatchIgnorableReturn, type WatchPausableReturn, type WatchThrottledOptions, type WatchTriggerableCallback, type WatchTriggerableReturn, type WatchWithFilterOptions, type WritableComputedRefWithControl, assert, refAutoReset as autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, provideLocal, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
|