dragselect 2.5.5 → 2.5.6
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 +4 -0
- package/deployment.md +32 -0
- package/dist/DragSelect.es6m.js +171 -98
- package/dist/DragSelect.js +172 -99
- package/dist/ds.es6m.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/package.json +15 -20
- package/rollup.config.js +1 -34
- package/src/DragSelect.js +1 -1
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -48
- package/LICENSE +0 -21
- package/README.md +0 -478
- package/deploying.md +0 -36
package/dist/DragSelect.es6m.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/***
|
|
2
2
|
|
|
3
|
-
~~~ Version 2.5.
|
|
3
|
+
~~~ Version 2.5.6 ~~~
|
|
4
4
|
|
|
5
5
|
******************************************
|
|
6
6
|
|
|
@@ -25,10 +25,58 @@
|
|
|
25
25
|
********* The MIT License (MIT) **********
|
|
26
26
|
******************************************
|
|
27
27
|
Created 2017 by ThibaultJanBeyer
|
|
28
|
-
web: http://www.
|
|
28
|
+
web: http://www.DragSelect.com/
|
|
29
29
|
github: https://github.com/ThibaultJanBeyer/DragSelect
|
|
30
30
|
|
|
31
31
|
*/
|
|
32
|
+
function _iterableToArrayLimit(arr, i) {
|
|
33
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
34
|
+
if (null != _i) {
|
|
35
|
+
var _s,
|
|
36
|
+
_e,
|
|
37
|
+
_x,
|
|
38
|
+
_r,
|
|
39
|
+
_arr = [],
|
|
40
|
+
_n = !0,
|
|
41
|
+
_d = !1;
|
|
42
|
+
try {
|
|
43
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
44
|
+
if (Object(_i) !== _i) return;
|
|
45
|
+
_n = !1;
|
|
46
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
_d = !0, _e = err;
|
|
49
|
+
} finally {
|
|
50
|
+
try {
|
|
51
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
52
|
+
} finally {
|
|
53
|
+
if (_d) throw _e;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return _arr;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function ownKeys(object, enumerableOnly) {
|
|
60
|
+
var keys = Object.keys(object);
|
|
61
|
+
if (Object.getOwnPropertySymbols) {
|
|
62
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
63
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
64
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
65
|
+
})), keys.push.apply(keys, symbols);
|
|
66
|
+
}
|
|
67
|
+
return keys;
|
|
68
|
+
}
|
|
69
|
+
function _objectSpread2(target) {
|
|
70
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
71
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
72
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
73
|
+
_defineProperty(target, key, source[key]);
|
|
74
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
75
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return target;
|
|
79
|
+
}
|
|
32
80
|
function _classCallCheck(instance, Constructor) {
|
|
33
81
|
if (!(instance instanceof Constructor)) {
|
|
34
82
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -40,15 +88,19 @@ function _defineProperties(target, props) {
|
|
|
40
88
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
41
89
|
descriptor.configurable = true;
|
|
42
90
|
if ("value" in descriptor) descriptor.writable = true;
|
|
43
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
91
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
44
92
|
}
|
|
45
93
|
}
|
|
46
94
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
47
95
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
48
96
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
97
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
98
|
+
writable: false
|
|
99
|
+
});
|
|
49
100
|
return Constructor;
|
|
50
101
|
}
|
|
51
102
|
function _defineProperty(obj, key, value) {
|
|
103
|
+
key = _toPropertyKey(key);
|
|
52
104
|
if (key in obj) {
|
|
53
105
|
Object.defineProperty(obj, key, {
|
|
54
106
|
value: value,
|
|
@@ -61,34 +113,6 @@ function _defineProperty(obj, key, value) {
|
|
|
61
113
|
}
|
|
62
114
|
return obj;
|
|
63
115
|
}
|
|
64
|
-
function ownKeys(object, enumerableOnly) {
|
|
65
|
-
var keys = Object.keys(object);
|
|
66
|
-
if (Object.getOwnPropertySymbols) {
|
|
67
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
68
|
-
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
69
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
70
|
-
});
|
|
71
|
-
keys.push.apply(keys, symbols);
|
|
72
|
-
}
|
|
73
|
-
return keys;
|
|
74
|
-
}
|
|
75
|
-
function _objectSpread2(target) {
|
|
76
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
77
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
78
|
-
if (i % 2) {
|
|
79
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
80
|
-
_defineProperty(target, key, source[key]);
|
|
81
|
-
});
|
|
82
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
83
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
84
|
-
} else {
|
|
85
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
86
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return target;
|
|
91
|
-
}
|
|
92
116
|
function _inherits(subClass, superClass) {
|
|
93
117
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
94
118
|
throw new TypeError("Super expression must either be null or a function");
|
|
@@ -100,16 +124,19 @@ function _inherits(subClass, superClass) {
|
|
|
100
124
|
configurable: true
|
|
101
125
|
}
|
|
102
126
|
});
|
|
127
|
+
Object.defineProperty(subClass, "prototype", {
|
|
128
|
+
writable: false
|
|
129
|
+
});
|
|
103
130
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
104
131
|
}
|
|
105
132
|
function _getPrototypeOf(o) {
|
|
106
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
133
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
107
134
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
108
135
|
};
|
|
109
136
|
return _getPrototypeOf(o);
|
|
110
137
|
}
|
|
111
138
|
function _setPrototypeOf(o, p) {
|
|
112
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
139
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
113
140
|
o.__proto__ = p;
|
|
114
141
|
return o;
|
|
115
142
|
};
|
|
@@ -120,7 +147,7 @@ function _isNativeReflectConstruct() {
|
|
|
120
147
|
if (Reflect.construct.sham) return false;
|
|
121
148
|
if (typeof Proxy === "function") return true;
|
|
122
149
|
try {
|
|
123
|
-
|
|
150
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
124
151
|
return true;
|
|
125
152
|
} catch (e) {
|
|
126
153
|
return false;
|
|
@@ -128,7 +155,7 @@ function _isNativeReflectConstruct() {
|
|
|
128
155
|
}
|
|
129
156
|
function _construct(Parent, args, Class) {
|
|
130
157
|
if (_isNativeReflectConstruct()) {
|
|
131
|
-
_construct = Reflect.construct;
|
|
158
|
+
_construct = Reflect.construct.bind();
|
|
132
159
|
} else {
|
|
133
160
|
_construct = function _construct(Parent, args, Class) {
|
|
134
161
|
var a = [null];
|
|
@@ -179,6 +206,8 @@ function _assertThisInitialized(self) {
|
|
|
179
206
|
function _possibleConstructorReturn(self, call) {
|
|
180
207
|
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
181
208
|
return call;
|
|
209
|
+
} else if (call !== void 0) {
|
|
210
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
182
211
|
}
|
|
183
212
|
return _assertThisInitialized(self);
|
|
184
213
|
}
|
|
@@ -203,21 +232,21 @@ function _superPropBase(object, property) {
|
|
|
203
232
|
}
|
|
204
233
|
return object;
|
|
205
234
|
}
|
|
206
|
-
function _get(
|
|
235
|
+
function _get() {
|
|
207
236
|
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
208
|
-
_get = Reflect.get;
|
|
237
|
+
_get = Reflect.get.bind();
|
|
209
238
|
} else {
|
|
210
239
|
_get = function _get(target, property, receiver) {
|
|
211
240
|
var base = _superPropBase(target, property);
|
|
212
241
|
if (!base) return;
|
|
213
242
|
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
214
243
|
if (desc.get) {
|
|
215
|
-
return desc.get.call(receiver);
|
|
244
|
+
return desc.get.call(arguments.length < 3 ? target : receiver);
|
|
216
245
|
}
|
|
217
246
|
return desc.value;
|
|
218
247
|
};
|
|
219
248
|
}
|
|
220
|
-
return _get(
|
|
249
|
+
return _get.apply(this, arguments);
|
|
221
250
|
}
|
|
222
251
|
function _slicedToArray(arr, i) {
|
|
223
252
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
@@ -232,30 +261,7 @@ function _arrayWithHoles(arr) {
|
|
|
232
261
|
if (Array.isArray(arr)) return arr;
|
|
233
262
|
}
|
|
234
263
|
function _iterableToArray(iter) {
|
|
235
|
-
if (typeof Symbol !== "undefined" && Symbol.iterator
|
|
236
|
-
}
|
|
237
|
-
function _iterableToArrayLimit(arr, i) {
|
|
238
|
-
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
239
|
-
var _arr = [];
|
|
240
|
-
var _n = true;
|
|
241
|
-
var _d = false;
|
|
242
|
-
var _e = undefined;
|
|
243
|
-
try {
|
|
244
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
245
|
-
_arr.push(_s.value);
|
|
246
|
-
if (i && _arr.length === i) break;
|
|
247
|
-
}
|
|
248
|
-
} catch (err) {
|
|
249
|
-
_d = true;
|
|
250
|
-
_e = err;
|
|
251
|
-
} finally {
|
|
252
|
-
try {
|
|
253
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
254
|
-
} finally {
|
|
255
|
-
if (_d) throw _e;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return _arr;
|
|
264
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
259
265
|
}
|
|
260
266
|
function _unsupportedIterableToArray(o, minLen) {
|
|
261
267
|
if (!o) return;
|
|
@@ -277,8 +283,8 @@ function _nonIterableRest() {
|
|
|
277
283
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
278
284
|
}
|
|
279
285
|
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
280
|
-
var it;
|
|
281
|
-
if (
|
|
286
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
287
|
+
if (!it) {
|
|
282
288
|
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
283
289
|
if (it) o = it;
|
|
284
290
|
var i = 0;
|
|
@@ -307,7 +313,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
|
307
313
|
err;
|
|
308
314
|
return {
|
|
309
315
|
s: function () {
|
|
310
|
-
it =
|
|
316
|
+
it = it.call(o);
|
|
311
317
|
},
|
|
312
318
|
n: function () {
|
|
313
319
|
var step = it.next();
|
|
@@ -327,6 +333,20 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
|
327
333
|
}
|
|
328
334
|
};
|
|
329
335
|
}
|
|
336
|
+
function _toPrimitive(input, hint) {
|
|
337
|
+
if (typeof input !== "object" || input === null) return input;
|
|
338
|
+
var prim = input[Symbol.toPrimitive];
|
|
339
|
+
if (prim !== undefined) {
|
|
340
|
+
var res = prim.call(input, hint || "default");
|
|
341
|
+
if (typeof res !== "object") return res;
|
|
342
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
343
|
+
}
|
|
344
|
+
return (hint === "string" ? String : Number)(input);
|
|
345
|
+
}
|
|
346
|
+
function _toPropertyKey(arg) {
|
|
347
|
+
var key = _toPrimitive(arg, "string");
|
|
348
|
+
return typeof key === "symbol" ? key : String(key);
|
|
349
|
+
}
|
|
330
350
|
|
|
331
351
|
/**
|
|
332
352
|
* The Settings to be passed to the Class
|
|
@@ -1552,12 +1572,15 @@ var Area = /*#__PURE__*/function () {
|
|
|
1552
1572
|
/** @param {DSArea} area */
|
|
1553
1573
|
_createClass(Area, [{
|
|
1554
1574
|
key: "HTMLNode",
|
|
1575
|
+
get:
|
|
1555
1576
|
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
1556
1577
|
// Node Getters
|
|
1557
|
-
|
|
1578
|
+
|
|
1579
|
+
function get() {
|
|
1558
1580
|
return (/** @type {DSArea} */this._node
|
|
1559
1581
|
);
|
|
1560
1582
|
}
|
|
1583
|
+
|
|
1561
1584
|
/**
|
|
1562
1585
|
* The computed border from the element (caches result)
|
|
1563
1586
|
* @type {{top:number,bottom:number,left:number,right:number}}
|
|
@@ -1573,6 +1596,7 @@ var Area = /*#__PURE__*/function () {
|
|
|
1573
1596
|
right: parseInt(this.computedStyle.borderRightWidth)
|
|
1574
1597
|
};
|
|
1575
1598
|
}
|
|
1599
|
+
|
|
1576
1600
|
/**
|
|
1577
1601
|
* The computed styles from the element (caches result)
|
|
1578
1602
|
* @type {CSSStyleDeclaration}
|
|
@@ -1584,6 +1608,7 @@ var Area = /*#__PURE__*/function () {
|
|
|
1584
1608
|
if (this.HTMLNode instanceof Document) return this._computedStyle = window.getComputedStyle(this.HTMLNode.body || this.HTMLNode.documentElement);
|
|
1585
1609
|
return this._computedStyle = window.getComputedStyle(this.HTMLNode);
|
|
1586
1610
|
}
|
|
1611
|
+
|
|
1587
1612
|
/**
|
|
1588
1613
|
* The element rect (caches result) (without scrollbar or borders)
|
|
1589
1614
|
* @type {DSBoundingRect}
|
|
@@ -1961,6 +1986,7 @@ var DropZone = /*#__PURE__*/function () {
|
|
|
1961
1986
|
this._itemsInside = null;
|
|
1962
1987
|
this.isDestroyed = true;
|
|
1963
1988
|
}
|
|
1989
|
+
|
|
1964
1990
|
/**
|
|
1965
1991
|
* @returns {DSDropZone}
|
|
1966
1992
|
*/
|
|
@@ -2014,7 +2040,7 @@ var DropZone = /*#__PURE__*/function () {
|
|
|
2014
2040
|
return DropZone;
|
|
2015
2041
|
}();
|
|
2016
2042
|
|
|
2017
|
-
var DropZones =
|
|
2043
|
+
var DropZones = /*#__PURE__*/_createClass(
|
|
2018
2044
|
/**
|
|
2019
2045
|
* Get the drop zone by the zone element
|
|
2020
2046
|
* @type {Map<DSElement, DropZone>}
|
|
@@ -2143,7 +2169,7 @@ function DropZones(_ref) {
|
|
|
2143
2169
|
/**
|
|
2144
2170
|
* @param {Object} obj
|
|
2145
2171
|
* @param {DSDropZone[]} [obj.dropZones]
|
|
2146
|
-
|
|
2172
|
+
*/);
|
|
2147
2173
|
|
|
2148
2174
|
var Interaction = /*#__PURE__*/function () {
|
|
2149
2175
|
/** @type {boolean} */
|
|
@@ -2215,6 +2241,7 @@ var Interaction = /*#__PURE__*/function () {
|
|
|
2215
2241
|
var event = _ref2.event;
|
|
2216
2242
|
if (!_this._canInteract(event)) return;
|
|
2217
2243
|
if (event.detail > 0) return; // mouse interaction
|
|
2244
|
+
|
|
2218
2245
|
var _this$DS = _this.DS,
|
|
2219
2246
|
_this$DS$stores = _this$DS.stores,
|
|
2220
2247
|
PointerStore = _this$DS$stores.PointerStore,
|
|
@@ -2304,10 +2331,11 @@ var Interaction = /*#__PURE__*/function () {
|
|
|
2304
2331
|
}
|
|
2305
2332
|
_createClass(Interaction, [{
|
|
2306
2333
|
key: "_canInteract",
|
|
2334
|
+
value:
|
|
2307
2335
|
/**
|
|
2308
2336
|
* @param {DSEvent} event
|
|
2309
2337
|
*/
|
|
2310
|
-
|
|
2338
|
+
function _canInteract(event) {
|
|
2311
2339
|
var isKeyboardClick = /** @type {MouseEvent} */event.clientX === 0 && /** @type {MouseEvent} */event.clientY === 0 && /** @type {MouseEvent} */event.detail === 0 && event.target;
|
|
2312
2340
|
if ( /** @type {MouseEvent} */event.button === 2 ||
|
|
2313
2341
|
// right-clicks
|
|
@@ -2319,6 +2347,7 @@ var Interaction = /*#__PURE__*/function () {
|
|
|
2319
2347
|
) return false;
|
|
2320
2348
|
return true;
|
|
2321
2349
|
}
|
|
2350
|
+
|
|
2322
2351
|
/**
|
|
2323
2352
|
* @param {DSEvent} event
|
|
2324
2353
|
*/
|
|
@@ -2326,7 +2355,7 @@ var Interaction = /*#__PURE__*/function () {
|
|
|
2326
2355
|
return Interaction;
|
|
2327
2356
|
}();
|
|
2328
2357
|
|
|
2329
|
-
var PubSub = function PubSub(_ref) {
|
|
2358
|
+
var PubSub = /*#__PURE__*/_createClass(function PubSub(_ref) {
|
|
2330
2359
|
var _this = this;
|
|
2331
2360
|
var DS = _ref.DS;
|
|
2332
2361
|
_classCallCheck(this, PubSub);
|
|
@@ -2374,7 +2403,7 @@ var PubSub = function PubSub(_ref) {
|
|
|
2374
2403
|
* @param {DSCallbackNames} eventName
|
|
2375
2404
|
* @param {DSCallback} callback
|
|
2376
2405
|
* @returns {number} event id, can be used to unsubscribe more efficiently
|
|
2377
|
-
|
|
2406
|
+
*/);
|
|
2378
2407
|
|
|
2379
2408
|
var SelectableSet = /*#__PURE__*/function (_Set) {
|
|
2380
2409
|
_inherits(SelectableSet, _Set);
|
|
@@ -2451,7 +2480,8 @@ var SelectableSet = /*#__PURE__*/function (_Set) {
|
|
|
2451
2480
|
}
|
|
2452
2481
|
_createClass(SelectableSet, [{
|
|
2453
2482
|
key: "add",
|
|
2454
|
-
/** @param {DSElement} element */
|
|
2483
|
+
value: /** @param {DSElement} element */
|
|
2484
|
+
function add(element) {
|
|
2455
2485
|
if (_get(_getPrototypeOf(SelectableSet.prototype), "has", this).call(this, element)) return;
|
|
2456
2486
|
var publishData = {
|
|
2457
2487
|
items: this.elements,
|
|
@@ -2474,7 +2504,9 @@ var SelectableSet = /*#__PURE__*/function (_Set) {
|
|
|
2474
2504
|
});
|
|
2475
2505
|
this.DS.publish('Selectable:added', publishData);
|
|
2476
2506
|
return _get(_getPrototypeOf(SelectableSet.prototype), "add", this).call(this, element);
|
|
2477
|
-
}
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
/** @param {DSElement} element */
|
|
2478
2510
|
}, {
|
|
2479
2511
|
key: "delete",
|
|
2480
2512
|
value: function _delete(element) {
|
|
@@ -2500,7 +2532,8 @@ var SelectableSet = /*#__PURE__*/function (_Set) {
|
|
|
2500
2532
|
}
|
|
2501
2533
|
}, {
|
|
2502
2534
|
key: "elements",
|
|
2503
|
-
/** @return {DSElements} */
|
|
2535
|
+
get: /** @return {DSElements} */
|
|
2536
|
+
function get() {
|
|
2504
2537
|
return Array.from(this.values());
|
|
2505
2538
|
}
|
|
2506
2539
|
}, {
|
|
@@ -2571,7 +2604,9 @@ var SelectedSet = /*#__PURE__*/function (_Set) {
|
|
|
2571
2604
|
element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) + 1);
|
|
2572
2605
|
this.DS.publish('Selected:added', publishData);
|
|
2573
2606
|
return this;
|
|
2574
|
-
}
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
/** @param {DSElement} element */
|
|
2575
2610
|
}, {
|
|
2576
2611
|
key: "delete",
|
|
2577
2612
|
value: function _delete(element) {
|
|
@@ -2589,18 +2624,22 @@ var SelectedSet = /*#__PURE__*/function (_Set) {
|
|
|
2589
2624
|
}
|
|
2590
2625
|
}, {
|
|
2591
2626
|
key: "toggle",
|
|
2627
|
+
value:
|
|
2592
2628
|
/**
|
|
2593
2629
|
* Adds/Removes an element. If it is already selected = remove, if not = add.
|
|
2594
2630
|
* @param {DSElement} element
|
|
2595
2631
|
* @return {DSElement}
|
|
2596
2632
|
*/
|
|
2597
|
-
|
|
2633
|
+
function toggle(element) {
|
|
2598
2634
|
if (this.has(element)) this["delete"](element);else this.add(element);
|
|
2599
2635
|
return element;
|
|
2600
|
-
}
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
/** @param {DSElements} elements */
|
|
2601
2639
|
}, {
|
|
2602
2640
|
key: "elements",
|
|
2603
|
-
/** @return {DSElements} */
|
|
2641
|
+
get: /** @return {DSElements} */
|
|
2642
|
+
function get() {
|
|
2604
2643
|
return Array.from(this.values());
|
|
2605
2644
|
}
|
|
2606
2645
|
}]);
|
|
@@ -2640,6 +2679,7 @@ var Selection = /*#__PURE__*/function () {
|
|
|
2640
2679
|
SelectableSet = _this$DS.SelectableSet,
|
|
2641
2680
|
SelectorArea = _this$DS.SelectorArea,
|
|
2642
2681
|
Selector = _this$DS.Selector;
|
|
2682
|
+
|
|
2643
2683
|
/** @type {any} */
|
|
2644
2684
|
var elRects = SelectableSet.rects;
|
|
2645
2685
|
var select = [];
|
|
@@ -2698,7 +2738,9 @@ var Selection = /*#__PURE__*/function () {
|
|
|
2698
2738
|
KeyStore = _this$DS2.stores.KeyStore,
|
|
2699
2739
|
SelectedSet = _this$DS2.SelectedSet;
|
|
2700
2740
|
if (KeyStore.isMultiSelectKeyPressed(event)) this._prevSelectedSet = new Set(SelectedSet);else this._prevSelectedSet = new Set();
|
|
2701
|
-
}
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
/** @param {{event:DSEvent,isDragging:boolean}} event */
|
|
2702
2744
|
}]);
|
|
2703
2745
|
return Selection;
|
|
2704
2746
|
}();
|
|
@@ -2884,12 +2926,13 @@ var SelectorArea = /*#__PURE__*/function () {
|
|
|
2884
2926
|
}
|
|
2885
2927
|
_createClass(SelectorArea, [{
|
|
2886
2928
|
key: "isClicked",
|
|
2929
|
+
value:
|
|
2887
2930
|
/**
|
|
2888
2931
|
* checks if the click was triggered on the area.
|
|
2889
2932
|
* @param {DSEvent} [event]
|
|
2890
2933
|
* @returns {boolean}
|
|
2891
2934
|
*/
|
|
2892
|
-
|
|
2935
|
+
function isClicked(event) {
|
|
2893
2936
|
var PointerStore = this.DS.stores.PointerStore;
|
|
2894
2937
|
var initialVal = event ? PointerStore.getPointerPosition(event) : PointerStore.initialVal;
|
|
2895
2938
|
return isCollision({
|
|
@@ -2979,7 +3022,8 @@ var KeyStore = /*#__PURE__*/function () {
|
|
|
2979
3022
|
}
|
|
2980
3023
|
_createClass(KeyStore, [{
|
|
2981
3024
|
key: "isMultiSelectKeyPressed",
|
|
2982
|
-
/** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */
|
|
3025
|
+
value: /** @param {KeyboardEvent|MouseEvent|PointerEvent|TouchEvent} [event] */
|
|
3026
|
+
function isMultiSelectKeyPressed(event) {
|
|
2983
3027
|
var _this2 = this;
|
|
2984
3028
|
if (this.DS.stores.SettingsStore.s.multiSelectMode) return true;
|
|
2985
3029
|
var multiSelectKeys = this.DS.stores.SettingsStore.s.multiSelectKeys.map(function (key) {
|
|
@@ -3121,25 +3165,31 @@ var PointerStore = /*#__PURE__*/function () {
|
|
|
3121
3165
|
}
|
|
3122
3166
|
_createClass(PointerStore, [{
|
|
3123
3167
|
key: "start",
|
|
3124
|
-
/** @param {DSEvent} [event] */
|
|
3168
|
+
value: /** @param {DSEvent} [event] */
|
|
3169
|
+
function start(event) {
|
|
3125
3170
|
if (!event) return;
|
|
3126
3171
|
this._isMouseInteraction = true;
|
|
3127
3172
|
this.currentVal = this.initialVal = this.getPointerPosition(event);
|
|
3128
|
-
}
|
|
3173
|
+
}
|
|
3174
|
+
|
|
3175
|
+
/** @param {DSEvent} event */
|
|
3129
3176
|
}, {
|
|
3130
3177
|
key: "_normalizedEvent",
|
|
3178
|
+
value:
|
|
3131
3179
|
/**
|
|
3132
3180
|
* @param {DSEvent} event
|
|
3133
3181
|
* @return {MouseEvent|PointerEvent|Touch}
|
|
3134
3182
|
* @private
|
|
3135
3183
|
*/
|
|
3136
|
-
|
|
3184
|
+
function _normalizedEvent(event) {
|
|
3137
3185
|
// touchend has not touches. so we take the last touch if a touchevent, we need to store the positions
|
|
3138
3186
|
if ('touches' in event && event.type !== 'touchend') this._lastTouch = event;
|
|
3139
3187
|
// if a touchevent, return the last touch rather than the regular event
|
|
3140
3188
|
// we need .touches[0] from that event instead
|
|
3141
3189
|
return 'touches' in event ? this._lastTouch.touches[0] : event;
|
|
3142
|
-
}
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3192
|
+
/** First recorded pointer position within the area */
|
|
3143
3193
|
}, {
|
|
3144
3194
|
key: "initialValArea",
|
|
3145
3195
|
get: function get() {
|
|
@@ -3148,7 +3198,9 @@ var PointerStore = /*#__PURE__*/function () {
|
|
|
3148
3198
|
y: 0
|
|
3149
3199
|
};
|
|
3150
3200
|
return this._initialValArea;
|
|
3151
|
-
}
|
|
3201
|
+
}
|
|
3202
|
+
|
|
3203
|
+
/** Current pointer position within the area */
|
|
3152
3204
|
}, {
|
|
3153
3205
|
key: "currentValArea",
|
|
3154
3206
|
get: function get() {
|
|
@@ -3157,7 +3209,9 @@ var PointerStore = /*#__PURE__*/function () {
|
|
|
3157
3209
|
y: 0
|
|
3158
3210
|
};
|
|
3159
3211
|
return this._currentValArea;
|
|
3160
|
-
}
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
/** Last recorded pointer position within the area */
|
|
3161
3215
|
}, {
|
|
3162
3216
|
key: "lastValArea",
|
|
3163
3217
|
get: function get() {
|
|
@@ -3166,7 +3220,9 @@ var PointerStore = /*#__PURE__*/function () {
|
|
|
3166
3220
|
y: 0
|
|
3167
3221
|
};
|
|
3168
3222
|
return this._lastValArea;
|
|
3169
|
-
}
|
|
3223
|
+
}
|
|
3224
|
+
|
|
3225
|
+
/** First recorded pointer position */
|
|
3170
3226
|
}, {
|
|
3171
3227
|
key: "initialVal",
|
|
3172
3228
|
get: function get() {
|
|
@@ -3175,7 +3231,9 @@ var PointerStore = /*#__PURE__*/function () {
|
|
|
3175
3231
|
y: 0
|
|
3176
3232
|
};
|
|
3177
3233
|
return this._initialVal;
|
|
3178
|
-
}
|
|
3234
|
+
}
|
|
3235
|
+
|
|
3236
|
+
/** Current pointer position */,
|
|
3179
3237
|
set: function set(value) {
|
|
3180
3238
|
this._initialVal = value;
|
|
3181
3239
|
this._initialValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
|
|
@@ -3188,7 +3246,9 @@ var PointerStore = /*#__PURE__*/function () {
|
|
|
3188
3246
|
y: 0
|
|
3189
3247
|
};
|
|
3190
3248
|
return this._currentVal;
|
|
3191
|
-
}
|
|
3249
|
+
}
|
|
3250
|
+
|
|
3251
|
+
/** Last recorded pointer position */,
|
|
3192
3252
|
set: function set(value) {
|
|
3193
3253
|
this._currentVal = value;
|
|
3194
3254
|
this._currentValArea = value && calc(value, '-', calc(rect2vect(this.DS.Area.rect), '+', rect2vect(this.DS.Area.computedBorder)));
|
|
@@ -3305,7 +3365,7 @@ var ScrollStore = /*#__PURE__*/function () {
|
|
|
3305
3365
|
return ScrollStore;
|
|
3306
3366
|
}();
|
|
3307
3367
|
|
|
3308
|
-
var SettingsStore =
|
|
3368
|
+
var SettingsStore = /*#__PURE__*/_createClass(
|
|
3309
3369
|
/**
|
|
3310
3370
|
* @type {Settings}
|
|
3311
3371
|
* @private
|
|
@@ -3384,7 +3444,7 @@ function SettingsStore(_ref) {
|
|
|
3384
3444
|
});
|
|
3385
3445
|
}
|
|
3386
3446
|
|
|
3387
|
-
/** @param {{settings: Settings, init?: boolean}} props
|
|
3447
|
+
/** @param {{settings: Settings, init?: boolean}} props */);
|
|
3388
3448
|
|
|
3389
3449
|
// Setup
|
|
3390
3450
|
/// ///////////////////////////////////////////////////////////////////////////////////
|
|
@@ -3525,6 +3585,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3525
3585
|
*/
|
|
3526
3586
|
_createClass(DragSelect, [{
|
|
3527
3587
|
key: "stop",
|
|
3588
|
+
value:
|
|
3528
3589
|
/**
|
|
3529
3590
|
* Complete function teardown
|
|
3530
3591
|
* Will teardown/stop the whole functionality
|
|
@@ -3532,7 +3593,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3532
3593
|
* @param {boolean} [fromSelection] - if elements should also be added/removed to the selection.
|
|
3533
3594
|
* @param {boolean} [withCallback] - if elements should also be added/removed to the selection.
|
|
3534
3595
|
*/
|
|
3535
|
-
|
|
3596
|
+
function stop() {
|
|
3536
3597
|
var remove = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
3537
3598
|
var fromSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
3538
3599
|
var withCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -3551,6 +3612,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3551
3612
|
if (fromSelection) this.SelectedSet.clear();
|
|
3552
3613
|
this.stopped = true;
|
|
3553
3614
|
}
|
|
3615
|
+
|
|
3554
3616
|
/**
|
|
3555
3617
|
* Utility to override DragSelect internal functionality:
|
|
3556
3618
|
* Break will skip the selection or dragging functionality (until after the callback) but let everything continue to run.
|
|
@@ -3558,6 +3620,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3558
3620
|
*/
|
|
3559
3621
|
}, {
|
|
3560
3622
|
key: "addSelection",
|
|
3623
|
+
value:
|
|
3561
3624
|
/**
|
|
3562
3625
|
* Adds several elements to the selection list also adds the specific classes and take into account all calculations.
|
|
3563
3626
|
* Does not clear the selection, in contrary to .setSelection. Can add multiple elements at once
|
|
@@ -3566,7 +3629,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3566
3629
|
* @param {boolean} [dontAddToSelectables] - if element should not be added to the list of selectable elements
|
|
3567
3630
|
* @return {DSElements} all selected elements
|
|
3568
3631
|
*/
|
|
3569
|
-
|
|
3632
|
+
function addSelection(elements) {
|
|
3570
3633
|
var triggerCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3571
3634
|
var dontAddToSelectables = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3572
3635
|
this.SelectedSet.addAll(toArray(elements));
|
|
@@ -3576,6 +3639,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3576
3639
|
});
|
|
3577
3640
|
return this.getSelection();
|
|
3578
3641
|
}
|
|
3642
|
+
|
|
3579
3643
|
/**
|
|
3580
3644
|
* Removes specific elements from the selection
|
|
3581
3645
|
* Multiple elements can be given at once, in contrary to unselect
|
|
@@ -3596,6 +3660,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3596
3660
|
});
|
|
3597
3661
|
return this.getSelection();
|
|
3598
3662
|
}
|
|
3663
|
+
|
|
3599
3664
|
/**
|
|
3600
3665
|
* Toggles specific elements from the selection:
|
|
3601
3666
|
* If element is not in selection it will be added, if it is already selected, it will be removed.
|
|
@@ -3619,6 +3684,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3619
3684
|
});
|
|
3620
3685
|
return this.getSelection();
|
|
3621
3686
|
}
|
|
3687
|
+
|
|
3622
3688
|
/**
|
|
3623
3689
|
* Sets the current selected elements and optionally run the callback
|
|
3624
3690
|
* By default, adds new elements also to the list of selectables
|
|
@@ -3636,6 +3702,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3636
3702
|
this.addSelection(elements, triggerCallback, dontAddToSelectables);
|
|
3637
3703
|
return this.getSelection();
|
|
3638
3704
|
}
|
|
3705
|
+
|
|
3639
3706
|
/**
|
|
3640
3707
|
* Unselect / Deselect all current selected Nodes
|
|
3641
3708
|
* @param {boolean} [triggerCallback] - if callback should be called
|
|
@@ -3651,6 +3718,7 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3651
3718
|
});
|
|
3652
3719
|
return this.getSelection();
|
|
3653
3720
|
}
|
|
3721
|
+
|
|
3654
3722
|
/**
|
|
3655
3723
|
* Add elements that can be selected. No node is added twice
|
|
3656
3724
|
* @param {DSInputElements} elements dom element(s)
|
|
@@ -3669,12 +3737,14 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3669
3737
|
});
|
|
3670
3738
|
return elements;
|
|
3671
3739
|
}
|
|
3740
|
+
|
|
3672
3741
|
/**
|
|
3673
3742
|
* Gets all nodes that can potentially be selected
|
|
3674
3743
|
* @return {DSElements} this.selectables
|
|
3675
3744
|
*/
|
|
3676
3745
|
}, {
|
|
3677
3746
|
key: "setSelectables",
|
|
3747
|
+
value:
|
|
3678
3748
|
/**
|
|
3679
3749
|
* Sets all elements that can be selected.
|
|
3680
3750
|
* Removes all current selectables (& their respective classes).
|
|
@@ -3684,13 +3754,14 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3684
3754
|
* @param {boolean} [addToSelection] if elements should also be added to current selection
|
|
3685
3755
|
* @return {DSInputElements} elements – the added element(s)
|
|
3686
3756
|
*/
|
|
3687
|
-
|
|
3757
|
+
function setSelectables(elements) {
|
|
3688
3758
|
var removeFromSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3689
3759
|
var addToSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3690
3760
|
console.warn('[DragSelect] DEPRECATION ".setSelectables" is deprecated and will be removed soon. Please use "ds.setSettings({ selectables: << new dom elements >> })" instead (see docs)');
|
|
3691
3761
|
this.removeSelectables(elements, removeFromSelection);
|
|
3692
3762
|
return this.addSelectables(elements, addToSelection);
|
|
3693
3763
|
}
|
|
3764
|
+
|
|
3694
3765
|
/**
|
|
3695
3766
|
* Remove elements from the elements that can be selected.
|
|
3696
3767
|
* @param {DSInputElements} elements – dom element(s)
|
|
@@ -3707,9 +3778,11 @@ var DragSelect = /*#__PURE__*/function () {
|
|
|
3707
3778
|
items: this.getSelection()
|
|
3708
3779
|
});
|
|
3709
3780
|
return elements;
|
|
3710
|
-
}
|
|
3781
|
+
}
|
|
3782
|
+
|
|
3783
|
+
/** The starting/initial position of the cursor/selector @return {Vect2} */
|
|
3711
3784
|
}]);
|
|
3712
3785
|
return DragSelect;
|
|
3713
3786
|
}();
|
|
3714
3787
|
|
|
3715
|
-
export default
|
|
3788
|
+
export { DragSelect as default };
|