@fangzhongya/fang-ui 0.1.20 → 0.1.21

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.
Files changed (77) hide show
  1. package/dist/components/array/src/data.cjs +4 -0
  2. package/dist/components/array/src/data.d.ts +4 -0
  3. package/dist/components/array/src/data.js +4 -0
  4. package/dist/components/array/src/index2.cjs +22 -21
  5. package/dist/components/array/src/index2.js +12 -11
  6. package/dist/components/common/compons.cjs +4 -2
  7. package/dist/components/common/compons.d.ts +1 -1
  8. package/dist/components/common/compons.js +4 -2
  9. package/dist/components/forms/src/data.cjs +2 -2
  10. package/dist/components/forms/src/data.js +2 -2
  11. package/dist/components/forms-div/src/index2.cjs +4 -3
  12. package/dist/components/forms-div/src/index2.js +3 -2
  13. package/dist/components/forms-item/src/label.cjs +3 -2
  14. package/dist/components/forms-item/src/label.js +3 -2
  15. package/dist/components/index.cjs +16 -14
  16. package/dist/components/index.d.ts +1 -0
  17. package/dist/components/index.js +2 -0
  18. package/dist/components/index.scss +3 -1
  19. package/dist/components/index2.scss +3 -1
  20. package/dist/components/list/src/index2.cjs +16 -15
  21. package/dist/components/list/src/index2.js +17 -16
  22. package/dist/components/lists/index.css +2 -2
  23. package/dist/components/lists/index.scss +7 -2
  24. package/dist/components/lists/src/data.cjs +12 -1
  25. package/dist/components/lists/src/data.d.ts +10 -0
  26. package/dist/components/lists/src/data.js +12 -1
  27. package/dist/components/lists/src/index2.cjs +7 -5
  28. package/dist/components/lists/src/index2.js +7 -5
  29. package/dist/components/listsp/index.css +2 -2
  30. package/dist/components/listsp/src/data.d.ts +1 -5
  31. package/dist/components/listspd/index.cjs +9 -0
  32. package/dist/components/listspd/index.css +99 -0
  33. package/dist/components/listspd/index.d.ts +4 -0
  34. package/dist/components/listspd/index.js +9 -0
  35. package/dist/components/listspd/index.scss +30 -0
  36. package/dist/components/listspd/src/data.cjs +13 -0
  37. package/dist/components/listspd/src/data.d.ts +14 -0
  38. package/dist/components/listspd/src/data.js +13 -0
  39. package/dist/components/listspd/src/index.cjs +4 -0
  40. package/dist/components/listspd/src/index.js +4 -0
  41. package/dist/components/listspd/src/index2.cjs +111 -0
  42. package/dist/components/listspd/src/index2.js +111 -0
  43. package/dist/components/listspd/style/index2.scss +4 -0
  44. package/dist/components/tables/common/config.cjs +1 -1
  45. package/dist/components/tables/common/config.js +1 -1
  46. package/dist/css/index.css +48 -2
  47. package/dist/css/lists.css +2 -2
  48. package/dist/css/listsp.css +2 -2
  49. package/dist/css/listspd.css +99 -0
  50. package/dist/directives/adjust/index.cjs +10 -6
  51. package/dist/directives/adjust/index.js +10 -6
  52. package/dist/directives/sortable/index.cjs +2 -2
  53. package/dist/directives/sortable/index.js +1 -1
  54. package/dist/expand/{chunk-OT6GISSR.cjs → chunk-2L4PC7LZ.cjs} +2 -0
  55. package/dist/expand/{chunk-2BLP2ANQ.js → chunk-RBGCE6BS.js} +2 -0
  56. package/dist/expand/components.cjs +5 -5
  57. package/dist/expand/components.js +1 -1
  58. package/dist/expand/config.cjs +2 -2
  59. package/dist/expand/config.js +1 -1
  60. package/dist/icons/index.json +1 -1
  61. package/dist/index.cjs +38 -36
  62. package/dist/{components/index.css → index.css} +48 -2
  63. package/dist/index.js +2 -0
  64. package/package.json +6 -6
  65. package/dist/directives/adjust/index copy 2.d.ts +0 -6
  66. package/dist/directives/adjust/index copy 3.d.ts +0 -6
  67. package/dist/directives/adjust/index copy 4.d.ts +0 -6
  68. package/dist/directives/adjust/index copy 5.d.ts +0 -6
  69. package/dist/directives/adjust/index copy 6.d.ts +0 -6
  70. package/dist/directives/adjust/index copy 7.d.ts +0 -6
  71. package/dist/directives/adjust/index copy 8.d.ts +0 -6
  72. package/dist/directives/adjust/index copy 9.d.ts +0 -6
  73. package/dist/directives/adjust/index copy.d.ts +0 -6
  74. package/dist/node_modules/.pnpm/sortablejs@1.15.6/node_modules/sortablejs/modular/sortable.esm.cjs +0 -2758
  75. package/dist/node_modules/.pnpm/sortablejs@1.15.6/node_modules/sortablejs/modular/sortable.esm.js +0 -2758
  76. /package/dist/components/{global-config → keep-com}/index.css +0 -0
  77. /package/dist/css/{global-config.css → keep-com.css} +0 -0
