1 | import React, { ForwardedRef, HTMLAttributes, MutableRefObject, EffectCallback, RefObject, Dispatch } from "react";
|
2 | import { AriaLabelingProps, DOMProps, FocusableElement, Orientation } from "@react-types/shared";
|
3 | export const useLayoutEffect: typeof React.useLayoutEffect;
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export function useId(defaultId?: string): string;
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export function mergeIds(idA: string, idB: string): string;
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | export function useSlotId(depArray?: ReadonlyArray<any>): string;
|
20 |
|
21 |
|
22 |
|
23 | export function chain(...callbacks: any[]): (...args: any[]) => void;
|
24 | interface Props {
|
25 | [key: string]: any;
|
26 | }
|
27 | type TupleTypes<T> = {
|
28 | [P in keyof T]: T[P];
|
29 | } extends {
|
30 | [key: number]: infer V;
|
31 | } ? V : never;
|
32 | type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
33 | /**
|
34 | * Merges multiple props objects together. Event handlers are chained,
|
35 | * classNames are combined, and ids are deduplicated - different ids
|
36 | * will trigger a side-effect and re-render components hooked up with `useId`.
|
37 | * For all other props, the last prop object overrides all previous ones.
|
38 | * @param args - Multiple sets of props to merge together.
|
39 | */
|
40 | export function mergeProps<T extends Props[]>(...args: T): UnionToIntersection<TupleTypes<T>>;
|
41 | /**
|
42 | * Merges multiple refs into one. Works with either callback or object refs.
|
43 | */
|
44 | export function mergeRefs<T>(...refs: ForwardedRef<T>[]): ForwardedRef<T>;
|
45 | interface Options {
|
46 | /**
|
47 | * If labelling associated aria properties should be included in the filter.
|
48 | */
|
49 | labelable?: boolean;
|
50 | /**
|
51 | * A Set of other property names that should be included in the filter.
|
52 | */
|
53 | propNames?: Set<string>;
|
54 | }
|
55 | /**
|
56 | * Filters out all props that aren't valid DOM props or defined via override prop obj.
|
57 | * @param props - The component props to be filtered.
|
58 | * @param opts - Props to override.
|
59 | */
|
60 | export function filterDOMProps(props: DOMProps & AriaLabelingProps, opts?: Options): DOMProps & AriaLabelingProps;
|
61 | export function focusWithoutScrolling(element: FocusableElement): void;
|
62 | export function getOffset(element: any, reverse: any, orientation?: string): any;
|
63 | export function runAfterTransition(fn: () => void): void;
|
64 | interface UseDrag1DProps {
|
65 | containerRef: MutableRefObject<HTMLElement>;
|
66 | reverse?: boolean;
|
67 | orientation?: Orientation;
|
68 | onHover?: (hovered: boolean) => void;
|
69 | onDrag?: (dragging: boolean) => void;
|
70 | onPositionChange?: (position: number) => void;
|
71 | onIncrement?: () => void;
|
72 | onDecrement?: () => void;
|
73 | onIncrementToMax?: () => void;
|
74 | onDecrementToMin?: () => void;
|
75 | onCollapseToggle?: () => void;
|
76 | }
|
77 | export function useDrag1D(props: UseDrag1DProps): HTMLAttributes<HTMLElement>;
|
78 | interface GlobalListeners {
|
79 | addGlobalListener<K extends keyof DocumentEventMap>(el: EventTarget, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
80 | addGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
81 | removeGlobalListener<K extends keyof DocumentEventMap>(el: EventTarget, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
82 | removeGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
83 | removeAllGlobalListeners(): void;
|
84 | }
|
85 | export function useGlobalListeners(): GlobalListeners;
|
86 | /**
|
87 | * Merges aria-label and aria-labelledby into aria-labelledby when both exist.
|
88 | * @param props - Aria label props.
|
89 | * @param defaultLabel - Default value for aria-label when not present.
|
90 | */
|
91 | export function useLabels(props: DOMProps & AriaLabelingProps, defaultLabel?: string): DOMProps & AriaLabelingProps;
|
92 | /**
|
93 | * Offers an object ref for a given callback ref or an object ref. Especially
|
94 | * helfpul when passing forwarded refs (created using `React.forwardRef`) to
|
95 | * React Aria Hooks.
|
96 | *
|
97 | * @param forwardedRef The original ref intended to be used.
|
98 | * @returns An object ref that updates the given ref.
|
99 | * @see https://reactjs.org/docs/forwarding-refs.html
|
100 | */
|
101 | export function useObjectRef<T>(forwardedRef?: ((instance: T | null) => void) | MutableRefObject<T | null> | null): MutableRefObject<T>;
|
102 | export function useUpdateEffect(effect: EffectCallback, dependencies: any[]): void;
|
103 | type useResizeObserverOptionsType<T> = {
|
104 | ref: RefObject<T | undefined> | undefined;
|
105 | onResize: () => void;
|
106 | };
|
107 | export function useResizeObserver<T extends Element>(options: useResizeObserverOptionsType<T>): void;
|
108 | interface ContextValue<T> {
|
109 | ref?: MutableRefObject<T>;
|
110 | }
|
111 | export function useSyncRef<T>(context: ContextValue<T>, ref: RefObject<T>): void;
|
112 | export function getScrollParent(node: Element): Element;
|
113 | interface ViewportSize {
|
114 | width: number;
|
115 | height: number;
|
116 | }
|
117 | export function useViewportSize(): ViewportSize;
|
118 | export function useDescription(description: string): AriaLabelingProps;
|
119 | export function isMac(): boolean;
|
120 | export function isIPhone(): boolean;
|
121 | export function isIPad(): boolean;
|
122 | export function isIOS(): boolean;
|
123 | export function isAppleDevice(): boolean;
|
124 | export function isWebKit(): boolean;
|
125 | export function isChrome(): any;
|
126 | export function isAndroid(): any;
|
127 | export function useEvent<K extends keyof GlobalEventHandlersEventMap>(ref: RefObject<EventTarget>, event: K, handler: (this: Document, ev: GlobalEventHandlersEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
128 | type SetValueAction<S> = (prev: S) => Generator<any, void, unknown>;
|
129 | export function useValueEffect<S>(defaultValue: S | (() => S)): [S, Dispatch<SetValueAction<S>>];
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | export function scrollIntoView(scrollView: HTMLElement, element: HTMLElement): void;
|
136 | export function isVirtualClick(event: MouseEvent | PointerEvent): boolean;
|
137 | export function isVirtualPointerEvent(event: PointerEvent): boolean;
|
138 | export { clamp, snapValueToStep } from '@react-stately/utils';
|
139 |
|
140 |
|