peerpigeon
Version:
WebRTC-based peer-to-peer mesh networking library with intelligent routing and signaling server
1,591 lines (1,545 loc) • 189 kB
text/typescript
import * as _vueuse_shared from '@vueuse/shared';
import { Fn, MaybeRef, MaybeRefOrGetter, Awaitable, ConfigurableEventFilter, ConfigurableFlush, RemovableRef, EventHookOn, Pausable, Arrayable, ReadonlyRefOrGetter, UseIntervalFnOptions, UseTimeoutFnOptions } from '@vueuse/shared';
export * from '@vueuse/shared';
import * as vue_demi from 'vue-demi';
import { Ref, InjectionKey, ComputedRef, DefineComponent, Slot, TransitionGroupProps, ComponentPublicInstance, Component, ShallowRef, WritableComputedRef, UnwrapRef, WatchOptions, UnwrapNestedRefs, WatchSource, ToRefs, StyleValue } from 'vue-demi';
import * as vue from 'vue-demi';
/**
* Handle overlapping async evaluations.
*
* @param cancelCallback The provided callback is invoked when a re-evaluation of the computed value is triggered before the previous one finished
*/
type AsyncComputedOnCancel = (cancelCallback: Fn) => void;
interface AsyncComputedOptions {
/**
* Should value be evaluated lazily
*
* @default false
*/
lazy?: boolean;
/**
* Ref passed to receive the updated of async evaluation
*/
evaluating?: Ref<boolean>;
/**
* Use shallowRef
*
* @default true
*/
shallow?: boolean;
/**
* Callback when error is caught.
*/
onError?: (e: unknown) => void;
}
/**
* Create an asynchronous computed dependency.
*
* @see https://vueuse.org/computedAsync
* @param evaluationCallback The promise-returning callback which generates the computed value
* @param initialState The initial state, used until the first evaluation finishes
* @param optionsOrRef Additional options or a ref passed to receive the updates of the async evaluation
*/
declare function computedAsync<T>(evaluationCallback: (onCancel: AsyncComputedOnCancel) => T | Promise<T>, initialState?: T, optionsOrRef?: Ref<boolean> | AsyncComputedOptions): Ref<T>;
type ComputedInjectGetter<T, K> = (source: T | undefined, ctx?: any) => K;
type ComputedInjectGetterWithDefault<T, K> = (source: T, ctx?: any) => K;
type ComputedInjectSetter<T> = (v: T) => void;
interface WritableComputedInjectOptions<T, K> {
get: ComputedInjectGetter<T, K>;
set: ComputedInjectSetter<K>;
}
interface WritableComputedInjectOptionsWithDefault<T, K> {
get: ComputedInjectGetterWithDefault<T, K>;
set: ComputedInjectSetter<K>;
}
declare function computedInject<T, K = any>(key: InjectionKey<T> | string, getter: ComputedInjectGetter<T, K>): ComputedRef<K | undefined>;
declare function computedInject<T, K = any>(key: InjectionKey<T> | string, options: WritableComputedInjectOptions<T, K>): ComputedRef<K | undefined>;
declare function computedInject<T, K = any>(key: InjectionKey<T> | string, getter: ComputedInjectGetterWithDefault<T, K>, defaultSource: T, treatDefaultAsFactory?: false): ComputedRef<K>;
declare function computedInject<T, K = any>(key: InjectionKey<T> | string, options: WritableComputedInjectOptionsWithDefault<T, K>, defaultSource: T | (() => T), treatDefaultAsFactory: true): ComputedRef<K>;
type ObjectLiteralWithPotentialObjectLiterals = Record<string, Record<string, any> | undefined>;
type GenerateSlotsFromSlotMap<T extends ObjectLiteralWithPotentialObjectLiterals> = {
[K in keyof T]: Slot<T[K]>;
};
type DefineTemplateComponent<Bindings extends Record<string, any>, MapSlotNameToSlotProps extends ObjectLiteralWithPotentialObjectLiterals> = DefineComponent & {
new (): {
$slots: {
default: (_: Bindings & {
$slots: GenerateSlotsFromSlotMap<MapSlotNameToSlotProps>;
}) => any;
};
};
};
type ReuseTemplateComponent<Bindings extends Record<string, any>, MapSlotNameToSlotProps extends ObjectLiteralWithPotentialObjectLiterals> = DefineComponent<Bindings> & {
new (): {
$slots: GenerateSlotsFromSlotMap<MapSlotNameToSlotProps>;
};
};
type ReusableTemplatePair<Bindings extends Record<string, any>, MapSlotNameToSlotProps extends ObjectLiteralWithPotentialObjectLiterals> = [
DefineTemplateComponent<Bindings, MapSlotNameToSlotProps>,
ReuseTemplateComponent<Bindings, MapSlotNameToSlotProps>
] & {
define: DefineTemplateComponent<Bindings, MapSlotNameToSlotProps>;
reuse: ReuseTemplateComponent<Bindings, MapSlotNameToSlotProps>;
};
interface CreateReusableTemplateOptions {
/**
* Inherit attrs from reuse component.
*
* @default true
*/
inheritAttrs?: boolean;
}
/**
* This function creates `define` and `reuse` components in pair,
* It also allow to pass a generic to bind with type.
*
* @see https://vueuse.org/createReusableTemplate
*/
declare function createReusableTemplate<Bindings extends Record<string, any>, MapSlotNameToSlotProps extends ObjectLiteralWithPotentialObjectLiterals = Record<'default', undefined>>(options?: CreateReusableTemplateOptions): ReusableTemplatePair<Bindings, MapSlotNameToSlotProps>;
interface TemplatePromiseProps<Return, Args extends any[] = []> {
/**
* The promise instance.
*/
promise: Promise<Return> | undefined;
/**
* Resolve the promise.
*/
resolve: (v: Return | Promise<Return>) => void;
/**
* Reject the promise.
*/
reject: (v: any) => void;
/**
* Arguments passed to TemplatePromise.start()
*/
args: Args;
/**
* Indicates if the promise is resolving.
* When passing another promise to `resolve`, this will be set to `true` until the promise is resolved.
*/
isResolving: boolean;
/**
* Options passed to createTemplatePromise()
*/
options: TemplatePromiseOptions;
/**
* Unique key for list rendering.
*/
key: number;
}
interface TemplatePromiseOptions {
/**
* Determines if the promise can be called only once at a time.
*
* @default false
*/
singleton?: boolean;
/**
* Transition props for the promise.
*/
transition?: TransitionGroupProps;
}
type TemplatePromise<Return, Args extends any[] = []> = DefineComponent<{}> & {
new (): {
$slots: {
default: (_: TemplatePromiseProps<Return, Args>) => any;
};
};
} & {
start: (...args: Args) => Promise<Return>;
};
/**
* Creates a template promise component.
*
* @see https://vueuse.org/createTemplatePromise
*/
declare function createTemplatePromise<Return, Args extends any[] = []>(options?: TemplatePromiseOptions): TemplatePromise<Return, Args>;
type UnrefFn<T> = T extends (...args: infer A) => infer R ? (...args: {
[K in keyof A]: MaybeRef<A[K]>;
}) => R : never;
/**
* Make a plain function accepting ref and raw values as arguments.
* Returns the same value the unconverted function returns, with proper typing.
*/
declare function createUnrefFn<T extends Function>(fn: T): UnrefFn<T>;
type VueInstance = ComponentPublicInstance;
type MaybeElementRef<T extends MaybeElement = MaybeElement> = MaybeRef<T>;
type MaybeComputedElementRef<T extends MaybeElement = MaybeElement> = MaybeRefOrGetter<T>;
type MaybeElement = HTMLElement | SVGElement | VueInstance | undefined | null;
type UnRefElementReturn<T extends MaybeElement = MaybeElement> = T extends VueInstance ? Exclude<MaybeElement, VueInstance> : T | undefined;
/**
* Get the dom element of a ref of element or Vue component instance
*
* @param elRef
*/
declare function unrefElement<T extends MaybeElement>(elRef: MaybeComputedElementRef<T>): UnRefElementReturn<T>;
interface ConfigurableWindow {
window?: Window;
}
interface ConfigurableDocument {
document?: Document;
}
interface ConfigurableDocumentOrShadowRoot {
document?: DocumentOrShadowRoot;
}
interface ConfigurableNavigator {
navigator?: Navigator;
}
interface ConfigurableLocation {
location?: Location;
}
declare const defaultWindow: (Window & typeof globalThis) | undefined;
declare const defaultDocument: Document | undefined;
declare const defaultNavigator: Navigator | undefined;
declare const defaultLocation: Location | undefined;
interface OnClickOutsideOptions extends ConfigurableWindow {
/**
* List of elements that should not trigger the event.
*/
ignore?: (MaybeElementRef | string)[];
/**
* Use capturing phase for internal event listener.
* @default true
*/
capture?: boolean;
/**
* Run handler function if focus moves to an iframe.
* @default false
*/
detectIframe?: boolean;
}
type OnClickOutsideHandler<T extends {
detectIframe: OnClickOutsideOptions['detectIframe'];
} = {
detectIframe: false;
}> = (evt: T['detectIframe'] extends true ? PointerEvent | FocusEvent : PointerEvent) => void;
/**
* Listen for clicks outside of an element.
*
* @see https://vueuse.org/onClickOutside
* @param target
* @param handler
* @param options
*/
declare function onClickOutside<T extends OnClickOutsideOptions>(target: MaybeElementRef, handler: OnClickOutsideHandler<{
detectIframe: T['detectIframe'];
}>, options?: T): () => void;
type KeyPredicate = (event: KeyboardEvent) => boolean;
type KeyFilter = true | string | string[] | KeyPredicate;
type KeyStrokeEventName = 'keydown' | 'keypress' | 'keyup';
interface OnKeyStrokeOptions {
eventName?: KeyStrokeEventName;
target?: MaybeRefOrGetter<EventTarget | null | undefined>;
passive?: boolean;
/**
* Set to `true` to ignore repeated events when the key is being held down.
*
* @default false
*/
dedupe?: MaybeRefOrGetter<boolean>;
}
/**
* Listen for keyboard keystrokes.
*
* @see https://vueuse.org/onKeyStroke
*/
declare function onKeyStroke(key: KeyFilter, handler: (event: KeyboardEvent) => void, options?: OnKeyStrokeOptions): () => void;
declare function onKeyStroke(handler: (event: KeyboardEvent) => void, options?: OnKeyStrokeOptions): () => void;
/**
* Listen to the keydown event of the given key.
*
* @see https://vueuse.org/onKeyStroke
* @param key
* @param handler
* @param options
*/
declare function onKeyDown(key: KeyFilter, handler: (event: KeyboardEvent) => void, options?: Omit<OnKeyStrokeOptions, 'eventName'>): () => void;
/**
* Listen to the keypress event of the given key.
*
* @see https://vueuse.org/onKeyStroke
* @param key
* @param handler
* @param options
*/
declare function onKeyPressed(key: KeyFilter, handler: (event: KeyboardEvent) => void, options?: Omit<OnKeyStrokeOptions, 'eventName'>): () => void;
/**
* Listen to the keyup event of the given key.
*
* @see https://vueuse.org/onKeyStroke
* @param key
* @param handler
* @param options
*/
declare function onKeyUp(key: KeyFilter, handler: (event: KeyboardEvent) => void, options?: Omit<OnKeyStrokeOptions, 'eventName'>): () => void;
interface OnLongPressOptions {
/**
* Time in ms till `longpress` gets called
*
* @default 500
*/
delay?: number;
modifiers?: OnLongPressModifiers;
/**
* Allowance of moving distance in pixels,
* The action will get canceled When moving too far from the pointerdown position.
* @default 10
*/
distanceThreshold?: number | false;
/**
* Function called when the ref element is released.
* @param duration how long the element was pressed in ms
* @param distance distance from the pointerdown position
* @param isLongPress whether the action was a long press or not
*/
onMouseUp?: (duration: number, distance: number, isLongPress: boolean) => void;
}
interface OnLongPressModifiers {
stop?: boolean;
once?: boolean;
prevent?: boolean;
capture?: boolean;
self?: boolean;
}
declare function onLongPress(target: MaybeElementRef, handler: (evt: PointerEvent) => void, options?: OnLongPressOptions): () => void;
/**
* Fires when users start typing on non-editable elements.
*
* @see https://vueuse.org/onStartTyping
* @param callback
* @param options
*/
declare function onStartTyping(callback: (event: KeyboardEvent) => void, options?: ConfigurableDocument): void;
/**
* Shorthand for binding ref to template element.
*
* @see https://vueuse.org/templateRef
* @param key
* @param initialValue
*/
declare function templateRef<T extends HTMLElement | SVGElement | Component | null>(key: string, initialValue?: T | null): Readonly<Ref<T>>;
interface UseActiveElementOptions extends ConfigurableWindow, ConfigurableDocumentOrShadowRoot {
/**
* Search active element deeply inside shadow dom
*
* @default true
*/
deep?: boolean;
/**
* Track active element when it's removed from the DOM
* Using a MutationObserver under the hood
* @default false
*/
triggerOnRemoval?: boolean;
}
/**
* Reactive `document.activeElement`
*
* @see https://vueuse.org/useActiveElement
* @param options
*/
declare function useActiveElement<T extends HTMLElement>(options?: UseActiveElementOptions): vue_demi.Ref<T | null | undefined>;
interface UseAnimateOptions extends KeyframeAnimationOptions, ConfigurableWindow {
/**
* Will automatically run play when `useAnimate` is used
*
* @default true
*/
immediate?: boolean;
/**
* Whether to commits the end styling state of an animation to the element being animated
* In general, you should use `fill` option with this.
*
* @default false
*/
commitStyles?: boolean;
/**
* Whether to persists the animation
*
* @default false
*/
persist?: boolean;
/**
* Executed after animation initialization
*/
onReady?: (animate: Animation) => void;
/**
* Callback when error is caught.
*/
onError?: (e: unknown) => void;
}
type UseAnimateKeyframes = MaybeRef<Keyframe[] | PropertyIndexedKeyframes | null>;
interface UseAnimateReturn {
isSupported: Ref<boolean>;
animate: ShallowRef<Animation | undefined>;
play: () => void;
pause: () => void;
reverse: () => void;
finish: () => void;
cancel: () => void;
pending: ComputedRef<boolean>;
playState: ComputedRef<AnimationPlayState>;
replaceState: ComputedRef<AnimationReplaceState>;
startTime: WritableComputedRef<CSSNumberish | number | null>;
currentTime: WritableComputedRef<CSSNumberish | null>;
timeline: WritableComputedRef<AnimationTimeline | null>;
playbackRate: WritableComputedRef<number>;
}
/**
* Reactive Web Animations API
*
* @see https://vueuse.org/useAnimate
* @param target
* @param keyframes
* @param options
*/
declare function useAnimate(target: MaybeComputedElementRef, keyframes: UseAnimateKeyframes, options?: number | UseAnimateOptions): UseAnimateReturn;
type UseAsyncQueueTask<T> = (...args: any[]) => T | Promise<T>;
type MapQueueTask<T extends any[]> = {
[K in keyof T]: UseAsyncQueueTask<T[K]>;
};
interface UseAsyncQueueResult<T> {
state: 'aborted' | 'fulfilled' | 'pending' | 'rejected';
data: T | null;
}
interface UseAsyncQueueReturn<T> {
activeIndex: Ref<number>;
result: T;
}
interface UseAsyncQueueOptions {
/**
* Interrupt tasks when current task fails.
*
* @default true
*/
interrupt?: boolean;
/**
* Trigger it when the tasks fails.
*
*/
onError?: () => void;
/**
* Trigger it when the tasks ends.
*
*/
onFinished?: () => void;
/**
* A AbortSignal that can be used to abort the task.
*/
signal?: AbortSignal;
}
/**
* Asynchronous queue task controller.
*
* @see https://vueuse.org/useAsyncQueue
* @param tasks
* @param options
*/
declare function useAsyncQueue<T extends any[], S = MapQueueTask<T>>(tasks: S & Array<UseAsyncQueueTask<any>>, options?: UseAsyncQueueOptions): UseAsyncQueueReturn<{
[P in keyof T]: UseAsyncQueueResult<T[P]>;
}>;
interface UseAsyncStateReturnBase<Data, Params extends any[], Shallow extends boolean> {
state: Shallow extends true ? Ref<Data> : Ref<UnwrapRef<Data>>;
isReady: Ref<boolean>;
isLoading: Ref<boolean>;
error: Ref<unknown>;
execute: (delay?: number, ...args: Params) => Promise<Data>;
}
type UseAsyncStateReturn<Data, Params extends any[], Shallow extends boolean> = UseAsyncStateReturnBase<Data, Params, Shallow> & PromiseLike<UseAsyncStateReturnBase<Data, Params, Shallow>>;
interface UseAsyncStateOptions<Shallow extends boolean, D = any> {
/**
* Delay for executing the promise. In milliseconds.
*
* @default 0
*/
delay?: number;
/**
* Execute the promise right after the function is invoked.
* Will apply the delay if any.
*
* When set to false, you will need to execute it manually.
*
* @default true
*/
immediate?: boolean;
/**
* Callback when error is caught.
*/
onError?: (e: unknown) => void;
/**
* Callback when success is caught.
* @param {D} data
*/
onSuccess?: (data: D) => void;
/**
* Sets the state to initialState before executing the promise.
*
* This can be useful when calling the execute function more than once (for
* example, to refresh data). When set to false, the current state remains
* unchanged until the promise resolves.
*
* @default true
*/
resetOnExecute?: boolean;
/**
* Use shallowRef.
*
* @default true
*/
shallow?: Shallow;
/**
*
* An error is thrown when executing the execute function
*
* @default false
*/
throwError?: boolean;
}
/**
* Reactive async state. Will not block your setup function and will trigger changes once
* the promise is ready.
*
* @see https://vueuse.org/useAsyncState
* @param promise The promise / async function to be resolved
* @param initialState The initial state, used until the first evaluation finishes
* @param options
*/
declare function useAsyncState<Data, Params extends any[] = [], Shallow extends boolean = true>(promise: Promise<Data> | ((...args: Params) => Promise<Data>), initialState: Data, options?: UseAsyncStateOptions<Shallow, Data>): UseAsyncStateReturn<Data, Params, Shallow>;
interface ToDataURLOptions {
/**
* MIME type
*/
type?: string | undefined;
/**
* Image quality of jpeg or webp
*/
quality?: any;
}
interface UseBase64ObjectOptions<T> {
serializer: (v: T) => string;
}
interface UseBase64Return {
base64: Ref<string>;
promise: Ref<Promise<string>>;
execute: () => Promise<string>;
}
declare function useBase64(target: MaybeRefOrGetter<string>): UseBase64Return;
declare function useBase64(target: MaybeRefOrGetter<Blob>): UseBase64Return;
declare function useBase64(target: MaybeRefOrGetter<ArrayBuffer>): UseBase64Return;
declare function useBase64(target: MaybeRefOrGetter<HTMLCanvasElement>, options?: ToDataURLOptions): UseBase64Return;
declare function useBase64(target: MaybeRefOrGetter<HTMLImageElement>, options?: ToDataURLOptions): UseBase64Return;
declare function useBase64<T extends Record<string, unknown>>(target: MaybeRefOrGetter<T>, options?: UseBase64ObjectOptions<T>): UseBase64Return;
declare function useBase64<T extends Map<string, unknown>>(target: MaybeRefOrGetter<T>, options?: UseBase64ObjectOptions<T>): UseBase64Return;
declare function useBase64<T extends Set<unknown>>(target: MaybeRefOrGetter<T>, options?: UseBase64ObjectOptions<T>): UseBase64Return;
declare function useBase64<T>(target: MaybeRefOrGetter<T[]>, options?: UseBase64ObjectOptions<T[]>): UseBase64Return;
interface BatteryManager extends EventTarget {
charging: boolean;
chargingTime: number;
dischargingTime: number;
level: number;
}
/**
* Reactive Battery Status API.
*
* @see https://vueuse.org/useBattery
*/
declare function useBattery(options?: ConfigurableNavigator): {
isSupported: vue_demi.ComputedRef<boolean>;
charging: vue_demi.Ref<boolean>;
chargingTime: vue_demi.Ref<number>;
dischargingTime: vue_demi.Ref<number>;
level: vue_demi.Ref<number>;
};
type UseBatteryReturn = ReturnType<typeof useBattery>;
interface UseBluetoothRequestDeviceOptions {
/**
*
* An array of BluetoothScanFilters. This filter consists of an array
* of BluetoothServiceUUIDs, a name parameter, and a namePrefix parameter.
*
*/
filters?: BluetoothLEScanFilter[] | undefined;
/**
*
* An array of BluetoothServiceUUIDs.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/BluetoothRemoteGATTService/uuid
*
*/
optionalServices?: BluetoothServiceUUID[] | undefined;
}
interface UseBluetoothOptions extends UseBluetoothRequestDeviceOptions, ConfigurableNavigator {
/**
*
* A boolean value indicating that the requesting script can accept all Bluetooth
* devices. The default is false.
*
* !! This may result in a bunch of unrelated devices being shown
* in the chooser and energy being wasted as there are no filters.
*
*
* Use it with caution.
*
* @default false
*
*/
acceptAllDevices?: boolean;
}
declare function useBluetooth(options?: UseBluetoothOptions): UseBluetoothReturn;
interface UseBluetoothReturn {
isSupported: Ref<boolean>;
isConnected: ComputedRef<boolean>;
device: Ref<BluetoothDevice | undefined>;
requestDevice: () => Promise<void>;
server: Ref<BluetoothRemoteGATTServer | undefined>;
error: Ref<unknown | null>;
}
/**
* Breakpoints from Tailwind V2
*
* @see https://tailwindcss.com/docs/breakpoints
*/
declare const breakpointsTailwind: {
sm: number;
md: number;
lg: number;
xl: number;
'2xl': number;
};
/**
* Breakpoints from Bootstrap V5
*
* @see https://getbootstrap.com/docs/5.0/layout/breakpoints
*/
declare const breakpointsBootstrapV5: {
xs: number;
sm: number;
md: number;
lg: number;
xl: number;
xxl: number;
};
/**
* Breakpoints from Vuetify V2
*
* @see https://v2.vuetifyjs.com/en/features/breakpoints/
*/
declare const breakpointsVuetifyV2: {
xs: number;
sm: number;
md: number;
lg: number;
xl: number;
};
/**
* Breakpoints from Vuetify V3
*
* @see https://vuetifyjs.com/en/styles/float/#overview
*/
declare const breakpointsVuetifyV3: {
xs: number;
sm: number;
md: number;
lg: number;
xl: number;
xxl: number;
};
/**
* Alias to `breakpointsVuetifyV2`
*
* @deprecated explictly use `breakpointsVuetifyV2` or `breakpointsVuetifyV3` instead
*/
declare const breakpointsVuetify: {
xs: number;
sm: number;
md: number;
lg: number;
xl: number;
};
/**
* Breakpoints from Ant Design
*
* @see https://ant.design/components/layout/#breakpoint-width
*/
declare const breakpointsAntDesign: {
xs: number;
sm: number;
md: number;
lg: number;
xl: number;
xxl: number;
};
/**
* Breakpoints from Quasar V2
*
* @see https://quasar.dev/style/breakpoints
*/
declare const breakpointsQuasar: {
xs: number;
sm: number;
md: number;
lg: number;
xl: number;
};
/**
* Sematic Breakpoints
*/
declare const breakpointsSematic: {
mobileS: number;
mobileM: number;
mobileL: number;
tablet: number;
laptop: number;
laptopL: number;
desktop4K: number;
};
/**
* Breakpoints from Master CSS
*
* @see https://docs.master.co/css/breakpoints
*/
declare const breakpointsMasterCss: {
'3xs': number;
'2xs': number;
xs: number;
sm: number;
md: number;
lg: number;
xl: number;
'2xl': number;
'3xl': number;
'4xl': number;
};
/**
* Breakpoints from PrimeFlex
*
* @see https://primeflex.org/installation
*/
declare const breakpointsPrimeFlex: {
sm: number;
md: number;
lg: number;
xl: number;
};
type Breakpoints<K extends string = string> = Record<K, MaybeRefOrGetter<number | string>>;
interface UseBreakpointsOptions extends ConfigurableWindow {
/**
* The query strategy to use for the generated shortcut methods like `.lg`
*
* 'min-width' - .lg will be true when the viewport is greater than or equal to the lg breakpoint (mobile-first)
* 'max-width' - .lg will be true when the viewport is smaller than the xl breakpoint (desktop-first)
*
* @default "min-width"
*/
strategy?: 'min-width' | 'max-width';
}
/**
* Reactively viewport breakpoints
*
* @see https://vueuse.org/useBreakpoints
*/
declare function useBreakpoints<K extends string>(breakpoints: Breakpoints<K>, options?: UseBreakpointsOptions): Record<K, Ref<boolean>> & {
greaterOrEqual: (k: MaybeRefOrGetter<K>) => Ref<boolean>;
smallerOrEqual: (k: MaybeRefOrGetter<K>) => Ref<boolean>;
greater(k: MaybeRefOrGetter<K>): Ref<boolean>;
smaller(k: MaybeRefOrGetter<K>): Ref<boolean>;
between(a: MaybeRefOrGetter<K>, b: MaybeRefOrGetter<K>): Ref<boolean>;
isGreater(k: MaybeRefOrGetter<K>): boolean;
isGreaterOrEqual(k: MaybeRefOrGetter<K>): boolean;
isSmaller(k: MaybeRefOrGetter<K>): boolean;
isSmallerOrEqual(k: MaybeRefOrGetter<K>): boolean;
isInBetween(a: MaybeRefOrGetter<K>, b: MaybeRefOrGetter<K>): boolean;
current: () => ComputedRef<string[]>;
active(): ComputedRef<string | undefined>;
};
type UseBreakpointsReturn<K extends string = string> = {
greater: (k: MaybeRefOrGetter<K>) => ComputedRef<boolean>;
greaterOrEqual: (k: MaybeRefOrGetter<K>) => ComputedRef<boolean>;
smaller: (k: MaybeRefOrGetter<K>) => ComputedRef<boolean>;
smallerOrEqual: (k: MaybeRefOrGetter<K>) => ComputedRef<boolean>;
between: (a: MaybeRefOrGetter<K>, b: MaybeRefOrGetter<K>) => ComputedRef<boolean>;
isGreater: (k: MaybeRefOrGetter<K>) => boolean;
isGreaterOrEqual: (k: MaybeRefOrGetter<K>) => boolean;
isSmaller: (k: MaybeRefOrGetter<K>) => boolean;
isSmallerOrEqual: (k: MaybeRefOrGetter<K>) => boolean;
isInBetween: (a: MaybeRefOrGetter<K>, b: MaybeRefOrGetter<K>) => boolean;
current: () => ComputedRef<string[]>;
active: ComputedRef<string>;
} & Record<K, ComputedRef<boolean>>;
interface UseBroadcastChannelOptions extends ConfigurableWindow {
/**
* The name of the channel.
*/
name: string;
}
/**
* Reactive BroadcastChannel
*
* @see https://vueuse.org/useBroadcastChannel
* @see https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
* @param options
*
*/
declare function useBroadcastChannel<D, P>(options: UseBroadcastChannelOptions): UseBroadcastChannelReturn<D, P>;
interface UseBroadcastChannelReturn<D, P> {
isSupported: Ref<boolean>;
channel: Ref<BroadcastChannel | undefined>;
data: Ref<D>;
post: (data: P) => void;
close: () => void;
error: Ref<Event | null>;
isClosed: Ref<boolean>;
}
interface BrowserLocationState {
readonly trigger: string;
readonly state?: any;
readonly length?: number;
readonly origin?: string;
hash?: string;
host?: string;
hostname?: string;
href?: string;
pathname?: string;
port?: string;
protocol?: string;
search?: string;
}
/**
* Reactive browser location.
*
* @see https://vueuse.org/useBrowserLocation
*/
declare function useBrowserLocation(options?: ConfigurableWindow): Ref<{
readonly trigger: string;
readonly state?: any;
readonly length?: number | undefined;
readonly origin?: string | undefined;
hash?: string | undefined;
host?: string | undefined;
hostname?: string | undefined;
href?: string | undefined;
pathname?: string | undefined;
port?: string | undefined;
protocol?: string | undefined;
search?: string | undefined;
}>;
type UseBrowserLocationReturn = ReturnType<typeof useBrowserLocation>;
declare function useCached<T>(refValue: Ref<T>, comparator?: (a: T, b: T) => boolean, watchOptions?: WatchOptions): Ref<T>;
interface UseClipboardOptions<Source> extends ConfigurableNavigator {
/**
* Enabled reading for clipboard
*
* @default false
*/
read?: boolean;
/**
* Copy source
*/
source?: Source;
/**
* Milliseconds to reset state of `copied` ref
*
* @default 1500
*/
copiedDuring?: number;
/**
* Whether fallback to document.execCommand('copy') if clipboard is undefined.
*
* @default false
*/
legacy?: boolean;
}
interface UseClipboardReturn<Optional> {
isSupported: Ref<boolean>;
text: ComputedRef<string>;
copied: ComputedRef<boolean>;
copy: Optional extends true ? (text?: string) => Promise<void> : (text: string) => Promise<void>;
}
/**
* Reactive Clipboard API.
*
* @see https://vueuse.org/useClipboard
* @param options
*/
declare function useClipboard(options?: UseClipboardOptions<undefined>): UseClipboardReturn<false>;
declare function useClipboard(options: UseClipboardOptions<MaybeRefOrGetter<string>>): UseClipboardReturn<true>;
interface UseClipboardItemsOptions<Source> extends ConfigurableNavigator {
/**
* Enabled reading for clipboard
*
* @default false
*/
read?: boolean;
/**
* Copy source
*/
source?: Source;
/**
* Milliseconds to reset state of `copied` ref
*
* @default 1500
*/
copiedDuring?: number;
}
interface UseClipboardItemsReturn<Optional> {
isSupported: Ref<boolean>;
content: ComputedRef<ClipboardItems>;
copied: ComputedRef<boolean>;
copy: Optional extends true ? (content?: ClipboardItems) => Promise<void> : (text: ClipboardItems) => Promise<void>;
}
/**
* Reactive Clipboard API.
*
* @see https://vueuse.org/useClipboardItems
* @param options
*/
declare function useClipboardItems(options?: UseClipboardItemsOptions<undefined>): UseClipboardItemsReturn<false>;
declare function useClipboardItems(options: UseClipboardItemsOptions<MaybeRefOrGetter<ClipboardItems>>): UseClipboardItemsReturn<true>;
interface UseClonedOptions<T = any> extends WatchOptions {
/**
* Custom clone function.
*
* By default, it use `JSON.parse(JSON.stringify(value))` to clone.
*/
clone?: (source: T) => T;
/**
* Manually sync the ref
*
* @default false
*/
manual?: boolean;
}
interface UseClonedReturn<T> {
/**
* Cloned ref
*/
cloned: Ref<T>;
/**
* Sync cloned data with source manually
*/
sync: () => void;
}
type CloneFn<F, T = F> = (x: F) => T;
declare function cloneFnJSON<T>(source: T): T;
declare function useCloned<T>(source: MaybeRefOrGetter<T>, options?: UseClonedOptions): UseClonedReturn<T>;
interface StorageLikeAsync {
getItem: (key: string) => Awaitable<string | null>;
setItem: (key: string, value: string) => Awaitable<void>;
removeItem: (key: string) => Awaitable<void>;
}
interface StorageLike {
getItem: (key: string) => string | null;
setItem: (key: string, value: string) => void;
removeItem: (key: string) => void;
}
/**
* @experimental The API is not finalized yet. It might not follow semver.
*/
interface SSRHandlersMap {
getDefaultStorage: () => StorageLike | undefined;
getDefaultStorageAsync: () => StorageLikeAsync | undefined;
updateHTMLAttrs: (selector: string | MaybeElementRef, attribute: string, value: string) => void;
}
declare function getSSRHandler<T extends keyof SSRHandlersMap>(key: T, fallback: SSRHandlersMap[T]): SSRHandlersMap[T];
declare function getSSRHandler<T extends keyof SSRHandlersMap>(key: T, fallback: SSRHandlersMap[T] | undefined): SSRHandlersMap[T] | undefined;
declare function setSSRHandler<T extends keyof SSRHandlersMap>(key: T, fn: SSRHandlersMap[T]): void;
interface Serializer<T> {
read: (raw: string) => T;
write: (value: T) => string;
}
interface SerializerAsync<T> {
read: (raw: string) => Awaitable<T>;
write: (value: T) => Awaitable<string>;
}
declare const StorageSerializers: Record<'boolean' | 'object' | 'number' | 'any' | 'string' | 'map' | 'set' | 'date', Serializer<any>>;
declare const customStorageEventName = "vueuse-storage";
interface StorageEventLike {
storageArea: StorageLike | null;
key: StorageEvent['key'];
oldValue: StorageEvent['oldValue'];
newValue: StorageEvent['newValue'];
}
interface UseStorageOptions<T> extends ConfigurableEventFilter, ConfigurableWindow, ConfigurableFlush {
/**
* Watch for deep changes
*
* @default true
*/
deep?: boolean;
/**
* Listen to storage changes, useful for multiple tabs application
*
* @default true
*/
listenToStorageChanges?: boolean;
/**
* Write the default value to the storage when it does not exist
*
* @default true
*/
writeDefaults?: boolean;
/**
* Merge the default value with the value read from the storage.
*
* When setting it to true, it will perform a **shallow merge** for objects.
* You can pass a function to perform custom merge (e.g. deep merge), for example:
*
* @default false
*/
mergeDefaults?: boolean | ((storageValue: T, defaults: T) => T);
/**
* Custom data serialization
*/
serializer?: Serializer<T>;
/**
* On error callback
*
* Default log error to `console.error`
*/
onError?: (error: unknown) => void;
/**
* Use shallow ref as reference
*
* @default false
*/
shallow?: boolean;
/**
* Wait for the component to be mounted before reading the storage.
*
* @default false
*/
initOnMounted?: boolean;
}
declare function useStorage(key: string, defaults: MaybeRefOrGetter<string>, storage?: StorageLike, options?: UseStorageOptions<string>): RemovableRef<string>;
declare function useStorage(key: string, defaults: MaybeRefOrGetter<boolean>, storage?: StorageLike, options?: UseStorageOptions<boolean>): RemovableRef<boolean>;
declare function useStorage(key: string, defaults: MaybeRefOrGetter<number>, storage?: StorageLike, options?: UseStorageOptions<number>): RemovableRef<number>;
declare function useStorage<T>(key: string, defaults: MaybeRefOrGetter<T>, storage?: StorageLike, options?: UseStorageOptions<T>): RemovableRef<T>;
declare function useStorage<T = unknown>(key: string, defaults: MaybeRefOrGetter<null>, storage?: StorageLike, options?: UseStorageOptions<T>): RemovableRef<T>;
type BasicColorMode = 'light' | 'dark';
type BasicColorSchema = BasicColorMode | 'auto';
interface UseColorModeOptions<T extends string = BasicColorMode> extends UseStorageOptions<T | BasicColorMode> {
/**
* CSS Selector for the target element applying to
*
* @default 'html'
*/
selector?: string | MaybeElementRef;
/**
* HTML attribute applying the target element
*
* @default 'class'
*/
attribute?: string;
/**
* The initial color mode
*
* @default 'auto'
*/
initialValue?: MaybeRefOrGetter<T | BasicColorSchema>;
/**
* Prefix when adding value to the attribute
*/
modes?: Partial<Record<T | BasicColorSchema, string>>;
/**
* A custom handler for handle the updates.
* When specified, the default behavior will be overridden.
*
* @default undefined
*/
onChanged?: (mode: T | BasicColorMode, defaultHandler: ((mode: T | BasicColorMode) => void)) => void;
/**
* Custom storage ref
*
* When provided, `useStorage` will be skipped
*/
storageRef?: Ref<T | BasicColorSchema>;
/**
* Key to persist the data into localStorage/sessionStorage.
*
* Pass `null` to disable persistence
*
* @default 'vueuse-color-scheme'
*/
storageKey?: string | null;
/**
* Storage object, can be localStorage or sessionStorage
*
* @default localStorage
*/
storage?: StorageLike;
/**
* Emit `auto` mode from state
*
* When set to `true`, preferred mode won't be translated into `light` or `dark`.
* This is useful when the fact that `auto` mode was selected needs to be known.
*
* @default undefined
* @deprecated use `store.value` when `auto` mode needs to be known
* @see https://vueuse.org/core/useColorMode/#advanced-usage
*/
emitAuto?: boolean;
/**
* Disable transition on switch
*
* @see https://paco.me/writing/disable-theme-transitions
* @default true
*/
disableTransition?: boolean;
}
type UseColorModeReturn<T extends string = BasicColorMode> = Ref<T | BasicColorSchema> & {
store: Ref<T | BasicColorSchema>;
system: ComputedRef<BasicColorMode>;
state: ComputedRef<T | BasicColorMode>;
};
/**
* Reactive color mode with auto data persistence.
*
* @see https://vueuse.org/useColorMode
* @param options
*/
declare function useColorMode<T extends string = BasicColorMode>(options?: UseColorModeOptions<T>): UseColorModeReturn<T>;
type UseConfirmDialogRevealResult<C, D> = {
data?: C;
isCanceled: false;
} | {
data?: D;
isCanceled: true;
};
interface UseConfirmDialogReturn<RevealData, ConfirmData, CancelData> {
/**
* Revealing state
*/
isRevealed: ComputedRef<boolean>;
/**
* Opens the dialog.
* Create promise and return it. Triggers `onReveal` hook.
*/
reveal: (data?: RevealData) => Promise<UseConfirmDialogRevealResult<ConfirmData, CancelData>>;
/**
* Confirms and closes the dialog. Triggers a callback inside `onConfirm` hook.
* Resolves promise from `reveal()` with `data` and `isCanceled` ref with `false` value.
* Can accept any data and to pass it to `onConfirm` hook.
*/
confirm: (data?: ConfirmData) => void;
/**
* Cancels and closes the dialog. Triggers a callback inside `onCancel` hook.
* Resolves promise from `reveal()` with `data` and `isCanceled` ref with `true` value.
* Can accept any data and to pass it to `onCancel` hook.
*/
cancel: (data?: CancelData) => void;
/**
* Event Hook to be triggered right before dialog creating.
*/
onReveal: EventHookOn<RevealData>;
/**
* Event Hook to be called on `confirm()`.
* Gets data object from `confirm` function.
*/
onConfirm: EventHookOn<ConfirmData>;
/**
* Event Hook to be called on `cancel()`.
* Gets data object from `cancel` function.
*/
onCancel: EventHookOn<CancelData>;
}
/**
* Hooks for creating confirm dialogs. Useful for modal windows, popups and logins.
*
* @see https://vueuse.org/useConfirmDialog/
* @param revealed `boolean` `ref` that handles a modal window
*/
declare function useConfirmDialog<RevealData = any, ConfirmData = any, CancelData = any>(revealed?: Ref<boolean>): UseConfirmDialogReturn<RevealData, ConfirmData, CancelData>;
interface UseCssVarOptions extends ConfigurableWindow {
initialValue?: string;
/**
* Use MutationObserver to monitor variable changes
* @default false
*/
observe?: boolean;
}
/**
* Manipulate CSS variables.
*
* @see https://vueuse.org/useCssVar
* @param prop
* @param target
* @param options
*/
declare function useCssVar(prop: MaybeRefOrGetter<string>, target?: MaybeElementRef, options?: UseCssVarOptions): vue_demi.Ref<string>;
declare function useCurrentElement<T extends MaybeElement = MaybeElement, R extends VueInstance = VueInstance>(rootComponent?: MaybeElementRef<R>): _vueuse_shared.ComputedRefWithControl<T>;
interface UseCycleListOptions<T> {
/**
* The initial value of the state.
* A ref can be provided to reuse.
*/
initialValue?: MaybeRef<T>;
/**
* The default index when
*/
fallbackIndex?: number;
/**
* Custom function to get the index of the current value.
*/
getIndexOf?: (value: T, list: T[]) => number;
}
/**
* Cycle through a list of items
*
* @see https://vueuse.org/useCycleList
*/
declare function useCycleList<T>(list: MaybeRefOrGetter<T[]>, options?: UseCycleListOptions<T>): UseCycleListReturn<T>;
interface UseCycleListReturn<T> {
state: Ref<T>;
index: Ref<number>;
next: (n?: number) => T;
prev: (n?: number) => T;
/**
* Go to a specific index
*/
go: (i: number) => T;
}
interface UseDarkOptions extends Omit<UseColorModeOptions<BasicColorSchema>, 'modes' | 'onChanged'> {
/**
* Value applying to the target element when isDark=true
*
* @default 'dark'
*/
valueDark?: string;
/**
* Value applying to the target element when isDark=false
*
* @default ''
*/
valueLight?: string;
/**
* A custom handler for handle the updates.
* When specified, the default behavior will be overridden.
*
* @default undefined
*/
onChanged?: (isDark: boolean, defaultHandler: ((mode: BasicColorSchema) => void), mode: BasicColorSchema) => void;
}
/**
* Reactive dark mode with auto data persistence.
*
* @see https://vueuse.org/useDark
* @param options
*/
declare function useDark(options?: UseDarkOptions): vue_demi.WritableComputedRef<boolean>;
interface UseRefHistoryRecord<T> {
snapshot: T;
timestamp: number;
}
interface UseManualRefHistoryOptions<Raw, Serialized = Raw> {
/**
* Maximum number of history to be kept. Default to unlimited.
*/
capacity?: number;
/**
* Clone when taking a snapshot, shortcut for dump: JSON.parse(JSON.stringify(value)).
* Default to false
*
* @default false
*/
clone?: boolean | CloneFn<Raw>;
/**
* Serialize data into the history
*/
dump?: (v: Raw) => Serialized;
/**
* Deserialize data from the history
*/
parse?: (v: Serialized) => Raw;
/**
* set data source
*/
setSource?: (source: Ref<Raw>, v: Raw) => void;
}
interface UseManualRefHistoryReturn<Raw, Serialized> {
/**
* Bypassed tracking ref from the argument
*/
source: Ref<Raw>;
/**
* An array of history records for undo, newest comes to first
*/
history: Ref<UseRefHistoryRecord<Serialized>[]>;
/**
* Last history point, source can be different if paused
*/
last: Ref<UseRefHistoryRecord<Serialized>>;
/**
* Same as {@link UseManualRefHistoryReturn.history | history}
*/
undoStack: Ref<UseRefHistoryRecord<Serialized>[]>;
/**
* Records array for redo
*/
redoStack: Ref<UseRefHistoryRecord<Serialized>[]>;
/**
* A ref representing if undo is possible (non empty undoStack)
*/
canUndo: Ref<boolean>;
/**
* A ref representing if redo is possible (non empty redoStack)
*/
canRedo: Ref<boolean>;
/**
* Undo changes
*/
undo: () => void;
/**
* Redo changes
*/
redo: () => void;
/**
* Clear all the history
*/
clear: () => void;
/**
* Create a new history record
*/
commit: () => void;
/**
* Reset ref's value with latest history
*/
reset: () => void;
}
/**
* Track the change history of a ref, also provides undo and redo functionality.
*
* @see https://vueuse.org/useManualRefHistory
* @param source
* @param options
*/
declare function useManualRefHistory<Raw, Serialized = Raw>(source: Ref<Raw>, options?: UseManualRefHistoryOptions<Raw, Serialized>): UseManualRefHistoryReturn<Raw, Serialized>;
interface UseRefHistoryOptions<Raw, Serialized = Raw> extends ConfigurableEventFilter {
/**
* Watch for deep changes, default to false
*
* When set to true, it will also create clones for values store in the history
*
* @default false
*/
deep?: boolean;
/**
* The flush option allows for greater control over the timing of a history point, default to 'pre'
*
* Possible values: 'pre', 'post', 'sync'
* It works in the same way as the flush option in watch and watch effect in vue reactivity
*
* @default 'pre'
*/
flush?: 'pre' | 'post' | 'sync';
/**
* Maximum number of history to be kept. Default to unlimited.
*/
capacity?: number;
/**
* Clone when taking a snapshot, shortcut for dump: JSON.parse(JSON.stringify(value)).
* Default to false
*
* @default false
*/
clone?: boolean | CloneFn<Raw>;
/**
* Serialize data into the history
*/
dump?: (v: Raw) => Serialized;
/**
* Deserialize data from the history
*/
parse?: (v: Serialized) => Raw;
}
interface UseRefHistoryReturn<Raw, Serialized> extends UseManualRefHistoryReturn<Raw, Serialized> {
/**
* A ref representing if the tracking is enabled
*/
isTracking: Ref<boolean>;
/**
* Pause change tracking
*/
pause: () => void;
/**
* Resume change tracking
*
* @param [commit] if true, a history record will be create after resuming
*/
resume: (commit?: boolean) => void;
/**
* A sugar for auto pause and auto resuming within a function scope
*
* @param fn
*/
batch: (fn: (cancel: Fn) => void) => void;
/**
* Clear the data and stop the watch
*/
dispose: () => void;
}
/**
* Track the change history of a ref, also provides undo and redo functionality.
*
* @see https://vueuse.org/useRefHistory
* @param source
* @param options
*/
declare function useRefHistory<Raw, Serialized = Raw>(source: Ref<Raw>, options?: UseRefHistoryOptions<Raw, Serialized>): UseRefHistoryReturn<Raw, Serialized>;
/**
* Shorthand for [useRefHistory](https://vueuse.org/useRefHistory) with debounce filter.
*
* @see https://vueuse.org/useDebouncedRefHistory
* @param source
* @param options
*/
declare function useDebouncedRefHistory<Raw, Serialized = Raw>(source: Ref<Raw>, options?: Omit<UseRefHistoryOptions<Raw, Serialized>, 'eventFilter'> & {
debounce?: MaybeRefOrGetter<number>;
}): UseRefHistoryReturn<Raw, Serialized>;
interface DeviceMotionOptions extends ConfigurableWindow, ConfigurableEventFilter {
}
/**
* Reactive DeviceMotionEvent.
*
* @see https://vueuse.org/useDeviceMotion
* @param options
*/
declare function useDeviceMotion(options?: DeviceMotionOptions): {
acceleration: Ref<DeviceMotionEventAcceleration | null>;
accelerationIncludingGravity: Ref<DeviceMotionEventAcceleration | null>;
rotationRate: Ref<DeviceMotionEventRotationRate | null>;
interval: Ref<number>;
};
type UseDeviceMotionReturn = ReturnType<typeof useDeviceMotion>;
/**
* Reactive DeviceOrientationEvent.
*
* @see https://vueuse.org/useDeviceOrientation
* @param options
*/
declare function useDeviceOrientation(options?: ConfigurableWindow): {
isSupported: vue_demi.ComputedRef<boolean>;
isAbsolute: Ref<boolean>;
alpha: Ref<number | null>;
beta: Ref<number | null>;
gamma: Ref<number | null>;
};
type UseDeviceOrientationReturn = ReturnType<typeof useDeviceOrientation>;
/**
* Reactively track `window.devicePixelRatio`.
*
* @see https://vueuse.org/useDevicePixelRatio
*/
declare function useDevicePixelRatio(options?: ConfigurableWindow): {
pixelRatio: vue_demi.Ref<number>;
};
type UseDevicePixelRatioReturn = ReturnType<typeof useDevicePixelRatio>;
interface UseDevicesListOptions extends ConfigurableNavigator {
onUpdated?: (devices: MediaDeviceInfo[]) => void;
/**
* Request for permissions immediately if it's not granted,
* otherwise label and deviceIds could be empty
*
* @default false
*/
requestPermissions?: boolean;
/**
* Request for types of media permissions
*
* @default { audio: true, video: true }
*/
constraints?: MediaStreamConstraints;
}
interface UseDevicesListReturn {
/**
* All devices
*/
devices: Ref<MediaDeviceInfo[]>;
videoInputs: ComputedRef<MediaDeviceInfo[]>;
audioInputs: ComputedRef<MediaDeviceInfo[]>;
audioOutputs: ComputedRef<MediaDeviceInfo[]>;
permissionGranted: Ref<boolean>;
ensurePermissions: () => Promise<boolean>;
isSupported: Ref<boolean>;
}
/**
* Reactive `enumerateDevices` listing available input/output devices
*
* @see https://vueuse.org/useDevicesList
* @param options
*/
declare function useDevicesList(options?: UseDevicesListOptions): UseDevicesListReturn;
interface UseDisplayMediaOptions extends ConfigurableNavigator {
/**
* If the stream is enabled
* @default false
*/
enabled?: MaybeRef<boolean>;
/**
* If the stream video media constraints
*/
video?: boolean | MediaTrackConstraints | undefined;
/**
* If the stream audio media constraints
*/
audio?: boolean | MediaTrackConstraints | undefined;
}
/**
* Reactive `mediaDevices.getDisplayMedia` streaming
*
* @see https://vueuse.org/useDisplayMedia
* @param options
*/
declare function useDisplayMedia(options?: UseDisplayMediaOptions): {
isSupported: vue_demi.ComputedRef<boolean>;
stream: Ref<MediaStream | undefined>;
start: () => Promise<MediaStream | undefined>;
stop: () => void;
enabled: Ref<boolean>;
};
type UseDisplayMediaReturn = ReturnType<typeof useDisplayMedia>;
/**
* Reactively track `document.visibilityState`.
*
* @see https://vueuse.org/useDocumentVisibility
*/
declare function useDocumentVisibility(options?: ConfigurableDocument): Ref<DocumentVisibilityState>;
interface Position {
x: number;
y: number;
}
interface RenderableComponent {
/**
* The element that the component should be rendered as
*
* @default 'div'
*/
as?: Object | string;
}
type PointerType = 'mouse' | 'touch' | 'pen';
interface UseDraggableOptions {
/**
* Only start the dragging when click on the element directly
*
* @default false
*/
exact?: MaybeRefOrGetter<boolean>;
/**
* Prevent events defaults
*
* @default false
*/
preventDefault?: MaybeRefOrGetter<boolean>;
/**
* Prevent events propagation
*
* @default false
*/
stopPropagation?: MaybeRefOrGetter<boolean>;
/**
* Whether dispatch events in capturing phase
*
* @default true
*/
capture?: boolean;
/**
* Element to attach `pointermo