1 | import { DOMAttributes, PressEvents, FocusableElement, FocusEvents, HoverEvents, KeyboardEvents, MoveEvents, ScrollEvents, LongPressEvent } from "@react-types/shared";
|
2 | import React, { RefObject, ReactElement, ReactNode, FocusEvent } from "react";
|
3 | export interface PressProps extends PressEvents {
|
4 |
|
5 | isPressed?: boolean;
|
6 |
|
7 | isDisabled?: boolean;
|
8 |
|
9 | preventFocusOnPress?: boolean;
|
10 | |
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | shouldCancelOnPointerExit?: boolean;
|
17 |
|
18 | allowTextSelectionOnPress?: boolean;
|
19 | }
|
20 | export interface PressHookProps extends PressProps {
|
21 |
|
22 | ref?: RefObject<Element>;
|
23 | }
|
24 | export interface PressResult {
|
25 |
|
26 | isPressed: boolean;
|
27 |
|
28 | pressProps: DOMAttributes;
|
29 | }
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | export function usePress(props: PressHookProps): PressResult;
|
36 | interface PressableProps extends PressProps {
|
37 | children: ReactElement<DOMAttributes, string>;
|
38 | }
|
39 | export const Pressable: React.ForwardRefExoticComponent<PressableProps & React.RefAttributes<HTMLElement>>;
|
40 | interface PressResponderProps extends PressProps {
|
41 | children: ReactNode;
|
42 | }
|
43 | export const PressResponder: React.ForwardRefExoticComponent<PressResponderProps & React.RefAttributes<FocusableElement>>;
|
44 | export function ClearPressResponder({ children }: {
|
45 | children: ReactNode;
|
46 | }): React.JSX.Element;
|
47 | export interface FocusProps<Target = FocusableElement> extends FocusEvents<Target> {
|
48 |
|
49 | isDisabled?: boolean;
|
50 | }
|
51 | export interface FocusResult<Target = FocusableElement> {
|
52 |
|
53 | focusProps: DOMAttributes<Target>;
|
54 | }
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | export function useFocus<Target extends FocusableElement = FocusableElement>(props: FocusProps<Target>): FocusResult<Target>;
|
60 | export type Modality = 'keyboard' | 'pointer' | 'virtual';
|
61 | export type FocusVisibleHandler = (isFocusVisible: boolean) => void;
|
62 | export interface FocusVisibleProps {
|
63 |
|
64 | isTextInput?: boolean;
|
65 |
|
66 | autoFocus?: boolean;
|
67 | }
|
68 | export interface FocusVisibleResult {
|
69 |
|
70 | isFocusVisible: boolean;
|
71 | }
|
72 |
|
73 |
|
74 |
|
75 | export function isFocusVisible(): boolean;
|
76 | export function getInteractionModality(): Modality | null;
|
77 | export function setInteractionModality(modality: Modality): void;
|
78 |
|
79 |
|
80 |
|
81 | export function useInteractionModality(): Modality | null;
|
82 |
|
83 |
|
84 |
|
85 | export function useFocusVisible(props?: FocusVisibleProps): FocusVisibleResult;
|
86 |
|
87 |
|
88 |
|
89 | export function useFocusVisibleListener(fn: FocusVisibleHandler, deps: ReadonlyArray<any>, opts?: {
|
90 | isTextInput?: boolean;
|
91 | }): void;
|
92 | export interface FocusWithinProps {
|
93 |
|
94 | isDisabled?: boolean;
|
95 |
|
96 | onFocusWithin?: (e: FocusEvent) => void;
|
97 |
|
98 | onBlurWithin?: (e: FocusEvent) => void;
|
99 |
|
100 | onFocusWithinChange?: (isFocusWithin: boolean) => void;
|
101 | }
|
102 | export interface FocusWithinResult {
|
103 |
|
104 | focusWithinProps: DOMAttributes;
|
105 | }
|
106 |
|
107 |
|
108 |
|
109 | export function useFocusWithin(props: FocusWithinProps): FocusWithinResult;
|
110 | export interface HoverProps extends HoverEvents {
|
111 |
|
112 | isDisabled?: boolean;
|
113 | }
|
114 | export interface HoverResult {
|
115 |
|
116 | hoverProps: DOMAttributes;
|
117 | isHovered: boolean;
|
118 | }
|
119 |
|
120 |
|
121 |
|
122 |
|
123 | export function useHover(props: HoverProps): HoverResult;
|
124 | export interface InteractOutsideProps {
|
125 | ref: RefObject<Element>;
|
126 | onInteractOutside?: (e: PointerEvent) => void;
|
127 | onInteractOutsideStart?: (e: PointerEvent) => void;
|
128 |
|
129 | isDisabled?: boolean;
|
130 | }
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | export function useInteractOutside(props: InteractOutsideProps): void;
|
136 | export interface KeyboardProps extends KeyboardEvents {
|
137 |
|
138 | isDisabled?: boolean;
|
139 | }
|
140 | export interface KeyboardResult {
|
141 |
|
142 | keyboardProps: DOMAttributes;
|
143 | }
|
144 |
|
145 |
|
146 |
|
147 | export function useKeyboard(props: KeyboardProps): KeyboardResult;
|
148 | export interface MoveResult {
|
149 |
|
150 | moveProps: DOMAttributes;
|
151 | }
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 | export function useMove(props: MoveEvents): MoveResult;
|
158 | export interface ScrollWheelProps extends ScrollEvents {
|
159 |
|
160 | isDisabled?: boolean;
|
161 | }
|
162 | export function useScrollWheel(props: ScrollWheelProps, ref: RefObject<HTMLElement>): void;
|
163 | export interface LongPressProps {
|
164 |
|
165 | isDisabled?: boolean;
|
166 |
|
167 | onLongPressStart?: (e: LongPressEvent) => void;
|
168 | |
169 |
|
170 |
|
171 |
|
172 | onLongPressEnd?: (e: LongPressEvent) => void;
|
173 | |
174 |
|
175 |
|
176 |
|
177 | onLongPress?: (e: LongPressEvent) => void;
|
178 | |
179 |
|
180 |
|
181 |
|
182 | threshold?: number;
|
183 | |
184 |
|
185 |
|
186 |
|
187 | accessibilityDescription?: string;
|
188 | }
|
189 | export interface LongPressResult {
|
190 |
|
191 | longPressProps: DOMAttributes;
|
192 | }
|
193 |
|
194 |
|
195 |
|
196 |
|
197 | export function useLongPress(props: LongPressProps): LongPressResult;
|
198 | export type { PressEvent, PressEvents, MoveStartEvent, MoveMoveEvent, MoveEndEvent, MoveEvents, HoverEvent, HoverEvents, FocusEvents, KeyboardEvents } from '@react-types/shared';
|
199 |
|
200 |
|