dragselect 2.5.0 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +3 -3
- package/dist/DragSelect.es6m.js +39 -33
- package/dist/DragSelect.js +39 -33
- package/dist/ds.es6m.min.js +1 -1
- package/dist/ds.min.js +1 -1
- package/dist/modules/DropZone.d.ts +5 -3
- package/dist/modules/DropZones.d.ts +0 -3
- package/dist/types.d.ts +10 -1
- package/package.json +1 -1
- package/src/methods/hydrateSettings.js +176 -47
- package/src/modules/DropZone.js +62 -25
- package/src/modules/DropZones.js +22 -16
- package/src/modules/SelectableSet.js +17 -13
- package/src/types.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# 2.5.2
|
|
2
|
+
|
|
3
|
+
- Make `droppables` within `dropZones` optional and use all selectables as default value if no droppables are provided.
|
|
4
|
+
|
|
5
|
+
# 2.5.1
|
|
6
|
+
|
|
7
|
+
- Fix: when an item had multiple dropzones, the `${droppedInsideClass}` was removed even tho’ the item was dropped inside a zone
|
|
8
|
+
|
|
1
9
|
# 2.5.0
|
|
2
10
|
|
|
3
11
|
- Add dropZones! Solves #115
|
package/README.md
CHANGED
|
@@ -170,8 +170,8 @@ const ds = new DragSelect({
|
|
|
170
170
|
selectables: document.querySelectorAll('.selectable-nodes'),
|
|
171
171
|
area: document.querySelector('#area'),
|
|
172
172
|
dropZones: [
|
|
173
|
-
{ element: document.querySelector('#zone-1'), id: 'zone-1',
|
|
174
|
-
{ element: document.querySelector('#zone-2'), id: 'zone-2', droppables: document.querySelectorAll('#item-2,#item-4') },
|
|
173
|
+
{ element: document.querySelector('#zone-1'), id: 'zone-1' }, // all selectables can be dropped into zone 1
|
|
174
|
+
{ element: document.querySelector('#zone-2'), id: 'zone-2', droppables: document.querySelectorAll('#item-2,#item-4') }, // only items 2 and 4 are droppable
|
|
175
175
|
],
|
|
176
176
|
dropInsideThreshold: 1, // 1 = has to be 100% inside the dropzone, 0.5 = 50% inside, 0 = just touching is fine
|
|
177
177
|
});
|
|
@@ -334,7 +334,7 @@ Here is the full list:
|
|
|
334
334
|
|keyboardDragSpeed |number |The speed at which elements are dragged using the keyboard. In pixels per keyDown. |`10`
|
|
335
335
|
|useTransform |boolean |Whether to use the more performant hardware accelerated css transforms when dragging instead of the top/left positions. |`true`
|
|
336
336
|
|refreshMemoryRate |number |Refresh rate on memoization, higher numbers mean better performance but more lag if elements are moving, lower numbers mean less lag but worse performance. If none of your DOMNodes are moving, you can set it to a very high number to increase performance. Value in milliseconds. |`80`
|
|
337
|
-
|dropZones |[{ id: 'string', element: single DOM element (node), droppables
|
|
337
|
+
|dropZones |[{ id: 'string', element: single DOM element (node), droppables?: DOM elements [nodes] }] |zones with association of droppable items that can be dropped into them. `id`: any unique identifying string. `element`: is the dropzone itself. `droppables`: the elements that can be dropped into that zone. This is optional, by default it is all selectables |`[]`
|
|
338
338
|
|dropInsideThreshold |number |How much % of the item has to be inside the dropzone to be considered inside (0 = barely touching, 1 = completely inside) |`1`
|
|
339
339
|
|dropTargetThreshold |number |How much % of the zone does the pointer has to be in to be considered a target (0 = anywhere in the zone, max: 0.5 = has to point at the center of the zone) |`0`
|
|
340
340
|
|usePointerEvents |boolean |Whether to use Pointer Events to replace traditional Mouse or Touch Events. Useful for tools like Google Blockly. |`false`
|
package/dist/DragSelect.es6m.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/***
|
|
2
2
|
|
|
3
|
-
~~~ Version 2.
|
|
3
|
+
~~~ Version 2.5.2 ~~~
|
|
4
4
|
|
|
5
5
|
******************************************
|
|
6
6
|
|
|
@@ -388,9 +388,9 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
|
388
388
|
|
|
389
389
|
/**
|
|
390
390
|
* @typedef {Object} DSInputDropZone
|
|
391
|
-
* @property {string} id
|
|
392
|
-
* @property {DSElement} element
|
|
393
|
-
* @property {DSInputElements} droppables
|
|
391
|
+
* @property {string} id can be any unique identifier of type string
|
|
392
|
+
* @property {DSElement} element is the dropzone itself
|
|
393
|
+
* @property {DSInputElements} [droppables] the elements that can be dropped into that zone. This is optional, by default it will be all selectables
|
|
394
394
|
*/
|
|
395
395
|
/**
|
|
396
396
|
* @typedef {Object} DSDropZone
|
|
@@ -1079,8 +1079,8 @@ var handleUnSelection = (function (_ref) {
|
|
|
1079
1079
|
});
|
|
1080
1080
|
|
|
1081
1081
|
/**
|
|
1082
|
-
* @param {string} key
|
|
1083
|
-
* @param {string} type
|
|
1082
|
+
* @param {string} key
|
|
1083
|
+
* @param {string} type
|
|
1084
1084
|
* @param {*} fallback
|
|
1085
1085
|
* @returns {void}
|
|
1086
1086
|
*/
|
|
@@ -1089,10 +1089,10 @@ var wrongTypeWarn = function wrongTypeWarn(key, type, fallback) {
|
|
|
1089
1089
|
};
|
|
1090
1090
|
|
|
1091
1091
|
/**
|
|
1092
|
-
* @param {string} key
|
|
1092
|
+
* @param {string} key
|
|
1093
1093
|
* @param {*} value
|
|
1094
|
-
* @param {boolean} withFallback
|
|
1095
|
-
* @param {*} fallback
|
|
1094
|
+
* @param {boolean} withFallback
|
|
1095
|
+
* @param {*} fallback
|
|
1096
1096
|
* @returns {object}
|
|
1097
1097
|
*/
|
|
1098
1098
|
var hydrateHelper = function hydrateHelper(key, value, withFallback, fallback) {
|
|
@@ -1114,24 +1114,24 @@ var hydrateHelper = function hydrateHelper(key, value, withFallback, fallback) {
|
|
|
1114
1114
|
}
|
|
1115
1115
|
|
|
1116
1116
|
// TypeCheck [Number]
|
|
1117
|
-
var expectedNumber = !isNaN(fallback) && typeof fallback === 'number';
|
|
1118
|
-
if (expectedNumber) isAvailable = !isNaN(value) && typeof value === 'number';
|
|
1117
|
+
var expectedNumber = !Number.isNaN(fallback) && typeof fallback === 'number';
|
|
1118
|
+
if (expectedNumber) isAvailable = !Number.isNaN(value) && typeof value === 'number';
|
|
1119
1119
|
if (expectedNumber && !isAvailable) {
|
|
1120
1120
|
forceFallback = true;
|
|
1121
1121
|
wrongTypeWarn(key, 'number');
|
|
1122
1122
|
}
|
|
1123
1123
|
|
|
1124
1124
|
// TypeCheck [Object]
|
|
1125
|
-
var expectedObject = Object.prototype.toString.call(fallback) ===
|
|
1126
|
-
if (expectedObject) isAvailable = Object.prototype.toString.call(value) ===
|
|
1125
|
+
var expectedObject = Object.prototype.toString.call(fallback) === '[object Object]';
|
|
1126
|
+
if (expectedObject) isAvailable = Object.prototype.toString.call(value) === '[object Object]';
|
|
1127
1127
|
if (expectedObject && !isAvailable) {
|
|
1128
1128
|
forceFallback = true;
|
|
1129
1129
|
wrongTypeWarn(key, 'object');
|
|
1130
1130
|
}
|
|
1131
1131
|
|
|
1132
1132
|
// TypeCheck [Boolean]
|
|
1133
|
-
var expectedBoolean = typeof fallback ===
|
|
1134
|
-
if (expectedBoolean) isAvailable = typeof value ===
|
|
1133
|
+
var expectedBoolean = typeof fallback === 'boolean';
|
|
1134
|
+
if (expectedBoolean) isAvailable = typeof value === 'boolean';
|
|
1135
1135
|
if (expectedBoolean && !isAvailable) {
|
|
1136
1136
|
forceFallback = true;
|
|
1137
1137
|
wrongTypeWarn(key, 'boolean');
|
|
@@ -1147,24 +1147,27 @@ var hydrateHelper = function hydrateHelper(key, value, withFallback, fallback) {
|
|
|
1147
1147
|
var isFallback = forceFallback || withFallback;
|
|
1148
1148
|
|
|
1149
1149
|
// Special rule for [dragKeys]
|
|
1150
|
-
if (key === 'dragKeys' && isAvailable) return _defineProperty({}, key, Object.assign(fallback, value));
|
|
1150
|
+
if (key === 'dragKeys' && isAvailable) return _defineProperty({}, key, Object.assign(fallback, value));
|
|
1151
|
+
if (key === 'dragKeys' && !isAvailable) return isFallback ? _defineProperty({}, key, fallback) : {};
|
|
1151
1152
|
|
|
1152
1153
|
// Special rule for [dropZones]
|
|
1153
1154
|
if (key === 'dropZones' && isAvailable && new Set(value.map(function (v) {
|
|
1154
1155
|
return v.id;
|
|
1155
1156
|
})).size !== value.length) console.warn("[DragSelect] UniqueConstraintsIssue: setting \"dropZones\" contains duplicate ids.");
|
|
1156
|
-
|
|
1157
|
+
if (isAvailable) return _defineProperty({}, key, value);
|
|
1158
|
+
if (isFallback) return _defineProperty({}, key, fallback);
|
|
1159
|
+
return {};
|
|
1157
1160
|
};
|
|
1158
1161
|
|
|
1159
1162
|
/**
|
|
1160
1163
|
* This helper method creates the setting object,
|
|
1161
1164
|
* - if the settings provided are of wrong type, the fallback value will be used
|
|
1162
1165
|
* - - except for if settings are undefined or explicitly marked as "null"
|
|
1163
|
-
* - if "withfallback" is true, it will return the object with all settings:
|
|
1166
|
+
* - if "withfallback" is true, it will return the object with all settings:
|
|
1164
1167
|
* - - if not provided from the settings object (or wrong type), the fallback will be used
|
|
1165
1168
|
* (the fallback value for each setting is the last prop of the hydrateHelper)
|
|
1166
|
-
* @param {Settings} settings
|
|
1167
|
-
* @param {boolean} withFallback
|
|
1169
|
+
* @param {Settings} settings
|
|
1170
|
+
* @param {boolean} withFallback
|
|
1168
1171
|
*/
|
|
1169
1172
|
var hydrateSettings = (function (settings, withFallback) {
|
|
1170
1173
|
return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_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, {
|
|
@@ -1817,7 +1820,7 @@ var DropZone = /*#__PURE__*/function () {
|
|
|
1817
1820
|
* @param {DragSelect} obj.DS
|
|
1818
1821
|
* @param {string} obj.id
|
|
1819
1822
|
* @param {DSElement} obj.element
|
|
1820
|
-
* @param {DSInputElements} obj.droppables
|
|
1823
|
+
* @param {DSInputElements} [obj.droppables]
|
|
1821
1824
|
* @ignore
|
|
1822
1825
|
*/
|
|
1823
1826
|
function DropZone(_ref) {
|
|
@@ -1829,7 +1832,7 @@ var DropZone = /*#__PURE__*/function () {
|
|
|
1829
1832
|
_classCallCheck(this, DropZone);
|
|
1830
1833
|
_defineProperty(this, "id", void 0);
|
|
1831
1834
|
_defineProperty(this, "element", void 0);
|
|
1832
|
-
_defineProperty(this, "
|
|
1835
|
+
_defineProperty(this, "_droppables", void 0);
|
|
1833
1836
|
_defineProperty(this, "_rect", void 0);
|
|
1834
1837
|
_defineProperty(this, "_observers", void 0);
|
|
1835
1838
|
_defineProperty(this, "_timeout", void 0);
|
|
@@ -1865,7 +1868,6 @@ var DropZone = /*#__PURE__*/function () {
|
|
|
1865
1868
|
_defineProperty(this, "handleDrop", function () {
|
|
1866
1869
|
var _this$droppables, _this$_itemsDropped2, _this$_itemsDropped3;
|
|
1867
1870
|
if (_this.isDestroyed) return;
|
|
1868
|
-
// @ts-ignore
|
|
1869
1871
|
_this._itemsDropped = _toConsumableArray(new Set([].concat(_toConsumableArray(_this._itemsDropped), _toConsumableArray((_this$droppables = _this.droppables) === null || _this$droppables === void 0 ? void 0 : _this$droppables.filter(function (item) {
|
|
1870
1872
|
return _this.DS.SelectedSet.has(item);
|
|
1871
1873
|
})))));
|
|
@@ -1885,8 +1887,8 @@ var DropZone = /*#__PURE__*/function () {
|
|
|
1885
1887
|
item.classList.add("".concat(_this.Settings.droppedInsideClass, "-").concat(_this.id));
|
|
1886
1888
|
isAnyInside = true;
|
|
1887
1889
|
} else {
|
|
1888
|
-
item.classList.remove("".concat(_this.Settings.droppedInsideClass));
|
|
1889
1890
|
item.classList.remove("".concat(_this.Settings.droppedInsideClass, "-").concat(_this.id));
|
|
1891
|
+
if (!item.className.includes("".concat(_this.Settings.droppedInsideClass, "-"))) item.classList.remove("".concat(_this.Settings.droppedInsideClass));
|
|
1890
1892
|
}
|
|
1891
1893
|
});
|
|
1892
1894
|
if (isAnyInside) _this.element.classList.add("".concat(_this.Settings.dropZoneInsideClass));else _this.element.classList.remove("".concat(_this.Settings.dropZoneInsideClass));
|
|
@@ -1915,14 +1917,14 @@ var DropZone = /*#__PURE__*/function () {
|
|
|
1915
1917
|
this.Settings = DS.stores.SettingsStore.s;
|
|
1916
1918
|
this.id = id;
|
|
1917
1919
|
this.element = element;
|
|
1918
|
-
this.droppables = toArray(droppables);
|
|
1920
|
+
if (droppables) this.droppables = toArray(droppables);
|
|
1919
1921
|
this.element.classList.add("".concat(this.Settings.dropZoneClass));
|
|
1920
1922
|
|
|
1921
1923
|
// @ts-ignore: @todo: update to typescript
|
|
1922
1924
|
this.DS.subscribe('Settings:updated:dropZoneClass', function (_ref4) {
|
|
1923
1925
|
var settings = _ref4.settings;
|
|
1924
1926
|
_this.element.classList.remove(settings['dropZoneClass:pre']);
|
|
1925
|
-
_this.element.classList.add(settings
|
|
1927
|
+
_this.element.classList.add(settings.dropZoneClass);
|
|
1926
1928
|
});
|
|
1927
1929
|
this._observers = addModificationObservers(this.parentNodes, debounce(function () {
|
|
1928
1930
|
return _this._rect = null;
|
|
@@ -1997,6 +1999,15 @@ var DropZone = /*#__PURE__*/function () {
|
|
|
1997
1999
|
if (this._parentNodes) return this._parentNodes;
|
|
1998
2000
|
return this._parentNodes = getAllParentNodes(this.element);
|
|
1999
2001
|
}
|
|
2002
|
+
}, {
|
|
2003
|
+
key: "droppables",
|
|
2004
|
+
get: function get() {
|
|
2005
|
+
if (this._droppables) return this._droppables;
|
|
2006
|
+
return this.DS.SelectableSet.elements;
|
|
2007
|
+
},
|
|
2008
|
+
set: function set(value) {
|
|
2009
|
+
this._droppables = value;
|
|
2010
|
+
}
|
|
2000
2011
|
}]);
|
|
2001
2012
|
return DropZone;
|
|
2002
2013
|
}();
|
|
@@ -2084,13 +2095,9 @@ function DropZones(_ref) {
|
|
|
2084
2095
|
}
|
|
2085
2096
|
}
|
|
2086
2097
|
});
|
|
2087
|
-
_defineProperty(this, "
|
|
2098
|
+
_defineProperty(this, "stop", function (_ref4) {
|
|
2088
2099
|
var isDragging = _ref4.isDragging;
|
|
2089
2100
|
if (!isDragging) return;
|
|
2090
|
-
});
|
|
2091
|
-
_defineProperty(this, "stop", function (_ref5) {
|
|
2092
|
-
var isDragging = _ref5.isDragging;
|
|
2093
|
-
if (!isDragging) return;
|
|
2094
2101
|
var target = _this.getTarget();
|
|
2095
2102
|
_this._handleDrop(target);
|
|
2096
2103
|
});
|
|
@@ -2125,7 +2132,6 @@ function DropZones(_ref) {
|
|
|
2125
2132
|
this.setDropZones({
|
|
2126
2133
|
dropZones: /** @type {DSDropZone[]} */this.DS.stores.SettingsStore.s.dropZones
|
|
2127
2134
|
});
|
|
2128
|
-
this.DS.subscribe('Interaction:start', this.start);
|
|
2129
2135
|
this.DS.subscribe('Interaction:end', this.stop);
|
|
2130
2136
|
}
|
|
2131
2137
|
|
|
@@ -2428,7 +2434,7 @@ var SelectableSet = /*#__PURE__*/function (_Set) {
|
|
|
2428
2434
|
var settings = _ref2.settings;
|
|
2429
2435
|
_this.forEach(function (el) {
|
|
2430
2436
|
el.classList.remove(settings['selectableClass:pre']);
|
|
2431
|
-
el.classList.add(settings
|
|
2437
|
+
el.classList.add(settings.selectableClass);
|
|
2432
2438
|
});
|
|
2433
2439
|
});
|
|
2434
2440
|
return _this;
|
package/dist/DragSelect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/***
|
|
2
2
|
|
|
3
|
-
~~~ Version 2.
|
|
3
|
+
~~~ Version 2.5.2 ~~~
|
|
4
4
|
|
|
5
5
|
******************************************
|
|
6
6
|
|
|
@@ -394,9 +394,9 @@
|
|
|
394
394
|
|
|
395
395
|
/**
|
|
396
396
|
* @typedef {Object} DSInputDropZone
|
|
397
|
-
* @property {string} id
|
|
398
|
-
* @property {DSElement} element
|
|
399
|
-
* @property {DSInputElements} droppables
|
|
397
|
+
* @property {string} id can be any unique identifier of type string
|
|
398
|
+
* @property {DSElement} element is the dropzone itself
|
|
399
|
+
* @property {DSInputElements} [droppables] the elements that can be dropped into that zone. This is optional, by default it will be all selectables
|
|
400
400
|
*/
|
|
401
401
|
/**
|
|
402
402
|
* @typedef {Object} DSDropZone
|
|
@@ -1085,8 +1085,8 @@
|
|
|
1085
1085
|
});
|
|
1086
1086
|
|
|
1087
1087
|
/**
|
|
1088
|
-
* @param {string} key
|
|
1089
|
-
* @param {string} type
|
|
1088
|
+
* @param {string} key
|
|
1089
|
+
* @param {string} type
|
|
1090
1090
|
* @param {*} fallback
|
|
1091
1091
|
* @returns {void}
|
|
1092
1092
|
*/
|
|
@@ -1095,10 +1095,10 @@
|
|
|
1095
1095
|
};
|
|
1096
1096
|
|
|
1097
1097
|
/**
|
|
1098
|
-
* @param {string} key
|
|
1098
|
+
* @param {string} key
|
|
1099
1099
|
* @param {*} value
|
|
1100
|
-
* @param {boolean} withFallback
|
|
1101
|
-
* @param {*} fallback
|
|
1100
|
+
* @param {boolean} withFallback
|
|
1101
|
+
* @param {*} fallback
|
|
1102
1102
|
* @returns {object}
|
|
1103
1103
|
*/
|
|
1104
1104
|
var hydrateHelper = function hydrateHelper(key, value, withFallback, fallback) {
|
|
@@ -1120,24 +1120,24 @@
|
|
|
1120
1120
|
}
|
|
1121
1121
|
|
|
1122
1122
|
// TypeCheck [Number]
|
|
1123
|
-
var expectedNumber = !isNaN(fallback) && typeof fallback === 'number';
|
|
1124
|
-
if (expectedNumber) isAvailable = !isNaN(value) && typeof value === 'number';
|
|
1123
|
+
var expectedNumber = !Number.isNaN(fallback) && typeof fallback === 'number';
|
|
1124
|
+
if (expectedNumber) isAvailable = !Number.isNaN(value) && typeof value === 'number';
|
|
1125
1125
|
if (expectedNumber && !isAvailable) {
|
|
1126
1126
|
forceFallback = true;
|
|
1127
1127
|
wrongTypeWarn(key, 'number');
|
|
1128
1128
|
}
|
|
1129
1129
|
|
|
1130
1130
|
// TypeCheck [Object]
|
|
1131
|
-
var expectedObject = Object.prototype.toString.call(fallback) ===
|
|
1132
|
-
if (expectedObject) isAvailable = Object.prototype.toString.call(value) ===
|
|
1131
|
+
var expectedObject = Object.prototype.toString.call(fallback) === '[object Object]';
|
|
1132
|
+
if (expectedObject) isAvailable = Object.prototype.toString.call(value) === '[object Object]';
|
|
1133
1133
|
if (expectedObject && !isAvailable) {
|
|
1134
1134
|
forceFallback = true;
|
|
1135
1135
|
wrongTypeWarn(key, 'object');
|
|
1136
1136
|
}
|
|
1137
1137
|
|
|
1138
1138
|
// TypeCheck [Boolean]
|
|
1139
|
-
var expectedBoolean = typeof fallback ===
|
|
1140
|
-
if (expectedBoolean) isAvailable = typeof value ===
|
|
1139
|
+
var expectedBoolean = typeof fallback === 'boolean';
|
|
1140
|
+
if (expectedBoolean) isAvailable = typeof value === 'boolean';
|
|
1141
1141
|
if (expectedBoolean && !isAvailable) {
|
|
1142
1142
|
forceFallback = true;
|
|
1143
1143
|
wrongTypeWarn(key, 'boolean');
|
|
@@ -1153,24 +1153,27 @@
|
|
|
1153
1153
|
var isFallback = forceFallback || withFallback;
|
|
1154
1154
|
|
|
1155
1155
|
// Special rule for [dragKeys]
|
|
1156
|
-
if (key === 'dragKeys' && isAvailable) return _defineProperty({}, key, Object.assign(fallback, value));
|
|
1156
|
+
if (key === 'dragKeys' && isAvailable) return _defineProperty({}, key, Object.assign(fallback, value));
|
|
1157
|
+
if (key === 'dragKeys' && !isAvailable) return isFallback ? _defineProperty({}, key, fallback) : {};
|
|
1157
1158
|
|
|
1158
1159
|
// Special rule for [dropZones]
|
|
1159
1160
|
if (key === 'dropZones' && isAvailable && new Set(value.map(function (v) {
|
|
1160
1161
|
return v.id;
|
|
1161
1162
|
})).size !== value.length) console.warn("[DragSelect] UniqueConstraintsIssue: setting \"dropZones\" contains duplicate ids.");
|
|
1162
|
-
|
|
1163
|
+
if (isAvailable) return _defineProperty({}, key, value);
|
|
1164
|
+
if (isFallback) return _defineProperty({}, key, fallback);
|
|
1165
|
+
return {};
|
|
1163
1166
|
};
|
|
1164
1167
|
|
|
1165
1168
|
/**
|
|
1166
1169
|
* This helper method creates the setting object,
|
|
1167
1170
|
* - if the settings provided are of wrong type, the fallback value will be used
|
|
1168
1171
|
* - - except for if settings are undefined or explicitly marked as "null"
|
|
1169
|
-
* - if "withfallback" is true, it will return the object with all settings:
|
|
1172
|
+
* - if "withfallback" is true, it will return the object with all settings:
|
|
1170
1173
|
* - - if not provided from the settings object (or wrong type), the fallback will be used
|
|
1171
1174
|
* (the fallback value for each setting is the last prop of the hydrateHelper)
|
|
1172
|
-
* @param {Settings} settings
|
|
1173
|
-
* @param {boolean} withFallback
|
|
1175
|
+
* @param {Settings} settings
|
|
1176
|
+
* @param {boolean} withFallback
|
|
1174
1177
|
*/
|
|
1175
1178
|
var hydrateSettings = (function (settings, withFallback) {
|
|
1176
1179
|
return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_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, {
|
|
@@ -1823,7 +1826,7 @@
|
|
|
1823
1826
|
* @param {DragSelect} obj.DS
|
|
1824
1827
|
* @param {string} obj.id
|
|
1825
1828
|
* @param {DSElement} obj.element
|
|
1826
|
-
* @param {DSInputElements} obj.droppables
|
|
1829
|
+
* @param {DSInputElements} [obj.droppables]
|
|
1827
1830
|
* @ignore
|
|
1828
1831
|
*/
|
|
1829
1832
|
function DropZone(_ref) {
|
|
@@ -1835,7 +1838,7 @@
|
|
|
1835
1838
|
_classCallCheck(this, DropZone);
|
|
1836
1839
|
_defineProperty(this, "id", void 0);
|
|
1837
1840
|
_defineProperty(this, "element", void 0);
|
|
1838
|
-
_defineProperty(this, "
|
|
1841
|
+
_defineProperty(this, "_droppables", void 0);
|
|
1839
1842
|
_defineProperty(this, "_rect", void 0);
|
|
1840
1843
|
_defineProperty(this, "_observers", void 0);
|
|
1841
1844
|
_defineProperty(this, "_timeout", void 0);
|
|
@@ -1871,7 +1874,6 @@
|
|
|
1871
1874
|
_defineProperty(this, "handleDrop", function () {
|
|
1872
1875
|
var _this$droppables, _this$_itemsDropped2, _this$_itemsDropped3;
|
|
1873
1876
|
if (_this.isDestroyed) return;
|
|
1874
|
-
// @ts-ignore
|
|
1875
1877
|
_this._itemsDropped = _toConsumableArray(new Set([].concat(_toConsumableArray(_this._itemsDropped), _toConsumableArray((_this$droppables = _this.droppables) === null || _this$droppables === void 0 ? void 0 : _this$droppables.filter(function (item) {
|
|
1876
1878
|
return _this.DS.SelectedSet.has(item);
|
|
1877
1879
|
})))));
|
|
@@ -1891,8 +1893,8 @@
|
|
|
1891
1893
|
item.classList.add("".concat(_this.Settings.droppedInsideClass, "-").concat(_this.id));
|
|
1892
1894
|
isAnyInside = true;
|
|
1893
1895
|
} else {
|
|
1894
|
-
item.classList.remove("".concat(_this.Settings.droppedInsideClass));
|
|
1895
1896
|
item.classList.remove("".concat(_this.Settings.droppedInsideClass, "-").concat(_this.id));
|
|
1897
|
+
if (!item.className.includes("".concat(_this.Settings.droppedInsideClass, "-"))) item.classList.remove("".concat(_this.Settings.droppedInsideClass));
|
|
1896
1898
|
}
|
|
1897
1899
|
});
|
|
1898
1900
|
if (isAnyInside) _this.element.classList.add("".concat(_this.Settings.dropZoneInsideClass));else _this.element.classList.remove("".concat(_this.Settings.dropZoneInsideClass));
|
|
@@ -1921,14 +1923,14 @@
|
|
|
1921
1923
|
this.Settings = DS.stores.SettingsStore.s;
|
|
1922
1924
|
this.id = id;
|
|
1923
1925
|
this.element = element;
|
|
1924
|
-
this.droppables = toArray(droppables);
|
|
1926
|
+
if (droppables) this.droppables = toArray(droppables);
|
|
1925
1927
|
this.element.classList.add("".concat(this.Settings.dropZoneClass));
|
|
1926
1928
|
|
|
1927
1929
|
// @ts-ignore: @todo: update to typescript
|
|
1928
1930
|
this.DS.subscribe('Settings:updated:dropZoneClass', function (_ref4) {
|
|
1929
1931
|
var settings = _ref4.settings;
|
|
1930
1932
|
_this.element.classList.remove(settings['dropZoneClass:pre']);
|
|
1931
|
-
_this.element.classList.add(settings
|
|
1933
|
+
_this.element.classList.add(settings.dropZoneClass);
|
|
1932
1934
|
});
|
|
1933
1935
|
this._observers = addModificationObservers(this.parentNodes, debounce(function () {
|
|
1934
1936
|
return _this._rect = null;
|
|
@@ -2003,6 +2005,15 @@
|
|
|
2003
2005
|
if (this._parentNodes) return this._parentNodes;
|
|
2004
2006
|
return this._parentNodes = getAllParentNodes(this.element);
|
|
2005
2007
|
}
|
|
2008
|
+
}, {
|
|
2009
|
+
key: "droppables",
|
|
2010
|
+
get: function get() {
|
|
2011
|
+
if (this._droppables) return this._droppables;
|
|
2012
|
+
return this.DS.SelectableSet.elements;
|
|
2013
|
+
},
|
|
2014
|
+
set: function set(value) {
|
|
2015
|
+
this._droppables = value;
|
|
2016
|
+
}
|
|
2006
2017
|
}]);
|
|
2007
2018
|
return DropZone;
|
|
2008
2019
|
}();
|
|
@@ -2090,13 +2101,9 @@
|
|
|
2090
2101
|
}
|
|
2091
2102
|
}
|
|
2092
2103
|
});
|
|
2093
|
-
_defineProperty(this, "
|
|
2104
|
+
_defineProperty(this, "stop", function (_ref4) {
|
|
2094
2105
|
var isDragging = _ref4.isDragging;
|
|
2095
2106
|
if (!isDragging) return;
|
|
2096
|
-
});
|
|
2097
|
-
_defineProperty(this, "stop", function (_ref5) {
|
|
2098
|
-
var isDragging = _ref5.isDragging;
|
|
2099
|
-
if (!isDragging) return;
|
|
2100
2107
|
var target = _this.getTarget();
|
|
2101
2108
|
_this._handleDrop(target);
|
|
2102
2109
|
});
|
|
@@ -2131,7 +2138,6 @@
|
|
|
2131
2138
|
this.setDropZones({
|
|
2132
2139
|
dropZones: /** @type {DSDropZone[]} */this.DS.stores.SettingsStore.s.dropZones
|
|
2133
2140
|
});
|
|
2134
|
-
this.DS.subscribe('Interaction:start', this.start);
|
|
2135
2141
|
this.DS.subscribe('Interaction:end', this.stop);
|
|
2136
2142
|
}
|
|
2137
2143
|
|
|
@@ -2434,7 +2440,7 @@
|
|
|
2434
2440
|
var settings = _ref2.settings;
|
|
2435
2441
|
_this.forEach(function (el) {
|
|
2436
2442
|
el.classList.remove(settings['selectableClass:pre']);
|
|
2437
|
-
el.classList.add(settings
|
|
2443
|
+
el.classList.add(settings.selectableClass);
|
|
2438
2444
|
});
|
|
2439
2445
|
});
|
|
2440
2446
|
return _this;
|