@atlaskit/pragmatic-drag-and-drop 1.7.0 → 1.7.2
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 +38 -0
- package/dist/cjs/adapter/element-adapter.js +6 -1
- package/dist/cjs/make-adapter/make-drop-target.js +6 -1
- package/dist/cjs/make-adapter/make-monitor.js +7 -2
- package/dist/es2019/adapter/element-adapter.js +6 -1
- package/dist/es2019/make-adapter/make-drop-target.js +6 -1
- package/dist/es2019/make-adapter/make-monitor.js +7 -2
- package/dist/esm/adapter/element-adapter.js +6 -1
- package/dist/esm/make-adapter/make-drop-target.js +6 -1
- package/dist/esm/make-adapter/make-monitor.js +7 -2
- package/package.json +3 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @atlaskit/pragmatic-drag-and-drop
|
|
2
2
|
|
|
3
|
+
## 1.7.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#164244](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/164244)
|
|
8
|
+
[`65021fc0267e2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/65021fc0267e2) -
|
|
9
|
+
The cleanup functions returned by the following utilities now only work on the first call. This
|
|
10
|
+
was done to prevent unexpected side effects of calling a cleanup function multiple times.
|
|
11
|
+
|
|
12
|
+
- `@atlaskit/pragmatic-drag-and-drop/adapter/element`
|
|
13
|
+
- `draggable`
|
|
14
|
+
- `dropTargetForElements`
|
|
15
|
+
- `monitorForElements`
|
|
16
|
+
- `@atlaskit/pragmatic-drag-and-drop/adapter/text-selection`
|
|
17
|
+
- `dropTargetForTextSelection`
|
|
18
|
+
- `monitorForTextSelection`
|
|
19
|
+
- `@atlaskit/pragmatic-drag-and-drop/adapter/external`
|
|
20
|
+
- `dropTargetForExternal`
|
|
21
|
+
- `monitorForExternal`
|
|
22
|
+
- `@atlaskit/pragmatic-drag-and-drop-auto-scroll/element`
|
|
23
|
+
- `autoScrollForElements`
|
|
24
|
+
- `autoScrollWindowForElements`
|
|
25
|
+
- `@atlaskit/pragmatic-drag-and-drop-auto-scroll/external`
|
|
26
|
+
- `autoScrollForExternal`
|
|
27
|
+
- `autoScrollWindowForExternal`
|
|
28
|
+
- `@atlaskit/pragmatic-drag-and-drop-auto-scroll/text-selection`
|
|
29
|
+
- `autoScrollForTextSelection`
|
|
30
|
+
- `autoScrollWindowForTextSelection`
|
|
31
|
+
|
|
32
|
+
## 1.7.1
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- [#162456](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/162456)
|
|
37
|
+
[`f916af5aab898`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f916af5aab898) -
|
|
38
|
+
Removes `@atlaskit/platform-feature-flags` as a dependency. Removes `@atlaskit/link` as a runtime
|
|
39
|
+
dependency, although it is still used in examples.
|
|
40
|
+
|
|
3
41
|
## 1.7.0
|
|
4
42
|
|
|
5
43
|
### Minor Changes
|
|
@@ -12,6 +12,7 @@ var _getElementFromPointWithoutHoneyPot = require("../honey-pot-fix/get-element-
|
|
|
12
12
|
var _makeHoneyPotFix = require("../honey-pot-fix/make-honey-pot-fix");
|
|
13
13
|
var _makeAdapter = require("../make-adapter/make-adapter");
|
|
14
14
|
var _combine = require("../public-utils/combine");
|
|
15
|
+
var _once = require("../public-utils/once");
|
|
15
16
|
var _addAttribute = require("../util/add-attribute");
|
|
16
17
|
var _android = require("../util/android");
|
|
17
18
|
var _getInput = require("../util/get-input");
|
|
@@ -271,7 +272,7 @@ function draggable(args) {
|
|
|
271
272
|
});
|
|
272
273
|
}
|
|
273
274
|
}
|
|
274
|
-
|
|
275
|
+
var cleanup = (0, _combine.combine)(
|
|
275
276
|
// making the draggable register the adapter rather than drop targets
|
|
276
277
|
// this is because you *must* have a draggable element to start a drag
|
|
277
278
|
// but you _might_ not have any drop targets immediately
|
|
@@ -280,6 +281,10 @@ function draggable(args) {
|
|
|
280
281
|
attribute: 'draggable',
|
|
281
282
|
value: 'true'
|
|
282
283
|
}));
|
|
284
|
+
|
|
285
|
+
// Wrapping in `once` to prevent unexpected side effects if consumers call
|
|
286
|
+
// the clean up function multiple times.
|
|
287
|
+
return (0, _once.once)(cleanup);
|
|
283
288
|
}
|
|
284
289
|
|
|
285
290
|
/** Common event payload for all events */
|
|
@@ -8,6 +8,7 @@ exports.makeDropTarget = makeDropTarget;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _combine = require("../public-utils/combine");
|
|
11
|
+
var _once = require("../public-utils/once");
|
|
11
12
|
var _addAttribute = require("../util/add-attribute");
|
|
12
13
|
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
14
|
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; }
|
|
@@ -46,10 +47,14 @@ function makeDropTarget(_ref) {
|
|
|
46
47
|
.replace(/\s{2,}/g, ' ').trim());
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
var cleanup = (0, _combine.combine)((0, _addAttribute.addAttribute)(args.element, {
|
|
50
51
|
attribute: dropTargetDataAtt,
|
|
51
52
|
value: 'true'
|
|
52
53
|
}), addToRegistry(args));
|
|
54
|
+
|
|
55
|
+
// Wrapping in `once` to prevent unexpected side effects if consumers call
|
|
56
|
+
// the clean up function multiple times.
|
|
57
|
+
return (0, _once.once)(cleanup);
|
|
53
58
|
}
|
|
54
59
|
function getActualDropTargets(_ref2) {
|
|
55
60
|
var _args$getData, _args$getData2, _args$getDropEffect, _args$getDropEffect2;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.makeMonitor = makeMonitor;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _once = require("../public-utils/once");
|
|
9
10
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
10
11
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
12
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -33,14 +34,18 @@ function makeMonitor() {
|
|
|
33
34
|
|
|
34
35
|
// if there is an active drag we need to see if this new monitor is relevant
|
|
35
36
|
tryAddToActive(entry);
|
|
36
|
-
|
|
37
|
+
function cleanup() {
|
|
37
38
|
registry.delete(entry);
|
|
38
39
|
|
|
39
40
|
// We need to stop publishing events during a drag to this monitor!
|
|
40
41
|
if (dragging) {
|
|
41
42
|
dragging.active.delete(entry);
|
|
42
43
|
}
|
|
43
|
-
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Wrapping in `once` to prevent unexpected side effects if consumers call
|
|
47
|
+
// the clean up function multiple times.
|
|
48
|
+
return (0, _once.once)(cleanup);
|
|
44
49
|
}
|
|
45
50
|
function dispatchEvent(_ref) {
|
|
46
51
|
var eventName = _ref.eventName,
|
|
@@ -3,6 +3,7 @@ import { getElementFromPointWithoutHoneypot } from '../honey-pot-fix/get-element
|
|
|
3
3
|
import { makeHoneyPotFix } from '../honey-pot-fix/make-honey-pot-fix';
|
|
4
4
|
import { makeAdapter } from '../make-adapter/make-adapter';
|
|
5
5
|
import { combine } from '../public-utils/combine';
|
|
6
|
+
import { once } from '../public-utils/once';
|
|
6
7
|
import { addAttribute } from '../util/add-attribute';
|
|
7
8
|
import { androidFallbackText, isAndroid } from '../util/android';
|
|
8
9
|
import { getInput } from '../util/get-input';
|
|
@@ -268,7 +269,7 @@ export function draggable(args) {
|
|
|
268
269
|
});
|
|
269
270
|
}
|
|
270
271
|
}
|
|
271
|
-
|
|
272
|
+
const cleanup = combine(
|
|
272
273
|
// making the draggable register the adapter rather than drop targets
|
|
273
274
|
// this is because you *must* have a draggable element to start a drag
|
|
274
275
|
// but you _might_ not have any drop targets immediately
|
|
@@ -277,6 +278,10 @@ export function draggable(args) {
|
|
|
277
278
|
attribute: 'draggable',
|
|
278
279
|
value: 'true'
|
|
279
280
|
}));
|
|
281
|
+
|
|
282
|
+
// Wrapping in `once` to prevent unexpected side effects if consumers call
|
|
283
|
+
// the clean up function multiple times.
|
|
284
|
+
return once(cleanup);
|
|
280
285
|
}
|
|
281
286
|
|
|
282
287
|
/** Common event payload for all events */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { combine } from '../public-utils/combine';
|
|
2
|
+
import { once } from '../public-utils/once';
|
|
2
3
|
import { addAttribute } from '../util/add-attribute';
|
|
3
4
|
function copyReverse(array) {
|
|
4
5
|
return array.slice(0).reverse();
|
|
@@ -35,10 +36,14 @@ export function makeDropTarget({
|
|
|
35
36
|
.replace(/\s{2,}/g, ' ').trim());
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
const cleanup = combine(addAttribute(args.element, {
|
|
39
40
|
attribute: dropTargetDataAtt,
|
|
40
41
|
value: 'true'
|
|
41
42
|
}), addToRegistry(args));
|
|
43
|
+
|
|
44
|
+
// Wrapping in `once` to prevent unexpected side effects if consumers call
|
|
45
|
+
// the clean up function multiple times.
|
|
46
|
+
return once(cleanup);
|
|
42
47
|
}
|
|
43
48
|
function getActualDropTargets({
|
|
44
49
|
source,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { once } from '../public-utils/once';
|
|
1
2
|
export function makeMonitor() {
|
|
2
3
|
const registry = new Set();
|
|
3
4
|
let dragging = null;
|
|
@@ -22,14 +23,18 @@ export function makeMonitor() {
|
|
|
22
23
|
|
|
23
24
|
// if there is an active drag we need to see if this new monitor is relevant
|
|
24
25
|
tryAddToActive(entry);
|
|
25
|
-
|
|
26
|
+
function cleanup() {
|
|
26
27
|
registry.delete(entry);
|
|
27
28
|
|
|
28
29
|
// We need to stop publishing events during a drag to this monitor!
|
|
29
30
|
if (dragging) {
|
|
30
31
|
dragging.active.delete(entry);
|
|
31
32
|
}
|
|
32
|
-
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Wrapping in `once` to prevent unexpected side effects if consumers call
|
|
36
|
+
// the clean up function multiple times.
|
|
37
|
+
return once(cleanup);
|
|
33
38
|
}
|
|
34
39
|
function dispatchEvent({
|
|
35
40
|
eventName,
|
|
@@ -4,6 +4,7 @@ import { getElementFromPointWithoutHoneypot } from '../honey-pot-fix/get-element
|
|
|
4
4
|
import { makeHoneyPotFix } from '../honey-pot-fix/make-honey-pot-fix';
|
|
5
5
|
import { makeAdapter } from '../make-adapter/make-adapter';
|
|
6
6
|
import { combine } from '../public-utils/combine';
|
|
7
|
+
import { once } from '../public-utils/once';
|
|
7
8
|
import { addAttribute } from '../util/add-attribute';
|
|
8
9
|
import { androidFallbackText, isAndroid } from '../util/android';
|
|
9
10
|
import { getInput } from '../util/get-input';
|
|
@@ -263,7 +264,7 @@ export function draggable(args) {
|
|
|
263
264
|
});
|
|
264
265
|
}
|
|
265
266
|
}
|
|
266
|
-
|
|
267
|
+
var cleanup = combine(
|
|
267
268
|
// making the draggable register the adapter rather than drop targets
|
|
268
269
|
// this is because you *must* have a draggable element to start a drag
|
|
269
270
|
// but you _might_ not have any drop targets immediately
|
|
@@ -272,6 +273,10 @@ export function draggable(args) {
|
|
|
272
273
|
attribute: 'draggable',
|
|
273
274
|
value: 'true'
|
|
274
275
|
}));
|
|
276
|
+
|
|
277
|
+
// Wrapping in `once` to prevent unexpected side effects if consumers call
|
|
278
|
+
// the clean up function multiple times.
|
|
279
|
+
return once(cleanup);
|
|
275
280
|
}
|
|
276
281
|
|
|
277
282
|
/** Common event payload for all events */
|
|
@@ -6,6 +6,7 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
6
6
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
7
7
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
8
8
|
import { combine } from '../public-utils/combine';
|
|
9
|
+
import { once } from '../public-utils/once';
|
|
9
10
|
import { addAttribute } from '../util/add-attribute';
|
|
10
11
|
function copyReverse(array) {
|
|
11
12
|
return array.slice(0).reverse();
|
|
@@ -39,10 +40,14 @@ export function makeDropTarget(_ref) {
|
|
|
39
40
|
.replace(/\s{2,}/g, ' ').trim());
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
var cleanup = combine(addAttribute(args.element, {
|
|
43
44
|
attribute: dropTargetDataAtt,
|
|
44
45
|
value: 'true'
|
|
45
46
|
}), addToRegistry(args));
|
|
47
|
+
|
|
48
|
+
// Wrapping in `once` to prevent unexpected side effects if consumers call
|
|
49
|
+
// the clean up function multiple times.
|
|
50
|
+
return once(cleanup);
|
|
46
51
|
}
|
|
47
52
|
function getActualDropTargets(_ref2) {
|
|
48
53
|
var _args$getData, _args$getData2, _args$getDropEffect, _args$getDropEffect2;
|
|
@@ -4,6 +4,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
4
4
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
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
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
|
+
import { once } from '../public-utils/once';
|
|
7
8
|
export function makeMonitor() {
|
|
8
9
|
var registry = new Set();
|
|
9
10
|
var dragging = null;
|
|
@@ -26,14 +27,18 @@ export function makeMonitor() {
|
|
|
26
27
|
|
|
27
28
|
// if there is an active drag we need to see if this new monitor is relevant
|
|
28
29
|
tryAddToActive(entry);
|
|
29
|
-
|
|
30
|
+
function cleanup() {
|
|
30
31
|
registry.delete(entry);
|
|
31
32
|
|
|
32
33
|
// We need to stop publishing events during a drag to this monitor!
|
|
33
34
|
if (dragging) {
|
|
34
35
|
dragging.active.delete(entry);
|
|
35
36
|
}
|
|
36
|
-
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Wrapping in `once` to prevent unexpected side effects if consumers call
|
|
40
|
+
// the clean up function multiple times.
|
|
41
|
+
return once(cleanup);
|
|
37
42
|
}
|
|
38
43
|
function dispatchEvent(_ref) {
|
|
39
44
|
var eventName = _ref.eventName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/pragmatic-drag-and-drop",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
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",
|
|
@@ -62,14 +62,13 @@
|
|
|
62
62
|
"./types": "./src/entry-point/types.ts"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@atlaskit/link": "^3.2.0",
|
|
66
|
-
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
67
65
|
"@babel/runtime": "^7.0.0",
|
|
68
66
|
"bind-event-listener": "^3.0.0",
|
|
69
67
|
"raf-schd": "^4.0.3"
|
|
70
68
|
},
|
|
71
69
|
"devDependencies": {
|
|
72
70
|
"@af/integration-testing": "workspace:^",
|
|
71
|
+
"@atlaskit/link": "^3.2.0",
|
|
73
72
|
"@atlaskit/visual-regression": "workspace:^",
|
|
74
73
|
"@emotion/react": "^11.7.1",
|
|
75
74
|
"@testing-library/dom": "^10.1.0",
|
|
@@ -105,10 +104,5 @@
|
|
|
105
104
|
]
|
|
106
105
|
}
|
|
107
106
|
},
|
|
108
|
-
"homepage": "https://atlassian.design/components/pragmatic-drag-and-drop/"
|
|
109
|
-
"platform-feature-flags": {
|
|
110
|
-
"dst-a11y__replace-anchor-with-link__design-system-": {
|
|
111
|
-
"type": "boolean"
|
|
112
|
-
}
|
|
113
|
-
}
|
|
107
|
+
"homepage": "https://atlassian.design/components/pragmatic-drag-and-drop/"
|
|
114
108
|
}
|