@atlaskit/pragmatic-drag-and-drop 0.22.0 → 0.24.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +66 -28
  2. package/constellation/index/about.mdx +4 -2
  3. package/dist/cjs/adapter/element-adapter.js +4 -6
  4. package/dist/cjs/adapter/file-adapter.js +3 -5
  5. package/dist/cjs/addon/cancel-unhandled.js +4 -5
  6. package/dist/cjs/entry-point/util/preserve-offset-on-source.js +12 -0
  7. package/dist/cjs/experimental/cross-window-element-adapter.js +2 -4
  8. package/dist/cjs/index.js +1 -2
  9. package/dist/cjs/ledger/lifecycle-manager.js +2 -3
  10. package/dist/cjs/make-adapter/make-adapter.js +1 -1
  11. package/dist/cjs/make-adapter/make-drop-target.js +7 -7
  12. package/dist/cjs/make-adapter/make-monitor.js +3 -3
  13. package/dist/cjs/util/custom-native-drag-preview/center-under-pointer.js +2 -3
  14. package/dist/cjs/util/custom-native-drag-preview/{preserve-offset-from-pointer.js → preserve-offset-on-source.js} +4 -4
  15. package/dist/cjs/util/custom-native-drag-preview/set-custom-native-drag-preview.js +2 -2
  16. package/dist/cjs/util/fix-post-drag-pointer-bug.js +2 -2
  17. package/dist/es2019/entry-point/util/preserve-offset-on-source.js +1 -0
  18. package/dist/es2019/util/custom-native-drag-preview/{preserve-offset-from-pointer.js → preserve-offset-on-source.js} +3 -3
  19. package/dist/esm/adapter/element-adapter.js +2 -2
  20. package/dist/esm/addon/cancel-unhandled.js +2 -2
  21. package/dist/esm/entry-point/util/preserve-offset-on-source.js +1 -0
  22. package/dist/esm/make-adapter/make-adapter.js +1 -1
  23. package/dist/esm/make-adapter/make-drop-target.js +7 -7
  24. package/dist/esm/make-adapter/make-monitor.js +3 -3
  25. package/dist/esm/util/custom-native-drag-preview/{preserve-offset-from-pointer.js → preserve-offset-on-source.js} +3 -3
  26. package/dist/esm/util/custom-native-drag-preview/set-custom-native-drag-preview.js +2 -2
  27. package/dist/esm/util/fix-post-drag-pointer-bug.js +2 -2
  28. package/dist/types/entry-point/util/preserve-offset-on-source.d.ts +1 -0
  29. package/dist/types/util/custom-native-drag-preview/{preserve-offset-from-pointer.d.ts → preserve-offset-on-source.d.ts} +2 -2
  30. package/dist/types-ts4.5/entry-point/util/preserve-offset-on-source.d.ts +1 -0
  31. package/dist/types-ts4.5/util/custom-native-drag-preview/{preserve-offset-from-pointer.d.ts → preserve-offset-on-source.d.ts} +2 -2
  32. package/package.json +10 -3
  33. package/util/preserve-offset-on-source/package.json +15 -0
  34. package/dist/cjs/entry-point/util/preserve-offset-from-pointer.js +0 -12
  35. package/dist/es2019/entry-point/util/preserve-offset-from-pointer.js +0 -1
  36. package/dist/esm/entry-point/util/preserve-offset-from-pointer.js +0 -1
  37. package/dist/types/entry-point/util/preserve-offset-from-pointer.d.ts +0 -1
  38. package/dist/types-ts4.5/entry-point/util/preserve-offset-from-pointer.d.ts +0 -1
  39. package/util/preserve-offset-from-pointer/package.json +0 -15
package/CHANGELOG.md CHANGED
@@ -1,10 +1,48 @@
1
1
  # @atlaskit/pragmatic-drag-and-drop
2
2
 
3
+ ## 0.24.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#39935](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39935) [`03b91562fec`](https://bitbucket.org/atlassian/atlassian-frontend/commits/03b91562fec) - Exposing `AllDragTypes` type. This was previously an internal type, but it provided helpful to expose for our new auto scroller. `AllDragTypes` is helpful if you need a function to work with either `element` or `file` drag operations.
8
+
9
+ ## 0.23.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#38713](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/38713) [`3da89e29dfc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3da89e29dfc) - We have renamed and tweaked the recently added `setCustomNativeDragPreview` `getOffset` utility `preserveOffsetFromPointer` to be a bit easier to understand what it is doing.
14
+
15
+ ```diff
16
+ - import { preserveOffsetFromPointer } from '@atlaskit/pragmatic-drag-and-drop/util/preserve-offset-from-pointer';
17
+ + import { preserveOffsetOnSource } from '@atlaskit/pragmatic-drag-and-drop/util/preserve-offset-on-source';
18
+
19
+ draggable({
20
+ element: myElement,
21
+ onGenerateDragPreview: ({ nativeSetDragImage, location, source }) => {
22
+ setCustomNativeDragPreview({
23
+ - getOffset: preserveOffsetFromPointer({
24
+ + 'preserveOffsetOnSource' is a more accurate description of what is being achieved
25
+ + getOffset: preserveOffsetOnSource({
26
+ - sourceElement: source.element,
27
+ + // no longer including 'source' in argument name
28
+ + // as it is implied by the function name
29
+ + element: source.element,
30
+ input: location.current.input,
31
+ }),
32
+ render: function render({ container }) {
33
+ /* ... */
34
+ },
35
+ nativeSetDragImage,
36
+ });
37
+ },
38
+ });
39
+ ```
40
+
3
41
  ## 0.22.0
4
42
 
5
43
  ### Minor Changes
6
44
 
7
- - [`d644a68ddf6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d644a68ddf6) - Added a new `setCustomNativeDragPreview` `getOffset` utililiy: `preserveOffsetFromPointer`. `preserveOffsetFromPointer` mimics the default behaviour for non custom drag previews when starting a drag: the initial cursor position offset is preserved for a seamless drag and drop experience.
45
+ - [#38397](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/38397) [`d644a68ddf6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d644a68ddf6) - Added a new `setCustomNativeDragPreview` `getOffset` utility: `preserveOffsetFromPointer`. `preserveOffsetFromPointer` mimics the default behaviour for non custom drag previews when starting a drag: the initial cursor position offset is preserved for a seamless drag and drop experience.
8
46
 
