@mantine-vue/hooks 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.cjs +4696 -0
- package/cjs/index.cjs.map +1 -0
- package/esm/index.mjs +4579 -0
- package/esm/index.mjs.map +1 -0
- package/lib/index.d.mts +141 -0
- package/lib/index.d.ts +141 -0
- package/lib/use-click-outside/use-click-outside.d.ts +4 -0
- package/lib/use-clipboard/use-clipboard.d.ts +11 -0
- package/lib/use-collapse/use-collapse.d.ts +38 -0
- package/lib/use-collapse/use-horizontal-collapse.d.ts +4 -0
- package/lib/use-color-scheme/use-color-scheme.d.ts +4 -0
- package/lib/use-counter/use-counter.d.ts +14 -0
- package/lib/use-debounced-callback/use-debounced-callback.d.ts +12 -0
- package/lib/use-debounced-state/use-debounced-state.d.ts +6 -0
- package/lib/use-debounced-value/use-debounced-value.d.ts +14 -0
- package/lib/use-did-update/use-did-update.d.ts +2 -0
- package/lib/use-disclosure/use-disclosure.d.ts +13 -0
- package/lib/use-document-title/use-document-title.d.ts +2 -0
- package/lib/use-document-visibility/use-document-visibility.d.ts +2 -0
- package/lib/use-drag/use-drag.d.ts +56 -0
- package/lib/use-event-listener/use-event-listener.d.ts +2 -0
- package/lib/use-eye-dropper/use-eye-dropper.d.ts +12 -0
- package/lib/use-favicon/use-favicon.d.ts +2 -0
- package/lib/use-fetch/use-fetch.d.ts +12 -0
- package/lib/use-file-dialog/use-file-dialog.d.ts +25 -0
- package/lib/use-floating-window/use-floating-window.d.ts +30 -0
- package/lib/use-focus-return/use-focus-return.d.ts +6 -0
- package/lib/use-focus-trap/scope-tab.d.ts +1 -0
- package/lib/use-focus-trap/tabbable.d.ts +4 -0
- package/lib/use-focus-trap/use-focus-trap.d.ts +5 -0
- package/lib/use-focus-within/use-focus-within.d.ts +10 -0
- package/lib/use-force-update/use-force-update.d.ts +2 -0
- package/lib/use-fullscreen/use-fullscreen.d.ts +12 -0
- package/lib/use-hash/use-hash.d.ts +6 -0
- package/lib/use-headroom/use-headroom.d.ts +27 -0
- package/lib/use-hotkeys/parse-hotkey.d.ts +20 -0
- package/lib/use-hotkeys/use-hotkeys.d.ts +15 -0
- package/lib/use-hover/use-hover.d.ts +6 -0
- package/lib/use-id/use-id.d.ts +2 -0
- package/lib/use-idle/use-idle.d.ts +6 -0
- package/lib/use-in-viewport/use-in-viewport.d.ts +6 -0
- package/lib/use-input-state/use-input-state.d.ts +6 -0
- package/lib/use-intersection/use-intersection.d.ts +6 -0
- package/lib/use-interval/use-interval.d.ts +16 -0
- package/lib/use-is-first-render/use-is-first-render.d.ts +2 -0
- package/lib/use-isomorphic-effect/use-isomorphic-effect.d.ts +1 -0
- package/lib/use-list-state/use-list-state.d.ts +25 -0
- package/lib/use-local-storage/create-storage.d.ts +23 -0
- package/lib/use-local-storage/use-local-storage.d.ts +3 -0
- package/lib/use-logger/use-logger.d.ts +2 -0
- package/lib/use-long-press/use-long-press.d.ts +20 -0
- package/lib/use-map/use-map.d.ts +1 -0
- package/lib/use-mask/use-mask.d.ts +57 -0
- package/lib/use-media-query/use-media-query.d.ts +5 -0
- package/lib/use-merged-ref/use-merged-ref.d.ts +6 -0
- package/lib/use-mounted/use-mounted.d.ts +2 -0
- package/lib/use-mouse/use-mouse.d.ts +15 -0
- package/lib/use-move/use-move.d.ts +17 -0
- package/lib/use-mutation-observer/use-mutation-observer.d.ts +3 -0
- package/lib/use-network/use-network.d.ts +11 -0
- package/lib/use-orientation/use-orientation.d.ts +23 -0
- package/lib/use-os/use-os.d.ts +6 -0
- package/lib/use-page-leave/use-page-leave.d.ts +2 -0
- package/lib/use-pagination/use-pagination.d.ts +20 -0
- package/lib/use-previous/use-previous.d.ts +2 -0
- package/lib/use-queue/use-queue.d.ts +20 -0
- package/lib/use-radial-move/use-radial-move.d.ts +13 -0
- package/lib/use-reduced-motion/use-reduced-motion.d.ts +3 -0
- package/lib/use-resize-observer/use-resize-observer.d.ts +13 -0
- package/lib/use-roving-index/use-roving-index.d.ts +45 -0
- package/lib/use-scroll-direction/use-scroll-direction.d.ts +3 -0
- package/lib/use-scroll-into-view/use-scroll-into-view.d.ts +32 -0
- package/lib/use-scroll-spy/use-scroll-spy.d.ts +30 -0
- package/lib/use-scroller/use-scroller.d.ts +25 -0
- package/lib/use-selection/use-selection.d.ts +27 -0
- package/lib/use-session-storage/use-session-storage.d.ts +3 -0
- package/lib/use-set/use-set.d.ts +9 -0
- package/lib/use-set-state/use-set-state.d.ts +4 -0
- package/lib/use-shallow-effect/use-shallow-effect.d.ts +2 -0
- package/lib/use-splitter/use-splitter.d.ts +94 -0
- package/lib/use-state-history/use-state-history.d.ts +17 -0
- package/lib/use-text-selection/use-text-selection.d.ts +2 -0
- package/lib/use-throttled-callback/use-throttled-callback.d.ts +2 -0
- package/lib/use-throttled-state/use-throttled-state.d.ts +3 -0
- package/lib/use-throttled-value/use-throttled-value.d.ts +2 -0
- package/lib/use-timeout/use-timeout.d.ts +8 -0
- package/lib/use-toggle/use-toggle.d.ts +4 -0
- package/lib/use-uncontrolled/use-uncontrolled.d.ts +13 -0
- package/lib/use-validated-state/use-validated-state.d.ts +16 -0
- package/lib/use-viewport-size/use-viewport-size.d.ts +6 -0
- package/lib/use-window-event/use-window-event.d.ts +2 -0
- package/lib/use-window-scroll/use-window-scroll.d.ts +8 -0
- package/lib/utils/clamp/clamp.d.ts +1 -0
- package/lib/utils/index.d.ts +7 -0
- package/lib/utils/lower-first/lower-first.d.ts +1 -0
- package/lib/utils/random-id/random-id.d.ts +1 -0
- package/lib/utils/range/range.d.ts +1 -0
- package/lib/utils/shallow-equal/shallow-equal.d.ts +1 -0
- package/lib/utils/upper-first/upper-first.d.ts +1 -0
- package/lib/utils/use-callback-ref/use-callback-ref.d.ts +2 -0
- package/package.json +37 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UseFocusWithinOptions {
|
|
3
|
+
onFocus?: (event: FocusEvent) => void;
|
|
4
|
+
onBlur?: (event: FocusEvent) => void;
|
|
5
|
+
}
|
|
6
|
+
export interface UseFocusWithinReturnValue<T extends HTMLElement = HTMLElement> {
|
|
7
|
+
ref: Ref<T | null>;
|
|
8
|
+
focused: Ref<boolean>;
|
|
9
|
+
}
|
|
10
|
+
export declare function useFocusWithin<T extends HTMLElement = HTMLElement>(options?: UseFocusWithinOptions): UseFocusWithinReturnValue<T>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UseFullscreenElementReturnValue<T extends HTMLElement = HTMLElement> {
|
|
3
|
+
ref: Ref<T | null>;
|
|
4
|
+
toggle: () => Promise<void>;
|
|
5
|
+
fullscreen: Ref<boolean>;
|
|
6
|
+
}
|
|
7
|
+
export declare function useFullscreenElement<T extends HTMLElement = HTMLElement>(): UseFullscreenElementReturnValue<T>;
|
|
8
|
+
export interface UseFullscreenDocumentReturnValue {
|
|
9
|
+
toggle: () => Promise<void>;
|
|
10
|
+
fullscreen: Ref<boolean>;
|
|
11
|
+
}
|
|
12
|
+
export declare function useFullscreenDocument(): UseFullscreenDocumentReturnValue;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export { useScrollDirection } from '../use-scroll-direction/use-scroll-direction';
|
|
3
|
+
export declare const isFixed: (current: number, fixedAt: number) => boolean;
|
|
4
|
+
export declare const isPinned: (current: number, previous: number) => boolean;
|
|
5
|
+
export declare const isReleased: (current: number, previous: number, fixedAt: number) => boolean;
|
|
6
|
+
export declare const isPinnedOrReleased: (current: number, fixedAt: number, isCurrentlyPinnedRef: {
|
|
7
|
+
value: boolean;
|
|
8
|
+
}, isScrollingUp: boolean, onPin?: () => void, onRelease?: () => void) => void;
|
|
9
|
+
export interface UseHeadroomInput {
|
|
10
|
+
/** Number in px at which element should be fixed */
|
|
11
|
+
fixedAt?: number;
|
|
12
|
+
/** Number of px to scroll to fully reveal or hide the element, 100 by default */
|
|
13
|
+
scrollDistance?: number;
|
|
14
|
+
/** Called when element is pinned */
|
|
15
|
+
onPin?: () => void;
|
|
16
|
+
/** Called when element is at fixed position */
|
|
17
|
+
onFix?: () => void;
|
|
18
|
+
/** Called when element is unpinned */
|
|
19
|
+
onRelease?: () => void;
|
|
20
|
+
}
|
|
21
|
+
export interface UseHeadroomReturnValue {
|
|
22
|
+
/** True when the element is at least partially visible */
|
|
23
|
+
pinned: Ref<boolean>;
|
|
24
|
+
/** Reveal progress: 0 = fully hidden, 1 = fully visible */
|
|
25
|
+
scrollProgress: Ref<number>;
|
|
26
|
+
}
|
|
27
|
+
export declare function useHeadroom({ fixedAt, scrollDistance, onPin, onFix, onRelease, }?: UseHeadroomInput): UseHeadroomReturnValue;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface KeyboardModifiers {
|
|
2
|
+
alt: boolean;
|
|
3
|
+
ctrl: boolean;
|
|
4
|
+
meta: boolean;
|
|
5
|
+
mod: boolean;
|
|
6
|
+
shift: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface Hotkey extends KeyboardModifiers {
|
|
9
|
+
key?: string;
|
|
10
|
+
}
|
|
11
|
+
type CheckHotkeyMatch = (event: KeyboardEvent) => boolean;
|
|
12
|
+
export declare function parseHotkey(hotkey: string): Hotkey;
|
|
13
|
+
export declare function getHotkeyMatcher(hotkey: string, usePhysicalKeys?: boolean): CheckHotkeyMatch;
|
|
14
|
+
export interface HotkeyItemOptions {
|
|
15
|
+
preventDefault?: boolean;
|
|
16
|
+
usePhysicalKeys?: boolean;
|
|
17
|
+
}
|
|
18
|
+
type HotkeyItemTuple = [string, (event: any) => void, HotkeyItemOptions?];
|
|
19
|
+
export declare function getHotkeyHandler(hotkeys: HotkeyItemTuple[]): (event: KeyboardEvent) => void;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { getHotkeyHandler, type HotkeyItemOptions } from './parse-hotkey';
|
|
3
|
+
export type { HotkeyItemOptions };
|
|
4
|
+
export { getHotkeyHandler };
|
|
5
|
+
export type HotkeyItem = [string, (event: KeyboardEvent) => void, HotkeyItemOptions?];
|
|
6
|
+
/**
|
|
7
|
+
* Listens for global keydown events and invokes matching handlers.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: the listener is attached to `window` rather than
|
|
10
|
+
* `document.documentElement` (which is what React Mantine uses). Real
|
|
11
|
+
* keyboard events always bubble to `window`, so this is behaviorally
|
|
12
|
+
* equivalent for actual usage while remaining consistent with how the rest
|
|
13
|
+
* of this package (and its test suite) dispatches synthetic events.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useHotkeys(hotkeys: MaybeRefOrGetter<HotkeyItem[]>, tagsToIgnore?: MaybeRefOrGetter<string[] | undefined>, triggerOnContentEditable?: MaybeRefOrGetter<boolean | undefined>): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UseInViewportReturnValue<T extends HTMLElement = HTMLElement> {
|
|
3
|
+
inViewport: Ref<boolean>;
|
|
4
|
+
ref: Ref<T | null>;
|
|
5
|
+
}
|
|
6
|
+
export declare function useInViewport<T extends HTMLElement = HTMLElement>(): UseInViewportReturnValue<T>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UseIntersectionReturnValue<T extends HTMLElement = HTMLElement> {
|
|
3
|
+
ref: Ref<T | null>;
|
|
4
|
+
entry: Ref<IntersectionObserverEntry | null>;
|
|
5
|
+
}
|
|
6
|
+
export declare function useIntersection<T extends HTMLElement = HTMLElement>(options?: IntersectionObserverInit): UseIntersectionReturnValue<T>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter, type Ref } from 'vue';
|
|
2
|
+
export interface UseIntervalOptions {
|
|
3
|
+
/** If set, the interval will start automatically when the component is mounted, `false` by default */
|
|
4
|
+
autoInvoke?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface UseIntervalReturnValue {
|
|
7
|
+
/** Starts the interval */
|
|
8
|
+
start: () => void;
|
|
9
|
+
/** Stops the interval */
|
|
10
|
+
stop: () => void;
|
|
11
|
+
/** Toggles the interval */
|
|
12
|
+
toggle: () => void;
|
|
13
|
+
/** Indicates if the interval is active */
|
|
14
|
+
active: Ref<boolean>;
|
|
15
|
+
}
|
|
16
|
+
export declare function useInterval(fn: () => void, interval: MaybeRefOrGetter<number>, options?: UseIntervalOptions): UseIntervalReturnValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsomorphicEffect(effect: () => void): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UseListStateHandlers<T> {
|
|
3
|
+
setState: (value: T[] | ((current: T[]) => T[])) => void;
|
|
4
|
+
append: (...items: T[]) => void;
|
|
5
|
+
prepend: (...items: T[]) => void;
|
|
6
|
+
insert: (index: number, ...items: T[]) => void;
|
|
7
|
+
pop: () => void;
|
|
8
|
+
shift: () => void;
|
|
9
|
+
apply: (fn: (item: T, index?: number) => T) => void;
|
|
10
|
+
applyWhere: (condition: (item: T, index: number) => boolean, fn: (item: T, index?: number) => T) => void;
|
|
11
|
+
remove: (...indices: number[]) => void;
|
|
12
|
+
reorder: (payload: {
|
|
13
|
+
from: number;
|
|
14
|
+
to: number;
|
|
15
|
+
}) => void;
|
|
16
|
+
swap: (payload: {
|
|
17
|
+
from: number;
|
|
18
|
+
to: number;
|
|
19
|
+
}) => void;
|
|
20
|
+
setItem: (index: number, item: T) => void;
|
|
21
|
+
setItemProp: <K extends keyof T, U extends T[K]>(index: number, prop: K, value: U) => void;
|
|
22
|
+
filter: (fn: (item: T, i: number) => boolean) => void;
|
|
23
|
+
}
|
|
24
|
+
export type UseListStateReturnValue<T> = [Ref<T[]>, UseListStateHandlers<T>];
|
|
25
|
+
export declare function useListState<T>(initialValue?: T[] | (() => T[])): UseListStateReturnValue<T>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export type StorageType = 'localStorage' | 'sessionStorage';
|
|
3
|
+
export interface UseStorageOptions<T> {
|
|
4
|
+
/** Storage key */
|
|
5
|
+
key: string;
|
|
6
|
+
/** Default value that will be set if value is not found in storage */
|
|
7
|
+
defaultValue?: T;
|
|
8
|
+
/** If set to true, the real storage value is read after mount rather than during initialization. Default value is true. */
|
|
9
|
+
getInitialValueInEffect?: boolean;
|
|
10
|
+
/** Determines whether the value must be synced between browser tabs, `true` by default */
|
|
11
|
+
sync?: boolean;
|
|
12
|
+
/** Function to serialize value into string to be saved in storage */
|
|
13
|
+
serialize?: (value: T) => string;
|
|
14
|
+
/** Function to deserialize string value from storage to value */
|
|
15
|
+
deserialize?: (value: string | undefined) => T;
|
|
16
|
+
}
|
|
17
|
+
export type UseStorageReturnValue<T> = [
|
|
18
|
+
Ref<T>,
|
|
19
|
+
(val: T | ((prevState: T) => T)) => void,
|
|
20
|
+
() => void
|
|
21
|
+
];
|
|
22
|
+
export declare function createStorage<T>(type: StorageType, hookName: string): ({ key, defaultValue, getInitialValueInEffect, sync, deserialize, serialize, }: UseStorageOptions<T>) => UseStorageReturnValue<T>;
|
|
23
|
+
export declare function readValue(type: StorageType): <T>({ key, defaultValue, deserialize, }: UseStorageOptions<T>) => T;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type UseLongPressEvent = 'mouse' | 'touch';
|
|
2
|
+
export interface UseLongPressOptions {
|
|
3
|
+
threshold?: number;
|
|
4
|
+
events?: UseLongPressEvent[];
|
|
5
|
+
cancelOnMove?: boolean | number;
|
|
6
|
+
onStart?: (event: MouseEvent | TouchEvent) => void;
|
|
7
|
+
onFinish?: (event: MouseEvent | TouchEvent) => void;
|
|
8
|
+
onCancel?: (event: MouseEvent | TouchEvent) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface UseLongPressReturnValue {
|
|
11
|
+
onMousedown?: (event: MouseEvent) => void;
|
|
12
|
+
onMouseup?: (event: MouseEvent) => void;
|
|
13
|
+
onMouseleave?: (event: MouseEvent) => void;
|
|
14
|
+
onMousemove?: (event: MouseEvent) => void;
|
|
15
|
+
onTouchstart?: (event: TouchEvent) => void;
|
|
16
|
+
onTouchend?: (event: TouchEvent) => void;
|
|
17
|
+
onTouchcancel?: (event: TouchEvent) => void;
|
|
18
|
+
onTouchmove?: (event: TouchEvent) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function useLongPress(onLongPress: (event: MouseEvent | TouchEvent) => void, options?: UseLongPressOptions): UseLongPressReturnValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useMap<T, V>(initialState?: [T, V][]): Map<T, V>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UseMaskOptions {
|
|
3
|
+
/** Mask pattern string or array of string literals and RegExp objects */
|
|
4
|
+
mask: string | Array<string | RegExp>;
|
|
5
|
+
/** Override or extend the default token map */
|
|
6
|
+
tokens?: Record<string, RegExp>;
|
|
7
|
+
/** Called before masking on each keystroke, can return overrides for mask options */
|
|
8
|
+
modify?: (value: string) => Partial<Pick<UseMaskOptions, 'mask' | 'tokens' | 'slotChar' | 'separate'>> | undefined;
|
|
9
|
+
/** When true, raw and display values are decoupled */
|
|
10
|
+
separate?: boolean;
|
|
11
|
+
/** Character displayed in unfilled slots, `"_"` by default */
|
|
12
|
+
slotChar?: string | null;
|
|
13
|
+
/** Show mask pattern even when field is empty and unfocused */
|
|
14
|
+
alwaysShowMask?: boolean;
|
|
15
|
+
/** Show mask placeholder on focus, `true` by default */
|
|
16
|
+
showMaskOnFocus?: boolean;
|
|
17
|
+
/** Transform each character before validation and insertion */
|
|
18
|
+
transform?: (char: string) => string;
|
|
19
|
+
/** Clear value on blur when mask is incomplete, `false` by default */
|
|
20
|
+
autoClear?: boolean;
|
|
21
|
+
/** Sets aria-invalid on the input */
|
|
22
|
+
invalid?: boolean;
|
|
23
|
+
/** Called on every change with raw and masked values */
|
|
24
|
+
onChangeRaw?: (rawValue: string, maskedValue: string) => void;
|
|
25
|
+
/** Called when all required mask slots are filled */
|
|
26
|
+
onComplete?: (maskedValue: string, rawValue: string) => void;
|
|
27
|
+
/** Escape hatch for advanced cursor/value manipulation */
|
|
28
|
+
beforeMaskedStateChange?: (states: {
|
|
29
|
+
previousState: MaskState;
|
|
30
|
+
currentState: MaskState;
|
|
31
|
+
nextState: MaskState;
|
|
32
|
+
}) => MaskState;
|
|
33
|
+
}
|
|
34
|
+
export interface MaskState {
|
|
35
|
+
value: string;
|
|
36
|
+
selection: {
|
|
37
|
+
start: number;
|
|
38
|
+
end: number;
|
|
39
|
+
} | null;
|
|
40
|
+
}
|
|
41
|
+
export interface UseMaskReturnValue {
|
|
42
|
+
/** Ref callback to attach to the input element */
|
|
43
|
+
ref: (node: HTMLInputElement | null) => void;
|
|
44
|
+
/** Current masked display value */
|
|
45
|
+
value: Ref<string>;
|
|
46
|
+
/** Current raw unmasked value */
|
|
47
|
+
rawValue: Ref<string>;
|
|
48
|
+
/** Whether all required mask slots are filled */
|
|
49
|
+
isComplete: Ref<boolean>;
|
|
50
|
+
/** Clear the input value and reset state */
|
|
51
|
+
reset: () => void;
|
|
52
|
+
}
|
|
53
|
+
export declare function formatMask(raw: string, options: UseMaskOptions): string;
|
|
54
|
+
export declare function unformatMask(masked: string, options: UseMaskOptions): string;
|
|
55
|
+
export declare function isMaskComplete(masked: string, options: UseMaskOptions): boolean;
|
|
56
|
+
export declare function generatePattern(mode: 'full' | 'full-inexact', options: UseMaskOptions): string;
|
|
57
|
+
export declare function useMask(options: UseMaskOptions): UseMaskReturnValue;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter, type Ref } from 'vue';
|
|
2
|
+
export interface UseMediaQueryOptions {
|
|
3
|
+
getInitialValueInEffect?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useMediaQuery(query: MaybeRefOrGetter<string>, initialValue?: boolean, options?: UseMediaQueryOptions): Readonly<Ref<boolean>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type VueRefTarget<T> = {
|
|
2
|
+
value: T | null;
|
|
3
|
+
} | ((value: T | null) => void) | undefined;
|
|
4
|
+
export declare function assignRef<T>(refTarget: VueRefTarget<T>, value: T | null): void;
|
|
5
|
+
export declare function mergeRefs<T>(...refs: VueRefTarget<T>[]): (value: T | null) => void;
|
|
6
|
+
export declare function useMergedRef<T>(...refs: VueRefTarget<T>[]): (value: T | null) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UseMouseOptions {
|
|
3
|
+
resetOnExit?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface UseMouseReturnValue<T extends HTMLElement = HTMLElement> {
|
|
6
|
+
ref: Ref<T | null>;
|
|
7
|
+
x: Ref<number>;
|
|
8
|
+
y: Ref<number>;
|
|
9
|
+
}
|
|
10
|
+
export declare function useMouse<T extends HTMLElement = HTMLElement>(options?: UseMouseOptions): UseMouseReturnValue<T>;
|
|
11
|
+
export interface UseMousePositionReturnValue {
|
|
12
|
+
x: Ref<number>;
|
|
13
|
+
y: Ref<number>;
|
|
14
|
+
}
|
|
15
|
+
export declare function useMousePosition(): UseMousePositionReturnValue;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ComponentPublicInstance } from 'vue';
|
|
2
|
+
export interface UseMovePosition {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
export interface UseMoveHandlers {
|
|
7
|
+
onScrubStart?: () => void;
|
|
8
|
+
onScrubEnd?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function clampUseMovePosition(position: UseMovePosition): {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function useMove<T extends HTMLElement = HTMLElement>(onChange: (position: UseMovePosition) => void, handlers?: UseMoveHandlers, dir?: 'ltr' | 'rtl'): {
|
|
15
|
+
ref: (node: Element | ComponentPublicInstance | null) => void;
|
|
16
|
+
active: Readonly<import("vue").Ref<boolean, boolean>>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter, type Ref } from 'vue';
|
|
2
|
+
export declare function useMutationObserver<T extends HTMLElement = HTMLElement>(callback: MutationCallback, options: MutationObserverInit): Ref<T | null>;
|
|
3
|
+
export declare function useMutationObserverTarget(callback: MutationCallback, options: MutationObserverInit, target?: MaybeRefOrGetter<HTMLElement | null | undefined>): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UserNetworkReturnValue {
|
|
3
|
+
online: boolean;
|
|
4
|
+
downlink?: number;
|
|
5
|
+
downlinkMax?: number;
|
|
6
|
+
effectiveType?: 'slow-2g' | '2g' | '3g' | '4g';
|
|
7
|
+
rtt?: number;
|
|
8
|
+
saveData?: boolean;
|
|
9
|
+
type?: 'bluetooth' | 'cellular' | 'ethernet' | 'wifi' | 'wimax' | 'none' | 'other' | 'unknown';
|
|
10
|
+
}
|
|
11
|
+
export declare function useNetwork(): Ref<UserNetworkReturnValue>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UseOrientationOptions {
|
|
3
|
+
/** Default angle value, used until the real can be retrieved
|
|
4
|
+
* (during server side rendering and before js executes on the page)
|
|
5
|
+
* If not provided, the default value is `0`
|
|
6
|
+
* */
|
|
7
|
+
defaultAngle?: number;
|
|
8
|
+
/** Default angle value, used until the real can be retrieved
|
|
9
|
+
* (during server side rendering and before js executes on the page)
|
|
10
|
+
* If not provided, the default value is `'landscape-primary'`
|
|
11
|
+
* */
|
|
12
|
+
defaultType?: OrientationType;
|
|
13
|
+
/** If true, the initial value will be resolved after mount (ssr safe)
|
|
14
|
+
* If false, the initial value will be resolved synchronously (ssr unsafe)
|
|
15
|
+
* True by default.
|
|
16
|
+
*/
|
|
17
|
+
getInitialValueInEffect?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface UseOrientationReturnType {
|
|
20
|
+
angle: number;
|
|
21
|
+
type: OrientationType;
|
|
22
|
+
}
|
|
23
|
+
export declare function useOrientation(options?: UseOrientationOptions): Ref<UseOrientationReturnType>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export type UseOSReturnValue = 'undetermined' | 'macos' | 'ios' | 'windows' | 'android' | 'linux' | 'chromeos';
|
|
3
|
+
export interface UseOsOptions {
|
|
4
|
+
getValueInEffect: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function useOs(options?: UseOsOptions): Readonly<Ref<UseOSReturnValue>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter } from 'vue';
|
|
2
|
+
export declare const DOTS: "dots";
|
|
3
|
+
export interface UsePaginationOptions {
|
|
4
|
+
total: number;
|
|
5
|
+
siblings?: number;
|
|
6
|
+
boundaries?: number;
|
|
7
|
+
page?: MaybeRefOrGetter<number | undefined>;
|
|
8
|
+
initialPage?: number;
|
|
9
|
+
onChange?: (page: number) => void;
|
|
10
|
+
startValue?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function usePagination({ total, siblings, boundaries, page, initialPage, onChange, startValue, }: UsePaginationOptions): {
|
|
13
|
+
range: import("vue").ComputedRef<(number | "dots")[]>;
|
|
14
|
+
active: import("vue").Ref<number, number>;
|
|
15
|
+
setPage: (pageNumber: number) => void;
|
|
16
|
+
next: () => void;
|
|
17
|
+
previous: () => void;
|
|
18
|
+
first: () => void;
|
|
19
|
+
last: () => void;
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UseQueueOptions<T> {
|
|
3
|
+
/** Initial values to be added to the queue */
|
|
4
|
+
initialValues?: T[];
|
|
5
|
+
/** Maximum number of items in the state */
|
|
6
|
+
limit: number;
|
|
7
|
+
}
|
|
8
|
+
export interface UseQueueReturnValue<T> {
|
|
9
|
+
/** Array of items in the queue */
|
|
10
|
+
queue: Readonly<Ref<T[]>>;
|
|
11
|
+
/** Array of items in the state */
|
|
12
|
+
state: Readonly<Ref<T[]>>;
|
|
13
|
+
/** Function to add items to state or queue */
|
|
14
|
+
add: (...items: T[]) => void;
|
|
15
|
+
/** Function to apply updates to current items */
|
|
16
|
+
update: (fn: (state: T[]) => T[]) => void;
|
|
17
|
+
/** Function to clear the queue */
|
|
18
|
+
cleanQueue: () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function useQueue<T>({ initialValues, limit, }: UseQueueOptions<T>): UseQueueReturnValue<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export declare function normalizeRadialValue(degree: number, step: number): number;
|
|
3
|
+
export interface UseRadialMoveOptions {
|
|
4
|
+
step?: number;
|
|
5
|
+
onChangeEnd?: (value: number) => void;
|
|
6
|
+
onScrubStart?: () => void;
|
|
7
|
+
onScrubEnd?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface UseRadialMoveReturnValue<T extends HTMLElement = HTMLElement> {
|
|
10
|
+
ref: (node: T | null) => void;
|
|
11
|
+
active: Ref<boolean>;
|
|
12
|
+
}
|
|
13
|
+
export declare function useRadialMove<T extends HTMLElement = HTMLElement>(onChange: (value: number) => void, { step, onChangeEnd, onScrubStart, onScrubEnd }?: UseRadialMoveOptions): UseRadialMoveReturnValue<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export type ObserverRect = Omit<DOMRectReadOnly, 'toJSON'>;
|
|
3
|
+
export interface UseResizeObserverReturnValue<T extends Element = HTMLElement> {
|
|
4
|
+
ref: Ref<T | null>;
|
|
5
|
+
rect: Ref<ObserverRect>;
|
|
6
|
+
}
|
|
7
|
+
export declare function useResizeObserver<T extends Element = HTMLElement>(options?: ResizeObserverOptions): UseResizeObserverReturnValue<T>;
|
|
8
|
+
export interface UseElementSizeReturnValue<T extends Element = HTMLElement> {
|
|
9
|
+
ref: Ref<T | null>;
|
|
10
|
+
width: Ref<number>;
|
|
11
|
+
height: Ref<number>;
|
|
12
|
+
}
|
|
13
|
+
export declare function useElementSize<T extends Element = HTMLElement>(options?: ResizeObserverOptions): UseElementSizeReturnValue<T>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ComponentPublicInstance, type MaybeRefOrGetter, type Ref } from 'vue';
|
|
2
|
+
export interface UseRovingIndexInput {
|
|
3
|
+
/** Total number of items in the group */
|
|
4
|
+
total: MaybeRefOrGetter<number>;
|
|
5
|
+
/** Which arrow keys navigate, `'horizontal'` by default */
|
|
6
|
+
orientation?: 'horizontal' | 'vertical' | 'both';
|
|
7
|
+
/** Whether navigation wraps at boundaries, `true` by default */
|
|
8
|
+
loop?: boolean;
|
|
9
|
+
/** Text direction, `'ltr'` by default */
|
|
10
|
+
dir?: 'rtl' | 'ltr';
|
|
11
|
+
/** Whether to click element when it receives focus via keyboard, `false` by default */
|
|
12
|
+
activateOnFocus?: boolean;
|
|
13
|
+
/** Number of columns for grid (2D) navigation. When set, enables grid mode */
|
|
14
|
+
columns?: MaybeRefOrGetter<number | undefined>;
|
|
15
|
+
/** Controlled focused index */
|
|
16
|
+
focusedIndex?: MaybeRefOrGetter<number | undefined>;
|
|
17
|
+
/** Initial focused index for uncontrolled mode, first non-disabled item by default */
|
|
18
|
+
initialIndex?: number;
|
|
19
|
+
/** Called when focused index changes */
|
|
20
|
+
onFocusChange?: (index: number) => void;
|
|
21
|
+
/** Function to check if item at given index is disabled, `() => false` by default */
|
|
22
|
+
isItemDisabled?: (index: number) => boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface UseRovingIndexGetItemPropsInput {
|
|
25
|
+
/** Index of the item in the group */
|
|
26
|
+
index: number;
|
|
27
|
+
/** Called when item is clicked */
|
|
28
|
+
onClick?: (event: MouseEvent) => void;
|
|
29
|
+
/** Called when keydown event fires on item */
|
|
30
|
+
onKeyDown?: (event: KeyboardEvent) => void;
|
|
31
|
+
}
|
|
32
|
+
export interface UseRovingIndexReturnValue {
|
|
33
|
+
/** Get props to spread on each navigable item */
|
|
34
|
+
getItemProps: (options: UseRovingIndexGetItemPropsInput) => {
|
|
35
|
+
tabIndex: 0 | -1;
|
|
36
|
+
onKeyDown: (event: KeyboardEvent) => void;
|
|
37
|
+
onClick: (event: MouseEvent) => void;
|
|
38
|
+
ref: (node: Element | ComponentPublicInstance | null) => void;
|
|
39
|
+
};
|
|
40
|
+
/** Currently focused index */
|
|
41
|
+
focusedIndex: Ref<number>;
|
|
42
|
+
/** Programmatically set focused index */
|
|
43
|
+
setFocusedIndex: (index: number) => void;
|
|
44
|
+
}
|
|
45
|
+
export declare function useRovingIndex(input: UseRovingIndexInput): UseRovingIndexReturnValue;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
interface UseScrollIntoViewAnimation {
|
|
3
|
+
/** Target element alignment relatively to parent based on current axis */
|
|
4
|
+
alignment?: 'start' | 'end' | 'center';
|
|
5
|
+
}
|
|
6
|
+
export interface UseScrollIntoViewOptions {
|
|
7
|
+
/** Callback fired after scroll */
|
|
8
|
+
onScrollFinish?: () => void;
|
|
9
|
+
/** Callback fired when scroll animation is canceled by user interaction */
|
|
10
|
+
onScrollCancel?: () => void;
|
|
11
|
+
/** Duration of scroll in milliseconds */
|
|
12
|
+
duration?: number;
|
|
13
|
+
/** Axis of scroll */
|
|
14
|
+
axis?: 'x' | 'y';
|
|
15
|
+
/** Custom mathematical easing function */
|
|
16
|
+
easing?: (t: number) => number;
|
|
17
|
+
/** Additional distance between nearest edge and element */
|
|
18
|
+
offset?: number;
|
|
19
|
+
/** Indicator if animation may be interrupted by user scrolling */
|
|
20
|
+
cancelable?: boolean;
|
|
21
|
+
/** Prevents content jumping in scrolling lists with multiple targets */
|
|
22
|
+
isList?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface UseScrollIntoViewReturnValue<Target extends HTMLElement = HTMLElement, Parent extends HTMLElement | null = null> {
|
|
25
|
+
scrollableRef: Ref<Parent | null>;
|
|
26
|
+
targetRef: Ref<Target | null>;
|
|
27
|
+
scrollIntoView: (params?: UseScrollIntoViewAnimation) => void;
|
|
28
|
+
cancel: () => void;
|
|
29
|
+
scrolling: Ref<boolean>;
|
|
30
|
+
}
|
|
31
|
+
export declare function useScrollIntoView<Target extends HTMLElement = HTMLElement, Parent extends HTMLElement | null = null>(options?: UseScrollIntoViewOptions): UseScrollIntoViewReturnValue<Target, Parent>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter } from 'vue';
|
|
2
|
+
export interface UseScrollSpyHeadingData {
|
|
3
|
+
depth: number;
|
|
4
|
+
value: string;
|
|
5
|
+
id: string;
|
|
6
|
+
getNode: () => HTMLElement;
|
|
7
|
+
}
|
|
8
|
+
export interface UseScrollSpyOptions {
|
|
9
|
+
selector?: MaybeRefOrGetter<string>;
|
|
10
|
+
getDepth?: (element: HTMLElement) => number;
|
|
11
|
+
getValue?: (element: HTMLElement) => string;
|
|
12
|
+
scrollHost?: MaybeRefOrGetter<HTMLElement | undefined>;
|
|
13
|
+
offset?: MaybeRefOrGetter<number>;
|
|
14
|
+
}
|
|
15
|
+
export declare function useScrollSpy(options?: UseScrollSpyOptions): {
|
|
16
|
+
active: Readonly<import("vue").Ref<number, number>>;
|
|
17
|
+
initialized: Readonly<import("vue").Ref<boolean, boolean>>;
|
|
18
|
+
data: Readonly<import("vue").Ref<readonly {
|
|
19
|
+
readonly depth: number;
|
|
20
|
+
readonly value: string;
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly getNode: () => HTMLElement;
|
|
23
|
+
}[], readonly {
|
|
24
|
+
readonly depth: number;
|
|
25
|
+
readonly value: string;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly getNode: () => HTMLElement;
|
|
28
|
+
}[]>>;
|
|
29
|
+
reinitialize: () => void;
|
|
30
|
+
};
|