@atlaskit/pragmatic-drag-and-drop 1.1.1 → 1.1.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/pragmatic-drag-and-drop
2
2
 
3
+ ## 1.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#84398](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/84398) [`77694db987fc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/77694db987fc) - Public release of Pragmatic drag and drop documentation
8
+
9
+ ## 1.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#84047](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/84047) [`72a86ac4a940`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/72a86ac4a940) - Removing experimental `DropData` from `onDrop()`. Exposing the native `dropEffect` turned out to problematic, as you will always get a `"none"` drop effect if dropping externally if the original `draggable` was removed (a native `"dragend"` event is targetted at the original draggable). This made the weak signal of `dropEffect` for even weaker and more problematic. In order to not create footguns for folks, we have decided to remove this experimental API for now. We can explore adding the API back in the future if folks think it would be valuable.
14
+
3
15
  ## 1.1.1
4
16
 
5
17
  ### Patch Changes
@@ -14,19 +26,7 @@
14
26
 
15
27
  ### Minor Changes
16
28
 
17
- - [#82653](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/82653) [`136d8da5542d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/136d8da5542d) - Adding additional information to `onDrop()` events to expose what the final `dropEffect` was for a drag operation.
18
-
19
- ```ts
20
- type DropData = {
21
- dropEffect: DataTransfer['dropEffect'];
22
- };
23
-
24
- monitorForElements({
25
- onDrop(payload) {
26
- const drop: DropData = payload.drop;
27
- },
28
- });
29
- ```
29
+ - [#82653](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/82653) [`136d8da5542d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/136d8da5542d) - _Experimental_: Adding additional information to `onDrop()` events to expose what the final `dropEffect` was for a drag operation (_now removed_)
30
30
 
31
31
  Fixing a bug where `preventUnhandled.start()` would prevent unhandled drag operations forever. It now only prevents unhandled drag operations for the current drag operation. `preventUnhandled.stop()` is now optional, as `preventUnhandled.start()` now tidies up itself. You can still leverage `preventUnhandled.stop()` to stop preventing unhandled drag operations during a drag.
32
32
 
@@ -112,14 +112,12 @@ function makeDispatch(_ref) {
112
112
  },
113
113
  drop: function drop(_ref5) {
114
114
  var current = _ref5.current,
115
- drop = _ref5.drop,
116
115
  updatedSourcePayload = _ref5.updatedSourcePayload;
117
116
  dragStart.flush();
118
117
  scheduleOnDrag.cancel();
119
118
  safeDispatch({
120
119
  eventName: 'onDrop',
121
120
  payload: {
122
- drop: drop,
123
121
  source: updatedSourcePayload !== null && updatedSourcePayload !== void 0 ? updatedSourcePayload : source,
124
122
  location: {
125
123
  current: current,
@@ -107,7 +107,7 @@ function start(_ref2) {
107
107
  input: input
108
108
  });
109
109
  }
110
- function cancel(drop) {
110
+ function cancel() {
111
111
  // The spec behaviour is that when a drag is cancelled, or when dropping on no drop targets,
112
112
  // a "dragleave" event is fired on the active drop target before a "dragend" event.
113
113
  // We are replicating that behaviour in `cancel` if there are any active drop targets to
@@ -124,7 +124,6 @@ function start(_ref2) {
124
124
  }
125
125
  dispatch.drop({
126
126
  current: state.current,
127
- drop: drop,
128
127
  updatedSourcePayload: null
129
128
  });
130
129
  finish();
@@ -216,15 +215,12 @@ function start(_ref2) {
216
215
  dropTargets: []
217
216
  });
218
217
  if (dragType.startedFrom === 'external') {
219
- cancel({
220
- dropEffect: 'none'
221
- });
218
+ cancel();
222
219
  }
223
220
  }
224
221
  }, {
225
222
  type: 'drop',
226
223
  listener: function listener(event) {
227
- var _event$dataTransfer$d, _event$dataTransfer;
228
224
  // A "drop" can only happen if the browser allowed the drop
229
225
 
230
226
  // Accepting drop operation.
@@ -238,11 +234,6 @@ function start(_ref2) {
238
234
  });
239
235
  dispatch.drop({
240
236
  current: state.current,
241
- drop: {
242
- // At this point the dropEffect has been set on the event
243
- // (if we have set it), so we can read it from there
244
- dropEffect: (_event$dataTransfer$d = (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.dropEffect) !== null && _event$dataTransfer$d !== void 0 ? _event$dataTransfer$d : 'none'
245
- },
246
237
  // When dropping something native, we need to extract the latest
247
238
  // `.items` from the "drop" event as it is now accessible
248
239
  updatedSourcePayload: dragType.type === 'external' ? dragType.getDropPayload(event) : null
@@ -268,16 +259,7 @@ function start(_ref2) {
268
259
  // as we will have already removed the event listener
269
260
  type: 'dragend',
270
261
  listener: function listener(event) {
271
- var _event$dataTransfer$d2, _event$dataTransfer2;
272
- // The `dropEffect` will be:
273
- // - "none" if dropped on no drop targets
274
- // - "none" if cancelled locally
275
- // - "none" if cancelled externally
276
- // - "none" if `preventUnhandled` is used (and there is no drop target)
277
- // - [not "none"] if accepted externally
278
- cancel({
279
- dropEffect: (_event$dataTransfer$d2 = (_event$dataTransfer2 = event.dataTransfer) === null || _event$dataTransfer2 === void 0 ? void 0 : _event$dataTransfer2.dropEffect) !== null && _event$dataTransfer$d2 !== void 0 ? _event$dataTransfer$d2 : 'none'
280
- });
262
+ cancel();
281
263
 
282
264
  // Applying this fix after `dispatch.drop` so that frameworks have the opportunity
283
265
  // to update UI in response to a "onDrop".
@@ -288,11 +270,7 @@ function start(_ref2) {
288
270
  }
289
271
  }
290
272
  }].concat((0, _toConsumableArray2.default)((0, _detectBrokenDrag.getBindingsForBrokenDrags)({
291
- onDragEnd: function onDragEnd() {
292
- return cancel({
293
- dropEffect: 'none'
294
- });
295
- }
273
+ onDragEnd: cancel
296
274
  }))),
297
275
  // Once we have started a managed drag operation it is important that we see / own all drag events
298
276
  // We got one adoption bug pop up where some code was stopping (`event.stopPropagation()`)
@@ -107,7 +107,6 @@ export function makeDispatch({
107
107
  },
108
108
  drop({
109
109
  current,
110
- drop,
111
110
  updatedSourcePayload
112
111
  }) {
113
112
  dragStart.flush();
@@ -115,7 +114,6 @@ export function makeDispatch({
115
114
  safeDispatch({
116
115
  eventName: 'onDrop',
117
116
  payload: {
118
- drop,
119
117
  source: updatedSourcePayload !== null && updatedSourcePayload !== void 0 ? updatedSourcePayload : source,
120
118
  location: {
121
119
  current,
@@ -101,7 +101,7 @@ function start({
101
101
  input
102
102
  });
103
103
  }
104
- function cancel(drop) {
104
+ function cancel() {
105
105
  // The spec behaviour is that when a drag is cancelled, or when dropping on no drop targets,
106
106
  // a "dragleave" event is fired on the active drop target before a "dragend" event.
107
107
  // We are replicating that behaviour in `cancel` if there are any active drop targets to
@@ -118,7 +118,6 @@ function start({
118
118
  }
119
119
  dispatch.drop({
120
120
  current: state.current,
121
- drop,
122
121
  updatedSourcePayload: null
123
122
  });
124
123
  finish();
@@ -210,15 +209,12 @@ function start({
210
209
  dropTargets: []
211
210
  });
212
211
  if (dragType.startedFrom === 'external') {
213
- cancel({
214
- dropEffect: 'none'
215
- });
212
+ cancel();
216
213
  }
217
214
  }
218
215
  }, {
219
216
  type: 'drop',
220
217
  listener(event) {
221
- var _event$dataTransfer$d, _event$dataTransfer;
222
218
  // A "drop" can only happen if the browser allowed the drop
223
219
 
224
220
  // Accepting drop operation.
@@ -232,11 +228,6 @@ function start({
232
228
  });
233
229
  dispatch.drop({
234
230
  current: state.current,
235
- drop: {
236
- // At this point the dropEffect has been set on the event
237
- // (if we have set it), so we can read it from there
238
- dropEffect: (_event$dataTransfer$d = (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.dropEffect) !== null && _event$dataTransfer$d !== void 0 ? _event$dataTransfer$d : 'none'
239
- },
240
231
  // When dropping something native, we need to extract the latest
241
232
  // `.items` from the "drop" event as it is now accessible
242
233
  updatedSourcePayload: dragType.type === 'external' ? dragType.getDropPayload(event) : null
@@ -262,16 +253,7 @@ function start({
262
253
  // as we will have already removed the event listener
263
254
  type: 'dragend',
264
255
  listener(event) {
265
- var _event$dataTransfer$d2, _event$dataTransfer2;
266
- // The `dropEffect` will be:
267
- // - "none" if dropped on no drop targets
268
- // - "none" if cancelled locally
269
- // - "none" if cancelled externally
270
- // - "none" if `preventUnhandled` is used (and there is no drop target)
271
- // - [not "none"] if accepted externally
272
- cancel({
273
- dropEffect: (_event$dataTransfer$d2 = (_event$dataTransfer2 = event.dataTransfer) === null || _event$dataTransfer2 === void 0 ? void 0 : _event$dataTransfer2.dropEffect) !== null && _event$dataTransfer$d2 !== void 0 ? _event$dataTransfer$d2 : 'none'
274
- });
256
+ cancel();
275
257
 
276
258
  // Applying this fix after `dispatch.drop` so that frameworks have the opportunity
277
259
  // to update UI in response to a "onDrop".
@@ -282,9 +264,7 @@ function start({
282
264
  }
283
265
  }
284
266
  }, ...getBindingsForBrokenDrags({
285
- onDragEnd: () => cancel({
286
- dropEffect: 'none'
287
- })
267
+ onDragEnd: cancel
288
268
  })],
289
269
  // Once we have started a managed drag operation it is important that we see / own all drag events
290
270
  // We got one adoption bug pop up where some code was stopping (`event.stopPropagation()`)
@@ -105,14 +105,12 @@ export function makeDispatch(_ref) {
105
105
  },
106
106
  drop: function drop(_ref5) {
107
107
  var current = _ref5.current,
108
- drop = _ref5.drop,
109
108
  updatedSourcePayload = _ref5.updatedSourcePayload;
110
109
  dragStart.flush();
111
110
  scheduleOnDrag.cancel();
112
111
  safeDispatch({
113
112
  eventName: 'onDrop',
114
113
  payload: {
115
- drop: drop,
116
114
  source: updatedSourcePayload !== null && updatedSourcePayload !== void 0 ? updatedSourcePayload : source,
117
115
  location: {
118
116
  current: current,
@@ -100,7 +100,7 @@ function start(_ref2) {
100
100
  input: input
101
101
  });
102
102
  }
103
- function cancel(drop) {
103
+ function cancel() {
104
104
  // The spec behaviour is that when a drag is cancelled, or when dropping on no drop targets,
105
105
  // a "dragleave" event is fired on the active drop target before a "dragend" event.
106
106
  // We are replicating that behaviour in `cancel` if there are any active drop targets to
@@ -117,7 +117,6 @@ function start(_ref2) {
117
117
  }
118
118
  dispatch.drop({
119
119
  current: state.current,
120
- drop: drop,
121
120
  updatedSourcePayload: null
122
121
  });
123
122
  finish();
@@ -209,15 +208,12 @@ function start(_ref2) {
209
208
  dropTargets: []
210
209
  });
211
210
  if (dragType.startedFrom === 'external') {
212
- cancel({
213
- dropEffect: 'none'
214
- });
211
+ cancel();
215
212
  }
216
213
  }
217
214
  }, {
218
215
  type: 'drop',
219
216
  listener: function listener(event) {
220
- var _event$dataTransfer$d, _event$dataTransfer;
221
217
  // A "drop" can only happen if the browser allowed the drop
222
218
 
223
219
  // Accepting drop operation.
@@ -231,11 +227,6 @@ function start(_ref2) {
231
227
  });
232
228
  dispatch.drop({
233
229
  current: state.current,
234
- drop: {
235
- // At this point the dropEffect has been set on the event
236
- // (if we have set it), so we can read it from there
237
- dropEffect: (_event$dataTransfer$d = (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.dropEffect) !== null && _event$dataTransfer$d !== void 0 ? _event$dataTransfer$d : 'none'
238
- },
239
230
  // When dropping something native, we need to extract the latest
240
231
  // `.items` from the "drop" event as it is now accessible
241
232
  updatedSourcePayload: dragType.type === 'external' ? dragType.getDropPayload(event) : null
@@ -261,16 +252,7 @@ function start(_ref2) {
261
252
  // as we will have already removed the event listener
262
253
  type: 'dragend',
263
254
  listener: function listener(event) {
264
- var _event$dataTransfer$d2, _event$dataTransfer2;
265
- // The `dropEffect` will be:
266
- // - "none" if dropped on no drop targets
267
- // - "none" if cancelled locally
268
- // - "none" if cancelled externally
269
- // - "none" if `preventUnhandled` is used (and there is no drop target)
270
- // - [not "none"] if accepted externally
271
- cancel({
272
- dropEffect: (_event$dataTransfer$d2 = (_event$dataTransfer2 = event.dataTransfer) === null || _event$dataTransfer2 === void 0 ? void 0 : _event$dataTransfer2.dropEffect) !== null && _event$dataTransfer$d2 !== void 0 ? _event$dataTransfer$d2 : 'none'
273
- });
255
+ cancel();
274
256
 
275
257
  // Applying this fix after `dispatch.drop` so that frameworks have the opportunity
276
258
  // to update UI in response to a "onDrop".
@@ -281,11 +263,7 @@ function start(_ref2) {
281
263
  }
282
264
  }
283
265
  }].concat(_toConsumableArray(getBindingsForBrokenDrags({
284
- onDragEnd: function onDragEnd() {
285
- return cancel({
286
- dropEffect: 'none'
287
- });
288
- }
266
+ onDragEnd: cancel
289
267
  }))),
290
268
  // Once we have started a managed drag operation it is important that we see / own all drag events
291
269
  // We got one adoption bug pop up where some code was stopping (`event.stopPropagation()`)
@@ -1 +1 @@
1
- export type { DropTargetAllowedDropEffect, DropTargetRecord, Position, Input, DragLocation, DragLocationHistory, DropData, CleanupFn, AllDragTypes, MonitorArgs, BaseEventPayload, ElementDragType, TextSelectionDragType, ExternalDragType, } from '../internal-types';
1
+ export type { DropTargetAllowedDropEffect, DropTargetRecord, Position, Input, DragLocation, DragLocationHistory, CleanupFn, AllDragTypes, MonitorArgs, BaseEventPayload, ElementDragType, TextSelectionDragType, ExternalDragType, } from '../internal-types';
@@ -193,9 +193,6 @@ export type BaseEventPayload<DragType extends AllDragTypes> = {
193
193
  */
194
194
  source: DragType['payload'];
195
195
  };
196
- export type DropData = {
197
- dropEffect: DataTransfer['dropEffect'];
198
- };
199
196
  export type EventPayloadMap<DragType extends AllDragTypes> = {
200
197
  /**
201
198
  * Drag is about to start.
@@ -231,9 +228,7 @@ export type EventPayloadMap<DragType extends AllDragTypes> = {
231
228
  *
232
229
  * The `location.current` property will accurately contain the final drop targets.
233
230
  */
234
- onDrop: BaseEventPayload<DragType> & {
235
- drop: DropData;
236
- };
231
+ onDrop: BaseEventPayload<DragType>;
237
232
  };
238
233
  export type AllEvents<DragType extends AllDragTypes> = {
239
234
  [EventName in keyof EventPayloadMap<DragType>]: (args: EventPayloadMap<DragType>[EventName]) => void;
@@ -1,4 +1,4 @@
1
- import { AllDragTypes, DragLocation, DropData, EventPayloadMap } from '../internal-types';
1
+ import { AllDragTypes, DragLocation, EventPayloadMap } from '../internal-types';
2
2
  export declare function makeDispatch<DragType extends AllDragTypes>({ source, initial, dispatchEvent, }: {
3
3
  source: DragType['payload'];
4
4
  initial: DragLocation;
@@ -16,9 +16,8 @@ export declare function makeDispatch<DragType extends AllDragTypes>({ source, in
16
16
  drag({ current }: {
17
17
  current: DragLocation;
18
18
  }): void;
19
- drop({ current, drop, updatedSourcePayload, }: {
19
+ drop({ current, updatedSourcePayload, }: {
20
20
  current: DragLocation;
21
- drop: DropData;
22
21
  /** When dragging from an external source, we need to collect the
23
22
  drag source information again as it is often only available during
24
23
  the "drop" event */
@@ -1 +1 @@
1
- export type { DropTargetAllowedDropEffect, DropTargetRecord, Position, Input, DragLocation, DragLocationHistory, DropData, CleanupFn, AllDragTypes, MonitorArgs, BaseEventPayload, ElementDragType, TextSelectionDragType, ExternalDragType, } from '../internal-types';
1
+ export type { DropTargetAllowedDropEffect, DropTargetRecord, Position, Input, DragLocation, DragLocationHistory, CleanupFn, AllDragTypes, MonitorArgs, BaseEventPayload, ElementDragType, TextSelectionDragType, ExternalDragType, } from '../internal-types';
@@ -193,9 +193,6 @@ export type BaseEventPayload<DragType extends AllDragTypes> = {
193
193
  */
194
194
  source: DragType['payload'];
195
195
  };
196
- export type DropData = {
197
- dropEffect: DataTransfer['dropEffect'];
198
- };
199
196
  export type EventPayloadMap<DragType extends AllDragTypes> = {
200
197
  /**
201
198
  * Drag is about to start.
@@ -231,9 +228,7 @@ export type EventPayloadMap<DragType extends AllDragTypes> = {
231
228
  *
232
229
  * The `location.current` property will accurately contain the final drop targets.
233
230
  */
234
- onDrop: BaseEventPayload<DragType> & {
235
- drop: DropData;
236
- };
231
+ onDrop: BaseEventPayload<DragType>;
237
232
  };
238
233
  export type AllEvents<DragType extends AllDragTypes> = {
239
234
  [EventName in keyof EventPayloadMap<DragType>]: (args: EventPayloadMap<DragType>[EventName]) => void;
@@ -1,4 +1,4 @@
1
- import { AllDragTypes, DragLocation, DropData, EventPayloadMap } from '../internal-types';
1
+ import { AllDragTypes, DragLocation, EventPayloadMap } from '../internal-types';
2
2
  export declare function makeDispatch<DragType extends AllDragTypes>({ source, initial, dispatchEvent, }: {
3
3
  source: DragType['payload'];
4
4
  initial: DragLocation;
@@ -16,9 +16,8 @@ export declare function makeDispatch<DragType extends AllDragTypes>({ source, in
16
16
  drag({ current }: {
17
17
  current: DragLocation;
18
18
  }): void;
19
- drop({ current, drop, updatedSourcePayload, }: {
19
+ drop({ current, updatedSourcePayload, }: {
20
20
  current: DragLocation;
21
- drop: DropData;
22
21
  /** When dragging from an external source, we need to collect the
23
22
  drag source information again as it is often only available during
24
23
  the "drop" event */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/pragmatic-drag-and-drop",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "The core package for Pragmatic drag and drop - enabling fast drag and drop for any experience on any tech stack",
5
5
  "repository": "https://github.com/atlassian/pragmatic-drag-and-drop",
6
6
  "author": "Atlassian Pty Ltd",
@@ -28,10 +28,7 @@
28
28
  "releaseModel": "continuous",
29
29
  "website": {
30
30
  "name": "Core",
31
- "category": "Libraries",
32
- "status": {
33
- "type": "alpha"
34
- }
31
+ "category": "Libraries"
35
32
  },
36
33
  "integrationTests": {
37
34
  "additionalBrowsers": [