@react-types/shared 3.0.0-nightly-641446f65-240905

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/src/dnd.d.ts ADDED
@@ -0,0 +1,286 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import {Key, RefObject} from '@react-types/shared';
14
+
15
+ export interface DragDropEvent {
16
+ /** The x coordinate of the event, relative to the target element. */
17
+ x: number,
18
+ /** The y coordinate of the event, relative to the target element. */
19
+ y: number
20
+ }
21
+
22
+ export type DropOperation = 'copy' | 'link' | 'move' | 'cancel';
23
+
24
+ export interface DragItem {
25
+ [type: string]: string
26
+ }
27
+
28
+ export interface DragStartEvent extends DragDropEvent {
29
+ /** The event type. */
30
+ type: 'dragstart'
31
+ }
32
+
33
+ export interface DragMoveEvent extends DragDropEvent {
34
+ /** The event type. */
35
+ type: 'dragmove'
36
+ }
37
+
38
+ export interface DragEndEvent extends DragDropEvent {
39
+ /** The event type. */
40
+ type: 'dragend',
41
+ /** The drop operation that occurred. */
42
+ dropOperation: DropOperation
43
+ }
44
+
45
+ export interface DropEnterEvent extends DragDropEvent {
46
+ /** The event type. */
47
+ type: 'dropenter'
48
+ }
49
+
50
+ export interface DropMoveEvent extends DragDropEvent {
51
+ /** The event type. */
52
+ type: 'dropmove'
53
+ }
54
+
55
+ export interface DropActivateEvent extends DragDropEvent {
56
+ /** The event type. */
57
+ type: 'dropactivate'
58
+ }
59
+
60
+ export interface DropExitEvent extends DragDropEvent {
61
+ /** The event type. */
62
+ type: 'dropexit'
63
+ }
64
+
65
+ export interface TextDropItem {
66
+ /** The item kind. */
67
+ kind: 'text',
68
+ /**
69
+ * The drag types available for this item.
70
+ * These are often mime types, but may be custom app-specific types.
71
+ */
72
+ types: Set<string>,
73
+ /** Returns the data for the given type as a string. */
74
+ getText(type: string): Promise<string>
75
+ }
76
+
77
+ export interface FileDropItem {
78
+ /** The item kind. */
79
+ kind: 'file',
80
+ /** The file type (usually a mime type). */
81
+ type: string,
82
+ /** The file name. */
83
+ name: string,
84
+ /** Returns the contents of the file as a blob. */
85
+ getFile(): Promise<File>,
86
+ /** Returns the contents of the file as a string. */
87
+ getText(): Promise<string>
88
+ }
89
+
90
+ export interface DirectoryDropItem {
91
+ /** The item kind. */
92
+ kind: 'directory',
93
+ /** The directory name. */
94
+ name: string,
95
+ /** Returns the entries contained within the directory. */
96
+ getEntries(): AsyncIterable<FileDropItem | DirectoryDropItem>
97
+ }
98
+
99
+ export type DropItem = TextDropItem | FileDropItem | DirectoryDropItem;
100
+
101
+ export interface DropEvent extends DragDropEvent {
102
+ /** The event type. */
103
+ type: 'drop',
104
+ /** The drop operation that should occur. */
105
+ dropOperation: DropOperation,
106
+ /** The dropped items. */
107
+ items: DropItem[]
108
+ }
109
+
110
+ export type DropPosition = 'on' | 'before' | 'after';
111
+ export interface RootDropTarget {
112
+ /** The event type. */
113
+ type: 'root'
114
+ }
115
+
116
+ export interface ItemDropTarget {
117
+ /** The drop target type. */
118
+ type: 'item',
119
+ /** The item key. */
120
+ key: Key,
121
+ /** The drop position relative to the item. */
122
+ dropPosition: DropPosition
123
+ }
124
+
125
+ export type DropTarget = RootDropTarget | ItemDropTarget;
126
+
127
+ export interface DroppableCollectionEnterEvent extends DropEnterEvent {
128
+ /** The drop target. */
129
+ target: DropTarget
130
+ }
131
+
132
+ export interface DroppableCollectionMoveEvent extends DropMoveEvent {
133
+ /** The drop target. */
134
+ target: DropTarget
135
+ }
136
+
137
+ export interface DroppableCollectionActivateEvent extends DropActivateEvent {
138
+ /** The drop target. */
139
+ target: DropTarget
140
+ }
141
+
142
+ export interface DroppableCollectionExitEvent extends DropExitEvent {
143
+ /** The drop target. */
144
+ target: DropTarget
145
+ }
146
+
147
+ export interface DroppableCollectionDropEvent extends DropEvent {
148
+ /** The drop target. */
149
+ target: DropTarget
150
+ }
151
+
152
+ export interface DroppableCollectionInsertDropEvent {
153
+ /** The dropped items. */
154
+ items: DropItem[],
155
+ /** The drop operation that should occur. */
156
+ dropOperation: DropOperation,
157
+ /** The drop target. */
158
+ target: ItemDropTarget
159
+ }
160
+
161
+ export interface DroppableCollectionRootDropEvent {
162
+ /** The dropped items. */
163
+ items: DropItem[],
164
+ /** The drop operation that should occur. */
165
+ dropOperation: DropOperation
166
+ }
167
+
168
+ export interface DroppableCollectionOnItemDropEvent {
169
+ /** The dropped items. */
170
+ items: DropItem[],
171
+ /** The drop operation that should occur. */
172
+ dropOperation: DropOperation,
173
+ /** Whether the drag originated within the same collection as the drop. */
174
+ isInternal: boolean,
175
+ /** The drop target. */
176
+ target: ItemDropTarget
177
+ }
178
+
179
+ export interface DroppableCollectionReorderEvent {
180
+ /** The keys of the items that were reordered. */
181
+ keys: Set<Key>,
182
+ /** The drop operation that should occur. */
183
+ dropOperation: DropOperation,
184
+ /** The drop target. */
185
+ target: ItemDropTarget
186
+ }
187
+
188
+ export interface DragTypes {
189
+ /** Returns whether the drag contains data of the given type. */
190
+ has(type: string | symbol): boolean
191
+ }
192
+
193
+ export interface DropTargetDelegate {
194
+ /**
195
+ * Returns a drop target within a collection for the given x and y coordinates.
196
+ * The point is provided relative to the top left corner of the collection container.
197
+ * A drop target can be checked to see if it is valid using the provided `isValidDropTarget` function.
198
+ */
199
+ getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget | null
200
+ }
201
+
202
+ export interface DroppableCollectionUtilityOptions {
203
+ /**
204
+ * The drag types that the droppable collection accepts. If the collection accepts directories, include `DIRECTORY_DRAG_TYPE` in your array of allowed types.
205
+ * @default 'all'
206
+ */
207
+ acceptedDragTypes?: 'all' | Array<string | symbol>,
208
+ /**
209
+ * Handler that is called when external items are dropped "between" items.
210
+ */
211
+ onInsert?: (e: DroppableCollectionInsertDropEvent) => void,
212
+ /**
213
+ * Handler that is called when external items are dropped on the droppable collection's root.
214
+ */
215
+ onRootDrop?: (e: DroppableCollectionRootDropEvent) => void,
216
+ /**
217
+ * Handler that is called when items are dropped "on" an item.
218
+ */
219
+ onItemDrop?: (e: DroppableCollectionOnItemDropEvent) => void,
220
+ /**
221
+ * Handler that is called when items are reordered via drag in the source collection.
222
+ */
223
+ onReorder?: (e: DroppableCollectionReorderEvent) => void,
224
+ /**
225
+ * A function returning whether a given target in the droppable collection is a valid "on" drop target for the current drag types.
226
+ */
227
+ shouldAcceptItemDrop?: (target: ItemDropTarget, types: DragTypes) => boolean
228
+ }
229
+
230
+ export interface DroppableCollectionBaseProps {
231
+ /** Handler that is called when a valid drag enters a drop target. */
232
+ onDropEnter?: (e: DroppableCollectionEnterEvent) => void,
233
+ /**
234
+ * Handler that is called after a valid drag is held over a drop target for a period of time.
235
+ * @private
236
+ */
237
+ onDropActivate?: (e: DroppableCollectionActivateEvent) => void,
238
+ /** Handler that is called when a valid drag exits a drop target. */
239
+ onDropExit?: (e: DroppableCollectionExitEvent) => void,
240
+ /**
241
+ * Handler that is called when a valid drag is dropped on a drop target. When defined, this overrides other
242
+ * drop handlers such as `onInsert`, and `onItemDrop`.
243
+ */
244
+ onDrop?: (e: DroppableCollectionDropEvent) => void,
245
+ /**
246
+ * A function returning the drop operation to be performed when items matching the given types are dropped
247
+ * on the drop target.
248
+ */
249
+ getDropOperation?: (target: DropTarget, types: DragTypes, allowedOperations: DropOperation[]) => DropOperation
250
+ }
251
+
252
+ export interface DroppableCollectionProps extends DroppableCollectionUtilityOptions, DroppableCollectionBaseProps {}
253
+
254
+ export interface DraggableCollectionStartEvent extends DragStartEvent {
255
+ /** The keys of the items that were dragged. */
256
+ keys: Set<Key>
257
+ }
258
+
259
+ export interface DraggableCollectionMoveEvent extends DragMoveEvent {
260
+ /** The keys of the items that were dragged. */
261
+ keys: Set<Key>
262
+ }
263
+
264
+ export interface DraggableCollectionEndEvent extends DragEndEvent {
265
+ /** The keys of the items that were dragged. */
266
+ keys: Set<Key>,
267
+ /** Whether the drop ended within the same collection as it originated. */
268
+ isInternal: boolean
269
+ }
270
+
271
+ export type DragPreviewRenderer = (items: DragItem[], callback: (node: HTMLElement) => void) => void;
272
+
273
+ export interface DraggableCollectionProps {
274
+ /** Handler that is called when a drag operation is started. */
275
+ onDragStart?: (e: DraggableCollectionStartEvent) => void,
276
+ /** Handler that is called when the drag is moved. */
277
+ onDragMove?: (e: DraggableCollectionMoveEvent) => void,
278
+ /** Handler that is called when the drag operation is ended, either as a result of a drop or a cancellation. */
279
+ onDragEnd?: (e: DraggableCollectionEndEvent) => void,
280
+ /** A function that returns the items being dragged. */
281
+ getItems: (keys: Set<Key>) => DragItem[],
282
+ /** The ref of the element that will be rendered as the drag preview while dragging. */
283
+ preview?: RefObject<DragPreviewRenderer | null>,
284
+ /** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */
285
+ getAllowedDropOperations?: () => DropOperation[]
286
+ }
package/src/dom.d.ts ADDED
@@ -0,0 +1,215 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import {
14
+ AriaAttributes,
15
+ AriaRole,
16
+ ClipboardEventHandler,
17
+ CompositionEventHandler,
18
+ CSSProperties,
19
+ FormEventHandler,
20
+ HTMLAttributeAnchorTarget,
21
+ HTMLAttributeReferrerPolicy,
22
+ DOMAttributes as ReactDOMAttributes,
23
+ ReactEventHandler
24
+ } from 'react';
25
+
26
+ export interface AriaLabelingProps {
27
+ /**
28
+ * Defines a string value that labels the current element.
29
+ */
30
+ 'aria-label'?: string,
31
+
32
+ /**
33
+ * Identifies the element (or elements) that labels the current element.
34
+ */
35
+ 'aria-labelledby'?: string,
36
+
37
+ /**
38
+ * Identifies the element (or elements) that describes the object.
39
+ */
40
+ 'aria-describedby'?: string,
41
+
42
+ /**
43
+ * Identifies the element (or elements) that provide a detailed, extended description for the object.
44
+ */
45
+ 'aria-details'?: string
46
+ }
47
+
48
+ export interface AriaValidationProps {
49
+ // https://www.w3.org/TR/wai-aria-1.2/#aria-errormessage
50
+ /**
51
+ * Identifies the element that provides an error message for the object.
52
+ */
53
+ 'aria-errormessage'?: string
54
+ }
55
+
56
+ // A set of common DOM props that are allowed on any component
57
+ // Ensure this is synced with DOMPropNames in filterDOMProps
58
+ export interface DOMProps {
59
+ /**
60
+ * The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
61
+ */
62
+ id?: string
63
+ }
64
+
65
+ export interface FocusableDOMProps extends DOMProps {
66
+ /**
67
+ * Whether to exclude the element from the sequential tab order. If true,
68
+ * the element will not be focusable via the keyboard by tabbing. This should
69
+ * be avoided except in rare scenarios where an alternative means of accessing
70
+ * the element or its functionality via the keyboard is available.
71
+ */
72
+ excludeFromTabOrder?: boolean
73
+ }
74
+
75
+
76
+ export interface TextInputDOMEvents {
77
+ // Clipboard events
78
+ /**
79
+ * Handler that is called when the user copies text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/oncopy).
80
+ */
81
+ onCopy?: ClipboardEventHandler<HTMLInputElement>,
82
+
83
+ /**
84
+ * Handler that is called when the user cuts text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/oncut).
85
+ */
86
+ onCut?: ClipboardEventHandler<HTMLInputElement>,
87
+
88
+ /**
89
+ * Handler that is called when the user pastes text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/onpaste).
90
+ */
91
+ onPaste?: ClipboardEventHandler<HTMLInputElement>,
92
+
93
+ // Composition events
94
+ /**
95
+ * Handler that is called when a text composition system starts a new text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionstart_event).
96
+ */
97
+ onCompositionStart?: CompositionEventHandler<HTMLInputElement>,
98
+
99
+ /**
100
+ * Handler that is called when a text composition system completes or cancels the current text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionend_event).
101
+ */
102
+ onCompositionEnd?: CompositionEventHandler<HTMLInputElement>,
103
+
104
+ /**
105
+ * Handler that is called when a new character is received in the current text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionupdate_event).
106
+ */
107
+ onCompositionUpdate?: CompositionEventHandler<HTMLInputElement>,
108
+
109
+ // Selection events
110
+ /**
111
+ * Handler that is called when text in the input is selected. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/select_event).
112
+ */
113
+ onSelect?: ReactEventHandler<HTMLInputElement>,
114
+
115
+ // Input events
116
+ /**
117
+ * Handler that is called when the input value is about to be modified. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/beforeinput_event).
118
+ */
119
+ onBeforeInput?: FormEventHandler<HTMLInputElement>,
120
+ /**
121
+ * Handler that is called when the input value is modified. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event).
122
+ */
123
+ onInput?: FormEventHandler<HTMLInputElement>
124
+ }
125
+
126
+ export interface InputDOMProps {
127
+ /**
128
+ * The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).
129
+ */
130
+ name?: string
131
+ }
132
+
133
+ // DOM props that apply to all text inputs
134
+ // Ensure this is synced with useTextField
135
+ export interface TextInputDOMProps extends DOMProps, InputDOMProps, TextInputDOMEvents {
136
+ /**
137
+ * Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).
138
+ */
139
+ autoComplete?: string,
140
+
141
+ /**
142
+ * The maximum number of characters supported by the input. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefmaxlength).
143
+ */
144
+ maxLength?: number,
145
+
146
+ /**
147
+ * The minimum number of characters required by the input. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefminlength).
148
+ */
149
+ minLength?: number,
150
+
151
+ /**
152
+ * Regex pattern that the value of the input must match to be valid. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefpattern).
153
+ */
154
+ pattern?: string,
155
+
156
+ /**
157
+ * Content that appears in the input when it is empty. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefplaceholder).
158
+ */
159
+ placeholder?: string,
160
+
161
+ /**
162
+ * The type of input to render. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdeftype).
163
+ */
164
+ type?: 'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | (string & {}),
165
+
166
+ /**
167
+ * Hints at the type of data that might be entered by the user while editing the element or its contents. See [MDN](https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute).
168
+ */
169
+ inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'
170
+ }
171
+
172
+ /**
173
+ * This type allows configuring link props with router options and type-safe URLs via TS module augmentation.
174
+ * By default, this is an empty type. Extend with `href` and `routerOptions` properties to configure your router.
175
+ */
176
+ export interface RouterConfig {}
177
+
178
+ export type Href = RouterConfig extends {href: infer H} ? H : string;
179
+ export type RouterOptions = RouterConfig extends {routerOptions: infer O} ? O : never;
180
+
181
+ // Make sure to update filterDOMProps.ts when updating this.
182
+ export interface LinkDOMProps {
183
+ /** A URL to link to. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href). */
184
+ href?: Href,
185
+ /** Hints at the human language of the linked URL. See[MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#hreflang). */
186
+ hrefLang?: string,
187
+ /** The target window for the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target). */
188
+ target?: HTMLAttributeAnchorTarget,
189
+ /** The relationship between the linked resource and the current page. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel). */
190
+ rel?: string,
191
+ /** Causes the browser to download the linked URL. A string may be provided to suggest a file name. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download). */
192
+ download?: boolean | string,
193
+ /** A space-separated list of URLs to ping when the link is followed. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#ping). */
194
+ ping?: string,
195
+ /** How much of the referrer to send when following the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#referrerpolicy). */
196
+ referrerPolicy?: HTMLAttributeReferrerPolicy,
197
+ /** Options for the configured client side router. */
198
+ routerOptions?: RouterOptions
199
+ }
200
+
201
+ /** Any focusable element, including both HTML and SVG elements. */
202
+ export interface FocusableElement extends Element, HTMLOrSVGElement {}
203
+
204
+ /** All DOM attributes supported across both HTML and SVG elements. */
205
+ export interface DOMAttributes<T = FocusableElement> extends AriaAttributes, ReactDOMAttributes<T> {
206
+ id?: string | undefined,
207
+ role?: AriaRole | undefined,
208
+ tabIndex?: number | undefined,
209
+ style?: CSSProperties | undefined,
210
+ className?: string | undefined
211
+ }
212
+
213
+ export interface GroupDOMAttributes extends Omit<DOMAttributes<HTMLElement>, 'role'> {
214
+ role?: 'group' | 'region' | 'presentation'
215
+ }
@@ -0,0 +1,177 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import {
14
+ FocusEvent,
15
+ KeyboardEvent as ReactKeyboardEvent,
16
+ SyntheticEvent
17
+ } from 'react';
18
+
19
+ // Event bubbling can be problematic in real-world applications, so the default for React Spectrum components
20
+ // is not to propagate. This can be overridden by calling continuePropagation() on the event.
21
+ export type BaseEvent<T extends SyntheticEvent> = T & {
22
+ /**
23
+ * Use continuePropagation.
24
+ * @deprecated */
25
+ stopPropagation(): void,
26
+ continuePropagation(): void
27
+ }
28
+
29
+ export type KeyboardEvent = BaseEvent<ReactKeyboardEvent<any>>;
30
+
31
+ export type PointerType = 'mouse' | 'pen' | 'touch' | 'keyboard' | 'virtual';
32
+
33
+ export interface PressEvent {
34
+ /** The type of press event being fired. */
35
+ type: 'pressstart' | 'pressend' | 'pressup' | 'press',
36
+ /** The pointer type that triggered the press event. */
37
+ pointerType: PointerType,
38
+ /** The target element of the press event. */
39
+ target: Element,
40
+ /** Whether the shift keyboard modifier was held during the press event. */
41
+ shiftKey: boolean,
42
+ /** Whether the ctrl keyboard modifier was held during the press event. */
43
+ ctrlKey: boolean,
44
+ /** Whether the meta keyboard modifier was held during the press event. */
45
+ metaKey: boolean,
46
+ /** Whether the alt keyboard modifier was held during the press event. */
47
+ altKey: boolean,
48
+ /** X position relative to the target. */
49
+ x: number,
50
+ /** Y position relative to the target. */
51
+ y: number,
52
+ /**
53
+ * By default, press events stop propagation to parent elements.
54
+ * In cases where a handler decides not to handle a specific event,
55
+ * it can call `continuePropagation()` to allow a parent to handle it.
56
+ */
57
+ continuePropagation(): void
58
+ }
59
+
60
+ export interface LongPressEvent extends Omit<PressEvent, 'type' | 'continuePropagation'> {
61
+ /** The type of long press event being fired. */
62
+ type: 'longpressstart' | 'longpressend' | 'longpress'
63
+ }
64
+
65
+ export interface HoverEvent {
66
+ /** The type of hover event being fired. */
67
+ type: 'hoverstart' | 'hoverend',
68
+ /** The pointer type that triggered the hover event. */
69
+ pointerType: 'mouse' | 'pen',
70
+ /** The target element of the hover event. */
71
+ target: HTMLElement
72
+ }
73
+
74
+ export interface KeyboardEvents {
75
+ /** Handler that is called when a key is pressed. */
76
+ onKeyDown?: (e: KeyboardEvent) => void,
77
+ /** Handler that is called when a key is released. */
78
+ onKeyUp?: (e: KeyboardEvent) => void
79
+ }
80
+
81
+ export interface FocusEvents<Target = Element> {
82
+ /** Handler that is called when the element receives focus. */
83
+ onFocus?: (e: FocusEvent<Target>) => void,
84
+ /** Handler that is called when the element loses focus. */
85
+ onBlur?: (e: FocusEvent<Target>) => void,
86
+ /** Handler that is called when the element's focus status changes. */
87
+ onFocusChange?: (isFocused: boolean) => void
88
+ }
89
+
90
+ export interface HoverEvents {
91
+ /** Handler that is called when a hover interaction starts. */
92
+ onHoverStart?: (e: HoverEvent) => void,
93
+ /** Handler that is called when a hover interaction ends. */
94
+ onHoverEnd?: (e: HoverEvent) => void,
95
+ /** Handler that is called when the hover state changes. */
96
+ onHoverChange?: (isHovering: boolean) => void
97
+ }
98
+
99
+ export interface PressEvents {
100
+ /** Handler that is called when the press is released over the target. */
101
+ onPress?: (e: PressEvent) => void,
102
+ /** Handler that is called when a press interaction starts. */
103
+ onPressStart?: (e: PressEvent) => void,
104
+ /**
105
+ * Handler that is called when a press interaction ends, either
106
+ * over the target or when the pointer leaves the target.
107
+ */
108
+ onPressEnd?: (e: PressEvent) => void,
109
+ /** Handler that is called when the press state changes. */
110
+ onPressChange?: (isPressed: boolean) => void,
111
+ /**
112
+ * Handler that is called when a press is released over the target, regardless of
113
+ * whether it started on the target or not.
114
+ */
115
+ onPressUp?: (e: PressEvent) => void
116
+ }
117
+
118
+ export interface FocusableProps<Target = Element> extends FocusEvents<Target>, KeyboardEvents {
119
+ /** Whether the element should receive focus on render. */
120
+ autoFocus?: boolean
121
+ }
122
+
123
+ interface BaseMoveEvent {
124
+ /** The pointer type that triggered the move event. */
125
+ pointerType: PointerType,
126
+ /** Whether the shift keyboard modifier was held during the move event. */
127
+ shiftKey: boolean,
128
+ /** Whether the ctrl keyboard modifier was held during the move event. */
129
+ ctrlKey: boolean,
130
+ /** Whether the meta keyboard modifier was held during the move event. */
131
+ metaKey: boolean,
132
+ /** Whether the alt keyboard modifier was held during the move event. */
133
+ altKey: boolean
134
+ }
135
+
136
+ export interface MoveStartEvent extends BaseMoveEvent {
137
+ /** The type of move event being fired. */
138
+ type: 'movestart'
139
+ }
140
+
141
+ export interface MoveMoveEvent extends BaseMoveEvent {
142
+ /** The type of move event being fired. */
143
+ type: 'move',
144
+ /** The amount moved in the X direction since the last event. */
145
+ deltaX: number,
146
+ /** The amount moved in the Y direction since the last event. */
147
+ deltaY: number
148
+
149
+ }
150
+
151
+ export interface MoveEndEvent extends BaseMoveEvent {
152
+ /** The type of move event being fired. */
153
+ type: 'moveend'
154
+ }
155
+
156
+ export type MoveEvent = MoveStartEvent | MoveMoveEvent | MoveEndEvent;
157
+
158
+ export interface MoveEvents {
159
+ /** Handler that is called when a move interaction starts. */
160
+ onMoveStart?: (e: MoveStartEvent) => void,
161
+ /** Handler that is called when the element is moved. */
162
+ onMove?: (e: MoveMoveEvent) => void,
163
+ /** Handler that is called when a move interaction ends. */
164
+ onMoveEnd?: (e: MoveEndEvent) => void
165
+ }
166
+
167
+ export interface ScrollEvent {
168
+ /** The amount moved in the X direction since the last event. */
169
+ deltaX: number,
170
+ /** The amount moved in the Y direction since the last event. */
171
+ deltaY: number
172
+ }
173
+
174
+ export interface ScrollEvents {
175
+ /** Handler that is called when the scroll wheel moves. */
176
+ onScroll?: (e: ScrollEvent) => void
177
+ }