@react-types/shared 3.0.0-nightly.1775 → 3.0.0-nightly.1779

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/dnd.d.ts +60 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-types/shared",
3
- "version": "3.0.0-nightly.1775+00c313323",
3
+ "version": "3.0.0-nightly.1779+afb946c4a",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "types": "src/index.d.ts",
@@ -14,5 +14,5 @@
14
14
  "publishConfig": {
15
15
  "access": "public"
16
16
  },
17
- "gitHead": "00c313323581ca010123f94e464f48d71cd47d8d"
17
+ "gitHead": "afb946c4ab759b0dd19e024f8c0768d382134a7b"
18
18
  }
package/src/dnd.d.ts CHANGED
@@ -114,6 +114,39 @@ interface DroppableCollectionDropEvent extends DropEvent {
114
114
  target: DropTarget
115
115
  }
116
116
 
117
+ interface DroppableCollectionInsertDropEvent {
118
+ items: DropItem[],
119
+ dropOperation: DropOperation,
120
+ target: {
121
+ key: Key,
122
+ dropPosition: Omit<DropPosition, 'on'>
123
+ }
124
+ }
125
+
126
+ interface DroppableCollectionRootDropEvent {
127
+ items: DropItem[],
128
+ dropOperation: DropOperation
129
+ }
130
+
131
+ interface DroppableCollectionOnItemDropEvent {
132
+ items: DropItem[],
133
+ dropOperation: DropOperation,
134
+ isInternalDrop: boolean,
135
+ target: {
136
+ key: Key,
137
+ dropPosition: 'on'
138
+ }
139
+ }
140
+
141
+ interface DroppableCollectionReorderEvent {
142
+ keys: Set<Key>,
143
+ dropOperation: DropOperation,
144
+ target: {
145
+ key: Key,
146
+ dropPosition: Omit<DropPosition, 'on'>
147
+ }
148
+ }
149
+
117
150
  export interface DragTypes {
118
151
  has(type: string): boolean
119
152
  }
@@ -142,7 +175,31 @@ export interface DroppableCollectionProps {
142
175
  /** Handler that is called when a valid drag exits the drop target. */
143
176
  onDropExit?: (e: DroppableCollectionExitEvent) => void,
144
177
  /** Handler that is called when a valid drag is dropped on the drop target. */
145
- onDrop?: (e: DroppableCollectionDropEvent) => void
178
+ onDrop?: (e: DroppableCollectionDropEvent) => void,
179
+ /**
180
+ * Handler called when external items are dropped "between" the droppable collection's items.
181
+ */
182
+ onInsert?: (e: DroppableCollectionInsertDropEvent) => void,
183
+ /**
184
+ * Handler called when external items are dropped on the droppable collection's root.
185
+ */
186
+ onRootDrop?: (e: DroppableCollectionRootDropEvent) => void,
187
+ /**
188
+ * Handler called when items are dropped "on" a droppable collection's item.
189
+ */
190
+ onItemDrop?: (e: DroppableCollectionOnItemDropEvent) => void,
191
+ /**
192
+ * Handler called when items are reordered via drag in the source collection.
193
+ */
194
+ onReorder?: (e: DroppableCollectionReorderEvent) => void,
195
+ /**
196
+ * The drag types that the droppable collection accepts. If your collection accepts directories, include 'directory' in your array of allowed types.
197
+ */
198
+ acceptedDragTypes?: 'all' | Array<string>,
199
+ /**
200
+ * A function returning whether a given target in the droppable collection is a valid "on" drop target for the current drag types.
201
+ */
202
+ shouldAcceptItemDrop?: (target: ItemDropTarget, types: DragTypes) => boolean
146
203
  }
147
204
 
148
205
  interface DraggableCollectionStartEvent extends DragStartEvent {
@@ -154,7 +211,8 @@ interface DraggableCollectionMoveEvent extends DragMoveEvent {
154
211
  }
155
212
 
156
213
  interface DraggableCollectionEndEvent extends DragEndEvent {
157
- keys: Set<Key>
214
+ keys: Set<Key>,
215
+ isInternalDrop: boolean
158
216
  }
159
217
 
160
218
  export type DragPreviewRenderer = (items: DragItem[], callback: (node: HTMLElement) => void) => void;