9
47
  ```ts
10
48
  import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview';
@@ -31,7 +69,7 @@
31
69
 
32
70
  ### Minor Changes
33
71
 
34
- - [`de7463c7096`](https://bitbucket.org/atlassian/atlassian-frontend/commits/de7463c7096) - Exposing some additional TypeScript types. These can be helpful when creating helper packages.
72
+ - [#38525](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/38525) [`de7463c7096`](https://bitbucket.org/atlassian/atlassian-frontend/commits/de7463c7096) - Exposing some additional TypeScript types. These can be helpful when creating helper packages.
35
73
 
36
74
  ```ts
37
75
  import type {
@@ -51,7 +89,7 @@
51
89
 
52
90
  ### Minor Changes
53
91
 
54
- - [`554a6d8cc34`](https://bitbucket.org/atlassian/atlassian-frontend/commits/554a6d8cc34) - ### Stickiness algorithm improvement
92
+ - [#38453](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/38453) [`554a6d8cc34`](https://bitbucket.org/atlassian/atlassian-frontend/commits/554a6d8cc34) - ### Stickiness algorithm improvement
55
93
 
56
94
  We have made some improvements to the drop target stickiness algorithm to allow sticky drop targets that are no longer dragged over to cancel their stickiness.
57
95
 
@@ -95,7 +133,7 @@
95
133
 
96
134
  ### Minor Changes
97
135
 
98
- - [`8c301a251e4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8c301a251e4) - We have changed the API of `setCustomNativeDragPreview()` to allow increased control and slightly lower bundles as well.
136
+ - [#35574](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/35574) [`8c301a251e4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8c301a251e4) - We have changed the API of `setCustomNativeDragPreview()` to allow increased control and slightly lower bundles as well.
99
137
 
100
138
  We have removed the `placement` argument, and replaced it with `getOffset()`.
101
139
 
@@ -158,25 +196,25 @@
158
196
 
159
197
  ### Patch Changes
160
198
 
161
- - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
199
+ - [#33793](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33793) [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
162
200
 
163
201
  ## 0.18.1
164
202
 
165
203
  ### Patch Changes
166
204
 
167
- - [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
205
+ - [#33649](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33649) [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
168
206
 
169
207
  ## 0.18.0
170
208
 
171
209
  ### Minor Changes
172
210
 
173
- - [`9fd8556db17`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9fd8556db17) - Internal folder name structure change
211
+ - [#33344](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33344) [`9fd8556db17`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9fd8556db17) - Internal folder name structure change
174
212
 
175
213
  ## 0.17.0
176
214
 
177
215
  ### Minor Changes
178
216
 
179
- - [`34ed7b2ec63`](https://bitbucket.org/atlassian/atlassian-frontend/commits/34ed7b2ec63) - We have changed the name of our drag and drop packages to align on the single name of "Pragmatic drag and drop"
217
+ - [#33262](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33262) [`34ed7b2ec63`](https://bitbucket.org/atlassian/atlassian-frontend/commits/34ed7b2ec63) - We have changed the name of our drag and drop packages to align on the single name of "Pragmatic drag and drop"
180
218
 
181
219
  ```diff
182
220
  - @atlaskit/drag-and-drop
@@ -208,25 +246,25 @@
208
246
 
209
247
  ### Minor Changes
210
248
 
211
- - [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip minor dependency bump
249
+ - [#33258](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33258) [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip minor dependency bump
212
250
 
213
251
  ## 0.15.1
214
252
 
215
253
  ### Patch Changes
216
254
 
217
- - [`2e01c9c74b5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2e01c9c74b5) - DUMMY remove before merging to master; dupe adf-schema via adf-utils
255
+ - [#32424](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/32424) [`2e01c9c74b5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2e01c9c74b5) - DUMMY remove before merging to master; dupe adf-schema via adf-utils
218
256
 
219
257
  ## 0.15.0
220
258
 
221
259
  ### Minor Changes
222
260
 
223
- - [`ed028658f13`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ed028658f13) - Minor internal refactor and adding additional tests
261
+ - [#31909](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31909) [`ed028658f13`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ed028658f13) - Minor internal refactor and adding additional tests
224
262
 
225
263
  ## 0.14.0
226
264
 
227
265
  ### Minor Changes
228
266
 
229
- - [`eab6d26451d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eab6d26451d) - Improving the resilience of our workaround for a [Browser bug](https://bugs.chromium.org/p/chromium/issues/detail?id=410328) where after a drag finishes, an unrelated element can be entered into.
267
+ - [#31794](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31794) [`eab6d26451d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eab6d26451d) - Improving the resilience of our workaround for a [Browser bug](https://bugs.chromium.org/p/chromium/issues/detail?id=410328) where after a drag finishes, an unrelated element can be entered into.
230
268
  - [`ba7ea570aee`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ba7ea570aee) - > Both of these changes should not impact most consumers as they are targeted at edge cases.
231
269
 
232
270
  - **Fix**: We no longer extract user input (eg `clientX`) from native `"dragleave"` events due to a [Bug with Chrome we discovered](https://bugs.chromium.org/p/chromium/issues/detail?id=1429937). Due to this bug, it was possible for `location.current.input` to be incorrectly set in `onDropTargetChange` and `onDrop` when a user was cancelling a drag or dropping or no drop targets.
@@ -237,7 +275,7 @@
237
275
 
238
276
  ### Minor Changes
239
277
 
240
- - [`2582df26509`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2582df26509) - Fixing a browser bug where after a drag finishes, a unrelated element can be entered into by the browser
278
+ - [#30879](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30879) [`2582df26509`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2582df26509) - Fixing a browser bug where after a drag finishes, a unrelated element can be entered into by the browser
241
279
 
242
280
  - [Visual explanation of bug](https://twitter.com/alexandereardon/status/1633614212873465856)
243
281
  - [Chrome bug](https://bugs.chromium.org/p/chromium/issues/detail?id=410328)
@@ -246,7 +284,7 @@
246
284
 
247
285
  ### Minor Changes
248
286
 
249
- - [`90901f5bbe0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/90901f5bbe0) - Replace default entry point of `undefined` with `{}`.
287
+ - [#30953](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30953) [`90901f5bbe0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/90901f5bbe0) - Replace default entry point of `undefined` with `{}`.
250
288
 
251
289
  > **NOTE:** Importing from the default entry point isn't supported.
252
290
  > _Please use individual entry points in order to always obtain minimum kbs._
@@ -255,7 +293,7 @@
255
293
 
256
294
  ### Minor Changes
257
295
 
258
- - [`1ecbb19d450`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1ecbb19d450) - Adding a new function to make creating _custom_ native drag previews safe and easy: `setCustomNativeDragPreview`
296
+ - [#30668](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/30668) [`1ecbb19d450`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1ecbb19d450) - Adding a new function to make creating _custom_ native drag previews safe and easy: `setCustomNativeDragPreview`
259
297
 
260
298
  ```tsx
261
299
  import { setCustomNativeDragPreview } from '@atlaskit/drag-and-drop/util/set-custom-native-drag-preview';
@@ -282,7 +320,7 @@
282
320
 
283
321
  ### Minor Changes
284
322
 
285
- - [`9c0975e2fab`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9c0975e2fab) - Bug fix: A _monitor_ should not be called after it is removed. Previously, if a _monitor_ (monitor 1) removed another _monitor_ (monitor 2) for the same event, then the second monitor (monitor 2) would still be called. This has been fixed
323
+ - [#29951](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/29951) [`9c0975e2fab`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9c0975e2fab) - Bug fix: A _monitor_ should not be called after it is removed. Previously, if a _monitor_ (monitor 1) removed another _monitor_ (monitor 2) for the same event, then the second monitor (monitor 2) would still be called. This has been fixed
286
324
 
287
325
  ```ts
288
326
  const cleanupMonitor1 = monitorForElements({
@@ -300,7 +338,7 @@
300
338
 
301
339
  ### Minor Changes
302
340
 
303
- - [`03e0aa5ae85`](https://bitbucket.org/atlassian/atlassian-frontend/commits/03e0aa5ae85) - `@atlaskit/drag-and-drop` adds event listeners to the `window` during a drag operation. These drag operation event listeners were [`bubble` phase event listeners](https://domevents.dev/), but they are now `capture` phase event listeners to be more resliant against external code (incorrectly) stopping events.
341
+ - [#29651](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/29651) [`03e0aa5ae85`](https://bitbucket.org/atlassian/atlassian-frontend/commits/03e0aa5ae85) - `@atlaskit/drag-and-drop` adds event listeners to the `window` during a drag operation. These drag operation event listeners were [`bubble` phase event listeners](https://domevents.dev/), but they are now `capture` phase event listeners to be more resliant against external code (incorrectly) stopping events.
304
342
 
305
343
  This does not impact the ability of a consumer to have their own `draggable`s on a page not controlled by `@atlaskit/drag-and-drop`
306
344
 
@@ -308,49 +346,49 @@
308
346
 
309
347
  ### Patch Changes
310
348
 
311
- - [`6455cf006b3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6455cf006b3) - Builds for this package now pass through a tokens babel plugin, removing runtime invocations of the tokens() function and improving performance.
349
+ - [#28324](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/28324) [`6455cf006b3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6455cf006b3) - Builds for this package now pass through a tokens babel plugin, removing runtime invocations of the tokens() function and improving performance.
312
350
 
313
351
  ## 0.8.0
314
352
 
315
353
  ### Minor Changes
316
354
 
317
- - [`1e3f9743e57`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1e3f9743e57) - A _monitor_ that is added during an event (eg `onDragStart`) will no longer be called for the current event. This is to prevent the accidental creation of infinite loops. This behaviour matches native [`EventTargets`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) where an event listener cannot add another event listener during an active event to the same event target in the same event phase.
355
+ - [#26317](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/26317) [`1e3f9743e57`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1e3f9743e57) - A _monitor_ that is added during an event (eg `onDragStart`) will no longer be called for the current event. This is to prevent the accidental creation of infinite loops. This behaviour matches native [`EventTargets`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) where an event listener cannot add another event listener during an active event to the same event target in the same event phase.
318
356
 
319
357
  ## 0.7.1
320
358
 
321
359
  ### Patch Changes
322
360
 
323
- - [`8cc2f888c83`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8cc2f888c83) - Upgrade Typescript from `4.3.5` to `4.5.5`
361
+ - [#24874](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24874) [`8cc2f888c83`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8cc2f888c83) - Upgrade Typescript from `4.3.5` to `4.5.5`
324
362
 
325
363
  ## 0.7.0
326
364
 
327
365
  ### Minor Changes
328
366
 
329
- - [`f2a7931d609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f2a7931d609) - Adding jsdoc to DragLocation type for better autocomplete
367
+ - [#25428](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/25428) [`f2a7931d609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f2a7931d609) - Adding jsdoc to DragLocation type for better autocomplete
330
368
 
331
369
  ## 0.6.0
332
370
 
333
371
  ### Minor Changes
334
372
 
335
- - [`0f755214ee7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0f755214ee7) - Internal folder renaming. No API impact
373
+ - [#25002](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/25002) [`0f755214ee7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0f755214ee7) - Internal folder renaming. No API impact
336
374
 
337
375
  ## 0.5.0
338
376
 
339
377
  ### Minor Changes
340
378
 
341
- - [`17950433a70`](https://bitbucket.org/atlassian/atlassian-frontend/commits/17950433a70) - Touching package to release re-release previous version. The previous (now deprecated) version did not have it's entry points built correctly
379
+ - [#25007](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/25007) [`17950433a70`](https://bitbucket.org/atlassian/atlassian-frontend/commits/17950433a70) - Touching package to release re-release previous version. The previous (now deprecated) version did not have it's entry points built correctly
342
380
 
343
381
  ## 0.4.0
344
382
 
345
383
  ### Minor Changes
346
384
 
347
- - [`4d739042b04`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4d739042b04) - Improving jsdoc auto complete information for `GetFeedbackArgs`
385
+ - [#24861](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24861) [`4d739042b04`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4d739042b04) - Improving jsdoc auto complete information for `GetFeedbackArgs`
348
386
 
349
387
  ## 0.3.0
350
388
 
351
389
  ### Minor Changes
352
390
 
353
- - [`52403a2c11f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/52403a2c11f) - Adding a `canMonitor()` function to _monitors_ to allow a _monitor_ to conditionally apply to a drag operation.
391
+ - [#24810](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24810) [`52403a2c11f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/52403a2c11f) - Adding a `canMonitor()` function to _monitors_ to allow a _monitor_ to conditionally apply to a drag operation.
354
392
 
355
393
  ```ts
356
394
  monitorForElements({
@@ -364,7 +402,7 @@
364
402
 
365
403
  ### Minor Changes
366
404
 
367
- - [`1cf9e484b4b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1cf9e484b4b) - We have improved our naming consistency across our drag and drop packages.
405
+ - [#24613](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24613) [`1cf9e484b4b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1cf9e484b4b) - We have improved our naming consistency across our drag and drop packages.
368
406
 
369
407
  - `@atlaskit/drag-and-drop/util/cancel-unhandled` has been renamed to `@atlaskit/drag-and-drop/addon/cancel-unhandled`
370
408
 
@@ -372,10 +410,10 @@
372
410
 
373
411
  ### Minor Changes
374
412
 
375
- - [`73427c38077`](https://bitbucket.org/atlassian/atlassian-frontend/commits/73427c38077) - Initial release of `@atlaskit/drag-and-drop` packages 🎉
413
+ - [#24532](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24532) [`73427c38077`](https://bitbucket.org/atlassian/atlassian-frontend/commits/73427c38077) - Initial release of `@atlaskit/drag-and-drop` packages 🎉
376
414
 
377
415
  ## 0.0.1
378
416
 
379
417
  ### Patch Changes
380
418
 
381
- - [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
419
+ - [#24492](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24492) [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
@@ -262,9 +262,11 @@ For clarity:
262
262
  - `{x: rect.width, y: rect.height}` bottom right of the `container` will be under the users pointer
263
263
  - `{x: 0, y: rect.height}` bottom left of the `container` will be under the users pointer
264
264
 
265
-
266
265
  ```ts
267
- type GetOffsetFn = (args: { container: HTMLElement }) => {x: number, y: number};
266
+ type GetOffsetFn = (args: { container: HTMLElement }) => {
267
+ x: number;
268
+ y: number;
269
+ };
268
270
  ```
269
271
 
270
272
  Notes:
@@ -77,7 +77,7 @@ var adapter = (0, _makeAdapter.makeAdapter)({
77
77
  // wrap the operation in a try/catch
78
78
  try {
79
79
  var _event$dataTransfer;
80
- (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.setData('application/vnd.pdnd', '');
80
+ (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 || _event$dataTransfer.setData('application/vnd.pdnd', '');
81
81
  } catch (e) {}
82
82
  var payload = {
83
83
  element: entry.element,
@@ -106,17 +106,15 @@ var adapter = (0, _makeAdapter.makeAdapter)({
106
106
  // So we need to get the latest entry from the registry in order
107
107
  // to call the latest event functions
108
108
 
109
- (_draggableRegistry$ge = draggableRegistry.get(payload.source.element)) === null || _draggableRegistry$ge === void 0 ? void 0 : (_draggableRegistry$ge2 = _draggableRegistry$ge[eventName]) === null || _draggableRegistry$ge2 === void 0 ? void 0 : _draggableRegistry$ge2.call(_draggableRegistry$ge,
109
+ (_draggableRegistry$ge = draggableRegistry.get(payload.source.element)) === null || _draggableRegistry$ge === void 0 || (_draggableRegistry$ge2 = _draggableRegistry$ge[eventName]) === null || _draggableRegistry$ge2 === void 0 || _draggableRegistry$ge2.call(_draggableRegistry$ge,
110
110
  // I cannot seem to get the types right here.
111
111
  // TS doesn't seem to like that one event can need `nativeSetDragImage`
112
112
  // @ts-expect-error
113
113
  payload);
114
114
  }
115
115
  });
116
- var dropTargetForElements = adapter.dropTarget;
117
- exports.dropTargetForElements = dropTargetForElements;
118
- var monitorForElements = adapter.monitor;
119
- exports.monitorForElements = monitorForElements;
116
+ var dropTargetForElements = exports.dropTargetForElements = adapter.dropTarget;
117
+ var monitorForElements = exports.monitorForElements = adapter.monitor;
120
118
  function draggable(args) {
121
119
  // Guardrail: warn if the drag handle is not contained in draggable element
122
120
  if (process.env.NODE_ENV !== 'production') {
@@ -83,16 +83,14 @@ var adapter = (0, _makeAdapter.makeAdapter)({
83
83
  // onDragStart: an external file can never start from inside a drop target
84
84
  // (it will always come from outside and we never let a file drag start in a drop target)
85
85
  // We remove `onDragStart` from drop targets, but monitors can still listen for a start
86
- var dropTargetForFiles = function dropTargetForFiles(args) {
86
+ var dropTargetForFiles = exports.dropTargetForFiles = function dropTargetForFiles(args) {
87
87
  return (0, _combine.combine)(
88
88
  // at least one drop target required before we will start listening for file events
89
89
  adapter.registerUsage(),
90
90
  // note: not removing unsupported events from args; just leaning on the type system
91
91
  adapter.dropTarget(args));
92
92
  };
93
- exports.dropTargetForFiles = dropTargetForFiles;
94
- var monitorForFiles = function monitorForFiles(args) {
93
+ var monitorForFiles = exports.monitorForFiles = function monitorForFiles(args) {
95
94
  // note: not removing unsupported events from args; just leaning on the type system
96
95
  return adapter.monitor(args);
97
- };
98
- exports.monitorForFiles = monitorForFiles;
96
+ };
@@ -26,10 +26,10 @@ var unbindEvents = null;
26
26
  /**
27
27
  * Block drag operations outside of `@atlaskit/pragmatic-drag-and-drop`
28
28
  */
29
- var cancelUnhandled = {
29
+ var cancelUnhandled = exports.cancelUnhandled = {
30
30
  start: function start() {
31
31
  var _unbindEvents;
32
- (_unbindEvents = unbindEvents) === null || _unbindEvents === void 0 ? void 0 : _unbindEvents();
32
+ (_unbindEvents = unbindEvents) === null || _unbindEvents === void 0 || _unbindEvents();
33
33
  unbindEvents = (0, _bindEventListener.bindAll)(window, [{
34
34
  type: 'dragover',
35
35
  listener: cancel
@@ -43,8 +43,7 @@ var cancelUnhandled = {
43
43
  },
44
44
  stop: function stop() {
45
45
  var _unbindEvents2;
46
- (_unbindEvents2 = unbindEvents) === null || _unbindEvents2 === void 0 ? void 0 : _unbindEvents2();
46
+ (_unbindEvents2 = unbindEvents) === null || _unbindEvents2 === void 0 || _unbindEvents2();
47
47
  unbindEvents = null;
48
48
  }
49
- };
50
- exports.cancelUnhandled = cancelUnhandled;
49
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "preserveOffsetOnSource", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _preserveOffsetOnSource.preserveOffsetOnSource;
10
+ }
11
+ });
12
+ var _preserveOffsetOnSource = require("../../util/custom-native-drag-preview/preserve-offset-on-source");
@@ -121,11 +121,9 @@ function setCrossWindowData(_ref) {
121
121
  function extractCrossWindowResult() {
122
122
  return storage.findResult();
123
123
  }
124
- var dropTargetForCrossWindowElements = function dropTargetForCrossWindowElements(args) {
124
+ var dropTargetForCrossWindowElements = exports.dropTargetForCrossWindowElements = function dropTargetForCrossWindowElements(args) {
125
125
  return (0, _combine.combine)(
126
126
  // at least one drop target required before we will start listening for cross element dragging
127
127
  adapter.registerUsage(), adapter.dropTarget(args));
128
128
  };
129
- exports.dropTargetForCrossWindowElements = dropTargetForCrossWindowElements;
130
- var monitorForCrossWindowElements = adapter.monitor;
131
- exports.monitorForCrossWindowElements = monitorForCrossWindowElements;
129
+ var monitorForCrossWindowElements = exports.monitorForCrossWindowElements = adapter.monitor;
package/dist/cjs/index.js CHANGED
@@ -8,5 +8,4 @@ exports.default = void 0;
8
8
  // Not exporting anything from the root entry point
9
9
  // Please use individual entry points in order to always
10
10
  // obtain minimum kbs.
11
- var _default = {};
12
- exports.default = _default;
11
+ var _default = exports.default = {};
@@ -328,8 +328,7 @@ function getStartLocation(_ref5) {
328
328
  dropTargets: dropTargets
329
329
  };
330
330
  }
331
- var lifecycle = {
331
+ var lifecycle = exports.lifecycle = {
332
332
  canStart: canStart,
333
333
  start: start
334
- };
335
- exports.lifecycle = lifecycle;
334
+ };
@@ -20,7 +20,7 @@ function makeAdapter(_ref) {
20
20
  });
21
21
  function dispatchEvent(args) {
22
22
  // 1. forward the event to source
23
- dispatchEventToSource === null || dispatchEventToSource === void 0 ? void 0 : dispatchEventToSource(args);
23
+ dispatchEventToSource === null || dispatchEventToSource === void 0 || dispatchEventToSource(args);
24
24
 
25
25
  // 2. forward the event to relevant dropTargets
26
26
  dropTargetAPI.dispatchEvent(args);
@@ -9,8 +9,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
10
  var _addAttribute = require("../util/add-attribute");
11
11
  var _combine = require("../util/combine");
12
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
14
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
15
15
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
@@ -118,7 +118,7 @@ function makeDropTarget(_ref) {
118
118
  var _args = _objectSpread(_objectSpread({}, payload), {}, {
119
119
  self: record
120
120
  });
121
- entry === null || entry === void 0 ? void 0 : (_entry$eventName = entry[eventName]) === null || _entry$eventName === void 0 ? void 0 : _entry$eventName.call(entry,
121
+ entry === null || entry === void 0 || (_entry$eventName = entry[eventName]) === null || _entry$eventName === void 0 || _entry$eventName.call(entry,
122
122
  // I cannot seem to get the types right here.
123
123
  // TS doesn't seem to like that one event can need `nativeSetDragImage`
124
124
  // @ts-expect-error
@@ -153,12 +153,12 @@ function makeDropTarget(_ref) {
153
153
  var _args2 = _objectSpread(_objectSpread({}, payload), {}, {
154
154
  self: record
155
155
  });
156
- entry === null || entry === void 0 ? void 0 : (_entry$onDropTargetCh = entry.onDropTargetChange) === null || _entry$onDropTargetCh === void 0 ? void 0 : _entry$onDropTargetCh.call(entry, _args2);
156
+ entry === null || entry === void 0 || (_entry$onDropTargetCh = entry.onDropTargetChange) === null || _entry$onDropTargetCh === void 0 || _entry$onDropTargetCh.call(entry, _args2);
157
157
 
158
158
  // if we cannot find the drop target in the current array, then it has been left
159
159
  if (!isOver) {
160
160
  var _entry$onDragLeave;
161
- entry === null || entry === void 0 ? void 0 : (_entry$onDragLeave = entry.onDragLeave) === null || _entry$onDragLeave === void 0 ? void 0 : _entry$onDragLeave.call(entry, _args2);
161
+ entry === null || entry === void 0 || (_entry$onDragLeave = entry.onDragLeave) === null || _entry$onDragLeave === void 0 || _entry$onDragLeave.call(entry, _args2);
162
162
  }
163
163
  }
164
164
  } catch (err) {
@@ -181,8 +181,8 @@ function makeDropTarget(_ref) {
181
181
  self: _record
182
182
  });
183
183
  var _entry = registry.get(_record.element);
184
- _entry === null || _entry === void 0 ? void 0 : (_entry$onDropTargetCh2 = _entry.onDropTargetChange) === null || _entry$onDropTargetCh2 === void 0 ? void 0 : _entry$onDropTargetCh2.call(_entry, _args3);
185
- _entry === null || _entry === void 0 ? void 0 : (_entry$onDragEnter = _entry.onDragEnter) === null || _entry$onDragEnter === void 0 ? void 0 : _entry$onDragEnter.call(_entry, _args3);
184
+ _entry === null || _entry === void 0 || (_entry$onDropTargetCh2 = _entry.onDropTargetChange) === null || _entry$onDropTargetCh2 === void 0 || _entry$onDropTargetCh2.call(_entry, _args3);
185
+ _entry === null || _entry === void 0 || (_entry$onDragEnter = _entry.onDragEnter) === null || _entry$onDragEnter === void 0 || _entry$onDragEnter.call(_entry, _args3);
186
186
  }
187
187
  } catch (err) {
188
188
  _iterator3.e(err);
@@ -9,8 +9,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
10
10
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
11
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
14
  function makeMonitor() {
15
15
  var registry = new Set();
16
16
  var dragging = null;
@@ -85,7 +85,7 @@ function makeMonitor() {
85
85
  if (dragging.active.has(_monitor)) {
86
86
  var _monitor$eventName;
87
87
  // @ts-expect-error: I cannot get this type working!
88
- (_monitor$eventName = _monitor[eventName]) === null || _monitor$eventName === void 0 ? void 0 : _monitor$eventName.call(_monitor, payload);
88
+ (_monitor$eventName = _monitor[eventName]) === null || _monitor$eventName === void 0 || _monitor$eventName.call(_monitor, payload);
89
89
  }
90
90
  }
91
91
  if (eventName === 'onDrop') {
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.centerUnderPointer = void 0;
7
- var centerUnderPointer = function centerUnderPointer(_ref) {
7
+ var centerUnderPointer = exports.centerUnderPointer = function centerUnderPointer(_ref) {
8
8
  var container = _ref.container;
9
9
  var rect = container.getBoundingClientRect();
10
10
  return {
11
11
  x: rect.width / 2,
12
12
  y: rect.height / 2
13
13
  };
14
- };
15
- exports.centerUnderPointer = centerUnderPointer;
14
+ };
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.preserveOffsetFromPointer = preserveOffsetFromPointer;
7
- function preserveOffsetFromPointer(_ref) {
8
- var sourceElement = _ref.sourceElement,
6
+ exports.preserveOffsetOnSource = preserveOffsetOnSource;
7
+ function preserveOffsetOnSource(_ref) {
8
+ var element = _ref.element,
9
9
  input = _ref.input;
10
10
  return function (_ref2) {
11
11
  var container = _ref2.container;
12
- var sourceRect = sourceElement.getBoundingClientRect();
12
+ var sourceRect = element.getBoundingClientRect();
13
13
  var containerRect = container.getBoundingClientRect();
14
14
  var offsetX = Math.min(
15
15
  // difference
@@ -67,10 +67,10 @@ function setCustomNativeDragPreview(_ref) {
67
67
  var previewOffset = getOffset({
68
68
  container: container
69
69
  });
70
- nativeSetDragImage === null || nativeSetDragImage === void 0 ? void 0 : nativeSetDragImage(container, previewOffset.x, previewOffset.y);
70
+ nativeSetDragImage === null || nativeSetDragImage === void 0 || nativeSetDragImage(container, previewOffset.x, previewOffset.y);
71
71
  function cleanup() {
72
72
  unbindMonitor();
73
- unmount === null || unmount === void 0 ? void 0 : unmount();
73
+ unmount === null || unmount === void 0 || unmount();
74
74
  document.body.removeChild(container);
75
75
  }
76
76
  var unbindMonitor = (0, _elementAdapter.monitorForElements)({
@@ -53,7 +53,7 @@ function blockPointerEventsOnEverything() {
53
53
 
54
54
  // Debug note: change from 'pointer-events: none' to 'background: red'
55
55
  // to get a better sense of what is being achieved
56
- (_element$sheet = element.sheet) === null || _element$sheet === void 0 ? void 0 : _element$sheet.insertRule('* { pointer-events: none !important; }');
56
+ (_element$sheet = element.sheet) === null || _element$sheet === void 0 || _element$sheet.insertRule('* { pointer-events: none !important; }');
57
57
  return function cleanup() {
58
58
  document.head.removeChild(element);
59
59
  };
@@ -86,7 +86,7 @@ function fixPostDragPointerBug(_ref3) {
86
86
  var undoGlobalBlock = blockPointerEventsOnEverything();
87
87
  function cleanup() {
88
88
  unbindEvents();
89
- undoUnderPointer === null || undoUnderPointer === void 0 ? void 0 : undoUnderPointer();
89
+ undoUnderPointer === null || undoUnderPointer === void 0 || undoUnderPointer();
90
90
  undoGlobalBlock();
91
91
  }
92
92
  var unbindEvents = (0, _bindEventListener.bindAll)(window, [{
@@ -0,0 +1 @@
1
+ export { preserveOffsetOnSource } from '../../util/custom-native-drag-preview/preserve-offset-on-source';
@@ -1,11 +1,11 @@
1
- export function preserveOffsetFromPointer({
2
- sourceElement,
1
+ export function preserveOffsetOnSource({
2
+ element,
3
3
  input
4
4
  }) {
5
5
  return ({
6
6
  container
7
7
  }) => {
8
- const sourceRect = sourceElement.getBoundingClientRect();
8
+ const sourceRect = element.getBoundingClientRect();
9
9
  const containerRect = container.getBoundingClientRect();
10
10
  const offsetX = Math.min(
11
11
  // difference
@@ -70,7 +70,7 @@ var adapter = makeAdapter({
70
70
  // wrap the operation in a try/catch
71
71
  try {
72
72
  var _event$dataTransfer;
73
- (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.setData('application/vnd.pdnd', '');
73
+ (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 || _event$dataTransfer.setData('application/vnd.pdnd', '');
74
74
  } catch (e) {}
75
75
  var payload = {
76
76
  element: entry.element,
@@ -99,7 +99,7 @@ var adapter = makeAdapter({
99
99
  // So we need to get the latest entry from the registry in order
100
100
  // to call the latest event functions
101
101
 
102
- (_draggableRegistry$ge = draggableRegistry.get(payload.source.element)) === null || _draggableRegistry$ge === void 0 ? void 0 : (_draggableRegistry$ge2 = _draggableRegistry$ge[eventName]) === null || _draggableRegistry$ge2 === void 0 ? void 0 : _draggableRegistry$ge2.call(_draggableRegistry$ge,
102
+ (_draggableRegistry$ge = draggableRegistry.get(payload.source.element)) === null || _draggableRegistry$ge === void 0 || (_draggableRegistry$ge2 = _draggableRegistry$ge[eventName]) === null || _draggableRegistry$ge2 === void 0 || _draggableRegistry$ge2.call(_draggableRegistry$ge,
103
103
  // I cannot seem to get the types right here.
104
104
  // TS doesn't seem to like that one event can need `nativeSetDragImage`
105
105
  // @ts-expect-error
@@ -23,7 +23,7 @@ var unbindEvents = null;
23
23
  export var cancelUnhandled = {
24
24
  start: function start() {
25
25
  var _unbindEvents;
26
- (_unbindEvents = unbindEvents) === null || _unbindEvents === void 0 ? void 0 : _unbindEvents();
26
+ (_unbindEvents = unbindEvents) === null || _unbindEvents === void 0 || _unbindEvents();
27
27
  unbindEvents = bindAll(window, [{
28
28
  type: 'dragover',
29
29
  listener: cancel
@@ -37,7 +37,7 @@ export var cancelUnhandled = {
37
37
  },
38
38
  stop: function stop() {
39
39
  var _unbindEvents2;
40
- (_unbindEvents2 = unbindEvents) === null || _unbindEvents2 === void 0 ? void 0 : _unbindEvents2();
40
+ (_unbindEvents2 = unbindEvents) === null || _unbindEvents2 === void 0 || _unbindEvents2();
41
41
  unbindEvents = null;
42
42
  }
43
43
  };
@@ -0,0 +1 @@
1
+ export { preserveOffsetOnSource } from '../../util/custom-native-drag-preview/preserve-offset-on-source';
@@ -14,7 +14,7 @@ export function makeAdapter(_ref) {
14
14
  });
15
15
  function dispatchEvent(args) {
16
16
  // 1. forward the event to source
17
- dispatchEventToSource === null || dispatchEventToSource === void 0 ? void 0 : dispatchEventToSource(args);
17
+ dispatchEventToSource === null || dispatchEventToSource === void 0 || dispatchEventToSource(args);
18
18
 
19
19
  // 2. forward the event to relevant dropTargets
20
20
  dropTargetAPI.dispatchEvent(args);
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
6
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
7
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
@@ -111,7 +111,7 @@ export function makeDropTarget(_ref) {
111
111
  var _args = _objectSpread(_objectSpread({}, payload), {}, {
112
112
  self: record
113
113
  });
114
- entry === null || entry === void 0 ? void 0 : (_entry$eventName = entry[eventName]) === null || _entry$eventName === void 0 ? void 0 : _entry$eventName.call(entry,
114
+ entry === null || entry === void 0 || (_entry$eventName = entry[eventName]) === null || _entry$eventName === void 0 || _entry$eventName.call(entry,
115
115
  // I cannot seem to get the types right here.
116
116
  // TS doesn't seem to like that one event can need `nativeSetDragImage`
117
117
  // @ts-expect-error
@@ -146,12 +146,12 @@ export function makeDropTarget(_ref) {
146
146
  var _args2 = _objectSpread(_objectSpread({}, payload), {}, {
147
147
  self: record
148
148
  });
149
- entry === null || entry === void 0 ? void 0 : (_entry$onDropTargetCh = entry.onDropTargetChange) === null || _entry$onDropTargetCh === void 0 ? void 0 : _entry$onDropTargetCh.call(entry, _args2);
149
+ entry === null || entry === void 0 || (_entry$onDropTargetCh = entry.onDropTargetChange) === null || _entry$onDropTargetCh === void 0 || _entry$onDropTargetCh.call(entry, _args2);
150
150
 
151
151
  // if we cannot find the drop target in the current array, then it has been left
152
152
  if (!isOver) {
153
153
  var _entry$onDragLeave;
154
- entry === null || entry === void 0 ? void 0 : (_entry$onDragLeave = entry.onDragLeave) === null || _entry$onDragLeave === void 0 ? void 0 : _entry$onDragLeave.call(entry, _args2);
154
+ entry === null || entry === void 0 || (_entry$onDragLeave = entry.onDragLeave) === null || _entry$onDragLeave === void 0 || _entry$onDragLeave.call(entry, _args2);
155
155
  }
156
156
  }
157
157
  } catch (err) {
@@ -174,8 +174,8 @@ export function makeDropTarget(_ref) {
174
174
  self: _record
175
175
  });
176
176
  var _entry = registry.get(_record.element);
177
- _entry === null || _entry === void 0 ? void 0 : (_entry$onDropTargetCh2 = _entry.onDropTargetChange) === null || _entry$onDropTargetCh2 === void 0 ? void 0 : _entry$onDropTargetCh2.call(_entry, _args3);
178
- _entry === null || _entry === void 0 ? void 0 : (_entry$onDragEnter = _entry.onDragEnter) === null || _entry$onDragEnter === void 0 ? void 0 : _entry$onDragEnter.call(_entry, _args3);
177
+ _entry === null || _entry === void 0 || (_entry$onDropTargetCh2 = _entry.onDropTargetChange) === null || _entry$onDropTargetCh2 === void 0 || _entry$onDropTargetCh2.call(_entry, _args3);
178
+ _entry === null || _entry === void 0 || (_entry$onDragEnter = _entry.onDragEnter) === null || _entry$onDragEnter === void 0 || _entry$onDragEnter.call(_entry, _args3);
179
179
  }
180
180
  } catch (err) {
181
181
  _iterator3.e(err);
@@ -2,8 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
3
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  export function makeMonitor() {
8
8
  var registry = new Set();
9
9
  var dragging = null;
@@ -78,7 +78,7 @@ export function makeMonitor() {
78
78
  if (dragging.active.has(_monitor)) {
79
79
  var _monitor$eventName;
80
80
  // @ts-expect-error: I cannot get this type working!
81
- (_monitor$eventName = _monitor[eventName]) === null || _monitor$eventName === void 0 ? void 0 : _monitor$eventName.call(_monitor, payload);
81
+ (_monitor$eventName = _monitor[eventName]) === null || _monitor$eventName === void 0 || _monitor$eventName.call(_monitor, payload);
82
82
  }
83
83
  }
84
84
  if (eventName === 'onDrop') {
@@ -1,9 +1,9 @@
1
- export function preserveOffsetFromPointer(_ref) {
2
- var sourceElement = _ref.sourceElement,
1
+ export function preserveOffsetOnSource(_ref) {
2
+ var element = _ref.element,
3
3
  input = _ref.input;
4
4
  return function (_ref2) {
5
5
  var container = _ref2.container;
6
- var sourceRect = sourceElement.getBoundingClientRect();
6
+ var sourceRect = element.getBoundingClientRect();
7
7
  var containerRect = container.getBoundingClientRect();
8
8
  var offsetX = Math.min(
9
9
  // difference
@@ -62,10 +62,10 @@ export function setCustomNativeDragPreview(_ref) {
62
62
  var previewOffset = getOffset({
63
63
  container: container
64
64
  });
65
- nativeSetDragImage === null || nativeSetDragImage === void 0 ? void 0 : nativeSetDragImage(container, previewOffset.x, previewOffset.y);
65
+ nativeSetDragImage === null || nativeSetDragImage === void 0 || nativeSetDragImage(container, previewOffset.x, previewOffset.y);
66
66
  function cleanup() {
67
67
  unbindMonitor();
68
- unmount === null || unmount === void 0 ? void 0 : unmount();
68
+ unmount === null || unmount === void 0 || unmount();
69
69
  document.body.removeChild(container);
70
70
  }
71
71
  var unbindMonitor = monitorForElements({
@@ -47,7 +47,7 @@ function blockPointerEventsOnEverything() {
47
47
 
48
48
  // Debug note: change from 'pointer-events: none' to 'background: red'
49
49
  // to get a better sense of what is being achieved
50
- (_element$sheet = element.sheet) === null || _element$sheet === void 0 ? void 0 : _element$sheet.insertRule('* { pointer-events: none !important; }');
50
+ (_element$sheet = element.sheet) === null || _element$sheet === void 0 || _element$sheet.insertRule('* { pointer-events: none !important; }');
51
51
  return function cleanup() {
52
52
  document.head.removeChild(element);
53
53
  };
@@ -80,7 +80,7 @@ export function fixPostDragPointerBug(_ref3) {
80
80
  var undoGlobalBlock = blockPointerEventsOnEverything();
81
81
  function cleanup() {
82
82
  unbindEvents();
83
- undoUnderPointer === null || undoUnderPointer === void 0 ? void 0 : undoUnderPointer();
83
+ undoUnderPointer === null || undoUnderPointer === void 0 || undoUnderPointer();
84
84
  undoGlobalBlock();
85
85
  }
86
86
  var unbindEvents = bindAll(window, [{
@@ -0,0 +1 @@
1
+ export { preserveOffsetOnSource } from '../../util/custom-native-drag-preview/preserve-offset-on-source';
@@ -1,6 +1,6 @@
1
1
  import { Input } from '../../entry-point/types';
2
2
  import type { GetOffsetFn } from './types';
3
- export declare function preserveOffsetFromPointer({ sourceElement, input, }: {
4
- sourceElement: HTMLElement;
3
+ export declare function preserveOffsetOnSource({ element, input, }: {
4
+ element: HTMLElement;
5
5
  input: Input;
6
6
  }): GetOffsetFn;
@@ -0,0 +1 @@
1
+ export { preserveOffsetOnSource } from '../../util/custom-native-drag-preview/preserve-offset-on-source';
@@ -1,6 +1,6 @@
1
1
  import { Input } from '../../entry-point/types';
2
2
  import type { GetOffsetFn } from './types';
3
- export declare function preserveOffsetFromPointer({ sourceElement, input, }: {
4
- sourceElement: HTMLElement;
3
+ export declare function preserveOffsetOnSource({ element, input, }: {
4
+ element: HTMLElement;
5
5
  input: Input;
6
6
  }): GetOffsetFn;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaskit/pragmatic-drag-and-drop",
3
- "version": "0.22.0",
4
- "description": "The core Pragmatic drag and drop framework, optimized for performance.",
3
+ "version": "0.24.0",
4
+ "description": "The core Pragmatic drag and drop framework, enabling flexible and fast drag and drop for any experience on any tech stack",
5
5
  "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
6
6
  "author": "Atlassian Pty Ltd",
7
7
  "license": "Apache-2.0",
@@ -32,6 +32,12 @@
32
32
  "status": {
33
33
  "type": "alpha"
34
34
  }
35
+ },
36
+ "integrationTests": {
37
+ "additionalBrowsers": [
38
+ "desktop-firefox",
39
+ "desktop-webkit"
40
+ ]
35
41
  }
36
42
  },
37
43
  "af:exports": {
@@ -46,7 +52,7 @@
46
52
  "./util/set-custom-native-drag-preview": "./src/entry-point/util/set-custom-native-drag-preview.ts",
47
53
  "./util/offset-from-pointer": "./src/entry-point/util/offset-from-pointer.ts",
48
54
  "./util/center-under-pointer": "./src/entry-point/util/center-under-pointer.ts",
49
- "./util/preserve-offset-from-pointer": "./src/entry-point/util/preserve-offset-from-pointer.ts",
55
+ "./util/preserve-offset-on-source": "./src/entry-point/util/preserve-offset-on-source.ts",
50
56
  "./util/disable-native-drag-preview": "./src/entry-point/util/disable-native-drag-preview.ts",
51
57
  "./util/scroll-just-enough-into-view": "./src/entry-point/util/scroll-just-enough-into-view.ts",
52
58
  "./experimental/cross-window-element-adapter": "./src/entry-point/experimental/cross-with-element-adapter.ts"
@@ -57,6 +63,7 @@
57
63
  "raf-schd": "^4.0.3"
58
64
  },
59
65
  "devDependencies": {
66
+ "@af/integration-testing": "*",
60
67
  "@atlaskit/visual-regression": "*",
61
68
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
62
69
  "@emotion/react": "^11.7.1",
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/pragmatic-drag-and-drop/util/preserve-offset-on-source",
3
+ "main": "../../dist/cjs/entry-point/util/preserve-offset-on-source.js",
4
+ "module": "../../dist/esm/entry-point/util/preserve-offset-on-source.js",
5
+ "module:es2019": "../../dist/es2019/entry-point/util/preserve-offset-on-source.js",
6
+ "sideEffects": false,
7
+ "types": "../../dist/types/entry-point/util/preserve-offset-on-source.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <4.9": {
10
+ "*": [
11
+ "../../dist/types-ts4.5/entry-point/util/preserve-offset-on-source.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "preserveOffsetFromPointer", {
7
- enumerable: true,
8
- get: function get() {
9
- return _preserveOffsetFromPointer.preserveOffsetFromPointer;
10
- }
11
- });
12
- var _preserveOffsetFromPointer = require("../../util/custom-native-drag-preview/preserve-offset-from-pointer");
@@ -1 +0,0 @@
1
- export { preserveOffsetFromPointer } from '../../util/custom-native-drag-preview/preserve-offset-from-pointer';
@@ -1 +0,0 @@
1
- export { preserveOffsetFromPointer } from '../../util/custom-native-drag-preview/preserve-offset-from-pointer';
@@ -1 +0,0 @@
1
- export { preserveOffsetFromPointer } from '../../util/custom-native-drag-preview/preserve-offset-from-pointer';
@@ -1 +0,0 @@
1
- export { preserveOffsetFromPointer } from '../../util/custom-native-drag-preview/preserve-offset-from-pointer';
@@ -1,15 +0,0 @@
1
- {
2
- "name": "@atlaskit/pragmatic-drag-and-drop/util/preserve-offset-from-pointer",
3
- "main": "../../dist/cjs/entry-point/util/preserve-offset-from-pointer.js",
4
- "module": "../../dist/esm/entry-point/util/preserve-offset-from-pointer.js",
5
- "module:es2019": "../../dist/es2019/entry-point/util/preserve-offset-from-pointer.js",
6
- "sideEffects": false,
7
- "types": "../../dist/types/entry-point/util/preserve-offset-from-pointer.d.ts",
8
- "typesVersions": {
9
- ">=4.5 <4.9": {
10
- "*": [
11
- "../../dist/types-ts4.5/entry-point/util/preserve-offset-from-pointer.d.ts"
12
- ]
13
- }
14
- }
15
- }