dragselect 2.3.0 → 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 +12 -0
- package/README.md +47 -25
- package/deploying.md +7 -4
- package/dist/DragSelect.d.ts +10 -18
- package/dist/DragSelect.es6m.js +417 -570
- package/dist/DragSelect.js +417 -570
- 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 -24
- 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 +4 -3
- package/src/DragSelect.js +22 -174
- 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 +31 -38
- 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,50 +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
1849
|
/** @type {boolean} */
|
|
1806
1850
|
|
|
1807
1851
|
/** @type {boolean} */
|
|
1808
1852
|
|
|
1809
1853
|
/**
|
|
1810
1854
|
* @constructor Interaction
|
|
1811
|
-
* @param {
|
|
1812
|
-
* @param {DSArea} obj.areaElement
|
|
1813
|
-
* @param {boolean} obj.draggability
|
|
1814
|
-
* @param {boolean} obj.immediateDrag
|
|
1815
|
-
* @param {DragSelect} obj.DS
|
|
1855
|
+
* @param {{DS:DragSelect}} obj
|
|
1816
1856
|
* @ignore
|
|
1817
1857
|
*/
|
|
1818
1858
|
function Interaction(_ref) {
|
|
1819
1859
|
var _this = this;
|
|
1820
1860
|
|
|
1821
|
-
var
|
|
1822
|
-
DS = _ref.DS,
|
|
1823
|
-
draggability = _ref.draggability,
|
|
1824
|
-
immediateDrag = _ref.immediateDrag;
|
|
1861
|
+
var DS = _ref.DS;
|
|
1825
1862
|
|
|
1826
1863
|
_classCallCheck(this, Interaction);
|
|
1827
1864
|
|
|
1828
|
-
_defineProperty(this, "_areaElement", void 0);
|
|
1829
|
-
|
|
1830
|
-
_defineProperty(this, "_draggability", void 0);
|
|
1831
|
-
|
|
1832
|
-
_defineProperty(this, "_immediateDrag", void 0);
|
|
1833
|
-
|
|
1834
1865
|
_defineProperty(this, "isInteracting", void 0);
|
|
1835
1866
|
|
|
1836
1867
|
_defineProperty(this, "isDragging", void 0);
|
|
@@ -1842,9 +1873,9 @@
|
|
|
1842
1873
|
_defineProperty(this, "_init", function () {
|
|
1843
1874
|
_this.stop();
|
|
1844
1875
|
|
|
1845
|
-
_this.
|
|
1876
|
+
_this.DS.Area.HTMLNode.addEventListener('mousedown', _this.start);
|
|
1846
1877
|
|
|
1847
|
-
_this.
|
|
1878
|
+
_this.DS.Area.HTMLNode.addEventListener('touchstart', _this.start, {
|
|
1848
1879
|
passive: false
|
|
1849
1880
|
});
|
|
1850
1881
|
|
|
@@ -1875,21 +1906,24 @@
|
|
|
1875
1906
|
});
|
|
1876
1907
|
|
|
1877
1908
|
_defineProperty(this, "isDragEvent", function (event) {
|
|
1878
|
-
|
|
1909
|
+
var clickedElement =
|
|
1910
|
+
/** @type {Element} */
|
|
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;
|
|
1879
1913
|
|
|
1880
|
-
if (_this.
|
|
1914
|
+
if (_this.DS.stores.SettingsStore.s.immediateDrag) {
|
|
1881
1915
|
if (!_this.DS.SelectedSet.size) _this.DS.SelectedSet.add(
|
|
1882
1916
|
/** @type {DSElement} */
|
|
1883
|
-
|
|
1917
|
+
clickedElement);else if (!_this.DS.SelectedSet.has(clickedElement)) {
|
|
1884
1918
|
_this.DS.SelectedSet.clear();
|
|
1885
1919
|
|
|
1886
1920
|
_this.DS.SelectedSet.add(
|
|
1887
1921
|
/** @type {DSElement} */
|
|
1888
|
-
|
|
1922
|
+
clickedElement);
|
|
1889
1923
|
}
|
|
1890
1924
|
}
|
|
1891
1925
|
|
|
1892
|
-
if (_this.DS.SelectedSet.has(
|
|
1926
|
+
if (_this.DS.SelectedSet.has(clickedElement)) return true;
|
|
1893
1927
|
return false;
|
|
1894
1928
|
});
|
|
1895
1929
|
|
|
@@ -1920,9 +1954,9 @@
|
|
|
1920
1954
|
_this.isInteracting = false;
|
|
1921
1955
|
_this.isDragging = false;
|
|
1922
1956
|
|
|
1923
|
-
_this.
|
|
1957
|
+
_this.DS.Area.HTMLNode.removeEventListener('mousedown', _this.start);
|
|
1924
1958
|
|
|
1925
|
-
_this.
|
|
1959
|
+
_this.DS.Area.HTMLNode.removeEventListener('touchstart', _this.start, {
|
|
1926
1960
|
// @ts-ignore
|
|
1927
1961
|
passive: false
|
|
1928
1962
|
});
|
|
@@ -1963,10 +1997,9 @@
|
|
|
1963
1997
|
});
|
|
1964
1998
|
});
|
|
1965
1999
|
|
|
1966
|
-
this.
|
|
1967
|
-
|
|
1968
|
-
this.
|
|
1969
|
-
this.DS = DS;
|
|
2000
|
+
this.DS = DS; // @ts-ignore: @todo: update to typescript
|
|
2001
|
+
|
|
2002
|
+
this.DS.subscribe('Settings:updated:area', this.init);
|
|
1970
2003
|
this.DS.subscribe('PointerStore:updated', this.update);
|
|
1971
2004
|
this.DS.subscribe('Selectable:click', this.onClick);
|
|
1972
2005
|
this.DS.subscribe('Selectable:pointer', function (_ref4) {
|
|
@@ -2087,68 +2120,22 @@
|
|
|
2087
2120
|
|
|
2088
2121
|
var _super = _createSuper(SelectableSet);
|
|
2089
2122
|
|
|
2090
|
-
/**
|
|
2091
|
-
* @type {DSElements}
|
|
2092
|
-
* @private
|
|
2093
|
-
* */
|
|
2094
|
-
|
|
2095
|
-
/**
|
|
2096
|
-
* @type {string}
|
|
2097
|
-
* @private
|
|
2098
|
-
* */
|
|
2099
|
-
|
|
2100
|
-
/**
|
|
2101
|
-
* @type {string}
|
|
2102
|
-
* @private
|
|
2103
|
-
* */
|
|
2104
|
-
|
|
2105
|
-
/**
|
|
2106
|
-
* @type {boolean}
|
|
2107
|
-
* @private
|
|
2108
|
-
* */
|
|
2109
|
-
|
|
2110
|
-
/**
|
|
2111
|
-
* @type {boolean}
|
|
2112
|
-
* @private
|
|
2113
|
-
* */
|
|
2114
|
-
|
|
2115
2123
|
/**
|
|
2116
2124
|
* @constructor SelectableSet
|
|
2117
|
-
* @param {
|
|
2118
|
-
* @param {DSInputElements} p.elements
|
|
2119
|
-
* @param {DragSelect} p.DS
|
|
2120
|
-
* @param {string} p.className
|
|
2121
|
-
* @param {string} p.hoverClassName
|
|
2122
|
-
* @param {boolean} p.useTransform
|
|
2123
|
-
* @param {boolean} p.draggability
|
|
2125
|
+
* @param {{DS:DragSelect}} obj
|
|
2124
2126
|
* @ignore
|
|
2125
2127
|
*/
|
|
2126
2128
|
function SelectableSet(_ref) {
|
|
2127
2129
|
var _this;
|
|
2128
2130
|
|
|
2129
|
-
var
|
|
2130
|
-
className = _ref.className,
|
|
2131
|
-
hoverClassName = _ref.hoverClassName,
|
|
2132
|
-
draggability = _ref.draggability,
|
|
2133
|
-
useTransform = _ref.useTransform,
|
|
2134
|
-
DS = _ref.DS;
|
|
2131
|
+
var DS = _ref.DS;
|
|
2135
2132
|
|
|
2136
2133
|
_classCallCheck(this, SelectableSet);
|
|
2137
2134
|
|
|
2138
2135
|
_this = _super.call(this);
|
|
2139
2136
|
|
|
2140
|
-
_defineProperty(_assertThisInitialized(_this), "_initElements", void 0);
|
|
2141
|
-
|
|
2142
|
-
_defineProperty(_assertThisInitialized(_this), "_className", void 0);
|
|
2143
|
-
|
|
2144
|
-
_defineProperty(_assertThisInitialized(_this), "_hoverClassName", void 0);
|
|
2145
|
-
|
|
2146
|
-
_defineProperty(_assertThisInitialized(_this), "_useTransform", void 0);
|
|
2147
|
-
|
|
2148
|
-
_defineProperty(_assertThisInitialized(_this), "_draggability", void 0);
|
|
2149
|
-
|
|
2150
2137
|
_defineProperty(_assertThisInitialized(_this), "init", function () {
|
|
2151
|
-
return _this.
|
|
2138
|
+
return toArray(_this.DS.stores.SettingsStore.s.selectables).forEach(function (el) {
|
|
2152
2139
|
return _this.add(el);
|
|
2153
2140
|
});
|
|
2154
2141
|
});
|
|
@@ -2184,13 +2171,25 @@
|
|
|
2184
2171
|
});
|
|
2185
2172
|
|
|
2186
2173
|
_this.DS = DS;
|
|
2187
|
-
_this._initElements = toArray(_elements);
|
|
2188
|
-
_this._className = className;
|
|
2189
|
-
_this._hoverClassName = hoverClassName;
|
|
2190
|
-
_this._useTransform = useTransform;
|
|
2191
|
-
_this._draggability = draggability;
|
|
2192
2174
|
|
|
2193
|
-
_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
|
+
});
|
|
2194
2193
|
|
|
2195
2194
|
return _this;
|
|
2196
2195
|
}
|
|
@@ -2200,14 +2199,14 @@
|
|
|
2200
2199
|
|
|
2201
2200
|
/** @param {DSElement} element */
|
|
2202
2201
|
value: function add(element) {
|
|
2203
|
-
element.classList.add(this.
|
|
2202
|
+
element.classList.add(this.DS.stores.SettingsStore.s.selectableClass);
|
|
2204
2203
|
element.addEventListener('click', this._onClick);
|
|
2205
2204
|
element.addEventListener('mousedown', this._onPointer);
|
|
2206
2205
|
element.addEventListener('touchstart', this._onPointer, {
|
|
2207
2206
|
// @ts-ignore
|
|
2208
2207
|
passive: false
|
|
2209
2208
|
});
|
|
2210
|
-
if (this.
|
|
2209
|
+
if (this.DS.stores.SettingsStore.s.draggability && !this.DS.stores.SettingsStore.s.useTransform) handleElementPositionAttribute({
|
|
2211
2210
|
computedStyle: window.getComputedStyle(element),
|
|
2212
2211
|
node: element
|
|
2213
2212
|
});
|
|
@@ -2218,8 +2217,8 @@
|
|
|
2218
2217
|
}, {
|
|
2219
2218
|
key: "delete",
|
|
2220
2219
|
value: function _delete(element) {
|
|
2221
|
-
element.classList.remove(this.
|
|
2222
|
-
element.classList.remove(this.
|
|
2220
|
+
element.classList.remove(this.DS.stores.SettingsStore.s.selectableClass);
|
|
2221
|
+
element.classList.remove(this.DS.stores.SettingsStore.s.hoverClass);
|
|
2223
2222
|
element.removeEventListener('click', this._onClick);
|
|
2224
2223
|
element.removeEventListener('mousedown', this._onPointer);
|
|
2225
2224
|
element.removeEventListener('touchstart', this._onPointer, {
|
|
@@ -2245,30 +2244,20 @@
|
|
|
2245
2244
|
|
|
2246
2245
|
var _super = _createSuper(SelectedSet);
|
|
2247
2246
|
|
|
2248
|
-
/**
|
|
2249
|
-
* @type {string}
|
|
2250
|
-
* @private
|
|
2251
|
-
* */
|
|
2252
|
-
|
|
2253
2247
|
/**
|
|
2254
2248
|
* @constructor SelectableSet
|
|
2255
|
-
* @param {
|
|
2256
|
-
* @param {DragSelect} p.DS
|
|
2257
|
-
* @param {string} p.className
|
|
2249
|
+
* @param {{DS:DragSelect}} obj
|
|
2258
2250
|
* @ignore
|
|
2259
2251
|
*/
|
|
2260
2252
|
function SelectedSet(_ref) {
|
|
2261
2253
|
var _this;
|
|
2262
2254
|
|
|
2263
|
-
var
|
|
2264
|
-
DS = _ref.DS;
|
|
2255
|
+
var DS = _ref.DS;
|
|
2265
2256
|
|
|
2266
2257
|
_classCallCheck(this, SelectedSet);
|
|
2267
2258
|
|
|
2268
2259
|
_this = _super.call(this);
|
|
2269
2260
|
|
|
2270
|
-
_defineProperty(_assertThisInitialized(_this), "_className", void 0);
|
|
2271
|
-
|
|
2272
2261
|
_defineProperty(_assertThisInitialized(_this), "clear", function () {
|
|
2273
2262
|
return _this.forEach(function (el) {
|
|
2274
2263
|
return _this["delete"](el);
|
|
@@ -2288,7 +2277,6 @@
|
|
|
2288
2277
|
});
|
|
2289
2278
|
|
|
2290
2279
|
_this.DS = DS;
|
|
2291
|
-
_this._className = className;
|
|
2292
2280
|
return _this;
|
|
2293
2281
|
}
|
|
2294
2282
|
/** @param {DSElement} element */
|
|
@@ -2306,7 +2294,7 @@
|
|
|
2306
2294
|
|
|
2307
2295
|
_get(_getPrototypeOf(SelectedSet.prototype), "add", this).call(this, element);
|
|
2308
2296
|
|
|
2309
|
-
element.classList.add(this.
|
|
2297
|
+
element.classList.add(this.DS.stores.SettingsStore.s.selectedClass);
|
|
2310
2298
|
element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) + 1);
|
|
2311
2299
|
this.DS.publish('Selected:added', publishData);
|
|
2312
2300
|
return this;
|
|
@@ -2325,7 +2313,7 @@
|
|
|
2325
2313
|
|
|
2326
2314
|
var deleted = _get(_getPrototypeOf(SelectedSet.prototype), "delete", this).call(this, element);
|
|
2327
2315
|
|
|
2328
|
-
element.classList.remove(this.
|
|
2316
|
+
element.classList.remove(this.DS.stores.SettingsStore.s.selectedClass);
|
|
2329
2317
|
element.style.zIndex = "".concat((parseInt(element.style.zIndex) || 0) - 1);
|
|
2330
2318
|
this.DS.publish('Selected:removed', publishData);
|
|
2331
2319
|
return deleted;
|
|
@@ -2362,36 +2350,20 @@
|
|
|
2362
2350
|
* @private
|
|
2363
2351
|
* */
|
|
2364
2352
|
|
|
2365
|
-
/**
|
|
2366
|
-
* @type {string}
|
|
2367
|
-
* @private
|
|
2368
|
-
* */
|
|
2369
|
-
|
|
2370
|
-
/**
|
|
2371
|
-
* @type {boolean}
|
|
2372
|
-
* @private
|
|
2373
|
-
* */
|
|
2374
|
-
|
|
2375
2353
|
/**
|
|
2376
2354
|
* @constructor Selection
|
|
2377
|
-
* @param {{ DS:DragSelect
|
|
2355
|
+
* @param {{ DS:DragSelect }} p
|
|
2378
2356
|
* @ignore
|
|
2379
2357
|
*/
|
|
2380
2358
|
function Selection(_ref) {
|
|
2381
2359
|
var _this = this;
|
|
2382
2360
|
|
|
2383
|
-
var DS = _ref.DS
|
|
2384
|
-
hoverClassName = _ref.hoverClassName,
|
|
2385
|
-
multiSelectToggling = _ref.multiSelectToggling;
|
|
2361
|
+
var DS = _ref.DS;
|
|
2386
2362
|
|
|
2387
2363
|
_classCallCheck(this, Selection);
|
|
2388
2364
|
|
|
2389
2365
|
_defineProperty(this, "_prevSelectedSet", void 0);
|
|
2390
2366
|
|
|
2391
|
-
_defineProperty(this, "_hoverClassName", void 0);
|
|
2392
|
-
|
|
2393
|
-
_defineProperty(this, "_multiSelectToggling", void 0);
|
|
2394
|
-
|
|
2395
2367
|
_defineProperty(this, "start", function (_ref2) {
|
|
2396
2368
|
var event = _ref2.event,
|
|
2397
2369
|
isDragging = _ref2.isDragging;
|
|
@@ -2427,7 +2399,7 @@
|
|
|
2427
2399
|
if (isCollision(elPosCombo[i][1], Selector.rect)) select.push(elPosCombo[i][0]);else unselect.push(elPosCombo[i][0]);
|
|
2428
2400
|
}
|
|
2429
2401
|
|
|
2430
|
-
var multiSelectionToggle = _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) && _this.
|
|
2402
|
+
var multiSelectionToggle = _this.DS.stores.KeyStore.isMultiSelectKeyPressed(event) && _this.DS.stores.SettingsStore.s.multiSelectToggling;
|
|
2431
2403
|
|
|
2432
2404
|
if (_this.DS["continue"]) return;
|
|
2433
2405
|
select.forEach(function (element) {
|
|
@@ -2436,7 +2408,7 @@
|
|
|
2436
2408
|
force: force,
|
|
2437
2409
|
multiSelectionToggle: multiSelectionToggle,
|
|
2438
2410
|
SelectedSet: _this.DS.SelectedSet,
|
|
2439
|
-
hoverClassName: _this.
|
|
2411
|
+
hoverClassName: _this.DS.stores.SettingsStore.s.hoverClass
|
|
2440
2412
|
});
|
|
2441
2413
|
});
|
|
2442
2414
|
unselect.forEach(function (element) {
|
|
@@ -2444,14 +2416,12 @@
|
|
|
2444
2416
|
element: element,
|
|
2445
2417
|
force: force,
|
|
2446
2418
|
SelectedSet: _this.DS.SelectedSet,
|
|
2447
|
-
hoverClassName: _this.
|
|
2419
|
+
hoverClassName: _this.DS.stores.SettingsStore.s.hoverClass,
|
|
2448
2420
|
PrevSelectedSet: _this._prevSelectedSet
|
|
2449
2421
|
});
|
|
2450
2422
|
});
|
|
2451
2423
|
});
|
|
2452
2424
|
|
|
2453
|
-
this._hoverClassName = hoverClassName;
|
|
2454
|
-
this._multiSelectToggling = multiSelectToggling;
|
|
2455
2425
|
this.DS = DS;
|
|
2456
2426
|
this.DS.subscribe('Interaction:start', this.start);
|
|
2457
2427
|
this.DS.subscribe('Interaction:update', this.update);
|
|
@@ -2486,25 +2456,29 @@
|
|
|
2486
2456
|
|
|
2487
2457
|
/**
|
|
2488
2458
|
* @constructor Selector
|
|
2489
|
-
* @param {
|
|
2490
|
-
* @param {DragSelect} p.DS
|
|
2491
|
-
* @param {HTMLElement} p.selector
|
|
2492
|
-
* @param {string} p.selectorClass
|
|
2493
|
-
* @param {boolean} p.customStyles
|
|
2459
|
+
* @param {{ DS:DragSelect }} p
|
|
2494
2460
|
* @ignore
|
|
2495
2461
|
*/
|
|
2496
2462
|
function Selector(_ref) {
|
|
2497
2463
|
var _this = this;
|
|
2498
2464
|
|
|
2499
|
-
var DS = _ref.DS
|
|
2500
|
-
selector = _ref.selector,
|
|
2501
|
-
selectorClass = _ref.selectorClass,
|
|
2502
|
-
customStyles = _ref.customStyles;
|
|
2465
|
+
var DS = _ref.DS;
|
|
2503
2466
|
|
|
2504
2467
|
_classCallCheck(this, Selector);
|
|
2505
2468
|
|
|
2506
2469
|
_defineProperty(this, "_rect", void 0);
|
|
2507
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
|
+
|
|
2508
2482
|
_defineProperty(this, "start", function (_ref2) {
|
|
2509
2483
|
var isDragging = _ref2.isDragging;
|
|
2510
2484
|
if (isDragging) return;
|
|
@@ -2536,9 +2510,18 @@
|
|
|
2536
2510
|
_this._rect = null;
|
|
2537
2511
|
});
|
|
2538
2512
|
|
|
2539
|
-
this.DS = DS;
|
|
2540
|
-
|
|
2541
|
-
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();
|
|
2542
2525
|
this.DS.subscribe('Interaction:start', this.start);
|
|
2543
2526
|
this.DS.subscribe('Interaction:update', this.update);
|
|
2544
2527
|
this.DS.subscribe('Interaction:end', this.stop);
|
|
@@ -2556,11 +2539,6 @@
|
|
|
2556
2539
|
}();
|
|
2557
2540
|
|
|
2558
2541
|
var SelectorArea = /*#__PURE__*/function () {
|
|
2559
|
-
/**
|
|
2560
|
-
* @type {number}
|
|
2561
|
-
* @private
|
|
2562
|
-
* */
|
|
2563
|
-
|
|
2564
2542
|
/**
|
|
2565
2543
|
* @type {*}
|
|
2566
2544
|
* @private
|
|
@@ -2576,37 +2554,25 @@
|
|
|
2576
2554
|
* @private
|
|
2577
2555
|
*/
|
|
2578
2556
|
|
|
2579
|
-
/**
|
|
2580
|
-
* @type {Vect2}
|
|
2581
|
-
* @private
|
|
2582
|
-
*/
|
|
2583
|
-
|
|
2584
2557
|
/**
|
|
2585
2558
|
* @class SelectorArea
|
|
2586
2559
|
* @constructor SelectorArea
|
|
2587
|
-
* @param {{ DS:DragSelect
|
|
2560
|
+
* @param {{ DS:DragSelect }} obj
|
|
2588
2561
|
* @ignore
|
|
2589
2562
|
*/
|
|
2590
2563
|
function SelectorArea(_ref) {
|
|
2591
2564
|
var _this = this;
|
|
2592
2565
|
|
|
2593
|
-
var DS = _ref.DS
|
|
2594
|
-
selectorAreaClass = _ref.selectorAreaClass,
|
|
2595
|
-
autoScrollSpeed = _ref.autoScrollSpeed,
|
|
2596
|
-
overflowTolerance = _ref.overflowTolerance;
|
|
2566
|
+
var DS = _ref.DS;
|
|
2597
2567
|
|
|
2598
2568
|
_classCallCheck(this, SelectorArea);
|
|
2599
2569
|
|
|
2600
|
-
_defineProperty(this, "_autoScrollSpeed", void 0);
|
|
2601
|
-
|
|
2602
2570
|
_defineProperty(this, "_scrollInterval", void 0);
|
|
2603
2571
|
|
|
2604
2572
|
_defineProperty(this, "_rect", void 0);
|
|
2605
2573
|
|
|
2606
2574
|
_defineProperty(this, "currentEdges", []);
|
|
2607
2575
|
|
|
2608
|
-
_defineProperty(this, "_overflowTolerance", void 0);
|
|
2609
|
-
|
|
2610
2576
|
_defineProperty(this, "start", function () {
|
|
2611
2577
|
return _this.applyElements('append');
|
|
2612
2578
|
});
|
|
@@ -2657,9 +2623,9 @@
|
|
|
2657
2623
|
_this.currentEdges = getOverflowEdges({
|
|
2658
2624
|
elementRect: vect2rect(PointerStore.currentVal),
|
|
2659
2625
|
containerRect: _this.rect,
|
|
2660
|
-
tolerance: _this.
|
|
2626
|
+
tolerance: _this.DS.stores.SettingsStore.s.overflowTolerance
|
|
2661
2627
|
});
|
|
2662
|
-
if (_this.currentEdges.length) Area.scroll(_this.currentEdges, _this.
|
|
2628
|
+
if (_this.currentEdges.length) Area.scroll(_this.currentEdges, _this.DS.stores.SettingsStore.s.autoScrollSpeed);
|
|
2663
2629
|
});
|
|
2664
2630
|
|
|
2665
2631
|
_defineProperty(this, "stopAutoScroll", function () {
|
|
@@ -2672,10 +2638,18 @@
|
|
|
2672
2638
|
return isCollision(_this.rect, elementRect || element.getBoundingClientRect());
|
|
2673
2639
|
});
|
|
2674
2640
|
|
|
2675
|
-
this._autoScrollSpeed = autoScrollSpeed;
|
|
2676
|
-
this._overflowTolerance = overflowTolerance;
|
|
2677
2641
|
this.DS = DS;
|
|
2678
|
-
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);
|
|
2679
2653
|
this.DS.subscribe('Area:modified', this.updatePos);
|
|
2680
2654
|
this.DS.subscribe('Interaction:init', this.start);
|
|
2681
2655
|
this.DS.subscribe('Interaction:start', this.startAutoScroll);
|
|
@@ -2716,16 +2690,6 @@
|
|
|
2716
2690
|
}();
|
|
2717
2691
|
|
|
2718
2692
|
var KeyStore = /*#__PURE__*/function () {
|
|
2719
|
-
/**
|
|
2720
|
-
* @type {boolean}
|
|
2721
|
-
* @private
|
|
2722
|
-
* */
|
|
2723
|
-
|
|
2724
|
-
/**
|
|
2725
|
-
* @type {DSMultiSelectKeys}
|
|
2726
|
-
* @private
|
|
2727
|
-
* */
|
|
2728
|
-
|
|
2729
2693
|
/**
|
|
2730
2694
|
* @type {Set<string>}
|
|
2731
2695
|
* @private
|
|
@@ -2739,22 +2703,16 @@
|
|
|
2739
2703
|
/**
|
|
2740
2704
|
* @class KeyStore
|
|
2741
2705
|
* @constructor KeyStore
|
|
2742
|
-
* @param {{DS:DragSelect
|
|
2706
|
+
* @param {{DS:DragSelect}} p
|
|
2743
2707
|
* @ignore
|
|
2744
2708
|
*/
|
|
2745
2709
|
function KeyStore(_ref) {
|
|
2746
2710
|
var _this = this;
|
|
2747
2711
|
|
|
2748
|
-
var DS = _ref.DS
|
|
2749
|
-
multiSelectKeys = _ref.multiSelectKeys,
|
|
2750
|
-
multiSelectMode = _ref.multiSelectMode;
|
|
2712
|
+
var DS = _ref.DS;
|
|
2751
2713
|
|
|
2752
2714
|
_classCallCheck(this, KeyStore);
|
|
2753
2715
|
|
|
2754
|
-
_defineProperty(this, "_multiSelectMode", void 0);
|
|
2755
|
-
|
|
2756
|
-
_defineProperty(this, "_multiSelectKeys", void 0);
|
|
2757
|
-
|
|
2758
2716
|
_defineProperty(this, "_currentValues", new Set());
|
|
2759
2717
|
|
|
2760
2718
|
_defineProperty(this, "_keyMapping", {
|
|
@@ -2814,25 +2772,6 @@
|
|
|
2814
2772
|
});
|
|
2815
2773
|
|
|
2816
2774
|
this.DS = DS;
|
|
2817
|
-
this._multiSelectMode = multiSelectMode; // @TODO: remove after deprecation
|
|
2818
|
-
|
|
2819
|
-
this._multiSelectKeys = multiSelectKeys.map(function (key) {
|
|
2820
|
-
var deprecatedKeys = {
|
|
2821
|
-
ctrlKey: 'Control',
|
|
2822
|
-
shiftKey: 'Shift',
|
|
2823
|
-
metaKey: 'Meta'
|
|
2824
|
-
};
|
|
2825
|
-
/** @type {string} */
|
|
2826
|
-
|
|
2827
|
-
var newName = deprecatedKeys[key];
|
|
2828
|
-
|
|
2829
|
-
if (newName) {
|
|
2830
|
-
console.warn("[DragSelect] ".concat(key, " is deprecated. Use \"").concat(newName, "\" instead. Act Now!. See docs for more info"));
|
|
2831
|
-
return newName.toLowerCase();
|
|
2832
|
-
}
|
|
2833
|
-
|
|
2834
|
-
return key.toLowerCase();
|
|
2835
|
-
});
|
|
2836
2775
|
this.DS.subscribe('Interaction:init', this.init);
|
|
2837
2776
|
}
|
|
2838
2777
|
|
|
@@ -2843,11 +2782,14 @@
|
|
|
2843
2782
|
value: function isMultiSelectKeyPressed(event) {
|
|
2844
2783
|
var _this2 = this;
|
|
2845
2784
|
|
|
2846
|
-
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
|
+
});
|
|
2847
2789
|
if (this.currentValues.some(function (key) {
|
|
2848
|
-
return
|
|
2790
|
+
return multiSelectKeys.includes(key.toLocaleLowerCase());
|
|
2849
2791
|
})) return true;
|
|
2850
|
-
if (event &&
|
|
2792
|
+
if (event && multiSelectKeys.some(function (key) {
|
|
2851
2793
|
return event[_this2._keyMapping[key]];
|
|
2852
2794
|
})) return true;
|
|
2853
2795
|
return false;
|
|
@@ -3111,10 +3053,6 @@
|
|
|
3111
3053
|
* @type {Vect2}
|
|
3112
3054
|
* @private */
|
|
3113
3055
|
|
|
3114
|
-
/**
|
|
3115
|
-
* @type {DSArea}
|
|
3116
|
-
* @private */
|
|
3117
|
-
|
|
3118
3056
|
/**
|
|
3119
3057
|
* @type {boolean}
|
|
3120
3058
|
* @private */
|
|
@@ -3122,15 +3060,13 @@
|
|
|
3122
3060
|
/**
|
|
3123
3061
|
* @class ScrollStore
|
|
3124
3062
|
* @constructor ScrollStore
|
|
3125
|
-
* @param {{ DS:DragSelect
|
|
3063
|
+
* @param {{ DS:DragSelect }} p
|
|
3126
3064
|
* @ignore
|
|
3127
3065
|
*/
|
|
3128
3066
|
function ScrollStore(_ref) {
|
|
3129
3067
|
var _this = this;
|
|
3130
3068
|
|
|
3131
|
-
var DS = _ref.DS
|
|
3132
|
-
areaElement = _ref.areaElement,
|
|
3133
|
-
zoom = _ref.zoom;
|
|
3069
|
+
var DS = _ref.DS;
|
|
3134
3070
|
|
|
3135
3071
|
_classCallCheck(this, ScrollStore);
|
|
3136
3072
|
|
|
@@ -3138,26 +3074,24 @@
|
|
|
3138
3074
|
|
|
3139
3075
|
_defineProperty(this, "_currentVal", void 0);
|
|
3140
3076
|
|
|
3141
|
-
_defineProperty(this, "_areaElement", void 0);
|
|
3142
|
-
|
|
3143
3077
|
_defineProperty(this, "_canScroll", void 0);
|
|
3144
3078
|
|
|
3145
3079
|
_defineProperty(this, "init", function () {
|
|
3146
|
-
return _this.
|
|
3080
|
+
return _this.DS.stores.SettingsStore.s.area.addEventListener('scroll', _this.update);
|
|
3147
3081
|
});
|
|
3148
3082
|
|
|
3149
3083
|
_defineProperty(this, "start", function () {
|
|
3150
|
-
_this._currentVal = _this._initialVal = getCurrentScroll(_this.
|
|
3084
|
+
_this._currentVal = _this._initialVal = getCurrentScroll(_this.DS.stores.SettingsStore.s.area);
|
|
3151
3085
|
|
|
3152
|
-
_this.
|
|
3086
|
+
_this.DS.stores.SettingsStore.s.area.addEventListener('scroll', _this.update);
|
|
3153
3087
|
});
|
|
3154
3088
|
|
|
3155
3089
|
_defineProperty(this, "update", function () {
|
|
3156
|
-
return _this._currentVal = getCurrentScroll(_this.
|
|
3090
|
+
return _this._currentVal = getCurrentScroll(_this.DS.stores.SettingsStore.s.area);
|
|
3157
3091
|
});
|
|
3158
3092
|
|
|
3159
3093
|
_defineProperty(this, "stop", function () {
|
|
3160
|
-
_this.
|
|
3094
|
+
_this.DS.stores.SettingsStore.s.area.removeEventListener('scroll', _this.update);
|
|
3161
3095
|
|
|
3162
3096
|
_this._initialVal = {
|
|
3163
3097
|
x: 0,
|
|
@@ -3172,9 +3106,7 @@
|
|
|
3172
3106
|
_this.start();
|
|
3173
3107
|
});
|
|
3174
3108
|
|
|
3175
|
-
this._areaElement = areaElement;
|
|
3176
3109
|
this.DS = DS;
|
|
3177
|
-
this.zoom = zoom;
|
|
3178
3110
|
this.DS.subscribe('Interaction:init', this.init);
|
|
3179
3111
|
this.DS.subscribe('Interaction:start', function () {
|
|
3180
3112
|
return _this.start();
|
|
@@ -3188,14 +3120,14 @@
|
|
|
3188
3120
|
key: "canScroll",
|
|
3189
3121
|
get: function get() {
|
|
3190
3122
|
if (typeof this._canScroll === 'boolean') return this._canScroll;
|
|
3191
|
-
return this._canScroll = canScroll(this.
|
|
3123
|
+
return this._canScroll = canScroll(this.DS.stores.SettingsStore.s.area);
|
|
3192
3124
|
}
|
|
3193
3125
|
}, {
|
|
3194
3126
|
key: "scrollAmount",
|
|
3195
3127
|
get: function get() {
|
|
3196
3128
|
var scrollDiff = calc(this.currentVal, '-', this.initialVal); // if area is zoomed, the scroll values are skewed, we need to fix that manually :(
|
|
3197
3129
|
|
|
3198
|
-
var zoom = num2vect(this.zoom);
|
|
3130
|
+
var zoom = num2vect(this.DS.stores.SettingsStore.s.zoom);
|
|
3199
3131
|
var zoomScroll = calc(calc(scrollDiff, '*', zoom), '-', scrollDiff);
|
|
3200
3132
|
return {
|
|
3201
3133
|
x: scrollDiff.x + zoomScroll.x,
|
|
@@ -3214,7 +3146,7 @@
|
|
|
3214
3146
|
}, {
|
|
3215
3147
|
key: "currentVal",
|
|
3216
3148
|
get: function get() {
|
|
3217
|
-
if (!this._currentVal) this._currentVal = getCurrentScroll(this.
|
|
3149
|
+
if (!this._currentVal) this._currentVal = getCurrentScroll(this.DS.stores.SettingsStore.s.area);
|
|
3218
3150
|
return this._currentVal;
|
|
3219
3151
|
}
|
|
3220
3152
|
}]);
|
|
@@ -3222,6 +3154,102 @@
|
|
|
3222
3154
|
return ScrollStore;
|
|
3223
3155
|
}();
|
|
3224
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
|
+
|
|
3225
3253
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
3226
3254
|
|
|
3227
3255
|
var DragSelect = /*#__PURE__*/function () {
|
|
@@ -3235,60 +3263,9 @@
|
|
|
3235
3263
|
* @constructor DragSelect
|
|
3236
3264
|
* @param {Settings} settings
|
|
3237
3265
|
*/
|
|
3238
|
-
function DragSelect(
|
|
3266
|
+
function DragSelect(_settings) {
|
|
3239
3267
|
var _this = this;
|
|
3240
3268
|
|
|
3241
|
-
var _ref$area = _ref.area,
|
|
3242
|
-
area = _ref$area === void 0 ? document : _ref$area,
|
|
3243
|
-
_ref$selectables = _ref.selectables,
|
|
3244
|
-
selectables = _ref$selectables === void 0 ? [] : _ref$selectables,
|
|
3245
|
-
_ref$autoScrollSpeed = _ref.autoScrollSpeed,
|
|
3246
|
-
autoScrollSpeed = _ref$autoScrollSpeed === void 0 ? 5 : _ref$autoScrollSpeed,
|
|
3247
|
-
_ref$overflowToleranc = _ref.overflowTolerance,
|
|
3248
|
-
overflowTolerance = _ref$overflowToleranc === void 0 ? {
|
|
3249
|
-
x: 25,
|
|
3250
|
-
y: 25
|
|
3251
|
-
} : _ref$overflowToleranc,
|
|
3252
|
-
_ref$zoom = _ref.zoom,
|
|
3253
|
-
zoom = _ref$zoom === void 0 ? 1 : _ref$zoom,
|
|
3254
|
-
_ref$customStyles = _ref.customStyles,
|
|
3255
|
-
customStyles = _ref$customStyles === void 0 ? false : _ref$customStyles,
|
|
3256
|
-
_ref$multiSelectMode = _ref.multiSelectMode,
|
|
3257
|
-
multiSelectMode = _ref$multiSelectMode === void 0 ? false : _ref$multiSelectMode,
|
|
3258
|
-
_ref$multiSelectToggl = _ref.multiSelectToggling,
|
|
3259
|
-
multiSelectToggling = _ref$multiSelectToggl === void 0 ? true : _ref$multiSelectToggl,
|
|
3260
|
-
_ref$multiSelectKeys = _ref.multiSelectKeys,
|
|
3261
|
-
multiSelectKeys = _ref$multiSelectKeys === void 0 ? ['Control', 'Shift', 'Meta'] : _ref$multiSelectKeys,
|
|
3262
|
-
_ref$selector = _ref.selector,
|
|
3263
|
-
selector = _ref$selector === void 0 ? undefined : _ref$selector,
|
|
3264
|
-
_ref$draggability = _ref.draggability,
|
|
3265
|
-
draggability = _ref$draggability === void 0 ? true : _ref$draggability,
|
|
3266
|
-
_ref$immediateDrag = _ref.immediateDrag,
|
|
3267
|
-
immediateDrag = _ref$immediateDrag === void 0 ? true : _ref$immediateDrag,
|
|
3268
|
-
_ref$keyboardDrag = _ref.keyboardDrag,
|
|
3269
|
-
keyboardDrag = _ref$keyboardDrag === void 0 ? true : _ref$keyboardDrag,
|
|
3270
|
-
dragKeys = _ref.dragKeys,
|
|
3271
|
-
_ref$keyboardDragSpee = _ref.keyboardDragSpeed,
|
|
3272
|
-
keyboardDragSpeed = _ref$keyboardDragSpee === void 0 ? 10 : _ref$keyboardDragSpee,
|
|
3273
|
-
_ref$useTransform = _ref.useTransform,
|
|
3274
|
-
useTransform = _ref$useTransform === void 0 ? true : _ref$useTransform,
|
|
3275
|
-
_ref$hoverClass = _ref.hoverClass,
|
|
3276
|
-
hoverClass = _ref$hoverClass === void 0 ? 'ds-hover' : _ref$hoverClass,
|
|
3277
|
-
_ref$selectableClass = _ref.selectableClass,
|
|
3278
|
-
selectableClass = _ref$selectableClass === void 0 ? 'ds-selectable' : _ref$selectableClass,
|
|
3279
|
-
_ref$selectedClass = _ref.selectedClass,
|
|
3280
|
-
selectedClass = _ref$selectedClass === void 0 ? 'ds-selected' : _ref$selectedClass,
|
|
3281
|
-
_ref$selectorClass = _ref.selectorClass,
|
|
3282
|
-
selectorClass = _ref$selectorClass === void 0 ? 'ds-selector' : _ref$selectorClass,
|
|
3283
|
-
_ref$selectorAreaClas = _ref.selectorAreaClass,
|
|
3284
|
-
selectorAreaClass = _ref$selectorAreaClas === void 0 ? 'ds-selector-area' : _ref$selectorAreaClas,
|
|
3285
|
-
callback = _ref.callback,
|
|
3286
|
-
onDragMove = _ref.onDragMove,
|
|
3287
|
-
onDragStartBegin = _ref.onDragStartBegin,
|
|
3288
|
-
onDragStart = _ref.onDragStart,
|
|
3289
|
-
onElementSelect = _ref.onElementSelect,
|
|
3290
|
-
onElementUnselect = _ref.onElementUnselect;
|
|
3291
|
-
|
|
3292
3269
|
_classCallCheck(this, DragSelect);
|
|
3293
3270
|
|
|
3294
3271
|
_defineProperty(this, "continue", false);
|
|
@@ -3343,90 +3320,57 @@
|
|
|
3343
3320
|
return _this.Interaction.isDragging;
|
|
3344
3321
|
});
|
|
3345
3322
|
|
|
3323
|
+
_defineProperty(this, "setSettings", function (settings) {
|
|
3324
|
+
return _this.stores.SettingsStore.update({
|
|
3325
|
+
settings: settings
|
|
3326
|
+
});
|
|
3327
|
+
});
|
|
3328
|
+
|
|
3346
3329
|
this.PubSub = new PubSub({
|
|
3347
3330
|
DS: this
|
|
3348
3331
|
});
|
|
3349
3332
|
this.subscribe = this.PubSub.subscribe;
|
|
3350
3333
|
this.unsubscribe = this.PubSub.unsubscribe;
|
|
3351
3334
|
this.publish = this.PubSub.publish;
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
this.stores = {
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
areaElement: area,
|
|
3369
|
-
zoom: zoom
|
|
3370
|
-
}),
|
|
3371
|
-
KeyStore: new KeyStore({
|
|
3372
|
-
DS: this,
|
|
3373
|
-
multiSelectKeys: multiSelectKeys,
|
|
3374
|
-
multiSelectMode: multiSelectMode
|
|
3375
|
-
})
|
|
3376
|
-
};
|
|
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
|
+
});
|
|
3377
3351
|
this.Area = new Area({
|
|
3378
|
-
|
|
3379
|
-
PS: this.PubSub,
|
|
3380
|
-
zoom: zoom
|
|
3352
|
+
DS: this
|
|
3381
3353
|
});
|
|
3382
3354
|
this.Selector = new Selector({
|
|
3383
|
-
DS: this
|
|
3384
|
-
selector: selector,
|
|
3385
|
-
selectorClass: selectorClass,
|
|
3386
|
-
customStyles: customStyles
|
|
3355
|
+
DS: this
|
|
3387
3356
|
});
|
|
3388
3357
|
this.SelectorArea = new SelectorArea({
|
|
3389
|
-
DS: this
|
|
3390
|
-
selectorAreaClass: selectorAreaClass,
|
|
3391
|
-
autoScrollSpeed: autoScrollSpeed,
|
|
3392
|
-
overflowTolerance: overflowTolerance
|
|
3358
|
+
DS: this
|
|
3393
3359
|
});
|
|
3394
3360
|
this.SelectableSet = new SelectableSet({
|
|
3395
|
-
|
|
3396
|
-
DS: this,
|
|
3397
|
-
className: selectableClass,
|
|
3398
|
-
hoverClassName: hoverClass,
|
|
3399
|
-
useTransform: useTransform,
|
|
3400
|
-
draggability: draggability
|
|
3361
|
+
DS: this
|
|
3401
3362
|
});
|
|
3402
3363
|
this.SelectedSet = new SelectedSet({
|
|
3403
|
-
DS: this
|
|
3404
|
-
className: selectedClass
|
|
3364
|
+
DS: this
|
|
3405
3365
|
});
|
|
3406
3366
|
this.Selection = new Selection({
|
|
3407
|
-
DS: this
|
|
3408
|
-
hoverClassName: hoverClass,
|
|
3409
|
-
multiSelectToggling: multiSelectToggling
|
|
3367
|
+
DS: this
|
|
3410
3368
|
});
|
|
3411
3369
|
this.Drag = new Drag({
|
|
3412
|
-
DS: this
|
|
3413
|
-
draggability: draggability,
|
|
3414
|
-
useTransform: useTransform,
|
|
3415
|
-
keyboardDrag: keyboardDrag,
|
|
3416
|
-
dragKeys: Object.assign({
|
|
3417
|
-
up: ['ArrowUp'],
|
|
3418
|
-
down: ['ArrowDown'],
|
|
3419
|
-
left: ['ArrowLeft'],
|
|
3420
|
-
right: ['ArrowRight']
|
|
3421
|
-
}, dragKeys),
|
|
3422
|
-
zoom: zoom,
|
|
3423
|
-
keyboardDragSpeed: keyboardDragSpeed
|
|
3370
|
+
DS: this
|
|
3424
3371
|
});
|
|
3425
3372
|
this.Interaction = new Interaction({
|
|
3426
|
-
|
|
3427
|
-
DS: this,
|
|
3428
|
-
draggability: draggability,
|
|
3429
|
-
immediateDrag: immediateDrag
|
|
3373
|
+
DS: this
|
|
3430
3374
|
}); // Subscriber Aliases
|
|
3431
3375
|
|
|
3432
3376
|
subscriberAliases({
|
|
@@ -3439,91 +3383,16 @@
|
|
|
3439
3383
|
return _this["continue"] = false;
|
|
3440
3384
|
});
|
|
3441
3385
|
this.start();
|
|
3442
|
-
} //
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
_createClass(DragSelect, [{
|
|
3446
|
-
key: "_callbacksTemp",
|
|
3447
|
-
value: function _callbacksTemp(_ref2) {
|
|
3448
|
-
var callback = _ref2.callback,
|
|
3449
|
-
onDragMove = _ref2.onDragMove,
|
|
3450
|
-
onDragStart = _ref2.onDragStart,
|
|
3451
|
-
onDragStartBegin = _ref2.onDragStartBegin,
|
|
3452
|
-
onElementSelect = _ref2.onElementSelect,
|
|
3453
|
-
onElementUnselect = _ref2.onElementUnselect;
|
|
3454
|
-
|
|
3455
|
-
var warnMessage = function warnMessage(name, newName) {
|
|
3456
|
-
return console.warn("[DragSelect] ".concat(name, " is deprecated. Use DragSelect.subscribe(\"").concat(newName, "\", (callbackObject) => {}) instead. Act Now! See docs for more info"));
|
|
3457
|
-
};
|
|
3458
|
-
|
|
3459
|
-
if (callback) {
|
|
3460
|
-
warnMessage('callback', 'callback');
|
|
3461
|
-
this.subscribe('callback', function (_ref3) {
|
|
3462
|
-
var items = _ref3.items,
|
|
3463
|
-
item = _ref3.item,
|
|
3464
|
-
event = _ref3.event;
|
|
3465
|
-
return callback(items, event);
|
|
3466
|
-
});
|
|
3467
|
-
}
|
|
3386
|
+
} // Useful methods for the user
|
|
3387
|
+
//////////////////////////////////////////////////////////////////////////////////////
|
|
3468
3388
|
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
item = _ref4.item,
|
|
3474
|
-
event = _ref4.event;
|
|
3475
|
-
return onDragMove(event);
|
|
3476
|
-
});
|
|
3477
|
-
}
|
|
3478
|
-
|
|
3479
|
-
if (onDragStart) {
|
|
3480
|
-
warnMessage('onDragStart', 'dragstart');
|
|
3481
|
-
this.subscribe('dragstart', function (_ref5) {
|
|
3482
|
-
var items = _ref5.items,
|
|
3483
|
-
item = _ref5.item,
|
|
3484
|
-
event = _ref5.event;
|
|
3485
|
-
return onDragStart(event);
|
|
3486
|
-
});
|
|
3487
|
-
}
|
|
3488
|
-
|
|
3489
|
-
if (onDragStartBegin) {
|
|
3490
|
-
warnMessage('onDragStartBegin', 'dragstart');
|
|
3491
|
-
this.subscribe('dragstart', function (_ref6) {
|
|
3492
|
-
var items = _ref6.items,
|
|
3493
|
-
item = _ref6.item,
|
|
3494
|
-
event = _ref6.event;
|
|
3495
|
-
return onDragStartBegin(event);
|
|
3496
|
-
});
|
|
3497
|
-
}
|
|
3498
|
-
|
|
3499
|
-
if (onElementSelect) {
|
|
3500
|
-
warnMessage('onElementSelect', 'elementselect');
|
|
3501
|
-
this.subscribe('elementselect', function (_ref7) {
|
|
3502
|
-
var items = _ref7.items,
|
|
3503
|
-
item = _ref7.item,
|
|
3504
|
-
event = _ref7.event;
|
|
3505
|
-
return onElementSelect(item, event);
|
|
3506
|
-
});
|
|
3507
|
-
}
|
|
3508
|
-
|
|
3509
|
-
if (onElementUnselect) {
|
|
3510
|
-
warnMessage('onElementUnselect', 'elementunselect');
|
|
3511
|
-
this.subscribe('elementunselect', function (_ref8) {
|
|
3512
|
-
var items = _ref8.items,
|
|
3513
|
-
item = _ref8.item,
|
|
3514
|
-
event = _ref8.event;
|
|
3515
|
-
return onElementUnselect(item, event);
|
|
3516
|
-
});
|
|
3517
|
-
}
|
|
3518
|
-
} // Useful methods for the user
|
|
3519
|
-
//////////////////////////////////////////////////////////////////////////////////////
|
|
3389
|
+
/**
|
|
3390
|
+
* Initializes the functionality. Automatically triggered when created.
|
|
3391
|
+
* Also, reset the functionality after a teardown
|
|
3392
|
+
*/
|
|
3520
3393
|
|
|
3521
|
-
/**
|
|
3522
|
-
* Initializes the functionality. Automatically triggered when created.
|
|
3523
|
-
* Also, reset the functionality after a teardown
|
|
3524
|
-
*/
|
|
3525
3394
|
|
|
3526
|
-
|
|
3395
|
+
_createClass(DragSelect, [{
|
|
3527
3396
|
key: "stop",
|
|
3528
3397
|
|
|
3529
3398
|
/**
|
|
@@ -3695,6 +3564,7 @@
|
|
|
3695
3564
|
value: function setSelectables(elements) {
|
|
3696
3565
|
var removeFromSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3697
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)');
|
|
3698
3568
|
this.removeSelectables(elements, removeFromSelection);
|
|
3699
3569
|
return this.addSelectables(elements, addToSelection);
|
|
3700
3570
|
}
|
|
@@ -3715,29 +3585,6 @@
|
|
|
3715
3585
|
}
|
|
3716
3586
|
/** The starting/initial position of the cursor/selector @return {Vect2} */
|
|
3717
3587
|
|
|
3718
|
-
}, {
|
|
3719
|
-
key: "getCursorPositionDifference",
|
|
3720
|
-
|
|
3721
|
-
/**
|
|
3722
|
-
* Utility method that returns the cursor position difference between start and now
|
|
3723
|
-
* @param {boolean} [usePreviousCursorDifference] if true, it will output the cursor position difference between the previous selection and now
|
|
3724
|
-
* @param {boolean} [useAreaPositions] if true, it will use cursor positions relative to the area
|
|
3725
|
-
* @return {Vect2}
|
|
3726
|
-
* @deprecated
|
|
3727
|
-
*/
|
|
3728
|
-
value: function getCursorPositionDifference() {
|
|
3729
|
-
var usePreviousCursorDifference = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
3730
|
-
var useAreaPositions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3731
|
-
console.warn('[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`');
|
|
3732
|
-
var posA = useAreaPositions ? this.getCurrentCursorPositionArea() : this.getCurrentCursorPosition();
|
|
3733
|
-
var posB = usePreviousCursorDifference ? useAreaPositions ? this.getPreviousCursorPositionArea() : this.getPreviousCursorPosition() : useAreaPositions ? this.getInitialCursorPositionArea() : this.getInitialCursorPosition();
|
|
3734
|
-
return calc(posA, '-', posB);
|
|
3735
|
-
}
|
|
3736
|
-
/**
|
|
3737
|
-
* Whether the user is currently drag n dropping elements (instead of selection)
|
|
3738
|
-
* @return {boolean}
|
|
3739
|
-
*/
|
|
3740
|
-
|
|
3741
3588
|
}]);
|
|
3742
3589
|
|
|
3743
3590
|
return DragSelect;
|