@@ -1,2758 +0,0 @@
1
- /**!
2
- * Sortable 1.15.6
3
- * @author RubaXa <trash@rubaxa.org>
4
- * @author owenm <owen23355@gmail.com>
5
- * @license MIT
6
- */
7
- function ownKeys(object, enumerableOnly) {
8
- var keys = Object.keys(object);
9
- if (Object.getOwnPropertySymbols) {
10
- var symbols = Object.getOwnPropertySymbols(object);
11
- if (enumerableOnly) {
12
- symbols = symbols.filter(function(sym) {
13
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
14
- });
15
- }
16
- keys.push.apply(keys, symbols);
17
- }
18
- return keys;
19
- }
20
- function _objectSpread2(target) {
21
- for (var i = 1; i < arguments.length; i++) {
22
- var source = arguments[i] != null ? arguments[i] : {};
23
- if (i % 2) {
24
- ownKeys(Object(source), true).forEach(function(key) {
25
- _defineProperty(target, key, source[key]);
26
- });
27
- } else if (Object.getOwnPropertyDescriptors) {
28
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
29
- } else {
30
- ownKeys(Object(source)).forEach(function(key) {
31
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
32
- });
33
- }
34
- }
35
- return target;
36
- }
37
- function _typeof(obj) {
38
- "@babel/helpers - typeof";
39
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
40
- _typeof = function(obj2) {
41
- return typeof obj2;
42
- };
43
- } else {
44
- _typeof = function(obj2) {
45
- return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
46
- };
47
- }
48
- return _typeof(obj);
49
- }
50
- function _defineProperty(obj, key, value) {
51
- if (key in obj) {
52
- Object.defineProperty(obj, key, {
53
- value,
54
- enumerable: true,
55
- configurable: true,
56
- writable: true
57
- });
58
- } else {
59
- obj[key] = value;
60
- }
61
- return obj;
62
- }
63
- function _extends() {
64
- _extends = Object.assign || function(target) {
65
- for (var i = 1; i < arguments.length; i++) {
66
- var source = arguments[i];
67
- for (var key in source) {
68
- if (Object.prototype.hasOwnProperty.call(source, key)) {
69
- target[key] = source[key];
70
- }
71
- }
72
- }
73
- return target;
74
- };
75
- return _extends.apply(this, arguments);
76
- }
77
- function _objectWithoutPropertiesLoose(source, excluded) {
78
- if (source == null) return {};
79
- var target = {};
80
- var sourceKeys = Object.keys(source);
81
- var key, i;
82
- for (i = 0; i < sourceKeys.length; i++) {
83
- key = sourceKeys[i];
84
- if (excluded.indexOf(key) >= 0) continue;
85
- target[key] = source[key];
86
- }
87
- return target;
88
- }
89
- function _objectWithoutProperties(source, excluded) {
90
- if (source == null) return {};
91
- var target = _objectWithoutPropertiesLoose(source, excluded);
92
- var key, i;
93
- if (Object.getOwnPropertySymbols) {
94
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
95
- for (i = 0; i < sourceSymbolKeys.length; i++) {
96
- key = sourceSymbolKeys[i];
97
- if (excluded.indexOf(key) >= 0) continue;
98
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
99
- target[key] = source[key];
100
- }
101
- }
102
- return target;
103
- }
104
- function _toConsumableArray(arr) {
105
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
106
- }
107
- function _arrayWithoutHoles(arr) {
108
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
109
- }
110
- function _iterableToArray(iter) {
111
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
112
- }
113
- function _unsupportedIterableToArray(o, minLen) {
114
- if (!o) return;
115
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
116
- var n = Object.prototype.toString.call(o).slice(8, -1);
117
- if (n === "Object" && o.constructor) n = o.constructor.name;
118
- if (n === "Map" || n === "Set") return Array.from(o);
119
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
120
- }
121
- function _arrayLikeToArray(arr, len) {
122
- if (len == null || len > arr.length) len = arr.length;
123
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
124
- return arr2;
125
- }
126
- function _nonIterableSpread() {
127
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
128
- }
129
- var version = "1.15.6";
130
- function userAgent(pattern) {
131
- if (typeof window !== "undefined" && window.navigator) {
132
- return !!/* @__PURE__ */ navigator.userAgent.match(pattern);
133
- }
134
- }
135
- var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
136
- var Edge = userAgent(/Edge/i);
137
- var FireFox = userAgent(/firefox/i);
138
- var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
139
- var IOS = userAgent(/iP(ad|od|hone)/i);
140
- var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
141
- var captureMode = {
142
- capture: false,
143
- passive: false
144
- };
145
- function on(el, event, fn) {
146
- el.addEventListener(event, fn, !IE11OrLess && captureMode);
147
- }
148
- function off(el, event, fn) {
149
- el.removeEventListener(event, fn, !IE11OrLess && captureMode);
150
- }
151
- function matches(el, selector) {
152
- if (!selector) return;
153
- selector[0] === ">" && (selector = selector.substring(1));
154
- if (el) {
155
- try {
156
- if (el.matches) {
157
- return el.matches(selector);
158
- } else if (el.msMatchesSelector) {
159
- return el.msMatchesSelector(selector);
160
- } else if (el.webkitMatchesSelector) {
161
- return el.webkitMatchesSelector(selector);
162
- }
163
- } catch (_) {
164
- return false;
165
- }
166
- }
167
- return false;
168
- }
169
- function getParentOrHost(el) {
170
- return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
171
- }
172
- function closest(el, selector, ctx, includeCTX) {
173
- if (el) {
174
- ctx = ctx || document;
175
- do {
176
- if (selector != null && (selector[0] === ">" ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
177
- return el;
178
- }
179
- if (el === ctx) break;
180
- } while (el = getParentOrHost(el));
181
- }
182
- return null;
183
- }
184
- var R_SPACE = /\s+/g;
185
- function toggleClass(el, name, state) {
186
- if (el && name) {
187
- if (el.classList) {
188
- el.classList[state ? "add" : "remove"](name);
189
- } else {
190
- var className = (" " + el.className + " ").replace(R_SPACE, " ").replace(" " + name + " ", " ");
191
- el.className = (className + (state ? " " + name : "")).replace(R_SPACE, " ");
192
- }
193
- }
194
- }
195
- function css(el, prop, val) {
196
- var style = el && el.style;
197
- if (style) {
198
- if (val === void 0) {
199
- if (document.defaultView && document.defaultView.getComputedStyle) {
200
- val = document.defaultView.getComputedStyle(el, "");
201
- } else if (el.currentStyle) {
202
- val = el.currentStyle;
203
- }
204
- return prop === void 0 ? val : val[prop];
205
- } else {
206
- if (!(prop in style) && prop.indexOf("webkit") === -1) {
207
- prop = "-webkit-" + prop;
208
- }
209
- style[prop] = val + (typeof val === "string" ? "" : "px");
210
- }
211
- }
212
- }
213
- function matrix(el, selfOnly) {
214
- var appliedTransforms = "";
215
- if (typeof el === "string") {
216
- appliedTransforms = el;
217
- } else {
218
- do {
219
- var transform = css(el, "transform");
220
- if (transform && transform !== "none") {
221
- appliedTransforms = transform + " " + appliedTransforms;
222
- }
223
- } while (!selfOnly && (el = el.parentNode));
224
- }
225
- var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
226
- return matrixFn && new matrixFn(appliedTransforms);
227
- }
228
- function find(ctx, tagName, iterator) {
229
- if (ctx) {
230
- var list = ctx.getElementsByTagName(tagName), i = 0, n = list.length;
231
- if (iterator) {
232
- for (; i < n; i++) {
233
- iterator(list[i], i);
234
- }
235
- }
236
- return list;
237
- }
238
- return [];
239
- }
240
- function getWindowScrollingElement() {
241
- var scrollingElement = document.scrollingElement;
242
- if (scrollingElement) {
243
- return scrollingElement;
244
- } else {
245
- return document.documentElement;
246
- }
247
- }
248
- function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
249
- if (!el.getBoundingClientRect && el !== window) return;
250
- var elRect, top, left, bottom, right, height, width;
251
- if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
252
- elRect = el.getBoundingClientRect();
253
- top = elRect.top;
254
- left = elRect.left;
255
- bottom = elRect.bottom;
256
- right = elRect.right;
257
- height = elRect.height;
258
- width = elRect.width;
259
- } else {
260
- top = 0;
261
- left = 0;
262
- bottom = window.innerHeight;
263
- right = window.innerWidth;
264
- height = window.innerHeight;
265
- width = window.innerWidth;
266
- }
267
- if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
268
- container = container || el.parentNode;
269
- if (!IE11OrLess) {
270
- do {
271
- if (container && container.getBoundingClientRect && (css(container, "transform") !== "none" || relativeToNonStaticParent && css(container, "position") !== "static")) {
272
- var containerRect = container.getBoundingClientRect();
273
- top -= containerRect.top + parseInt(css(container, "border-top-width"));
274
- left -= containerRect.left + parseInt(css(container, "border-left-width"));
275
- bottom = top + elRect.height;
276
- right = left + elRect.width;
277
- break;
278
- }
279
- } while (container = container.parentNode);
280
- }
281
- }
282
- if (undoScale && el !== window) {
283
- var elMatrix = matrix(container || el), scaleX = elMatrix && elMatrix.a, scaleY = elMatrix && elMatrix.d;
284
- if (elMatrix) {
285
- top /= scaleY;
286
- left /= scaleX;
287
- width /= scaleX;
288
- height /= scaleY;
289
- bottom = top + height;
290
- right = left + width;
291
- }
292
- }
293
- return {
294
- top,
295
- left,
296
- bottom,
297
- right,
298
- width,
299
- height
300
- };
301
- }
302
- function isScrolledPast(el, elSide, parentSide) {
303
- var parent = getParentAutoScrollElement(el, true), elSideVal = getRect(el)[elSide];
304
- while (parent) {
305
- var parentSideVal = getRect(parent)[parentSide], visible = void 0;
306
- if (parentSide === "top" || parentSide === "left") {
307
- visible = elSideVal >= parentSideVal;
308
- } else {
309
- visible = elSideVal <= parentSideVal;
310
- }
311
- if (!visible) return parent;
312
- if (parent === getWindowScrollingElement()) break;
313
- parent = getParentAutoScrollElement(parent, false);
314
- }
315
- return false;
316
- }
317
- function getChild(el, childNum, options, includeDragEl) {
318
- var currentChild = 0, i = 0, children = el.children;
319
- while (i < children.length) {
320
- if (children[i].style.display !== "none" && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
321
- if (currentChild === childNum) {
322
- return children[i];
323
- }
324
- currentChild++;
325
- }
326
- i++;
327
- }
328
- return null;
329
- }
330
- function lastChild(el, selector) {
331
- var last = el.lastElementChild;
332
- while (last && (last === Sortable.ghost || css(last, "display") === "none" || selector && !matches(last, selector))) {
333
- last = last.previousElementSibling;
334
- }
335
- return last || null;
336
- }
337
- function index(el, selector) {
338
- var index2 = 0;
339
- if (!el || !el.parentNode) {
340
- return -1;
341
- }
342
- while (el = el.previousElementSibling) {
343
- if (el.nodeName.toUpperCase() !== "TEMPLATE" && el !== Sortable.clone && (!selector || matches(el, selector))) {
344
- index2++;
345
- }
346
- }
347
- return index2;
348
- }
349
- function getRelativeScrollOffset(el) {
350
- var offsetLeft = 0, offsetTop = 0, winScroller = getWindowScrollingElement();
351
- if (el) {
352
- do {
353
- var elMatrix = matrix(el), scaleX = elMatrix.a, scaleY = elMatrix.d;
354
- offsetLeft += el.scrollLeft * scaleX;
355
- offsetTop += el.scrollTop * scaleY;
356
- } while (el !== winScroller && (el = el.parentNode));
357
- }
358
- return [offsetLeft, offsetTop];
359
- }
360
- function indexOfObject(arr, obj) {
361
- for (var i in arr) {
362
- if (!arr.hasOwnProperty(i)) continue;
363
- for (var key in obj) {
364
- if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
365
- }
366
- }
367
- return -1;
368
- }
369
- function getParentAutoScrollElement(el, includeSelf) {
370
- if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
371
- var elem = el;
372
- var gotSelf = false;
373
- do {
374
- if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
375
- var elemCSS = css(elem);
376
- if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == "auto" || elemCSS.overflowX == "scroll") || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == "auto" || elemCSS.overflowY == "scroll")) {
377
- if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
378
- if (gotSelf || includeSelf) return elem;
379
- gotSelf = true;
380
- }
381
- }
382
- } while (elem = elem.parentNode);
383
- return getWindowScrollingElement();
384
- }
385
- function extend(dst, src) {
386
- if (dst && src) {
387
- for (var key in src) {
388
- if (src.hasOwnProperty(key)) {
389
- dst[key] = src[key];
390
- }
391
- }
392
- }
393
- return dst;
394
- }
395
- function isRectEqual(rect1, rect2) {
396
- return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width);
397
- }
398
- var _throttleTimeout;
399
- function throttle(callback, ms) {
400
- return function() {
401
- if (!_throttleTimeout) {
402
- var args = arguments, _this = this;
403
- if (args.length === 1) {
404
- callback.call(_this, args[0]);
405
- } else {
406
- callback.apply(_this, args);
407
- }
408
- _throttleTimeout = setTimeout(function() {
409
- _throttleTimeout = void 0;
410
- }, ms);
411
- }
412
- };
413
- }
414
- function cancelThrottle() {
415
- clearTimeout(_throttleTimeout);
416
- _throttleTimeout = void 0;
417
- }
418
- function scrollBy(el, x, y) {
419
- el.scrollLeft += x;
420
- el.scrollTop += y;
421
- }
422
- function clone(el) {
423
- var Polymer = window.Polymer;
424
- var $ = window.jQuery || window.Zepto;
425
- if (Polymer && Polymer.dom) {
426
- return Polymer.dom(el).cloneNode(true);
427
- } else if ($) {
428
- return $(el).clone(true)[0];
429
- } else {
430
- return el.cloneNode(true);
431
- }
432
- }
433
- function setRect(el, rect) {
434
- css(el, "position", "absolute");
435
- css(el, "top", rect.top);
436
- css(el, "left", rect.left);
437
- css(el, "width", rect.width);
438
- css(el, "height", rect.height);
439
- }
440
- function unsetRect(el) {
441
- css(el, "position", "");
442
- css(el, "top", "");
443
- css(el, "left", "");
444
- css(el, "width", "");
445
- css(el, "height", "");
446
- }
447
- function getChildContainingRectFromElement(container, options, ghostEl2) {
448
- var rect = {};
449
- Array.from(container.children).forEach(function(child) {
450
- var _rect$left, _rect$top, _rect$right, _rect$bottom;
451
- if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl2) return;
452
- var childRect = getRect(child);
453
- rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
454
- rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
455
- rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
456
- rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
457
- });
458
- rect.width = rect.right - rect.left;
459
- rect.height = rect.bottom - rect.top;
460
- rect.x = rect.left;
461
- rect.y = rect.top;
462
- return rect;
463
- }
464
- var expando = "Sortable" + (/* @__PURE__ */ new Date()).getTime();
465
- function AnimationStateManager() {
466
- var animationStates = [], animationCallbackId;
467
- return {
468
- captureAnimationState: function captureAnimationState() {
469
- animationStates = [];
470
- if (!this.options.animation) return;
471
- var children = [].slice.call(this.el.children);
472
- children.forEach(function(child) {
473
- if (css(child, "display") === "none" || child === Sortable.ghost) return;
474
- animationStates.push({
475
- target: child,
476
- rect: getRect(child)
477
- });
478
- var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect);
479
- if (child.thisAnimationDuration) {
480
- var childMatrix = matrix(child, true);
481
- if (childMatrix) {
482
- fromRect.top -= childMatrix.f;
483
- fromRect.left -= childMatrix.e;
484
- }
485
- }
486
- child.fromRect = fromRect;
487
- });
488
- },
489
- addAnimationState: function addAnimationState(state) {
490
- animationStates.push(state);
491
- },
492
- removeAnimationState: function removeAnimationState(target) {
493
- animationStates.splice(indexOfObject(animationStates, {
494
- target
495
- }), 1);
496
- },
497
- animateAll: function animateAll(callback) {
498
- var _this = this;
499
- if (!this.options.animation) {
500
- clearTimeout(animationCallbackId);
501
- if (typeof callback === "function") callback();
502
- return;
503
- }
504
- var animating = false, animationTime = 0;
505
- animationStates.forEach(function(state) {
506
- var time = 0, target = state.target, fromRect = target.fromRect, toRect = getRect(target), prevFromRect = target.prevFromRect, prevToRect = target.prevToRect, animatingRect = state.rect, targetMatrix = matrix(target, true);
507
- if (targetMatrix) {
508
- toRect.top -= targetMatrix.f;
509
- toRect.left -= targetMatrix.e;
510
- }
511
- target.toRect = toRect;
512
- if (target.thisAnimationDuration) {
513
- if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) && // Make sure animatingRect is on line between toRect & fromRect
514
- (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
515
- time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
516
- }
517
- }
518
- if (!isRectEqual(toRect, fromRect)) {
519
- target.prevFromRect = fromRect;
520
- target.prevToRect = toRect;
521
- if (!time) {
522
- time = _this.options.animation;
523
- }
524
- _this.animate(target, animatingRect, toRect, time);
525
- }
526
- if (time) {
527
- animating = true;
528
- animationTime = Math.max(animationTime, time);
529
- clearTimeout(target.animationResetTimer);
530
- target.animationResetTimer = setTimeout(function() {
531
- target.animationTime = 0;
532
- target.prevFromRect = null;
533
- target.fromRect = null;
534
- target.prevToRect = null;
535
- target.thisAnimationDuration = null;
536
- }, time);
537
- target.thisAnimationDuration = time;
538
- }
539
- });
540
- clearTimeout(animationCallbackId);
541
- if (!animating) {
542
- if (typeof callback === "function") callback();
543
- } else {
544
- animationCallbackId = setTimeout(function() {
545
- if (typeof callback === "function") callback();
546
- }, animationTime);
547
- }
548
- animationStates = [];
549
- },
550
- animate: function animate(target, currentRect, toRect, duration) {
551
- if (duration) {
552
- css(target, "transition", "");
553
- css(target, "transform", "");
554
- var elMatrix = matrix(this.el), scaleX = elMatrix && elMatrix.a, scaleY = elMatrix && elMatrix.d, translateX = (currentRect.left - toRect.left) / (scaleX || 1), translateY = (currentRect.top - toRect.top) / (scaleY || 1);
555
- target.animatingX = !!translateX;
556
- target.animatingY = !!translateY;
557
- css(target, "transform", "translate3d(" + translateX + "px," + translateY + "px,0)");
558
- this.forRepaintDummy = repaint(target);
559
- css(target, "transition", "transform " + duration + "ms" + (this.options.easing ? " " + this.options.easing : ""));
560
- css(target, "transform", "translate3d(0,0,0)");
561
- typeof target.animated === "number" && clearTimeout(target.animated);
562
- target.animated = setTimeout(function() {
563
- css(target, "transition", "");
564
- css(target, "transform", "");
565
- target.animated = false;
566
- target.animatingX = false;
567
- target.animatingY = false;
568
- }, duration);
569
- }
570
- }
571
- };
572
- }
573
- function repaint(target) {
574
- return target.offsetWidth;
575
- }
576
- function calculateRealTime(animatingRect, fromRect, toRect, options) {
577
- return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation;
578
- }
579
- var plugins = [];
580
- var defaults = {
581
- initializeByDefault: true
582
- };
583
- var PluginManager = {
584
- mount: function mount(plugin) {
585
- for (var option2 in defaults) {
586
- if (defaults.hasOwnProperty(option2) && !(option2 in plugin)) {
587
- plugin[option2] = defaults[option2];
588
- }
589
- }
590
- plugins.forEach(function(p) {
591
- if (p.pluginName === plugin.pluginName) {
592
- throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
593
- }
594
- });
595
- plugins.push(plugin);
596
- },
597
- pluginEvent: function pluginEvent(eventName, sortable, evt) {
598
- var _this = this;
599
- this.eventCanceled = false;
600
- evt.cancel = function() {
601
- _this.eventCanceled = true;
602
- };
603
- var eventNameGlobal = eventName + "Global";
604
- plugins.forEach(function(plugin) {
605
- if (!sortable[plugin.pluginName]) return;
606
- if (sortable[plugin.pluginName][eventNameGlobal]) {
607
- sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
608
- sortable
609
- }, evt));
610
- }
611
- if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
612
- sortable[plugin.pluginName][eventName](_objectSpread2({
613
- sortable
614
- }, evt));
615
- }
616
- });
617
- },
618
- initializePlugins: function initializePlugins(sortable, el, defaults2, options) {
619
- plugins.forEach(function(plugin) {
620
- var pluginName = plugin.pluginName;
621
- if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
622
- var initialized = new plugin(sortable, el, sortable.options);
623
- initialized.sortable = sortable;
624
- initialized.options = sortable.options;
625
- sortable[pluginName] = initialized;
626
- _extends(defaults2, initialized.defaults);
627
- });
628
- for (var option2 in sortable.options) {
629
- if (!sortable.options.hasOwnProperty(option2)) continue;
630
- var modified = this.modifyOption(sortable, option2, sortable.options[option2]);
631
- if (typeof modified !== "undefined") {
632
- sortable.options[option2] = modified;
633
- }
634
- }
635
- },
636
- getEventProperties: function getEventProperties(name, sortable) {
637
- var eventProperties = {};
638
- plugins.forEach(function(plugin) {
639
- if (typeof plugin.eventProperties !== "function") return;
640
- _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
641
- });
642
- return eventProperties;
643
- },
644
- modifyOption: function modifyOption(sortable, name, value) {
645
- var modifiedValue;
646
- plugins.forEach(function(plugin) {
647
- if (!sortable[plugin.pluginName]) return;
648
- if (plugin.optionListeners && typeof plugin.optionListeners[name] === "function") {
649
- modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
650
- }
651
- });
652
- return modifiedValue;
653
- }
654
- };
655
- function dispatchEvent(_ref) {
656
- var sortable = _ref.sortable, rootEl2 = _ref.rootEl, name = _ref.name, targetEl = _ref.targetEl, cloneEl2 = _ref.cloneEl, toEl = _ref.toEl, fromEl = _ref.fromEl, oldIndex2 = _ref.oldIndex, newIndex2 = _ref.newIndex, oldDraggableIndex2 = _ref.oldDraggableIndex, newDraggableIndex2 = _ref.newDraggableIndex, originalEvent = _ref.originalEvent, putSortable2 = _ref.putSortable, extraEventProperties = _ref.extraEventProperties;
657
- sortable = sortable || rootEl2 && rootEl2[expando];
658
- if (!sortable) return;
659
- var evt, options = sortable.options, onName = "on" + name.charAt(0).toUpperCase() + name.substr(1);
660
- if (window.CustomEvent && !IE11OrLess && !Edge) {
661
- evt = new CustomEvent(name, {
662
- bubbles: true,
663
- cancelable: true
664
- });
665
- } else {
666
- evt = document.createEvent("Event");
667
- evt.initEvent(name, true, true);
668
- }
669
- evt.to = toEl || rootEl2;
670
- evt.from = fromEl || rootEl2;
671
- evt.item = targetEl || rootEl2;
672
- evt.clone = cloneEl2;
673
- evt.oldIndex = oldIndex2;
674
- evt.newIndex = newIndex2;
675
- evt.oldDraggableIndex = oldDraggableIndex2;
676
- evt.newDraggableIndex = newDraggableIndex2;
677
- evt.originalEvent = originalEvent;
678
- evt.pullMode = putSortable2 ? putSortable2.lastPutMode : void 0;
679
- var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
680
- for (var option2 in allEventProperties) {
681
- evt[option2] = allEventProperties[option2];
682
- }
683
- if (rootEl2) {
684
- rootEl2.dispatchEvent(evt);
685
- }
686
- if (options[onName]) {
687
- options[onName].call(sortable, evt);
688
- }
689
- }
690
- var _excluded = ["evt"];
691
- var pluginEvent2 = function pluginEvent3(eventName, sortable) {
692
- var _ref = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, originalEvent = _ref.evt, data = _objectWithoutProperties(_ref, _excluded);
693
- PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
694
- dragEl,
695
- parentEl,
696
- ghostEl,
697
- rootEl,
698
- nextEl,
699
- lastDownEl,
700
- cloneEl,
701
- cloneHidden,
702
- dragStarted: moved,
703
- putSortable,
704
- activeSortable: Sortable.active,
705
- originalEvent,
706
- oldIndex,
707
- oldDraggableIndex,
708
- newIndex,
709
- newDraggableIndex,
710
- hideGhostForTarget: _hideGhostForTarget,
711
- unhideGhostForTarget: _unhideGhostForTarget,
712
- cloneNowHidden: function cloneNowHidden() {
713
- cloneHidden = true;
714
- },
715
- cloneNowShown: function cloneNowShown() {
716
- cloneHidden = false;
717
- },
718
- dispatchSortableEvent: function dispatchSortableEvent(name) {
719
- _dispatchEvent({
720
- sortable,
721
- name,
722
- originalEvent
723
- });
724
- }
725
- }, data));
726
- };
727
- function _dispatchEvent(info) {
728
- dispatchEvent(_objectSpread2({
729
- putSortable,
730
- cloneEl,
731
- targetEl: dragEl,
732
- rootEl,
733
- oldIndex,
734
- oldDraggableIndex,
735
- newIndex,
736
- newDraggableIndex
737
- }, info));
738
- }
739
- var dragEl, parentEl, ghostEl, rootEl, nextEl, lastDownEl, cloneEl, cloneHidden, oldIndex, newIndex, oldDraggableIndex, newDraggableIndex, activeGroup, putSortable, awaitingDragStarted = false, ignoreNextClick = false, sortables = [], tapEvt, touchEvt, lastDx, lastDy, tapDistanceLeft, tapDistanceTop, moved, lastTarget, lastDirection, pastFirstInvertThresh = false, isCircumstantialInvert = false, targetMoveDistance, ghostRelativeParent, ghostRelativeParentInitialScroll = [], _silent = false, savedInputChecked = [];
740
- var documentExists = typeof document !== "undefined", PositionGhostAbsolutely = IOS, CSSFloatProperty = Edge || IE11OrLess ? "cssFloat" : "float", supportDraggable = documentExists && !ChromeForAndroid && !IOS && "draggable" in document.createElement("div"), supportCssPointerEvents = (function() {
741
- if (!documentExists) return;
742
- if (IE11OrLess) {
743
- return false;
744
- }
745
- var el = document.createElement("x");
746
- el.style.cssText = "pointer-events:auto";
747
- return el.style.pointerEvents === "auto";
748
- })(), _detectDirection = function _detectDirection2(el, options) {
749
- var elCSS = css(el), elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth), child1 = getChild(el, 0, options), child2 = getChild(el, 1, options), firstChildCSS = child1 && css(child1), secondChildCSS = child2 && css(child2), firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width, secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
750
- if (elCSS.display === "flex") {
751
- return elCSS.flexDirection === "column" || elCSS.flexDirection === "column-reverse" ? "vertical" : "horizontal";
752
- }
753
- if (elCSS.display === "grid") {
754
- return elCSS.gridTemplateColumns.split(" ").length <= 1 ? "vertical" : "horizontal";
755
- }
756
- if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== "none") {
757
- var touchingSideChild2 = firstChildCSS["float"] === "left" ? "left" : "right";
758
- return child2 && (secondChildCSS.clear === "both" || secondChildCSS.clear === touchingSideChild2) ? "vertical" : "horizontal";
759
- }
760
- return child1 && (firstChildCSS.display === "block" || firstChildCSS.display === "flex" || firstChildCSS.display === "table" || firstChildCSS.display === "grid" || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === "none" || child2 && elCSS[CSSFloatProperty] === "none" && firstChildWidth + secondChildWidth > elWidth) ? "vertical" : "horizontal";
761
- }, _dragElInRowColumn = function _dragElInRowColumn2(dragRect, targetRect, vertical) {
762
- var dragElS1Opp = vertical ? dragRect.left : dragRect.top, dragElS2Opp = vertical ? dragRect.right : dragRect.bottom, dragElOppLength = vertical ? dragRect.width : dragRect.height, targetS1Opp = vertical ? targetRect.left : targetRect.top, targetS2Opp = vertical ? targetRect.right : targetRect.bottom, targetOppLength = vertical ? targetRect.width : targetRect.height;
763
- return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
764
- }, _detectNearestEmptySortable = function _detectNearestEmptySortable2(x, y) {
765
- var ret;
766
- sortables.some(function(sortable) {
767
- var threshold = sortable[expando].options.emptyInsertThreshold;
768
- if (!threshold || lastChild(sortable)) return;
769
- var rect = getRect(sortable), insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold, insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
770
- if (insideHorizontally && insideVertically) {
771
- return ret = sortable;
772
- }
773
- });
774
- return ret;
775
- }, _prepareGroup = function _prepareGroup2(options) {
776
- function toFn(value, pull) {
777
- return function(to, from, dragEl2, evt) {
778
- var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
779
- if (value == null && (pull || sameGroup)) {
780
- return true;
781
- } else if (value == null || value === false) {
782
- return false;
783
- } else if (pull && value === "clone") {
784
- return value;
785
- } else if (typeof value === "function") {
786
- return toFn(value(to, from, dragEl2, evt), pull)(to, from, dragEl2, evt);
787
- } else {
788
- var otherGroup = (pull ? to : from).options.group.name;
789
- return value === true || typeof value === "string" && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
790
- }
791
- };
792
- }
793
- var group = {};
794
- var originalGroup = options.group;
795
- if (!originalGroup || _typeof(originalGroup) != "object") {
796
- originalGroup = {
797
- name: originalGroup
798
- };
799
- }
800
- group.name = originalGroup.name;
801
- group.checkPull = toFn(originalGroup.pull, true);
802
- group.checkPut = toFn(originalGroup.put);
803
- group.revertClone = originalGroup.revertClone;
804
- options.group = group;
805
- }, _hideGhostForTarget = function _hideGhostForTarget2() {
806
- if (!supportCssPointerEvents && ghostEl) {
807
- css(ghostEl, "display", "none");
808
- }
809
- }, _unhideGhostForTarget = function _unhideGhostForTarget2() {
810
- if (!supportCssPointerEvents && ghostEl) {
811
- css(ghostEl, "display", "");
812
- }
813
- };
814
- if (documentExists && !ChromeForAndroid) {
815
- document.addEventListener("click", function(evt) {
816
- if (ignoreNextClick) {
817
- evt.preventDefault();
818
- evt.stopPropagation && evt.stopPropagation();
819
- evt.stopImmediatePropagation && evt.stopImmediatePropagation();
820
- ignoreNextClick = false;
821
- return false;
822
- }
823
- }, true);
824
- }
825
- var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent2(evt) {
826
- if (dragEl) {
827
- evt = evt.touches ? evt.touches[0] : evt;
828
- var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
829
- if (nearest) {
830
- var event = {};
831
- for (var i in evt) {
832
- if (evt.hasOwnProperty(i)) {
833
- event[i] = evt[i];
834
- }
835
- }
836
- event.target = event.rootEl = nearest;
837
- event.preventDefault = void 0;
838
- event.stopPropagation = void 0;
839
- nearest[expando]._onDragOver(event);
840
- }
841
- }
842
- };
843
- var _checkOutsideTargetEl = function _checkOutsideTargetEl2(evt) {
844
- if (dragEl) {
845
- dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
846
- }
847
- };
848
- function Sortable(el, options) {
849
- if (!(el && el.nodeType && el.nodeType === 1)) {
850
- throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
851
- }
852
- this.el = el;
853
- this.options = options = _extends({}, options);
854
- el[expando] = this;
855
- var defaults2 = {
856
- group: null,
857
- sort: true,
858
- disabled: false,
859
- store: null,
860
- handle: null,
861
- draggable: /^[uo]l$/i.test(el.nodeName) ? ">li" : ">*",
862
- swapThreshold: 1,
863
- // percentage; 0 <= x <= 1
864
- invertSwap: false,
865
- // invert always
866
- invertedSwapThreshold: null,
867
- // will be set to same as swapThreshold if default
868
- removeCloneOnHide: true,
869
- direction: function direction() {
870
- return _detectDirection(el, this.options);
871
- },
872
- ghostClass: "sortable-ghost",
873
- chosenClass: "sortable-chosen",
874
- dragClass: "sortable-drag",
875
- ignore: "a, img",
876
- filter: null,
877
- preventOnFilter: true,
878
- animation: 0,
879
- easing: null,
880
- setData: function setData(dataTransfer, dragEl2) {
881
- dataTransfer.setData("Text", dragEl2.textContent);
882
- },
883
- dropBubble: false,
884
- dragoverBubble: false,
885
- dataIdAttr: "data-id",
886
- delay: 0,
887
- delayOnTouchOnly: false,
888
- touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
889
- forceFallback: false,
890
- fallbackClass: "sortable-fallback",
891
- fallbackOnBody: false,
892
- fallbackTolerance: 0,
893
- fallbackOffset: {
894
- x: 0,
895
- y: 0
896
- },
897
- // Disabled on Safari: #1571; Enabled on Safari IOS: #2244
898
- supportPointer: Sortable.supportPointer !== false && "PointerEvent" in window && (!Safari || IOS),
899
- emptyInsertThreshold: 5
900
- };
901
- PluginManager.initializePlugins(this, el, defaults2);
902
- for (var name in defaults2) {
903
- !(name in options) && (options[name] = defaults2[name]);
904
- }
905
- _prepareGroup(options);
906
- for (var fn in this) {
907
- if (fn.charAt(0) === "_" && typeof this[fn] === "function") {
908
- this[fn] = this[fn].bind(this);
909
- }
910
- }
911
- this.nativeDraggable = options.forceFallback ? false : supportDraggable;
912
- if (this.nativeDraggable) {
913
- this.options.touchStartThreshold = 1;
914
- }
915
- if (options.supportPointer) {
916
- on(el, "pointerdown", this._onTapStart);
917
- } else {
918
- on(el, "mousedown", this._onTapStart);
919
- on(el, "touchstart", this._onTapStart);
920
- }
921
- if (this.nativeDraggable) {
922
- on(el, "dragover", this);
923
- on(el, "dragenter", this);
924
- }
925
- sortables.push(this.el);
926
- options.store && options.store.get && this.sort(options.store.get(this) || []);
927
- _extends(this, AnimationStateManager());
928
- }
929
- Sortable.prototype = /** @lends Sortable.prototype */
930
- {
931
- constructor: Sortable,
932
- _isOutsideThisEl: function _isOutsideThisEl(target) {
933
- if (!this.el.contains(target) && target !== this.el) {
934
- lastTarget = null;
935
- }
936
- },
937
- _getDirection: function _getDirection(evt, target) {
938
- return typeof this.options.direction === "function" ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
939
- },
940
- _onTapStart: function _onTapStart(evt) {
941
- if (!evt.cancelable) return;
942
- var _this = this, el = this.el, options = this.options, preventOnFilter = options.preventOnFilter, type = evt.type, touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === "touch" && evt, target = (touch || evt).target, originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target, filter = options.filter;
943
- _saveInputCheckedState(el);
944
- if (dragEl) {
945
- return;
946
- }
947
- if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
948
- return;
949
- }
950
- if (originalTarget.isContentEditable) {
951
- return;
952
- }
953
- if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === "SELECT") {
954
- return;
955
- }
956
- target = closest(target, options.draggable, el, false);
957
- if (target && target.animated) {
958
- return;
959
- }
960
- if (lastDownEl === target) {
961
- return;
962
- }
963
- oldIndex = index(target);
964
- oldDraggableIndex = index(target, options.draggable);
965
- if (typeof filter === "function") {
966
- if (filter.call(this, evt, target, this)) {
967
- _dispatchEvent({
968
- sortable: _this,
969
- rootEl: originalTarget,
970
- name: "filter",
971
- targetEl: target,
972
- toEl: el,
973
- fromEl: el
974
- });
975
- pluginEvent2("filter", _this, {
976
- evt
977
- });
978
- preventOnFilter && evt.preventDefault();
979
- return;
980
- }
981
- } else if (filter) {
982
- filter = filter.split(",").some(function(criteria) {
983
- criteria = closest(originalTarget, criteria.trim(), el, false);
984
- if (criteria) {
985
- _dispatchEvent({
986
- sortable: _this,
987
- rootEl: criteria,
988
- name: "filter",
989
- targetEl: target,
990
- fromEl: el,
991
- toEl: el
992
- });
993
- pluginEvent2("filter", _this, {
994
- evt
995
- });
996
- return true;
997
- }
998
- });
999
- if (filter) {
1000
- preventOnFilter && evt.preventDefault();
1001
- return;
1002
- }
1003
- }
1004
- if (options.handle && !closest(originalTarget, options.handle, el, false)) {
1005
- return;
1006
- }
1007
- this._prepareDragStart(evt, touch, target);
1008
- },
1009
- _prepareDragStart: function _prepareDragStart(evt, touch, target) {
1010
- var _this = this, el = _this.el, options = _this.options, ownerDocument = el.ownerDocument, dragStartFn;
1011
- if (target && !dragEl && target.parentNode === el) {
1012
- var dragRect = getRect(target);
1013
- rootEl = el;
1014
- dragEl = target;
1015
- parentEl = dragEl.parentNode;
1016
- nextEl = dragEl.nextSibling;
1017
- lastDownEl = target;
1018
- activeGroup = options.group;
1019
- Sortable.dragged = dragEl;
1020
- tapEvt = {
1021
- target: dragEl,
1022
- clientX: (touch || evt).clientX,
1023
- clientY: (touch || evt).clientY
1024
- };
1025
- tapDistanceLeft = tapEvt.clientX - dragRect.left;
1026
- tapDistanceTop = tapEvt.clientY - dragRect.top;
1027
- this._lastX = (touch || evt).clientX;
1028
- this._lastY = (touch || evt).clientY;
1029
- dragEl.style["will-change"] = "all";
1030
- dragStartFn = function dragStartFn2() {
1031
- pluginEvent2("delayEnded", _this, {
1032
- evt
1033
- });
1034
- if (Sortable.eventCanceled) {
1035
- _this._onDrop();
1036
- return;
1037
- }
1038
- _this._disableDelayedDragEvents();
1039
- if (!FireFox && _this.nativeDraggable) {
1040
- dragEl.draggable = true;
1041
- }
1042
- _this._triggerDragStart(evt, touch);
1043
- _dispatchEvent({
1044
- sortable: _this,
1045
- name: "choose",
1046
- originalEvent: evt
1047
- });
1048
- toggleClass(dragEl, options.chosenClass, true);
1049
- };
1050
- options.ignore.split(",").forEach(function(criteria) {
1051
- find(dragEl, criteria.trim(), _disableDraggable);
1052
- });
1053
- on(ownerDocument, "dragover", nearestEmptyInsertDetectEvent);
1054
- on(ownerDocument, "mousemove", nearestEmptyInsertDetectEvent);
1055
- on(ownerDocument, "touchmove", nearestEmptyInsertDetectEvent);
1056
- if (options.supportPointer) {
1057
- on(ownerDocument, "pointerup", _this._onDrop);
1058
- !this.nativeDraggable && on(ownerDocument, "pointercancel", _this._onDrop);
1059
- } else {
1060
- on(ownerDocument, "mouseup", _this._onDrop);
1061
- on(ownerDocument, "touchend", _this._onDrop);
1062
- on(ownerDocument, "touchcancel", _this._onDrop);
1063
- }
1064
- if (FireFox && this.nativeDraggable) {
1065
- this.options.touchStartThreshold = 4;
1066
- dragEl.draggable = true;
1067
- }
1068
- pluginEvent2("delayStart", this, {
1069
- evt
1070
- });
1071
- if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
1072
- if (Sortable.eventCanceled) {
1073
- this._onDrop();
1074
- return;
1075
- }
1076
- if (options.supportPointer) {
1077
- on(ownerDocument, "pointerup", _this._disableDelayedDrag);
1078
- on(ownerDocument, "pointercancel", _this._disableDelayedDrag);
1079
- } else {
1080
- on(ownerDocument, "mouseup", _this._disableDelayedDrag);
1081
- on(ownerDocument, "touchend", _this._disableDelayedDrag);
1082
- on(ownerDocument, "touchcancel", _this._disableDelayedDrag);
1083
- }
1084
- on(ownerDocument, "mousemove", _this._delayedDragTouchMoveHandler);
1085
- on(ownerDocument, "touchmove", _this._delayedDragTouchMoveHandler);
1086
- options.supportPointer && on(ownerDocument, "pointermove", _this._delayedDragTouchMoveHandler);
1087
- _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
1088
- } else {
1089
- dragStartFn();
1090
- }
1091
- }
1092
- },
1093
- _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(e) {
1094
- var touch = e.touches ? e.touches[0] : e;
1095
- if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
1096
- this._disableDelayedDrag();
1097
- }
1098
- },
1099
- _disableDelayedDrag: function _disableDelayedDrag() {
1100
- dragEl && _disableDraggable(dragEl);
1101
- clearTimeout(this._dragStartTimer);
1102
- this._disableDelayedDragEvents();
1103
- },
1104
- _disableDelayedDragEvents: function _disableDelayedDragEvents() {
1105
- var ownerDocument = this.el.ownerDocument;
1106
- off(ownerDocument, "mouseup", this._disableDelayedDrag);
1107
- off(ownerDocument, "touchend", this._disableDelayedDrag);
1108
- off(ownerDocument, "touchcancel", this._disableDelayedDrag);
1109
- off(ownerDocument, "pointerup", this._disableDelayedDrag);
1110
- off(ownerDocument, "pointercancel", this._disableDelayedDrag);
1111
- off(ownerDocument, "mousemove", this._delayedDragTouchMoveHandler);
1112
- off(ownerDocument, "touchmove", this._delayedDragTouchMoveHandler);
1113
- off(ownerDocument, "pointermove", this._delayedDragTouchMoveHandler);
1114
- },
1115
- _triggerDragStart: function _triggerDragStart(evt, touch) {
1116
- touch = touch || evt.pointerType == "touch" && evt;
1117
- if (!this.nativeDraggable || touch) {
1118
- if (this.options.supportPointer) {
1119
- on(document, "pointermove", this._onTouchMove);
1120
- } else if (touch) {
1121
- on(document, "touchmove", this._onTouchMove);
1122
- } else {
1123
- on(document, "mousemove", this._onTouchMove);
1124
- }
1125
- } else {
1126
- on(dragEl, "dragend", this);
1127
- on(rootEl, "dragstart", this._onDragStart);
1128
- }
1129
- try {
1130
- if (document.selection) {
1131
- _nextTick(function() {
1132
- document.selection.empty();
1133
- });
1134
- } else {
1135
- window.getSelection().removeAllRanges();
1136
- }
1137
- } catch (err) {
1138
- }
1139
- },
1140
- _dragStarted: function _dragStarted(fallback, evt) {
1141
- awaitingDragStarted = false;
1142
- if (rootEl && dragEl) {
1143
- pluginEvent2("dragStarted", this, {
1144
- evt
1145
- });
1146
- if (this.nativeDraggable) {
1147
- on(document, "dragover", _checkOutsideTargetEl);
1148
- }
1149
- var options = this.options;
1150
- !fallback && toggleClass(dragEl, options.dragClass, false);
1151
- toggleClass(dragEl, options.ghostClass, true);
1152
- Sortable.active = this;
1153
- fallback && this._appendGhost();
1154
- _dispatchEvent({
1155
- sortable: this,
1156
- name: "start",
1157
- originalEvent: evt
1158
- });
1159
- } else {
1160
- this._nulling();
1161
- }
1162
- },
1163
- _emulateDragOver: function _emulateDragOver() {
1164
- if (touchEvt) {
1165
- this._lastX = touchEvt.clientX;
1166
- this._lastY = touchEvt.clientY;
1167
- _hideGhostForTarget();
1168
- var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1169
- var parent = target;
1170
- while (target && target.shadowRoot) {
1171
- target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1172
- if (target === parent) break;
1173
- parent = target;
1174
- }
1175
- dragEl.parentNode[expando]._isOutsideThisEl(target);
1176
- if (parent) {
1177
- do {
1178
- if (parent[expando]) {
1179
- var inserted = void 0;
1180
- inserted = parent[expando]._onDragOver({
1181
- clientX: touchEvt.clientX,
1182
- clientY: touchEvt.clientY,
1183
- target,
1184
- rootEl: parent
1185
- });
1186
- if (inserted && !this.options.dragoverBubble) {
1187
- break;
1188
- }
1189
- }
1190
- target = parent;
1191
- } while (parent = getParentOrHost(parent));
1192
- }
1193
- _unhideGhostForTarget();
1194
- }
1195
- },
1196
- _onTouchMove: function _onTouchMove(evt) {
1197
- if (tapEvt) {
1198
- var options = this.options, fallbackTolerance = options.fallbackTolerance, fallbackOffset = options.fallbackOffset, touch = evt.touches ? evt.touches[0] : evt, ghostMatrix = ghostEl && matrix(ghostEl, true), scaleX = ghostEl && ghostMatrix && ghostMatrix.a, scaleY = ghostEl && ghostMatrix && ghostMatrix.d, relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent), dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1), dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
1199
- if (!Sortable.active && !awaitingDragStarted) {
1200
- if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
1201
- return;
1202
- }
1203
- this._onDragStart(evt, true);
1204
- }
1205
- if (ghostEl) {
1206
- if (ghostMatrix) {
1207
- ghostMatrix.e += dx - (lastDx || 0);
1208
- ghostMatrix.f += dy - (lastDy || 0);
1209
- } else {
1210
- ghostMatrix = {
1211
- a: 1,
1212
- b: 0,
1213
- c: 0,
1214
- d: 1,
1215
- e: dx,
1216
- f: dy
1217
- };
1218
- }
1219
- var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
1220
- css(ghostEl, "webkitTransform", cssMatrix);
1221
- css(ghostEl, "mozTransform", cssMatrix);
1222
- css(ghostEl, "msTransform", cssMatrix);
1223
- css(ghostEl, "transform", cssMatrix);
1224
- lastDx = dx;
1225
- lastDy = dy;
1226
- touchEvt = touch;
1227
- }
1228
- evt.cancelable && evt.preventDefault();
1229
- }
1230
- },
1231
- _appendGhost: function _appendGhost() {
1232
- if (!ghostEl) {
1233
- var container = this.options.fallbackOnBody ? document.body : rootEl, rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container), options = this.options;
1234
- if (PositionGhostAbsolutely) {
1235
- ghostRelativeParent = container;
1236
- while (css(ghostRelativeParent, "position") === "static" && css(ghostRelativeParent, "transform") === "none" && ghostRelativeParent !== document) {
1237
- ghostRelativeParent = ghostRelativeParent.parentNode;
1238
- }
1239
- if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
1240
- if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
1241
- rect.top += ghostRelativeParent.scrollTop;
1242
- rect.left += ghostRelativeParent.scrollLeft;
1243
- } else {
1244
- ghostRelativeParent = getWindowScrollingElement();
1245
- }
1246
- ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
1247
- }
1248
- ghostEl = dragEl.cloneNode(true);
1249
- toggleClass(ghostEl, options.ghostClass, false);
1250
- toggleClass(ghostEl, options.fallbackClass, true);
1251
- toggleClass(ghostEl, options.dragClass, true);
1252
- css(ghostEl, "transition", "");
1253
- css(ghostEl, "transform", "");
1254
- css(ghostEl, "box-sizing", "border-box");
1255
- css(ghostEl, "margin", 0);
1256
- css(ghostEl, "top", rect.top);
1257
- css(ghostEl, "left", rect.left);
1258
- css(ghostEl, "width", rect.width);
1259
- css(ghostEl, "height", rect.height);
1260
- css(ghostEl, "opacity", "0.8");
1261
- css(ghostEl, "position", PositionGhostAbsolutely ? "absolute" : "fixed");
1262
- css(ghostEl, "zIndex", "100000");
1263
- css(ghostEl, "pointerEvents", "none");
1264
- Sortable.ghost = ghostEl;
1265
- container.appendChild(ghostEl);
1266
- css(ghostEl, "transform-origin", tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + "% " + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + "%");
1267
- }
1268
- },
1269
- _onDragStart: function _onDragStart(evt, fallback) {
1270
- var _this = this;
1271
- var dataTransfer = evt.dataTransfer;
1272
- var options = _this.options;
1273
- pluginEvent2("dragStart", this, {
1274
- evt
1275
- });
1276
- if (Sortable.eventCanceled) {
1277
- this._onDrop();
1278
- return;
1279
- }
1280
- pluginEvent2("setupClone", this);
1281
- if (!Sortable.eventCanceled) {
1282
- cloneEl = clone(dragEl);
1283
- cloneEl.removeAttribute("id");
1284
- cloneEl.draggable = false;
1285
- cloneEl.style["will-change"] = "";
1286
- this._hideClone();
1287
- toggleClass(cloneEl, this.options.chosenClass, false);
1288
- Sortable.clone = cloneEl;
1289
- }
1290
- _this.cloneId = _nextTick(function() {
1291
- pluginEvent2("clone", _this);
1292
- if (Sortable.eventCanceled) return;
1293
- if (!_this.options.removeCloneOnHide) {
1294
- rootEl.insertBefore(cloneEl, dragEl);
1295
- }
1296
- _this._hideClone();
1297
- _dispatchEvent({
1298
- sortable: _this,
1299
- name: "clone"
1300
- });
1301
- });
1302
- !fallback && toggleClass(dragEl, options.dragClass, true);
1303
- if (fallback) {
1304
- ignoreNextClick = true;
1305
- _this._loopId = setInterval(_this._emulateDragOver, 50);
1306
- } else {
1307
- off(document, "mouseup", _this._onDrop);
1308
- off(document, "touchend", _this._onDrop);
1309
- off(document, "touchcancel", _this._onDrop);
1310
- if (dataTransfer) {
1311
- dataTransfer.effectAllowed = "move";
1312
- options.setData && options.setData.call(_this, dataTransfer, dragEl);
1313
- }
1314
- on(document, "drop", _this);
1315
- css(dragEl, "transform", "translateZ(0)");
1316
- }
1317
- awaitingDragStarted = true;
1318
- _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
1319
- on(document, "selectstart", _this);
1320
- moved = true;
1321
- window.getSelection().removeAllRanges();
1322
- if (Safari) {
1323
- css(document.body, "user-select", "none");
1324
- }
1325
- },
1326
- // Returns true - if no further action is needed (either inserted or another condition)
1327
- _onDragOver: function _onDragOver(evt) {
1328
- var el = this.el, target = evt.target, dragRect, targetRect, revert, options = this.options, group = options.group, activeSortable = Sortable.active, isOwner = activeGroup === group, canSort = options.sort, fromSortable = putSortable || activeSortable, vertical, _this = this, completedFired = false;
1329
- if (_silent) return;
1330
- function dragOverEvent(name, extra) {
1331
- pluginEvent2(name, _this, _objectSpread2({
1332
- evt,
1333
- isOwner,
1334
- axis: vertical ? "vertical" : "horizontal",
1335
- revert,
1336
- dragRect,
1337
- targetRect,
1338
- canSort,
1339
- fromSortable,
1340
- target,
1341
- completed,
1342
- onMove: function onMove(target2, after2) {
1343
- return _onMove(rootEl, el, dragEl, dragRect, target2, getRect(target2), evt, after2);
1344
- },
1345
- changed
1346
- }, extra));
1347
- }
1348
- function capture() {
1349
- dragOverEvent("dragOverAnimationCapture");
1350
- _this.captureAnimationState();
1351
- if (_this !== fromSortable) {
1352
- fromSortable.captureAnimationState();
1353
- }
1354
- }
1355
- function completed(insertion) {
1356
- dragOverEvent("dragOverCompleted", {
1357
- insertion
1358
- });
1359
- if (insertion) {
1360
- if (isOwner) {
1361
- activeSortable._hideClone();
1362
- } else {
1363
- activeSortable._showClone(_this);
1364
- }
1365
- if (_this !== fromSortable) {
1366
- toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
1367
- toggleClass(dragEl, options.ghostClass, true);
1368
- }
1369
- if (putSortable !== _this && _this !== Sortable.active) {
1370
- putSortable = _this;
1371
- } else if (_this === Sortable.active && putSortable) {
1372
- putSortable = null;
1373
- }
1374
- if (fromSortable === _this) {
1375
- _this._ignoreWhileAnimating = target;
1376
- }
1377
- _this.animateAll(function() {
1378
- dragOverEvent("dragOverAnimationComplete");
1379
- _this._ignoreWhileAnimating = null;
1380
- });
1381
- if (_this !== fromSortable) {
1382
- fromSortable.animateAll();
1383
- fromSortable._ignoreWhileAnimating = null;
1384
- }
1385
- }
1386
- if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
1387
- lastTarget = null;
1388
- }
1389
- if (!options.dragoverBubble && !evt.rootEl && target !== document) {
1390
- dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1391
- !insertion && nearestEmptyInsertDetectEvent(evt);
1392
- }
1393
- !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
1394
- return completedFired = true;
1395
- }
1396
- function changed() {
1397
- newIndex = index(dragEl);
1398
- newDraggableIndex = index(dragEl, options.draggable);
1399
- _dispatchEvent({
1400
- sortable: _this,
1401
- name: "change",
1402
- toEl: el,
1403
- newIndex,
1404
- newDraggableIndex,
1405
- originalEvent: evt
1406
- });
1407
- }
1408
- if (evt.preventDefault !== void 0) {
1409
- evt.cancelable && evt.preventDefault();
1410
- }
1411
- target = closest(target, options.draggable, el, true);
1412
- dragOverEvent("dragOver");
1413
- if (Sortable.eventCanceled) return completedFired;
1414
- if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
1415
- return completed(false);
1416
- }
1417
- ignoreNextClick = false;
1418
- if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
1419
- vertical = this._getDirection(evt, target) === "vertical";
1420
- dragRect = getRect(dragEl);
1421
- dragOverEvent("dragOverValid");
1422
- if (Sortable.eventCanceled) return completedFired;
1423
- if (revert) {
1424
- parentEl = rootEl;
1425
- capture();
1426
- this._hideClone();
1427
- dragOverEvent("revert");
1428
- if (!Sortable.eventCanceled) {
1429
- if (nextEl) {
1430
- rootEl.insertBefore(dragEl, nextEl);
1431
- } else {
1432
- rootEl.appendChild(dragEl);
1433
- }
1434
- }
1435
- return completed(true);
1436
- }
1437
- var elLastChild = lastChild(el, options.draggable);
1438
- if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
1439
- if (elLastChild === dragEl) {
1440
- return completed(false);
1441
- }
1442
- if (elLastChild && el === evt.target) {
1443
- target = elLastChild;
1444
- }
1445
- if (target) {
1446
- targetRect = getRect(target);
1447
- }
1448
- if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
1449
- capture();
1450
- if (elLastChild && elLastChild.nextSibling) {
1451
- el.insertBefore(dragEl, elLastChild.nextSibling);
1452
- } else {
1453
- el.appendChild(dragEl);
1454
- }
1455
- parentEl = el;
1456
- changed();
1457
- return completed(true);
1458
- }
1459
- } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
1460
- var firstChild = getChild(el, 0, options, true);
1461
- if (firstChild === dragEl) {
1462
- return completed(false);
1463
- }
1464
- target = firstChild;
1465
- targetRect = getRect(target);
1466
- if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
1467
- capture();
1468
- el.insertBefore(dragEl, firstChild);
1469
- parentEl = el;
1470
- changed();
1471
- return completed(true);
1472
- }
1473
- } else if (target.parentNode === el) {
1474
- targetRect = getRect(target);
1475
- var direction = 0, targetBeforeFirstSwap, differentLevel = dragEl.parentNode !== el, differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical), side1 = vertical ? "top" : "left", scrolledPastTop = isScrolledPast(target, "top", "top") || isScrolledPast(dragEl, "top", "top"), scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
1476
- if (lastTarget !== target) {
1477
- targetBeforeFirstSwap = targetRect[side1];
1478
- pastFirstInvertThresh = false;
1479
- isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
1480
- }
1481
- direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
1482
- var sibling;
1483
- if (direction !== 0) {
1484
- var dragIndex = index(dragEl);
1485
- do {
1486
- dragIndex -= direction;
1487
- sibling = parentEl.children[dragIndex];
1488
- } while (sibling && (css(sibling, "display") === "none" || sibling === ghostEl));
1489
- }
1490
- if (direction === 0 || sibling === target) {
1491
- return completed(false);
1492
- }
1493
- lastTarget = target;
1494
- lastDirection = direction;
1495
- var nextSibling = target.nextElementSibling, after = false;
1496
- after = direction === 1;
1497
- var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
1498
- if (moveVector !== false) {
1499
- if (moveVector === 1 || moveVector === -1) {
1500
- after = moveVector === 1;
1501
- }
1502
- _silent = true;
1503
- setTimeout(_unsilent, 30);
1504
- capture();
1505
- if (after && !nextSibling) {
1506
- el.appendChild(dragEl);
1507
- } else {
1508
- target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
1509
- }
1510
- if (scrolledPastTop) {
1511
- scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
1512
- }
1513
- parentEl = dragEl.parentNode;
1514
- if (targetBeforeFirstSwap !== void 0 && !isCircumstantialInvert) {
1515
- targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
1516
- }
1517
- changed();
1518
- return completed(true);
1519
- }
1520
- }
1521
- if (el.contains(dragEl)) {
1522
- return completed(false);
1523
- }
1524
- }
1525
- return false;
1526
- },
1527
- _ignoreWhileAnimating: null,
1528
- _offMoveEvents: function _offMoveEvents() {
1529
- off(document, "mousemove", this._onTouchMove);
1530
- off(document, "touchmove", this._onTouchMove);
1531
- off(document, "pointermove", this._onTouchMove);
1532
- off(document, "dragover", nearestEmptyInsertDetectEvent);
1533
- off(document, "mousemove", nearestEmptyInsertDetectEvent);
1534
- off(document, "touchmove", nearestEmptyInsertDetectEvent);
1535
- },
1536
- _offUpEvents: function _offUpEvents() {
1537
- var ownerDocument = this.el.ownerDocument;
1538
- off(ownerDocument, "mouseup", this._onDrop);
1539
- off(ownerDocument, "touchend", this._onDrop);
1540
- off(ownerDocument, "pointerup", this._onDrop);
1541
- off(ownerDocument, "pointercancel", this._onDrop);
1542
- off(ownerDocument, "touchcancel", this._onDrop);
1543
- off(document, "selectstart", this);
1544
- },
1545
- _onDrop: function _onDrop(evt) {
1546
- var el = this.el, options = this.options;
1547
- newIndex = index(dragEl);
1548
- newDraggableIndex = index(dragEl, options.draggable);
1549
- pluginEvent2("drop", this, {
1550
- evt
1551
- });
1552
- parentEl = dragEl && dragEl.parentNode;
1553
- newIndex = index(dragEl);
1554
- newDraggableIndex = index(dragEl, options.draggable);
1555
- if (Sortable.eventCanceled) {
1556
- this._nulling();
1557
- return;
1558
- }
1559
- awaitingDragStarted = false;
1560
- isCircumstantialInvert = false;
1561
- pastFirstInvertThresh = false;
1562
- clearInterval(this._loopId);
1563
- clearTimeout(this._dragStartTimer);
1564
- _cancelNextTick(this.cloneId);
1565
- _cancelNextTick(this._dragStartId);
1566
- if (this.nativeDraggable) {
1567
- off(document, "drop", this);
1568
- off(el, "dragstart", this._onDragStart);
1569
- }
1570
- this._offMoveEvents();
1571
- this._offUpEvents();
1572
- if (Safari) {
1573
- css(document.body, "user-select", "");
1574
- }
1575
- css(dragEl, "transform", "");
1576
- if (evt) {
1577
- if (moved) {
1578
- evt.cancelable && evt.preventDefault();
1579
- !options.dropBubble && evt.stopPropagation();
1580
- }
1581
- ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
1582
- if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== "clone") {
1583
- cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
1584
- }
1585
- if (dragEl) {
1586
- if (this.nativeDraggable) {
1587
- off(dragEl, "dragend", this);
1588
- }
1589
- _disableDraggable(dragEl);
1590
- dragEl.style["will-change"] = "";
1591
- if (moved && !awaitingDragStarted) {
1592
- toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
1593
- }
1594
- toggleClass(dragEl, this.options.chosenClass, false);
1595
- _dispatchEvent({
1596
- sortable: this,
1597
- name: "unchoose",
1598
- toEl: parentEl,
1599
- newIndex: null,
1600
- newDraggableIndex: null,
1601
- originalEvent: evt
1602
- });
1603
- if (rootEl !== parentEl) {
1604
- if (newIndex >= 0) {
1605
- _dispatchEvent({
1606
- rootEl: parentEl,
1607
- name: "add",
1608
- toEl: parentEl,
1609
- fromEl: rootEl,
1610
- originalEvent: evt
1611
- });
1612
- _dispatchEvent({
1613
- sortable: this,
1614
- name: "remove",
1615
- toEl: parentEl,
1616
- originalEvent: evt
1617
- });
1618
- _dispatchEvent({
1619
- rootEl: parentEl,
1620
- name: "sort",
1621
- toEl: parentEl,
1622
- fromEl: rootEl,
1623
- originalEvent: evt
1624
- });
1625
- _dispatchEvent({
1626
- sortable: this,
1627
- name: "sort",
1628
- toEl: parentEl,
1629
- originalEvent: evt
1630
- });
1631
- }
1632
- putSortable && putSortable.save();
1633
- } else {
1634
- if (newIndex !== oldIndex) {
1635
- if (newIndex >= 0) {
1636
- _dispatchEvent({
1637
- sortable: this,
1638
- name: "update",
1639
- toEl: parentEl,
1640
- originalEvent: evt
1641
- });
1642
- _dispatchEvent({
1643
- sortable: this,
1644
- name: "sort",
1645
- toEl: parentEl,
1646
- originalEvent: evt
1647
- });
1648
- }
1649
- }
1650
- }
1651
- if (Sortable.active) {
1652
- if (newIndex == null || newIndex === -1) {
1653
- newIndex = oldIndex;
1654
- newDraggableIndex = oldDraggableIndex;
1655
- }
1656
- _dispatchEvent({
1657
- sortable: this,
1658
- name: "end",
1659
- toEl: parentEl,
1660
- originalEvent: evt
1661
- });
1662
- this.save();
1663
- }
1664
- }
1665
- }
1666
- this._nulling();
1667
- },
1668
- _nulling: function _nulling() {
1669
- pluginEvent2("nulling", this);
1670
- rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
1671
- savedInputChecked.forEach(function(el) {
1672
- el.checked = true;
1673
- });
1674
- savedInputChecked.length = lastDx = lastDy = 0;
1675
- },
1676
- handleEvent: function handleEvent(evt) {
1677
- switch (evt.type) {
1678
- case "drop":
1679
- case "dragend":
1680
- this._onDrop(evt);
1681
- break;
1682
- case "dragenter":
1683
- case "dragover":
1684
- if (dragEl) {
1685
- this._onDragOver(evt);
1686
- _globalDragOver(evt);
1687
- }
1688
- break;
1689
- case "selectstart":
1690
- evt.preventDefault();
1691
- break;
1692
- }
1693
- },
1694
- /**
1695
- * Serializes the item into an array of string.
1696
- * @returns {String[]}
1697
- */
1698
- toArray: function toArray() {
1699
- var order = [], el, children = this.el.children, i = 0, n = children.length, options = this.options;
1700
- for (; i < n; i++) {
1701
- el = children[i];
1702
- if (closest(el, options.draggable, this.el, false)) {
1703
- order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
1704
- }
1705
- }
1706
- return order;
1707
- },
1708
- /**
1709
- * Sorts the elements according to the array.
1710
- * @param {String[]} order order of the items
1711
- */
1712
- sort: function sort(order, useAnimation) {
1713
- var items = {}, rootEl2 = this.el;
1714
- this.toArray().forEach(function(id, i) {
1715
- var el = rootEl2.children[i];
1716
- if (closest(el, this.options.draggable, rootEl2, false)) {
1717
- items[id] = el;
1718
- }
1719
- }, this);
1720
- useAnimation && this.captureAnimationState();
1721
- order.forEach(function(id) {
1722
- if (items[id]) {
1723
- rootEl2.removeChild(items[id]);
1724
- rootEl2.appendChild(items[id]);
1725
- }
1726
- });
1727
- useAnimation && this.animateAll();
1728
- },
1729
- /**
1730
- * Save the current sorting
1731
- */
1732
- save: function save() {
1733
- var store = this.options.store;
1734
- store && store.set && store.set(this);
1735
- },
1736
- /**
1737
- * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
1738
- * @param {HTMLElement} el
1739
- * @param {String} [selector] default: `options.draggable`
1740
- * @returns {HTMLElement|null}
1741
- */
1742
- closest: function closest$1(el, selector) {
1743
- return closest(el, selector || this.options.draggable, this.el, false);
1744
- },
1745
- /**
1746
- * Set/get option
1747
- * @param {string} name
1748
- * @param {*} [value]
1749
- * @returns {*}
1750
- */
1751
- option: function option(name, value) {
1752
- var options = this.options;
1753
- if (value === void 0) {
1754
- return options[name];
1755
- } else {
1756
- var modifiedValue = PluginManager.modifyOption(this, name, value);
1757
- if (typeof modifiedValue !== "undefined") {
1758
- options[name] = modifiedValue;
1759
- } else {
1760
- options[name] = value;
1761
- }
1762
- if (name === "group") {
1763
- _prepareGroup(options);
1764
- }
1765
- }
1766
- },
1767
- /**
1768
- * Destroy
1769
- */
1770
- destroy: function destroy() {
1771
- pluginEvent2("destroy", this);
1772
- var el = this.el;
1773
- el[expando] = null;
1774
- off(el, "mousedown", this._onTapStart);
1775
- off(el, "touchstart", this._onTapStart);
1776
- off(el, "pointerdown", this._onTapStart);
1777
- if (this.nativeDraggable) {
1778
- off(el, "dragover", this);
1779
- off(el, "dragenter", this);
1780
- }
1781
- Array.prototype.forEach.call(el.querySelectorAll("[draggable]"), function(el2) {
1782
- el2.removeAttribute("draggable");
1783
- });
1784
- this._onDrop();
1785
- this._disableDelayedDragEvents();
1786
- sortables.splice(sortables.indexOf(this.el), 1);
1787
- this.el = el = null;
1788
- },
1789
- _hideClone: function _hideClone() {
1790
- if (!cloneHidden) {
1791
- pluginEvent2("hideClone", this);
1792
- if (Sortable.eventCanceled) return;
1793
- css(cloneEl, "display", "none");
1794
- if (this.options.removeCloneOnHide && cloneEl.parentNode) {
1795
- cloneEl.parentNode.removeChild(cloneEl);
1796
- }
1797
- cloneHidden = true;
1798
- }
1799
- },
1800
- _showClone: function _showClone(putSortable2) {
1801
- if (putSortable2.lastPutMode !== "clone") {
1802
- this._hideClone();
1803
- return;
1804
- }
1805
- if (cloneHidden) {
1806
- pluginEvent2("showClone", this);
1807
- if (Sortable.eventCanceled) return;
1808
- if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
1809
- rootEl.insertBefore(cloneEl, dragEl);
1810
- } else if (nextEl) {
1811
- rootEl.insertBefore(cloneEl, nextEl);
1812
- } else {
1813
- rootEl.appendChild(cloneEl);
1814
- }
1815
- if (this.options.group.revertClone) {
1816
- this.animate(dragEl, cloneEl);
1817
- }
1818
- css(cloneEl, "display", "");
1819
- cloneHidden = false;
1820
- }
1821
- }
1822
- };
1823
- function _globalDragOver(evt) {
1824
- if (evt.dataTransfer) {
1825
- evt.dataTransfer.dropEffect = "move";
1826
- }
1827
- evt.cancelable && evt.preventDefault();
1828
- }
1829
- function _onMove(fromEl, toEl, dragEl2, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
1830
- var evt, sortable = fromEl[expando], onMoveFn = sortable.options.onMove, retVal;
1831
- if (window.CustomEvent && !IE11OrLess && !Edge) {
1832
- evt = new CustomEvent("move", {
1833
- bubbles: true,
1834
- cancelable: true
1835
- });
1836
- } else {
1837
- evt = document.createEvent("Event");
1838
- evt.initEvent("move", true, true);
1839
- }
1840
- evt.to = toEl;
1841
- evt.from = fromEl;
1842
- evt.dragged = dragEl2;
1843
- evt.draggedRect = dragRect;
1844
- evt.related = targetEl || toEl;
1845
- evt.relatedRect = targetRect || getRect(toEl);
1846
- evt.willInsertAfter = willInsertAfter;
1847
- evt.originalEvent = originalEvent;
1848
- fromEl.dispatchEvent(evt);
1849
- if (onMoveFn) {
1850
- retVal = onMoveFn.call(sortable, evt, originalEvent);
1851
- }
1852
- return retVal;
1853
- }
1854
- function _disableDraggable(el) {
1855
- el.draggable = false;
1856
- }
1857
- function _unsilent() {
1858
- _silent = false;
1859
- }
1860
- function _ghostIsFirst(evt, vertical, sortable) {
1861
- var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
1862
- var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
1863
- var spacer = 10;
1864
- return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
1865
- }
1866
- function _ghostIsLast(evt, vertical, sortable) {
1867
- var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
1868
- var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
1869
- var spacer = 10;
1870
- return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
1871
- }
1872
- function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
1873
- var mouseOnAxis = vertical ? evt.clientY : evt.clientX, targetLength = vertical ? targetRect.height : targetRect.width, targetS1 = vertical ? targetRect.top : targetRect.left, targetS2 = vertical ? targetRect.bottom : targetRect.right, invert = false;
1874
- if (!invertSwap) {
1875
- if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
1876
- if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
1877
- pastFirstInvertThresh = true;
1878
- }
1879
- if (!pastFirstInvertThresh) {
1880
- if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance : mouseOnAxis > targetS2 - targetMoveDistance) {
1881
- return -lastDirection;
1882
- }
1883
- } else {
1884
- invert = true;
1885
- }
1886
- } else {
1887
- if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
1888
- return _getInsertDirection(target);
1889
- }
1890
- }
1891
- }
1892
- invert = invert || invertSwap;
1893
- if (invert) {
1894
- if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
1895
- return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
1896
- }
1897
- }
1898
- return 0;
1899
- }
1900
- function _getInsertDirection(target) {
1901
- if (index(dragEl) < index(target)) {
1902
- return 1;
1903
- } else {
1904
- return -1;
1905
- }
1906
- }
1907
- function _generateId(el) {
1908
- var str = el.tagName + el.className + el.src + el.href + el.textContent, i = str.length, sum = 0;
1909
- while (i--) {
1910
- sum += str.charCodeAt(i);
1911
- }
1912
- return sum.toString(36);
1913
- }
1914
- function _saveInputCheckedState(root) {
1915
- savedInputChecked.length = 0;
1916
- var inputs = root.getElementsByTagName("input");
1917
- var idx = inputs.length;
1918
- while (idx--) {
1919
- var el = inputs[idx];
1920
- el.checked && savedInputChecked.push(el);
1921
- }
1922
- }
1923
- function _nextTick(fn) {
1924
- return setTimeout(fn, 0);
1925
- }
1926
- function _cancelNextTick(id) {
1927
- return clearTimeout(id);
1928
- }
1929
- if (documentExists) {
1930
- on(document, "touchmove", function(evt) {
1931
- if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
1932
- evt.preventDefault();
1933
- }
1934
- });
1935
- }
1936
- Sortable.utils = {
1937
- on,
1938
- off,
1939
- css,
1940
- find,
1941
- is: function is(el, selector) {
1942
- return !!closest(el, selector, el, false);
1943
- },
1944
- extend,
1945
- throttle,
1946
- closest,
1947
- toggleClass,
1948
- clone,
1949
- index,
1950
- nextTick: _nextTick,
1951
- cancelNextTick: _cancelNextTick,
1952
- detectDirection: _detectDirection,
1953
- getChild,
1954
- expando
1955
- };
1956
- Sortable.get = function(element) {
1957
- return element[expando];
1958
- };
1959
- Sortable.mount = function() {
1960
- for (var _len = arguments.length, plugins2 = new Array(_len), _key = 0; _key < _len; _key++) {
1961
- plugins2[_key] = arguments[_key];
1962
- }
1963
- if (plugins2[0].constructor === Array) plugins2 = plugins2[0];
1964
- plugins2.forEach(function(plugin) {
1965
- if (!plugin.prototype || !plugin.prototype.constructor) {
1966
- throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
1967
- }
1968
- if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
1969
- PluginManager.mount(plugin);
1970
- });
1971
- };
1972
- Sortable.create = function(el, options) {
1973
- return new Sortable(el, options);
1974
- };
1975
- Sortable.version = version;
1976
- var autoScrolls = [], scrollEl, scrollRootEl, scrolling = false, lastAutoScrollX, lastAutoScrollY, touchEvt$1, pointerElemChangedInterval;
1977
- function AutoScrollPlugin() {
1978
- function AutoScroll() {
1979
- this.defaults = {
1980
- scroll: true,
1981
- forceAutoScrollFallback: false,
1982
- scrollSensitivity: 30,
1983
- scrollSpeed: 10,
1984
- bubbleScroll: true
1985
- };
1986
- for (var fn in this) {
1987
- if (fn.charAt(0) === "_" && typeof this[fn] === "function") {
1988
- this[fn] = this[fn].bind(this);
1989
- }
1990
- }
1991
- }
1992
- AutoScroll.prototype = {
1993
- dragStarted: function dragStarted2(_ref) {
1994
- var originalEvent = _ref.originalEvent;
1995
- if (this.sortable.nativeDraggable) {
1996
- on(document, "dragover", this._handleAutoScroll);
1997
- } else {
1998
- if (this.options.supportPointer) {
1999
- on(document, "pointermove", this._handleFallbackAutoScroll);
2000
- } else if (originalEvent.touches) {
2001
- on(document, "touchmove", this._handleFallbackAutoScroll);
2002
- } else {
2003
- on(document, "mousemove", this._handleFallbackAutoScroll);
2004
- }
2005
- }
2006
- },
2007
- dragOverCompleted: function dragOverCompleted(_ref2) {
2008
- var originalEvent = _ref2.originalEvent;
2009
- if (!this.options.dragOverBubble && !originalEvent.rootEl) {
2010
- this._handleAutoScroll(originalEvent);
2011
- }
2012
- },
2013
- drop: function drop3() {
2014
- if (this.sortable.nativeDraggable) {
2015
- off(document, "dragover", this._handleAutoScroll);
2016
- } else {
2017
- off(document, "pointermove", this._handleFallbackAutoScroll);
2018
- off(document, "touchmove", this._handleFallbackAutoScroll);
2019
- off(document, "mousemove", this._handleFallbackAutoScroll);
2020
- }
2021
- clearPointerElemChangedInterval();
2022
- clearAutoScrolls();
2023
- cancelThrottle();
2024
- },
2025
- nulling: function nulling() {
2026
- touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
2027
- autoScrolls.length = 0;
2028
- },
2029
- _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
2030
- this._handleAutoScroll(evt, true);
2031
- },
2032
- _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
2033
- var _this = this;
2034
- var x = (evt.touches ? evt.touches[0] : evt).clientX, y = (evt.touches ? evt.touches[0] : evt).clientY, elem = document.elementFromPoint(x, y);
2035
- touchEvt$1 = evt;
2036
- if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
2037
- autoScroll(evt, this.options, elem, fallback);
2038
- var ogElemScroller = getParentAutoScrollElement(elem, true);
2039
- if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
2040
- pointerElemChangedInterval && clearPointerElemChangedInterval();
2041
- pointerElemChangedInterval = setInterval(function() {
2042
- var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
2043
- if (newElem !== ogElemScroller) {
2044
- ogElemScroller = newElem;
2045
- clearAutoScrolls();
2046
- }
2047
- autoScroll(evt, _this.options, newElem, fallback);
2048
- }, 10);
2049
- lastAutoScrollX = x;
2050
- lastAutoScrollY = y;
2051
- }
2052
- } else {
2053
- if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
2054
- clearAutoScrolls();
2055
- return;
2056
- }
2057
- autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
2058
- }
2059
- }
2060
- };
2061
- return _extends(AutoScroll, {
2062
- pluginName: "scroll",
2063
- initializeByDefault: true
2064
- });
2065
- }
2066
- function clearAutoScrolls() {
2067
- autoScrolls.forEach(function(autoScroll2) {
2068
- clearInterval(autoScroll2.pid);
2069
- });
2070
- autoScrolls = [];
2071
- }
2072
- function clearPointerElemChangedInterval() {
2073
- clearInterval(pointerElemChangedInterval);
2074
- }
2075
- var autoScroll = throttle(function(evt, options, rootEl2, isFallback) {
2076
- if (!options.scroll) return;
2077
- var x = (evt.touches ? evt.touches[0] : evt).clientX, y = (evt.touches ? evt.touches[0] : evt).clientY, sens = options.scrollSensitivity, speed = options.scrollSpeed, winScroller = getWindowScrollingElement();
2078
- var scrollThisInstance = false, scrollCustomFn;
2079
- if (scrollRootEl !== rootEl2) {
2080
- scrollRootEl = rootEl2;
2081
- clearAutoScrolls();
2082
- scrollEl = options.scroll;
2083
- scrollCustomFn = options.scrollFn;
2084
- if (scrollEl === true) {
2085
- scrollEl = getParentAutoScrollElement(rootEl2, true);
2086
- }
2087
- }
2088
- var layersOut = 0;
2089
- var currentParent = scrollEl;
2090
- do {
2091
- var el = currentParent, rect = getRect(el), top = rect.top, bottom = rect.bottom, left = rect.left, right = rect.right, width = rect.width, height = rect.height, canScrollX = void 0, canScrollY = void 0, scrollWidth = el.scrollWidth, scrollHeight = el.scrollHeight, elCSS = css(el), scrollPosX = el.scrollLeft, scrollPosY = el.scrollTop;
2092
- if (el === winScroller) {
2093
- canScrollX = width < scrollWidth && (elCSS.overflowX === "auto" || elCSS.overflowX === "scroll" || elCSS.overflowX === "visible");
2094
- canScrollY = height < scrollHeight && (elCSS.overflowY === "auto" || elCSS.overflowY === "scroll" || elCSS.overflowY === "visible");
2095
- } else {
2096
- canScrollX = width < scrollWidth && (elCSS.overflowX === "auto" || elCSS.overflowX === "scroll");
2097
- canScrollY = height < scrollHeight && (elCSS.overflowY === "auto" || elCSS.overflowY === "scroll");
2098
- }
2099
- var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
2100
- var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
2101
- if (!autoScrolls[layersOut]) {
2102
- for (var i = 0; i <= layersOut; i++) {
2103
- if (!autoScrolls[i]) {
2104
- autoScrolls[i] = {};
2105
- }
2106
- }
2107
- }
2108
- if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
2109
- autoScrolls[layersOut].el = el;
2110
- autoScrolls[layersOut].vx = vx;
2111
- autoScrolls[layersOut].vy = vy;
2112
- clearInterval(autoScrolls[layersOut].pid);
2113
- if (vx != 0 || vy != 0) {
2114
- scrollThisInstance = true;
2115
- autoScrolls[layersOut].pid = setInterval((function() {
2116
- if (isFallback && this.layer === 0) {
2117
- Sortable.active._onTouchMove(touchEvt$1);
2118
- }
2119
- var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
2120
- var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
2121
- if (typeof scrollCustomFn === "function") {
2122
- if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== "continue") {
2123
- return;
2124
- }
2125
- }
2126
- scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
2127
- }).bind({
2128
- layer: layersOut
2129
- }), 24);
2130
- }
2131
- }
2132
- layersOut++;
2133
- } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
2134
- scrolling = scrollThisInstance;
2135
- }, 30);
2136
- var drop = function drop2(_ref) {
2137
- var originalEvent = _ref.originalEvent, putSortable2 = _ref.putSortable, dragEl2 = _ref.dragEl, activeSortable = _ref.activeSortable, dispatchSortableEvent = _ref.dispatchSortableEvent, hideGhostForTarget = _ref.hideGhostForTarget, unhideGhostForTarget = _ref.unhideGhostForTarget;
2138
- if (!originalEvent) return;
2139
- var toSortable = putSortable2 || activeSortable;
2140
- hideGhostForTarget();
2141
- var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
2142
- var target = document.elementFromPoint(touch.clientX, touch.clientY);
2143
- unhideGhostForTarget();
2144
- if (toSortable && !toSortable.el.contains(target)) {
2145
- dispatchSortableEvent("spill");
2146
- this.onSpill({
2147
- dragEl: dragEl2,
2148
- putSortable: putSortable2
2149
- });
2150
- }
2151
- };
2152
- function Revert() {
2153
- }
2154
- Revert.prototype = {
2155
- startIndex: null,
2156
- dragStart: function dragStart(_ref2) {
2157
- var oldDraggableIndex2 = _ref2.oldDraggableIndex;
2158
- this.startIndex = oldDraggableIndex2;
2159
- },
2160
- onSpill: function onSpill(_ref3) {
2161
- var dragEl2 = _ref3.dragEl, putSortable2 = _ref3.putSortable;
2162
- this.sortable.captureAnimationState();
2163
- if (putSortable2) {
2164
- putSortable2.captureAnimationState();
2165
- }
2166
- var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
2167
- if (nextSibling) {
2168
- this.sortable.el.insertBefore(dragEl2, nextSibling);
2169
- } else {
2170
- this.sortable.el.appendChild(dragEl2);
2171
- }
2172
- this.sortable.animateAll();
2173
- if (putSortable2) {
2174
- putSortable2.animateAll();
2175
- }
2176
- },
2177
- drop
2178
- };
2179
- _extends(Revert, {
2180
- pluginName: "revertOnSpill"
2181
- });
2182
- function Remove() {
2183
- }
2184
- Remove.prototype = {
2185
- onSpill: function onSpill2(_ref4) {
2186
- var dragEl2 = _ref4.dragEl, putSortable2 = _ref4.putSortable;
2187
- var parentSortable = putSortable2 || this.sortable;
2188
- parentSortable.captureAnimationState();
2189
- dragEl2.parentNode && dragEl2.parentNode.removeChild(dragEl2);
2190
- parentSortable.animateAll();
2191
- },
2192
- drop
2193
- };
2194
- _extends(Remove, {
2195
- pluginName: "removeOnSpill"
2196
- });
2197
- var lastSwapEl;
2198
- function SwapPlugin() {
2199
- function Swap() {
2200
- this.defaults = {
2201
- swapClass: "sortable-swap-highlight"
2202
- };
2203
- }
2204
- Swap.prototype = {
2205
- dragStart: function dragStart2(_ref) {
2206
- var dragEl2 = _ref.dragEl;
2207
- lastSwapEl = dragEl2;
2208
- },
2209
- dragOverValid: function dragOverValid(_ref2) {
2210
- var completed = _ref2.completed, target = _ref2.target, onMove = _ref2.onMove, activeSortable = _ref2.activeSortable, changed = _ref2.changed, cancel = _ref2.cancel;
2211
- if (!activeSortable.options.swap) return;
2212
- var el = this.sortable.el, options = this.options;
2213
- if (target && target !== el) {
2214
- var prevSwapEl = lastSwapEl;
2215
- if (onMove(target) !== false) {
2216
- toggleClass(target, options.swapClass, true);
2217
- lastSwapEl = target;
2218
- } else {
2219
- lastSwapEl = null;
2220
- }
2221
- if (prevSwapEl && prevSwapEl !== lastSwapEl) {
2222
- toggleClass(prevSwapEl, options.swapClass, false);
2223
- }
2224
- }
2225
- changed();
2226
- completed(true);
2227
- cancel();
2228
- },
2229
- drop: function drop3(_ref3) {
2230
- var activeSortable = _ref3.activeSortable, putSortable2 = _ref3.putSortable, dragEl2 = _ref3.dragEl;
2231
- var toSortable = putSortable2 || this.sortable;
2232
- var options = this.options;
2233
- lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
2234
- if (lastSwapEl && (options.swap || putSortable2 && putSortable2.options.swap)) {
2235
- if (dragEl2 !== lastSwapEl) {
2236
- toSortable.captureAnimationState();
2237
- if (toSortable !== activeSortable) activeSortable.captureAnimationState();
2238
- swapNodes(dragEl2, lastSwapEl);
2239
- toSortable.animateAll();
2240
- if (toSortable !== activeSortable) activeSortable.animateAll();
2241
- }
2242
- }
2243
- },
2244
- nulling: function nulling() {
2245
- lastSwapEl = null;
2246
- }
2247
- };
2248
- return _extends(Swap, {
2249
- pluginName: "swap",
2250
- eventProperties: function eventProperties() {
2251
- return {
2252
- swapItem: lastSwapEl
2253
- };
2254
- }
2255
- });
2256
- }
2257
- function swapNodes(n1, n2) {
2258
- var p1 = n1.parentNode, p2 = n2.parentNode, i1, i2;
2259
- if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return;
2260
- i1 = index(n1);
2261
- i2 = index(n2);
2262
- if (p1.isEqualNode(p2) && i1 < i2) {
2263
- i2++;
2264
- }
2265
- p1.insertBefore(n2, p1.children[i1]);
2266
- p2.insertBefore(n1, p2.children[i2]);
2267
- }
2268
- var multiDragElements = [], multiDragClones = [], lastMultiDragSelect, multiDragSortable, initialFolding = false, folding = false, dragStarted = false, dragEl$1, clonesFromRect, clonesHidden;
2269
- function MultiDragPlugin() {
2270
- function MultiDrag(sortable) {
2271
- for (var fn in this) {
2272
- if (fn.charAt(0) === "_" && typeof this[fn] === "function") {
2273
- this[fn] = this[fn].bind(this);
2274
- }
2275
- }
2276
- if (!sortable.options.avoidImplicitDeselect) {
2277
- if (sortable.options.supportPointer) {
2278
- on(document, "pointerup", this._deselectMultiDrag);
2279
- } else {
2280
- on(document, "mouseup", this._deselectMultiDrag);
2281
- on(document, "touchend", this._deselectMultiDrag);
2282
- }
2283
- }
2284
- on(document, "keydown", this._checkKeyDown);
2285
- on(document, "keyup", this._checkKeyUp);
2286
- this.defaults = {
2287
- selectedClass: "sortable-selected",
2288
- multiDragKey: null,
2289
- avoidImplicitDeselect: false,
2290
- setData: function setData(dataTransfer, dragEl2) {
2291
- var data = "";
2292
- if (multiDragElements.length && multiDragSortable === sortable) {
2293
- multiDragElements.forEach(function(multiDragElement, i) {
2294
- data += (!i ? "" : ", ") + multiDragElement.textContent;
2295
- });
2296
- } else {
2297
- data = dragEl2.textContent;
2298
- }
2299
- dataTransfer.setData("Text", data);
2300
- }
2301
- };
2302
- }
2303
- MultiDrag.prototype = {
2304
- multiDragKeyDown: false,
2305
- isMultiDrag: false,
2306
- delayStartGlobal: function delayStartGlobal(_ref) {
2307
- var dragged = _ref.dragEl;
2308
- dragEl$1 = dragged;
2309
- },
2310
- delayEnded: function delayEnded() {
2311
- this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1);
2312
- },
2313
- setupClone: function setupClone(_ref2) {
2314
- var sortable = _ref2.sortable, cancel = _ref2.cancel;
2315
- if (!this.isMultiDrag) return;
2316
- for (var i = 0; i < multiDragElements.length; i++) {
2317
- multiDragClones.push(clone(multiDragElements[i]));
2318
- multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex;
2319
- multiDragClones[i].draggable = false;
2320
- multiDragClones[i].style["will-change"] = "";
2321
- toggleClass(multiDragClones[i], this.options.selectedClass, false);
2322
- multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false);
2323
- }
2324
- sortable._hideClone();
2325
- cancel();
2326
- },
2327
- clone: function clone2(_ref3) {
2328
- var sortable = _ref3.sortable, rootEl2 = _ref3.rootEl, dispatchSortableEvent = _ref3.dispatchSortableEvent, cancel = _ref3.cancel;
2329
- if (!this.isMultiDrag) return;
2330
- if (!this.options.removeCloneOnHide) {
2331
- if (multiDragElements.length && multiDragSortable === sortable) {
2332
- insertMultiDragClones(true, rootEl2);
2333
- dispatchSortableEvent("clone");
2334
- cancel();
2335
- }
2336
- }
2337
- },
2338
- showClone: function showClone(_ref4) {
2339
- var cloneNowShown = _ref4.cloneNowShown, rootEl2 = _ref4.rootEl, cancel = _ref4.cancel;
2340
- if (!this.isMultiDrag) return;
2341
- insertMultiDragClones(false, rootEl2);
2342
- multiDragClones.forEach(function(clone2) {
2343
- css(clone2, "display", "");
2344
- });
2345
- cloneNowShown();
2346
- clonesHidden = false;
2347
- cancel();
2348
- },
2349
- hideClone: function hideClone(_ref5) {
2350
- var _this = this;
2351
- var sortable = _ref5.sortable, cloneNowHidden = _ref5.cloneNowHidden, cancel = _ref5.cancel;
2352
- if (!this.isMultiDrag) return;
2353
- multiDragClones.forEach(function(clone2) {
2354
- css(clone2, "display", "none");
2355
- if (_this.options.removeCloneOnHide && clone2.parentNode) {
2356
- clone2.parentNode.removeChild(clone2);
2357
- }
2358
- });
2359
- cloneNowHidden();
2360
- clonesHidden = true;
2361
- cancel();
2362
- },
2363
- dragStartGlobal: function dragStartGlobal(_ref6) {
2364
- var sortable = _ref6.sortable;
2365
- if (!this.isMultiDrag && multiDragSortable) {
2366
- multiDragSortable.multiDrag._deselectMultiDrag();
2367
- }
2368
- multiDragElements.forEach(function(multiDragElement) {
2369
- multiDragElement.sortableIndex = index(multiDragElement);
2370
- });
2371
- multiDragElements = multiDragElements.sort(function(a, b) {
2372
- return a.sortableIndex - b.sortableIndex;
2373
- });
2374
- dragStarted = true;
2375
- },
2376
- dragStarted: function dragStarted2(_ref7) {
2377
- var _this2 = this;
2378
- var sortable = _ref7.sortable;
2379
- if (!this.isMultiDrag) return;
2380
- if (this.options.sort) {
2381
- sortable.captureAnimationState();
2382
- if (this.options.animation) {
2383
- multiDragElements.forEach(function(multiDragElement) {
2384
- if (multiDragElement === dragEl$1) return;
2385
- css(multiDragElement, "position", "absolute");
2386
- });
2387
- var dragRect = getRect(dragEl$1, false, true, true);
2388
- multiDragElements.forEach(function(multiDragElement) {
2389
- if (multiDragElement === dragEl$1) return;
2390
- setRect(multiDragElement, dragRect);
2391
- });
2392
- folding = true;
2393
- initialFolding = true;
2394
- }
2395
- }
2396
- sortable.animateAll(function() {
2397
- folding = false;
2398
- initialFolding = false;
2399
- if (_this2.options.animation) {
2400
- multiDragElements.forEach(function(multiDragElement) {
2401
- unsetRect(multiDragElement);
2402
- });
2403
- }
2404
- if (_this2.options.sort) {
2405
- removeMultiDragElements();
2406
- }
2407
- });
2408
- },
2409
- dragOver: function dragOver(_ref8) {
2410
- var target = _ref8.target, completed = _ref8.completed, cancel = _ref8.cancel;
2411
- if (folding && ~multiDragElements.indexOf(target)) {
2412
- completed(false);
2413
- cancel();
2414
- }
2415
- },
2416
- revert: function revert(_ref9) {
2417
- var fromSortable = _ref9.fromSortable, rootEl2 = _ref9.rootEl, sortable = _ref9.sortable, dragRect = _ref9.dragRect;
2418
- if (multiDragElements.length > 1) {
2419
- multiDragElements.forEach(function(multiDragElement) {
2420
- sortable.addAnimationState({
2421
- target: multiDragElement,
2422
- rect: folding ? getRect(multiDragElement) : dragRect
2423
- });
2424
- unsetRect(multiDragElement);
2425
- multiDragElement.fromRect = dragRect;
2426
- fromSortable.removeAnimationState(multiDragElement);
2427
- });
2428
- folding = false;
2429
- insertMultiDragElements(!this.options.removeCloneOnHide, rootEl2);
2430
- }
2431
- },
2432
- dragOverCompleted: function dragOverCompleted(_ref10) {
2433
- var sortable = _ref10.sortable, isOwner = _ref10.isOwner, insertion = _ref10.insertion, activeSortable = _ref10.activeSortable, parentEl2 = _ref10.parentEl, putSortable2 = _ref10.putSortable;
2434
- var options = this.options;
2435
- if (insertion) {
2436
- if (isOwner) {
2437
- activeSortable._hideClone();
2438
- }
2439
- initialFolding = false;
2440
- if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable2)) {
2441
- var dragRectAbsolute = getRect(dragEl$1, false, true, true);
2442
- multiDragElements.forEach(function(multiDragElement) {
2443
- if (multiDragElement === dragEl$1) return;
2444
- setRect(multiDragElement, dragRectAbsolute);
2445
- parentEl2.appendChild(multiDragElement);
2446
- });
2447
- folding = true;
2448
- }
2449
- if (!isOwner) {
2450
- if (!folding) {
2451
- removeMultiDragElements();
2452
- }
2453
- if (multiDragElements.length > 1) {
2454
- var clonesHiddenBefore = clonesHidden;
2455
- activeSortable._showClone(sortable);
2456
- if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) {
2457
- multiDragClones.forEach(function(clone2) {
2458
- activeSortable.addAnimationState({
2459
- target: clone2,
2460
- rect: clonesFromRect
2461
- });
2462
- clone2.fromRect = clonesFromRect;
2463
- clone2.thisAnimationDuration = null;
2464
- });
2465
- }
2466
- } else {
2467
- activeSortable._showClone(sortable);
2468
- }
2469
- }
2470
- }
2471
- },
2472
- dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) {
2473
- var dragRect = _ref11.dragRect, isOwner = _ref11.isOwner, activeSortable = _ref11.activeSortable;
2474
- multiDragElements.forEach(function(multiDragElement) {
2475
- multiDragElement.thisAnimationDuration = null;
2476
- });
2477
- if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
2478
- clonesFromRect = _extends({}, dragRect);
2479
- var dragMatrix = matrix(dragEl$1, true);
2480
- clonesFromRect.top -= dragMatrix.f;
2481
- clonesFromRect.left -= dragMatrix.e;
2482
- }
2483
- },
2484
- dragOverAnimationComplete: function dragOverAnimationComplete() {
2485
- if (folding) {
2486
- folding = false;
2487
- removeMultiDragElements();
2488
- }
2489
- },
2490
- drop: function drop3(_ref12) {
2491
- var evt = _ref12.originalEvent, rootEl2 = _ref12.rootEl, parentEl2 = _ref12.parentEl, sortable = _ref12.sortable, dispatchSortableEvent = _ref12.dispatchSortableEvent, oldIndex2 = _ref12.oldIndex, putSortable2 = _ref12.putSortable;
2492
- var toSortable = putSortable2 || this.sortable;
2493
- if (!evt) return;
2494
- var options = this.options, children = parentEl2.children;
2495
- if (!dragStarted) {
2496
- if (options.multiDragKey && !this.multiDragKeyDown) {
2497
- this._deselectMultiDrag();
2498
- }
2499
- toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1));
2500
- if (!~multiDragElements.indexOf(dragEl$1)) {
2501
- multiDragElements.push(dragEl$1);
2502
- dispatchEvent({
2503
- sortable,
2504
- rootEl: rootEl2,
2505
- name: "select",
2506
- targetEl: dragEl$1,
2507
- originalEvent: evt
2508
- });
2509
- if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
2510
- var lastIndex = index(lastMultiDragSelect), currentIndex = index(dragEl$1);
2511
- if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
2512
- (function() {
2513
- var n, i;
2514
- if (currentIndex > lastIndex) {
2515
- i = lastIndex;
2516
- n = currentIndex;
2517
- } else {
2518
- i = currentIndex;
2519
- n = lastIndex + 1;
2520
- }
2521
- var filter = options.filter;
2522
- for (; i < n; i++) {
2523
- if (~multiDragElements.indexOf(children[i])) continue;
2524
- if (!closest(children[i], options.draggable, parentEl2, false)) continue;
2525
- var filtered = filter && (typeof filter === "function" ? filter.call(sortable, evt, children[i], sortable) : filter.split(",").some(function(criteria) {
2526
- return closest(children[i], criteria.trim(), parentEl2, false);
2527
- }));
2528
- if (filtered) continue;
2529
- toggleClass(children[i], options.selectedClass, true);
2530
- multiDragElements.push(children[i]);
2531
- dispatchEvent({
2532
- sortable,
2533
- rootEl: rootEl2,
2534
- name: "select",
2535
- targetEl: children[i],
2536
- originalEvent: evt
2537
- });
2538
- }
2539
- })();
2540
- }
2541
- } else {
2542
- lastMultiDragSelect = dragEl$1;
2543
- }
2544
- multiDragSortable = toSortable;
2545
- } else {
2546
- multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1);
2547
- lastMultiDragSelect = null;
2548
- dispatchEvent({
2549
- sortable,
2550
- rootEl: rootEl2,
2551
- name: "deselect",
2552
- targetEl: dragEl$1,
2553
- originalEvent: evt
2554
- });
2555
- }
2556
- }
2557
- if (dragStarted && this.isMultiDrag) {
2558
- folding = false;
2559
- if ((parentEl2[expando].options.sort || parentEl2 !== rootEl2) && multiDragElements.length > 1) {
2560
- var dragRect = getRect(dragEl$1), multiDragIndex = index(dragEl$1, ":not(." + this.options.selectedClass + ")");
2561
- if (!initialFolding && options.animation) dragEl$1.thisAnimationDuration = null;
2562
- toSortable.captureAnimationState();
2563
- if (!initialFolding) {
2564
- if (options.animation) {
2565
- dragEl$1.fromRect = dragRect;
2566
- multiDragElements.forEach(function(multiDragElement) {
2567
- multiDragElement.thisAnimationDuration = null;
2568
- if (multiDragElement !== dragEl$1) {
2569
- var rect = folding ? getRect(multiDragElement) : dragRect;
2570
- multiDragElement.fromRect = rect;
2571
- toSortable.addAnimationState({
2572
- target: multiDragElement,
2573
- rect
2574
- });
2575
- }
2576
- });
2577
- }
2578
- removeMultiDragElements();
2579
- multiDragElements.forEach(function(multiDragElement) {
2580
- if (children[multiDragIndex]) {
2581
- parentEl2.insertBefore(multiDragElement, children[multiDragIndex]);
2582
- } else {
2583
- parentEl2.appendChild(multiDragElement);
2584
- }
2585
- multiDragIndex++;
2586
- });
2587
- if (oldIndex2 === index(dragEl$1)) {
2588
- var update = false;
2589
- multiDragElements.forEach(function(multiDragElement) {
2590
- if (multiDragElement.sortableIndex !== index(multiDragElement)) {
2591
- update = true;
2592
- return;
2593
- }
2594
- });
2595
- if (update) {
2596
- dispatchSortableEvent("update");
2597
- dispatchSortableEvent("sort");
2598
- }
2599
- }
2600
- }
2601
- multiDragElements.forEach(function(multiDragElement) {
2602
- unsetRect(multiDragElement);
2603
- });
2604
- toSortable.animateAll();
2605
- }
2606
- multiDragSortable = toSortable;
2607
- }
2608
- if (rootEl2 === parentEl2 || putSortable2 && putSortable2.lastPutMode !== "clone") {
2609
- multiDragClones.forEach(function(clone2) {
2610
- clone2.parentNode && clone2.parentNode.removeChild(clone2);
2611
- });
2612
- }
2613
- },
2614
- nullingGlobal: function nullingGlobal() {
2615
- this.isMultiDrag = dragStarted = false;
2616
- multiDragClones.length = 0;
2617
- },
2618
- destroyGlobal: function destroyGlobal() {
2619
- this._deselectMultiDrag();
2620
- off(document, "pointerup", this._deselectMultiDrag);
2621
- off(document, "mouseup", this._deselectMultiDrag);
2622
- off(document, "touchend", this._deselectMultiDrag);
2623
- off(document, "keydown", this._checkKeyDown);
2624
- off(document, "keyup", this._checkKeyUp);
2625
- },
2626
- _deselectMultiDrag: function _deselectMultiDrag(evt) {
2627
- if (typeof dragStarted !== "undefined" && dragStarted) return;
2628
- if (multiDragSortable !== this.sortable) return;
2629
- if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false)) return;
2630
- if (evt && evt.button !== 0) return;
2631
- while (multiDragElements.length) {
2632
- var el = multiDragElements[0];
2633
- toggleClass(el, this.options.selectedClass, false);
2634
- multiDragElements.shift();
2635
- dispatchEvent({
2636
- sortable: this.sortable,
2637
- rootEl: this.sortable.el,
2638
- name: "deselect",
2639
- targetEl: el,
2640
- originalEvent: evt
2641
- });
2642
- }
2643
- },
2644
- _checkKeyDown: function _checkKeyDown(evt) {
2645
- if (evt.key === this.options.multiDragKey) {
2646
- this.multiDragKeyDown = true;
2647
- }
2648
- },
2649
- _checkKeyUp: function _checkKeyUp(evt) {
2650
- if (evt.key === this.options.multiDragKey) {
2651
- this.multiDragKeyDown = false;
2652
- }
2653
- }
2654
- };
2655
- return _extends(MultiDrag, {
2656
- // Static methods & properties
2657
- pluginName: "multiDrag",
2658
- utils: {
2659
- /**
2660
- * Selects the provided multi-drag item
2661
- * @param {HTMLElement} el The element to be selected
2662
- */
2663
- select: function select(el) {
2664
- var sortable = el.parentNode[expando];
2665
- if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el)) return;
2666
- if (multiDragSortable && multiDragSortable !== sortable) {
2667
- multiDragSortable.multiDrag._deselectMultiDrag();
2668
- multiDragSortable = sortable;
2669
- }
2670
- toggleClass(el, sortable.options.selectedClass, true);
2671
- multiDragElements.push(el);
2672
- },
2673
- /**
2674
- * Deselects the provided multi-drag item
2675
- * @param {HTMLElement} el The element to be deselected
2676
- */
2677
- deselect: function deselect(el) {
2678
- var sortable = el.parentNode[expando], index2 = multiDragElements.indexOf(el);
2679
- if (!sortable || !sortable.options.multiDrag || !~index2) return;
2680
- toggleClass(el, sortable.options.selectedClass, false);
2681
- multiDragElements.splice(index2, 1);
2682
- }
2683
- },
2684
- eventProperties: function eventProperties() {
2685
- var _this3 = this;
2686
- var oldIndicies = [], newIndicies = [];
2687
- multiDragElements.forEach(function(multiDragElement) {
2688
- oldIndicies.push({
2689
- multiDragElement,
2690
- index: multiDragElement.sortableIndex
2691
- });
2692
- var newIndex2;
2693
- if (folding && multiDragElement !== dragEl$1) {
2694
- newIndex2 = -1;
2695
- } else if (folding) {
2696
- newIndex2 = index(multiDragElement, ":not(." + _this3.options.selectedClass + ")");
2697
- } else {
2698
- newIndex2 = index(multiDragElement);
2699
- }
2700
- newIndicies.push({
2701
- multiDragElement,
2702
- index: newIndex2
2703
- });
2704
- });
2705
- return {
2706
- items: _toConsumableArray(multiDragElements),
2707
- clones: [].concat(multiDragClones),
2708
- oldIndicies,
2709
- newIndicies
2710
- };
2711
- },
2712
- optionListeners: {
2713
- multiDragKey: function multiDragKey(key) {
2714
- key = key.toLowerCase();
2715
- if (key === "ctrl") {
2716
- key = "Control";
2717
- } else if (key.length > 1) {
2718
- key = key.charAt(0).toUpperCase() + key.substr(1);
2719
- }
2720
- return key;
2721
- }
2722
- }
2723
- });
2724
- }
2725
- function insertMultiDragElements(clonesInserted, rootEl2) {
2726
- multiDragElements.forEach(function(multiDragElement, i) {
2727
- var target = rootEl2.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
2728
- if (target) {
2729
- rootEl2.insertBefore(multiDragElement, target);
2730
- } else {
2731
- rootEl2.appendChild(multiDragElement);
2732
- }
2733
- });
2734
- }
2735
- function insertMultiDragClones(elementsInserted, rootEl2) {
2736
- multiDragClones.forEach(function(clone2, i) {
2737
- var target = rootEl2.children[clone2.sortableIndex + (elementsInserted ? Number(i) : 0)];
2738
- if (target) {
2739
- rootEl2.insertBefore(clone2, target);
2740
- } else {
2741
- rootEl2.appendChild(clone2);
2742
- }
2743
- });
2744
- }
2745
- function removeMultiDragElements() {
2746
- multiDragElements.forEach(function(multiDragElement) {
2747
- if (multiDragElement === dragEl$1) return;
2748
- multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
2749
- });
2750
- }
2751
- Sortable.mount(new AutoScrollPlugin());
2752
- Sortable.mount(Remove, Revert);
2753
- export {
2754
- MultiDragPlugin as MultiDrag,
2755
- Sortable,
2756
- SwapPlugin as Swap,
2757
- Sortable as default
2758
- };