@vueuse/shared 12.8.2 → 13.0.0-beta.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.
Files changed (4) hide show
  1. package/package.json +4 -10
  2. package/index.cjs +0 -1732
  3. package/index.d.cts +0 -1260
  4. package/index.d.ts +0 -1260
package/index.d.cts DELETED
@@ -1,1260 +0,0 @@
1
- import * as vue from 'vue';
2
- import { WatchOptionsBase, ShallowRef, WatchSource, ComputedGetter, ComputedRef, WritableComputedOptions, WritableComputedRef, WatchOptions, Ref, MaybeRef, MaybeRefOrGetter, InjectionKey, ShallowUnwrapRef as ShallowUnwrapRef$1, inject, provide, UnwrapNestedRefs, UnwrapRef, ToRef, ToRefs, toValue as toValue$1, WatchCallback, WatchStopHandle } from 'vue';
3
- export { MaybeRef, MaybeRefOrGetter } from 'vue';
4
-
5
- /**
6
- * Note: If you are using Vue 3.4+, you can straight use computed instead.
7
- * Because in Vue 3.4+, if computed new value does not change,
8
- * computed, effect, watch, watchEffect, render dependencies will not be triggered.
9
- * refer: https://github.com/vuejs/core/pull/5912
10
- *
11
- * @param fn effect function
12
- * @param options WatchOptionsBase
13
- * @returns readonly shallowRef
14
- */
15
- declare function computedEager<T>(fn: () => T, options?: WatchOptionsBase): Readonly<ShallowRef<T>>;
16
-
17
- interface ComputedWithControlRefExtra {
18
- /**
19
- * Force update the computed value.
20
- */
21
- trigger: () => void;
22
- }
23
- interface ComputedRefWithControl<T> extends ComputedRef<T>, ComputedWithControlRefExtra {
24
- }
25
- interface WritableComputedRefWithControl<T> extends WritableComputedRef<T>, ComputedWithControlRefExtra {
26
- }
27
- declare function computedWithControl<T, S>(source: WatchSource<S> | WatchSource<S>[], fn: ComputedGetter<T>): ComputedRefWithControl<T>;
28
- declare function computedWithControl<T, S>(source: WatchSource<S> | WatchSource<S>[], fn: WritableComputedOptions<T>): WritableComputedRefWithControl<T>;
29
-
30
- /**
31
- * Void function
32
- */
33
- type Fn = () => void;
34
- /**
35
- * Any function
36
- */
37
- type AnyFn = (...args: any[]) => any;
38
- /**
39
- * A ref that allow to set null or undefined
40
- */
41
- type RemovableRef<T> = Omit<Ref<T>, 'value'> & {
42
- get value(): T;
43
- set value(value: T | null | undefined);
44
- };
45
- /**
46
- * Maybe it's a computed ref, or a readonly value, or a getter function
47
- */
48
- type ReadonlyRefOrGetter<T> = ComputedRef<T> | (() => T);
49
- /**
50
- * Make all the nested attributes of an object or array to MaybeRef<T>
51
- *
52
- * Good for accepting options that will be wrapped with `reactive` or `ref`
53
- *
54
- * ```ts
55
- * UnwrapRef<DeepMaybeRef<T>> === T
56
- * ```
57
- */
58
- type DeepMaybeRef<T> = T extends Ref<infer V> ? MaybeRef<V> : T extends Array<any> | object ? {
59
- [K in keyof T]: DeepMaybeRef<T[K]>;
60
- } : MaybeRef<T>;
61
- type Arrayable<T> = T[] | T;
62
- /**
63
- * Infers the element type of an array
64
- */
65
- type ElementOf<T> = T extends (infer E)[] ? E : never;
66
- type ShallowUnwrapRef<T> = T extends Ref<infer P> ? P : T;
67
- type Awaitable<T> = Promise<T> | T;
68
- type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
69
- /**
70
- * Compatible with versions below TypeScript 4.5 Awaited
71
- */
72
- type Awaited<T> = T extends null | undefined ? T : T extends object & {
73
- then: (onfulfilled: infer F, ...args: infer _) => any;
74
- } ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T;
75
- type Promisify<T> = Promise<Awaited<T>>;
76
- type PromisifyFn<T extends AnyFn> = (...args: ArgumentsType<T>) => Promisify<ReturnType<T>>;
77
- interface Pausable {
78
- /**
79
- * A ref indicate whether a pausable instance is active
80
- */
81
- isActive: Readonly<ShallowRef<boolean>>;
82
- /**
83
- * Temporary pause the effect from executing
84
- */
85
- pause: Fn;
86
- /**
87
- * Resume the effects
88
- */
89
- resume: Fn;
90
- }
91
- interface Stoppable<StartFnArgs extends any[] = any[]> {
92
- /**
93
- * A ref indicate whether a stoppable instance is executing
94
- */
95
- isPending: Readonly<Ref<boolean>>;
96
- /**
97
- * Stop the effect from executing
98
- */
99
- stop: Fn;
100
- /**
101
- * Start the effects
102
- */
103
- start: (...args: StartFnArgs) => void;
104
- }
105
- interface ConfigurableFlush {
106
- /**
107
- * Timing for monitoring changes, refer to WatchOptions for more details
108
- *
109
- * @default 'pre'
110
- */
111
- flush?: WatchOptions['flush'];
112
- }
113
- interface ConfigurableFlushSync {
114
- /**
115
- * Timing for monitoring changes, refer to WatchOptions for more details.
116
- * Unlike `watch()`, the default is set to `sync`
117
- *
118
- * @default 'sync'
119
- */
120
- flush?: WatchOptions['flush'];
121
- }
122
- type MultiWatchSources = (WatchSource<unknown> | object)[];
123
- type MapSources<T> = {
124
- [K in keyof T]: T[K] extends WatchSource<infer V> ? V : never;
125
- };
126
- type MapOldSources<T, Immediate> = {
127
- [K in keyof T]: T[K] extends WatchSource<infer V> ? Immediate extends true ? V | undefined : V : never;
128
- };
129
- type Mutable<T> = {
130
- -readonly [P in keyof T]: T[P];
131
- };
132
- type IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N;
133
- /**
134
- * will return `true` if `T` is `any`, or `false` otherwise
135
- */
136
- type IsAny<T> = IfAny<T, true, false>;
137
-
138
- /**
139
- * The source code for this function was inspired by vue-apollo's `useEventHook` util
140
- * https://github.com/vuejs/vue-apollo/blob/v4/packages/vue-apollo-composable/src/util/useEventHook.ts
141
- */
142
-
143
- type Callback<T> = IsAny<T> extends true ? (...param: any) => void : ([
144
- T
145
- ] extends [void] ? (...param: unknown[]) => void : [T] extends [any[]] ? (...param: T) => void : (...param: [T, ...unknown[]]) => void);
146
- type EventHookOn<T = any> = (fn: Callback<T>) => {
147
- off: () => void;
148
- };
149
- type EventHookOff<T = any> = (fn: Callback<T>) => void;
150
- type EventHookTrigger<T = any> = (...param: Parameters<Callback<T>>) => Promise<unknown[]>;
151
- interface EventHook<T = any> {
152
- on: EventHookOn<T>;
153
- off: EventHookOff<T>;
154
- trigger: EventHookTrigger<T>;
155
- clear: () => void;
156
- }
157
- /**
158
- * Utility for creating event hooks
159
- *
160
- * @see https://vueuse.org/createEventHook
161
- */
162
- declare function createEventHook<T = any>(): EventHook<T>;
163
-
164
- type FunctionArgs<Args extends any[] = any[], Return = void> = (...args: Args) => Return;
165
- interface FunctionWrapperOptions<Args extends any[] = any[], This = any> {
166
- fn: FunctionArgs<Args, This>;
167
- args: Args;
168
- thisArg: This;
169
- }
170
- type EventFilter<Args extends any[] = any[], This = any, Invoke extends AnyFn = AnyFn> = (invoke: Invoke, options: FunctionWrapperOptions<Args, This>) => ReturnType<Invoke> | Promisify<ReturnType<Invoke>>;
171
- interface ConfigurableEventFilter {
172
- /**
173
- * Filter for if events should to be received.
174
- *
175
- * @see https://vueuse.org/guide/config.html#event-filters
176
- */
177
- eventFilter?: EventFilter;
178
- }
179
- interface DebounceFilterOptions {
180
- /**
181
- * The maximum time allowed to be delayed before it's invoked.
182
- * In milliseconds.
183
- */
184
- maxWait?: MaybeRefOrGetter<number>;
185
- /**
186
- * Whether to reject the last call if it's been cancel.
187
- *
188
- * @default false
189
- */
190
- rejectOnCancel?: boolean;
191
- }
192
- /**
193
- * @internal
194
- */
195
- declare function createFilterWrapper<T extends AnyFn>(filter: EventFilter, fn: T): (this: any, ...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
196
- declare const bypassFilter: EventFilter;
197
- /**
198
- * Create an EventFilter that debounce the events
199
- */
200
- declare function debounceFilter(ms: MaybeRefOrGetter<number>, options?: DebounceFilterOptions): EventFilter<any[], any, AnyFn>;
201
- interface ThrottleFilterOptions {
202
- /**
203
- * The maximum time allowed to be delayed before it's invoked.
204
- */
205
- delay: MaybeRefOrGetter<number>;
206
- /**
207
- * Whether to invoke on the trailing edge of the timeout.
208
- */
209
- trailing?: boolean;
210
- /**
211
- * Whether to invoke on the leading edge of the timeout.
212
- */
213
- leading?: boolean;
214
- /**
215
- * Whether to reject the last call if it's been cancel.
216
- */
217
- rejectOnCancel?: boolean;
218
- }
219
- /**
220
- * Create an EventFilter that throttle the events
221
- *
222
- * @param ms
223
- * @param [trailing]
224
- * @param [leading]
225
- * @param [rejectOnCancel]
226
- */
227
- declare function throttleFilter(ms: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter;
228
- declare function throttleFilter(options: ThrottleFilterOptions): EventFilter;
229
- interface PausableFilterOptions {
230
- /**
231
- * The initial state
232
- *
233
- * @default 'active'
234
- */
235
- initialState?: 'active' | 'paused';
236
- }
237
- /**
238
- * EventFilter that gives extra controls to pause and resume the filter
239
- *
240
- * @param extendFilter Extra filter to apply when the PausableFilter is active, default to none
241
- * @param options Options to configure the filter
242
- */
243
- declare function pausableFilter(extendFilter?: EventFilter, options?: PausableFilterOptions): Pausable & {
244
- eventFilter: EventFilter;
245
- };
246
-
247
- declare const isClient: boolean;
248
- declare const isWorker: boolean;
249
- declare const isDef: <T = any>(val?: T) => val is T;
250
- declare const notNullish: <T = any>(val?: T | null | undefined) => val is T;
251
- declare const assert: (condition: boolean, ...infos: any[]) => void;
252
- declare const isObject: (val: any) => val is object;
253
- declare const now: () => number;
254
- declare const timestamp: () => number;
255
- declare const clamp: (n: number, min: number, max: number) => number;
256
- declare const noop: () => void;
257
- declare const rand: (min: number, max: number) => number;
258
- declare const hasOwn: <T extends object, K extends keyof T>(val: T, key: K) => key is K;
259
- declare const isIOS: boolean | "";
260
-
261
- declare const hyphenate: (str: string) => string;
262
- declare const camelize: (str: string) => string;
263
-
264
- declare function promiseTimeout(ms: number, throwOnTimeout?: boolean, reason?: string): Promise<void>;
265
- declare function identity<T>(arg: T): T;
266
- interface SingletonPromiseReturn<T> {
267
- (): Promise<T>;
268
- /**
269
- * Reset current staled promise.
270
- * await it to have proper shutdown.
271
- */
272
- reset: () => Promise<void>;
273
- }
274
- /**
275
- * Create singleton promise function
276
- *
277
- * @example
278
- * ```
279
- * const promise = createSingletonPromise(async () => { ... })
280
- *
281
- * await promise()
282
- * await promise() // all of them will be bind to a single promise instance
283
- * await promise() // and be resolved together
284
- * ```
285
- */
286
- declare function createSingletonPromise<T>(fn: () => Promise<T>): SingletonPromiseReturn<T>;
287
- declare function invoke<T>(fn: () => T): T;
288
- declare function containsProp(obj: object, ...props: string[]): boolean;
289
- /**
290
- * Increase string a value with unit
291
- *
292
- * @example '2px' + 1 = '3px'
293
- * @example '15em' + (-2) = '13em'
294
- */
295
- declare function increaseWithUnit(target: number, delta: number): number;
296
- declare function increaseWithUnit(target: string, delta: number): string;
297
- declare function increaseWithUnit(target: string | number, delta: number): string | number;
298
- /**
299
- * Get a px value for SSR use, do not rely on this method outside of SSR as REM unit is assumed at 16px, which might not be the case on the client
300
- */
301
- declare function pxValue(px: string): number;
302
- /**
303
- * Create a new subset object by giving keys
304
- */
305
- declare function objectPick<O extends object, T extends keyof O>(obj: O, keys: T[], omitUndefined?: boolean): Pick<O, T>;
306
- /**
307
- * Create a new subset object by omit giving keys
308
- */
309
- declare function objectOmit<O extends object, T extends keyof O>(obj: O, keys: T[], omitUndefined?: boolean): Omit<O, T>;
310
- declare function objectEntries<T extends object>(obj: T): Array<[keyof T, T[keyof T]]>;
311
- declare function getLifeCycleTarget(target?: any): any;
312
- declare function toArray<T>(value: T | readonly T[]): readonly T[];
313
- declare function toArray<T>(value: T | T[]): T[];
314
-
315
- /**
316
- * Keep states in the global scope to be reusable across Vue instances.
317
- *
318
- * @see https://vueuse.org/createGlobalState
319
- * @param stateFactory A factory function to create the state
320
- */
321
- declare function createGlobalState<Fn extends AnyFn>(stateFactory: Fn): Fn;
322
-
323
- interface CreateInjectionStateOptions<Return> {
324
- /**
325
- * Custom injectionKey for InjectionState
326
- */
327
- injectionKey?: string | InjectionKey<Return>;
328
- /**
329
- * Default value for the InjectionState
330
- */
331
- defaultValue?: Return;
332
- }
333
- /**
334
- * Create global state that can be injected into components.
335
- *
336
- * @see https://vueuse.org/createInjectionState
337
- *
338
- */
339
- declare function createInjectionState<Arguments extends Array<any>, Return>(composable: (...args: Arguments) => Return, options?: CreateInjectionStateOptions<Return>): readonly [useProvidingState: (...args: Arguments) => Return, useInjectedState: () => Return | undefined];
340
-
341
- type ShallowOrDeepRef<T = any, D extends boolean = false> = D extends true ? Ref<T> : ShallowRef<T>;
342
- /**
343
- * Returns a `deepRef` or `shallowRef` depending on the `deep` param.
344
- *
345
- * @example createRef(1) // ShallowRef<number>
346
- * @example createRef(1, false) // ShallowRef<number>
347
- * @example createRef(1, true) // Ref<number>
348
- * @example createRef("string") // ShallowRef<string>
349
- * @example createRef<"A"|"B">("A", true) // Ref<"A"|"B">
350
- *
351
- * @param value
352
- * @param deep
353
- * @returns the `deepRef` or `shallowRef`
354
- */
355
- declare function createRef<T = any, D extends boolean = false>(value: T, deep?: D): ShallowOrDeepRef<T, D>;
356
-
357
- /**
358
- * Make a composable function usable with multiple Vue instances.
359
- *
360
- * @see https://vueuse.org/createSharedComposable
361
- */
362
- declare function createSharedComposable<Fn extends AnyFn>(composable: Fn): Fn;
363
-
364
- interface ExtendRefOptions<Unwrap extends boolean = boolean> {
365
- /**
366
- * Is the extends properties enumerable
367
- *
368
- * @default false
369
- */
370
- enumerable?: boolean;
371
- /**
372
- * Unwrap for Ref properties
373
- *
374
- * @default true
375
- */
376
- unwrap?: Unwrap;
377
- }
378
- /**
379
- * Overload 1: Unwrap set to false
380
- */
381
- declare function extendRef<R extends Ref<any>, Extend extends object, Options extends ExtendRefOptions<false>>(ref: R, extend: Extend, options?: Options): ShallowUnwrapRef$1<Extend> & R;
382
- /**
383
- * Overload 2: Unwrap unset or set to true
384
- */
385
- declare function extendRef<R extends Ref<any>, Extend extends object, Options extends ExtendRefOptions>(ref: R, extend: Extend, options?: Options): Extend & R;
386
-
387
- /**
388
- * Shorthand for accessing `ref.value`
389
- */
390
- declare function get<T>(ref: MaybeRef<T>): T;
391
- declare function get<T, K extends keyof T>(ref: MaybeRef<T>, key: K): T[K];
392
-
393
- /**
394
- * On the basis of `inject`, it is allowed to directly call inject to obtain the value after call provide in the same component.
395
- *
396
- * @example
397
- * ```ts
398
- * injectLocal('MyInjectionKey', 1)
399
- * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
400
- * ```
401
- */
402
- declare const injectLocal: typeof inject;
403
-
404
- declare function isDefined<T>(v: ComputedRef<T>): v is ComputedRef<Exclude<T, null | undefined>>;
405
- declare function isDefined<T>(v: Ref<T>): v is Ref<Exclude<T, null | undefined>>;
406
- declare function isDefined<T>(v: T): v is Exclude<T, null | undefined>;
407
-
408
- declare function makeDestructurable<T extends Record<string, unknown>, A extends readonly any[]>(obj: T, arr: A): T & A;
409
-
410
- /**
411
- * On the basis of `provide`, it is allowed to directly call inject to obtain the value after call provide in the same component.
412
- *
413
- * @example
414
- * ```ts
415
- * provideLocal('MyInjectionKey', 1)
416
- * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
417
- * ```
418
- */
419
- declare const provideLocal: typeof provide;
420
-
421
- type Reactified<T, Computed extends boolean> = T extends (...args: infer A) => infer R ? (...args: {
422
- [K in keyof A]: Computed extends true ? MaybeRefOrGetter<A[K]> : MaybeRef<A[K]>;
423
- }) => ComputedRef<R> : never;
424
- interface ReactifyOptions<T extends boolean> {
425
- /**
426
- * Accept passing a function as a reactive getter
427
- *
428
- * @default true
429
- */
430
- computedGetter?: T;
431
- }
432
- /**
433
- * Converts plain function into a reactive function.
434
- * The converted function accepts refs as it's arguments
435
- * and returns a ComputedRef, with proper typing.
436
- *
437
- * @param fn - Source function
438
- */
439
- declare function reactify<T extends Function, K extends boolean = true>(fn: T, options?: ReactifyOptions<K>): Reactified<T, K>;
440
-
441
- type ReactifyNested<T, Keys extends keyof T = keyof T, S extends boolean = true> = {
442
- [K in Keys]: T[K] extends AnyFn ? Reactified<T[K], S> : T[K];
443
- };
444
- interface ReactifyObjectOptions<T extends boolean> extends ReactifyOptions<T> {
445
- /**
446
- * Includes names from Object.getOwnPropertyNames
447
- *
448
- * @default true
449
- */
450
- includeOwnProperties?: boolean;
451
- }
452
- /**
453
- * Apply `reactify` to an object
454
- */
455
- declare function reactifyObject<T extends object, Keys extends keyof T>(obj: T, keys?: (keyof T)[]): ReactifyNested<T, Keys, true>;
456
- declare function reactifyObject<T extends object, S extends boolean = true>(obj: T, options?: ReactifyObjectOptions<S>): ReactifyNested<T, keyof T, S>;
457
-
458
- /**
459
- * Computed reactive object.
460
- */
461
- declare function reactiveComputed<T extends object>(fn: ComputedGetter<T>): UnwrapNestedRefs<T>;
462
-
463
- type ReactiveOmitPredicate<T> = (value: T[keyof T], key: keyof T) => boolean;
464
- declare function reactiveOmit<T extends object, K extends keyof T>(obj: T, ...keys: (K | K[])[]): Omit<T, K>;
465
- declare function reactiveOmit<T extends object>(obj: T, predicate: ReactiveOmitPredicate<T>): Partial<T>;
466
-
467
- type ReactivePickPredicate<T> = (value: T[keyof T], key: keyof T) => boolean;
468
- declare function reactivePick<T extends object, K extends keyof T>(obj: T, ...keys: (K | K[])[]): {
469
- [S in K]: UnwrapRef<T[S]>;
470
- };
471
- declare function reactivePick<T extends object>(obj: T, predicate: ReactivePickPredicate<T>): {
472
- [S in keyof T]?: UnwrapRef<T[S]>;
473
- };
474
-
475
- /**
476
- * Create a ref which will be reset to the default value after some time.
477
- *
478
- * @see https://vueuse.org/refAutoReset
479
- * @param defaultValue The value which will be set.
480
- * @param afterMs A zero-or-greater delay in milliseconds.
481
- */
482
- declare function refAutoReset<T>(defaultValue: MaybeRefOrGetter<T>, afterMs?: MaybeRefOrGetter<number>): Ref<T>;
483
-
484
- /**
485
- * Debounce updates of a ref.
486
- *
487
- * @return A new debounced ref.
488
- */
489
- declare function refDebounced<T>(value: Ref<T>, ms?: MaybeRefOrGetter<number>, options?: DebounceFilterOptions): Readonly<Ref<T>>;
490
-
491
- /**
492
- * Apply default value to a ref.
493
- */
494
- declare function refDefault<T>(source: Ref<T | undefined | null>, defaultValue: T): Ref<T>;
495
-
496
- /**
497
- * Throttle execution of a function. Especially useful for rate limiting
498
- * execution of handlers on events like resize and scroll.
499
- *
500
- * @param value Ref value to be watched with throttle effect
501
- * @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
502
- * @param [trailing] if true, update the value again after the delay time is up
503
- * @param [leading] if true, update the value on the leading edge of the ms timeout
504
- */
505
- declare function refThrottled<T>(value: Ref<T>, delay?: number, trailing?: boolean, leading?: boolean): Ref<T, T>;
506
-
507
- interface ControlledRefOptions<T> {
508
- /**
509
- * Callback function before the ref changing.
510
- *
511
- * Returning `false` to dismiss the change.
512
- */
513
- onBeforeChange?: (value: T, oldValue: T) => void | boolean;
514
- /**
515
- * Callback function after the ref changed
516
- *
517
- * This happens synchronously, with less overhead compare to `watch`
518
- */
519
- onChanged?: (value: T, oldValue: T) => void;
520
- }
521
- /**
522
- * Fine-grained controls over ref and its reactivity.
523
- */
524
- declare function refWithControl<T>(initial: T, options?: ControlledRefOptions<T>): vue.ShallowUnwrapRef<{
525
- get: (tracking?: boolean) => T;
526
- set: (value: T, triggering?: boolean) => void;
527
- untrackedGet: () => T;
528
- silentSet: (v: T) => void;
529
- peek: () => T;
530
- lay: (v: T) => void;
531
- }> & vue.Ref<T, T>;
532
- /**
533
- * Alias for `refWithControl`
534
- */
535
- declare const controlledRef: typeof refWithControl;
536
-
537
- declare function set<T>(ref: Ref<T>, value: T): void;
538
- declare function set<O extends object, K extends keyof O>(target: O, key: K, value: O[K]): void;
539
-
540
- type Direction = 'ltr' | 'rtl' | 'both';
541
- type SpecificFieldPartial<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
542
- /**
543
- * A = B
544
- */
545
- type Equal<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;
546
- /**
547
- * A ∩ B ≠ ∅
548
- */
549
- type IntersectButNotEqual<A, B> = Equal<A, B> extends true ? false : A & B extends never ? false : true;
550
- /**
551
- * A ⊆ B
552
- */
553
- type IncludeButNotEqual<A, B> = Equal<A, B> extends true ? false : A extends B ? true : false;
554
- /**
555
- * A ∩ B = ∅
556
- */
557
- type NotIntersect<A, B> = Equal<A, B> extends true ? false : A & B extends never ? true : false;
558
- interface EqualType<D extends Direction, L, R, O extends keyof Transform<L, R> = D extends 'both' ? 'ltr' | 'rtl' : D> {
559
- transform?: SpecificFieldPartial<Pick<Transform<L, R>, O>, O>;
560
- }
561
- 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 ? {
562
- transform?: SpecificFieldPartial<Pick<Transform<L, R>, D>, D>;
563
- } : {
564
- transform: Pick<Transform<L, R>, D>;
565
- };
566
- type StrictIncludeType<IncludeType extends 'LR' | 'RL', D extends Direction, L, R> = D extends 'both' ? {
567
- transform: SpecificFieldPartial<Transform<L, R>, IncludeType extends 'LR' ? 'ltr' : 'rtl'>;
568
- } : D extends Exclude<Direction, 'both'> ? StrictIncludeMap<IncludeType, D, L, R> : never;
569
- type IntersectButNotEqualType<D extends Direction, L, R> = D extends 'both' ? {
570
- transform: Transform<L, R>;
571
- } : D extends Exclude<Direction, 'both'> ? {
572
- transform: Pick<Transform<L, R>, D>;
573
- } : never;
574
- type NotIntersectType<D extends Direction, L, R> = IntersectButNotEqualType<D, L, R>;
575
- interface Transform<L, R> {
576
- ltr: (left: L) => R;
577
- rtl: (right: R) => L;
578
- }
579
- 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;
580
- type SyncRefOptions<L, R, D extends Direction> = ConfigurableFlushSync & {
581
- /**
582
- * Watch deeply
583
- *
584
- * @default false
585
- */
586
- deep?: boolean;
587
- /**
588
- * Sync values immediately
589
- *
590
- * @default true
591
- */
592
- immediate?: boolean;
593
- /**
594
- * Direction of syncing. Value will be redefined if you define syncConvertors
595
- *
596
- * @default 'both'
597
- */
598
- direction?: D;
599
- } & TransformType<D, L, R>;
600
- /**
601
- * Two-way refs synchronization.
602
- * From the set theory perspective to restrict the option's type
603
- * Check in the following order:
604
- * 1. L = R
605
- * 2. L ∩ R ≠ ∅
606
- * 3. L ⊆ R
607
- * 4. L ∩ R = ∅
608
- */
609
- declare function syncRef<L, R, D extends Direction = 'both'>(left: Ref<L>, right: Ref<R>, ...[options]: Equal<L, R> extends true ? [options?: SyncRefOptions<L, R, D>] : [options: SyncRefOptions<L, R, D>]): () => void;
610
-
611
- interface SyncRefsOptions extends ConfigurableFlushSync {
612
- /**
613
- * Watch deeply
614
- *
615
- * @default false
616
- */
617
- deep?: boolean;
618
- /**
619
- * Sync values immediately
620
- *
621
- * @default true
622
- */
623
- immediate?: boolean;
624
- }
625
- /**
626
- * Keep target ref(s) in sync with the source ref
627
- *
628
- * @param source source ref
629
- * @param targets
630
- */
631
- declare function syncRefs<T>(source: WatchSource<T>, targets: Ref<T> | Ref<T>[], options?: SyncRefsOptions): vue.WatchHandle;
632
-
633
- /**
634
- * Converts ref to reactive.
635
- *
636
- * @see https://vueuse.org/toReactive
637
- * @param objectRef A ref of object
638
- */
639
- declare function toReactive<T extends object>(objectRef: MaybeRef<T>): UnwrapNestedRefs<T>;
640
-
641
- /**
642
- * Normalize value/ref/getter to `ref` or `computed`.
643
- */
644
- declare function toRef<T>(r: () => T): Readonly<Ref<T>>;
645
- declare function toRef<T>(r: ComputedRef<T>): ComputedRef<T>;
646
- declare function toRef<T>(r: MaybeRefOrGetter<T>): Ref<T>;
647
- declare function toRef<T>(r: T): Ref<T>;
648
- declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>;
649
- declare function toRef<T extends object, K extends keyof T>(object: T, key: K, defaultValue: T[K]): ToRef<Exclude<T[K], undefined>>;
650
- /**
651
- * @deprecated use `toRef` instead
652
- */
653
- declare const resolveRef: typeof toRef;
654
-
655
- interface ToRefsOptions {
656
- /**
657
- * Replace the original ref with a copy on property update.
658
- *
659
- * @default true
660
- */
661
- replaceRef?: MaybeRefOrGetter<boolean>;
662
- }
663
- /**
664
- * Extended `toRefs` that also accepts refs of an object.
665
- *
666
- * @see https://vueuse.org/toRefs
667
- * @param objectRef A ref or normal object or array.
668
- */
669
- declare function toRefs<T extends object>(objectRef: MaybeRef<T>, options?: ToRefsOptions): ToRefs<T>;
670
-
671
- /**
672
- * Get the value of value/ref/getter.
673
- *
674
- * @deprecated use `toValue` from `vue` instead
675
- */
676
- declare const toValue: typeof toValue$1;
677
- /**
678
- * @deprecated use `toValue` instead
679
- */
680
- declare const resolveUnref: typeof toValue$1;
681
-
682
- /**
683
- * Call onBeforeMount() if it's inside a component lifecycle, if not, just call the function
684
- *
685
- * @param fn
686
- * @param sync if set to false, it will run in the nextTick() of Vue
687
- * @param target
688
- */
689
- declare function tryOnBeforeMount(fn: Fn, sync?: boolean, target?: any): void;
690
-
691
- /**
692
- * Call onBeforeUnmount() if it's inside a component lifecycle, if not, do nothing
693
- *
694
- * @param fn
695
- * @param target
696
- */
697
- declare function tryOnBeforeUnmount(fn: Fn, target?: any): void;
698
-
699
- /**
700
- * Call onMounted() if it's inside a component lifecycle, if not, just call the function
701
- *
702
- * @param fn
703
- * @param sync if set to false, it will run in the nextTick() of Vue
704
- * @param target
705
- */
706
- declare function tryOnMounted(fn: Fn, sync?: boolean, target?: any): void;
707
-
708
- /**
709
- * Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing
710
- *
711
- * @param fn
712
- */
713
- declare function tryOnScopeDispose(fn: Fn): boolean;
714
-
715
- /**
716
- * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing
717
- *
718
- * @param fn
719
- * @param target
720
- */
721
- declare function tryOnUnmounted(fn: Fn, target?: any): void;
722
-
723
- interface UntilToMatchOptions {
724
- /**
725
- * Milliseconds timeout for promise to resolve/reject if the when condition does not meet.
726
- * 0 for never timed out
727
- *
728
- * @default 0
729
- */
730
- timeout?: number;
731
- /**
732
- * Reject the promise when timeout
733
- *
734
- * @default false
735
- */
736
- throwOnTimeout?: boolean;
737
- /**
738
- * `flush` option for internal watch
739
- *
740
- * @default 'sync'
741
- */
742
- flush?: WatchOptions['flush'];
743
- /**
744
- * `deep` option for internal watch
745
- *
746
- * @default 'false'
747
- */
748
- deep?: WatchOptions['deep'];
749
- }
750
- interface UntilBaseInstance<T, Not extends boolean = false> {
751
- toMatch: (<U extends T = T>(condition: (v: T) => v is U, options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, U>> : Promise<U>) & ((condition: (v: T) => boolean, options?: UntilToMatchOptions) => Promise<T>);
752
- changed: (options?: UntilToMatchOptions) => Promise<T>;
753
- changedTimes: (n?: number, options?: UntilToMatchOptions) => Promise<T>;
754
- }
755
- type Falsy = false | void | null | undefined | 0 | 0n | '';
756
- interface UntilValueInstance<T, Not extends boolean = false> extends UntilBaseInstance<T, Not> {
757
- readonly not: UntilValueInstance<T, Not extends true ? false : true>;
758
- toBe: <P = T>(value: MaybeRefOrGetter<P>, options?: UntilToMatchOptions) => Not extends true ? Promise<T> : Promise<P>;
759
- toBeTruthy: (options?: UntilToMatchOptions) => Not extends true ? Promise<T & Falsy> : Promise<Exclude<T, Falsy>>;
760
- toBeNull: (options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, null>> : Promise<null>;
761
- toBeUndefined: (options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, undefined>> : Promise<undefined>;
762
- toBeNaN: (options?: UntilToMatchOptions) => Promise<T>;
763
- }
764
- interface UntilArrayInstance<T> extends UntilBaseInstance<T> {
765
- readonly not: UntilArrayInstance<T>;
766
- toContains: (value: MaybeRefOrGetter<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions) => Promise<T>;
767
- }
768
- /**
769
- * Promised one-time watch for changes
770
- *
771
- * @see https://vueuse.org/until
772
- * @example
773
- * ```
774
- * const { count } = useCounter()
775
- *
776
- * await until(count).toMatch(v => v > 7)
777
- *
778
- * alert('Counter is now larger than 7!')
779
- * ```
780
- */
781
- declare function until<T extends unknown[]>(r: WatchSource<T> | MaybeRefOrGetter<T>): UntilArrayInstance<T>;
782
- declare function until<T>(r: WatchSource<T> | MaybeRefOrGetter<T>): UntilValueInstance<T>;
783
-
784
- interface UseArrayDifferenceOptions {
785
- /**
786
- * Returns asymmetric difference
787
- *
788
- * @see https://en.wikipedia.org/wiki/Symmetric_difference
789
- * @default false
790
- */
791
- symmetric?: boolean;
792
- }
793
- declare function useArrayDifference<T>(list: MaybeRefOrGetter<T[]>, values: MaybeRefOrGetter<T[]>, key?: keyof T, options?: UseArrayDifferenceOptions): ComputedRef<T[]>;
794
- declare function useArrayDifference<T>(list: MaybeRefOrGetter<T[]>, values: MaybeRefOrGetter<T[]>, compareFn?: (value: T, othVal: T) => boolean, options?: UseArrayDifferenceOptions): ComputedRef<T[]>;
795
-
796
- /**
797
- * Reactive `Array.every`
798
- *
799
- * @see https://vueuse.org/useArrayEvery
800
- * @param list - the array was called upon.
801
- * @param fn - a function to test each element.
802
- *
803
- * @returns **true** if the `fn` function returns a **truthy** value for every element from the array. Otherwise, **false**.
804
- */
805
- declare function useArrayEvery<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): ComputedRef<boolean>;
806
-
807
- /**
808
- * Reactive `Array.filter`
809
- *
810
- * @see https://vueuse.org/useArrayFilter
811
- * @param list - the array was called upon.
812
- * @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.
813
- *
814
- * @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.
815
- */
816
- declare function useArrayFilter<T, S extends T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => element is S): ComputedRef<S[]>;
817
- declare function useArrayFilter<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => unknown): ComputedRef<T[]>;
818
-
819
- /**
820
- * Reactive `Array.find`
821
- *
822
- * @see https://vueuse.org/useArrayFind
823
- * @param list - the array was called upon.
824
- * @param fn - a function to test each element.
825
- *
826
- * @returns the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
827
- */
828
- declare function useArrayFind<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => boolean): ComputedRef<T | undefined>;
829
-
830
- /**
831
- * Reactive `Array.findIndex`
832
- *
833
- * @see https://vueuse.org/useArrayFindIndex
834
- * @param list - the array was called upon.
835
- * @param fn - a function to test each element.
836
- *
837
- * @returns the index of the first element in the array that passes the test. Otherwise, "-1".
838
- */
839
- declare function useArrayFindIndex<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): ComputedRef<number>;
840
-
841
- /**
842
- * Reactive `Array.findLast`
843
- *
844
- * @see https://vueuse.org/useArrayFindLast
845
- * @param list - the array was called upon.
846
- * @param fn - a function to test each element.
847
- *
848
- * @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
849
- */
850
- declare function useArrayFindLast<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => boolean): ComputedRef<T | undefined>;
851
-
852
- type UseArrayIncludesComparatorFn<T, V> = ((element: T, value: V, index: number, array: MaybeRefOrGetter<T>[]) => boolean);
853
- interface UseArrayIncludesOptions<T, V> {
854
- fromIndex?: number;
855
- comparator?: UseArrayIncludesComparatorFn<T, V> | keyof T;
856
- }
857
- /**
858
- * Reactive `Array.includes`
859
- *
860
- * @see https://vueuse.org/useArrayIncludes
861
- *
862
- * @returns true if the `value` is found in the array. Otherwise, false.
863
- */
864
- declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, comparator?: UseArrayIncludesComparatorFn<T, V>): ComputedRef<boolean>;
865
- declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, comparator?: keyof T): ComputedRef<boolean>;
866
- declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, options?: UseArrayIncludesOptions<T, V>): ComputedRef<boolean>;
867
-
868
- /**
869
- * Reactive `Array.join`
870
- *
871
- * @see https://vueuse.org/useArrayJoin
872
- * @param list - the array was called upon.
873
- * @param separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (",").
874
- *
875
- * @returns a string with all array elements joined. If arr.length is 0, the empty string is returned.
876
- */
877
- declare function useArrayJoin(list: MaybeRefOrGetter<MaybeRefOrGetter<any>[]>, separator?: MaybeRefOrGetter<string>): ComputedRef<string>;
878
-
879
- /**
880
- * Reactive `Array.map`
881
- *
882
- * @see https://vueuse.org/useArrayMap
883
- * @param list - the array was called upon.
884
- * @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.
885
- *
886
- * @returns a new array with each element being the result of the callback function.
887
- */
888
- declare function useArrayMap<T, U = T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => U): ComputedRef<U[]>;
889
-
890
- type UseArrayReducer<PV, CV, R> = (previousValue: PV, currentValue: CV, currentIndex: number) => R;
891
- /**
892
- * Reactive `Array.reduce`
893
- *
894
- * @see https://vueuse.org/useArrayReduce
895
- * @param list - the array was called upon.
896
- * @param reducer - a "reducer" function.
897
- *
898
- * @returns the value that results from running the "reducer" callback function to completion over the entire array.
899
- */
900
- declare function useArrayReduce<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, reducer: UseArrayReducer<T, T, T>): ComputedRef<T>;
901
- /**
902
- * Reactive `Array.reduce`
903
- *
904
- * @see https://vueuse.org/useArrayReduce
905
- * @param list - the array was called upon.
906
- * @param reducer - a "reducer" function.
907
- * @param initialValue - a value to be initialized the first time when the callback is called.
908
- *
909
- * @returns the value that results from running the "reducer" callback function to completion over the entire array.
910
- */
911
- declare function useArrayReduce<T, U>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, reducer: UseArrayReducer<U, T, U>, initialValue: MaybeRefOrGetter<U>): ComputedRef<U>;
912
-
913
- /**
914
- * Reactive `Array.some`
915
- *
916
- * @see https://vueuse.org/useArraySome
917
- * @param list - the array was called upon.
918
- * @param fn - a function to test each element.
919
- *
920
- * @returns **true** if the `fn` function returns a **truthy** value for any element from the array. Otherwise, **false**.
921
- */
922
- declare function useArraySome<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): ComputedRef<boolean>;
923
-
924
- /**
925
- * reactive unique array
926
- * @see https://vueuse.org/useArrayUnique
927
- * @param list - the array was called upon.
928
- * @param compareFn
929
- * @returns A computed ref that returns a unique array of items.
930
- */
931
- declare function useArrayUnique<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, compareFn?: (a: T, b: T, array: T[]) => boolean): ComputedRef<T[]>;
932
-
933
- interface UseCounterOptions {
934
- min?: number;
935
- max?: number;
936
- }
937
- /**
938
- * Basic counter with utility functions.
939
- *
940
- * @see https://vueuse.org/useCounter
941
- * @param [initialValue]
942
- * @param options
943
- */
944
- declare function useCounter(initialValue?: MaybeRef<number>, options?: UseCounterOptions): {
945
- count: vue.Ref<number, number> | vue.ShallowRef<number, number> | vue.WritableComputedRef<number, number>;
946
- inc: (delta?: number) => number;
947
- dec: (delta?: number) => number;
948
- get: () => number;
949
- set: (val: number) => number;
950
- reset: (val?: number) => number;
951
- };
952
-
953
- type DateLike = Date | number | string | undefined;
954
- interface UseDateFormatOptions {
955
- /**
956
- * The locale(s) to used for dd/ddd/dddd/MMM/MMMM format
957
- *
958
- * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).
959
- */
960
- locales?: MaybeRefOrGetter<Intl.LocalesArgument>;
961
- /**
962
- * A custom function to re-modify the way to display meridiem
963
- *
964
- */
965
- customMeridiem?: (hours: number, minutes: number, isLowercase?: boolean, hasPeriod?: boolean) => string;
966
- }
967
- declare function formatDate(date: Date, formatStr: string, options?: UseDateFormatOptions): string;
968
- declare function normalizeDate(date: DateLike): Date;
969
- /**
970
- * Get the formatted date according to the string of tokens passed in.
971
- *
972
- * @see https://vueuse.org/useDateFormat
973
- * @param date - The date to format, can either be a `Date` object, a timestamp, or a string
974
- * @param formatStr - The combination of tokens to format the date
975
- * @param options - UseDateFormatOptions
976
- */
977
- declare function useDateFormat(date: MaybeRefOrGetter<DateLike>, formatStr?: MaybeRefOrGetter<string>, options?: UseDateFormatOptions): vue.ComputedRef<string>;
978
- type UseDateFormatReturn = ReturnType<typeof useDateFormat>;
979
-
980
- /**
981
- * Debounce execution of a function.
982
- *
983
- * @see https://vueuse.org/useDebounceFn
984
- * @param fn A function to be executed after delay milliseconds debounced.
985
- * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
986
- * @param options Options
987
- *
988
- * @return A new, debounce, function.
989
- */
990
- declare function useDebounceFn<T extends FunctionArgs>(fn: T, ms?: MaybeRefOrGetter<number>, options?: DebounceFilterOptions): PromisifyFn<T>;
991
-
992
- interface UseIntervalOptions<Controls extends boolean> {
993
- /**
994
- * Expose more controls
995
- *
996
- * @default false
997
- */
998
- controls?: Controls;
999
- /**
1000
- * Execute the update immediately on calling
1001
- *
1002
- * @default true
1003
- */
1004
- immediate?: boolean;
1005
- /**
1006
- * Callback on every interval
1007
- */
1008
- callback?: (count: number) => void;
1009
- }
1010
- interface UseIntervalControls {
1011
- counter: ShallowRef<number>;
1012
- reset: () => void;
1013
- }
1014
- /**
1015
- * Reactive counter increases on every interval
1016
- *
1017
- * @see https://vueuse.org/useInterval
1018
- * @param interval
1019
- * @param options
1020
- */
1021
- declare function useInterval(interval?: MaybeRefOrGetter<number>, options?: UseIntervalOptions<false>): ShallowRef<number>;
1022
- declare function useInterval(interval: MaybeRefOrGetter<number>, options: UseIntervalOptions<true>): UseIntervalControls & Pausable;
1023
-
1024
- interface UseIntervalFnOptions {
1025
- /**
1026
- * Start the timer immediately
1027
- *
1028
- * @default true
1029
- */
1030
- immediate?: boolean;
1031
- /**
1032
- * Execute the callback immediately after calling `resume`
1033
- *
1034
- * @default false
1035
- */
1036
- immediateCallback?: boolean;
1037
- }
1038
- /**
1039
- * Wrapper for `setInterval` with controls
1040
- *
1041
- * @param cb
1042
- * @param interval
1043
- * @param options
1044
- */
1045
- declare function useIntervalFn(cb: Fn, interval?: MaybeRefOrGetter<number>, options?: UseIntervalFnOptions): Pausable;
1046
-
1047
- interface UseLastChangedOptions<Immediate extends boolean, InitialValue extends number | null | undefined = undefined> extends WatchOptions<Immediate> {
1048
- initialValue?: InitialValue;
1049
- }
1050
- /**
1051
- * Records the timestamp of the last change
1052
- *
1053
- * @see https://vueuse.org/useLastChanged
1054
- */
1055
- declare function useLastChanged(source: WatchSource, options?: UseLastChangedOptions<false>): ShallowRef<number | null>;
1056
- declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<true> | UseLastChangedOptions<boolean, number>): ShallowRef<number>;
1057
-
1058
- /**
1059
- * Throttle execution of a function. Especially useful for rate limiting
1060
- * execution of handlers on events like resize and scroll.
1061
- *
1062
- * @param fn A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
1063
- * to `callback` when the throttled-function is executed.
1064
- * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
1065
- * (default value: 200)
1066
- *
1067
- * @param [trailing] if true, call fn again after the time is up (default value: false)
1068
- *
1069
- * @param [leading] if true, call fn on the leading edge of the ms timeout (default value: true)
1070
- *
1071
- * @param [rejectOnCancel] if true, reject the last call if it's been cancel (default value: false)
1072
- *
1073
- * @return A new, throttled, function.
1074
- */
1075
- declare function useThrottleFn<T extends FunctionArgs>(fn: T, ms?: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): PromisifyFn<T>;
1076
-
1077
- interface UseTimeoutFnOptions {
1078
- /**
1079
- * Start the timer immediately
1080
- *
1081
- * @default true
1082
- */
1083
- immediate?: boolean;
1084
- /**
1085
- * Execute the callback immediately after calling `start`
1086
- *
1087
- * @default false
1088
- */
1089
- immediateCallback?: boolean;
1090
- }
1091
- /**
1092
- * Wrapper for `setTimeout` with controls.
1093
- *
1094
- * @param cb
1095
- * @param interval
1096
- * @param options
1097
- */
1098
- declare function useTimeoutFn<CallbackFn extends AnyFn>(cb: CallbackFn, interval: MaybeRefOrGetter<number>, options?: UseTimeoutFnOptions): Stoppable<Parameters<CallbackFn> | []>;
1099
-
1100
- interface UseTimeoutOptions<Controls extends boolean> extends UseTimeoutFnOptions {
1101
- /**
1102
- * Expose more controls
1103
- *
1104
- * @default false
1105
- */
1106
- controls?: Controls;
1107
- /**
1108
- * Callback on timeout
1109
- */
1110
- callback?: Fn;
1111
- }
1112
- /**
1113
- * Update value after a given time with controls.
1114
- *
1115
- * @see {@link https://vueuse.org/useTimeout}
1116
- * @param interval
1117
- * @param options
1118
- */
1119
- declare function useTimeout(interval?: MaybeRefOrGetter<number>, options?: UseTimeoutOptions<false>): ComputedRef<boolean>;
1120
- declare function useTimeout(interval: MaybeRefOrGetter<number>, options: UseTimeoutOptions<true>): {
1121
- ready: ComputedRef<boolean>;
1122
- } & Stoppable;
1123
-
1124
- interface UseToNumberOptions {
1125
- /**
1126
- * Method to use to convert the value to a number.
1127
- *
1128
- * Or a custom function for the conversion.
1129
- *
1130
- * @default 'parseFloat'
1131
- */
1132
- method?: 'parseFloat' | 'parseInt' | ((value: string | number) => number);
1133
- /**
1134
- * The base in mathematical numeral systems passed to `parseInt`.
1135
- * Only works with `method: 'parseInt'`
1136
- */
1137
- radix?: number;
1138
- /**
1139
- * Replace NaN with zero
1140
- *
1141
- * @default false
1142
- */
1143
- nanToZero?: boolean;
1144
- }
1145
- /**
1146
- * Reactively convert a string ref to number.
1147
- */
1148
- declare function useToNumber(value: MaybeRefOrGetter<number | string>, options?: UseToNumberOptions): ComputedRef<number>;
1149
-
1150
- /**
1151
- * Reactively convert a ref to string.
1152
- *
1153
- * @see https://vueuse.org/useToString
1154
- */
1155
- declare function useToString(value: MaybeRefOrGetter<unknown>): ComputedRef<string>;
1156
-
1157
- interface UseToggleOptions<Truthy, Falsy> {
1158
- truthyValue?: MaybeRefOrGetter<Truthy>;
1159
- falsyValue?: MaybeRefOrGetter<Falsy>;
1160
- }
1161
- declare function useToggle<Truthy, Falsy, T = Truthy | Falsy>(initialValue: Ref<T>, options?: UseToggleOptions<Truthy, Falsy>): (value?: T) => T;
1162
- declare function useToggle<Truthy = true, Falsy = false, T = Truthy | Falsy>(initialValue?: T, options?: UseToggleOptions<Truthy, Falsy>): [ShallowRef<T>, (value?: T) => T];
1163
-
1164
- declare type WatchArrayCallback<V = any, OV = any> = (value: V, oldValue: OV, added: V, removed: OV, onCleanup: (cleanupFn: () => void) => void) => any;
1165
- /**
1166
- * Watch for an array with additions and removals.
1167
- *
1168
- * @see https://vueuse.org/watchArray
1169
- */
1170
- declare function watchArray<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T[]> | T[], cb: WatchArrayCallback<T[], Immediate extends true ? T[] | undefined : T[]>, options?: WatchOptions<Immediate>): vue.WatchHandle;
1171
-
1172
- interface WatchWithFilterOptions<Immediate> extends WatchOptions<Immediate>, ConfigurableEventFilter {
1173
- }
1174
- declare function watchWithFilter<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle;
1175
- declare function watchWithFilter<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle;
1176
- declare function watchWithFilter<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle;
1177
-
1178
- interface WatchAtMostOptions<Immediate> extends WatchWithFilterOptions<Immediate> {
1179
- count: MaybeRefOrGetter<number>;
1180
- }
1181
- interface WatchAtMostReturn {
1182
- stop: WatchStopHandle;
1183
- count: ShallowRef<number>;
1184
- }
1185
- declare function watchAtMost<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn;
1186
- declare function watchAtMost<T, Immediate extends Readonly<boolean> = false>(sources: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn;
1187
-
1188
- interface WatchDebouncedOptions<Immediate> extends WatchOptions<Immediate>, DebounceFilterOptions {
1189
- debounce?: MaybeRefOrGetter<number>;
1190
- }
1191
- declare function watchDebounced<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle;
1192
- declare function watchDebounced<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle;
1193
- declare function watchDebounced<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle;
1194
-
1195
- declare function watchDeep<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: Omit<WatchOptions<Immediate>, 'deep'>): WatchStopHandle;
1196
- declare function watchDeep<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: Omit<WatchOptions<Immediate>, 'deep'>): WatchStopHandle;
1197
- declare function watchDeep<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: Omit<WatchOptions<Immediate>, 'deep'>): WatchStopHandle;
1198
-
1199
- type IgnoredUpdater = (updater: () => void) => void;
1200
- interface WatchIgnorableReturn {
1201
- ignoreUpdates: IgnoredUpdater;
1202
- ignorePrevAsyncUpdates: () => void;
1203
- stop: WatchStopHandle;
1204
- }
1205
- declare function watchIgnorable<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn;
1206
- declare function watchIgnorable<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn;
1207
- declare function watchIgnorable<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn;
1208
-
1209
- declare function watchImmediate<T extends Readonly<WatchSource<unknown>[]>>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, true>>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchStopHandle;
1210
- declare function watchImmediate<T>(source: WatchSource<T>, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchStopHandle;
1211
- declare function watchImmediate<T extends object>(source: T, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchStopHandle;
1212
-
1213
- 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;
1214
- 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;
1215
-
1216
- interface WatchPausableReturn extends Pausable {
1217
- stop: WatchStopHandle;
1218
- }
1219
- type WatchPausableOptions<Immediate> = WatchWithFilterOptions<Immediate> & PausableFilterOptions;
1220
- declare function watchPausable<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchPausableOptions<Immediate>): WatchPausableReturn;
1221
- declare function watchPausable<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchPausableOptions<Immediate>): WatchPausableReturn;
1222
- declare function watchPausable<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchPausableOptions<Immediate>): WatchPausableReturn;
1223
-
1224
- interface WatchThrottledOptions<Immediate> extends WatchOptions<Immediate> {
1225
- throttle?: MaybeRefOrGetter<number>;
1226
- trailing?: boolean;
1227
- leading?: boolean;
1228
- }
1229
- declare function watchThrottled<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle;
1230
- declare function watchThrottled<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle;
1231
- declare function watchThrottled<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle;
1232
-
1233
- interface WatchTriggerableReturn<FnReturnT = void> extends WatchIgnorableReturn {
1234
- /** Execute `WatchCallback` immediately */
1235
- trigger: () => FnReturnT;
1236
- }
1237
- type OnCleanup = (cleanupFn: () => void) => void;
1238
- type WatchTriggerableCallback<V = any, OV = any, R = void> = (value: V, oldValue: OV, onCleanup: OnCleanup) => R;
1239
- declare function watchTriggerable<T extends Readonly<WatchSource<unknown>[]>, FnReturnT>(sources: [...T], cb: WatchTriggerableCallback<MapSources<T>, MapOldSources<T, true>, FnReturnT>, options?: WatchWithFilterOptions<boolean>): WatchTriggerableReturn<FnReturnT>;
1240
- declare function watchTriggerable<T, FnReturnT>(source: WatchSource<T>, cb: WatchTriggerableCallback<T, T | undefined, FnReturnT>, options?: WatchWithFilterOptions<boolean>): WatchTriggerableReturn<FnReturnT>;
1241
- declare function watchTriggerable<T extends object, FnReturnT>(source: T, cb: WatchTriggerableCallback<T, T | undefined, FnReturnT>, options?: WatchWithFilterOptions<boolean>): WatchTriggerableReturn<FnReturnT>;
1242
-
1243
- interface WheneverOptions extends WatchOptions {
1244
- /**
1245
- * Only trigger once when the condition is met
1246
- *
1247
- * Override the `once` option in `WatchOptions`
1248
- *
1249
- * @default false
1250
- */
1251
- once?: boolean;
1252
- }
1253
- /**
1254
- * Shorthand for watching value to be truthy
1255
- *
1256
- * @see https://vueuse.org/whenever
1257
- */
1258
- declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WheneverOptions): vue.WatchHandle;
1259
-
1260
- 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 IfAny, type IgnoredUpdater, type IsAny, type MapOldSources, type MapSources, type MultiWatchSources, type Mutable, type Pausable, type PausableFilterOptions, type Promisify, type PromisifyFn, type Reactified, type ReactifyNested, type ReactifyObjectOptions, type ReactifyOptions, type ReactiveOmitPredicate, type ReactivePickPredicate, type ReadonlyRefOrGetter, type RemovableRef, type ShallowOrDeepRef, type ShallowUnwrapRef, type SingletonPromiseReturn, type Stoppable, type SyncRefOptions, type SyncRefsOptions, type ThrottleFilterOptions, type ToRefsOptions, type UntilArrayInstance, type UntilBaseInstance, type UntilToMatchOptions, type UntilValueInstance, type UseArrayDifferenceOptions, 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 WatchPausableOptions, type WatchPausableReturn, type WatchThrottledOptions, type WatchTriggerableCallback, type WatchTriggerableReturn, type WatchWithFilterOptions, type WheneverOptions, type WritableComputedRefWithControl, assert, refAutoReset as autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createRef, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, computedEager as eagerComputed, extendRef, formatDate, get, getLifeCycleTarget, 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, pxValue, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toArray, 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 };