dragselect 2.3.1 → 2.4.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.
- package/CHANGELOG.md +7 -0
- package/README.md +45 -23
- package/deploying.md +7 -4
- package/dist/DragSelect.d.ts +10 -18
- package/dist/DragSelect.es6m.js +412 -579
- package/dist/DragSelect.js +412 -579
- package/dist/ds.es6m.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/dist/methods/createSelectorAreaElement.d.ts +1 -1
- package/dist/methods/getOverflowEdges.d.ts +1 -1
- package/dist/methods/hydrateSettings.d.ts +3 -0
- package/dist/methods/index.d.ts +1 -0
- package/dist/modules/Area.d.ts +10 -15
- package/dist/modules/Drag.d.ts +4 -40
- package/dist/modules/Interaction.d.ts +2 -31
- package/dist/modules/SelectableSet.d.ts +6 -38
- package/dist/modules/SelectedSet.d.ts +6 -10
- package/dist/modules/Selection.d.ts +2 -14
- package/dist/modules/Selector.d.ts +5 -11
- package/dist/modules/SelectorArea.d.ts +4 -17
- package/dist/stores/KeyStore.d.ts +2 -14
- package/dist/stores/ScrollStore.d.ts +2 -9
- package/dist/stores/SettingsStore.d.ts +39 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/types.d.ts +13 -32
- package/package.json +3 -3
- package/src/DragSelect.js +22 -175
- package/src/methods/createSelectorAreaElement.js +1 -3
- package/src/methods/hydrateSettings.js +109 -0
- package/src/methods/index.js +1 -0
- package/src/modules/Area.js +24 -22
- package/src/modules/Drag.js +37 -71
- package/src/modules/Interaction.js +14 -45
- package/src/modules/SelectableSet.js +29 -54
- package/src/modules/SelectedSet.js +4 -13
- package/src/modules/Selection.js +6 -19
- package/src/modules/Selector.js +21 -8
- package/src/modules/SelectorArea.js +12 -17
- package/src/stores/KeyStore.js +11 -37
- package/src/stores/ScrollStore.js +17 -17
- package/src/stores/SettingsStore.js +67 -0
- package/src/stores/index.js +1 -0
- package/src/types.js +4 -7
package/dist/DragSelect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/***
|
|
2
2
|
|
|
3
|
-
~~~ Version 2.
|
|
3
|
+
~~~ Version 2.4.0 ~~~
|
|
4
4
|
|
|
5
5
|
******************************************
|
|
6
6
|
|
|
@@ -366,12 +366,6 @@
|
|
|
366
366
|
* @property {string} [selectedClass=ds-selected] the class assigned to the selected items
|
|
367
367
|
* @property {string} [selectorClass=ds-selector] the class assigned to the square selector helper
|
|
368
368
|
* @property {string} [selectorAreaClass=ds-selector-area] the class assigned to the square in which the selector resides. By default it's invisible
|
|
369
|
-
* @property {DSCallback} [callback] Deprecated: please use DragSelect.subscribe('callback', callback) instead
|
|
370
|
-
* @property {DSCallback} [onDragMove] Deprecated: please use DragSelect.subscribe('onDragMove', onDragMove) instead
|
|
371
|
-
* @property {DSCallback} [onDragStartBegin] Deprecated: please use DragSelect.subscribe('onDragStartBegin', onDragStartBegin) instead
|
|
372
|
-
* @property {DSCallback} [onDragStart] Deprecated: please use DragSelect.subscribe('onDragStart', onDragStart) instead
|
|
373
|
-
* @property {DSCallback} [onElementSelect] Deprecated: please use DragSelect.subscribe('onElementSelect', onElementSelect) instead
|
|
374
|
-
* @property {DSCallback} [onElementUnselect] Deprecated: please use DragSelect.subscribe('onElementUnselect', onElementUnselect) instead
|
|
375
369
|
*/
|
|
376
370
|
|
|
377
371
|
/**
|
|
@@ -383,6 +377,7 @@
|
|
|
383
377
|
* @property {boolean} [isDragging] Whether the interaction is a drag or a select
|
|
384
378
|
* @property {boolean} [isDraggingKeyboard] Whether or not the drag interaction is via keyboard
|
|
385
379
|
* @property {string} [key] Pressed key (lowercase)
|
|
380
|
+
* @property {Settings} [settings] the settings being updates/manipulated/passed, also holds the previous value. i.e. updating selectorClass will publish { settings: { selectorClass: 'newVal', 'selectorClass:pre': 'oldVal' } }
|
|
386
381
|
* @property {Array.<'top'|'bottom'|'left'|'right'|undefined>} [scroll_directions]
|
|
387
382
|
* @property {number} [scroll_multiplier]
|
|
388
383
|
*/
|
|
@@ -417,8 +412,11 @@
|
|
|
417
412
|
/** @typedef {'Interaction:init'|'Interaction:start'|'Interaction:end'|'Interaction:update'|'Area:modified'|'Area:scroll'|'PointerStore:updated'|'Selected:added'|'Selected:removed'|'Selectable:click'|'Selectable:pointer'|'KeyStore:down'|'KeyStore:up'} DSInternalEventNames */
|
|
418
413
|
|
|
419
414
|
/** @typedef {'Interaction:init:pre'|'Interaction:start:pre'|'Interaction:end:pre'|'Interaction:update:pre'|'Area:modified:pre'|'Area:scroll:pre'|'PointerStore:updated:pre'|'Selected:added:pre'|'Selected:removed:pre'|'Selectable:click:pre'|'Selectable:pointer:pre'|'KeyStore:down:pre'|'KeyStore:up:pre'} DSInternalEventNamesPre */
|
|
415
|
+
// @todo: update to typescript for complex defs like `Settings:updated:${string}` | `Settings:updated:${string}:pre`
|
|
420
416
|
|
|
421
|
-
/** @typedef {
|
|
417
|
+
/** @typedef {'Settings:updated'|'Settings:updated:pre'|'Settings:updated:*'|'Settings:updated:*:pre'} DSInternalSettingEvents */
|
|
418
|
+
|
|
419
|
+
/** @typedef {DSEventNames|DSInternalEventNames|DSInternalEventNamesPre|DSInternalSettingEvents} DSCallbackNames the name of the callback */
|
|
422
420
|
|
|
423
421
|
/** @typedef {{top:number,left:number,bottom:number,right:number,width:number,height:number}} DSBoundingRect */
|
|
424
422
|
|
|
@@ -542,17 +540,15 @@
|
|
|
542
540
|
// @ts-check
|
|
543
541
|
/**
|
|
544
542
|
* Creates the SelectorArea
|
|
545
|
-
* @param {string} selectorAreaClass
|
|
546
543
|
* @return {HTMLDivElement}
|
|
547
544
|
*/
|
|
548
545
|
|
|
549
|
-
var createSelectorAreaElement = (function (
|
|
546
|
+
var createSelectorAreaElement = (function () {
|
|
550
547
|
var node = document.createElement('div');
|
|
551
548
|
node.style.position = 'fixed';
|
|
552
549
|
node.style.overflow = 'hidden';
|
|
553
550
|
node.style.pointerEvents = 'none';
|
|
554
551
|
node.style.zIndex = '999999999999999999';
|
|
555
|
-
node.classList.add(selectorAreaClass);
|
|
556
552
|
return node;
|
|
557
553
|
});
|
|
558
554
|
|
|
@@ -1079,6 +1075,107 @@
|
|
|
1079
1075
|
element.classList.remove(hoverClassName);
|
|
1080
1076
|
});
|
|
1081
1077
|
|
|
1078
|
+
/**
|
|
1079
|
+
* @param {string} key
|
|
1080
|
+
* @param {string} type
|
|
1081
|
+
* @param {*} fallback
|
|
1082
|
+
* @returns {void}
|
|
1083
|
+
*/
|
|
1084
|
+
var wrongTypeWarn = function wrongTypeWarn(key, type, fallback) {
|
|
1085
|
+
return console.warn("[DragSelect] TypeIssue: setting \"".concat(key, "\" is not of type \"").concat(type, "\"."));
|
|
1086
|
+
};
|
|
1087
|
+
/**
|
|
1088
|
+
* @param {string} key
|
|
1089
|
+
* @param {*} value
|
|
1090
|
+
* @param {boolean} withFallback
|
|
1091
|
+
* @param {*} fallback
|
|
1092
|
+
* @returns {object}
|
|
1093
|
+
*/
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
var hydrateHelper = function hydrateHelper(key, value, withFallback, fallback) {
|
|
1097
|
+
// no value available
|
|
1098
|
+
if (value === undefined) return withFallback ? _defineProperty({}, key, fallback) : {}; // force unsetting of a value
|
|
1099
|
+
|
|
1100
|
+
if (value === null) return _defineProperty({}, key, null); // TypeCheck [GENERIC]
|
|
1101
|
+
|
|
1102
|
+
var isAvailable = true; // if it’s not undefined, it was set voluntarily
|
|
1103
|
+
|
|
1104
|
+
var forceFallback = false; // TypeCheck [String]
|
|
1105
|
+
|
|
1106
|
+
var expectedString = typeof fallback === 'string';
|
|
1107
|
+
if (expectedString) isAvailable = typeof value === 'string' || value instanceof String;
|
|
1108
|
+
|
|
1109
|
+
if (expectedString && !isAvailable) {
|
|
1110
|
+
forceFallback = true;
|
|
1111
|
+
wrongTypeWarn(key, 'string');
|
|
1112
|
+
} // TypeCheck [Number]
|
|
1113
|
+
|
|
1114
|
+
|
|
1115
|
+
var expectedNumber = !isNaN(fallback) && typeof fallback === 'number';
|
|
1116
|
+
if (expectedNumber) isAvailable = !isNaN(value) && typeof value === 'number';
|
|
1117
|
+
|
|
1118
|
+
if (expectedNumber && !isAvailable) {
|
|
1119
|
+
forceFallback = true;
|
|
1120
|
+
wrongTypeWarn(key, 'number');
|
|
1121
|
+
} // TypeCheck [Object]
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
var expectedObject = Object.prototype.toString.call(fallback) === "[object Object]";
|
|
1125
|
+
if (expectedObject) isAvailable = Object.prototype.toString.call(value) === "[object Object]";
|
|
1126
|
+
|
|
1127
|
+
if (expectedObject && !isAvailable) {
|
|
1128
|
+
forceFallback = true;
|
|
1129
|
+
wrongTypeWarn(key, 'object');
|
|
1130
|
+
} // TypeCheck [Boolean]
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
var expectedBoolean = typeof fallback === "boolean";
|
|
1134
|
+
if (expectedBoolean) isAvailable = typeof value === "boolean";
|
|
1135
|
+
|
|
1136
|
+
if (expectedBoolean && !isAvailable) {
|
|
1137
|
+
forceFallback = true;
|
|
1138
|
+
wrongTypeWarn(key, 'boolean');
|
|
1139
|
+
} // TypeCheck [Array]
|
|
1140
|
+
|
|
1141
|
+
|
|
1142
|
+
var expectedArray = Array.isArray(fallback);
|
|
1143
|
+
if (expectedArray) isAvailable = Array.isArray(value);
|
|
1144
|
+
|
|
1145
|
+
if (expectedArray && !isAvailable) {
|
|
1146
|
+
forceFallback = true;
|
|
1147
|
+
wrongTypeWarn(key, 'array');
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
var isFallback = forceFallback || withFallback; // Special rule for [dragKeys]
|
|
1151
|
+
|
|
1152
|
+
if (key === 'dragKeys' && isAvailable) return _defineProperty({}, key, Object.assign(fallback, value));else if (key === 'dragKeys' && !isAvailable) return isFallback ? _defineProperty({}, key, fallback) : {};
|
|
1153
|
+
return isAvailable ? _defineProperty({}, key, value) : isFallback ? _defineProperty({}, key, fallback) : {};
|
|
1154
|
+
};
|
|
1155
|
+
/**
|
|
1156
|
+
* This helper method creates the setting object,
|
|
1157
|
+
* - if the settings provided are of wrong type, the fallback value will be used
|
|
1158
|
+
* - - except for if settings are undefined or explicitly marked as "null"
|
|
1159
|
+
* - if "withfallback" is true, it will return the object with all settings:
|
|
1160
|
+
* - - if not provided from the settings object (or wrong type), the fallback will be used
|
|
1161
|
+
* (the fallback value for each setting is the last prop of the hydrateHelper)
|
|
1162
|
+
* @param {Settings} settings
|
|
1163
|
+
* @param {boolean} withFallback
|
|
1164
|
+
*/
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
var hydrateSettings = (function (settings, withFallback) {
|
|
1168
|
+
return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, hydrateHelper('area', settings.area, withFallback, document)), hydrateHelper('selectables', settings.selectables, withFallback, null)), hydrateHelper('autoScrollSpeed', settings.autoScrollSpeed, withFallback, 5)), hydrateHelper('overflowTolerance', settings.overflowTolerance, withFallback, {
|
|
1169
|
+
x: 25,
|
|
1170
|
+
y: 25
|
|
1171
|
+
})), hydrateHelper('zoom', settings.zoom, withFallback, 1)), hydrateHelper('customStyles', settings.customStyles, withFallback, false)), hydrateHelper('multiSelectMode', settings.multiSelectMode, withFallback, false)), hydrateHelper('multiSelectToggling', settings.multiSelectToggling, withFallback, true)), hydrateHelper('multiSelectKeys', settings.multiSelectKeys, withFallback, ['Control', 'Shift', 'Meta'])), hydrateHelper('selector', settings.selector, withFallback, null)), hydrateHelper('draggability', settings.draggability, withFallback, true)), hydrateHelper('immediateDrag', settings.immediateDrag, withFallback, true)), hydrateHelper('keyboardDrag', settings.keyboardDrag, withFallback, true)), hydrateHelper('dragKeys', settings.dragKeys, withFallback, {
|
|
1172
|
+
up: ['ArrowUp'],
|
|
1173
|
+
down: ['ArrowDown'],
|
|
1174
|
+
left: ['ArrowLeft'],
|
|
1175
|
+
right: ['ArrowRight']
|
|
1176
|
+
})), hydrateHelper('keyboardDragSpeed', settings.keyboardDragSpeed, withFallback, 10)), hydrateHelper('useTransform', settings.useTransform, withFallback, true)), hydrateHelper('hoverClass', settings.hoverClass, withFallback, 'ds-hover')), hydrateHelper('selectableClass', settings.selectableClass, withFallback, 'ds-selectable')), hydrateHelper('selectedClass', settings.selectedClass, withFallback, 'ds-selected')), hydrateHelper('selectorClass', settings.selectorClass, withFallback, 'ds-selector')), hydrateHelper('selectorAreaClass', settings.selectorAreaClass, withFallback, 'ds-selector-area'));
|
|
1177
|
+
});
|
|
1178
|
+
|
|
1082
1179
|
// @ts-check
|
|
1083
1180
|
/**
|
|
1084
1181
|
* Axis-Aligned Bounding Box Collision Detection.
|
|
@@ -1314,14 +1411,12 @@
|
|
|
1314
1411
|
element.style.height = "".concat(pos.height, "px");
|
|
1315
1412
|
});
|
|
1316
1413
|
|
|
1317
|
-
/**
|
|
1318
|
-
* @typedef {Object} AreaProps
|
|
1319
|
-
* @property {DSArea} area
|
|
1320
|
-
* @property {PubSub} PS
|
|
1321
|
-
* @property {number} zoom
|
|
1322
|
-
*/
|
|
1323
|
-
|
|
1324
1414
|
var Area = /*#__PURE__*/function () {
|
|
1415
|
+
/**
|
|
1416
|
+
* @type {DragSelect}
|
|
1417
|
+
* @private
|
|
1418
|
+
*/
|
|
1419
|
+
|
|
1325
1420
|
/**
|
|
1326
1421
|
* @type {DSModificationCallback}
|
|
1327
1422
|
* @private
|
|
@@ -1364,18 +1459,18 @@
|
|
|
1364
1459
|
|
|
1365
1460
|
/**
|
|
1366
1461
|
* @constructor Area
|
|
1367
|
-
* @param {
|
|
1462
|
+
* @param {{DS:DragSelect}} p
|
|
1368
1463
|
* @ignore
|
|
1369
1464
|
*/
|
|
1370
1465
|
function Area(_ref) {
|
|
1371
1466
|
var _this = this;
|
|
1372
1467
|
|
|
1373
|
-
var
|
|
1374
|
-
PS = _ref.PS,
|
|
1375
|
-
zoom = _ref.zoom;
|
|
1468
|
+
var DS = _ref.DS;
|
|
1376
1469
|
|
|
1377
1470
|
_classCallCheck(this, Area);
|
|
1378
1471
|
|
|
1472
|
+
_defineProperty(this, "DS", void 0);
|
|
1473
|
+
|
|
1379
1474
|
_defineProperty(this, "_modificationCallback", void 0);
|
|
1380
1475
|
|
|
1381
1476
|
_defineProperty(this, "_modificationObserver", void 0);
|
|
@@ -1400,13 +1495,13 @@
|
|
|
1400
1495
|
}); // first immediate debounce to update values after dom-update
|
|
1401
1496
|
|
|
1402
1497
|
setTimeout(function () {
|
|
1403
|
-
_this.PubSub.publish('Area:modified:pre', {
|
|
1498
|
+
_this.DS.PubSub.publish('Area:modified:pre', {
|
|
1404
1499
|
item: _this
|
|
1405
1500
|
});
|
|
1406
1501
|
|
|
1407
1502
|
_this.reset();
|
|
1408
1503
|
|
|
1409
|
-
_this.PubSub.publish('Area:modified', {
|
|
1504
|
+
_this.DS.PubSub.publish('Area:modified', {
|
|
1410
1505
|
item: _this
|
|
1411
1506
|
});
|
|
1412
1507
|
});
|
|
@@ -1435,32 +1530,36 @@
|
|
|
1435
1530
|
scroll_multiplier: multiplier
|
|
1436
1531
|
};
|
|
1437
1532
|
|
|
1438
|
-
_this.PubSub.publish('Area:scroll:pre', data);
|
|
1533
|
+
_this.DS.PubSub.publish('Area:scroll:pre', data);
|
|
1439
1534
|
|
|
1440
1535
|
scrollElement(_this._node, directions, multiplier);
|
|
1441
1536
|
|
|
1442
|
-
_this.PubSub.publish('Area:scroll', data);
|
|
1537
|
+
_this.DS.PubSub.publish('Area:scroll', data);
|
|
1443
1538
|
});
|
|
1444
1539
|
|
|
1445
|
-
this.
|
|
1446
|
-
this.
|
|
1447
|
-
|
|
1540
|
+
this.DS = DS;
|
|
1541
|
+
this.setArea(this.DS.stores.SettingsStore.s.area); // @ts-ignore: @todo: update to typescript
|
|
1542
|
+
|
|
1543
|
+
this.DS.PubSub.subscribe('Settings:updated:area', function (_ref2) {
|
|
1544
|
+
var settings = _ref2.settings;
|
|
1545
|
+
return _this.setArea(settings.area);
|
|
1546
|
+
});
|
|
1448
1547
|
this._modificationCallback = debounce(function (event) {
|
|
1449
|
-
_this.PubSub.publish('Area:modified:pre', {
|
|
1548
|
+
_this.DS.PubSub.publish('Area:modified:pre', {
|
|
1450
1549
|
event: event,
|
|
1451
1550
|
item: _this
|
|
1452
1551
|
});
|
|
1453
1552
|
|
|
1454
1553
|
_this.reset();
|
|
1455
1554
|
|
|
1456
|
-
_this.PubSub.publish('Area:modified', {
|
|
1555
|
+
_this.DS.PubSub.publish('Area:modified', {
|
|
1457
1556
|
event: event,
|
|
1458
1557
|
item: _this
|
|
1459
1558
|
});
|
|
1460
1559
|
}, 60);
|
|
1461
1560
|
this._modificationObserver = new MutationObserver(this._modificationCallback);
|
|
1462
|
-
this.PubSub.subscribe('Interaction:init', this.start);
|
|
1463
|
-
this.PubSub.subscribe('Interaction:end', this.reset);
|
|
1561
|
+
this.DS.PubSub.subscribe('Interaction:init', this.start);
|
|
1562
|
+
this.DS.PubSub.subscribe('Interaction:end', this.reset);
|
|
1464
1563
|
}
|
|
1465
1564
|
/** @param {DSArea} area */
|
|
1466
1565
|
|
|
@@ -1511,7 +1610,7 @@
|
|
|
1511
1610
|
key: "rect",
|
|
1512
1611
|
get: function get() {
|
|
1513
1612
|
if (this._rect) return this._rect;
|
|
1514
|
-
return this._rect = getAreaRect(this.HTMLNode, this.
|
|
1613
|
+
return this._rect = getAreaRect(this.HTMLNode, this.DS.stores.SettingsStore.s.zoom);
|
|
1515
1614
|
}
|
|
1516
1615
|
}, {
|
|
1517
1616
|
key: "parentNodes",
|
|
@@ -1542,11 +1641,6 @@
|
|
|
1542
1641
|
}();
|
|
1543
1642
|
|
|
1544
1643
|
var Drag = /*#__PURE__*/function () {
|
|
1545
|
-
/**
|
|
1546
|
-
* @type {boolean}
|
|
1547
|
-
* @private
|
|
1548
|
-
*/
|
|
1549
|
-
|
|
1550
1644
|
/**
|
|
1551
1645
|
* @type {Vect2}
|
|
1552
1646
|
* @private
|
|
@@ -1562,11 +1656,6 @@
|
|
|
1562
1656
|
* @private
|
|
1563
1657
|
*/
|
|
1564
1658
|
|
|
1565
|
-
/**
|
|
1566
|
-
* @type {boolean}
|
|
1567
|
-
* @private
|
|
1568
|
-
*/
|
|
1569
|
-
|
|
1570
1659
|
/**
|
|
1571
1660
|
* @type {DSDragKeys}
|
|
1572
1661
|
* @private
|
|
@@ -1578,68 +1667,52 @@
|
|
|
1578
1667
|
*/
|
|
1579
1668
|
|
|
1580
1669
|
/**
|
|
1581
|
-
* @
|
|
1582
|
-
* @
|
|
1583
|
-
*/
|
|
1584
|
-
|
|
1585
|
-
/**
|
|
1586
|
-
* @type {number}
|
|
1587
|
-
* @private
|
|
1588
|
-
*/
|
|
1589
|
-
|
|
1590
|
-
/**
|
|
1591
|
-
* @type {number}
|
|
1592
|
-
* @private
|
|
1593
|
-
*/
|
|
1594
|
-
|
|
1595
|
-
/**
|
|
1596
|
-
* @param {Object} p
|
|
1597
|
-
* @param {DragSelect} p.DS
|
|
1598
|
-
* @param {boolean} p.draggability
|
|
1599
|
-
* @param {boolean} p.useTransform
|
|
1600
|
-
* @param {DSDragKeys} p.dragKeys
|
|
1601
|
-
* @param {boolean} p.keyboardDrag
|
|
1602
|
-
* @param {number} p.keyboardDragSpeed
|
|
1603
|
-
* @param {number} p.zoom
|
|
1670
|
+
* @constructor Drag
|
|
1671
|
+
* @param {{DS:DragSelect}} obj
|
|
1604
1672
|
* @ignore
|
|
1605
1673
|
*/
|
|
1606
1674
|
function Drag(_ref) {
|
|
1607
1675
|
var _this = this;
|
|
1608
1676
|
|
|
1609
|
-
var DS = _ref.DS
|
|
1610
|
-
dragKeys = _ref.dragKeys,
|
|
1611
|
-
draggability = _ref.draggability,
|
|
1612
|
-
keyboardDrag = _ref.keyboardDrag,
|
|
1613
|
-
keyboardDragSpeed = _ref.keyboardDragSpeed,
|
|
1614
|
-
useTransform = _ref.useTransform,
|
|
1615
|
-
zoom = _ref.zoom;
|
|
1677
|
+
var DS = _ref.DS;
|
|
1616
1678
|
|
|
1617
1679
|
_classCallCheck(this, Drag);
|
|
1618
1680
|
|
|
1619
|
-
_defineProperty(this, "_useTransform", void 0);
|
|
1620
|
-
|
|
1621
1681
|
_defineProperty(this, "_prevCursorPos", void 0);
|
|
1622
1682
|
|
|
1623
1683
|
_defineProperty(this, "_prevScrollPos", void 0);
|
|
1624
1684
|
|
|
1625
1685
|
_defineProperty(this, "_elements", []);
|
|
1626
1686
|
|
|
1627
|
-
_defineProperty(this, "_draggability", void 0);
|
|
1628
|
-
|
|
1629
1687
|
_defineProperty(this, "_dragKeys", void 0);
|
|
1630
1688
|
|
|
1631
|
-
_defineProperty(this, "_dragKeysFlat",
|
|
1632
|
-
|
|
1633
|
-
_defineProperty(this, "
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1689
|
+
_defineProperty(this, "_dragKeysFlat", []);
|
|
1690
|
+
|
|
1691
|
+
_defineProperty(this, "assignDragkeys", function () {
|
|
1692
|
+
_this._dragKeys = {
|
|
1693
|
+
up: _this.DS.stores.SettingsStore.s.dragKeys.up.map(function (k) {
|
|
1694
|
+
return k.toLowerCase();
|
|
1695
|
+
}),
|
|
1696
|
+
down: _this.DS.stores.SettingsStore.s.dragKeys.down.map(function (k) {
|
|
1697
|
+
return k.toLowerCase();
|
|
1698
|
+
}),
|
|
1699
|
+
left: _this.DS.stores.SettingsStore.s.dragKeys.left.map(function (k) {
|
|
1700
|
+
return k.toLowerCase();
|
|
1701
|
+
}),
|
|
1702
|
+
right: _this.DS.stores.SettingsStore.s.dragKeys.right.map(function (k) {
|
|
1703
|
+
return k.toLowerCase();
|
|
1704
|
+
})
|
|
1705
|
+
};
|
|
1706
|
+
_this._dragKeysFlat = [].concat(_toConsumableArray(_this._dragKeys.up), _toConsumableArray(_this._dragKeys.down), _toConsumableArray(_this._dragKeys.left), _toConsumableArray(_this._dragKeys.right));
|
|
1707
|
+
});
|
|
1638
1708
|
|
|
1639
1709
|
_defineProperty(this, "keyboardDrag", function (_ref2) {
|
|
1640
1710
|
var event = _ref2.event,
|
|
1641
1711
|
key = _ref2.key;
|
|
1642
|
-
|
|
1712
|
+
|
|
1713
|
+
var _key = key.toLowerCase();
|
|
1714
|
+
|
|
1715
|
+
if (!_this.DS.stores.SettingsStore.s.keyboardDrag || !_this._dragKeysFlat.includes(_key) || !_this.DS.SelectedSet.size || !_this.DS.stores.SettingsStore.s.draggability || _this.DS["continue"]) return;
|
|
1643
1716
|
var publishData = {
|
|
1644
1717
|
event: event,
|
|
1645
1718
|
isDragging: true,
|
|
@@ -1654,9 +1727,9 @@
|
|
|
1654
1727
|
|
|
1655
1728
|
var posDirection = handleKeyboardDragPosDifference({
|
|
1656
1729
|
shiftKey: _this.DS.stores.KeyStore.currentValues.includes('shift'),
|
|
1657
|
-
keyboardDragSpeed: _this.
|
|
1658
|
-
zoom: _this.
|
|
1659
|
-
key:
|
|
1730
|
+
keyboardDragSpeed: _this.DS.stores.SettingsStore.s.keyboardDragSpeed,
|
|
1731
|
+
zoom: _this.DS.stores.SettingsStore.s.zoom,
|
|
1732
|
+
key: _key,
|
|
1660
1733
|
scrollCallback: _this.DS.Area.scroll,
|
|
1661
1734
|
scrollDiff: _this._scrollDiff,
|
|
1662
1735
|
canScroll: _this.DS.stores.ScrollStore.canScroll,
|
|
@@ -1668,7 +1741,7 @@
|
|
|
1668
1741
|
element: element,
|
|
1669
1742
|
posDirection: posDirection,
|
|
1670
1743
|
containerRect: _this.DS.SelectorArea.rect,
|
|
1671
|
-
useTransform: _this.
|
|
1744
|
+
useTransform: _this.DS.stores.SettingsStore.s.useTransform
|
|
1672
1745
|
});
|
|
1673
1746
|
});
|
|
1674
1747
|
|
|
@@ -1678,10 +1751,13 @@
|
|
|
1678
1751
|
_defineProperty(this, "keyboardEnd", function (_ref3) {
|
|
1679
1752
|
var event = _ref3.event,
|
|
1680
1753
|
key = _ref3.key;
|
|
1681
|
-
|
|
1754
|
+
|
|
1755
|
+
var _key = key.toLowerCase();
|
|
1756
|
+
|
|
1757
|
+
if (!_this.DS.stores.SettingsStore.s.keyboardDrag || !_this._dragKeysFlat.includes(_key) || !_this.DS.SelectedSet.size || !_this.DS.stores.SettingsStore.s.draggability) return;
|
|
1682
1758
|
var publishData = {
|
|
1683
1759
|
event: event,
|
|
1684
|
-
isDragging: _this.
|
|
1760
|
+
isDragging: _this.DS.stores.SettingsStore.s.draggability,
|
|
1685
1761
|
isDraggingKeyboard: true
|
|
1686
1762
|
};
|
|
1687
1763
|
|
|
@@ -1720,7 +1796,7 @@
|
|
|
1720
1796
|
element: element,
|
|
1721
1797
|
posDirection: posDirection,
|
|
1722
1798
|
containerRect: _this.DS.SelectorArea.rect,
|
|
1723
|
-
useTransform: _this.
|
|
1799
|
+
useTransform: _this.DS.stores.SettingsStore.s.useTransform
|
|
1724
1800
|
});
|
|
1725
1801
|
});
|
|
1726
1802
|
});
|
|
@@ -1731,27 +1807,10 @@
|
|
|
1731
1807
|
});
|
|
1732
1808
|
});
|
|
1733
1809
|
|
|
1734
|
-
this.DS = DS;
|
|
1735
|
-
|
|
1736
|
-
this.
|
|
1737
|
-
this.
|
|
1738
|
-
this._zoom = zoom;
|
|
1739
|
-
this._draggability = draggability;
|
|
1740
|
-
this._dragKeys = {
|
|
1741
|
-
up: dragKeys.up.map(function (k) {
|
|
1742
|
-
return k.toLowerCase();
|
|
1743
|
-
}),
|
|
1744
|
-
down: dragKeys.down.map(function (k) {
|
|
1745
|
-
return k.toLowerCase();
|
|
1746
|
-
}),
|
|
1747
|
-
left: dragKeys.left.map(function (k) {
|
|
1748
|
-
return k.toLowerCase();
|
|
1749
|
-
}),
|
|
1750
|
-
right: dragKeys.right.map(function (k) {
|
|
1751
|
-
return k.toLowerCase();
|
|
1752
|
-
})
|
|
1753
|
-
};
|
|
1754
|
-
this._dragKeysFlat = [].concat(_toConsumableArray(this._dragKeys.up), _toConsumableArray(this._dragKeys.down), _toConsumableArray(this._dragKeys.left), _toConsumableArray(this._dragKeys.right));
|
|
1810
|
+
this.DS = DS; // @ts-ignore: @todo: update to typescript
|
|
1811
|
+
|
|
1812
|
+
this.DS.subscribe('Settings:updated:dragKeys', this.assignDragkeys);
|
|
1813
|
+
this.assignDragkeys();
|
|
1755
1814
|
this.DS.subscribe('Interaction:start', this.start);
|
|
1756
1815
|
this.DS.subscribe('Interaction:end', this.stop);
|
|
1757
1816
|
this.DS.subscribe('Interaction:update', this.update);
|
|
@@ -1787,59 +1846,22 @@
|
|
|
1787
1846
|
}();
|
|
1788
1847
|
|
|
1789
1848
|
var Interaction = /*#__PURE__*/function () {
|
|
1790
|
-
/**
|
|
1791
|
-
* @type {DSArea}
|
|
1792
|
-
* @private
|
|
1793
|
-
* */
|
|
1794
|
-
|
|
1795
|
-
/**
|
|
1796
|
-
* @type {boolean}
|
|
1797
|
-
* @private
|
|
1798
|
-
* */
|
|
1799
|
-
|
|
1800
|
-
/**
|
|
1801
|
-
* @type {boolean}
|
|
1802
|
-
* @private
|
|
1803
|
-
* */
|
|
1804
|
-
|
|
1805
|
-
/**
|
|
1806
|
-
* @type {string}
|
|
1807
|
-
* @private
|
|
1808
|
-
* */
|
|
1809
|
-
|
|
1810
1849
|
/** @type {boolean} */
|
|
1811
1850
|
|
|
1812
1851
|
/** @type {boolean} */
|
|
1813
1852
|
|
|
1814
1853
|
/**
|
|
1815
1854
|
* @constructor Interaction
|
|
1816
|
-
* @param {
|
|
1817
|
-
* @param {DragSelect} obj.DS
|
|
1818
|
-
* @param {DSArea} obj.areaElement
|
|
1819
|
-
* @param {boolean} obj.draggability
|
|
1820
|
-
* @param {boolean} obj.immediateDrag
|
|
1821
|
-
* @param {string} obj.selectableClass
|
|
1855
|
+
* @param {{DS:DragSelect}} obj
|
|
1822
1856
|
* @ignore
|
|
1823
1857
|
*/
|
|
1824
1858
|
function Interaction(_ref) {
|
|
1825
1859
|
var _this = this;
|
|
1826
1860
|
|
|
1827
|
-
var DS = _ref.DS
|
|
1828
|
-
areaElement = _ref.areaElement,
|
|
1829
|
-
draggability = _ref.draggability,
|
|
1830
|
-
immediateDrag = _ref.immediateDrag,
|
|
1831
|
-
selectableClass = _ref.selectableClass;
|
|
1861
|
+
var DS = _ref.DS;
|
|
1832
1862
|
|
|
1833
1863
|
_classCallCheck(this, Interaction);
|
|
1834
1864
|
|
|
1835
|
-
_defineProperty(this, "_areaElement", void 0);
|
|
1836
|
-
|
|
1837
|
-
_defineProperty(this, "_draggability", void 0);
|
|
1838
|
-
|
|
1839
|
-
_defineProperty(this, "_immediateDrag", void 0);
|
|
1840
|
-
|
|
1841
|
-
_defineProperty(this, "_selectableClass", void 0);
|
|
1842
|
-
|
|
1843
1865
|
_defineProperty(this, "isInteracting", void 0);
|
|
1844
1866
|
|
|
1845
1867
|
_defineProperty(this, "isDragging", void 0);
|
|
@@ -1851,9 +1873,9 @@
|
|
|
1851
1873
|
_defineProperty(this, "_init", function () {
|
|
1852
1874
|
_this.stop();
|
|
1853
1875
|
|
|
1854
|
-
_this.
|
|
1876
|
+
_this.DS.Area.HTMLNode.addEventListener('mousedown', _this.start);
|
|
1855
1877
|
|
|
1856
|
-
_this.
|
|
1878
|
+
_this.DS.Area.HTMLNode.addEventListener('touchstart', _this.start, {
|
|
1857
1879
|
passive: false
|
|
1858
1880
|
});
|
|
1859
1881
|
|
|
@@ -1886,10 +1908,10 @@
|
|
|
1886
1908
|
_defineProperty(this, "isDragEvent", function (event) {
|
|
1887
1909
|
var clickedElement =
|
|
1888
1910
|
/** @type {Element} */
|
|
1889
|
-
event.target.closest(".".concat(_this.
|
|
1890
|
-
if (!_this.
|
|
1911
|
+
event.target.closest(".".concat(_this.DS.stores.SettingsStore.s.selectableClass));
|
|
1912
|
+
if (!_this.DS.stores.SettingsStore.s.draggability || _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) || !clickedElement) return false;
|
|
1891
1913
|
|
|
1892
|
-
if (_this.
|
|
1914
|
+
if (_this.DS.stores.SettingsStore.s.immediateDrag) {
|
|
1893
1915
|
if (!_this.DS.SelectedSet.size) _this.DS.SelectedSet.add(
|
|
1894
1916
|
/** @type {DSElement} */
|
|
1895
1917
|
clickedElement);else if (!_this.DS.SelectedSet.has(clickedElement)) {
|
|
@@ -1932,9 +1954,9 @@
|
|
|
1932
1954
|
_this.isInteracting = false;
|
|
1933
1955
|
_this.isDragging = false;
|
|
1934
1956
|
|
|
1935
|
-
_this.
|
|
1957
|
+
_this.DS.Area.HTMLNode.removeEventListener('mousedown', _this.start);
|
|
1936
1958
|
|
|
1937
|
-
_this.
|
|
1959
|
+
_this.DS.Area.HTMLNode.removeEventListener('touchstart', _this.start, {
|
|
1938
1960
|
// @ts-ignore
|
|
1939
1961
|
passive: false
|
|
1940
1962
|
});
|
|
@@ -1975,11 +1997,9 @@
|
|
|
1975
1997
|
});
|
|
1976
1998
|
});
|
|
1977
1999
|
|
|
1978
|
-
this.
|
|
1979
|
-
|
|
1980
|
-
this.
|
|
1981
|
-
this._selectableClass = selectableClass;
|
|
1982
|
-
this.DS = DS;
|
|
2000
|
+
this.DS = DS; // @ts-ignore: @todo: update to typescript
|
|
2001
|
+
|
|
2002
|
+
this.DS.subscribe('Settings:updated:area', this.init);
|
|
1983
2003
|
this.DS.subscribe('PointerStore:updated', this.update);
|
|
1984
2004
|
this.DS.subscribe('Selectable:click', this.onClick);
|
|
1985
2005
|
this.DS.subscribe('Selectable:pointer', function (_ref4) {
|
|
@@ -2100,68 +2120,22 @@
|
|
|
2100
2120
|
|
|
2101
2121
|
var _super = _createSuper(SelectableSet);
|
|
2102
2122
|
|
|
2103
|
-
/**
|
|
2104
|
-
* @type {DSElements}
|
|
2105
|
-
* @private
|
|
2106
|
-
* */
|
|
2107
|
-
|
|
2108
|
-
/**
|
|
2109
|
-
* @type {string}
|
|
2110
|
-
* @private
|
|
2111
|
-
* */
|
|
2112
|
-
|
|
2113
|
-
/**
|
|
2114
|
-
* @type {string}
|
|
2115
|
-
* @private
|
|
2116
|
-
* */
|
|
2117
|
-
|
|
2118
|
-
/**
|
|
2119
|
-
* @type {boolean}
|
|
2120
|
-
* @private
|
|
2121
|
-
* */
|
|
2122
|
-
|
|
2123
|
-
/**
|
|
2124
|
-
* @type {boolean}
|
|
2125
|
-
* @private
|
|
2126
|
-
* */
|
|
2127
|
-
|
|
2128
2123
|
/**
|
|
2129
2124
|
* @constructor SelectableSet
|
|
2130
|
-
* @param {
|
|
2131
|
-
* @param {DSInputElements} p.elements
|
|
2132
|
-
* @param {DragSelect} p.DS
|
|
2133
|
-
* @param {string} p.className
|
|
2134
|
-
* @param {string} p.hoverClassName
|
|
2135
|
-
* @param {boolean} p.useTransform
|
|
2136
|
-
* @param {boolean} p.draggability
|
|
2125
|
+
* @param {{DS:DragSelect}} obj
|
|
2137
2126
|
* @ignore
|
|
2138
2127
|
*/
|
|
2139
2128
|
function SelectableSet(_ref) {
|
|
2140
2129
|
var _this;
|
|
2141
2130
|
|
|
2142
|
-
var
|
|
2143
|
-
className = _ref.className,
|
|
2144
|
-
hoverClassName = _ref.hoverClassName,
|
|
2145
|
-
draggability = _ref.draggability,
|
|
2146
|
-
useTransform = _ref.useTransform,
|
|
2147
|
-
DS = _ref.DS;
|
|
2131
|
+
var DS = _ref.DS;
|
|
2148
2132
|
|
|
2149
2133
|
_classCallCheck(this, SelectableSet);
|
|
2150
2134
|
|
|
2151
2135
|
_this = _super.call(this);
|
|
2152
2136
|
|
|
2153
|
-
_defineProperty(_assertThisInitialized(_this), "_initElements", void 0);
|
|
2154
|
-
|
|
2155
|
-
_defineProperty(_assertThisInitialized(_this), "_className", void 0);
|
|
2156
|
-
|
|
2157
|
-
_defineProperty(_assertThisInitialized(_this), "_hoverClassName", void 0);
|
|
2158
|
-
|
|
2159
|
-
_defineProperty(_assertThisInitialized(_this), "_useTransform", void 0);
|
|
2160
|
-
|
|
2161
|
-
_defineProperty(_assertThisInitialized(_this), "_draggability", void 0);
|
|
2162
|
-
|
|
2163
2137
|
_defineProperty(_assertThisInitialized(_this), "init", function () {
|
|
2164
|
-
return _this.
|
|
2138
|
+
return toArray(_this.DS.stores.SettingsStore.s.selectables).forEach(function (el) {
|
|
2165
2139
|
return _this.add(el);
|
|
2166
2140
|
});
|
|
2167
2141
|
});
|
|
@@ -2197,13 +2171,25 @@
|
|
|
2197
2171
|
});
|
|
2198
2172
|
|
|
2199
2173
|
_this.DS = DS;
|
|
2200
|
-
_this._initElements = toArray(_elements);
|
|
2201
|
-
_this._className = className;
|
|
2202
|
-
_this._hoverClassName = hoverClassName;
|
|
2203
|
-
_this._useTransform = useTransform;
|
|
2204
|
-
_this._draggability = draggability;
|
|
2205
2174
|
|
|
2206
|
-
_this.DS.subscribe('Interaction:init', _this.init);
|
|
2175
|
+
_this.DS.subscribe('Interaction:init', _this.init); // @ts-ignore: @todo: update to typescript
|
|
2176
|
+
|
|
2177
|
+
|
|
2178
|
+
_this.DS.PubSub.subscribe('Settings:updated:selectables', function () {
|
|
2179
|
+
_this.clear();
|
|
2180
|
+
|
|
2181
|
+
_this.init();
|
|
2182
|
+
}); // @ts-ignore: @todo: update to typescript
|
|
2183
|
+
|
|
2184
|
+
|
|
2185
|
+
_this.DS.subscribe('Settings:updated:selectableClass', function (_ref2) {
|
|
2186
|
+
var settings = _ref2.settings;
|
|
2187
|
+
|
|
2188
|
+
_this.forEach(function (el) {
|
|
2189
|
+
el.classList.remove(settings['selectableClass:pre']);
|
|
2190
|
+
el.classList.add(settings['selectableClass']);
|
|
2191
|
+
});
|
|
2192
|
+
});
|
|
2207
2193
|
|
|
2208
2194
|
return _this;
|
|
2209
2195
|
}
|
|
@@ -2213,14 +2199,14 @@
|
|
|
2213
2199
|
|
|
2214
2200
|
/** @param {DSElement} element */
|
|
2215
2201
|
value: function add(element) {
|
|
2216
|
-
element.classList.add(this.
|
|
2202
|
+
element.classList.add(this.DS.stores.SettingsStore.s.selectableClass);
|
|
2217
2203
|
element.addEventListener('click', this._onClick);
|
|
2218
2204
|
element.addEventListener('mousedown', this._onPointer);
|
|
2219
2205
|
element.addEventListener('touchstart', this._onPointer, {
|
|
2220
2206
|
// @ts-ignore
|
|
2221
2207
|
passive: false
|
|
2222
2208
|
});
|
|
2223
|
-
if (this.
|
|
2209
|
+
if (this.DS.stores.SettingsStore.s.draggability && !this.DS.stores.SettingsStore.s.useTransform) handleElementPositionAttribute({
|
|
2224
2210
|
computedStyle: window.getComputedStyle(element),
|
|
2225
2211
|
node: element
|
|
2226
2212
|
});
|
|
@@ -2231,8 +2217,8 @@
|
|
|
2231
2217
|
}, {
|
|
2232
2218
|
key: "delete",
|
|
2233
2219
|
value: function _delete(element) {
|
|
2234
|
-
element.classList.remove(this.
|
|
2235
|
-
element.classList.remove(this.
|
|
2220
|
+
element.classList.remove(this.DS.stores.SettingsStore.s.selectableClass);
|
|
2221
|
+
element.classList.remove(this.DS.stores.SettingsStore.s.hoverClass);
|
|
2236
2222
|
element.removeEventListener('click', this._onClick);
|
|
2237
2223
|
element.removeEventListener('mousedown', this._onPointer);
|
|
2238
2224
|
element.removeEventListener('touchstart', this._onPointer, {
|
|
@@ -2258,30 +2244,20 @@
|
|
|
2258
2244
|
|
|
2259
2245
|
var _super = _createSuper(SelectedSet);
|
|
2260
2246
|
|
|
2261
|
-
/**
|
|
2262
|
-
* @type {string}
|
|
2263
|
-
* @private
|
|
2264
|
-
* */
|
|
2265
|
-
|
|
2266
2247
|
/**
|
|
2267
2248
|
* @constructor SelectableSet
|
|
2268
|
-
* @param {
|
|
2269
|
-
* @param {DragSelect} p.DS
|
|
2270
|
-
* @param {string} p.className
|
|
2249
|
+
* @param {{DS:DragSelect}} obj
|
|
2271
2250
|
* @ignore
|
|
2272
2251
|
*/
|
|
2273
2252
|
function SelectedSet(_ref) {
|
|
2274
2253
|
var _this;
|
|
2275
2254
|
|
|
2276
|
-
var
|
|
2277
|
-
DS = _ref.DS;
|
|
2255
|
+
var DS = _ref.DS;
|
|
2278
2256
|
|
|
2279
2257
|
_classCallCheck(this, SelectedSet);
|
|
2280
2258
|
|
|
2281
2259
|
_this = _super.call(this);
|
|
2282
2260
|
|
|
2283
|
-
_defineProperty(_assertThisInitialized(_this), "_className", void 0);
|
|
2284
|
-
|
|
2285
2261
|
_defineProperty(_assertThisInitialized(_this), "clear", function () {
|
|
2286
2262
|
return _this.forEach(function (el) {
|
|
2287
2263
|
return _this["delete"](el);
|
|
@@ -2301,7 +2277,6 @@
|
|
|
2301
2277
|
});
|
|
2302
2278
|
|
|
2303
2279
|
_this.DS = DS;
|
|
2304
|
-
_this._className = className;
|
|
2305
2280
|
return _this;
|
|
2306
2281
|
}
|
|
2307
2282
|
/** @param {DSElement} element */
|
|
@@ -2319,7 +2294,7 @@
|
|
|
2319
2294
|
|
|
2320
2295
|
_get(_getPrototypeOf(SelectedSet.prototype), "add", this).call(this, element);
|
|
2321
2296
|
|
|
2322
|
-
element.classList.add(this.
|
|
2297
|
+
element.classList.add(this.DS.stores.SettingsStore.s.selectedClass);
|
|
2323
2298
|
element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) + 1);
|
|
2324
2299
|
this.DS.publish('Selected:added', publishData);
|
|
2325
2300
|
return this;
|
|
@@ -2338,7 +2313,7 @@
|
|
|
2338
2313
|
|
|
2339
2314
|
var deleted = _get(_getPrototypeOf(SelectedSet.prototype), "delete", this).call(this, element);
|
|
2340
2315
|
|
|
2341
|
-
element.classList.remove(this.
|
|
2316
|
+
element.classList.remove(this.DS.stores.SettingsStore.s.selectedClass);
|
|
2342
2317
|
element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) - 1);
|
|
2343
2318
|
this.DS.publish('Selected:removed', publishData);
|
|
2344
2319
|
return deleted;
|
|
@@ -2375,36 +2350,20 @@
|
|
|
2375
2350
|
* @private
|
|
2376
2351
|
* */
|
|
2377
2352
|
|
|
2378
|
-
/**
|
|
2379
|
-
* @type {string}
|
|
2380
|
-
* @private
|
|
2381
|
-
* */
|
|
2382
|
-
|
|
2383
|
-
/**
|
|
2384
|
-
* @type {boolean}
|
|
2385
|
-
* @private
|
|
2386
|
-
* */
|
|
2387
|
-
|
|
2388
2353
|
/**
|
|
2389
2354
|
* @constructor Selection
|
|
2390
|
-
* @param {{ DS:DragSelect
|
|
2355
|
+
* @param {{ DS:DragSelect }} p
|
|
2391
2356
|
* @ignore
|
|
2392
2357
|
*/
|
|
2393
2358
|
function Selection(_ref) {
|
|
2394
2359
|
var _this = this;
|
|
2395
2360
|
|
|
2396
|
-
var DS = _ref.DS
|
|
2397
|
-
hoverClassName = _ref.hoverClassName,
|
|
2398
|
-
multiSelectToggling = _ref.multiSelectToggling;
|
|
2361
|
+
var DS = _ref.DS;
|
|
2399
2362
|
|
|
2400
2363
|
_classCallCheck(this, Selection);
|
|
2401
2364
|
|
|
2402
2365
|
_defineProperty(this, "_prevSelectedSet", void 0);
|
|
2403
2366
|
|
|
2404
|
-
_defineProperty(this, "_hoverClassName", void 0);
|
|
2405
|
-
|
|
2406
|
-
_defineProperty(this, "_multiSelectToggling", void 0);
|
|
2407
|
-
|
|
2408
2367
|
_defineProperty(this, "start", function (_ref2) {
|
|
2409
2368
|
var event = _ref2.event,
|
|
2410
2369
|
isDragging = _ref2.isDragging;
|
|
@@ -2440,7 +2399,7 @@
|
|
|
2440
2399
|
if (isCollision(elPosCombo[i][1], Selector.rect)) select.push(elPosCombo[i][0]);else unselect.push(elPosCombo[i][0]);
|
|
2441
2400
|
}
|
|
2442
2401
|
|
|
2443
|
-
var multiSelectionToggle = _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) && _this.
|
|
2402
|
+
var multiSelectionToggle = _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) && _this.DS.stores.SettingsStore.s.multiSelectToggling;
|
|
2444
2403
|
|
|
2445
2404
|
if (_this.DS["continue"]) return;
|
|
2446
2405
|
select.forEach(function (element) {
|
|
@@ -2449,7 +2408,7 @@
|
|
|
2449
2408
|
force: force,
|
|
2450
2409
|
multiSelectionToggle: multiSelectionToggle,
|
|
2451
2410
|
SelectedSet: _this.DS.SelectedSet,
|
|
2452
|
-
hoverClassName: _this.
|
|
2411
|
+
hoverClassName: _this.DS.stores.SettingsStore.s.hoverClass
|
|
2453
2412
|
});
|
|
2454
2413
|
});
|
|
2455
2414
|
unselect.forEach(function (element) {
|
|
@@ -2457,14 +2416,12 @@
|
|
|
2457
2416
|
element: element,
|
|
2458
2417
|
force: force,
|
|
2459
2418
|
SelectedSet: _this.DS.SelectedSet,
|
|
2460
|
-
hoverClassName: _this.
|
|
2419
|
+
hoverClassName: _this.DS.stores.SettingsStore.s.hoverClass,
|
|
2461
2420
|
PrevSelectedSet: _this._prevSelectedSet
|
|
2462
2421
|
});
|
|
2463
2422
|
});
|
|
2464
2423
|
});
|
|
2465
2424
|
|
|
2466
|
-
this._hoverClassName = hoverClassName;
|
|
2467
|
-
this._multiSelectToggling = multiSelectToggling;
|
|
2468
2425
|
this.DS = DS;
|
|
2469
2426
|
this.DS.subscribe('Interaction:start', this.start);
|
|
2470
2427
|
this.DS.subscribe('Interaction:update', this.update);
|
|
@@ -2499,25 +2456,29 @@
|
|
|
2499
2456
|
|
|
2500
2457
|
/**
|
|
2501
2458
|
* @constructor Selector
|
|
2502
|
-
* @param {
|
|
2503
|
-
* @param {DragSelect} p.DS
|
|
2504
|
-
* @param {HTMLElement} p.selector
|
|
2505
|
-
* @param {string} p.selectorClass
|
|
2506
|
-
* @param {boolean} p.customStyles
|
|
2459
|
+
* @param {{ DS:DragSelect }} p
|
|
2507
2460
|
* @ignore
|
|
2508
2461
|
*/
|
|
2509
2462
|
function Selector(_ref) {
|
|
2510
2463
|
var _this = this;
|
|
2511
2464
|
|
|
2512
|
-
var DS = _ref.DS
|
|
2513
|
-
selector = _ref.selector,
|
|
2514
|
-
selectorClass = _ref.selectorClass,
|
|
2515
|
-
customStyles = _ref.customStyles;
|
|
2465
|
+
var DS = _ref.DS;
|
|
2516
2466
|
|
|
2517
2467
|
_classCallCheck(this, Selector);
|
|
2518
2468
|
|
|
2519
2469
|
_defineProperty(this, "_rect", void 0);
|
|
2520
2470
|
|
|
2471
|
+
_defineProperty(this, "attachSelector", function () {
|
|
2472
|
+
var _this$DS$SelectorArea, _this$DS$SelectorArea2;
|
|
2473
|
+
|
|
2474
|
+
if (_this.HTMLNode && (_this$DS$SelectorArea = _this.DS.SelectorArea) !== null && _this$DS$SelectorArea !== void 0 && _this$DS$SelectorArea.HTMLNode) _this.DS.SelectorArea.HTMLNode.removeChild(_this.HTMLNode);
|
|
2475
|
+
_this.HTMLNode = _this.DS.stores.SettingsStore.s.selector || createSelectorElement(_this.DS.stores.SettingsStore.s.customStyles);
|
|
2476
|
+
|
|
2477
|
+
_this.HTMLNode.classList.add(_this.DS.stores.SettingsStore.s.selectorClass);
|
|
2478
|
+
|
|
2479
|
+
if (_this.HTMLNode && (_this$DS$SelectorArea2 = _this.DS.SelectorArea) !== null && _this$DS$SelectorArea2 !== void 0 && _this$DS$SelectorArea2.HTMLNode) _this.DS.SelectorArea.HTMLNode.appendChild(_this.HTMLNode);
|
|
2480
|
+
});
|
|
2481
|
+
|
|
2521
2482
|
_defineProperty(this, "start", function (_ref2) {
|
|
2522
2483
|
var isDragging = _ref2.isDragging;
|
|
2523
2484
|
if (isDragging) return;
|
|
@@ -2549,9 +2510,18 @@
|
|
|
2549
2510
|
_this._rect = null;
|
|
2550
2511
|
});
|
|
2551
2512
|
|
|
2552
|
-
this.DS = DS;
|
|
2553
|
-
|
|
2554
|
-
this.
|
|
2513
|
+
this.DS = DS; // @ts-ignore: @todo: update to typescript
|
|
2514
|
+
|
|
2515
|
+
this.DS.subscribe('Settings:updated:selectorClass', function (_ref4) {
|
|
2516
|
+
var settings = _ref4.settings;
|
|
2517
|
+
|
|
2518
|
+
_this.HTMLNode.classList.remove(settings['selectorClass:pre']);
|
|
2519
|
+
|
|
2520
|
+
_this.HTMLNode.classList.add(settings['selectorClass']);
|
|
2521
|
+
}); // @ts-ignore: @todo: update to typescript
|
|
2522
|
+
|
|
2523
|
+
this.DS.subscribe('Settings:updated:selector', this.attachSelector);
|
|
2524
|
+
this.attachSelector();
|
|
2555
2525
|
this.DS.subscribe('Interaction:start', this.start);
|
|
2556
2526
|
this.DS.subscribe('Interaction:update', this.update);
|
|
2557
2527
|
this.DS.subscribe('Interaction:end', this.stop);
|
|
@@ -2569,11 +2539,6 @@
|
|
|
2569
2539
|
}();
|
|
2570
2540
|
|
|
2571
2541
|
var SelectorArea = /*#__PURE__*/function () {
|
|
2572
|
-
/**
|
|
2573
|
-
* @type {number}
|
|
2574
|
-
* @private
|
|
2575
|
-
* */
|
|
2576
|
-
|
|
2577
2542
|
/**
|
|
2578
2543
|
* @type {*}
|
|
2579
2544
|
* @private
|
|
@@ -2589,37 +2554,25 @@
|
|
|
2589
2554
|
* @private
|
|
2590
2555
|
*/
|
|
2591
2556
|
|
|
2592
|
-
/**
|
|
2593
|
-
* @type {Vect2}
|
|
2594
|
-
* @private
|
|
2595
|
-
*/
|
|
2596
|
-
|
|
2597
2557
|
/**
|
|
2598
2558
|
* @class SelectorArea
|
|
2599
2559
|
* @constructor SelectorArea
|
|
2600
|
-
* @param {{ DS:DragSelect
|
|
2560
|
+
* @param {{ DS:DragSelect }} obj
|
|
2601
2561
|
* @ignore
|
|
2602
2562
|
*/
|
|
2603
2563
|
function SelectorArea(_ref) {
|
|
2604
2564
|
var _this = this;
|
|
2605
2565
|
|
|
2606
|
-
var DS = _ref.DS
|
|
2607
|
-
selectorAreaClass = _ref.selectorAreaClass,
|
|
2608
|
-
autoScrollSpeed = _ref.autoScrollSpeed,
|
|
2609
|
-
overflowTolerance = _ref.overflowTolerance;
|
|
2566
|
+
var DS = _ref.DS;
|
|
2610
2567
|
|
|
2611
2568
|
_classCallCheck(this, SelectorArea);
|
|
2612
2569
|
|
|
2613
|
-
_defineProperty(this, "_autoScrollSpeed", void 0);
|
|
2614
|
-
|
|
2615
2570
|
_defineProperty(this, "_scrollInterval", void 0);
|
|
2616
2571
|
|
|
2617
2572
|
_defineProperty(this, "_rect", void 0);
|
|
2618
2573
|
|
|
2619
2574
|
_defineProperty(this, "currentEdges", []);
|
|
2620
2575
|
|
|
2621
|
-
_defineProperty(this, "_overflowTolerance", void 0);
|
|
2622
|
-
|
|
2623
2576
|
_defineProperty(this, "start", function () {
|
|
2624
2577
|
return _this.applyElements('append');
|
|
2625
2578
|
});
|
|
@@ -2670,9 +2623,9 @@
|
|
|
2670
2623
|
_this.currentEdges = getOverflowEdges({
|
|
2671
2624
|
elementRect: vect2rect(PointerStore.currentVal),
|
|
2672
2625
|
containerRect: _this.rect,
|
|
2673
|
-
tolerance: _this.
|
|
2626
|
+
tolerance: _this.DS.stores.SettingsStore.s.overflowTolerance
|
|
2674
2627
|
});
|
|
2675
|
-
if (_this.currentEdges.length) Area.scroll(_this.currentEdges, _this.
|
|
2628
|
+
if (_this.currentEdges.length) Area.scroll(_this.currentEdges, _this.DS.stores.SettingsStore.s.autoScrollSpeed);
|
|
2676
2629
|
});
|
|
2677
2630
|
|
|
2678
2631
|
_defineProperty(this, "stopAutoScroll", function () {
|
|
@@ -2685,10 +2638,18 @@
|
|
|
2685
2638
|
return isCollision(_this.rect, elementRect || element.getBoundingClientRect());
|
|
2686
2639
|
});
|
|
2687
2640
|
|
|
2688
|
-
this._autoScrollSpeed = autoScrollSpeed;
|
|
2689
|
-
this._overflowTolerance = overflowTolerance;
|
|
2690
2641
|
this.DS = DS;
|
|
2691
|
-
this.HTMLNode = createSelectorAreaElement(
|
|
2642
|
+
this.HTMLNode = createSelectorAreaElement(); // @ts-ignore: @todo: update to typescript
|
|
2643
|
+
|
|
2644
|
+
this.DS.subscribe('Settings:updated:selectorAreaClass', function (_ref2) {
|
|
2645
|
+
var settings = _ref2.settings;
|
|
2646
|
+
|
|
2647
|
+
_this.HTMLNode.classList.remove(settings['selectorAreaClass:pre']);
|
|
2648
|
+
|
|
2649
|
+
_this.HTMLNode.classList.add(settings['selectorAreaClass']);
|
|
2650
|
+
});
|
|
2651
|
+
this.HTMLNode.classList.add(this.DS.stores.SettingsStore.s.selectorAreaClass);
|
|
2652
|
+
this.DS.subscribe('Area:modified', this.updatePos);
|
|
2692
2653
|
this.DS.subscribe('Area:modified', this.updatePos);
|
|
2693
2654
|
this.DS.subscribe('Interaction:init', this.start);
|
|
2694
2655
|
this.DS.subscribe('Interaction:start', this.startAutoScroll);
|
|
@@ -2729,16 +2690,6 @@
|
|
|
2729
2690
|
}();
|
|
2730
2691
|
|
|
2731
2692
|
var KeyStore = /*#__PURE__*/function () {
|
|
2732
|
-
/**
|
|
2733
|
-
* @type {boolean}
|
|
2734
|
-
* @private
|
|
2735
|
-
* */
|
|
2736
|
-
|
|
2737
|
-
/**
|
|
2738
|
-
* @type {DSMultiSelectKeys}
|
|
2739
|
-
* @private
|
|
2740
|
-
* */
|
|
2741
|
-
|
|
2742
2693
|
/**
|
|
2743
2694
|
* @type {Set<string>}
|
|
2744
2695
|
* @private
|
|
@@ -2752,22 +2703,16 @@
|
|
|
2752
2703
|
/**
|
|
2753
2704
|
* @class KeyStore
|
|
2754
2705
|
* @constructor KeyStore
|
|
2755
|
-
* @param {{DS:DragSelect
|
|
2706
|
+
* @param {{DS:DragSelect}} p
|
|
2756
2707
|
* @ignore
|
|
2757
2708
|
*/
|
|
2758
2709
|
function KeyStore(_ref) {
|
|
2759
2710
|
var _this = this;
|
|
2760
2711
|
|
|
2761
|
-
var DS = _ref.DS
|
|
2762
|
-
multiSelectKeys = _ref.multiSelectKeys,
|
|
2763
|
-
multiSelectMode = _ref.multiSelectMode;
|
|
2712
|
+
var DS = _ref.DS;
|
|
2764
2713
|
|
|
2765
2714
|
_classCallCheck(this, KeyStore);
|
|
2766
2715
|
|
|
2767
|
-
_defineProperty(this, "_multiSelectMode", void 0);
|
|
2768
|
-
|
|
2769
|
-
_defineProperty(this, "_multiSelectKeys", void 0);
|
|
2770
|
-
|
|
2771
2716
|
_defineProperty(this, "_currentValues", new Set());
|
|
2772
2717
|
|
|
2773
2718
|
_defineProperty(this, "_keyMapping", {
|
|
@@ -2827,25 +2772,6 @@
|
|
|
2827
2772
|
});
|
|
2828
2773
|
|
|
2829
2774
|
this.DS = DS;
|
|
2830
|
-
this._multiSelectMode = multiSelectMode; // @TODO: remove after deprecation
|
|
2831
|
-
|
|
2832
|
-
this._multiSelectKeys = multiSelectKeys.map(function (key) {
|
|
2833
|
-
var deprecatedKeys = {
|
|
2834
|
-
ctrlKey: 'Control',
|
|
2835
|
-
shiftKey: 'Shift',
|
|
2836
|
-
metaKey: 'Meta'
|
|
2837
|
-
};
|
|
2838
|
-
/** @type {string} */
|
|
2839
|
-
|
|
2840
|
-
var newName = deprecatedKeys[key];
|
|
2841
|
-
|
|
2842
|
-
if (newName) {
|
|
2843
|
-
console.warn("[DragSelect] ".concat(key, " is deprecated. Use \"").concat(newName, "\" instead. Act Now!. See docs for more info"));
|
|
2844
|
-
return newName.toLowerCase();
|
|
2845
|
-
}
|
|
2846
|
-
|
|
2847
|
-
return key.toLowerCase();
|
|
2848
|
-
});
|
|
2849
2775
|
this.DS.subscribe('Interaction:init', this.init);
|
|
2850
2776
|
}
|
|
2851
2777
|
|
|
@@ -2856,11 +2782,14 @@
|
|
|
2856
2782
|
value: function isMultiSelectKeyPressed(event) {
|
|
2857
2783
|
var _this2 = this;
|
|
2858
2784
|
|
|
2859
|
-
if (this.
|
|
2785
|
+
if (this.DS.stores.SettingsStore.s.multiSelectMode) return true;
|
|
2786
|
+
var multiSelectKeys = this.DS.stores.SettingsStore.s.multiSelectKeys.map(function (key) {
|
|
2787
|
+
return key.toLocaleLowerCase();
|
|
2788
|
+
});
|
|
2860
2789
|
if (this.currentValues.some(function (key) {
|
|
2861
|
-
return
|
|
2790
|
+
return multiSelectKeys.includes(key.toLocaleLowerCase());
|
|
2862
2791
|
})) return true;
|
|
2863
|
-
if (event &&
|
|
2792
|
+
if (event && multiSelectKeys.some(function (key) {
|
|
2864
2793
|
return event[_this2._keyMapping[key]];
|
|
2865
2794
|
})) return true;
|
|
2866
2795
|
return false;
|
|
@@ -3124,10 +3053,6 @@
|
|
|
3124
3053
|
* @type {Vect2}
|
|
3125
3054
|
* @private */
|
|
3126
3055
|
|
|
3127
|
-
/**
|
|
3128
|
-
* @type {DSArea}
|
|
3129
|
-
* @private */
|
|
3130
|
-
|
|
3131
3056
|
/**
|
|
3132
3057
|
* @type {boolean}
|
|
3133
3058
|
* @private */
|
|
@@ -3135,15 +3060,13 @@
|
|
|
3135
3060
|
/**
|
|
3136
3061
|
* @class ScrollStore
|
|
3137
3062
|
* @constructor ScrollStore
|
|
3138
|
-
* @param {{ DS:DragSelect
|
|
3063
|
+
* @param {{ DS:DragSelect }} p
|
|
3139
3064
|
* @ignore
|
|
3140
3065
|
*/
|
|
3141
3066
|
function ScrollStore(_ref) {
|
|
3142
3067
|
var _this = this;
|
|
3143
3068
|
|
|
3144
|
-
var DS = _ref.DS
|
|
3145
|
-
areaElement = _ref.areaElement,
|
|
3146
|
-
zoom = _ref.zoom;
|
|
3069
|
+
var DS = _ref.DS;
|
|
3147
3070
|
|
|
3148
3071
|
_classCallCheck(this, ScrollStore);
|
|
3149
3072
|
|
|
@@ -3151,26 +3074,24 @@
|
|
|
3151
3074
|
|
|
3152
3075
|
_defineProperty(this, "_currentVal", void 0);
|
|
3153
3076
|
|
|
3154
|
-
_defineProperty(this, "_areaElement", void 0);
|
|
3155
|
-
|
|
3156
3077
|
_defineProperty(this, "_canScroll", void 0);
|
|
3157
3078
|
|
|
3158
3079
|
_defineProperty(this, "init", function () {
|
|
3159
|
-
return _this.
|
|
3080
|
+
return _this.DS.stores.SettingsStore.s.area.addEventListener('scroll', _this.update);
|
|
3160
3081
|
});
|
|
3161
3082
|
|
|
3162
3083
|
_defineProperty(this, "start", function () {
|
|
3163
|
-
_this._currentVal = _this._initialVal = getCurrentScroll(_this.
|
|
3084
|
+
_this._currentVal = _this._initialVal = getCurrentScroll(_this.DS.stores.SettingsStore.s.area);
|
|
3164
3085
|
|
|
3165
|
-
_this.
|
|
3086
|
+
_this.DS.stores.SettingsStore.s.area.addEventListener('scroll', _this.update);
|
|
3166
3087
|
});
|
|
3167
3088
|
|
|
3168
3089
|
_defineProperty(this, "update", function () {
|
|
3169
|
-
return _this._currentVal = getCurrentScroll(_this.
|
|
3090
|
+
return _this._currentVal = getCurrentScroll(_this.DS.stores.SettingsStore.s.area);
|
|
3170
3091
|
});
|
|
3171
3092
|
|
|
3172
3093
|
_defineProperty(this, "stop", function () {
|
|
3173
|
-
_this.
|
|
3094
|
+
_this.DS.stores.SettingsStore.s.area.removeEventListener('scroll', _this.update);
|
|
3174
3095
|
|
|
3175
3096
|
_this._initialVal = {
|
|
3176
3097
|
x: 0,
|
|
@@ -3185,9 +3106,7 @@
|
|
|
3185
3106
|
_this.start();
|
|
3186
3107
|
});
|
|
3187
3108
|
|
|
3188
|
-
this._areaElement = areaElement;
|
|
3189
3109
|
this.DS = DS;
|
|
3190
|
-
this.zoom = zoom;
|
|
3191
3110
|
this.DS.subscribe('Interaction:init', this.init);
|
|
3192
3111
|
this.DS.subscribe('Interaction:start', function () {
|
|
3193
3112
|
return _this.start();
|
|
@@ -3201,14 +3120,14 @@
|
|
|
3201
3120
|
key: "canScroll",
|
|
3202
3121
|
get: function get() {
|
|
3203
3122
|
if (typeof this._canScroll === 'boolean') return this._canScroll;
|
|
3204
|
-
return this._canScroll = canScroll(this.
|
|
3123
|
+
return this._canScroll = canScroll(this.DS.stores.SettingsStore.s.area);
|
|
3205
3124
|
}
|
|
3206
3125
|
}, {
|
|
3207
3126
|
key: "scrollAmount",
|
|
3208
3127
|
get: function get() {
|
|
3209
3128
|
var scrollDiff = calc(this.currentVal, '-', this.initialVal); // if area is zoomed, the scroll values are skewed, we need to fix that manually :(
|
|
3210
3129
|
|
|
3211
|
-
var zoom = num2vect(this.zoom);
|
|
3130
|
+
var zoom = num2vect(this.DS.stores.SettingsStore.s.zoom);
|
|
3212
3131
|
var zoomScroll = calc(calc(scrollDiff, '*', zoom), '-', scrollDiff);
|
|
3213
3132
|
return {
|
|
3214
3133
|
x: scrollDiff.x + zoomScroll.x,
|
|
@@ -3227,7 +3146,7 @@
|
|
|
3227
3146
|
}, {
|
|
3228
3147
|
key: "currentVal",
|
|
3229
3148
|
get: function get() {
|
|
3230
|
-
if (!this._currentVal) this._currentVal = getCurrentScroll(this.
|
|
3149
|
+
if (!this._currentVal) this._currentVal = getCurrentScroll(this.DS.stores.SettingsStore.s.area);
|
|
3231
3150
|
return this._currentVal;
|
|
3232
3151
|
}
|
|
3233
3152
|
}]);
|
|
@@ -3235,6 +3154,102 @@
|
|
|
3235
3154
|
return ScrollStore;
|
|
3236
3155
|
}();
|
|
3237
3156
|
|
|
3157
|
+
var SettingsStore =
|
|
3158
|
+
/**
|
|
3159
|
+
* @type {Settings}
|
|
3160
|
+
* @private
|
|
3161
|
+
* */
|
|
3162
|
+
|
|
3163
|
+
/**
|
|
3164
|
+
* Holds the settings and their previous value `:pre`
|
|
3165
|
+
* @example {
|
|
3166
|
+
* autoScrollSpeed: 3,
|
|
3167
|
+
* 'autoScrollSpeed:pre': 5
|
|
3168
|
+
* }
|
|
3169
|
+
* @type {Settings}
|
|
3170
|
+
* */
|
|
3171
|
+
|
|
3172
|
+
/**
|
|
3173
|
+
* @class ScrollStore
|
|
3174
|
+
* @constructor ScrollStore
|
|
3175
|
+
* @param {{ DS:DragSelect, settings:Settings }} p
|
|
3176
|
+
* @ignore
|
|
3177
|
+
*/
|
|
3178
|
+
function SettingsStore(_ref) {
|
|
3179
|
+
var _this = this;
|
|
3180
|
+
|
|
3181
|
+
var DS = _ref.DS,
|
|
3182
|
+
_settings2 = _ref.settings;
|
|
3183
|
+
|
|
3184
|
+
_classCallCheck(this, SettingsStore);
|
|
3185
|
+
|
|
3186
|
+
_defineProperty(this, "_settings", {});
|
|
3187
|
+
|
|
3188
|
+
_defineProperty(this, "s", {});
|
|
3189
|
+
|
|
3190
|
+
_defineProperty(this, "update", function (_ref2) {
|
|
3191
|
+
var settings = _ref2.settings,
|
|
3192
|
+
init = _ref2.init;
|
|
3193
|
+
return _this.DS.publish('Settings:updated:pre', _objectSpread2({
|
|
3194
|
+
settings: settings
|
|
3195
|
+
}, init ? {
|
|
3196
|
+
init: init
|
|
3197
|
+
} : {}));
|
|
3198
|
+
});
|
|
3199
|
+
|
|
3200
|
+
_defineProperty(this, "_update", function (_ref3) {
|
|
3201
|
+
var settings = _ref3.settings,
|
|
3202
|
+
init = _ref3.init;
|
|
3203
|
+
|
|
3204
|
+
var _settings = hydrateSettings(settings, init);
|
|
3205
|
+
|
|
3206
|
+
var _loop = function _loop() {
|
|
3207
|
+
var _settings4;
|
|
3208
|
+
|
|
3209
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
3210
|
+
key = _Object$entries$_i[0],
|
|
3211
|
+
value = _Object$entries$_i[1];
|
|
3212
|
+
|
|
3213
|
+
if (!(key in _this._settings)) {
|
|
3214
|
+
Object.defineProperty(_this.s, key, {
|
|
3215
|
+
get: function get() {
|
|
3216
|
+
return _this._settings[key];
|
|
3217
|
+
},
|
|
3218
|
+
set: function set(newValue) {
|
|
3219
|
+
return _this.update({
|
|
3220
|
+
settings: _defineProperty({}, key, newValue)
|
|
3221
|
+
});
|
|
3222
|
+
}
|
|
3223
|
+
});
|
|
3224
|
+
}
|
|
3225
|
+
|
|
3226
|
+
_this._settings["".concat(key, ":pre")] = _this._settings[key];
|
|
3227
|
+
_this._settings[key] = value;
|
|
3228
|
+
var update = {
|
|
3229
|
+
settings: (_settings4 = {}, _defineProperty(_settings4, key, _this._settings[key]), _defineProperty(_settings4, "".concat(key, ":pre"), _this._settings["".concat(key, ":pre")]), _settings4)
|
|
3230
|
+
};
|
|
3231
|
+
|
|
3232
|
+
_this.DS.publish('Settings:updated', update); // @ts-ignore: @todo: update to typescript
|
|
3233
|
+
|
|
3234
|
+
|
|
3235
|
+
_this.DS.publish("Settings:updated:".concat(key), update);
|
|
3236
|
+
};
|
|
3237
|
+
|
|
3238
|
+
for (var _i = 0, _Object$entries = Object.entries(_settings); _i < _Object$entries.length; _i++) {
|
|
3239
|
+
_loop();
|
|
3240
|
+
}
|
|
3241
|
+
});
|
|
3242
|
+
|
|
3243
|
+
this.DS = DS;
|
|
3244
|
+
this.DS.subscribe('Settings:updated:pre', this._update);
|
|
3245
|
+
this.update({
|
|
3246
|
+
settings: _settings2,
|
|
3247
|
+
init: true
|
|
3248
|
+
});
|
|
3249
|
+
}
|
|
3250
|
+
/** @param {{settings: Settings, init?: boolean}} props */
|
|
3251
|
+
;
|
|
3252
|
+
|
|
3238
3253
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
3239
3254
|
|
|
3240
3255
|
var DragSelect = /*#__PURE__*/function () {
|
|
@@ -3248,60 +3263,9 @@
|
|
|
3248
3263
|
* @constructor DragSelect
|
|
3249
3264
|
* @param {Settings} settings
|
|
3250
3265
|
*/
|
|
3251
|
-
function DragSelect(
|
|
3266
|
+
function DragSelect(_settings) {
|
|
3252
3267
|
var _this = this;
|
|
3253
3268
|
|
|
3254
|
-
var _ref$area = _ref.area,
|
|
3255
|
-
area = _ref$area === void 0 ? document : _ref$area,
|
|
3256
|
-
_ref$selectables = _ref.selectables,
|
|
3257
|
-
selectables = _ref$selectables === void 0 ? [] : _ref$selectables,
|
|
3258
|
-
_ref$autoScrollSpeed = _ref.autoScrollSpeed,
|
|
3259
|
-
autoScrollSpeed = _ref$autoScrollSpeed === void 0 ? 5 : _ref$autoScrollSpeed,
|
|
3260
|
-
_ref$overflowToleranc = _ref.overflowTolerance,
|
|
3261
|
-
overflowTolerance = _ref$overflowToleranc === void 0 ? {
|
|
3262
|
-
x: 25,
|
|
3263
|
-
y: 25
|
|
3264
|
-
} : _ref$overflowToleranc,
|
|
3265
|
-
_ref$zoom = _ref.zoom,
|
|
3266
|
-
zoom = _ref$zoom === void 0 ? 1 : _ref$zoom,
|
|
3267
|
-
_ref$customStyles = _ref.customStyles,
|
|
3268
|
-
customStyles = _ref$customStyles === void 0 ? false : _ref$customStyles,
|
|
3269
|
-
_ref$multiSelectMode = _ref.multiSelectMode,
|
|
3270
|
-
multiSelectMode = _ref$multiSelectMode === void 0 ? false : _ref$multiSelectMode,
|
|
3271
|
-
_ref$multiSelectToggl = _ref.multiSelectToggling,
|
|
3272
|
-
multiSelectToggling = _ref$multiSelectToggl === void 0 ? true : _ref$multiSelectToggl,
|
|
3273
|
-
_ref$multiSelectKeys = _ref.multiSelectKeys,
|
|
3274
|
-
multiSelectKeys = _ref$multiSelectKeys === void 0 ? ['Control', 'Shift', 'Meta'] : _ref$multiSelectKeys,
|
|
3275
|
-
_ref$selector = _ref.selector,
|
|
3276
|
-
selector = _ref$selector === void 0 ? undefined : _ref$selector,
|
|
3277
|
-
_ref$draggability = _ref.draggability,
|
|
3278
|
-
draggability = _ref$draggability === void 0 ? true : _ref$draggability,
|
|
3279
|
-
_ref$immediateDrag = _ref.immediateDrag,
|
|
3280
|
-
immediateDrag = _ref$immediateDrag === void 0 ? true : _ref$immediateDrag,
|
|
3281
|
-
_ref$keyboardDrag = _ref.keyboardDrag,
|
|
3282
|
-
keyboardDrag = _ref$keyboardDrag === void 0 ? true : _ref$keyboardDrag,
|
|
3283
|
-
dragKeys = _ref.dragKeys,
|
|
3284
|
-
_ref$keyboardDragSpee = _ref.keyboardDragSpeed,
|
|
3285
|
-
keyboardDragSpeed = _ref$keyboardDragSpee === void 0 ? 10 : _ref$keyboardDragSpee,
|
|
3286
|
-
_ref$useTransform = _ref.useTransform,
|
|
3287
|
-
useTransform = _ref$useTransform === void 0 ? true : _ref$useTransform,
|
|
3288
|
-
_ref$hoverClass = _ref.hoverClass,
|
|
3289
|
-
hoverClass = _ref$hoverClass === void 0 ? 'ds-hover' : _ref$hoverClass,
|
|
3290
|
-
_ref$selectableClass = _ref.selectableClass,
|
|
3291
|
-
selectableClass = _ref$selectableClass === void 0 ? 'ds-selectable' : _ref$selectableClass,
|
|
3292
|
-
_ref$selectedClass = _ref.selectedClass,
|
|
3293
|
-
selectedClass = _ref$selectedClass === void 0 ? 'ds-selected' : _ref$selectedClass,
|
|
3294
|
-
_ref$selectorClass = _ref.selectorClass,
|
|
3295
|
-
selectorClass = _ref$selectorClass === void 0 ? 'ds-selector' : _ref$selectorClass,
|
|
3296
|
-
_ref$selectorAreaClas = _ref.selectorAreaClass,
|
|
3297
|
-
selectorAreaClass = _ref$selectorAreaClas === void 0 ? 'ds-selector-area' : _ref$selectorAreaClas,
|
|
3298
|
-
callback = _ref.callback,
|
|
3299
|
-
onDragMove = _ref.onDragMove,
|
|
3300
|
-
onDragStartBegin = _ref.onDragStartBegin,
|
|
3301
|
-
onDragStart = _ref.onDragStart,
|
|
3302
|
-
onElementSelect = _ref.onElementSelect,
|
|
3303
|
-
onElementUnselect = _ref.onElementUnselect;
|
|
3304
|
-
|
|
3305
3269
|
_classCallCheck(this, DragSelect);
|
|
3306
3270
|
|
|
3307
3271
|
_defineProperty(this, "continue", false);
|
|
@@ -3356,91 +3320,57 @@
|
|
|
3356
3320
|
return _this.Interaction.isDragging;
|
|
3357
3321
|
});
|
|
3358
3322
|
|
|
3323
|
+
_defineProperty(this, "setSettings", function (settings) {
|
|
3324
|
+
return _this.stores.SettingsStore.update({
|
|
3325
|
+
settings: settings
|
|
3326
|
+
});
|
|
3327
|
+
});
|
|
3328
|
+
|
|
3359
3329
|
this.PubSub = new PubSub({
|
|
3360
3330
|
DS: this
|
|
3361
3331
|
});
|
|
3362
3332
|
this.subscribe = this.PubSub.subscribe;
|
|
3363
3333
|
this.unsubscribe = this.PubSub.unsubscribe;
|
|
3364
3334
|
this.publish = this.PubSub.publish;
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
this.stores = {
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
areaElement: area,
|
|
3382
|
-
zoom: zoom
|
|
3383
|
-
}),
|
|
3384
|
-
KeyStore: new KeyStore({
|
|
3385
|
-
DS: this,
|
|
3386
|
-
multiSelectKeys: multiSelectKeys,
|
|
3387
|
-
multiSelectMode: multiSelectMode
|
|
3388
|
-
})
|
|
3389
|
-
};
|
|
3335
|
+
this.stores =
|
|
3336
|
+
/** @type {{ SettingsStore:SettingsStore, PointerStore:PointerStore, ScrollStore:ScrollStore, KeyStore:KeyStore }} */
|
|
3337
|
+
{};
|
|
3338
|
+
this.stores.SettingsStore = new SettingsStore({
|
|
3339
|
+
DS: this,
|
|
3340
|
+
settings: _settings
|
|
3341
|
+
});
|
|
3342
|
+
this.stores.PointerStore = new PointerStore({
|
|
3343
|
+
DS: this
|
|
3344
|
+
});
|
|
3345
|
+
this.stores.ScrollStore = new ScrollStore({
|
|
3346
|
+
DS: this
|
|
3347
|
+
});
|
|
3348
|
+
this.stores.KeyStore = new KeyStore({
|
|
3349
|
+
DS: this
|
|
3350
|
+
});
|
|
3390
3351
|
this.Area = new Area({
|
|
3391
|
-
|
|
3392
|
-
PS: this.PubSub,
|
|
3393
|
-
zoom: zoom
|
|
3352
|
+
DS: this
|
|
3394
3353
|
});
|
|
3395
3354
|
this.Selector = new Selector({
|
|
3396
|
-
DS: this
|
|
3397
|
-
selector: selector,
|
|
3398
|
-
selectorClass: selectorClass,
|
|
3399
|
-
customStyles: customStyles
|
|
3355
|
+
DS: this
|
|
3400
3356
|
});
|
|
3401
3357
|
this.SelectorArea = new SelectorArea({
|
|
3402
|
-
DS: this
|
|
3403
|
-
selectorAreaClass: selectorAreaClass,
|
|
3404
|
-
autoScrollSpeed: autoScrollSpeed,
|
|
3405
|
-
overflowTolerance: overflowTolerance
|
|
3358
|
+
DS: this
|
|
3406
3359
|
});
|
|
3407
3360
|
this.SelectableSet = new SelectableSet({
|
|
3408
|
-
|
|
3409
|
-
DS: this,
|
|
3410
|
-
className: selectableClass,
|
|
3411
|
-
hoverClassName: hoverClass,
|
|
3412
|
-
useTransform: useTransform,
|
|
3413
|
-
draggability: draggability
|
|
3361
|
+
DS: this
|
|
3414
3362
|
});
|
|
3415
3363
|
this.SelectedSet = new SelectedSet({
|
|
3416
|
-
DS: this
|
|
3417
|
-
className: selectedClass
|
|
3364
|
+
DS: this
|
|
3418
3365
|
});
|
|
3419
3366
|
this.Selection = new Selection({
|
|
3420
|
-
DS: this
|
|
3421
|
-
hoverClassName: hoverClass,
|
|
3422
|
-
multiSelectToggling: multiSelectToggling
|
|
3367
|
+
DS: this
|
|
3423
3368
|
});
|
|
3424
3369
|
this.Drag = new Drag({
|
|
3425
|
-
DS: this
|
|
3426
|
-
draggability: draggability,
|
|
3427
|
-
useTransform: useTransform,
|
|
3428
|
-
keyboardDrag: keyboardDrag,
|
|
3429
|
-
dragKeys: Object.assign({
|
|
3430
|
-
up: ['ArrowUp'],
|
|
3431
|
-
down: ['ArrowDown'],
|
|
3432
|
-
left: ['ArrowLeft'],
|
|
3433
|
-
right: ['ArrowRight']
|
|
3434
|
-
}, dragKeys),
|
|
3435
|
-
zoom: zoom,
|
|
3436
|
-
keyboardDragSpeed: keyboardDragSpeed
|
|
3370
|
+
DS: this
|
|
3437
3371
|
});
|
|
3438
3372
|
this.Interaction = new Interaction({
|
|
3439
|
-
|
|
3440
|
-
DS: this,
|
|
3441
|
-
draggability: draggability,
|
|
3442
|
-
immediateDrag: immediateDrag,
|
|
3443
|
-
selectableClass: selectableClass
|
|
3373
|
+
DS: this
|
|
3444
3374
|
}); // Subscriber Aliases
|
|
3445
3375
|
|
|
3446
3376
|
subscriberAliases({
|
|
@@ -3453,91 +3383,16 @@
|
|
|
3453
3383
|
return _this["continue"] = false;
|
|
3454
3384
|
});
|
|
3455
3385
|
this.start();
|
|
3456
|
-
} //
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
_createClass(DragSelect, [{
|
|
3460
|
-
key: "_callbacksTemp",
|
|
3461
|
-
value: function _callbacksTemp(_ref2) {
|
|
3462
|
-
var callback = _ref2.callback,
|
|
3463
|
-
onDragMove = _ref2.onDragMove,
|
|
3464
|
-
onDragStart = _ref2.onDragStart,
|
|
3465
|
-
onDragStartBegin = _ref2.onDragStartBegin,
|
|
3466
|
-
onElementSelect = _ref2.onElementSelect,
|
|
3467
|
-
onElementUnselect = _ref2.onElementUnselect;
|
|
3468
|
-
|
|
3469
|
-
var warnMessage = function warnMessage(name, newName) {
|
|
3470
|
-
return console.warn("[DragSelect] ".concat(name, " is deprecated. Use DragSelect.subscribe(\"").concat(newName, "\", (callbackObject) => {}) instead. Act Now! See docs for more info"));
|
|
3471
|
-
};
|
|
3472
|
-
|
|
3473
|
-
if (callback) {
|
|
3474
|
-
warnMessage('callback', 'callback');
|
|
3475
|
-
this.subscribe('callback', function (_ref3) {
|
|
3476
|
-
var items = _ref3.items,
|
|
3477
|
-
item = _ref3.item,
|
|
3478
|
-
event = _ref3.event;
|
|
3479
|
-
return callback(items, event);
|
|
3480
|
-
});
|
|
3481
|
-
}
|
|
3482
|
-
|
|
3483
|
-
if (onDragMove) {
|
|
3484
|
-
warnMessage('onDragMove', 'dragmove');
|
|
3485
|
-
this.subscribe('dragmove', function (_ref4) {
|
|
3486
|
-
var items = _ref4.items,
|
|
3487
|
-
item = _ref4.item,
|
|
3488
|
-
event = _ref4.event;
|
|
3489
|
-
return onDragMove(event);
|
|
3490
|
-
});
|
|
3491
|
-
}
|
|
3492
|
-
|
|
3493
|
-
if (onDragStart) {
|
|
3494
|
-
warnMessage('onDragStart', 'dragstart');
|
|
3495
|
-
this.subscribe('dragstart', function (_ref5) {
|
|
3496
|
-
var items = _ref5.items,
|
|
3497
|
-
item = _ref5.item,
|
|
3498
|
-
event = _ref5.event;
|
|
3499
|
-
return onDragStart(event);
|
|
3500
|
-
});
|
|
3501
|
-
}
|
|
3502
|
-
|
|
3503
|
-
if (onDragStartBegin) {
|
|
3504
|
-
warnMessage('onDragStartBegin', 'dragstart');
|
|
3505
|
-
this.subscribe('dragstart', function (_ref6) {
|
|
3506
|
-
var items = _ref6.items,
|
|
3507
|
-
item = _ref6.item,
|
|
3508
|
-
event = _ref6.event;
|
|
3509
|
-
return onDragStartBegin(event);
|
|
3510
|
-
});
|
|
3511
|
-
}
|
|
3386
|
+
} // Useful methods for the user
|
|
3387
|
+
//////////////////////////////////////////////////////////////////////////////////////
|
|
3512
3388
|
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
item = _ref7.item,
|
|
3518
|
-
event = _ref7.event;
|
|
3519
|
-
return onElementSelect(item, event);
|
|
3520
|
-
});
|
|
3521
|
-
}
|
|
3522
|
-
|
|
3523
|
-
if (onElementUnselect) {
|
|
3524
|
-
warnMessage('onElementUnselect', 'elementunselect');
|
|
3525
|
-
this.subscribe('elementunselect', function (_ref8) {
|
|
3526
|
-
var items = _ref8.items,
|
|
3527
|
-
item = _ref8.item,
|
|
3528
|
-
event = _ref8.event;
|
|
3529
|
-
return onElementUnselect(item, event);
|
|
3530
|
-
});
|
|
3531
|
-
}
|
|
3532
|
-
} // Useful methods for the user
|
|
3533
|
-
//////////////////////////////////////////////////////////////////////////////////////
|
|
3389
|
+
/**
|
|
3390
|
+
* Initializes the functionality. Automatically triggered when created.
|
|
3391
|
+
* Also, reset the functionality after a teardown
|
|
3392
|
+
*/
|
|
3534
3393
|
|
|
3535
|
-
/**
|
|
3536
|
-
* Initializes the functionality. Automatically triggered when created.
|
|
3537
|
-
* Also, reset the functionality after a teardown
|
|
3538
|
-
*/
|
|
3539
3394
|
|
|
3540
|
-
|
|
3395
|
+
_createClass(DragSelect, [{
|
|
3541
3396
|
key: "stop",
|
|
3542
3397
|
|
|
3543
3398
|
/**
|
|
@@ -3709,6 +3564,7 @@
|
|
|
3709
3564
|
value: function setSelectables(elements) {
|
|
3710
3565
|
var removeFromSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3711
3566
|
var addToSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
3567
|
+
console.warn('[DragSelect] DEPRECATION ".setSelectables" is deprecated and will be removed soon. Please use "ds.setSettings({ selectables: << new dom elements >> })" instead (see docs)');
|
|
3712
3568
|
this.removeSelectables(elements, removeFromSelection);
|
|
3713
3569
|
return this.addSelectables(elements, addToSelection);
|
|
3714
3570
|
}
|
|
@@ -3729,29 +3585,6 @@
|
|
|
3729
3585
|
}
|
|
3730
3586
|
/** The starting/initial position of the cursor/selector @return {Vect2} */
|
|
3731
3587
|
|
|
3732
|
-
}, {
|
|
3733
|
-
key: "getCursorPositionDifference",
|
|
3734
|
-
|
|
3735
|
-
/**
|
|
3736
|
-
* Utility method that returns the cursor position difference between start and now
|
|
3737
|
-
* @param {boolean} [usePreviousCursorDifference] if true, it will output the cursor position difference between the previous selection and now
|
|
3738
|
-
* @param {boolean} [useAreaPositions] if true, it will use cursor positions relative to the area
|
|
3739
|
-
* @return {Vect2}
|
|
3740
|
-
* @deprecated
|
|
3741
|
-
*/
|
|
3742
|
-
value: function getCursorPositionDifference() {
|
|
3743
|
-
var usePreviousCursorDifference = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
3744
|
-
var useAreaPositions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3745
|
-
console.warn('[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`');
|
|
3746
|
-
var posA = useAreaPositions ? this.getCurrentCursorPositionArea() : this.getCurrentCursorPosition();
|
|
3747
|
-
var posB = usePreviousCursorDifference ? useAreaPositions ? this.getPreviousCursorPositionArea() : this.getPreviousCursorPosition() : useAreaPositions ? this.getInitialCursorPositionArea() : this.getInitialCursorPosition();
|
|
3748
|
-
return calc(posA, '-', posB);
|
|
3749
|
-
}
|
|
3750
|
-
/**
|
|
3751
|
-
* Whether the user is currently drag n dropping elements (instead of selection)
|
|
3752
|
-
* @return {boolean}
|
|
3753
|
-
*/
|
|
3754
|
-
|
|
3755
3588
|
}]);
|
|
3756
3589
|
|
|
3757
3590
|
return DragSelect;
|