import { WatchOptionsBase, Ref, ComputedRef, WritableComputedRef, WatchSource, ComputedGetter, WritableComputedOptions, ShallowRef, WatchOptions, InjectionKey, ShallowUnwrapRef as ShallowUnwrapRef$1, inject, provide, UnwrapNestedRefs, UnwrapRef, ToRef, ToRefs, WatchCallback, WatchStopHandle } from 'vue-demi'; import * as vue from 'vue-demi'; /** * Note: If you are using Vue 3.4+, you can straight use computed instead. * Because in Vue 3.4+, if computed new value does not change, * computed, effect, watch, watchEffect, render dependencies will not be triggered. * refer: https://github.com/vuejs/core/pull/5912 * * @param fn effect function * @param options WatchOptionsBase * @returns readonly ref */ declare function computedEager(fn: () => T, options?: WatchOptionsBase): Readonly>; interface ComputedWithControlRefExtra { /** * Force update the computed value. */ trigger: () => void; } interface ComputedRefWithControl extends ComputedRef, ComputedWithControlRefExtra { } interface WritableComputedRefWithControl extends WritableComputedRef, ComputedWithControlRefExtra { } declare function computedWithControl(source: WatchSource | WatchSource[], fn: ComputedGetter): ComputedRefWithControl; declare function computedWithControl(source: WatchSource | WatchSource[], fn: WritableComputedOptions): WritableComputedRefWithControl; /** * Void function */ type Fn = () => void; /** * Any function */ type AnyFn = (...args: any[]) => any; /** * A ref that allow to set null or undefined */ type RemovableRef = Omit, 'value'> & { get value(): T; set value(value: T | null | undefined); }; /** * Maybe it's a ref, or a plain value. */ type MaybeRef = T | Ref | ShallowRef | WritableComputedRef; /** * Maybe it's a ref, or a plain value, or a getter function. */ type MaybeRefOrGetter = MaybeRef | ComputedRef | (() => T); /** * Maybe it's a computed ref, or a readonly value, or a getter function */ type ReadonlyRefOrGetter = ComputedRef | (() => T); /** * Make all the nested attributes of an object or array to MaybeRef * * Good for accepting options that will be wrapped with `reactive` or `ref` * * ```ts * UnwrapRef> === T * ``` */ type DeepMaybeRef = T extends Ref ? MaybeRef : T extends Array | object ? { [K in keyof T]: DeepMaybeRef; } : MaybeRef; type Arrayable = T[] | T; /** * Infers the element type of an array */ type ElementOf = T extends (infer E)[] ? E : never; type ShallowUnwrapRef = T extends Ref ? P : T; type Awaitable = Promise | T; type ArgumentsType = T extends (...args: infer U) => any ? U : never; /** * Compatible with versions below TypeScript 4.5 Awaited */ type Awaited = T extends null | undefined ? T : T extends object & { then: (onfulfilled: infer F, ...args: infer _) => any; } ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited : never : T; type Promisify = Promise>; type PromisifyFn = (...args: ArgumentsType) => Promisify>; interface Pausable { /** * A ref indicate whether a pausable instance is active */ isActive: Readonly>; /** * Temporary pause the effect from executing */ pause: Fn; /** * Resume the effects */ resume: Fn; } interface Stoppable { /** * A ref indicate whether a stoppable instance is executing */ isPending: Readonly>; /** * Stop the effect from executing */ stop: Fn; /** * Start the effects */ start: (...args: StartFnArgs) => void; } interface ConfigurableFlush { /** * Timing for monitoring changes, refer to WatchOptions for more details * * @default 'pre' */ flush?: WatchOptions['flush']; } interface ConfigurableFlushSync { /** * Timing for monitoring changes, refer to WatchOptions for more details. * Unlike `watch()`, the default is set to `sync` * * @default 'sync' */ flush?: WatchOptions['flush']; } type MultiWatchSources = (WatchSource | object)[]; type MapSources = { [K in keyof T]: T[K] extends WatchSource ? V : never; }; type MapOldSources = { [K in keyof T]: T[K] extends WatchSource ? Immediate extends true ? V | undefined : V : never; }; type Mutable = { -readonly [P in keyof T]: T[P]; }; type IfAny = 0 extends (1 & T) ? Y : N; /** * will return `true` if `T` is `any`, or `false` otherwise */ type IsAny = IfAny; /** * The source code for this function was inspired by vue-apollo's `useEventHook` util * https://github.com/vuejs/vue-apollo/blob/v4/packages/vue-apollo-composable/src/util/useEventHook.ts */ type Callback = IsAny extends true ? (...param: any) => void : ([ T ] extends [void] ? (...param: unknown[]) => void : (...param: [T, ...unknown[]]) => void); type EventHookOn = (fn: Callback) => { off: () => void; }; type EventHookOff = (fn: Callback) => void; type EventHookTrigger = (...param: IsAny extends true ? unknown[] : [T, ...unknown[]]) => Promise; interface EventHook { on: EventHookOn; off: EventHookOff; trigger: EventHookTrigger; } /** * Utility for creating event hooks * * @see https://vueuse.org/createEventHook */ declare function createEventHook(): EventHook; declare const directiveHooks: { mounted: "mounted"; updated: "updated"; unmounted: "unmounted"; }; type FunctionArgs = (...args: Args) => Return; interface FunctionWrapperOptions { fn: FunctionArgs; args: Args; thisArg: This; } type EventFilter = (invoke: Invoke, options: FunctionWrapperOptions) => ReturnType | Promisify>; interface ConfigurableEventFilter { /** * Filter for if events should to be received. * * @see https://vueuse.org/guide/config.html#event-filters */ eventFilter?: EventFilter; } interface DebounceFilterOptions { /** * The maximum time allowed to be delayed before it's invoked. * In milliseconds. */ maxWait?: MaybeRefOrGetter; /** * Whether to reject the last call if it's been cancel. * * @default false */ rejectOnCancel?: boolean; } /** * @internal */ declare function createFilterWrapper(filter: EventFilter, fn: T): (this: any, ...args: ArgumentsType) => Promise>>; declare const bypassFilter: EventFilter; /** * Create an EventFilter that debounce the events */ declare function debounceFilter(ms: MaybeRefOrGetter, options?: DebounceFilterOptions): EventFilter; interface ThrottleFilterOptions { /** * The maximum time allowed to be delayed before it's invoked. */ delay: MaybeRefOrGetter; /** * Whether to invoke on the trailing edge of the timeout. */ trailing?: boolean; /** * Whether to invoke on the leading edge of the timeout. */ leading?: boolean; /** * Whether to reject the last call if it's been cancel. */ rejectOnCancel?: boolean; } /** * Create an EventFilter that throttle the events * * @param ms * @param [trailing] * @param [leading] * @param [rejectOnCancel] */ declare function throttleFilter(ms: MaybeRefOrGetter, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter; declare function throttleFilter(options: ThrottleFilterOptions): EventFilter; /** * EventFilter that gives extra controls to pause and resume the filter * * @param extendFilter Extra filter to apply when the PausableFilter is active, default to none * */ declare function pausableFilter(extendFilter?: EventFilter): Pausable & { eventFilter: EventFilter; }; declare const isClient: boolean; declare const isWorker: boolean; declare const isDef: (val?: T) => val is T; declare const notNullish: (val?: T | null | undefined) => val is T; declare const assert: (condition: boolean, ...infos: any[]) => void; declare const isObject: (val: any) => val is object; declare const now: () => number; declare const timestamp: () => number; declare const clamp: (n: number, min: number, max: number) => number; declare const noop: () => void; declare const rand: (min: number, max: number) => number; declare const hasOwn: (val: T, key: K) => key is K; declare const isIOS: boolean | ""; declare const hyphenate: (str: string) => string; declare const camelize: (str: string) => string; declare function promiseTimeout(ms: number, throwOnTimeout?: boolean, reason?: string): Promise; declare function identity(arg: T): T; interface SingletonPromiseReturn { (): Promise; /** * Reset current staled promise. * await it to have proper shutdown. */ reset: () => Promise; } /** * Create singleton promise function * * @example * ``` * const promise = createSingletonPromise(async () => { ... }) * * await promise() * await promise() // all of them will be bind to a single promise instance * await promise() // and be resolved together * ``` */ declare function createSingletonPromise(fn: () => Promise): SingletonPromiseReturn; declare function invoke(fn: () => T): T; declare function containsProp(obj: object, ...props: string[]): boolean; /** * Increase string a value with unit * * @example '2px' + 1 = '3px' * @example '15em' + (-2) = '13em' */ declare function increaseWithUnit(target: number, delta: number): number; declare function increaseWithUnit(target: string, delta: number): string; declare function increaseWithUnit(target: string | number, delta: number): string | number; /** * Create a new subset object by giving keys */ declare function objectPick(obj: O, keys: T[], omitUndefined?: boolean): Pick; /** * Create a new subset object by omit giving keys */ declare function objectOmit(obj: O, keys: T[], omitUndefined?: boolean): Omit; declare function objectEntries(obj: T): Array<[keyof T, T[keyof T]]>; declare function getLifeCycleTarget(target?: any): any; /** * Keep states in the global scope to be reusable across Vue instances. * * @see https://vueuse.org/createGlobalState * @param stateFactory A factory function to create the state */ declare function createGlobalState(stateFactory: Fn): Fn; interface CreateInjectionStateOptions { /** * Custom injectionKey for InjectionState */ injectionKey?: string | InjectionKey; /** * Default value for the InjectionState */ defaultValue?: Return; } /** * Create global state that can be injected into components. * * @see https://vueuse.org/createInjectionState * */ declare function createInjectionState, Return>(composable: (...args: Arguments) => Return, options?: CreateInjectionStateOptions): readonly [useProvidingState: (...args: Arguments) => Return, useInjectedState: () => Return | undefined]; /** * Make a composable function usable with multiple Vue instances. * * @see https://vueuse.org/createSharedComposable */ declare function createSharedComposable(composable: Fn): Fn; interface ExtendRefOptions { /** * Is the extends properties enumerable * * @default false */ enumerable?: boolean; /** * Unwrap for Ref properties * * @default true */ unwrap?: Unwrap; } /** * Overload 1: Unwrap set to false */ declare function extendRef, Extend extends object, Options extends ExtendRefOptions>(ref: R, extend: Extend, options?: Options): ShallowUnwrapRef$1 & R; /** * Overload 2: Unwrap unset or set to true */ declare function extendRef, Extend extends object, Options extends ExtendRefOptions>(ref: R, extend: Extend, options?: Options): Extend & R; /** * Shorthand for accessing `ref.value` */ declare function get(ref: MaybeRef): T; declare function get(ref: MaybeRef, key: K): T[K]; /** * On the basis of `inject`, it is allowed to directly call inject to obtain the value after call provide in the same component. * * @example * ```ts * injectLocal('MyInjectionKey', 1) * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1 * ``` */ declare const injectLocal: typeof inject; declare function isDefined(v: ComputedRef): v is ComputedRef>; declare function isDefined(v: Ref): v is Ref>; declare function isDefined(v: T): v is Exclude; declare function makeDestructurable, A extends readonly any[]>(obj: T, arr: A): T & A; /** * On the basis of `provide`, it is allowed to directly call inject to obtain the value after call provide in the same component. * * @example * ```ts * provideLocal('MyInjectionKey', 1) * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1 * ``` */ declare const provideLocal: typeof provide; type Reactified = T extends (...args: infer A) => infer R ? (...args: { [K in keyof A]: Computed extends true ? MaybeRefOrGetter : MaybeRef; }) => ComputedRef : never; interface ReactifyOptions { /** * Accept passing a function as a reactive getter * * @default true */ computedGetter?: T; } /** * Converts plain function into a reactive function. * The converted function accepts refs as it's arguments * and returns a ComputedRef, with proper typing. * * @param fn - Source function */ declare function reactify(fn: T, options?: ReactifyOptions): Reactified; type ReactifyNested = { [K in Keys]: T[K] extends AnyFn ? Reactified : T[K]; }; interface ReactifyObjectOptions extends ReactifyOptions { /** * Includes names from Object.getOwnPropertyNames * * @default true */ includeOwnProperties?: boolean; } /** * Apply `reactify` to an object */ declare function reactifyObject(obj: T, keys?: (keyof T)[]): ReactifyNested; declare function reactifyObject(obj: T, options?: ReactifyObjectOptions): ReactifyNested; /** * Computed reactive object. */ declare function reactiveComputed(fn: () => T): UnwrapNestedRefs; type ReactiveOmitPredicate = (value: T[keyof T], key: keyof T) => boolean; declare function reactiveOmit(obj: T, ...keys: (K | K[])[]): Omit; declare function reactiveOmit(obj: T, predicate: ReactiveOmitPredicate): Partial; type ReactivePickPredicate = (value: T[keyof T], key: keyof T) => boolean; declare function reactivePick(obj: T, ...keys: (K | K[])[]): { [S in K]: UnwrapRef; }; declare function reactivePick(obj: T, predicate: ReactivePickPredicate): { [S in keyof T]?: UnwrapRef; }; /** * Create a ref which will be reset to the default value after some time. * * @see https://vueuse.org/refAutoReset * @param defaultValue The value which will be set. * @param afterMs A zero-or-greater delay in milliseconds. */ declare function refAutoReset(defaultValue: MaybeRefOrGetter, afterMs?: MaybeRefOrGetter): Ref; /** * Debounce updates of a ref. * * @return A new debounced ref. */ declare function refDebounced(value: Ref, ms?: MaybeRefOrGetter, options?: DebounceFilterOptions): Readonly>; /** * Apply default value to a ref. */ declare function refDefault(source: Ref, defaultValue: T): Ref; /** * Throttle execution of a function. Especially useful for rate limiting * execution of handlers on events like resize and scroll. * * @param value Ref value to be watched with throttle effect * @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. * @param [trailing] if true, update the value again after the delay time is up * @param [leading] if true, update the value on the leading edge of the ms timeout */ declare function refThrottled(value: Ref, delay?: number, trailing?: boolean, leading?: boolean): Ref; interface ControlledRefOptions { /** * Callback function before the ref changing. * * Returning `false` to dismiss the change. */ onBeforeChange?: (value: T, oldValue: T) => void | boolean; /** * Callback function after the ref changed * * This happens synchronously, with less overhead compare to `watch` */ onChanged?: (value: T, oldValue: T) => void; } /** * Fine-grained controls over ref and its reactivity. */ declare function refWithControl(initial: T, options?: ControlledRefOptions): vue.ShallowUnwrapRef<{ get: (tracking?: boolean) => T; set: (value: T, triggering?: boolean) => void; untrackedGet: () => T; silentSet: (v: T) => void; peek: () => T; lay: (v: T) => void; }> & vue.Ref; /** * Alias for `refWithControl` */ declare const controlledRef: typeof refWithControl; declare function set(ref: Ref, value: T): void; declare function set(target: O, key: K, value: O[K]): void; type Direction = 'ltr' | 'rtl' | 'both'; type SpecificFieldPartial = Partial> & Omit; /** * A = B */ type Equal = [A] extends [B] ? ([B] extends [A] ? true : false) : false; /** * A ∩ B ≠ ∅ */ type IntersectButNotEqual = Equal extends true ? false : A & B extends never ? false : true; /** * A ⊆ B */ type IncludeButNotEqual = Equal extends true ? false : A extends B ? true : false; /** * A ∩ B = ∅ */ type NotIntersect = Equal extends true ? false : A & B extends never ? true : false; interface EqualType = D extends 'both' ? 'ltr' | 'rtl' : D> { transform?: SpecificFieldPartial, O>, O>; } type StrictIncludeMap, L, R> = (Equal<[IncludeType, D], ['LR', 'ltr']> & Equal<[IncludeType, D], ['RL', 'rtl']>) extends true ? { transform?: SpecificFieldPartial, D>, D>; } : { transform: Pick, D>; }; type StrictIncludeType = D extends 'both' ? { transform: SpecificFieldPartial, IncludeType extends 'LR' ? 'ltr' : 'rtl'>; } : D extends Exclude ? StrictIncludeMap : never; type IntersectButNotEqualType = D extends 'both' ? { transform: Transform; } : D extends Exclude ? { transform: Pick, D>; } : never; type NotIntersectType = IntersectButNotEqualType; interface Transform { ltr: (left: L) => R; rtl: (right: R) => L; } type TransformType = Equal extends true ? EqualType : IncludeButNotEqual extends true ? StrictIncludeType<'LR', D, L, R> : IncludeButNotEqual extends true ? StrictIncludeType<'RL', D, L, R> : IntersectButNotEqual extends true ? IntersectButNotEqualType : NotIntersect extends true ? NotIntersectType : never; type SyncRefOptions = ConfigurableFlushSync & { /** * Watch deeply * * @default false */ deep?: boolean; /** * Sync values immediately * * @default true */ immediate?: boolean; /** * Direction of syncing. Value will be redefined if you define syncConvertors * * @default 'both' */ direction?: D; } & TransformType; /** * Two-way refs synchronization. * From the set theory perspective to restrict the option's type * Check in the following order: * 1. L = R * 2. L ∩ R ≠ ∅ * 3. L ⊆ R * 4. L ∩ R = ∅ */ declare function syncRef(left: Ref, right: Ref, ...[options]: Equal extends true ? [options?: SyncRefOptions] : [options: SyncRefOptions]): () => void; interface SyncRefsOptions extends ConfigurableFlushSync { /** * Watch deeply * * @default false */ deep?: boolean; /** * Sync values immediately * * @default true */ immediate?: boolean; } /** * Keep target ref(s) in sync with the source ref * * @param source source ref * @param targets */ declare function syncRefs(source: WatchSource, targets: Ref | Ref[], options?: SyncRefsOptions): vue.WatchHandle; /** * Converts ref to reactive. * * @see https://vueuse.org/toReactive * @param objectRef A ref of object */ declare function toReactive(objectRef: MaybeRef): UnwrapNestedRefs; /** * Normalize value/ref/getter to `ref` or `computed`. */ declare function toRef(r: () => T): Readonly>; declare function toRef(r: ComputedRef): ComputedRef; declare function toRef(r: MaybeRefOrGetter): Ref; declare function toRef(r: T): Ref; declare function toRef(object: T, key: K): ToRef; declare function toRef(object: T, key: K, defaultValue: T[K]): ToRef>; /** * @deprecated use `toRef` instead */ declare const resolveRef: typeof toRef; interface ToRefsOptions { /** * Replace the original ref with a copy on property update. * * @default true */ replaceRef?: MaybeRefOrGetter; } /** * Extended `toRefs` that also accepts refs of an object. * * @see https://vueuse.org/toRefs * @param objectRef A ref or normal object or array. */ declare function toRefs(objectRef: MaybeRef, options?: ToRefsOptions): ToRefs; /** * Get the value of value/ref/getter. */ declare function toValue(r: MaybeRefOrGetter): T; /** * @deprecated use `toValue` instead */ declare const resolveUnref: typeof toValue; /** * Call onBeforeMount() if it's inside a component lifecycle, if not, just call the function * * @param fn * @param sync if set to false, it will run in the nextTick() of Vue * @param target */ declare function tryOnBeforeMount(fn: Fn, sync?: boolean, target?: any): void; /** * Call onBeforeUnmount() if it's inside a component lifecycle, if not, do nothing * * @param fn * @param target */ declare function tryOnBeforeUnmount(fn: Fn, target?: any): void; /** * Call onMounted() if it's inside a component lifecycle, if not, just call the function * * @param fn * @param sync if set to false, it will run in the nextTick() of Vue * @param target */ declare function tryOnMounted(fn: Fn, sync?: boolean, target?: any): void; /** * Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing * * @param fn */ declare function tryOnScopeDispose(fn: Fn): boolean; /** * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing * * @param fn * @param target */ declare function tryOnUnmounted(fn: Fn, target?: any): void; interface UntilToMatchOptions { /** * Milliseconds timeout for promise to resolve/reject if the when condition does not meet. * 0 for never timed out * * @default 0 */ timeout?: number; /** * Reject the promise when timeout * * @default false */ throwOnTimeout?: boolean; /** * `flush` option for internal watch * * @default 'sync' */ flush?: WatchOptions['flush']; /** * `deep` option for internal watch * * @default 'false' */ deep?: WatchOptions['deep']; } interface UntilBaseInstance { toMatch: ((condition: (v: T) => v is U, options?: UntilToMatchOptions) => Not extends true ? Promise> : Promise) & ((condition: (v: T) => boolean, options?: UntilToMatchOptions) => Promise); changed: (options?: UntilToMatchOptions) => Promise; changedTimes: (n?: number, options?: UntilToMatchOptions) => Promise; } type Falsy = false | void | null | undefined | 0 | 0n | ''; interface UntilValueInstance extends UntilBaseInstance { readonly not: UntilValueInstance; toBe:

(value: MaybeRefOrGetter

, options?: UntilToMatchOptions) => Not extends true ? Promise : Promise

; toBeTruthy: (options?: UntilToMatchOptions) => Not extends true ? Promise : Promise>; toBeNull: (options?: UntilToMatchOptions) => Not extends true ? Promise> : Promise; toBeUndefined: (options?: UntilToMatchOptions) => Not extends true ? Promise> : Promise; toBeNaN: (options?: UntilToMatchOptions) => Promise; } interface UntilArrayInstance extends UntilBaseInstance { readonly not: UntilArrayInstance; toContains: (value: MaybeRefOrGetter>>, options?: UntilToMatchOptions) => Promise; } /** * Promised one-time watch for changes * * @see https://vueuse.org/until * @example * ``` * const { count } = useCounter() * * await until(count).toMatch(v => v > 7) * * alert('Counter is now larger than 7!') * ``` */ declare function until(r: WatchSource | MaybeRefOrGetter): UntilArrayInstance; declare function until(r: WatchSource | MaybeRefOrGetter): UntilValueInstance; declare function useArrayDifference(list: MaybeRefOrGetter, values: MaybeRefOrGetter, key?: keyof T): ComputedRef; declare function useArrayDifference(list: MaybeRefOrGetter, values: MaybeRefOrGetter, compareFn?: (value: T, othVal: T) => boolean): ComputedRef; /** * Reactive `Array.every` * * @see https://vueuse.org/useArrayEvery * @param list - the array was called upon. * @param fn - a function to test each element. * * @returns **true** if the `fn` function returns a **truthy** value for every element from the array. Otherwise, **false**. */ declare function useArrayEvery(list: MaybeRefOrGetter[]>, fn: (element: T, index: number, array: MaybeRefOrGetter[]) => unknown): ComputedRef; /** * Reactive `Array.filter` * * @see https://vueuse.org/useArrayFilter * @param list - the array was called upon. * @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. * * @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. */ declare function useArrayFilter(list: MaybeRefOrGetter[]>, fn: (element: T, index: number, array: T[]) => element is S): ComputedRef; declare function useArrayFilter(list: MaybeRefOrGetter[]>, fn: (element: T, index: number, array: T[]) => unknown): ComputedRef; /** * Reactive `Array.find` * * @see https://vueuse.org/useArrayFind * @param list - the array was called upon. * @param fn - a function to test each element. * * @returns the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned. */ declare function useArrayFind(list: MaybeRefOrGetter[]>, fn: (element: T, index: number, array: MaybeRefOrGetter[]) => boolean): ComputedRef; /** * Reactive `Array.findIndex` * * @see https://vueuse.org/useArrayFindIndex * @param list - the array was called upon. * @param fn - a function to test each element. * * @returns the index of the first element in the array that passes the test. Otherwise, "-1". */ declare function useArrayFindIndex(list: MaybeRefOrGetter[]>, fn: (element: T, index: number, array: MaybeRefOrGetter[]) => unknown): ComputedRef; /** * Reactive `Array.findLast` * * @see https://vueuse.org/useArrayFindLast * @param list - the array was called upon. * @param fn - a function to test each element. * * @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned. */ declare function useArrayFindLast(list: MaybeRefOrGetter[]>, fn: (element: T, index: number, array: MaybeRefOrGetter[]) => boolean): ComputedRef; type UseArrayIncludesComparatorFn = ((element: T, value: V, index: number, array: MaybeRefOrGetter[]) => boolean); interface UseArrayIncludesOptions { fromIndex?: number; comparator?: UseArrayIncludesComparatorFn | keyof T; } /** * Reactive `Array.includes` * * @see https://vueuse.org/useArrayIncludes * * @returns true if the `value` is found in the array. Otherwise, false. */ declare function useArrayIncludes(list: MaybeRefOrGetter[]>, value: MaybeRefOrGetter, comparator?: UseArrayIncludesComparatorFn): ComputedRef; declare function useArrayIncludes(list: MaybeRefOrGetter[]>, value: MaybeRefOrGetter, comparator?: keyof T): ComputedRef; declare function useArrayIncludes(list: MaybeRefOrGetter[]>, value: MaybeRefOrGetter, options?: UseArrayIncludesOptions): ComputedRef; /** * Reactive `Array.join` * * @see https://vueuse.org/useArrayJoin * @param list - the array was called upon. * @param separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (","). * * @returns a string with all array elements joined. If arr.length is 0, the empty string is returned. */ declare function useArrayJoin(list: MaybeRefOrGetter[]>, separator?: MaybeRefOrGetter): ComputedRef; /** * Reactive `Array.map` * * @see https://vueuse.org/useArrayMap * @param list - the array was called upon. * @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. * * @returns a new array with each element being the result of the callback function. */ declare function useArrayMap(list: MaybeRefOrGetter[]>, fn: (element: T, index: number, array: T[]) => U): ComputedRef; type UseArrayReducer = (previousValue: PV, currentValue: CV, currentIndex: number) => R; /** * Reactive `Array.reduce` * * @see https://vueuse.org/useArrayReduce * @param list - the array was called upon. * @param reducer - a "reducer" function. * * @returns the value that results from running the "reducer" callback function to completion over the entire array. */ declare function useArrayReduce(list: MaybeRefOrGetter[]>, reducer: UseArrayReducer): ComputedRef; /** * Reactive `Array.reduce` * * @see https://vueuse.org/useArrayReduce * @param list - the array was called upon. * @param reducer - a "reducer" function. * @param initialValue - a value to be initialized the first time when the callback is called. * * @returns the value that results from running the "reducer" callback function to completion over the entire array. */ declare function useArrayReduce(list: MaybeRefOrGetter[]>, reducer: UseArrayReducer, initialValue: MaybeRefOrGetter): ComputedRef; /** * Reactive `Array.some` * * @see https://vueuse.org/useArraySome * @param list - the array was called upon. * @param fn - a function to test each element. * * @returns **true** if the `fn` function returns a **truthy** value for any element from the array. Otherwise, **false**. */ declare function useArraySome(list: MaybeRefOrGetter[]>, fn: (element: T, index: number, array: MaybeRefOrGetter[]) => unknown): ComputedRef; /** * reactive unique array * @see https://vueuse.org/useArrayUnique * @param list - the array was called upon. * @param compareFn * @returns A computed ref that returns a unique array of items. */ declare function useArrayUnique(list: MaybeRefOrGetter[]>, compareFn?: (a: T, b: T, array: T[]) => boolean): ComputedRef; interface UseCounterOptions { min?: number; max?: number; } /** * Basic counter with utility functions. * * @see https://vueuse.org/useCounter * @param [initialValue] * @param options */ declare function useCounter(initialValue?: MaybeRef, options?: UseCounterOptions): { count: vue.Ref>; inc: (delta?: number) => number; dec: (delta?: number) => number; get: () => number; set: (val: number) => number; reset: (val?: number) => number; }; type DateLike = Date | number | string | undefined; interface UseDateFormatOptions { /** * The locale(s) to used for dd/ddd/dddd/MMM/MMMM format * * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument). */ locales?: MaybeRefOrGetter; /** * A custom function to re-modify the way to display meridiem * */ customMeridiem?: (hours: number, minutes: number, isLowercase?: boolean, hasPeriod?: boolean) => string; } declare function formatDate(date: Date, formatStr: string, options?: UseDateFormatOptions): string; declare function normalizeDate(date: DateLike): Date; /** * Get the formatted date according to the string of tokens passed in. * * @see https://vueuse.org/useDateFormat * @param date - The date to format, can either be a `Date` object, a timestamp, or a string * @param formatStr - The combination of tokens to format the date * @param options - UseDateFormatOptions */ declare function useDateFormat(date: MaybeRefOrGetter, formatStr?: MaybeRefOrGetter, options?: UseDateFormatOptions): vue.ComputedRef; type UseDateFormatReturn = ReturnType; /** * Debounce execution of a function. * * @see https://vueuse.org/useDebounceFn * @param fn A function to be executed after delay milliseconds debounced. * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. * @param options Options * * @return A new, debounce, function. */ declare function useDebounceFn(fn: T, ms?: MaybeRefOrGetter, options?: DebounceFilterOptions): PromisifyFn; interface UseIntervalOptions { /** * Expose more controls * * @default false */ controls?: Controls; /** * Execute the update immediately on calling * * @default true */ immediate?: boolean; /** * Callback on every interval */ callback?: (count: number) => void; } interface UseIntervalControls { counter: Ref; reset: () => void; } /** * Reactive counter increases on every interval * * @see https://vueuse.org/useInterval * @param interval * @param options */ declare function useInterval(interval?: MaybeRefOrGetter, options?: UseIntervalOptions): Ref; declare function useInterval(interval: MaybeRefOrGetter, options: UseIntervalOptions): UseIntervalControls & Pausable; interface UseIntervalFnOptions { /** * Start the timer immediately * * @default true */ immediate?: boolean; /** * Execute the callback immediately after calling `resume` * * @default false */ immediateCallback?: boolean; } /** * Wrapper for `setInterval` with controls * * @param cb * @param interval * @param options */ declare function useIntervalFn(cb: Fn, interval?: MaybeRefOrGetter, options?: UseIntervalFnOptions): Pausable; interface UseLastChangedOptions extends WatchOptions { initialValue?: InitialValue; } /** * Records the timestamp of the last change * * @see https://vueuse.org/useLastChanged */ declare function useLastChanged(source: WatchSource, options?: UseLastChangedOptions): Ref; declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions | UseLastChangedOptions): Ref; /** * Throttle execution of a function. Especially useful for rate limiting * execution of handlers on events like resize and scroll. * * @param fn A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is, * to `callback` when the throttled-function is executed. * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. * (default value: 200) * * @param [trailing] if true, call fn again after the time is up (default value: false) * * @param [leading] if true, call fn on the leading edge of the ms timeout (default value: true) * * @param [rejectOnCancel] if true, reject the last call if it's been cancel (default value: false) * * @return A new, throttled, function. */ declare function useThrottleFn(fn: T, ms?: MaybeRefOrGetter, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): PromisifyFn; interface UseTimeoutFnOptions { /** * Start the timer immediate after calling this function * * @default true */ immediate?: boolean; } /** * Wrapper for `setTimeout` with controls. * * @param cb * @param interval * @param options */ declare function useTimeoutFn(cb: CallbackFn, interval: MaybeRefOrGetter, options?: UseTimeoutFnOptions): Stoppable | []>; interface UseTimeoutOptions extends UseTimeoutFnOptions { /** * Expose more controls * * @default false */ controls?: Controls; /** * Callback on timeout */ callback?: Fn; } /** * Update value after a given time with controls. * * @see {@link https://vueuse.org/useTimeout} * @param interval * @param options */ declare function useTimeout(interval?: MaybeRefOrGetter, options?: UseTimeoutOptions): ComputedRef; declare function useTimeout(interval: MaybeRefOrGetter, options: UseTimeoutOptions): { ready: ComputedRef; } & Stoppable; interface UseToNumberOptions { /** * Method to use to convert the value to a number. * * @default 'parseFloat' */ method?: 'parseFloat' | 'parseInt'; /** * The base in mathematical numeral systems passed to `parseInt`. * Only works with `method: 'parseInt'` */ radix?: number; /** * Replace NaN with zero * * @default false */ nanToZero?: boolean; } /** * Reactively convert a string ref to number. */ declare function useToNumber(value: MaybeRefOrGetter, options?: UseToNumberOptions): ComputedRef; /** * Reactively convert a ref to string. * * @see https://vueuse.org/useToString */ declare function useToString(value: MaybeRefOrGetter): ComputedRef; interface UseToggleOptions { truthyValue?: MaybeRefOrGetter; falsyValue?: MaybeRefOrGetter; } declare function useToggle(initialValue: Ref, options?: UseToggleOptions): (value?: T) => T; declare function useToggle(initialValue?: T, options?: UseToggleOptions): [Ref, (value?: T) => T]; declare type WatchArrayCallback = (value: V, oldValue: OV, added: V, removed: OV, onCleanup: (cleanupFn: () => void) => void) => any; /** * Watch for an array with additions and removals. * * @see https://vueuse.org/watchArray */ declare function watchArray = false>(source: WatchSource | T[], cb: WatchArrayCallback, options?: WatchOptions): vue.WatchHandle; interface WatchWithFilterOptions extends WatchOptions, ConfigurableEventFilter { } declare function watchWithFilter[]>, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapOldSources>, options?: WatchWithFilterOptions): WatchStopHandle; declare function watchWithFilter = false>(source: WatchSource, cb: WatchCallback, options?: WatchWithFilterOptions): WatchStopHandle; declare function watchWithFilter = false>(source: T, cb: WatchCallback, options?: WatchWithFilterOptions): WatchStopHandle; interface WatchAtMostOptions extends WatchWithFilterOptions { count: MaybeRefOrGetter; } interface WatchAtMostReturn { stop: WatchStopHandle; count: Ref; } declare function watchAtMost[]>, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapOldSources>, options: WatchAtMostOptions): WatchAtMostReturn; declare function watchAtMost = false>(sources: WatchSource, cb: WatchCallback, options: WatchAtMostOptions): WatchAtMostReturn; interface WatchDebouncedOptions extends WatchOptions, DebounceFilterOptions { debounce?: MaybeRefOrGetter; } declare function watchDebounced[]>, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapOldSources>, options?: WatchDebouncedOptions): WatchStopHandle; declare function watchDebounced = false>(source: WatchSource, cb: WatchCallback, options?: WatchDebouncedOptions): WatchStopHandle; declare function watchDebounced = false>(source: T, cb: WatchCallback, options?: WatchDebouncedOptions): WatchStopHandle; declare function watchDeep[]>, Immediate extends Readonly = false>(source: [...T], cb: WatchCallback, MapOldSources>, options?: Omit, 'deep'>): WatchStopHandle; declare function watchDeep = false>(source: WatchSource, cb: WatchCallback, options?: Omit, 'deep'>): WatchStopHandle; declare function watchDeep = false>(source: T, cb: WatchCallback, options?: Omit, 'deep'>): WatchStopHandle; type IgnoredUpdater = (updater: () => void) => void; interface WatchIgnorableReturn { ignoreUpdates: IgnoredUpdater; ignorePrevAsyncUpdates: () => void; stop: WatchStopHandle; } declare function watchIgnorable[]>, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapOldSources>, options?: WatchWithFilterOptions): WatchIgnorableReturn; declare function watchIgnorable = false>(source: WatchSource, cb: WatchCallback, options?: WatchWithFilterOptions): WatchIgnorableReturn; declare function watchIgnorable = false>(source: T, cb: WatchCallback, options?: WatchWithFilterOptions): WatchIgnorableReturn; declare function watchImmediate[]>>(source: [...T], cb: WatchCallback, MapOldSources>, options?: Omit, 'immediate'>): WatchStopHandle; declare function watchImmediate(source: WatchSource, cb: WatchCallback, options?: Omit, 'immediate'>): WatchStopHandle; declare function watchImmediate(source: T, cb: WatchCallback, options?: Omit, 'immediate'>): WatchStopHandle; declare function watchOnce[]>, Immediate extends Readonly = false>(source: [...T], cb: WatchCallback, MapOldSources>, options?: WatchOptions): WatchStopHandle; declare function watchOnce = false>(sources: WatchSource, cb: WatchCallback, options?: WatchOptions): WatchStopHandle; interface WatchPausableReturn extends Pausable { stop: WatchStopHandle; } declare function watchPausable[]>, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapOldSources>, options?: WatchWithFilterOptions): WatchPausableReturn; declare function watchPausable = false>(source: WatchSource, cb: WatchCallback, options?: WatchWithFilterOptions): WatchPausableReturn; declare function watchPausable = false>(source: T, cb: WatchCallback, options?: WatchWithFilterOptions): WatchPausableReturn; interface WatchThrottledOptions extends WatchOptions { throttle?: MaybeRefOrGetter; trailing?: boolean; leading?: boolean; } declare function watchThrottled[]>, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapOldSources>, options?: WatchThrottledOptions): WatchStopHandle; declare function watchThrottled = false>(source: WatchSource, cb: WatchCallback, options?: WatchThrottledOptions): WatchStopHandle; declare function watchThrottled = false>(source: T, cb: WatchCallback, options?: WatchThrottledOptions): WatchStopHandle; interface WatchTriggerableReturn extends WatchIgnorableReturn { /** Execute `WatchCallback` immediately */ trigger: () => FnReturnT; } type OnCleanup = (cleanupFn: () => void) => void; type WatchTriggerableCallback = (value: V, oldValue: OV, onCleanup: OnCleanup) => R; declare function watchTriggerable[]>, FnReturnT>(sources: [...T], cb: WatchTriggerableCallback, MapOldSources, FnReturnT>, options?: WatchWithFilterOptions): WatchTriggerableReturn; declare function watchTriggerable(source: WatchSource, cb: WatchTriggerableCallback, options?: WatchWithFilterOptions): WatchTriggerableReturn; declare function watchTriggerable(source: T, cb: WatchTriggerableCallback, options?: WatchWithFilterOptions): WatchTriggerableReturn; interface WheneverOptions extends WatchOptions { /** * Only trigger once when the condition is met * * Override the `once` option in `WatchOptions` * * @default false */ once?: boolean; } /** * Shorthand for watching value to be truthy * * @see https://vueuse.org/whenever */ declare function whenever(source: WatchSource, cb: WatchCallback, options?: WheneverOptions): vue.WatchHandle; 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 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 ThrottleFilterOptions, 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 WheneverOptions, 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, 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, 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 };