@react-types/shared 3.34.0 → 3.35.0
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/package.json +9 -6
- package/src/collections.d.ts +85 -75
- package/src/dna.d.ts +9 -40
- package/src/dnd.d.ts +105 -84
- package/src/dom.d.ts +240 -188
- package/src/events.d.ts +54 -58
- package/src/inputs.d.ts +32 -27
- package/src/labelable.d.ts +9 -6
- package/src/refs.d.ts +10 -5
- package/src/removable.d.ts +2 -2
- package/src/selection.d.ts +11 -11
- package/src/style.d.ts +504 -180
package/src/dnd.d.ts
CHANGED
|
@@ -14,280 +14,301 @@ import {Key, RefObject} from '@react-types/shared';
|
|
|
14
14
|
|
|
15
15
|
export interface DragDropEvent {
|
|
16
16
|
/** The x coordinate of the event, relative to the target element. */
|
|
17
|
-
x: number
|
|
17
|
+
x: number;
|
|
18
18
|
/** The y coordinate of the event, relative to the target element. */
|
|
19
|
-
y: number
|
|
19
|
+
y: number;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export type DropOperation = 'copy' | 'link' | 'move' | 'cancel';
|
|
23
23
|
|
|
24
24
|
export interface DragItem {
|
|
25
|
-
[type: string]: string
|
|
25
|
+
[type: string]: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface DragStartEvent extends DragDropEvent {
|
|
29
29
|
/** The event type. */
|
|
30
|
-
type: 'dragstart'
|
|
30
|
+
type: 'dragstart';
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export interface DragMoveEvent extends DragDropEvent {
|
|
34
34
|
/** The event type. */
|
|
35
|
-
type: 'dragmove'
|
|
35
|
+
type: 'dragmove';
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export interface DragEndEvent extends DragDropEvent {
|
|
39
39
|
/** The event type. */
|
|
40
|
-
type: 'dragend'
|
|
40
|
+
type: 'dragend';
|
|
41
41
|
/** The drop operation that occurred. */
|
|
42
|
-
dropOperation: DropOperation
|
|
42
|
+
dropOperation: DropOperation;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export interface DropEnterEvent extends DragDropEvent {
|
|
46
46
|
/** The event type. */
|
|
47
|
-
type: 'dropenter'
|
|
47
|
+
type: 'dropenter';
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
export interface DropMoveEvent extends DragDropEvent {
|
|
51
51
|
/** The event type. */
|
|
52
|
-
type: 'dropmove'
|
|
52
|
+
type: 'dropmove';
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export interface DropActivateEvent extends DragDropEvent {
|
|
56
56
|
/** The event type. */
|
|
57
|
-
type: 'dropactivate'
|
|
57
|
+
type: 'dropactivate';
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export interface DropExitEvent extends DragDropEvent {
|
|
61
61
|
/** The event type. */
|
|
62
|
-
type: 'dropexit'
|
|
62
|
+
type: 'dropexit';
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export interface TextDropItem {
|
|
66
66
|
/** The item kind. */
|
|
67
|
-
kind: 'text'
|
|
67
|
+
kind: 'text';
|
|
68
68
|
/**
|
|
69
69
|
* The drag types available for this item.
|
|
70
70
|
* These are often mime types, but may be custom app-specific types.
|
|
71
71
|
*/
|
|
72
|
-
types: Set<string
|
|
72
|
+
types: Set<string>;
|
|
73
73
|
/** Returns the data for the given type as a string. */
|
|
74
|
-
getText(type: string): Promise<string
|
|
74
|
+
getText(type: string): Promise<string>;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export interface FileDropItem {
|
|
78
78
|
/** The item kind. */
|
|
79
|
-
kind: 'file'
|
|
79
|
+
kind: 'file';
|
|
80
80
|
/** The file type (usually a mime type). */
|
|
81
|
-
type: string
|
|
81
|
+
type: string;
|
|
82
82
|
/** The file name. */
|
|
83
|
-
name: string
|
|
83
|
+
name: string;
|
|
84
84
|
/** Returns the contents of the file as a blob. */
|
|
85
|
-
getFile(): Promise<File
|
|
85
|
+
getFile(): Promise<File>;
|
|
86
86
|
/** Returns the contents of the file as a string. */
|
|
87
|
-
getText(): Promise<string
|
|
87
|
+
getText(): Promise<string>;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
export interface DirectoryDropItem {
|
|
91
91
|
/** The item kind. */
|
|
92
|
-
kind: 'directory'
|
|
92
|
+
kind: 'directory';
|
|
93
93
|
/** The directory name. */
|
|
94
|
-
name: string
|
|
94
|
+
name: string;
|
|
95
95
|
/** Returns the entries contained within the directory. */
|
|
96
|
-
getEntries(): AsyncIterable<FileDropItem | DirectoryDropItem
|
|
96
|
+
getEntries(): AsyncIterable<FileDropItem | DirectoryDropItem>;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export type DropItem = TextDropItem | FileDropItem | DirectoryDropItem;
|
|
100
100
|
|
|
101
101
|
export interface DropEvent extends DragDropEvent {
|
|
102
102
|
/** The event type. */
|
|
103
|
-
type: 'drop'
|
|
103
|
+
type: 'drop';
|
|
104
104
|
/** The drop operation that should occur. */
|
|
105
|
-
dropOperation: DropOperation
|
|
105
|
+
dropOperation: DropOperation;
|
|
106
106
|
/** The dropped items. */
|
|
107
|
-
items: DropItem[]
|
|
107
|
+
items: DropItem[];
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
export type DropPosition = 'on' | 'before' | 'after';
|
|
111
111
|
export interface RootDropTarget {
|
|
112
112
|
/** The event type. */
|
|
113
|
-
type: 'root'
|
|
113
|
+
type: 'root';
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
export interface ItemDropTarget {
|
|
117
117
|
/** The drop target type. */
|
|
118
|
-
type: 'item'
|
|
118
|
+
type: 'item';
|
|
119
119
|
/** The item key. */
|
|
120
|
-
key: Key
|
|
120
|
+
key: Key;
|
|
121
121
|
/** The drop position relative to the item. */
|
|
122
|
-
dropPosition: DropPosition
|
|
122
|
+
dropPosition: DropPosition;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
export type DropTarget = RootDropTarget | ItemDropTarget;
|
|
126
126
|
|
|
127
127
|
export interface DroppableCollectionEnterEvent extends DropEnterEvent {
|
|
128
128
|
/** The drop target. */
|
|
129
|
-
target: DropTarget
|
|
129
|
+
target: DropTarget;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
export interface DroppableCollectionMoveEvent extends DropMoveEvent {
|
|
133
133
|
/** The drop target. */
|
|
134
|
-
target: DropTarget
|
|
134
|
+
target: DropTarget;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
export interface DroppableCollectionActivateEvent extends DropActivateEvent {
|
|
138
138
|
/** The drop target. */
|
|
139
|
-
target: DropTarget
|
|
139
|
+
target: DropTarget;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
export interface DroppableCollectionExitEvent extends DropExitEvent {
|
|
143
143
|
/** The drop target. */
|
|
144
|
-
target: DropTarget
|
|
144
|
+
target: DropTarget;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
export interface DroppableCollectionDropEvent extends DropEvent {
|
|
148
148
|
/** The drop target. */
|
|
149
|
-
target: DropTarget
|
|
149
|
+
target: DropTarget;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
export interface DroppableCollectionInsertDropEvent {
|
|
153
153
|
/** The dropped items. */
|
|
154
|
-
items: DropItem[]
|
|
154
|
+
items: DropItem[];
|
|
155
155
|
/** The drop operation that should occur. */
|
|
156
|
-
dropOperation: DropOperation
|
|
157
|
-
|
|
158
|
-
target: ItemDropTarget
|
|
156
|
+
dropOperation: DropOperation;
|
|
157
|
+
/** The drop target. */
|
|
158
|
+
target: ItemDropTarget;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
export interface DroppableCollectionRootDropEvent {
|
|
162
162
|
/** The dropped items. */
|
|
163
|
-
items: DropItem[]
|
|
163
|
+
items: DropItem[];
|
|
164
164
|
/** The drop operation that should occur. */
|
|
165
|
-
dropOperation: DropOperation
|
|
165
|
+
dropOperation: DropOperation;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
export interface DroppableCollectionOnItemDropEvent {
|
|
169
169
|
/** The dropped items. */
|
|
170
|
-
items: DropItem[]
|
|
170
|
+
items: DropItem[];
|
|
171
171
|
/** The drop operation that should occur. */
|
|
172
|
-
dropOperation: DropOperation
|
|
172
|
+
dropOperation: DropOperation;
|
|
173
173
|
/** Whether the drag originated within the same collection as the drop. */
|
|
174
|
-
isInternal: boolean
|
|
174
|
+
isInternal: boolean;
|
|
175
175
|
/** The drop target. */
|
|
176
|
-
target: ItemDropTarget
|
|
176
|
+
target: ItemDropTarget;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
export interface DroppableCollectionReorderEvent {
|
|
180
180
|
/** The keys of the items that were reordered. */
|
|
181
|
-
keys: Set<Key
|
|
181
|
+
keys: Set<Key>;
|
|
182
182
|
/** The drop operation that should occur. */
|
|
183
|
-
dropOperation: DropOperation
|
|
183
|
+
dropOperation: DropOperation;
|
|
184
184
|
/** The drop target. */
|
|
185
|
-
target: ItemDropTarget
|
|
185
|
+
target: ItemDropTarget;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
export interface DragTypes {
|
|
189
189
|
/** Returns whether the drag contains data of the given type. */
|
|
190
|
-
has(type: string | symbol): boolean
|
|
190
|
+
has(type: string | symbol): boolean;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
export interface DropTargetDelegate {
|
|
194
194
|
/**
|
|
195
|
-
* Returns a drop target within a collection for the given x and y coordinates.
|
|
196
|
-
*
|
|
197
|
-
*
|
|
195
|
+
* Returns a drop target within a collection for the given x and y coordinates. The point is
|
|
196
|
+
* provided relative to the top left corner of the collection container. A drop target can be
|
|
197
|
+
* checked to see if it is valid using the provided `isValidDropTarget` function.
|
|
198
198
|
*/
|
|
199
|
-
getDropTargetFromPoint(
|
|
199
|
+
getDropTargetFromPoint(
|
|
200
|
+
x: number,
|
|
201
|
+
y: number,
|
|
202
|
+
isValidDropTarget: (target: DropTarget) => boolean
|
|
203
|
+
): DropTarget | null;
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
export interface DroppableCollectionUtilityOptions {
|
|
203
207
|
/**
|
|
204
|
-
* The drag types that the droppable collection accepts. If the collection accepts directories,
|
|
208
|
+
* The drag types that the droppable collection accepts. If the collection accepts directories,
|
|
209
|
+
* include `DIRECTORY_DRAG_TYPE` in your array of allowed types.
|
|
210
|
+
*
|
|
205
211
|
* @default 'all'
|
|
206
212
|
*/
|
|
207
|
-
acceptedDragTypes?: 'all' | Array<string | symbol
|
|
213
|
+
acceptedDragTypes?: 'all' | Array<string | symbol>;
|
|
208
214
|
/**
|
|
209
215
|
* Handler that is called when external items are dropped "between" items.
|
|
210
216
|
*/
|
|
211
|
-
onInsert?: (e: DroppableCollectionInsertDropEvent) => void
|
|
217
|
+
onInsert?: (e: DroppableCollectionInsertDropEvent) => void;
|
|
212
218
|
/**
|
|
213
219
|
* Handler that is called when external items are dropped on the droppable collection's root.
|
|
214
220
|
*/
|
|
215
|
-
onRootDrop?: (e: DroppableCollectionRootDropEvent) => void
|
|
221
|
+
onRootDrop?: (e: DroppableCollectionRootDropEvent) => void;
|
|
216
222
|
/**
|
|
217
223
|
* Handler that is called when items are dropped "on" an item.
|
|
218
224
|
*/
|
|
219
|
-
onItemDrop?: (e: DroppableCollectionOnItemDropEvent) => void
|
|
225
|
+
onItemDrop?: (e: DroppableCollectionOnItemDropEvent) => void;
|
|
220
226
|
/**
|
|
221
227
|
* Handler that is called when items are reordered within the collection.
|
|
222
228
|
* This handler only allows dropping between items, not on items.
|
|
223
229
|
* It does not allow moving items to a different parent item within a tree.
|
|
224
230
|
*/
|
|
225
|
-
onReorder?: (e: DroppableCollectionReorderEvent) => void
|
|
231
|
+
onReorder?: (e: DroppableCollectionReorderEvent) => void;
|
|
226
232
|
/**
|
|
227
233
|
* Handler that is called when items are moved within the source collection.
|
|
228
234
|
* This handler allows dropping both on or between items, and items may be
|
|
229
235
|
* moved to a different parent item within a tree.
|
|
230
236
|
*/
|
|
231
|
-
onMove?: (e: DroppableCollectionReorderEvent) => void
|
|
237
|
+
onMove?: (e: DroppableCollectionReorderEvent) => void;
|
|
232
238
|
/**
|
|
233
|
-
* A function returning whether a given target in the droppable collection is a valid "on" drop
|
|
239
|
+
* A function returning whether a given target in the droppable collection is a valid "on" drop
|
|
240
|
+
* target for the current drag types.
|
|
234
241
|
*/
|
|
235
|
-
shouldAcceptItemDrop?: (target: ItemDropTarget, types: DragTypes) => boolean
|
|
242
|
+
shouldAcceptItemDrop?: (target: ItemDropTarget, types: DragTypes) => boolean;
|
|
236
243
|
}
|
|
237
244
|
|
|
238
245
|
export interface DroppableCollectionBaseProps {
|
|
239
246
|
/** Handler that is called when a valid drag enters a drop target. */
|
|
240
|
-
onDropEnter?: (e: DroppableCollectionEnterEvent) => void
|
|
247
|
+
onDropEnter?: (e: DroppableCollectionEnterEvent) => void;
|
|
241
248
|
/**
|
|
242
249
|
* Handler that is called after a valid drag is held over a drop target for a period of time.
|
|
243
250
|
*/
|
|
244
|
-
onDropActivate?: (e: DroppableCollectionActivateEvent) => void
|
|
251
|
+
onDropActivate?: (e: DroppableCollectionActivateEvent) => void;
|
|
245
252
|
/** Handler that is called when a valid drag exits a drop target. */
|
|
246
|
-
onDropExit?: (e: DroppableCollectionExitEvent) => void
|
|
253
|
+
onDropExit?: (e: DroppableCollectionExitEvent) => void;
|
|
247
254
|
/**
|
|
248
|
-
* Handler that is called when a valid drag is dropped on a drop target. When defined, this
|
|
249
|
-
* drop handlers such as `onInsert`, and `onItemDrop`.
|
|
255
|
+
* Handler that is called when a valid drag is dropped on a drop target. When defined, this
|
|
256
|
+
* overrides other drop handlers such as `onInsert`, and `onItemDrop`.
|
|
250
257
|
*/
|
|
251
|
-
onDrop?: (e: DroppableCollectionDropEvent) => void
|
|
258
|
+
onDrop?: (e: DroppableCollectionDropEvent) => void;
|
|
252
259
|
/**
|
|
253
|
-
* A function returning the drop operation to be performed when items matching the given types are
|
|
254
|
-
* on the drop target.
|
|
260
|
+
* A function returning the drop operation to be performed when items matching the given types are
|
|
261
|
+
* dropped on the drop target.
|
|
255
262
|
*/
|
|
256
|
-
getDropOperation?: (
|
|
263
|
+
getDropOperation?: (
|
|
264
|
+
target: DropTarget,
|
|
265
|
+
types: DragTypes,
|
|
266
|
+
allowedOperations: DropOperation[]
|
|
267
|
+
) => DropOperation;
|
|
257
268
|
}
|
|
258
269
|
|
|
259
|
-
export interface DroppableCollectionProps
|
|
270
|
+
export interface DroppableCollectionProps
|
|
271
|
+
extends DroppableCollectionUtilityOptions, DroppableCollectionBaseProps {}
|
|
260
272
|
|
|
261
273
|
export interface DraggableCollectionStartEvent extends DragStartEvent {
|
|
262
274
|
/** The keys of the items that were dragged. */
|
|
263
|
-
keys: Set<Key
|
|
275
|
+
keys: Set<Key>;
|
|
264
276
|
}
|
|
265
277
|
|
|
266
278
|
export interface DraggableCollectionMoveEvent extends DragMoveEvent {
|
|
267
279
|
/** The keys of the items that were dragged. */
|
|
268
|
-
keys: Set<Key
|
|
280
|
+
keys: Set<Key>;
|
|
269
281
|
}
|
|
270
282
|
|
|
271
283
|
export interface DraggableCollectionEndEvent extends DragEndEvent {
|
|
272
284
|
/** The keys of the items that were dragged. */
|
|
273
|
-
keys: Set<Key
|
|
285
|
+
keys: Set<Key>;
|
|
274
286
|
/** Whether the drop ended within the same collection as it originated. */
|
|
275
|
-
isInternal: boolean
|
|
287
|
+
isInternal: boolean;
|
|
276
288
|
}
|
|
277
289
|
|
|
278
|
-
export type DragPreviewRenderer = (
|
|
290
|
+
export type DragPreviewRenderer = (
|
|
291
|
+
items: DragItem[],
|
|
292
|
+
callback: (node: HTMLElement | null, x?: number, y?: number) => void
|
|
293
|
+
) => void;
|
|
279
294
|
|
|
280
295
|
export interface DraggableCollectionProps<T = object> {
|
|
281
296
|
/** Handler that is called when a drag operation is started. */
|
|
282
|
-
onDragStart?: (e: DraggableCollectionStartEvent) => void
|
|
297
|
+
onDragStart?: (e: DraggableCollectionStartEvent) => void;
|
|
283
298
|
/** Handler that is called when the drag is moved. */
|
|
284
|
-
onDragMove?: (e: DraggableCollectionMoveEvent) => void
|
|
285
|
-
/**
|
|
286
|
-
|
|
299
|
+
onDragMove?: (e: DraggableCollectionMoveEvent) => void;
|
|
300
|
+
/**
|
|
301
|
+
* Handler that is called when the drag operation is ended, either as a result of a drop or a
|
|
302
|
+
* cancellation.
|
|
303
|
+
*/
|
|
304
|
+
onDragEnd?: (e: DraggableCollectionEndEvent) => void;
|
|
287
305
|
/** A function that returns the items being dragged. */
|
|
288
|
-
getItems: (keys: Set<Key>, items: T[]) => DragItem[]
|
|
306
|
+
getItems: (keys: Set<Key>, items: T[]) => DragItem[];
|
|
289
307
|
/** The ref of the element that will be rendered as the drag preview while dragging. */
|
|
290
|
-
preview?: RefObject<DragPreviewRenderer | null
|
|
291
|
-
/**
|
|
292
|
-
|
|
308
|
+
preview?: RefObject<DragPreviewRenderer | null>;
|
|
309
|
+
/**
|
|
310
|
+
* Function that returns the drop operations that are allowed for the dragged items. If not
|
|
311
|
+
* provided, all drop operations are allowed.
|
|
312
|
+
*/
|
|
313
|
+
getAllowedDropOperations?: () => DropOperation[];
|
|
293
314
|
}
|